From 8da3e37e73d0c13d181fb3da4e700dc71bd5ba73 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 21 Oct 2014 08:58:37 +0000 Subject: [PATCH] * Admin/LDAP: LDAP extra attributes homedirector and loginshell were not stored (home set to /dev/null) --- admin/inc/class.admin_account.inc.php | 13 ++++++++++- admin/js/app.js | 2 +- admin/templates/default/account.xet | 2 +- phpgwapi/inc/class.common.inc.php | 32 ++++++++++++++++++--------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/admin/inc/class.admin_account.inc.php b/admin/inc/class.admin_account.inc.php index cc3482e5c0..3233a05d5c 100644 --- a/admin/inc/class.admin_account.inc.php +++ b/admin/inc/class.admin_account.inc.php @@ -135,7 +135,8 @@ class admin_account 'changepassword', 'anonymous', 'mustchangepassword', 'account_passwd', 'account_passwd2', 'account_primary_group', - 'account_expires' + 'account_expires', + 'homedirectory', 'loginshell', ) as $c_name => $a_name) { if (is_int($c_name)) $c_name = $a_name; @@ -265,6 +266,16 @@ class admin_account if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before + // set home-directory when account_lid is entered, but only for new accounts + if ($changed == 'account_lid' && !$data['account_id'] && + $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && + $GLOBALS['egw_info']['server']['ldap_account_home']) + { + egw_json_response::get()->assign('addressbook-edit_homedirectory', 'value', + $GLOBALS['egw_info']['server']['ldap_account_home'].'/'.preg_replace('/[^a-z0-9_.-]/i', '', + common::transliterate($data['account_lid']))); + } + // set dummy membership to get no error about no members yet $data['account_memberships'] = array($data['account_primary_user'] = $GLOBALS['egw_info']['user']['account_primary_group']); diff --git a/admin/js/app.js b/admin/js/app.js index f04bb558d1..0d6f17f268 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -800,7 +800,7 @@ app.classes.admin = AppJS.extend( var _buttons = [ {"button_id": "delete[cancel]","text": this.egw.lang('Cancel'), id: 'delete[cancel]', image: 'cancel', "default":true}, {"button_id": "delete[delete]","text": this.egw.lang('Delete'), id: 'delete[delete]', image: 'delete'}, - {"button_id": "delete[subs]","text": this.egw.lang('Delete including sub-enteries'), id: 'delete[subs]', image: 'delete'}, + {"button_id": "delete[subs]","text": this.egw.lang('Delete including sub-enteries'), id: 'delete[subs]', image: 'delete'} ]; var action = _action; var self = this; diff --git a/admin/templates/default/account.xet b/admin/templates/default/account.xet index 12e87e1381..0b0b091603 100644 --- a/admin/templates/default/account.xet +++ b/admin/templates/default/account.xet @@ -46,7 +46,7 @@ - + diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 61d47c63b3..b69e6a81bd 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -1202,6 +1202,25 @@ class common return $h12.':'.$min.$sec.$ampm; } + /** + * convert all european special chars to ascii + * + * @param string $str + * @return string + */ + public static function transliterate($str) + { + static $extra = array( + 'ß' => 'ss', + ' ' => '', + ); + $entities = htmlentities($str, ENT_QUOTES,translation::charset()); + $extra_replaced = str_replace(array_keys($extra),array_values($extra),$entities); + $umlauts = preg_replace('/&([aAuUoO])uml;/','\\1e',$extra_replaced); // replace german umlauts with the letter plus one 'e' + $accents = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1',$umlauts); // remove all types of acents + return preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','',$accents); // remove all other entities + } + /** * Format an email address according to the system standard * @@ -1210,24 +1229,15 @@ class common * @param string $first firstname * @param string $last lastname * @param string $account account-name (lid) - * @param string $domain=null domain-name or null to use eGW's default domain $GLOBALS['egw_info']['server']['mail_suffix] + * @param string $domain =null domain-name or null to use eGW's default domain $GLOBALS['egw_info']['server']['mail_suffix] * @return string with email address */ static function email_address($first,$last,$account,$domain=null) { //echo "

common::email_address('$first','$last','$account')"; - // convert all european special chars to ascii, (c) RalfBecker-AT-egroupware.org ;-) - static $extra = array( - 'ß' => 'ss', - ' ' => '', - ); foreach (array('first','last','account') as $name) { - $entities = htmlentities($$name,ENT_QUOTES,translation::charset()); - $extra_replaced = str_replace(array_keys($extra),array_values($extra),$entities); - $umlauts = preg_replace('/&([aAuUoO])uml;/','\\1e',$extra_replaced); // replace german umlauts with the letter plus one 'e' - $accents = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1',$umlauts); // remove all types of acents - $$name = preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','',$accents); // remove all other entities + $$name = self::transliterate($$name); } //echo " --> ('$first', '$last', '$account')"; if (!$first && !$last) // fallback to the account-name, if real names contain only special chars