added option to auto-sync with group of names

This commit is contained in:
Roland Gruber 2015-05-31 08:46:44 +00:00
parent e0d291378e
commit ec066fe7e6
1 changed files with 48 additions and 21 deletions

View File

@ -1308,7 +1308,10 @@ class posixAccount extends baseModule implements passwordService {
*/
function process_group() {
// Unix groups
if (!$this->isBooleanConfigOptionSet('posixAccount_hideposixGroups')) {
if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) {
$this->syncGonToGroups();
}
elseif (!$this->isBooleanConfigOptionSet('posixAccount_hideposixGroups')) {
if (isset($_POST['addgroups']) && isset($_POST['addgroups_button'])) { // Add groups to list
// add new group
$this->groups = @array_merge($this->groups, $_POST['addgroups']);
@ -1612,6 +1615,13 @@ class posixAccount extends baseModule implements passwordService {
$unixContainer = new htmlTable();
$unixContainer->alignment = htmlElement::ALIGN_TOP;
$unixContainer->addElement(new htmlSubTitle(_("Unix groups")), true);
if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) {
$this->syncGonToGroups();
foreach ($this->groups as $group) {
$unixContainer->addElement(new htmlOutputText($group), true);
}
}
else {
$unixContainer->addElement(new htmlOutputText(_("Selected groups")));
$unixContainer->addElement(new htmlOutputText(''));
$unixContainer->addElement(new htmlOutputText(_("Available groups")));
@ -1629,8 +1639,8 @@ class posixAccount extends baseModule implements passwordService {
$addSelect = new htmlSelect('addgroups', $groups, null, 15);
$addSelect->setMultiSelect(true);
$addSelect->setTransformSingleSelect(false);
$unixContainer->addElement($addSelect);
$unixContainer->addNewLine();
$unixContainer->addElement($addSelect, true);
}
$return->addElement($unixContainer);
}
@ -2862,7 +2872,7 @@ class posixAccount extends baseModule implements passwordService {
/**
* Finds all existing LDAP group of names.
*
* @return array groups array(dn => array('cn' => array('groupName'), 'objectClass' => array('top', 'groupOfNames')))
* @return array groups array(dn => array('cn' => array('groupName'), 'objectclass' => array('top', 'groupOfNames')))
*/
private function findGroupOfNames() {
if ($this->gonCache != null) {
@ -3266,6 +3276,23 @@ class posixAccount extends baseModule implements passwordService {
return $name;
}
/**
* Syncs the group of names with groups.
*/
private function syncGonToGroups() {
$this->groups = array();
$allGons = $this->findGroupOfNames();
foreach ($this->gonList as $dn) {
if (!isset($allGons[$dn])) {
continue;
}
$gon = $this->gonCache[$dn];
if (in_array_ignore_case('posixGroup', $gon['objectclass']) && !empty($gon['cn'])) {
$this->groups[] = $gon['cn'][0];
}
}
}
}
?>