From c076e72cbf6fe9106956ef1ecf1ec5cf9a8c7fae Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 5 Jan 2016 20:38:32 -0800 Subject: provide an option to toggle the view of locked features so we can use the same list in an admin feature set & lock page. --- include/features.php | 28 +++++++++++++++------------- version.inc | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/features.php b/include/features.php index b02d912cf..3cbbf5b7d 100644 --- a/include/features.php +++ b/include/features.php @@ -36,7 +36,7 @@ function get_feature_default($feature) { } -function get_features() { +function get_features($filtered = true) { $arr = array( @@ -98,20 +98,22 @@ function get_features() { // removed any locked features and remove the entire category if this makes it empty - foreach($arr as $k => $x) { - $has_items = false; - for($y = 0; $y < count($arr[$k]); $y ++) { - if(is_array($arr[$k][$y])) { - if($arr[$k][$y][4] === false) { - $has_items = true; - } - else { - unset($arr[$k][$y]); + if($filtered) { + foreach($arr as $k => $x) { + $has_items = false; + for($y = 0; $y < count($arr[$k]); $y ++) { + if(is_array($arr[$k][$y])) { + if($arr[$k][$y][4] === false) { + $has_items = true; + } + else { + unset($arr[$k][$y]); + } } } - } - if(! $has_items) { - unset($arr[$k]); + if(! $has_items) { + unset($arr[$k]); + } } } diff --git a/version.inc b/version.inc index 8a363fc45..fe3e27349 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2016-01-04.1268H +2016-01-05.1269H -- cgit v1.2.3 From 93565ea768a726a02052bd1279dcf09738057460 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 6 Jan 2016 13:01:28 -0800 Subject: features management page for hubmins --- include/widgets.php | 1 + mod/admin.php | 74 ++++++++++++++++++++++++++++++++++++ version.inc | 2 +- view/tpl/admin_aside.tpl | 1 + view/tpl/admin_settings_features.tpl | 31 +++++++++++++++ 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 view/tpl/admin_settings_features.tpl diff --git a/include/widgets.php b/include/widgets.php index 0f170fd52..a7d06d39e 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1217,6 +1217,7 @@ function widget_admin($arr) { 'site' => array(z_root() . '/admin/site/', t('Site'), 'site'), 'users' => array(z_root() . '/admin/users/', t('Accounts'), 'users'), 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), + 'features' => array(z_root() . '/admin/features/', t('Features'), 'features'), 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), diff --git a/mod/admin.php b/mod/admin.php index 85ab3627c..c175a4a61 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -62,6 +62,9 @@ function admin_post(&$a){ case 'hubloc': admin_page_hubloc_post($a); break; + case 'features': + admin_page_features_post($a); + break; case 'dbsync': admin_page_dbsync_post($a); break; @@ -113,6 +116,9 @@ function admin_content(&$a) { // case 'hubloc': // $o = admin_page_hubloc($a); // break; + case 'features': + $o = admin_page_features($a); + break; case 'logs': $o = admin_page_logs($a); break; @@ -530,6 +536,74 @@ function admin_page_hubloc_post(&$a){ goaway($a->get_baseurl(true) . '/admin/hubloc' ); } + +function admin_page_features_post(&$a) { + + check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features'); + + logger('postvars: ' . print_r($_POST,true)); + + $arr = array(); + $features = get_features(false); + + foreach($features as $fname => $fdata) { + foreach(array_slice($fdata,1) as $f) { + $feature = $f[0]; + + if(array_key_exists('feature_' . $feature,$_POST)) + $val = intval($_POST['feature_' . $feature]); + else + $val = 0; + set_config('feature',$feature,$val); + + if(array_key_exists('featurelock_' . $feature,$_POST)) + set_config('feature_lock',$feature,$val); + else + del_config('feature_lock',$feature); + } + } + + goaway(z_root() . '/admin/features' ); + +} + +function admin_page_features(&$a) { + + if((argc() > 1) && (argv(1) === 'features')) { + $arr = array(); + $features = get_features(false); + + foreach($features as $fname => $fdata) { + $arr[$fname] = array(); + $arr[$fname][0] = $fdata[0]; + foreach(array_slice($fdata,1) as $f) { + + $set = get_config('feature',$f[0]); + if($set === false) + $set = $f[3]; + $arr[$fname][1][] = array( + array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))), + array('featurelock_' .$f[0],sprintf( t('Lock feature %s'),$f[1]),(($f[4] !== false) ? 1 : 0),'',array(t('Off'),t('On'))) + ); + } + } + + $tpl = get_markup_template("admin_settings_features.tpl"); + $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("admin_manage_features"), + '$title' => t('Manage Additional Features'), + '$features' => $arr, + '$submit' => t('Submit'), + )); + + return $o; + } +} + + + + + function admin_page_hubloc(&$a) { $hubloc = q("SELECT hubloc_id, hubloc_addr, hubloc_host, hubloc_status FROM hubloc"); diff --git a/version.inc b/version.inc index fe3e27349..be2d3de4a 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2016-01-05.1269H +2016-01-06.1270H diff --git a/view/tpl/admin_aside.tpl b/view/tpl/admin_aside.tpl index 57ac7f3e1..0a77ef73c 100755 --- a/view/tpl/admin_aside.tpl +++ b/view/tpl/admin_aside.tpl @@ -19,6 +19,7 @@
  • {{$admin.queue.1}}
  • {{$admin.plugins.1}}
  • {{$admin.themes.1}}
  • +
  • {{$admin.features.1}}
  • {{$admin.dbsync.1}}
  • diff --git a/view/tpl/admin_settings_features.tpl b/view/tpl/admin_settings_features.tpl new file mode 100644 index 000000000..2d5cf7e0b --- /dev/null +++ b/view/tpl/admin_settings_features.tpl @@ -0,0 +1,31 @@ +
    +
    +

    {{$title}}

    +
    +
    + +
    + {{foreach $features as $g => $f}} +
    + +
    +
    + {{foreach $f.1 as $fcat}} + {{include file="field_checkbox.tpl" field=$fcat.0}} + {{include file="field_checkbox.tpl" field=$fcat.1}} + {{/foreach}} +
    + +
    +
    +
    +
    + {{/foreach}} +
    +
    -- cgit v1.2.3 From 761afd029d97703f2f7609d546b7b5f3d257c601 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 6 Jan 2016 13:53:49 -0800 Subject: version roll --- boot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index a3e35f63c..4c2cff09b 100755 --- a/boot.php +++ b/boot.php @@ -47,8 +47,8 @@ require_once('include/AccessList.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'H'); -define ( 'STD_VERSION', '1.0.1' ); +define ( 'RED_VERSION', trim(file_get_contents('version.inc'))); +define ( 'STD_VERSION', '1.1' ); define ( 'ZOT_REVISION', 1 ); define ( 'DB_UPDATE_VERSION', 1161 ); -- cgit v1.2.3