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;
10 use Friendica\Network\HTTPException\ForbiddenException;
12 require_once 'boot.php';
15 * This abstract module is meant to be extended by all modules that are reserved to administrator users.
17 * It performs a blanket permission check in all the module methods as long as the relevant `parent::method()` is
18 * called in the inheriting module.
20 * Additionally, it puts together the administration page aside with all the administration links.
22 * @package Friendica\Module
24 abstract class BaseAdminModule extends BaseModule
26 public static function post(array $parameters = [])
28 if (!is_site_admin()) {
32 // do not allow a page manager to access the admin panel at all.
33 if (!empty($_SESSION['submanage'])) {
38 public static function rawContent(array $parameters = [])
40 if (!is_site_admin()) {
44 if (!empty($_SESSION['submanage'])) {
51 public static function content(array $parameters = [])
55 if (!is_site_admin()) {
56 notice(L10n::t('Please login to continue.'));
57 Session::set('return_path', $a->query_string);
58 $a->internalRedirect('login');
61 if (!empty($_SESSION['submanage'])) {
62 throw new ForbiddenException(L10n::t('Submanaged account can\'t access the administation pages. Please log back in as the master account.'));
66 $a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
72 // array(url, name, extra css classes)
73 // not part of $aside to make the template more adjustable
75 'information' => [L10n::t('Information'), [
76 'overview' => ['admin' , L10n::t('Overview') , 'overview'],
77 'federation' => ['admin/federation' , L10n::t('Federation Statistics') , 'federation']
79 'configuration' => [L10n::t('Configuration'), [
80 'site' => ['admin/site' , L10n::t('Site') , 'site'],
81 'users' => ['admin/users' , L10n::t('Users') , 'users'],
82 'addons' => ['admin/addons' , L10n::t('Addons') , 'addons'],
83 'themes' => ['admin/themes' , L10n::t('Themes') , 'themes'],
84 'features' => ['admin/features' , L10n::t('Additional features') , 'features'],
85 'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'],
87 'database' => [L10n::t('Database'), [
88 'dbsync' => ['admin/dbsync' , L10n::t('DB updates') , 'dbsync'],
89 'deferred' => ['admin/queue/deferred', L10n::t('Inspect Deferred Workers'), 'deferred'],
90 'workerqueue' => ['admin/queue' , L10n::t('Inspect worker Queue') , 'workerqueue'],
92 'tools' => [L10n::t('Tools'), [
93 'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist') , 'contactblock'],
94 'blocklist' => ['admin/blocklist/server' , L10n::t('Server Blocklist') , 'blocklist'],
95 'deleteitem' => ['admin/item/delete' , L10n::t('Delete Item') , 'deleteitem'],
97 'logs' => [L10n::t('Logs'), [
98 'logsconfig' => ['admin/logs/', L10n::t('Logs') , 'logs'],
99 'logsview' => ['admin/logs/view' , L10n::t('View Logs') , 'viewlogs'],
101 'diagnostics' => [L10n::t('Diagnostics'), [
102 'phpinfo' => ['admin/phpinfo' , L10n::t('PHP Info') , 'phpinfo'],
103 'probe' => ['probe' , L10n::t('probe address') , 'probe'],
104 'webfinger' => ['webfinger' , L10n::t('check webfinger') , 'webfinger'],
105 'itemsource' => ['admin/item/source' , L10n::t('Item Source') , 'itemsource'],
106 'babel' => ['babel' , L10n::t('Babel') , 'babel'],
110 $t = Renderer::getMarkupTemplate('admin/aside.tpl');
111 $a->page['aside'] .= Renderer::replaceMacros($t, [
112 '$admin' => ['addons_admin' => Addon::getAdminList()],
113 '$subpages' => $aside_sub,
114 '$admtxt' => L10n::t('Admin'),
115 '$plugadmtxt' => L10n::t('Addon Features'),
116 '$h_pending' => L10n::t('User registrations waiting for confirmation'),
117 '$admurl' => 'admin/'