show cn of user in member dialog
This commit is contained in:
parent
6657436544
commit
777392fc7c
|
@ -233,18 +233,18 @@ class posixGroup extends baseModule implements passwordService {
|
|||
$this->attributes['memberUid'] = array();
|
||||
}
|
||||
// load list with all users
|
||||
$userAndGIDs = $this->getUserAndGIDs();
|
||||
$userAndGIDs = $this->getUsers();
|
||||
$users = array();
|
||||
foreach ($userAndGIDs as $user => $GID) {
|
||||
foreach ($userAndGIDs as $user => $userAttrs) {
|
||||
if (!in_array($user, $this->attributes['memberUid'])) {
|
||||
if ($this->attributes['gidNumber'][0] == $GID) {
|
||||
if ($this->attributes['gidNumber'][0] == $userAttrs['gid']) {
|
||||
if (isset($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0])
|
||||
&& ($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0] == 'true')) {
|
||||
$users[] = $user;
|
||||
$users[$user . ' (' . $userAttrs['cn'] . ')'] = $user;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$users[] = $user;
|
||||
$users[$user . ' (' . $userAttrs['cn'] . ')'] = $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,13 +255,23 @@ class posixGroup extends baseModule implements passwordService {
|
|||
$return->addElement(new htmlOutputText(_("Available users")));
|
||||
$return->addNewLine();
|
||||
|
||||
$remGroups = array();
|
||||
$remUsers = array();
|
||||
if (isset($this->attributes['memberUid'])) {
|
||||
$remGroups = $this->attributes['memberUid'];
|
||||
$remUsers = $this->attributes['memberUid'];
|
||||
}
|
||||
$remSelect = new htmlSelect('removeusers', $remGroups, null, 15);
|
||||
$remUsersDescriptive = array();
|
||||
foreach ($remUsers as $user) {
|
||||
if (isset($userAndGIDs[$user])) {
|
||||
$remUsersDescriptive[$user . ' (' . $userAndGIDs[$user]['cn'] . ')'] = $user;
|
||||
}
|
||||
else {
|
||||
$remUsersDescriptive[$user] = $user;
|
||||
}
|
||||
}
|
||||
$remSelect = new htmlSelect('removeusers', $remUsersDescriptive, null, 15);
|
||||
$remSelect->setMultiSelect(true);
|
||||
$remSelect->setTransformSingleSelect(false);
|
||||
$remSelect->setHasDescriptiveElements(true);
|
||||
$return->addElement($remSelect);
|
||||
$buttonContainer = new htmlTable();
|
||||
$buttonContainer->addElement(new htmlButton('addusers_button', 'back.gif', true), true);
|
||||
|
@ -271,6 +281,7 @@ class posixGroup extends baseModule implements passwordService {
|
|||
$addSelect = new htmlSelect('addusers', $users, null, 15);
|
||||
$addSelect->setMultiSelect(true);
|
||||
$addSelect->setTransformSingleSelect(false);
|
||||
$addSelect->setHasDescriptiveElements(true);
|
||||
$return->addElement($addSelect);
|
||||
$return->addNewLine();
|
||||
|
||||
|
@ -917,18 +928,18 @@ class posixGroup extends baseModule implements passwordService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of existing users and their GID numbers.
|
||||
* Returns a list of existing users and their GID numbers and cn.
|
||||
*
|
||||
* @return array list in format array(uid => gidNumber)
|
||||
* @return array list in format array(uid => array('gid' => 123, 'cn' => 'Some user'))
|
||||
*/
|
||||
private function getUserAndGIDs() {
|
||||
private function getUsers() {
|
||||
if ($this->cachedUserToGIDList != null) {
|
||||
return $this->cachedUserToGIDList;
|
||||
}
|
||||
$result = searchLDAPByAttribute('gidNumber', '*', 'posixAccount', array('uid', 'gidNumber'), array('user'));
|
||||
$result = searchLDAPByAttribute('gidNumber', '*', 'posixAccount', array('uid', 'gidNumber', 'cn'), array('user'));
|
||||
$this->cachedUserToGIDList = array();
|
||||
for ($i = 0; $i < sizeof($result); $i++) {
|
||||
$this->cachedUserToGIDList[$result[$i]['uid'][0]] = $result[$i]['gidnumber'][0];
|
||||
$this->cachedUserToGIDList[$result[$i]['uid'][0]] = array('gid' => $result[$i]['gidnumber'][0], 'cn' => $result[$i]['cn'][0]);
|
||||
}
|
||||
return $this->cachedUserToGIDList;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue