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\Core\System;
32 use Friendica\Module\Security\Login;
33 use Friendica\Network\HTTPException\ForbiddenException;
34 use Friendica\Util\Profiler;
35 use Psr\Log\LoggerInterface;
37 class BaseSettings extends BaseModule
41 /** @var IHandleUserSessions */
44 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 = [])
46 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
49 $this->session = $session;
51 if ($this->session->getSubManagedUserId()) {
52 throw new ForbiddenException($this->t('Permission denied.'));
56 protected function content(array $request = []): string
58 Nav::setSelected('settings');
60 if (!$this->session->getLocalUserId()) {
61 $this->session->set('return_path', $this->args->getCommand());
62 $this->baseUrl->redirect('login');
70 public function createAside()
72 $tpl = Renderer::getMarkupTemplate('settings/head.tpl');
73 $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
74 '$ispublic' => $this->t('everybody')
80 'label' => $this->t('Account'),
82 'selected' => static::class == Settings\Account::class ? 'active' : '',
87 'label' => $this->t('Two-factor authentication'),
88 'url' => 'settings/2fa',
89 'selected' => in_array(static::class, [
90 Settings\TwoFactor\AppSpecific::class,
91 Settings\TwoFactor\Index::class,
92 Settings\TwoFactor\Recovery::class,
93 Settings\TwoFactor\Trusted::class,
94 Settings\TwoFactor\Verify::class
100 'label' => $this->t('Profile'),
101 'url' => 'settings/profile',
102 'selected' => in_array(static::class, [
103 Settings\Profile\Index::class,
104 Settings\Profile\Photo\Crop::class,
105 Settings\Profile\Photo\Index::class,
110 if (Feature::get()) {
112 'label' => $this->t('Additional features'),
113 'url' => 'settings/features',
114 'selected' => static::class == Settings\Features::class ? 'active' : '',
120 'label' => $this->t('Display'),
121 'url' => 'settings/display',
122 'selected' => static::class == Settings\Display::class ? 'active' : '',
127 'label' => $this->t('Social Networks'),
128 'url' => 'settings/connectors',
129 'selected' => static::class == Settings\Connectors::class ? 'active' : '',
134 'label' => $this->t('Addons'),
135 'url' => 'settings/addons',
136 'selected' => static::class == Settings\Addons::class ? 'active' : '',
141 'label' => $this->t('Manage Accounts'),
142 'url' => 'settings/delegation',
143 'selected' => static::class == Settings\Delegation::class ? 'active' : '',
148 'label' => $this->t('Connected apps'),
149 'url' => 'settings/oauth',
150 'selected' => static::class == Settings\OAuth::class ? 'active' : '',
155 'label' => $this->t('Export personal data'),
156 'url' => 'settings/userexport',
157 'selected' => static::class == Settings\UserExport::class ? 'active' : '',
162 'label' => $this->t('Remove account'),
163 'url' => 'settings/removeme',
164 'selected' => static::class === Settings\RemoveMe::class ? 'active' : '',
168 $tabtpl = Renderer::getMarkupTemplate('generic_links_widget.tpl');
169 $this->page['aside'] = Renderer::replaceMacros($tabtpl, [
170 '$title' => $this->t('Settings'),
171 '$class' => 'settings-widget',