added option to auto-sync with group of names
This commit is contained in:
parent
e0d291378e
commit
ec066fe7e6
|
@ -1308,7 +1308,10 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
*/
|
*/
|
||||||
function process_group() {
|
function process_group() {
|
||||||
// Unix groups
|
// 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
|
if (isset($_POST['addgroups']) && isset($_POST['addgroups_button'])) { // Add groups to list
|
||||||
// add new group
|
// add new group
|
||||||
$this->groups = @array_merge($this->groups, $_POST['addgroups']);
|
$this->groups = @array_merge($this->groups, $_POST['addgroups']);
|
||||||
|
@ -1612,25 +1615,32 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$unixContainer = new htmlTable();
|
$unixContainer = new htmlTable();
|
||||||
$unixContainer->alignment = htmlElement::ALIGN_TOP;
|
$unixContainer->alignment = htmlElement::ALIGN_TOP;
|
||||||
$unixContainer->addElement(new htmlSubTitle(_("Unix groups")), true);
|
$unixContainer->addElement(new htmlSubTitle(_("Unix groups")), true);
|
||||||
$unixContainer->addElement(new htmlOutputText(_("Selected groups")));
|
if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) {
|
||||||
$unixContainer->addElement(new htmlOutputText(''));
|
$this->syncGonToGroups();
|
||||||
$unixContainer->addElement(new htmlOutputText(_("Available groups")));
|
foreach ($this->groups as $group) {
|
||||||
$unixContainer->addNewLine();
|
$unixContainer->addElement(new htmlOutputText($group), true);
|
||||||
|
}
|
||||||
$remSelect = new htmlSelect('removegroups', $this->groups, null, 15);
|
}
|
||||||
$remSelect->setMultiSelect(true);
|
else {
|
||||||
$remSelect->setTransformSingleSelect(false);
|
$unixContainer->addElement(new htmlOutputText(_("Selected groups")));
|
||||||
$unixContainer->addElement($remSelect);
|
$unixContainer->addElement(new htmlOutputText(''));
|
||||||
$buttonContainer = new htmlTable();
|
$unixContainer->addElement(new htmlOutputText(_("Available groups")));
|
||||||
$buttonContainer->addElement(new htmlButton('addgroups_button', 'back.gif', true), true);
|
$unixContainer->addNewLine();
|
||||||
$buttonContainer->addElement(new htmlButton('removegroups_button', 'forward.gif', true), true);
|
|
||||||
$buttonContainer->addElement(new htmlHelpLink('addgroup'));
|
$remSelect = new htmlSelect('removegroups', $this->groups, null, 15);
|
||||||
$unixContainer->addElement($buttonContainer);
|
$remSelect->setMultiSelect(true);
|
||||||
$addSelect = new htmlSelect('addgroups', $groups, null, 15);
|
$remSelect->setTransformSingleSelect(false);
|
||||||
$addSelect->setMultiSelect(true);
|
$unixContainer->addElement($remSelect);
|
||||||
$addSelect->setTransformSingleSelect(false);
|
$buttonContainer = new htmlTable();
|
||||||
$unixContainer->addElement($addSelect);
|
$buttonContainer->addElement(new htmlButton('addgroups_button', 'back.gif', true), true);
|
||||||
$unixContainer->addNewLine();
|
$buttonContainer->addElement(new htmlButton('removegroups_button', 'forward.gif', true), true);
|
||||||
|
$buttonContainer->addElement(new htmlHelpLink('addgroup'));
|
||||||
|
$unixContainer->addElement($buttonContainer);
|
||||||
|
$addSelect = new htmlSelect('addgroups', $groups, null, 15);
|
||||||
|
$addSelect->setMultiSelect(true);
|
||||||
|
$addSelect->setTransformSingleSelect(false);
|
||||||
|
$unixContainer->addElement($addSelect, true);
|
||||||
|
}
|
||||||
|
|
||||||
$return->addElement($unixContainer);
|
$return->addElement($unixContainer);
|
||||||
}
|
}
|
||||||
|
@ -2862,7 +2872,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
/**
|
/**
|
||||||
* Finds all existing LDAP group of names.
|
* 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() {
|
private function findGroupOfNames() {
|
||||||
if ($this->gonCache != null) {
|
if ($this->gonCache != null) {
|
||||||
|
@ -3266,6 +3276,23 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
return $name;
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue