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