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