]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/BaseAdmin.php
Move mod/cal.php and mod/events.php to Module
[friendica.git] / src / Module / BaseAdmin.php
index 90b246e432f0640cea9aa080207afbf456d2690b..1c9fc0f2446ab41759eaa85cfe58ab567a7c3206 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,12 +24,9 @@ namespace Friendica\Module;
 use Friendica\BaseModule;
 use Friendica\Core\Addon;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Network\HTTPException;
 
-require_once 'boot.php';
-
 /**
  * This abstract module is meant to be extended by all modules that are reserved to administrator users.
  *
@@ -43,32 +40,35 @@ require_once 'boot.php';
 abstract class BaseAdmin extends BaseModule
 {
        /**
+        * Checks admin access and throws exceptions if not logged-in administrator
+        *
         * @param bool $interactive
+        * @return void
         * @throws HTTPException\ForbiddenException
         * @throws HTTPException\InternalServerErrorException
         */
        public static function checkAdminAccess(bool $interactive = false)
        {
-               if (!local_user()) {
+               if (!DI::userSession()->getLocalUserId()) {
                        if ($interactive) {
-                               notice(DI::l10n()->t('Please login to continue.'));
-                               Session::set('return_path', DI::args()->getQueryString());
+                               DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.'));
+                               DI::session()->set('return_path', DI::args()->getQueryString());
                                DI::baseUrl()->redirect('login');
                        } else {
                                throw new HTTPException\UnauthorizedException(DI::l10n()->t('Please login to continue.'));
                        }
                }
 
-               if (!is_site_admin()) {
+               if (!DI::app()->isSiteAdmin()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
                }
 
-               if (!empty($_SESSION['submanage'])) {
+               if (DI::userSession()->getSubManagedUserId()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Submanaged account can\'t access the administration pages. Please log back in as the main account.'));
                }
        }
 
-       public static function content(array $parameters = [])
+       protected function content(array $request = []): string
        {
                self::checkAdminAccess(true);
 
@@ -88,6 +88,7 @@ abstract class BaseAdmin extends BaseModule
                        ]],
                        'configuration' => [DI::l10n()->t('Configuration'), [
                                'site'         => ['admin/site'        , DI::l10n()->t('Site')                    , 'site'],
+                               'storage'      => ['admin/storage'     , DI::l10n()->t('Storage')                 , 'storage'],
                                'users'        => ['admin/users'       , DI::l10n()->t('Users')                   , 'users'],
                                'addons'       => ['admin/addons'      , DI::l10n()->t('Addons')                  , 'addons'],
                                'themes'       => ['admin/themes'      , DI::l10n()->t('Themes')                  , 'themes'],