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 = [])
54 if (!is_site_admin()) {
55 notice(L10n::t('Please login to continue.'));
56 Session::set('return_path', DI::args()->getQueryString());
57 DI::baseUrl()->redirect('login');
60 if (!empty($_SESSION['submanage'])) {
61 throw new ForbiddenException(L10n::t('Submanaged account can\'t access the administation pages. Please log back in as the master account.'));
65 DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
71 // array(url, name, extra css classes)
72 // not part of $aside to make the template more adjustable
74 'information' => [L10n::t('Information'), [
75 'overview' => ['admin' , L10n::t('Overview') , 'overview'],
76 'federation' => ['admin/federation' , L10n::t('Federation Statistics') , 'federation']
78 'configuration' => [L10n::t('Configuration'), [
79 'site' => ['admin/site' , L10n::t('Site') , 'site'],
80 'users' => ['admin/users' , L10n::t('Users') , 'users'],
81 'addons' => ['admin/addons' , L10n::t('Addons') , 'addons'],
82 'themes' => ['admin/themes' , L10n::t('Themes') , 'themes'],
83 'features' => ['admin/features' , L10n::t('Additional features') , 'features'],
84 'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'],
86 'database' => [L10n::t('Database'), [
87 'dbsync' => ['admin/dbsync' , L10n::t('DB updates') , 'dbsync'],
88 'deferred' => ['admin/queue/deferred', L10n::t('Inspect Deferred Workers'), 'deferred'],
89 'workerqueue' => ['admin/queue' , L10n::t('Inspect worker Queue') , 'workerqueue'],
91 'tools' => [L10n::t('Tools'), [
92 'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist') , 'contactblock'],
93 'blocklist' => ['admin/blocklist/server' , L10n::t('Server Blocklist') , 'blocklist'],
94 'deleteitem' => ['admin/item/delete' , L10n::t('Delete Item') , 'deleteitem'],
96 'logs' => [L10n::t('Logs'), [
97 'logsconfig' => ['admin/logs/', L10n::t('Logs') , 'logs'],
98 'logsview' => ['admin/logs/view' , L10n::t('View Logs') , 'viewlogs'],
100 'diagnostics' => [L10n::t('Diagnostics'), [
101 'phpinfo' => ['admin/phpinfo' , L10n::t('PHP Info') , 'phpinfo'],
102 'probe' => ['probe' , L10n::t('probe address') , 'probe'],
103 'webfinger' => ['webfinger' , L10n::t('check webfinger') , 'webfinger'],
104 'itemsource' => ['admin/item/source' , L10n::t('Item Source') , 'itemsource'],
105 'babel' => ['babel' , L10n::t('Babel') , 'babel'],
109 $t = Renderer::getMarkupTemplate('admin/aside.tpl');
110 DI::page()['aside'] .= Renderer::replaceMacros($t, [
111 '$admin' => ['addons_admin' => Addon::getAdminList()],
112 '$subpages' => $aside_sub,
113 '$admtxt' => L10n::t('Admin'),
114 '$plugadmtxt' => L10n::t('Addon Features'),
115 '$h_pending' => L10n::t('User registrations waiting for confirmation'),
116 '$admurl' => 'admin/'