more work merging techlevels and features
This commit is contained in:
parent
e0255c0dc4
commit
e4ee165e29
@ -8,26 +8,16 @@ class Features {
|
|||||||
function post() {
|
function post() {
|
||||||
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
|
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
|
||||||
|
|
||||||
// Build list of features and check which are set
|
$features = get_features(false);
|
||||||
// We will not create any settings for features that are above our techlevel
|
|
||||||
|
|
||||||
if(intval($_REQUEST['techlevel']))
|
foreach($features as $fname => $fdata) {
|
||||||
$level = intval($_REQUEST['techlevel']);
|
foreach(array_slice($fdata,1) as $f) {
|
||||||
else {
|
$k = $f[0];
|
||||||
$level = get_account_techlevel();
|
if(array_key_exists("feature_$k",$_POST))
|
||||||
}
|
set_pconfig(local_channel(),'feature',$k, (string) $_POST["feature_$k"]);
|
||||||
|
|
||||||
$features = get_features(true,$level);
|
|
||||||
$all_features = array();
|
|
||||||
foreach($features as $k => $v) {
|
|
||||||
foreach($v as $f)
|
|
||||||
$all_features[] = $f[0];
|
|
||||||
}
|
|
||||||
foreach($all_features as $k) {
|
|
||||||
if(x($_POST,"feature_$k"))
|
|
||||||
set_pconfig(local_channel(),'feature',$k, 1);
|
|
||||||
else
|
else
|
||||||
set_pconfig(local_channel(),'feature',$k, 0);
|
set_pconfig(local_channel(),'feature', $k, '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
build_sync_packet();
|
build_sync_packet();
|
||||||
return;
|
return;
|
||||||
@ -36,6 +26,8 @@ class Features {
|
|||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
$arr = [];
|
$arr = [];
|
||||||
|
$harr = [];
|
||||||
|
|
||||||
if(intval($_REQUEST['techlevel']))
|
if(intval($_REQUEST['techlevel']))
|
||||||
$level = intval($_REQUEST['techlevel']);
|
$level = intval($_REQUEST['techlevel']);
|
||||||
else {
|
else {
|
||||||
@ -44,16 +36,29 @@ class Features {
|
|||||||
|
|
||||||
$techlevels = \Zotlabs\Lib\Techlevels::levels();
|
$techlevels = \Zotlabs\Lib\Techlevels::levels();
|
||||||
|
|
||||||
$def_techlevel = \App::$account['account_level'];
|
unset($techlevels[0]);
|
||||||
|
|
||||||
|
logger('techlevels: ' . print_r($techlevels,true));
|
||||||
|
|
||||||
|
$def_techlevel = (($level > 0) ? $level : 1);
|
||||||
$techlock = get_config('system','techlevel_lock');
|
$techlock = get_config('system','techlevel_lock');
|
||||||
|
|
||||||
|
$all_features_raw = get_features(false);
|
||||||
|
|
||||||
|
foreach($all_features_raw as $fname => $fdata) {
|
||||||
|
foreach(array_slice($fdata,1) as $f) {
|
||||||
|
$harr[$f[0]] = ((intval(feature_enabled(local_channel(),$f[0]))) ? "1" : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$features = get_features(true,$level);
|
$features = get_features(true,$level);
|
||||||
|
|
||||||
foreach($features as $fname => $fdata) {
|
foreach($features as $fname => $fdata) {
|
||||||
$arr[$fname] = array();
|
$arr[$fname] = array();
|
||||||
$arr[$fname][0] = $fdata[0];
|
$arr[$fname][0] = $fdata[0];
|
||||||
foreach(array_slice($fdata,1) as $f) {
|
foreach(array_slice($fdata,1) as $f) {
|
||||||
$arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(feature_enabled(local_channel(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On')));
|
$arr[$fname][1][] = array('feature_' . $f[0],$f[1],((intval(feature_enabled(local_channel(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On')));
|
||||||
|
unset($harr[$f[0]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +69,8 @@ class Features {
|
|||||||
'$techlevel' => [ 'techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience and additional features consistent with your comfort level'), $techlevels ],
|
'$techlevel' => [ 'techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience and additional features consistent with your comfort level'), $techlevels ],
|
||||||
'$techlock' => $techlock,
|
'$techlock' => $techlock,
|
||||||
'$features' => $arr,
|
'$features' => $arr,
|
||||||
|
'$hiddens' => $harr,
|
||||||
|
'$baseurl' => z_root(),
|
||||||
'$submit' => t('Submit'),
|
'$submit' => t('Submit'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#id_techlevel').change(function() {
|
||||||
|
var techlvl = $('#id_techlevel').val();
|
||||||
|
window.location.href='{{$baseurl}}/settings/features?f=&techlevel=' + techlvl;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="generic-content-wrapper">
|
<div class="generic-content-wrapper">
|
||||||
<div class="section-title-wrapper">
|
<div class="section-title-wrapper">
|
||||||
<h2>{{$title}}</h2>
|
<h2>{{$title}}</h2>
|
||||||
@ -11,6 +20,12 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<input type="hidden" name="techlevel" value="{{$techlevel.2}}" />
|
<input type="hidden" name="techlevel" value="{{$techlevel.2}}" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $hiddens}}
|
||||||
|
{{foreach $hiddens as $k => $v}}
|
||||||
|
<input type="hidden" name="feature_{{$k}}" value="{{$v}}" />
|
||||||
|
{{/foreach}}
|
||||||
|
{{/if}}
|
||||||
<div class="panel-group" id="settings" role="tablist" aria-multiselectable="true">
|
<div class="panel-group" id="settings" role="tablist" aria-multiselectable="true">
|
||||||
{{foreach $features as $g => $f}}
|
{{foreach $features as $g => $f}}
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
Reference in New Issue
Block a user