X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FBaseSettings.php;h=a1e88e9a104a3b0a12630d4e97ebd1c160f383f0;hb=4246ffc892d13fc7dd0057d8358fcacc44da5048;hp=4baceee856e059a70be761bc81857b5da12dba8f;hpb=38a5358bfa646ae13a4a1a385741890fa88d9b7f;p=friendica.git diff --git a/src/Module/BaseSettings.php b/src/Module/BaseSettings.php index 4baceee856..a1e88e9a10 100644 --- a/src/Module/BaseSettings.php +++ b/src/Module/BaseSettings.php @@ -1,6 +1,6 @@ page = $page; + $this->session = $session; + + if ($this->session->getSubManagedUserId()) { + throw new ForbiddenException($this->t('Permission denied.')); + } + } + + protected function content(array $request = []): string { - $a = DI::app(); + Nav::setSelected('settings'); + if (!$this->session->getLocalUserId()) { + $this->session->set('return_path', $this->args->getCommand()); + $this->baseUrl->redirect('login'); + } + + $this->createAside(); + + return ''; + } + + public function createAside() + { $tpl = Renderer::getMarkupTemplate('settings/head.tpl'); - DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ - '$ispublic' => DI::l10n()->t('everybody') + $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ + '$ispublic' => $this->t('everybody') ]); $tabs = []; $tabs[] = [ - 'label' => DI::l10n()->t('Account'), - 'url' => 'settings', - 'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings') ? 'active' : ''), + 'label' => $this->t('Account'), + 'url' => 'settings', + 'selected' => static::class == Settings\Account::class ? 'active' : '', 'accesskey' => 'o', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Two-factor authentication'), - 'url' => 'settings/2fa', - 'selected' => (($a->argc > 1) && ($a->argv[1] === '2fa') ? 'active' : ''), - 'accesskey' => 'o', + 'label' => $this->t('Two-factor authentication'), + 'url' => 'settings/2fa', + 'selected' => in_array(static::class, [ + Settings\TwoFactor\AppSpecific::class, + Settings\TwoFactor\Index::class, + Settings\TwoFactor\Recovery::class, + Settings\TwoFactor\Trusted::class, + Settings\TwoFactor\Verify::class + ]) ? 'active' : '', + 'accesskey' => '2', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Profile'), - 'url' => 'settings/profile', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'profile') ? 'active' : ''), + 'label' => $this->t('Profile'), + 'url' => 'settings/profile', + 'selected' => in_array(static::class, [ + Settings\Profile\Index::class, + Settings\Profile\Photo\Crop::class, + Settings\Profile\Photo\Index::class, + ]) ? 'active' : '', 'accesskey' => 'p', ]; if (Feature::get()) { $tabs[] = [ - 'label' => DI::l10n()->t('Additional features'), - 'url' => 'settings/features', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''), + 'label' => $this->t('Additional features'), + 'url' => 'settings/features', + 'selected' => static::class == Settings\Features::class ? 'active' : '', 'accesskey' => 't', ]; } $tabs[] = [ - 'label' => DI::l10n()->t('Display'), - 'url' => 'settings/display', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'display') ? 'active' : ''), + 'label' => $this->t('Display'), + 'url' => 'settings/display', + 'selected' => static::class == Settings\Display::class ? 'active' : '', 'accesskey' => 'i', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Social Networks'), - 'url' => 'settings/connectors', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors') ? 'active' : ''), + 'label' => $this->t('Social Networks'), + 'url' => 'settings/connectors', + 'selected' => static::class == Settings\Connectors::class ? 'active' : '', 'accesskey' => 'w', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Addons'), - 'url' => 'settings/addon', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon') ? 'active' : ''), + 'label' => $this->t('Addons'), + 'url' => 'settings/addons', + 'selected' => static::class == Settings\Addons::class ? 'active' : '', 'accesskey' => 'l', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Manage Accounts'), - 'url' => 'settings/delegation', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'delegation') ? 'active' : ''), + 'label' => $this->t('Manage Accounts'), + 'url' => 'settings/delegation', + 'selected' => static::class == Settings\Delegation::class ? 'active' : '', 'accesskey' => 'd', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Connected apps'), - 'url' => 'settings/oauth', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth') ? 'active' : ''), + 'label' => $this->t('Connected apps'), + 'url' => 'settings/oauth', + 'selected' => static::class == Settings\OAuth::class ? 'active' : '', 'accesskey' => 'b', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Export personal data'), - 'url' => 'settings/userexport', - 'selected' => (($a->argc > 1) && ($a->argv[1] === 'userexport') ? 'active' : ''), + 'label' => $this->t('Export personal data'), + 'url' => 'settings/userexport', + 'selected' => static::class == Settings\UserExport::class ? 'active' : '', 'accesskey' => 'e', ]; $tabs[] = [ - 'label' => DI::l10n()->t('Remove account'), - 'url' => 'removeme', - 'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme') ? 'active' : ''), + 'label' => $this->t('Remove account'), + 'url' => 'settings/removeme', + 'selected' => static::class === Settings\RemoveMe::class ? 'active' : '', 'accesskey' => 'r', ]; - - $tabtpl = Renderer::getMarkupTemplate("generic_links_widget.tpl"); - DI::page()['aside'] = Renderer::replaceMacros($tabtpl, [ - '$title' => DI::l10n()->t('Settings'), + $tabtpl = Renderer::getMarkupTemplate('generic_links_widget.tpl'); + $this->page['aside'] = Renderer::replaceMacros($tabtpl, [ + '$title' => $this->t('Settings'), '$class' => 'settings-widget', '$items' => $tabs, ]);