aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Admin.php13
-rw-r--r--Zotlabs/Module/Connedit.php8
-rw-r--r--Zotlabs/Module/Directory.php2
-rw-r--r--Zotlabs/Module/Pubsites.php14
-rw-r--r--Zotlabs/Module/Rate.php10
-rw-r--r--Zotlabs/Module/Ratings.php14
-rw-r--r--Zotlabs/Module/Setup.php19
-rw-r--r--Zotlabs/Render/Comanche.php65
-rwxr-xr-xZotlabs/Render/SmartyTemplate.php6
9 files changed, 115 insertions, 36 deletions
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/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 .= '<div class="generic-content-wrapper">';
$o .= '<div class="section-title-wrapper"><h2>' . t('Public Hubs') . '</h2></div>';
@@ -28,7 +30,10 @@ class Pubsites extends \Zotlabs\Web\Controller {
if($ret['success']) {
$j = json_decode($ret['body'],true);
if($j) {
- $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Stats') . '</td><td>' . t('Software') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>';
+ $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Stats') . '</td><td>' . t('Software') . '</td>';
+ if($rating_enabled)
+ $o .= '<td colspan="2">' . t('Ratings') . '</td>';
+ $o .= '</tr>';
if($j['sites']) {
foreach($j['sites'] as $jj) {
$m = parse_url($jj['url']);
@@ -44,7 +49,10 @@ class Pubsites extends \Zotlabs\Web\Controller {
$location = '<br />&nbsp;';
}
$urltext = str_replace(array('https://'), '', $jj['url']);
- $o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . '<a target="stats" href="https://hubchart-tarine.rhcloud.com/hub.jsp?hubFqdn=' . $m['host'] . '"><i class="fa fa-area-chart"></i></a></td><td>' . ucwords($jj['project']) . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links . '</tr>';
+ $o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . '<a target="stats" href="https://hubchart-tarine.rhcloud.com/hub.jsp?hubFqdn=' . $m['host'] . '"><i class="fa fa-area-chart"></i></a></td><td>' . ucwords($jj['project']) . '</td>';
+ if($rating_enabled)
+ $o .= '<td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links ;
+ $o .= '</tr>';
}
}
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'])) ?
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 <strong>advanced</strong> 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()),
diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php
index 820897ee9..91f0ce33a 100644
--- a/Zotlabs/Render/Comanche.php
+++ b/Zotlabs/Render/Comanche.php
@@ -99,18 +99,73 @@ 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') {
+ 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;
+ }
+ return false;
+ }
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('/[\$](.*?)\s\=\=\s(.*?)$/',$s,$matches)) {
+ $x = $this->get_condition_var($matches[1]);
+ if($x == trim($matches[2]))
+ return true;
+ return false;
+ }
+ 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('/[\$](.*?)\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('/[\$](.*?)\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('/[\$](.*?)/',$s,$matches)) {
+ $x = $this->get_condition_var($matches[1]);
+ if($x)
return true;
+ return false;
}
return false;
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();