2019-05-02 06:01:43 +02:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @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-02 06:01:43 +02:00
|
|
|
|
|
|
|
namespace Friendica\Module\Admin;
|
|
|
|
|
|
|
|
use Friendica\Content\Feature;
|
|
|
|
use Friendica\Core\Renderer;
|
2019-12-15 22:34:11 +01:00
|
|
|
use Friendica\DI;
|
2020-01-23 05:14:14 +01:00
|
|
|
use Friendica\Module\BaseAdmin;
|
2019-05-02 06:01:43 +02:00
|
|
|
|
2020-01-23 05:14:14 +01:00
|
|
|
class Features extends BaseAdmin
|
2019-05-02 06:01:43 +02:00
|
|
|
{
|
2019-11-05 22:48:54 +01:00
|
|
|
public static function post(array $parameters = [])
|
2019-05-02 06:01:43 +02:00
|
|
|
{
|
2019-11-05 21:22:54 +01:00
|
|
|
parent::post($parameters);
|
2019-05-02 06:01:43 +02:00
|
|
|
|
|
|
|
parent::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
|
|
|
|
|
|
|
|
$features = Feature::get(false);
|
|
|
|
|
|
|
|
foreach ($features as $fname => $fdata) {
|
|
|
|
foreach (array_slice($fdata, 1) as $f) {
|
|
|
|
$feature = $f[0];
|
|
|
|
$feature_state = 'feature_' . $feature;
|
|
|
|
$featurelock = 'featurelock_' . $feature;
|
|
|
|
|
|
|
|
if (!empty($_POST[$feature_state])) {
|
|
|
|
$val = intval($_POST[$feature_state]);
|
|
|
|
} else {
|
|
|
|
$val = 0;
|
|
|
|
}
|
2020-01-19 21:21:53 +01:00
|
|
|
DI::config()->set('feature', $feature, $val);
|
2019-05-02 06:01:43 +02:00
|
|
|
|
|
|
|
if (!empty($_POST[$featurelock])) {
|
2020-01-19 21:21:53 +01:00
|
|
|
DI::config()->set('feature_lock', $feature, $val);
|
2019-05-02 06:01:43 +02:00
|
|
|
} else {
|
2020-01-19 21:22:33 +01:00
|
|
|
DI::config()->delete('feature_lock', $feature);
|
2019-05-02 06:01:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 00:28:31 +01:00
|
|
|
DI::baseUrl()->redirect('admin/features');
|
2019-05-02 06:01:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-05 22:48:54 +01:00
|
|
|
public static function content(array $parameters = [])
|
2019-05-02 06:01:43 +02:00
|
|
|
{
|
2019-11-05 21:22:54 +01:00
|
|
|
parent::content($parameters);
|
2019-05-02 06:01:43 +02:00
|
|
|
|
2020-04-02 00:27:14 +02:00
|
|
|
$features = [];
|
2019-05-02 06:01:43 +02:00
|
|
|
|
2020-04-02 00:27:14 +02:00
|
|
|
foreach (Feature::get(false) as $fname => $fdata) {
|
|
|
|
$features[$fname] = [];
|
|
|
|
$features[$fname][0] = $fdata[0];
|
2019-05-02 06:01:43 +02:00
|
|
|
foreach (array_slice($fdata, 1) as $f) {
|
2020-01-19 21:21:13 +01:00
|
|
|
$set = DI::config()->get('feature', $f[0], $f[3]);
|
2020-04-02 00:27:14 +02:00
|
|
|
$features[$fname][1][] = [
|
2020-03-01 20:15:08 +01:00
|
|
|
['feature_' . $f[0], $f[1], $set, $f[2]],
|
|
|
|
['featurelock_' . $f[0], DI::l10n()->t('Lock feature %s', $f[1]), $f[4], '']
|
2019-05-02 06:01:43 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tpl = Renderer::getMarkupTemplate('admin/features.tpl');
|
|
|
|
$o = Renderer::replaceMacros($tpl, [
|
|
|
|
'$form_security_token' => parent::getFormSecurityToken("admin_manage_features"),
|
2020-04-02 00:27:14 +02:00
|
|
|
'$baseurl' => DI::baseUrl()->get(true),
|
|
|
|
'$title' => DI::l10n()->t('Manage Additional Features'),
|
|
|
|
'$features' => $features,
|
|
|
|
'$submit' => DI::l10n()->t('Save Settings'),
|
2019-05-02 06:01:43 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
}
|