]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/BaseAdminModule.php
Remove deprecated code
[friendica.git] / src / Module / BaseAdminModule.php
index dd89bcb6c769d88c815748b5805ffb47a51759e0..f0cfb0c11c1019180a0c6354e0e65b521674524d 100644 (file)
@@ -4,9 +4,12 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Addon;
-use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
-use Friendica\Core\System;
+use Friendica\Core\Session;
+use Friendica\DI;
+use Friendica\Network\HTTPException\ForbiddenException;
+
+require_once 'boot.php';
 
 /**
  * This abstract module is meant to be extended by all modules that are reserved to administrator users.
@@ -20,7 +23,7 @@ use Friendica\Core\System;
  */
 abstract class BaseAdminModule extends BaseModule
 {
-       public static function post()
+       public static function post(array $parameters = [])
        {
                if (!is_site_admin()) {
                        return;
@@ -32,38 +35,33 @@ abstract class BaseAdminModule extends BaseModule
                }
        }
 
-       public static function rawContent()
+       public static function rawContent(array $parameters = [])
        {
                if (!is_site_admin()) {
-                       System::httpExit(403);
+                       return '';
                }
 
                if (!empty($_SESSION['submanage'])) {
-                       System::httpExit(403);
+                       return '';
                }
 
                return '';
        }
 
-       public static function content()
+       public static function content(array $parameters = [])
        {
                if (!is_site_admin()) {
-                       return Login::form();
+                       notice(DI::l10n()->t('Please login to continue.'));
+                       Session::set('return_path', DI::args()->getQueryString());
+                       DI::baseUrl()->redirect('login');
                }
 
                if (!empty($_SESSION['submanage'])) {
-                       return '';
+                       throw new ForbiddenException(DI::l10n()->t('Submanaged account can\'t access the administation pages. Please log back in as the master account.'));
                }
 
-               $a = self::getApp();
-
-               // APC deactivated, since there are problems with PHP 5.5
-               //if (function_exists("apc_delete")) {
-               // $toDelete = new APCIterator('user', APC_ITER_VALUE);
-               // apc_delete($toDelete);
-               //}
                // Header stuff
-               $a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
+               DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
 
                /*
                 * Side bar links
@@ -72,48 +70,48 @@ abstract class BaseAdminModule extends BaseModule
                // array(url, name, extra css classes)
                // not part of $aside to make the template more adjustable
                $aside_sub = [
-                       'information' => [L10n::t('Information'), [
-                               'overview'     => ['admin'             , L10n::t('Overview')                , 'overview'],
-                               'federation'   => ['admin/federation'  , L10n::t('Federation Statistics')   , 'federation']
+                       'information' => [DI::l10n()->t('Information'), [
+                               'overview'     => ['admin'             , DI::l10n()->t('Overview')                , 'overview'],
+                               'federation'   => ['admin/federation'  , DI::l10n()->t('Federation Statistics')   , 'federation']
                        ]],
-                       'configuration' => [L10n::t('Configuration'), [
-                               'site'         => ['admin/site'        , L10n::t('Site')                    , 'site'],
-                               'users'        => ['admin/users'       , L10n::t('Users')                   , 'users'],
-                               'addons'       => ['admin/addons'      , L10n::t('Addons')                  , 'addons'],
-                               'themes'       => ['admin/themes'      , L10n::t('Themes')                  , 'themes'],
-                               'features'     => ['admin/features'    , L10n::t('Additional features')     , 'features'],
-                               'tos'          => ['admin/tos'         , L10n::t('Terms of Service')        , 'tos'],
+                       'configuration' => [DI::l10n()->t('Configuration'), [
+                               'site'         => ['admin/site'        , DI::l10n()->t('Site')                    , 'site'],
+                               'users'        => ['admin/users'       , DI::l10n()->t('Users')                   , 'users'],
+                               'addons'       => ['admin/addons'      , DI::l10n()->t('Addons')                  , 'addons'],
+                               'themes'       => ['admin/themes'      , DI::l10n()->t('Themes')                  , 'themes'],
+                               'features'     => ['admin/features'    , DI::l10n()->t('Additional features')     , 'features'],
+                               'tos'          => ['admin/tos'         , DI::l10n()->t('Terms of Service')        , 'tos'],
                        ]],
-                       'database' => [L10n::t('Database'), [
-                               'dbsync'       => ['admin/dbsync'      , L10n::t('DB updates')              , 'dbsync'],
-                               'deferred'     => ['admin/queue/deferred', L10n::t('Inspect Deferred Workers'), 'deferred'],
-                               'workerqueue'  => ['admin/queue'       , L10n::t('Inspect worker Queue')    , 'workerqueue'],
+                       'database' => [DI::l10n()->t('Database'), [
+                               'dbsync'       => ['admin/dbsync'      , DI::l10n()->t('DB updates')              , 'dbsync'],
+                               'deferred'     => ['admin/queue/deferred', DI::l10n()->t('Inspect Deferred Workers'), 'deferred'],
+                               'workerqueue'  => ['admin/queue'       , DI::l10n()->t('Inspect worker Queue')    , 'workerqueue'],
                        ]],
-                       'tools' => [L10n::t('Tools'), [
-                               'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist')  , 'contactblock'],
-                               'blocklist'    => ['admin/blocklist/server' , L10n::t('Server Blocklist')   , 'blocklist'],
-                               'deleteitem'   => ['admin/item/delete' , L10n::t('Delete Item')             , 'deleteitem'],
+                       'tools' => [DI::l10n()->t('Tools'), [
+                               'contactblock' => ['admin/blocklist/contact', DI::l10n()->t('Contact Blocklist')  , 'contactblock'],
+                               'blocklist'    => ['admin/blocklist/server' , DI::l10n()->t('Server Blocklist')   , 'blocklist'],
+                               'deleteitem'   => ['admin/item/delete' , DI::l10n()->t('Delete Item')             , 'deleteitem'],
                        ]],
-                       'logs' => [L10n::t('Logs'), [
-                               'logsconfig'   => ['admin/logs/', L10n::t('Logs')                           , 'logs'],
-                               'logsview'     => ['admin/logs/view'    , L10n::t('View Logs')              , 'viewlogs'],
+                       'logs' => [DI::l10n()->t('Logs'), [
+                               'logsconfig'   => ['admin/logs/', DI::l10n()->t('Logs')                           , 'logs'],
+                               'logsview'     => ['admin/logs/view'    , DI::l10n()->t('View Logs')              , 'viewlogs'],
                        ]],
-                       'diagnostics' => [L10n::t('Diagnostics'), [
-                               'phpinfo'      => ['admin/phpinfo'           , L10n::t('PHP Info')          , 'phpinfo'],
-                               'probe'        => ['probe'             , L10n::t('probe address')           , 'probe'],
-                               'webfinger'    => ['webfinger'         , L10n::t('check webfinger')         , 'webfinger'],
-                               'itemsource'   => ['admin/item/source' , L10n::t('Item Source')             , 'itemsource'],
-                               'babel'        => ['babel'             , L10n::t('Babel')                   , 'babel'],
+                       'diagnostics' => [DI::l10n()->t('Diagnostics'), [
+                               'phpinfo'      => ['admin/phpinfo'           , DI::l10n()->t('PHP Info')          , 'phpinfo'],
+                               'probe'        => ['probe'             , DI::l10n()->t('probe address')           , 'probe'],
+                               'webfinger'    => ['webfinger'         , DI::l10n()->t('check webfinger')         , 'webfinger'],
+                               'itemsource'   => ['admin/item/source' , DI::l10n()->t('Item Source')             , 'itemsource'],
+                               'babel'        => ['babel'             , DI::l10n()->t('Babel')                   , 'babel'],
                        ]],
                ];
 
                $t = Renderer::getMarkupTemplate('admin/aside.tpl');
-               $a->page['aside'] .= Renderer::replaceMacros($t, [
+               DI::page()['aside'] .= Renderer::replaceMacros($t, [
                        '$admin' => ['addons_admin' => Addon::getAdminList()],
                        '$subpages' => $aside_sub,
-                       '$admtxt' => L10n::t('Admin'),
-                       '$plugadmtxt' => L10n::t('Addon Features'),
-                       '$h_pending' => L10n::t('User registrations waiting for confirmation'),
+                       '$admtxt' => DI::l10n()->t('Admin'),
+                       '$plugadmtxt' => DI::l10n()->t('Addon Features'),
+                       '$h_pending' => DI::l10n()->t('User registrations waiting for confirmation'),
                        '$admurl' => 'admin/'
                ]);