added sync with Windows members
This commit is contained in:
parent
c83842ef40
commit
89a8c41f78
|
@ -380,10 +380,26 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
if ($gon != null) {
|
if ($gon != null) {
|
||||||
$return->addElement(new htmlSpacer(null, '20px'), true);
|
$return->addElement(new htmlSpacer(null, '20px'), true);
|
||||||
|
$syncGroup = new htmlTable();
|
||||||
|
$syncGroup->colspan = 5;
|
||||||
$syncButton = new htmlButton('syncGON', sprintf(_('Sync from %s'), $gon->get_alias()));
|
$syncButton = new htmlButton('syncGON', sprintf(_('Sync from %s'), $gon->get_alias()));
|
||||||
$syncButton->colspan = 5;
|
|
||||||
$syncButton->setIconClass('refreshButton');
|
$syncButton->setIconClass('refreshButton');
|
||||||
$return->addElement($syncButton, true);
|
$syncGroup->addElement($syncButton);
|
||||||
|
$syncGroup->addSpace('2rem');
|
||||||
|
$syncGroup->addElement(new htmlTableExtendedInputCheckbox('syncGON_delete', true, _('Delete non-matching entries'), null, false));
|
||||||
|
$return->addElement($syncGroup, true);
|
||||||
|
}
|
||||||
|
$windows = $this->getAccountContainer()->getAccountModule('windowsGroup');
|
||||||
|
if ($windows != null) {
|
||||||
|
$return->addElement(new htmlSpacer(null, '20px'), true);
|
||||||
|
$syncGroup = new htmlTable();
|
||||||
|
$syncGroup->colspan = 5;
|
||||||
|
$syncButton = new htmlButton('syncWindows', sprintf(_('Sync from %s'), $windows->get_alias()));
|
||||||
|
$syncButton->setIconClass('refreshButton');
|
||||||
|
$syncGroup->addElement($syncButton);
|
||||||
|
$syncGroup->addSpace('2rem');
|
||||||
|
$syncGroup->addElement(new htmlTableExtendedInputCheckbox('syncWindows_delete', true, _('Delete non-matching entries'), null, false));
|
||||||
|
$return->addElement($syncGroup, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// back button
|
// back button
|
||||||
|
@ -985,6 +1001,10 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
elseif (isset($_POST['syncGON'])) {
|
elseif (isset($_POST['syncGON'])) {
|
||||||
$return = array_merge($return, $this->syncGon());
|
$return = array_merge($return, $this->syncGon());
|
||||||
}
|
}
|
||||||
|
// sync Windows
|
||||||
|
elseif (isset($_POST['syncWindows'])) {
|
||||||
|
$return = array_merge($return, $this->syncWindows());
|
||||||
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -994,6 +1014,7 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
* @return array list of status messages
|
* @return array list of status messages
|
||||||
*/
|
*/
|
||||||
protected function syncGon() {
|
protected function syncGon() {
|
||||||
|
$delete = isset($_POST['syncGON_delete']) && ($_POST['syncGON_delete'] == 'on');
|
||||||
$return = array();
|
$return = array();
|
||||||
$gon = $this->getAccountContainer()->getAccountModule('groupOfNames');
|
$gon = $this->getAccountContainer()->getAccountModule('groupOfNames');
|
||||||
if ($gon == null) {
|
if ($gon == null) {
|
||||||
|
@ -1008,7 +1029,9 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
$memberDNs = $gon->getMembers();
|
$memberDNs = $gon->getMembers();
|
||||||
$users = $this->getUsers();
|
$users = $this->getUsers();
|
||||||
$oldValues = $this->attributes['memberUid'];
|
$oldValues = $this->attributes['memberUid'];
|
||||||
|
if ($delete) {
|
||||||
$this->attributes['memberUid'] = array();
|
$this->attributes['memberUid'] = array();
|
||||||
|
}
|
||||||
foreach ($memberDNs as $dn) {
|
foreach ($memberDNs as $dn) {
|
||||||
foreach ($users as $userName => $userAttrs) {
|
foreach ($users as $userName => $userAttrs) {
|
||||||
if ($userAttrs['dn'] != $dn) {
|
if ($userAttrs['dn'] != $dn) {
|
||||||
|
@ -1021,10 +1044,55 @@ class posixGroup extends baseModule implements passwordService {
|
||||||
if (!empty($added)) {
|
if (!empty($added)) {
|
||||||
$return[] = array('INFO', _('Added users'), htmlspecialchars(implode($added, ', ')));
|
$return[] = array('INFO', _('Added users'), htmlspecialchars(implode($added, ', ')));
|
||||||
}
|
}
|
||||||
|
if ($delete) {
|
||||||
$deleted = array_delete($this->attributes['memberUid'], $oldValues);
|
$deleted = array_delete($this->attributes['memberUid'], $oldValues);
|
||||||
if (!empty($deleted)) {
|
if (!empty($deleted)) {
|
||||||
$return[] = array('INFO', _('Removed users'), htmlspecialchars(implode($deleted, ', ')));
|
$return[] = array('INFO', _('Removed users'), htmlspecialchars(implode($deleted, ', ')));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Syncs with Windows.
|
||||||
|
*
|
||||||
|
* @return array list of status messages
|
||||||
|
*/
|
||||||
|
protected function syncWindows() {
|
||||||
|
$delete = isset($_POST['syncWindows_delete']) && ($_POST['syncWindows_delete'] == 'on');
|
||||||
|
$return = array();
|
||||||
|
$windows = $this->getAccountContainer()->getAccountModule('windowsGroup');
|
||||||
|
if (!isset($this->attributes['memberUid'])) {
|
||||||
|
$this->attributes['memberUid'] = array();
|
||||||
|
}
|
||||||
|
$windowsAttributes = $windows->getAttributes();
|
||||||
|
$memberDNs = array();
|
||||||
|
if (!empty($windowsAttributes['member'])) {
|
||||||
|
$memberDNs = $windowsAttributes['member'];
|
||||||
|
}
|
||||||
|
$users = $this->getUsers();
|
||||||
|
$oldValues = $this->attributes['memberUid'];
|
||||||
|
if ($delete) {
|
||||||
|
$this->attributes['memberUid'] = array();
|
||||||
|
}
|
||||||
|
foreach ($memberDNs as $dn) {
|
||||||
|
foreach ($users as $userName => $userAttrs) {
|
||||||
|
if ($userAttrs['dn'] != $dn) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->attributes['memberUid'][] = $userName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$added = array_delete($oldValues, $this->attributes['memberUid']);
|
||||||
|
if (!empty($added)) {
|
||||||
|
$return[] = array('INFO', _('Added users'), htmlspecialchars(implode($added, ', ')));
|
||||||
|
}
|
||||||
|
if ($delete) {
|
||||||
|
$deleted = array_delete($this->attributes['memberUid'], $oldValues);
|
||||||
|
if (!empty($deleted)) {
|
||||||
|
$return[] = array('INFO', _('Removed users'), htmlspecialchars(implode($deleted, ', ')));
|
||||||
|
}
|
||||||
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue