2019-05-02 06:01:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Module\Admin;
|
|
|
|
|
|
|
|
use Friendica\Content\Feature;
|
|
|
|
use Friendica\Core\Config;
|
|
|
|
use Friendica\Core\L10n;
|
|
|
|
use Friendica\Core\Renderer;
|
2019-12-15 22:34:11 +01:00
|
|
|
use Friendica\DI;
|
2019-05-02 06:01:43 +02:00
|
|
|
use Friendica\Module\BaseAdminModule;
|
|
|
|
|
|
|
|
class Features extends BaseAdminModule
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
Config::set('feature', $feature, $val);
|
|
|
|
|
|
|
|
if (!empty($_POST[$featurelock])) {
|
|
|
|
Config::set('feature_lock', $feature, $val);
|
|
|
|
} else {
|
|
|
|
Config::delete('feature_lock', $feature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-15 22:34:11 +01:00
|
|
|
DI::app()->internalRedirect('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
|
|
|
|
|
|
|
$arr = [];
|
|
|
|
$features = Feature::get(false);
|
|
|
|
|
|
|
|
foreach ($features as $fname => $fdata) {
|
|
|
|
$arr[$fname] = [];
|
|
|
|
$arr[$fname][0] = $fdata[0];
|
|
|
|
foreach (array_slice($fdata, 1) as $f) {
|
|
|
|
$set = Config::get('feature', $f[0], $f[3]);
|
|
|
|
$arr[$fname][1][] = [
|
|
|
|
['feature_' . $f[0], $f[1], $set, $f[2], [L10n::t('Off'), L10n::t('On')]],
|
|
|
|
['featurelock_' . $f[0], L10n::t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', [L10n::t('Off'), L10n::t('On')]]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tpl = Renderer::getMarkupTemplate('admin/features.tpl');
|
|
|
|
$o = Renderer::replaceMacros($tpl, [
|
|
|
|
'$form_security_token' => parent::getFormSecurityToken("admin_manage_features"),
|
|
|
|
'$title' => L10n::t('Manage Additional Features'),
|
|
|
|
'$features' => $arr,
|
|
|
|
'$submit' => L10n::t('Save Settings'),
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
}
|