}
$return_path = 'admin/themes/' . $theme . (!empty($_GET['mode']) ? '?mode=' . $_GET['mode'] : '');
break;
- case 'features':
- admin_page_features_post($a);
- break;
case 'logs':
admin_page_logs_post($a);
break;
case 'themes':
$o = admin_page_themes($a);
break;
- case 'features':
- $o = admin_page_features($a);
- break;
case 'logs':
$o = admin_page_logs($a);
break;
]);
}
-/**
- * @brief Prosesses data send by the features admin page
- *
- * @param App $a
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
-function admin_page_features_post(App $a)
-{
- BaseModule::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
-
- Logger::log('postvars: ' . print_r($_POST, true), Logger::DATA);
-
- $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);
- }
- }
- }
-
- $a->internalRedirect('admin/features');
- return; // NOTREACHED
-}
-
-/**
- * @brief Subpage for global additional feature management
- *
- * This functin generates the subpage 'Manage Additional Features'
- * for the admin panel. At this page the admin can set preferences
- * for the user settings of the 'additional features'. If needed this
- * preferences can be locked through the admin.
- *
- * The returned string contains the HTML code of the subpage 'Manage
- * Additional Features'
- *
- * @param App $a
- * @return string
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
-function admin_page_features(App $a)
-{
- if (($a->argc > 1) && ($a->getArgumentValue(1) === 'features')) {
- $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/settings_features.tpl');
- $o = Renderer::replaceMacros($tpl, [
- '$form_security_token' => BaseModule::getFormSecurityToken("admin_manage_features"),
- '$title' => L10n::t('Manage Additional Features'),
- '$features' => $arr,
- '$submit' => L10n::t('Save Settings'),
- ]);
-
- return $o;
- }
-}
-
function admin_page_server_vital()
{
// Fetch the host-meta to check if this really is a vital server
$collector->addRoute(['GET', 'POST'], '/addons' , Module\Admin\Addons\Index::class);
$collector->addRoute(['GET', 'POST'], '/addons/{addon}' , Module\Admin\Addons\Details::class);
+ $collector->addRoute(['GET', 'POST'], '/features' , Module\Admin\Features::class);
$collector->addRoute(['GET'] , '/federation' , Module\Admin\Federation::class);
$collector->addRoute(['GET', 'POST'], '/themes' , Module\Admin\Themes\Index::class);
--- /dev/null
+<?php\r
+\r
+namespace Friendica\Module\Admin;\r
+\r
+use Friendica\Content\Feature;\r
+use Friendica\Core\Config;\r
+use Friendica\Core\L10n;\r
+use Friendica\Core\Logger;\r
+use Friendica\Core\Renderer;\r
+use Friendica\Module\BaseAdminModule;\r
+\r
+class Features extends BaseAdminModule\r
+{\r
+ public static function post()\r
+ {\r
+ parent::post();\r
+\r
+ parent::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');\r
+\r
+ $features = Feature::get(false);\r
+\r
+ foreach ($features as $fname => $fdata) {\r
+ foreach (array_slice($fdata, 1) as $f) {\r
+ $feature = $f[0];\r
+ $feature_state = 'feature_' . $feature;\r
+ $featurelock = 'featurelock_' . $feature;\r
+\r
+ if (!empty($_POST[$feature_state])) {\r
+ $val = intval($_POST[$feature_state]);\r
+ } else {\r
+ $val = 0;\r
+ }\r
+ Config::set('feature', $feature, $val);\r
+\r
+ if (!empty($_POST[$featurelock])) {\r
+ Config::set('feature_lock', $feature, $val);\r
+ } else {\r
+ Config::delete('feature_lock', $feature);\r
+ }\r
+ }\r
+ }\r
+\r
+ self::getApp()->internalRedirect('admin/features');\r
+ }\r
+\r
+ public static function content()\r
+ {\r
+ parent::content();\r
+\r
+ $a = self::getApp();\r
+\r
+ if (($a->argc > 1) && ($a->getArgumentValue(1) === 'features')) {\r
+ $arr = [];\r
+ $features = Feature::get(false);\r
+\r
+ foreach ($features as $fname => $fdata) {\r
+ $arr[$fname] = [];\r
+ $arr[$fname][0] = $fdata[0];\r
+ foreach (array_slice($fdata, 1) as $f) {\r
+ $set = Config::get('feature', $f[0], $f[3]);\r
+ $arr[$fname][1][] = [\r
+ ['feature_' . $f[0], $f[1], $set, $f[2], [L10n::t('Off'), L10n::t('On')]],\r
+ ['featurelock_' . $f[0], L10n::t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', [L10n::t('Off'), L10n::t('On')]]\r
+ ];\r
+ }\r
+ }\r
+\r
+ $tpl = Renderer::getMarkupTemplate('admin/features.tpl');\r
+ $o = Renderer::replaceMacros($tpl, [\r
+ '$form_security_token' => parent::getFormSecurityToken("admin_manage_features"),\r
+ '$title' => L10n::t('Manage Additional Features'),\r
+ '$features' => $arr,\r
+ '$submit' => L10n::t('Save Settings'),\r
+ ]);\r
+\r
+ return $o;\r
+ }\r
+ }\r
+}
\ No newline at end of file
'users' => ['admin/users' , L10n::t('Users') , 'users'],\r
'addons' => ['admin/addons' , L10n::t('Addons') , 'addons'],\r
'themes' => ['admin/themes' , L10n::t('Themes') , 'themes'],\r
+ 'features' => ['admin/features' , L10n::t('Additional features') , 'features'],\r
'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'],\r
]],\r
];\r
--- /dev/null
+
+<div id="adminpage">
+ <h1>{{$title}}</h1>
+
+ <form action="admin/features" method="post" autocomplete="off">
+ <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
+
+ {{foreach $features as $g => $f}}
+ <h3 class="settings-heading"><a href="javascript:;">{{$f.0}}</a></h3>
+
+ <div class="settings-content-block">
+ {{foreach $f.1 as $fcat}}
+ <div class="settings-block">
+ {{include file="field_yesno.tpl" field=$fcat.0}}
+ {{include file="field_yesno.tpl" field=$fcat.1}}
+ </div>
+ {{/foreach}}
+
+ <div class="settings-submit-wrapper" >
+ <input type="submit" name="submit" class="settings-features-submit" value="{{$submit}}" />
+ </div>
+ </div>
+ {{/foreach}}
+
+ </form>
+</div>
+++ /dev/null
-
-<div id="adminpage">
- <h1>{{$title}}</h1>
-
- <form action="admin/features" method="post" autocomplete="off">
- <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
-
- {{foreach $features as $g => $f}}
- <h3 class="settings-heading"><a href="javascript:;">{{$f.0}}</a></h3>
-
- <div class="settings-content-block">
- {{foreach $f.1 as $fcat}}
- <div class="settings-block">
- {{include file="field_yesno.tpl" field=$fcat.0}}
- {{include file="field_yesno.tpl" field=$fcat.1}}
- </div>
- {{/foreach}}
-
- <div class="settings-submit-wrapper" >
- <input type="submit" name="submit" class="settings-features-submit" value="{{$submit}}" />
- </div>
- </div>
- {{/foreach}}
-
- </form>
-</div>