replace $user and $group in displayName

This commit is contained in:
Roland Gruber 2014-07-27 15:51:00 +00:00
parent e5e219f35c
commit ef400b8359
1 changed files with 10 additions and 3 deletions

View File

@ -188,6 +188,7 @@ class sambaSamAccount extends baseModule implements passwordService {
// profile mappings // profile mappings
$return['profile_mappings'] = array( $return['profile_mappings'] = array(
'sambaSamAccount_sambaDomainName' => 'sambaDomainName', 'sambaSamAccount_sambaDomainName' => 'sambaDomainName',
'sambaSamAccount_displayName' => 'displayName',
); );
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideHomePath')) { if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideHomePath')) {
$return['profile_mappings']['sambaSamAccount_smbhome'] = 'sambaHomePath'; $return['profile_mappings']['sambaSamAccount_smbhome'] = 'sambaHomePath';
@ -752,6 +753,7 @@ class sambaSamAccount extends baseModule implements passwordService {
return array(); return array();
} }
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$unixGroupName = $this->getGroupName($attrs['gidNumber'][0]);
// Save attributes // Save attributes
$this->attributes['sambaDomainName'][0] = $_POST['sambaDomainName']; $this->attributes['sambaDomainName'][0] = $_POST['sambaDomainName'];
// Get Domain SID from name // Get Domain SID from name
@ -797,6 +799,10 @@ class sambaSamAccount extends baseModule implements passwordService {
// display name // display name
$this->attributes['displayName'][0] = $_POST['displayName']; $this->attributes['displayName'][0] = $_POST['displayName'];
if (!empty($this->attributes['displayName'][0])) {
$this->attributes['displayName'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['displayName'][0]);
$this->attributes['displayName'][0] = str_replace('$group', $unixGroupName, $this->attributes['displayName'][0]);
}
if (!($this->attributes['displayName'][0] == '') && !(get_preg($this->attributes['displayName'][0], 'realname'))) { if (!($this->attributes['displayName'][0] == '') && !(get_preg($this->attributes['displayName'][0], 'realname'))) {
$errors[] = $this->messages['displayName'][1]; $errors[] = $this->messages['displayName'][1];
} }
@ -815,7 +821,6 @@ class sambaSamAccount extends baseModule implements passwordService {
} }
} }
// user attributes // user attributes
$unixGroupName = $this->getGroupName($attrs['gidNumber'][0]);
if ($this->get_scope()=='user') { if ($this->get_scope()=='user') {
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideHomePath')) { if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideHomePath')) {
$this->attributes['sambaHomePath'][0] = $_POST['sambaHomePath']; $this->attributes['sambaHomePath'][0] = $_POST['sambaHomePath'];
@ -1124,10 +1129,10 @@ class sambaSamAccount extends baseModule implements passwordService {
} }
// display name // display name
$displayName = ''; $displayName = '';
if (isset($this->attributes['displayName'][0])) { if (!empty($this->attributes['displayName'][0])) {
$displayName = $this->attributes['displayName'][0]; $displayName = $this->attributes['displayName'][0];
} }
else if ($this->getAccountContainer()->isNewAccount && !isset($this->attributes['displayName'])) { else if ($this->getAccountContainer()->isNewAccount && empty($this->attributes['displayName'][0])) {
if (isset($personalAttributes['givenName'][0]) && $personalAttributes['givenName'][0] && isset($personalAttributes['sn'][0]) && $personalAttributes['sn'][0]) { if (isset($personalAttributes['givenName'][0]) && $personalAttributes['givenName'][0] && isset($personalAttributes['sn'][0]) && $personalAttributes['sn'][0]) {
$displayName = $personalAttributes['givenName'][0] . " " . $personalAttributes['sn'][0]; $displayName = $personalAttributes['givenName'][0] . " " . $personalAttributes['sn'][0];
} }
@ -1729,6 +1734,8 @@ class sambaSamAccount extends baseModule implements passwordService {
for ( $i=1; $i<=31; $i++ ) $day[] = $i; for ( $i=1; $i<=31; $i++ ) $day[] = $i;
for ( $i=1; $i<=12; $i++ ) $mon[] = $i; for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; for ( $i=2003; $i<=2030; $i++ ) $year[] = $i;
// display name
$return->addElement(new htmlTableExtendedInputField(_('Display name'), 'sambaSamAccount_displayName', '', 'displayName'), true);
// use no password at all // use no password at all
$return->addElement(new htmlTableExtendedInputCheckbox('sambaSamAccount_sambaAcctFlagsN', false, _('Use no password'), 'noPassword'), true); $return->addElement(new htmlTableExtendedInputCheckbox('sambaSamAccount_sambaAcctFlagsN', false, _('Use no password'), 'noPassword'), true);
// account deactivation // account deactivation