3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module;
25 use Friendica\BaseModule;
26 use Friendica\Content\Feature;
27 use Friendica\Content\Nav;
28 use Friendica\Core\L10n;
29 use Friendica\Core\Renderer;
30 use Friendica\Core\Session\Capability\IHandleUserSessions;
31 use Friendica\Network\HTTPException\ForbiddenException;
32 use Friendica\Util\Profiler;
33 use Psr\Log\LoggerInterface;
35 class BaseSettings extends BaseModule
39 /** @var IHandleUserSessions */
42 public function __construct(IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
44 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
47 $this->session = $session;
49 if ($this->session->getSubManagedUserId()) {
50 throw new ForbiddenException($this->t('Permission denied.'));
54 protected function content(array $request = []): string
56 Nav::setSelected('settings');
58 if (!$this->session->getLocalUserId()) {
59 $this->session->set('return_path', $this->args->getCommand());
60 $this->baseUrl->redirect('login');
68 public function createAside()
70 $tpl = Renderer::getMarkupTemplate('settings/head.tpl');
71 $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
72 '$ispublic' => $this->t('everybody')
78 'label' => $this->t('Account'),
80 'selected' => static::class == Settings\Account::class ? 'active' : '',
85 'label' => $this->t('Two-factor authentication'),
86 'url' => 'settings/2fa',
87 'selected' => in_array(static::class, [
88 Settings\TwoFactor\AppSpecific::class,
89 Settings\TwoFactor\Index::class,
90 Settings\TwoFactor\Recovery::class,
91 Settings\TwoFactor\Trusted::class,
92 Settings\TwoFactor\Verify::class
98 'label' => $this->t('Profile'),
99 'url' => 'settings/profile',
100 'selected' => in_array(static::class, [
101 Settings\Profile\Index::class,
102 Settings\Profile\Photo\Crop::class,
103 Settings\Profile\Photo\Index::class,
108 if (Feature::get()) {
110 'label' => $this->t('Additional features'),
111 'url' => 'settings/features',
112 'selected' => static::class == Settings\Features::class ? 'active' : '',
118 'label' => $this->t('Display'),
119 'url' => 'settings/display',
120 'selected' => static::class == Settings\Display::class ? 'active' : '',
125 'label' => $this->t('Channels'),
126 'url' => 'settings/channels',
127 'selected' => static::class == Settings\Display::class ? 'active' : '',
132 'label' => $this->t('Social Networks'),
133 'url' => 'settings/connectors',
134 'selected' => static::class == Settings\Connectors::class ? 'active' : '',
139 'label' => $this->t('Addons'),
140 'url' => 'settings/addons',
141 'selected' => static::class == Settings\Addons::class ? 'active' : '',
146 'label' => $this->t('Manage Accounts'),
147 'url' => 'settings/delegation',
148 'selected' => static::class == Settings\Delegation::class ? 'active' : '',
153 'label' => $this->t('Connected apps'),
154 'url' => 'settings/oauth',
155 'selected' => static::class == Settings\OAuth::class ? 'active' : '',
160 'label' => $this->t('Remote servers'),
161 'url' => 'settings/server',
162 'selected' => static::class == Settings\Server\Index::class ? 'active' : '',
167 'label' => $this->t('Export personal data'),
168 'url' => 'settings/userexport',
169 'selected' => static::class == Settings\UserExport::class ? 'active' : '',
174 'label' => $this->t('Remove account'),
175 'url' => 'settings/removeme',
176 'selected' => static::class === Settings\RemoveMe::class ? 'active' : '',
180 $tabtpl = Renderer::getMarkupTemplate('generic_links_widget.tpl');
181 $this->page['aside'] = Renderer::replaceMacros($tabtpl, [
182 '$title' => $this->t('Settings'),
183 '$class' => 'settings-widget',