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 parent::post($parameters);
35 parent::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);
68 $features = Feature::get(false);
70 foreach ($features as $fname => $fdata) {
72 $arr[$fname][0] = $fdata[0];
73 foreach (array_slice($fdata, 1) as $f) {
74 $set = DI::config()->get('feature', $f[0], $f[3]);
76 ['feature_' . $f[0], $f[1], $set, $f[2], [DI::l10n()->t('Off'), DI::l10n()->t('On')]],
77 ['featurelock_' . $f[0], DI::l10n()->t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', [DI::l10n()->t('Off'), DI::l10n()->t('On')]]
82 $tpl = Renderer::getMarkupTemplate('admin/features.tpl');
83 $o = Renderer::replaceMacros($tpl, [
84 '$form_security_token' => parent::getFormSecurityToken("admin_manage_features"),
85 '$title' => DI::l10n()->t('Manage Additional Features'),
87 '$submit' => DI::l10n()->t('Save Settings'),