3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\Addon;
7 use Friendica\Core\L10n;
8 use Friendica\Core\Renderer;
9 use Friendica\Core\Session;
11 use Friendica\Network\HTTPException\ForbiddenException;
13 require_once 'boot.php';
16 * This abstract module is meant to be extended by all modules that are reserved to administrator users.
18 * It performs a blanket permission check in all the module methods as long as the relevant `parent::method()` is
19 * called in the inheriting module.
21 * Additionally, it puts together the administration page aside with all the administration links.
23 * @package Friendica\Module
25 abstract class BaseAdminModule extends BaseModule
27 public static function post(array $parameters = [])
29 if (!is_site_admin()) {
33 // do not allow a page manager to access the admin panel at all.
34 if (!empty($_SESSION['submanage'])) {
39 public static function rawContent(array $parameters = [])
41 if (!is_site_admin()) {
45 if (!empty($_SESSION['submanage'])) {
52 public static function content(array $parameters = [])
56 if (!is_site_admin()) {
57 notice(L10n::t('Please login to continue.'));
58 Session::set('return_path', DI::args()->getQueryString());
59 DI::baseUrl()->redirect('login');
62 if (!empty($_SESSION['submanage'])) {
63 throw new ForbiddenException(L10n::t('Submanaged account can\'t access the administation pages. Please log back in as the master account.'));
67 $a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
73 // array(url, name, extra css classes)
74 // not part of $aside to make the template more adjustable
76 'information' => [L10n::t('Information'), [
77 'overview' => ['admin' , L10n::t('Overview') , 'overview'],
78 'federation' => ['admin/federation' , L10n::t('Federation Statistics') , 'federation']
80 'configuration' => [L10n::t('Configuration'), [
81 'site' => ['admin/site' , L10n::t('Site') , 'site'],
82 'users' => ['admin/users' , L10n::t('Users') , 'users'],
83 'addons' => ['admin/addons' , L10n::t('Addons') , 'addons'],
84 'themes' => ['admin/themes' , L10n::t('Themes') , 'themes'],
85 'features' => ['admin/features' , L10n::t('Additional features') , 'features'],
86 'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'],
88 'database' => [L10n::t('Database'), [
89 'dbsync' => ['admin/dbsync' , L10n::t('DB updates') , 'dbsync'],
90 'deferred' => ['admin/queue/deferred', L10n::t('Inspect Deferred Workers'), 'deferred'],
91 'workerqueue' => ['admin/queue' , L10n::t('Inspect worker Queue') , 'workerqueue'],
93 'tools' => [L10n::t('Tools'), [
94 'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist') , 'contactblock'],
95 'blocklist' => ['admin/blocklist/server' , L10n::t('Server Blocklist') , 'blocklist'],
96 'deleteitem' => ['admin/item/delete' , L10n::t('Delete Item') , 'deleteitem'],
98 'logs' => [L10n::t('Logs'), [
99 'logsconfig' => ['admin/logs/', L10n::t('Logs') , 'logs'],
100 'logsview' => ['admin/logs/view' , L10n::t('View Logs') , 'viewlogs'],
102 'diagnostics' => [L10n::t('Diagnostics'), [
103 'phpinfo' => ['admin/phpinfo' , L10n::t('PHP Info') , 'phpinfo'],
104 'probe' => ['probe' , L10n::t('probe address') , 'probe'],
105 'webfinger' => ['webfinger' , L10n::t('check webfinger') , 'webfinger'],
106 'itemsource' => ['admin/item/source' , L10n::t('Item Source') , 'itemsource'],
107 'babel' => ['babel' , L10n::t('Babel') , 'babel'],
111 $t = Renderer::getMarkupTemplate('admin/aside.tpl');
112 $a->page['aside'] .= Renderer::replaceMacros($t, [
113 '$admin' => ['addons_admin' => Addon::getAdminList()],
114 '$subpages' => $aside_sub,
115 '$admtxt' => L10n::t('Admin'),
116 '$plugadmtxt' => L10n::t('Addon Features'),
117 '$h_pending' => L10n::t('User registrations waiting for confirmation'),
118 '$admurl' => 'admin/'