X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp.php;h=e8385b7f29491b28dac1cd93e9db8663157829aa;hb=44b2b97e80624aca5768511def80a95f0e6e0381;hp=27eaf100f490e7908abcea41d6e96695320cd060;hpb=a7e9457ef2417b74aadfe3640f1ed2e2b332c1fd;p=friendica.git diff --git a/src/App.php b/src/App.php index 27eaf100f4..e8385b7f29 100644 --- a/src/App.php +++ b/src/App.php @@ -27,6 +27,9 @@ use Friendica\App\BaseURL; use Friendica\Capabilities\ICanCreateResponses; use Friendica\Core\Config\Factory\Config; use Friendica\Core\Session\Capability\IHandleUserSessions; +use Friendica\Database\Definition\DbaDefinition; +use Friendica\Database\Definition\ViewDefinition; +use Friendica\Model\User; use Friendica\Module\Maintenance; use Friendica\Security\Authentication; use Friendica\Core\Config\ValueObject\Cache; @@ -61,14 +64,13 @@ class App { const PLATFORM = 'Friendica'; const CODENAME = 'Giant Rhubarb'; - const VERSION = '2022.12-dev'; + const VERSION = '2022.12-rc'; // Allow themes to control internal parameters // by changing App values in theme.php private $theme_info = [ 'videowidth' => 425, 'videoheight' => 350, - 'events_in_profile' => true ]; private $user_id = 0; @@ -164,14 +166,16 @@ class App * Check if current user has admin role. * * @return bool true if user is an admin + * @throws Exception */ public function isSiteAdmin(): bool { - $admin_email = $this->config->get('config', 'admin_email'); - - $adminlist = explode(',', str_replace(' ', '', $admin_email)); - - return $this->session->getLocalUserId() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]); + return + $this->session->getLocalUserId() + && $this->database->exists('user', [ + 'uid' => $this->getLoggedInUserId(), + 'email' => User::getAdminEmailList() + ]); } /** @@ -259,8 +263,8 @@ class App /** * Set workerqueue information * - * @param array $queue - * @return void + * @param array $queue + * @return void */ public function setQueue(array $queue) { @@ -335,27 +339,29 @@ class App * @param App\Arguments $args The Friendica Arguments of the call * @param IManagePersonalConfigValues $pConfig Personal configuration * @param IHandleUserSessions $session The (User)Session handler + * @param DbaDefinition $dbaDefinition + * @param ViewDefinition $viewDefinition */ - public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session) + public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition) { - $this->database = $database; - $this->config = $config; - $this->mode = $mode; - $this->baseURL = $baseURL; - $this->profiler = $profiler; - $this->logger = $logger; - $this->l10n = $l10n; - $this->args = $args; - $this->pConfig = $pConfig; - $this->session = $session; + $this->database = $database; + $this->config = $config; + $this->mode = $mode; + $this->baseURL = $baseURL; + $this->profiler = $profiler; + $this->logger = $logger; + $this->l10n = $l10n; + $this->args = $args; + $this->pConfig = $pConfig; + $this->session = $session; - $this->load(); + $this->load($dbaDefinition, $viewDefinition); } /** * Load the whole app instance */ - public function load() + protected function load(DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition) { set_time_limit(0); @@ -384,6 +390,10 @@ class App Core\Hook::loadHooks(); $loader = (new Config())->createConfigFileLoader($this->getBasePath(), $_SERVER); Core\Hook::callAll('load_config', $loader); + + // Hooks are now working, reload the whole definitions with hook enabled + $dbaDefinition->load(true); + $viewDefinition->load(true); } $this->loadDefaultTimezone(); @@ -629,10 +639,10 @@ class App // ZRL if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->session->getLocalUserId()) { - // Only continue when the given profile link seems valid + // Only continue when the given profile link seems valid. // Valid profile links contain a path with "/profile/" and no query parameters if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') && - strstr(parse_url($_GET['zrl'], PHP_URL_PATH), '/profile/')) { + strpos(parse_url($_GET['zrl'], PHP_URL_PATH) ?? '', '/profile/') !== false) { if ($this->session->get('visitor_home') != $_GET['zrl']) { $this->session->set('my_url', $_GET['zrl']); $this->session->set('authenticated', 0);