diff options
Diffstat (limited to 'Zotlabs/Module/Settings')
-rw-r--r-- | Zotlabs/Module/Settings/Channel.php | 48 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Display.php | 17 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Featured.php | 29 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Permcats.php | 117 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Tokens.php | 3 |
5 files changed, 197 insertions, 17 deletions
diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index a73aa2e60..5b9cfdaca 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -18,6 +18,7 @@ class Channel { $role = ((x($_POST,'permissions_role')) ? notags(trim($_POST['permissions_role'])) : ''); $oldrole = get_pconfig(local_channel(),'system','permissions_role'); + if(($role != $oldrole) || ($role === 'custom')) { @@ -88,15 +89,17 @@ class Channel { intval(local_channel()) ); } - - $x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['perms_connect']); - foreach($x as $k => $v) { - set_abconfig(local_channel(),$channel['channel_hash'],'my_perms',$k, $v); - if($role_permissions['perms_auto']) { - set_pconfig(local_channel(),'autoperms',$k,$v); - } - else { - del_pconfig(local_channel(),'autoperms',$k); + + if($role_permissions['perms_connect']) { + $x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['perms_connect']); + foreach($x as $k => $v) { + set_abconfig(local_channel(),$channel['channel_hash'],'my_perms',$k, $v); + if($role_permissions['perms_auto']) { + set_pconfig(local_channel(),'autoperms',$k,$v); + } + else { + del_pconfig(local_channel(),'autoperms',$k); + } } } @@ -142,6 +145,7 @@ class Channel { $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0); $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0); $adult = (($_POST['adult'] == 1) ? 1 : 0); + $defpermcat = ((x($_POST,'defpermcat')) ? notags(trim($_POST['defpermcat'])) : 'default'); $cal_first_day = (((x($_POST,'first_day')) && (intval($_POST['first_day']) == 1)) ? 1: 0); @@ -230,6 +234,7 @@ class Channel { set_pconfig(local_channel(),'system','photo_path',$photo_path); set_pconfig(local_channel(),'system','attach_path',$attach_path); set_pconfig(local_channel(),'system','cal_first_day',$cal_first_day); + set_pconfig(local_channel(),'system','default_permcat',$defpermcat); $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d", dbesc($username), @@ -409,6 +414,19 @@ class Channel { '$basepath' => \App::get_hostname() )); + + + $pcat = new \Zotlabs\Lib\Permcat(local_channel()); + $pcatlist = $pcat->listing(); + $permcats = []; + if($pcatlist) { + foreach($pcatlist as $pc) { + $permcats[$pc['name']] = $pc['localname']; + } + } + + $default_permcat = get_pconfig(local_channel(),'system','default_permcat','default'); + $stpl = get_markup_template('settings.tpl'); @@ -448,7 +466,10 @@ class Channel { $always_show_in_notices = get_pconfig(local_channel(),'system','always_show_in_notices'); if($vnotify === false) $vnotify = (-1); - + + $plugin = [ 'basic' => '', 'security' => '', 'notify' => '', 'misc' => '' ]; + call_hooks('channel_settings',$plugin); + $o .= replace_macros($stpl,array( '$ptitle' => t('Channel Settings'), @@ -495,7 +516,8 @@ class Channel { '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', $perm_roles), - + '$defpermcat' => [ 'defpermcat', t('Default Permissions Group'), $default_permcat, '', $permcats ], + '$permcat_enable' => feature_enabled(local_channel(),'permcats'), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, @@ -537,6 +559,10 @@ class Channel { '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), + '$basic_addon' => $plugin['basic'], + '$sec_addon' => $plugin['security'], + '$notify_addon' => $plugin['notify'], + '$misc_addon' => $plugin['misc'], '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index 25d1d21a0..eae44e82c 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -65,7 +65,7 @@ class Display { set_pconfig(local_channel(),'system','manual_conversation_update', $manual_update); $newschema = ''; - if($theme == $existing_theme){ + if($theme){ // call theme_post only if theme has not been changed if( ($themeconfigfile = $this->get_theme_config_file($theme)) != null){ require_once($themeconfigfile); @@ -130,12 +130,20 @@ class Display { if($allowed_themes) { foreach($allowed_themes as $th) { $f = $th; + + $info = get_theme_info($th); + $compatible = check_plugin_versions($info); + if(!$compatible) { + $mobile_themes[$f] = $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); + continue; + } + $is_experimental = file_exists('view/theme/' . $th . '/experimental'); $unsupported = file_exists('view/theme/' . $th . '/unsupported'); $is_mobile = file_exists('view/theme/' . $th . '/mobile'); $is_library = file_exists('view/theme/'. $th . '/library'); - $mobile_themes["---"] = t("No special theme for mobile devices"); - + $mobile_themes['---'] = t("No special theme for mobile devices"); + if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ $theme_name = (($is_experimental) ? sprintf(t('%s - (Experimental)'), $f) : $f); if (! $is_library) { @@ -147,7 +155,6 @@ class Display { } } } - } } @@ -206,7 +213,7 @@ class Display { '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1-intval($nosmile), '', $yes_no), - '$manual_update' => array('manual_update', t('Manual conversation updates'), channel_manual_conv_update(local_channel()), t('Default is automatic, which may increase screen jumping'), $yes_no), + '$manual_update' => array('manual_update', t('Manual conversation updates'), channel_manual_conv_update(local_channel()), t('Default is on, turning this off may increase screen jumping'), $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php index eec5f6c02..4885abd1d 100644 --- a/Zotlabs/Module/Settings/Featured.php +++ b/Zotlabs/Module/Settings/Featured.php @@ -10,6 +10,16 @@ class Featured { call_hooks('feature_settings_post', $_POST); + if(intval($_POST['affinity_cmax'])) { + set_pconfig(local_channel(),'affinity','cmax',intval($_POST['affinity_cmax'])); + } + if(intval($_POST['affinity_cmin'])) { + set_pconfig(local_channel(),'affinity','cmin',intval($_POST['affinity_cmin'])); + } + if(intval($_POST['affinity_cmax']) || intval($_POST['affinity_cmin'])) { + info( t('Affinity Slider settings updated.') . EOL); + } + build_sync_packet(); return; } @@ -23,6 +33,25 @@ class Featured { if(! $r) $settings_addons = t('No feature settings configured'); + if(feature_enabled(local_channel(),'affinity')) { + + $cmax = intval(get_pconfig(local_channel(),'affinity','cmax')); + $cmax = (($cmax) ? $cmax : 99); + $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array( + '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, '') + )); + $cmin = intval(get_pconfig(local_channel(),'affinity','cmin')); + $cmin = (($cmin) ? $cmin : 0); + $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array( + '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, '') + )); + + $settings_addons .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array( + '$addon' => array('affinity_slider', '' . t('Affinity Slider Settings'), '', t('Submit')), + '$content' => $setting_fields + )); + } + call_hooks('feature_settings', $settings_addons); $tpl = get_markup_template("settings_addons.tpl"); diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php new file mode 100644 index 000000000..35d533196 --- /dev/null +++ b/Zotlabs/Module/Settings/Permcats.php @@ -0,0 +1,117 @@ +<?php + +namespace Zotlabs\Module\Settings; + + + +class Permcats { + + function post() { + + if(! local_channel()) + return; + + $channel = \App::get_channel(); + + check_form_security_token_redirectOnErr('/settings/permcats', 'settings_permcats'); + + + $all_perms = \Zotlabs\Access\Permissions::Perms(); + + $name = escape_tags(trim($_POST['name'])); + + $pcarr = []; + + if($all_perms) { + foreach($all_perms as $perm => $desc) { + if(array_key_exists('perms_' . $perm, $_POST)) { + $pcarr[] = $perm; + } + } + } + + \Zotlabs\Lib\Permcat::update(local_channel(),$name,$pcarr); + + build_sync_packet(); + + info( t('Permission category saved.') . EOL); + + return; + } + + + function get() { + +logger('cmd: ' . \App::$cmd); + + if(! local_channel()) + return; + + $channel = \App::get_channel(); + + + if(argc() > 2) + $name = argv(2); + + if(argc() > 3 && argv(3) === 'drop') { + \Zotlabs\Lib\Permcat::delete(local_channel(),$name); + build_sync_packet(); + json_return_and_die([ 'success' => true ]); + } + + + $desc = t('Use this form to create permission rules for various classes of people or connections.'); + + $existing = []; + + $pcat = new \Zotlabs\Lib\Permcat(local_channel()); + $pcatlist = $pcat->listing(); + $permcats = []; + if($pcatlist) { + foreach($pcatlist as $pc) { + if(($pc['name']) && ($name) && ($pc['name'] == $name)) + $existing = $pc['perms']; + if(! $pc['system']) + $permcats[$pc['name']] = $pc['localname']; + } + } + + $global_perms = \Zotlabs\Access\Permissions::Perms(); + + foreach($global_perms as $k => $v) { + $thisperm = \Zotlabs\Lib\Permcat::find_permcat($existing,$k); + $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k); + + if($existing[$k]) + $thisperm = "1"; + + $perms[] = array('perms_' . $k, $v, ((array_key_exists($k,$their_perms)) ? intval($their_perms[$k]) : ''),$thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); + } + + + + $tpl = get_markup_template("settings_permcats.tpl"); + $o .= replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("settings_permcats"), + '$title' => t('Permission Categories'), + '$desc' => $desc, + '$desc2' => $desc2, + '$tokens' => $t, + '$permcats' => $permcats, + '$atoken' => $atoken, + '$url1' => z_root() . '/channel/' . $channel['channel_address'], + '$url2' => z_root() . '/photos/' . $channel['channel_address'], + '$name' => array('name', t('Permission Name') . ' <span class="required">*</span>', (($name) ? $name : ''), ''), + '$me' => t('My Settings'), + '$perms' => $perms, + '$inherited' => t('inherited'), + '$notself' => 0, + '$self' => 1, + '$permlbl' => t('Individual Permissions'), + '$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'), + '$submit' => t('Submit') + )); + return $o; + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Settings/Tokens.php b/Zotlabs/Module/Settings/Tokens.php index d32a00c95..bf22ec7aa 100644 --- a/Zotlabs/Module/Settings/Tokens.php +++ b/Zotlabs/Module/Settings/Tokens.php @@ -161,7 +161,8 @@ class Tokens { '$me' => t('My Settings'), '$perms' => $perms, '$inherited' => t('inherited'), - '$notself' => '1', + '$notself' => 0, + '$self' => 1, '$permlbl' => t('Individual Permissions'), '$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'), '$submit' => t('Submit') |