From 238621ee926e43625a8b15fb9faf996fb45149b3 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 23 Aug 2016 23:00:24 -0700 Subject: allow changing the server role - as well as configuring any of the three options during installation --- Zotlabs/Module/Admin.php | 13 +++++++++++++ Zotlabs/Module/Setup.php | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index eede5a045..15edbd407 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -268,6 +268,8 @@ class Admin extends \Zotlabs\Web\Controller { check_form_security_token_redirectOnErr('/admin/site', 'admin_site'); $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : ''); + $server_role = ((x($_POST,'server_role')) ? notags(trim($_POST['server_role'])) : 'standard'); + $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); $admininfo = ((x($_POST,'admininfo')) ? trim($_POST['admininfo']) : false); $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); @@ -308,6 +310,8 @@ class Admin extends \Zotlabs\Web\Controller { $feed_contacts = ((x($_POST,'feed_contacts')) ? intval($_POST['feed_contacts']) : 0); $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); + + set_config('system', 'server_role', $server_role); set_config('system', 'feed_contacts', $feed_contacts); set_config('system', 'delivery_interval', $delivery_interval); set_config('system', 'delivery_batch_count', $delivery_batch_count); @@ -481,6 +485,12 @@ class Admin extends \Zotlabs\Web\Controller { // now invert the logic for the setting. $discover_tab = (1 - $discover_tab); + $server_roles = [ + 'basic' => t('Basic/Minimal Social Networking'), + 'standard' => t('Standard Configuration (default)'), + 'pro' => t('Professional') + ]; + $homelogin = get_config('system','login_on_homepage'); $enable_context_help = get_config('system','enable_context_help'); @@ -498,6 +508,9 @@ class Admin extends \Zotlabs\Web\Controller { '$baseurl' => z_root(), // name, label, value, help string, extra data... '$sitename' => array('sitename', t("Site name"), htmlspecialchars(get_config('system','sitename'), ENT_QUOTES, 'UTF-8'),''), + + '$server_role' => array('server_role', t("Server Configuration/Role"), get_config('system','server_role'),'',$server_roles), + '$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")), '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices), diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index cb43b5c20..f8e210410 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -73,7 +73,9 @@ class Setup extends \Zotlabs\Web\Controller { $phpath = trim($_POST['phpath']); $adminmail = trim($_POST['adminmail']); $siteurl = trim($_POST['siteurl']); - $advanced = ((intval($_POST['advanced'])) ? 1 : 0); + $server_role = trim($_POST['server_role']); + if(! $server_role) + $server_role = 'standard'; // $siteurl should not have a trailing slash @@ -101,7 +103,9 @@ class Setup extends \Zotlabs\Web\Controller { $timezone = notags(trim($_POST['timezone'])); $adminmail = notags(trim($_POST['adminmail'])); $siteurl = notags(trim($_POST['siteurl'])); - $advanced = ((intval($_POST['advanced'])) ? 'standard' : 'basic'); + $server_role = notags(trim($_POST['server_role'])); + if(! $server_role) + $server_role = 'standard'; if($siteurl != z_root()) { $test = z_fetch_url($siteurl."/setup/testrewrite"); @@ -130,7 +134,7 @@ class Setup extends \Zotlabs\Web\Controller { '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$dbtype' => $dbtype, - '$server_role' => $advanced, + '$server_role' => $server_role, '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), @@ -327,6 +331,12 @@ class Setup extends \Zotlabs\Web\Controller { $siteurl = notags(trim($_POST['siteurl'])); $timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles'); + $server_roles = [ + 'basic' => t('Basic/Minimal Social Networking'), + 'standard' => t('Standard Configuration (default)'), + 'pro' => t('Professional') + ]; + $tpl = get_markup_template('install_settings.tpl'); $o .= replace_macros($tpl, array( '$title' => $install_title, @@ -344,7 +354,8 @@ class Setup extends \Zotlabs\Web\Controller { '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), '$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')), - '$advanced' => array('advanced', t('Enable $Projectname advanced features?'), 1, t('Some advanced features, while useful - may be best suited for technically proficient audiences')), + + '$server_role' => array('server_role', t("Server Configuration/Role"), 'standard','',$server_roles), '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()), -- cgit v1.2.3 From dd654b976691d5091070631c5e64979cd2772a6f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 24 Aug 2016 13:11:01 -0700 Subject: provide a mechanism for global template values (macro replacements that are available to all templates). There's a strong likelihood this list will increase but we may wish to actively prevent it from mushrooming out of control. --- Zotlabs/Render/SmartyTemplate.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Render/SmartyTemplate.php b/Zotlabs/Render/SmartyTemplate.php index 532d6e42f..b7e68c1bc 100755 --- a/Zotlabs/Render/SmartyTemplate.php +++ b/Zotlabs/Render/SmartyTemplate.php @@ -27,6 +27,12 @@ class SmartyTemplate implements TemplateEngine { public function replace_macros($s, $r) { $template = ''; + + // these are available for use in all templates + + $r['$z_baseurl'] = z_root(); + $r['$z_server_role'] = \Zotlabs\Lib\System::get_server_role(); + if(gettype($s) === 'string') { $template = $s; $s = new SmartyInterface(); -- cgit v1.2.3 From f1fbcd7c02bb06e262b60fd40594c04e1c871b66 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 24 Aug 2016 17:42:59 -0700 Subject: some more complex test scenarios for comanche conditionals: equals x, not equals x, in_array, and array_key_exists --- Zotlabs/Render/Comanche.php | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 820897ee9..ff5aa7140 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -103,14 +103,50 @@ class Comanche { function test_condition($s) { - // This is extensible. The first version of variable testing supports tests of the form + // This is extensible. The first version of variable testing supports tests of the forms: + // [if $config.system.foo == baz] which will check if get_config('system','foo') is the string 'baz'; + // [if $config.system.foo != baz] which will check if get_config('system','foo') is not the string 'baz'; + // You may check numeric entries, but these checks are evaluated as strings. + // [if $config.system.foo {} baz] which will check if 'baz' is an array element in get_config('system','foo') + // [if $config.system.foo {*} baz] which will check if 'baz' is an array key in get_config('system','foo') // [if $config.system.foo] which will check for a return of a true condition for get_config('system','foo'); // The values 0, '', an empty array, and an unset value will all evaluate to false. - if(preg_match("/[\$]config[\.](.*?)/",$s,$matches)) { - $x = explode('.',$s); - if(get_config($x[1],$x[2])) + if(preg_match('/[\$]config[\.](.*?)\s\=\=\s(.*?)$/',$s,$matches)) { + $x = explode('.',$matches[1]); + if(get_config(trim($x[0]),trim($x[1])) == trim($matches[2])) return true; + return false; + } + if(preg_match('/[\$]config[\.](.*?)\s\!\=\s(.*?)$/',$s,$matches)) { + $x = explode('.',$matches[1]); + if(get_config(trim($x[0]),trim($x[1])) != trim($matches[2])) + return true; + return false; + } + + if(preg_match('/[\$]config[\.](.*?)\s\{\}\s(.*?)$/',$s,$matches)) { + $x = explode('.',$matches[1]); + $y = get_config(trim($x[0]),trim($x[1])); + if(is_array($y) && in_array(trim($matches[2]),$y)) + return true; + return false; + } + + if(preg_match('/[\$]config[\.](.*?)\s\{\*\}\s(.*?)$/',$s,$matches)) { + $x = explode('.',$matches[1]); + $y = get_config(trim($x[0]),trim($x[1])); + if(is_array($y) && array_key_exists(trim($matches[2]),$y)) + return true; + return false; + } + + + if(preg_match('/[\$]config[\.](.*?)/',$s,$matches)) { + $x = explode('.',$matches[1]); + if(get_config(trim($x[0]),trim($x[1]))) + return true; + return false; } return false; -- cgit v1.2.3 From 38ea8bee935181220e89fd22120865ab63af9da6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 25 Aug 2016 17:43:07 -0700 Subject: ratings are gone. They can be enabled, but there is no UI for doing so at this time; and will likely only be available in a 'pro' configuration once the new implementation details have been hashed out. This appears to require a mechanism for rebuttal before it can again be opened to the public. There are also some synchronisation issues to contend with; as ratings are currently only distributed to active directory servers. There is no reliable mechanism for a new directory server to fetch existing ratings. --- Zotlabs/Module/Connedit.php | 8 ++------ Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Pubsites.php | 14 +++++++++++--- Zotlabs/Module/Rate.php | 10 +++------- Zotlabs/Module/Ratings.php | 14 ++++---------- 5 files changed, 21 insertions(+), 27 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 217249469..43feac189 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -663,13 +663,9 @@ class Connedit extends \Zotlabs\Web\Controller { $rating_text = $xl[0]['xlink_rating_text']; } - $poco_rating = get_config('system','poco_rating_enable'); + $rating_enabled = get_config('system','rating_enabled'); - // if unset default to enabled - if($poco_rating === false) - $poco_rating = true; - - if($poco_rating) { + if($rating_enabled) { $rating = replace_macros(get_markup_template('rating_slider.tpl'),array( '$min' => -10, '$val' => $rating_val diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 560038ffc..84d40a166 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -239,7 +239,7 @@ class Directory extends \Zotlabs\Web\Controller { $page_type = ''; - if($rr['total_ratings']) + if($rr['total_ratings'] && get_config('system','rating_enabled')) $total_ratings = sprintf( tt("%d rating", "%d ratings", $rr['total_ratings']), $rr['total_ratings']); else $total_ratings = ''; diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php index 0dda08e6d..35a305130 100644 --- a/Zotlabs/Module/Pubsites.php +++ b/Zotlabs/Module/Pubsites.php @@ -16,7 +16,9 @@ class Pubsites extends \Zotlabs\Web\Controller { $url = $directory['url'] . '/dirsearch'; } $url .= '/sites'; - + + $rating_enabled = get_config('system','rating_enabled'); + $o .= '
'; $o .= '

' . t('Public Hubs') . '

'; @@ -28,7 +30,10 @@ class Pubsites extends \Zotlabs\Web\Controller { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $o .= ''; + $o .= '
' . t('Hub URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Stats') . '' . t('Software') . '' . t('Ratings') . '
'; + if($rating_enabled) + $o .= ''; + $o .= ''; if($j['sites']) { foreach($j['sites'] as $jj) { $m = parse_url($jj['url']); @@ -44,7 +49,10 @@ class Pubsites extends \Zotlabs\Web\Controller { $location = '
 '; } $urltext = str_replace(array('https://'), '', $jj['url']); - $o .= '' . $rate_links . ''; + $o .= ''; + if($rating_enabled) + $o .= '' . $rate_links ; + $o .= ''; } } diff --git a/Zotlabs/Module/Rate.php b/Zotlabs/Module/Rate.php index 2f769b36b..c03aaa54f 100644 --- a/Zotlabs/Module/Rate.php +++ b/Zotlabs/Module/Rate.php @@ -119,8 +119,8 @@ class Rate extends \Zotlabs\Web\Controller { // return; // } - $poco_rating = get_config('system','poco_rating_enable'); - if((! $poco_rating) && ($poco_rating !== false)) { + $rating_enabled = get_config('system','rating_enabled'); + if(! $rating_enabled) { notice('Ratings are disabled on this site.'); return; } @@ -141,11 +141,7 @@ class Rate extends \Zotlabs\Web\Controller { $rating_text = ''; } - // if unset default to enabled - if($poco_rating === false) - $poco_rating = true; - - if($poco_rating) { + if($rating_enabled) { $rating = replace_macros(get_markup_template('rating_slider.tpl'),array( '$min' => -10, '$val' => $rating_val diff --git a/Zotlabs/Module/Ratings.php b/Zotlabs/Module/Ratings.php index 969fb5015..055b16ca3 100644 --- a/Zotlabs/Module/Ratings.php +++ b/Zotlabs/Module/Ratings.php @@ -21,12 +21,9 @@ class Ratings extends \Zotlabs\Web\Controller { if($x) $url = $x['url']; - $poco_rating = get_config('system','poco_rating_enable'); - // if unset default to enabled - if($poco_rating === false) - $poco_rating = true; + $rating_enabled = get_config('system','rating_enabled'); - if(! $poco_rating) + if(! $rating_enabled) return; if(argc() > 1) @@ -87,12 +84,9 @@ class Ratings extends \Zotlabs\Web\Controller { return; } - $poco_rating = get_config('system','poco_rating_enable'); - // if unset default to enabled - if($poco_rating === false) - $poco_rating = true; + $rating_enabled = get_config('system','rating_enabled'); - if(! $poco_rating) + if(! $rating_enabled) return; $site_target = ((array_key_exists('target',\App::$data) && array_key_exists('site_url',\App::$data['target'])) ? -- cgit v1.2.3 From 86dd67f57da2f36ab4d4706ce0022e0fd4579b76 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 26 Aug 2016 13:58:37 -0700 Subject: comanche: generalise the conditional variable usage and add $observer as a test. Update comanche doco to reflect recent changes. --- Zotlabs/Render/Comanche.php | 46 ++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index ff5aa7140..b0efa5e0b 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -99,7 +99,18 @@ class Comanche { } } - + function get_condition_var($v) { + if($v) { + $x = explode('.',$v); + if($x[0] == 'config') + return get_config($x[1],$x[2]); + elseif($x[0] === 'observer') + return get_observer_hash(); + else + return false; + } + return false; + } function test_condition($s) { @@ -112,39 +123,36 @@ class Comanche { // [if $config.system.foo] which will check for a return of a true condition for get_config('system','foo'); // The values 0, '', an empty array, and an unset value will all evaluate to false. - if(preg_match('/[\$]config[\.](.*?)\s\=\=\s(.*?)$/',$s,$matches)) { - $x = explode('.',$matches[1]); - if(get_config(trim($x[0]),trim($x[1])) == trim($matches[2])) + if(preg_match('/[\$](.*?)\s\=\=\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x == trim($matches[2])) return true; return false; } - if(preg_match('/[\$]config[\.](.*?)\s\!\=\s(.*?)$/',$s,$matches)) { - $x = explode('.',$matches[1]); - if(get_config(trim($x[0]),trim($x[1])) != trim($matches[2])) + if(preg_match('/[\$](.*?)\s\!\=\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x != trim($matches[2])) return true; return false; } - if(preg_match('/[\$]config[\.](.*?)\s\{\}\s(.*?)$/',$s,$matches)) { - $x = explode('.',$matches[1]); - $y = get_config(trim($x[0]),trim($x[1])); - if(is_array($y) && in_array(trim($matches[2]),$y)) + if(preg_match('/[\$](.*?)\s\{\}\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if(is_array($x) && in_array(trim($matches[2]),$x)) return true; return false; } - if(preg_match('/[\$]config[\.](.*?)\s\{\*\}\s(.*?)$/',$s,$matches)) { - $x = explode('.',$matches[1]); - $y = get_config(trim($x[0]),trim($x[1])); - if(is_array($y) && array_key_exists(trim($matches[2]),$y)) + if(preg_match('/[\$](.*?)\s\{\*\}\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if(is_array($x) && array_key_exists(trim($matches[2]),$x)) return true; return false; } - - if(preg_match('/[\$]config[\.](.*?)/',$s,$matches)) { - $x = explode('.',$matches[1]); - if(get_config(trim($x[0]),trim($x[1]))) + if(preg_match('/[\$](.*?)/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x) return true; return false; } -- cgit v1.2.3 From 8e243edd20e758082c3c30fd3053bd9fb0d11dcf Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 26 Aug 2016 14:43:58 -0700 Subject: add a couple of useful observer constructs to support identity aware pages --- Zotlabs/Render/Comanche.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index b0efa5e0b..91f0ce33a 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -104,8 +104,19 @@ class Comanche { $x = explode('.',$v); if($x[0] == 'config') return get_config($x[1],$x[2]); - elseif($x[0] === 'observer') + elseif($x[0] === 'observer') { + if(count($x) > 1) { + $y = \App::get_observer(); + if(! $y) + return false; + if($x[1] == 'address') + return $y['xchan_addr']; + elseif($x[1] == 'name') + return $y['xchan_name']; + return false; + } return get_observer_hash(); + } else return false; } -- cgit v1.2.3
' . t('Hub URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Stats') . '' . t('Software') . '' . t('Ratings') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . '' . '' . ucwords($jj['project']) . ' ' . t('View') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . '' . '' . ucwords($jj['project']) . ' ' . t('View') . '