From cef1aa6d1b21b15458783661ed4c7e6fe8a99011 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 3 Oct 2016 17:16:24 -0700 Subject: 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. --- Zotlabs/Lib/Techlevels.php | 21 +++++++++++++ Zotlabs/Module/Admin/Account_edit.php | 20 ++++++++++++ Zotlabs/Module/Settings/Account.php | 10 +----- include/language.php | 58 +++++++++++++++++++++++++++++++++++ include/text.php | 36 ---------------------- view/en-au/hstrings.php | 5 +++ view/en-gb/hstrings.php | 31 +++++++++++++++++++ view/tpl/admin_account_edit.tpl | 9 ++++++ 8 files changed, 145 insertions(+), 45 deletions(-) create mode 100644 Zotlabs/Lib/Techlevels.php create mode 100644 view/en-au/hstrings.php create mode 100644 view/en-gb/hstrings.php diff --git a/Zotlabs/Lib/Techlevels.php b/Zotlabs/Lib/Techlevels.php new file mode 100644 index 000000000..6a8c36fb3 --- /dev/null +++ b/Zotlabs/Lib/Techlevels.php @@ -0,0 +1,21 @@ + 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; + } + +} + diff --git a/Zotlabs/Module/Admin/Account_edit.php b/Zotlabs/Module/Admin/Account_edit.php index ddb7e19f4..6dfadf183 100644 --- a/Zotlabs/Module/Admin/Account_edit.php +++ b/Zotlabs/Module/Admin/Account_edit.php @@ -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'), ] ); diff --git a/Zotlabs/Module/Settings/Account.php b/Zotlabs/Module/Settings/Account.php index cd5ed1fca..ec176797d 100644 --- a/Zotlabs/Module/Settings/Account.php +++ b/Zotlabs/Module/Settings/Account.php @@ -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'); diff --git a/include/language.php b/include/language.php index 96d3e48a9..efe9397fb 100644 --- a/include/language.php +++ b/include/language.php @@ -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; +} + diff --git a/include/text.php b/include/text.php index 9c4a4a5c5..2f89d3d98 100644 --- a/include/text.php +++ b/include/text.php @@ -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; diff --git a/view/en-au/hstrings.php b/view/en-au/hstrings.php new file mode 100644 index 000000000..95f8c4e00 --- /dev/null +++ b/view/en-au/hstrings.php @@ -0,0 +1,5 @@ + +{{/if}} +{{include file="field_select.tpl" field=$account_language}} +{{include file="field_input.tpl" field=$service_class}} + + -- cgit v1.2.3