3 * @copyright Copyright (C) 2010-2022, 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\Settings;
25 use Friendica\Content\Feature;
26 use Friendica\Core\L10n;
27 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
28 use Friendica\Core\Renderer;
29 use Friendica\Core\Session\Capability\IHandleUserSessions;
30 use Friendica\Module\BaseSettings;
31 use Friendica\Module\Response;
32 use Friendica\Util\Profiler;
33 use Psr\Log\LoggerInterface;
35 class Features extends BaseSettings
37 /** @var IManagePersonalConfigValues */
40 public function __construct(IManagePersonalConfigValues $pConfig, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
42 parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
44 $this->pConfig = $pConfig;
47 protected function post(array $request = [])
49 BaseSettings::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
50 foreach ($request as $k => $v) {
51 if (strpos($k, 'feature_') === 0) {
52 $this->pConfig->set($this->session->getLocalUserId(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
57 protected function content(array $request = []): string
59 parent::content($request);
62 $features = Feature::get();
63 foreach ($features as $name => $feature) {
65 $arr[$name][0] = $feature[0];
66 foreach (array_slice($feature, 1) as $f) {
67 $arr[$name][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled($this->session->getLocalUserId(), $f[0]), $f[2]];
71 $tpl = Renderer::getMarkupTemplate('settings/features.tpl');
72 return Renderer::replaceMacros($tpl, [
73 '$form_security_token' => BaseSettings::getFormSecurityToken('settings_features'),
74 '$title' => $this->t('Additional Features'),
76 '$submit' => $this->t('Save Settings'),