2019-05-13 07:38:15 +02:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
2022-01-02 08:27:47 +01:00
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
2020-02-09 15:45:36 +01:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-05-13 07:38:15 +02:00
|
|
|
|
|
|
|
namespace Friendica\Module;
|
|
|
|
|
2022-11-05 03:15:32 +01:00
|
|
|
use Friendica\App;
|
2019-05-13 07:38:15 +02:00
|
|
|
use Friendica\BaseModule;
|
|
|
|
use Friendica\Content\Feature;
|
2022-11-05 03:15:32 +01:00
|
|
|
use Friendica\Content\Nav;
|
|
|
|
use Friendica\Core\L10n;
|
2019-05-13 07:38:15 +02:00
|
|
|
use Friendica\Core\Renderer;
|
2022-11-05 03:15:32 +01:00
|
|
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
|
|
|
use Friendica\Core\System;
|
|
|
|
use Friendica\Module\Security\Login;
|
|
|
|
use Friendica\Network\HTTPException\ForbiddenException;
|
|
|
|
use Friendica\Util\Profiler;
|
|
|
|
use Psr\Log\LoggerInterface;
|
2019-05-13 07:38:15 +02:00
|
|
|
|
2020-01-23 05:14:14 +01:00
|
|
|
class BaseSettings extends BaseModule
|
2019-05-13 07:38:15 +02:00
|
|
|
{
|
2022-11-05 03:15:32 +01:00
|
|
|
/** @var App\Page */
|
|
|
|
protected $page;
|
|
|
|
/** @var IHandleUserSessions */
|
|
|
|
protected $session;
|
|
|
|
|
|
|
|
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 = [])
|
|
|
|
{
|
|
|
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
|
|
|
|
|
|
|
$this->page = $page;
|
|
|
|
$this->session = $session;
|
|
|
|
|
|
|
|
if ($this->session->getSubManagedUserId()) {
|
|
|
|
throw new ForbiddenException($this->t('Permission denied.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function content(array $request = []): string
|
|
|
|
{
|
|
|
|
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()
|
2019-05-13 07:38:15 +02:00
|
|
|
{
|
|
|
|
$tpl = Renderer::getMarkupTemplate('settings/head.tpl');
|
2022-11-05 03:15:32 +01:00
|
|
|
$this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
|
|
|
'$ispublic' => $this->t('everybody')
|
2019-05-13 07:38:15 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
$tabs = [];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Account'),
|
|
|
|
'url' => 'settings',
|
|
|
|
'selected' => static::class == Settings\Account::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'o',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'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' : '',
|
2022-06-19 06:30:00 +02:00
|
|
|
'accesskey' => '2',
|
2019-05-13 07:38:15 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'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' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'p',
|
|
|
|
];
|
|
|
|
|
|
|
|
if (Feature::get()) {
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Additional features'),
|
|
|
|
'url' => 'settings/features',
|
|
|
|
'selected' => static::class == Settings\Features::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 't',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Display'),
|
|
|
|
'url' => 'settings/display',
|
|
|
|
'selected' => static::class == Settings\Display::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'i',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Social Networks'),
|
|
|
|
'url' => 'settings/connectors',
|
2022-11-05 04:47:42 +01:00
|
|
|
'selected' => static::class == Settings\Connectors::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'w',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Addons'),
|
2022-11-05 03:32:46 +01:00
|
|
|
'url' => 'settings/addons',
|
2022-11-05 03:15:32 +01:00
|
|
|
'selected' => static::class == Settings\Addons::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'l',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Manage Accounts'),
|
|
|
|
'url' => 'settings/delegation',
|
|
|
|
'selected' => static::class == Settings\Delegation::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'd',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Connected apps'),
|
|
|
|
'url' => 'settings/oauth',
|
|
|
|
'selected' => static::class == Settings\OAuth::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'b',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Export personal data'),
|
|
|
|
'url' => 'settings/userexport',
|
|
|
|
'selected' => static::class == Settings\UserExport::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'e',
|
|
|
|
];
|
|
|
|
|
|
|
|
$tabs[] = [
|
2022-11-05 03:15:32 +01:00
|
|
|
'label' => $this->t('Remove account'),
|
|
|
|
'url' => 'settings/removeme',
|
|
|
|
'selected' => static::class === Settings\RemoveMe::class ? 'active' : '',
|
2019-05-13 07:38:15 +02:00
|
|
|
'accesskey' => 'r',
|
|
|
|
];
|
|
|
|
|
2022-11-05 03:15:32 +01:00
|
|
|
$tabtpl = Renderer::getMarkupTemplate('generic_links_widget.tpl');
|
|
|
|
$this->page['aside'] = Renderer::replaceMacros($tabtpl, [
|
|
|
|
'$title' => $this->t('Settings'),
|
2019-05-13 07:38:15 +02:00
|
|
|
'$class' => 'settings-widget',
|
|
|
|
'$items' => $tabs,
|
|
|
|
]);
|
2021-11-21 20:06:36 +01:00
|
|
|
}
|
2019-05-13 07:38:15 +02:00
|
|
|
}
|