add some more stuff to admin/account_edit (service class, language, and techlevel if appropriate). Fix en-au and en-gb so they are listed as languages, and move language selector stuff to include/language.php instead of include/text.php; new file Zotlabs/Lib/Techlevels.php so we only need to write the selection array once.

This commit is contained in:
redmatrix 2016-10-03 17:16:24 -07:00
parent 5b10db6f91
commit cef1aa6d1b
8 changed files with 145 additions and 45 deletions

View File

@ -0,0 +1,21 @@
<?php
namespace Zotlabs\Lib;
class Techlevels {
static public function levels() {
$techlevels = [
'0' => t('Beginner/Basic'),
'1' => t('Novice - not skilled but willing to learn'),
'2' => t('Intermediate - somewhat comfortable'),
'3' => t('Advanced - very comfortable'),
'4' => t('Expert - I can write computer code'),
'5' => t('Wizard - I probably know more than you do')
];
return $techlevels;
}
}

View File

@ -29,6 +29,22 @@ class Account_edit {
info( sprintf( t('Password changed for account %d.'), $account_id). EOL);
}
$service_class = trim($_REQUEST['service_class']);
$account_level = intval(trim($_REQUEST['account_level']));
$account_language = trim($_REQUEST['account_language']);
$r = q("update account set account_service_class = '%s', account_level = %d, account_language = '%s'
where account_id = %d",
dbesc($service_class),
intval($account_level),
dbesc($account_language),
intval($account_id)
);
if($r)
info( t('Account settings updated.') . EOL);
goaway(z_root() . '/admin/accounts');
}
@ -46,11 +62,15 @@ class Account_edit {
return '';
}
$a = replace_macros(get_markup_template('admin_account_edit.tpl'), [
'$account' => $x[0],
'$title' => t('Account Edit'),
'$pass1' => [ 'pass1', t('New Password'), ' ','' ],
'$pass2' => [ 'pass2', t('New Password again'), ' ','' ],
'$account_level' => [ 'account_level', t('Technical skill level'), $x[0]['account_level'], '', \Zotlabs\Lib\Techlevels::levels() ],
'$account_language' => [ 'account_language' , t('Account language (for emails)'), $x[0]['account_language'], '', language_list() ],
'$service_class' => [ 'service_class', t('Service class'), $x[0]['account_service_class'], '' ],
'$submit' => t('Submit'),
]
);

View File

@ -101,15 +101,7 @@ class Account {
$email = \App::$account['account_email'];
$techlevels = [
'0' => t('Beginner/Basic'),
'1' => t('Novice - not skilled but willing to learn'),
'2' => t('Intermediate - somewhat comfortable'),
'3' => t('Advanced - very comfortable'),
'4' => t('Expert - I can write computer code'),
'5' => t('Wizard - I probably know more than you do')
];
$techlevels = \Zotlabs\Lib\Techlevels::levels();
$def_techlevel = \App::$account['account_level'];
$techlock = get_config('system','techlevel_lock');

View File

@ -327,3 +327,61 @@ function get_language_name($s, $l = null) {
return $language->getName();
}
function language_list() {
$langs = glob('view/*/hstrings.php');
$lang_options = array();
$selected = "";
if(is_array($langs) && count($langs)) {
if(! in_array('view/en/hstrings.php',$langs))
$langs[] = 'view/en/';
asort($langs);
foreach($langs as $l) {
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
$lang_options[$ll] = get_language_name($ll, $ll) . " ($ll)";
}
}
return $lang_options;
}
function lang_selector() {
$langs = glob('view/*/hstrings.php');
$lang_options = array();
$selected = "";
if(is_array($langs) && count($langs)) {
$langs[] = '';
if(! in_array('view/en/hstrings.php',$langs))
$langs[] = 'view/en/';
asort($langs);
foreach($langs as $l) {
if($l == '') {
$lang_options[""] = t('default');
continue;
}
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
$selected = (($ll === App::$language && (x($_SESSION, 'language'))) ? $ll : $selected);
$lang_options[$ll] = get_language_name($ll, $ll) . " ($ll)";
}
}
$tpl = get_markup_template('lang_selector.tpl');
$o = replace_macros($tpl, array(
'$title' => t('Select an alternate language'),
'$langs' => array($lang_options, $selected),
));
return $o;
}

View File

@ -1837,42 +1837,6 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
return $o;
}
function lang_selector() {
$langs = glob('view/*/hstrings.php');
$lang_options = array();
$selected = "";
if(is_array($langs) && count($langs)) {
$langs[] = '';
if(! in_array('view/en/hstrings.php',$langs))
$langs[] = 'view/en/';
asort($langs);
foreach($langs as $l) {
if($l == '') {
$lang_options[""] = t('default');
continue;
}
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
$selected = (($ll === App::$language && (x($_SESSION, 'language'))) ? $ll : $selected);
$lang_options[$ll] = get_language_name($ll, $ll) . " ($ll)";
}
}
$tpl = get_markup_template("lang_selector.tpl");
$o = replace_macros($tpl, array(
'$title' => t('Select an alternate language'),
'$langs' => array($lang_options, $selected),
));
return $o;
}
function engr_units_to_bytes ($size_str) {
if(! $size_str)
return $size_str;

5
view/en-au/hstrings.php Normal file
View File

@ -0,0 +1,5 @@
<?php
require_once('view/en-gb/strings.php');
App::$strings['Welcome %s. Remote authentication successful.'] = "G'day %s. Remote authentication successful";

31
view/en-gb/hstrings.php Normal file
View File

@ -0,0 +1,31 @@
<?php
App::$strings["Set shadow color, default #000"] = "Set shadow colour, default #000";
App::$strings["Set background color"] = "Set background colour";
App::$strings["Set section background color"] = "Set section background colour";
App::$strings["Set color of items - use hex"] = "Set colour of items - use hex";
App::$strings["Set color of links - use hex"] = "Set colour of links - use hex";
App::$strings["Set color of fonts - use hex"] = "Set colour of fonts - use hex";
App::$strings["Navigation bar background color"] = "Navigation bar background colour";
App::$strings["Navigation bar gradient top color"] = "Navigation bar gradient top colour";
App::$strings["Navigation bar gradient bottom color"] = "Navigation bar gradient bottom colour";
App::$strings["Navigation active button gradient top color"] = "Navigation active button gradient top colour";
App::$strings["Navigation active button gradient bottom color"] = "Navigation active button gradient bottom colour";
App::$strings["Navigation bar border color "] = "Navigation bar border colour ";
App::$strings["Navigation bar icon color "] = "Navigation bar icon colour ";
App::$strings["Navigation bar active icon color "] = "Navigation bar active icon colour ";
App::$strings["link color"] = "link colour";
App::$strings["Set font-color for banner"] = "Set font-colour for banner";
App::$strings["Set the background color"] = "Set the background colour";
App::$strings["Set the background color of items"] = "Set the background colour of items";
App::$strings["Set the background color of comments"] = "Set the background colour of comments";
App::$strings["Set the border color of comments"] = "Set the border colour of comments";
App::$strings["Set the basic color for item icons"] = "Set the basic colour for item icons";
App::$strings["Set the hover color for item icons"] = "Set the hover colour for item icons";
App::$strings["Set font-color for posts and comments"] = "Set font-colour for posts and comments";
App::$strings["Authorize application connection"] = "Authorise application connection";
App::$strings["Do you want to authorize this application to access your posts and contacts, and/or create new posts for you?"] = "Do you want to authorise this application to access your posts and contacts, and/or create new posts for you?";
App::$strings["If your certificate is not recognized, members of other sites (who may themselves have valid certificates) will get a warning message on their own site complaining about security issues."] = "If your certificate is not recognised, members of other sites (who may themselves have valid certificates) will get a warning message on their own site complaining about security issues.";
App::$strings["This is a hub of the Hubzilla - a global cooperative network of decentralized privacy enhanced websites."] = "This is a hub of the Hubzilla - a global cooperative network of decentralised privacy enhanced websites.";
App::$strings["You are cordially invited to join me and some other close friends on the Hubzilla - a revolutionary new decentralized communication and information tool."] = "You are cordially invited to join me and some other close friends on the Hubzilla - a revolutionary new decentralised communication and information tool.";
App::$strings["l F d, Y \\@ g:i A"] = "l j F, Y \\@ G:i";
App::$strings["D, d M Y - g:i A"] = "D, d M Y - G:i";

View File

@ -9,6 +9,15 @@
{{include file="field_password.tpl" field=$pass1}}
{{include file="field_password.tpl" field=$pass2}}
{{if $z_server_role == 'pro'}}
{{include file="field_select.tpl" field=$account_level}}
{{else}}
<input type="hidden" name="account_level" value="{{$account_level.2}}" />
{{/if}}
{{include file="field_select.tpl" field=$account_language}}
{{include file="field_input.tpl" field=$service_class}}
<input type="submit" name="submit" value="{{$submit}}" />
</form>