Merge pull request #12006 from annando/constants
Some more constants are moved to their specific classes
This commit is contained in:
commit
54951b7be6
17
boot.php
17
boot.php
|
@ -32,8 +32,6 @@ use Friendica\Model\Contact;
|
|||
define('FRIENDICA_PLATFORM', 'Friendica');
|
||||
define('FRIENDICA_CODENAME', 'Giant Rhubarb');
|
||||
define('FRIENDICA_VERSION', '2022.12-dev');
|
||||
define('DFRN_PROTOCOL_VERSION', '2.23');
|
||||
define('NEW_TABLE_STRUCTURE_VERSION', 1288);
|
||||
|
||||
/**
|
||||
* Constant with a HTML line break.
|
||||
|
@ -44,21 +42,6 @@ define('NEW_TABLE_STRUCTURE_VERSION', 1288);
|
|||
*/
|
||||
define('EOL', "<br />\r\n");
|
||||
|
||||
/**
|
||||
* @name CP
|
||||
*
|
||||
* Type of the community page
|
||||
* @{
|
||||
*/
|
||||
define('CP_NO_INTERNAL_COMMUNITY', -2);
|
||||
define('CP_NO_COMMUNITY_PAGE', -1);
|
||||
define('CP_USERS_ON_SERVER', 0);
|
||||
define('CP_GLOBAL_COMMUNITY', 1);
|
||||
define('CP_USERS_AND_GLOBAL', 2);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Gravity
|
||||
*
|
||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Conversation\Community;
|
||||
|
||||
class Nav
|
||||
{
|
||||
|
@ -251,8 +252,8 @@ class Nav
|
|||
}
|
||||
}
|
||||
|
||||
if ((local_user() || DI::config()->get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) &&
|
||||
!(DI::config()->get('system', 'community_page_style') == CP_NO_INTERNAL_COMMUNITY)) {
|
||||
if ((local_user() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
|
||||
!(DI::config()->get('system', 'community_page_style') == Community::DISABLED)) {
|
||||
$nav['community'] = ['community', DI::l10n()->t('Community'), '', DI::l10n()->t('Conversations on this and other servers')];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ class Update
|
|||
const SUCCESS = 0;
|
||||
const FAILED = 1;
|
||||
|
||||
const NEW_TABLE_STRUCTURE_VERSION = 1288;
|
||||
|
||||
/**
|
||||
* Function to check if the Database structure needs an update.
|
||||
*
|
||||
|
@ -63,7 +65,7 @@ class Update
|
|||
}
|
||||
|
||||
// We don't support upgrading from very old versions anymore
|
||||
if ($build < NEW_TABLE_STRUCTURE_VERSION) {
|
||||
if ($build < self::NEW_TABLE_STRUCTURE_VERSION) {
|
||||
$error = DI::l10n()->t('Updates from version %s are not supported. Please update at least to version 2021.01 and wait until the postupdate finished version 1383.', $build);
|
||||
if (DI::mode()->getExecutor() == Mode::INDEX) {
|
||||
die($error);
|
||||
|
@ -73,8 +75,8 @@ class Update
|
|||
}
|
||||
|
||||
// The postupdate has to completed version 1288 for the new post views to take over
|
||||
$postupdate = DI::config()->get('system', 'post_update_version', NEW_TABLE_STRUCTURE_VERSION);
|
||||
if ($postupdate < NEW_TABLE_STRUCTURE_VERSION) {
|
||||
$postupdate = DI::config()->get('system', 'post_update_version', self::NEW_TABLE_STRUCTURE_VERSION);
|
||||
if ($postupdate < self::NEW_TABLE_STRUCTURE_VERSION) {
|
||||
$error = DI::l10n()->t('Updates from postupdate version %s are not supported. Please update at least to version 2021.01 and wait until the postupdate finished version 1383.', $postupdate);
|
||||
if (DI::mode()->getExecutor() == Mode::INDEX) {
|
||||
die($error);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Relocate;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\System;
|
||||
|
@ -33,12 +32,11 @@ use Friendica\DI;
|
|||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseAdmin;
|
||||
use Friendica\Module\Conversation\Community;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\EMailer\MailBuilder;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
require_once __DIR__ . '/../../../boot.php';
|
||||
|
||||
|
@ -364,11 +362,11 @@ class Site extends BaseAdmin
|
|||
|
||||
/* Community page style */
|
||||
$community_page_style_choices = [
|
||||
CP_NO_INTERNAL_COMMUNITY => DI::l10n()->t('No community page for local users'),
|
||||
CP_NO_COMMUNITY_PAGE => DI::l10n()->t('No community page'),
|
||||
CP_USERS_ON_SERVER => DI::l10n()->t('Public postings from users of this site'),
|
||||
CP_GLOBAL_COMMUNITY => DI::l10n()->t('Public postings from the federated network'),
|
||||
CP_USERS_AND_GLOBAL => DI::l10n()->t('Public postings from local users and the federated network')
|
||||
Community::DISABLED => DI::l10n()->t('No community page'),
|
||||
Community::DISABLED_VISITOR => DI::l10n()->t('No community page for visitors'),
|
||||
Community::LOCAL => DI::l10n()->t('Public postings from users of this site'),
|
||||
Community::GLOBAL => DI::l10n()->t('Public postings from the federated network'),
|
||||
Community::LOCAL_AND_GLOBAL => DI::l10n()->t('Public postings from local users and the federated network')
|
||||
];
|
||||
|
||||
/* get user names to make the install a personal install of X */
|
||||
|
|
|
@ -55,7 +55,6 @@ class Config extends BaseApi
|
|||
'friendica' => [
|
||||
'FRIENDICA_PLATFORM' => FRIENDICA_PLATFORM,
|
||||
'FRIENDICA_VERSION' => FRIENDICA_VERSION,
|
||||
'DFRN_PROTOCOL_VERSION' => DFRN_PROTOCOL_VERSION,
|
||||
'DB_UPDATE_VERSION' => DB_UPDATE_VERSION,
|
||||
]
|
||||
],
|
||||
|
|
|
@ -40,6 +40,21 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class Community extends BaseModule
|
||||
{
|
||||
/**
|
||||
* @name CP
|
||||
*
|
||||
* Type of the community page
|
||||
* @{
|
||||
*/
|
||||
const DISABLED = -2;
|
||||
const DISABLED_VISITOR = -1;
|
||||
const LOCAL = 0;
|
||||
const GLOBAL = 1;
|
||||
const LOCAL_AND_GLOBAL = 2;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
protected static $page_style;
|
||||
protected static $content;
|
||||
protected static $accountTypeString;
|
||||
|
@ -69,7 +84,7 @@ class Community extends BaseModule
|
|||
if (empty($_GET['mode']) || ($_GET['mode'] != 'raw')) {
|
||||
$tabs = [];
|
||||
|
||||
if ((Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(DI::config()->get('system', 'singleuser'))) {
|
||||
if ((Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::LOCAL])) && empty(DI::config()->get('system', 'singleuser'))) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Local Community'),
|
||||
'url' => 'community/local',
|
||||
|
@ -80,7 +95,7 @@ class Community extends BaseModule
|
|||
];
|
||||
}
|
||||
|
||||
if (Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
|
||||
if (Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::GLOBAL])) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Global Community'),
|
||||
'url' => 'community/global',
|
||||
|
@ -177,7 +192,7 @@ class Community extends BaseModule
|
|||
|
||||
self::$page_style = DI::config()->get('system', 'community_page_style');
|
||||
|
||||
if (self::$page_style == CP_NO_INTERNAL_COMMUNITY) {
|
||||
if (self::$page_style == self::DISABLED) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
|
||||
}
|
||||
|
||||
|
@ -191,7 +206,7 @@ class Community extends BaseModule
|
|||
self::$content = 'global';
|
||||
} else {
|
||||
// When only the global community is allowed, we use this as default
|
||||
self::$content = self::$page_style == CP_GLOBAL_COMMUNITY ? 'global' : 'local';
|
||||
self::$content = self::$page_style == self::GLOBAL ? 'global' : 'local';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,14 +216,14 @@ class Community extends BaseModule
|
|||
|
||||
// Check if we are allowed to display the content to visitors
|
||||
if (!Session::isAuthenticated()) {
|
||||
$available = self::$page_style == CP_USERS_AND_GLOBAL;
|
||||
$available = self::$page_style == self::LOCAL_AND_GLOBAL;
|
||||
|
||||
if (!$available) {
|
||||
$available = (self::$page_style == CP_USERS_ON_SERVER) && (self::$content == 'local');
|
||||
$available = (self::$page_style == self::LOCAL) && (self::$content == 'local');
|
||||
}
|
||||
|
||||
if (!$available) {
|
||||
$available = (self::$page_style == CP_GLOBAL_COMMUNITY) && (self::$content == 'global');
|
||||
$available = (self::$page_style == self::GLOBAL) && (self::$content == 'global');
|
||||
}
|
||||
|
||||
if (!$available) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user