3 * @copyright Copyright (C) 2020, Friendica
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\Admin;
24 use Friendica\Content\Feature;
25 use Friendica\Core\Renderer;
27 use Friendica\Module\BaseAdmin;
29 class Features extends BaseAdmin
31 public static function post(array $parameters = [])
33 self::checkAdminAccess();
35 self::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
37 $features = Feature::get(false);
39 foreach ($features as $fname => $fdata) {
40 foreach (array_slice($fdata, 1) as $f) {
42 $feature_state = 'feature_' . $feature;
43 $featurelock = 'featurelock_' . $feature;
45 if (!empty($_POST[$feature_state])) {
46 $val = intval($_POST[$feature_state]);
50 DI::config()->set('feature', $feature, $val);
52 if (!empty($_POST[$featurelock])) {
53 DI::config()->set('feature_lock', $feature, $val);
55 DI::config()->delete('feature_lock', $feature);
60 DI::baseUrl()->redirect('admin/features');
63 public static function content(array $parameters = [])
65 parent::content($parameters);
69 foreach (Feature::get(false) as $fname => $fdata) {
70 $features[$fname] = [];
71 $features[$fname][0] = $fdata[0];
72 foreach (array_slice($fdata, 1) as $f) {
73 $set = DI::config()->get('feature', $f[0], $f[3]);
74 $features[$fname][1][] = [
75 ['feature_' . $f[0], $f[1], $set, $f[2]],
76 ['featurelock_' . $f[0], DI::l10n()->t('Lock feature %s', $f[1]), $f[4], '']
81 $tpl = Renderer::getMarkupTemplate('admin/features.tpl');
82 $o = Renderer::replaceMacros($tpl, [
83 '$form_security_token' => self::getFormSecurityToken("admin_manage_features"),
84 '$baseurl' => DI::baseUrl()->get(true),
85 '$title' => DI::l10n()->t('Manage Additional Features'),
86 '$features' => $features,
87 '$submit' => DI::l10n()->t('Save Settings'),