2016-09-07 03:10:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zotlabs\Module\Settings;
|
|
|
|
|
2018-06-05 01:40:11 +00:00
|
|
|
use Zotlabs\Lib\Libsync;
|
2016-09-07 03:10:56 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
class Features
|
|
|
|
{
|
|
|
|
|
|
|
|
public function post()
|
|
|
|
{
|
|
|
|
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
|
|
|
|
|
2022-01-25 23:20:02 +00:00
|
|
|
$features = Features::get(false);
|
2021-12-02 23:02:31 +00:00
|
|
|
|
|
|
|
foreach ($features as $fname => $fdata) {
|
|
|
|
foreach (array_slice($fdata, 1) as $f) {
|
|
|
|
$k = $f[0];
|
2021-12-03 03:01:39 +00:00
|
|
|
if (array_key_exists("feature_$k", $_POST)) {
|
2021-12-02 23:02:31 +00:00
|
|
|
set_pconfig(local_channel(), 'feature', $k, (string)$_POST["feature_$k"]);
|
2021-12-03 03:01:39 +00:00
|
|
|
} else {
|
2021-12-02 23:02:31 +00:00
|
|
|
set_pconfig(local_channel(), 'feature', $k, '');
|
2021-12-03 03:01:39 +00:00
|
|
|
}
|
2021-12-02 23:02:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Libsync::build_sync_packet();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get()
|
|
|
|
{
|
|
|
|
|
|
|
|
$arr = [];
|
|
|
|
$harr = [];
|
|
|
|
|
|
|
|
|
2022-01-25 23:20:02 +00:00
|
|
|
$all_features_raw = Features::get(false);
|
2021-12-02 23:02:31 +00:00
|
|
|
|
|
|
|
foreach ($all_features_raw as $fname => $fdata) {
|
|
|
|
foreach (array_slice($fdata, 1) as $f) {
|
2022-01-25 23:20:02 +00:00
|
|
|
$harr[$f[0]] = ((intval(Features::enabled(local_channel(), $f[0]))) ? "1" : '');
|
2021-12-02 23:02:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 23:20:02 +00:00
|
|
|
$features = Features::get(true);
|
2021-12-02 23:02:31 +00:00
|
|
|
|
|
|
|
foreach ($features as $fname => $fdata) {
|
|
|
|
$arr[$fname] = [];
|
|
|
|
$arr[$fname][0] = $fdata[0];
|
|
|
|
foreach (array_slice($fdata, 1) as $f) {
|
2022-01-25 23:20:02 +00:00
|
|
|
$arr[$fname][1][] = array('feature_' . $f[0], $f[1], ((intval(Features::enabled(local_channel(), $f[0]))) ? "1" : ''), $f[2], array(t('Off'), t('On')));
|
2021-12-02 23:02:31 +00:00
|
|
|
unset($harr[$f[0]]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tpl = get_markup_template("settings_features.tpl");
|
|
|
|
$o .= replace_macros($tpl, array(
|
|
|
|
'$form_security_token' => get_form_security_token("settings_features"),
|
|
|
|
'$title' => t('Additional Features'),
|
|
|
|
'$features' => $arr,
|
|
|
|
'$hiddens' => $harr,
|
|
|
|
'$baseurl' => z_root(),
|
|
|
|
'$submit' => t('Submit'),
|
|
|
|
));
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
2016-10-04 19:11:11 +00:00
|
|
|
}
|