* Admin/LDAP: LDAP extra attributes homedirector and loginshell were not stored (home set to /dev/null)

This commit is contained in:
Ralf Becker 2014-10-21 08:58:37 +00:00
parent c0972a636a
commit 8da3e37e73
4 changed files with 35 additions and 14 deletions

View File

@ -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']);

View File

@ -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;

View File

@ -46,7 +46,7 @@
<textbox id="homedirectory" class="et2_fullWidth"/>
<description/>
<description value="Login shell" for="loginshell"/>
<textbox id="Login shell" class="et2_fullWidth"/>
<textbox id="loginshell" class="et2_fullWidth"/>
<description/>
</row>
<row>

View File

@ -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(
'&szlig;' => '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 "<p align=right>common::email_address('$first','$last','$account')";
// convert all european special chars to ascii, (c) RalfBecker-AT-egroupware.org ;-)
static $extra = array(
'&szlig;' => '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