added preDeleteActions()
This commit is contained in:
parent
f20325c0e0
commit
896c8f89d4
|
@ -140,59 +140,71 @@ if ($_POST['delete']) {
|
||||||
// First load DN.
|
// First load DN.
|
||||||
$_SESSION['account']->load_account($_SESSION['delete_dn'][$m]);
|
$_SESSION['account']->load_account($_SESSION['delete_dn'][$m]);
|
||||||
// get commands and changes of each attribute
|
// get commands and changes of each attribute
|
||||||
$module = array_keys ($_SESSION['account']->module);
|
$module = array_keys($_SESSION['account']->module);
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
$errors = array();
|
$errors = array();
|
||||||
// load attributes
|
// predelete actions
|
||||||
foreach ($module as $singlemodule) {
|
if (!$stopprocessing) {
|
||||||
// load changes
|
foreach ($module as $singlemodule) {
|
||||||
$temp = $_SESSION['account']->module[$singlemodule]->delete_attributes();
|
$success = $_SESSION['account']->module[$singlemodule]->preDeleteActions();
|
||||||
if (is_array($temp)) {
|
if (!$success) {
|
||||||
// merge changes
|
$stopprocessing = true;
|
||||||
$DNs = array_keys($temp);
|
break;
|
||||||
// *** fixme don't include references
|
}
|
||||||
$attributes = array_merge_recursive($temp, $attributes);
|
}
|
||||||
for ($i=0; $i<count($DNs); $i++) {
|
}
|
||||||
$ops = array_keys($temp[$DNs[$i]]);
|
if (!$stopprocessing) {
|
||||||
for ($j=0; $j<count($ops); $j++) {
|
// load attributes
|
||||||
$attrs = array_keys($temp[$DNs[$i]][$ops[$j]]);
|
foreach ($module as $singlemodule) {
|
||||||
for ($k=0; $k<count($attrs); $k++)
|
// load changes
|
||||||
$attributes[$DNs[$i]][$ops[$j]][$attrs[$k]] = array_unique($attributes[$DNs[$i]][$ops[$j]][$attrs[$k]]);
|
$temp = $_SESSION['account']->module[$singlemodule]->delete_attributes();
|
||||||
|
if (is_array($temp)) {
|
||||||
|
// merge changes
|
||||||
|
$DNs = array_keys($temp);
|
||||||
|
// *** fixme don't include references
|
||||||
|
$attributes = array_merge_recursive($temp, $attributes);
|
||||||
|
for ($i=0; $i<count($DNs); $i++) {
|
||||||
|
$ops = array_keys($temp[$DNs[$i]]);
|
||||||
|
for ($j=0; $j<count($ops); $j++) {
|
||||||
|
$attrs = array_keys($temp[$DNs[$i]][$ops[$j]]);
|
||||||
|
for ($k=0; $k<count($attrs); $k++)
|
||||||
|
$attributes[$DNs[$i]][$ops[$j]][$attrs[$k]] = array_unique($attributes[$DNs[$i]][$ops[$j]][$attrs[$k]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$DNs = array_keys($attributes);
|
||||||
$DNs = array_keys($attributes);
|
for ($i=0; $i<count($DNs); $i++) {
|
||||||
for ($i=0; $i<count($DNs); $i++) {
|
if (isset($attributes[$DNs[$i]]['errors'])) {
|
||||||
if (isset($attributes[$DNs[$i]]['errors'])) {
|
foreach ($attributes[$DNs[$i]]['errors'] as $singleerror) {
|
||||||
foreach ($attributes[$DNs[$i]]['errors'] as $singleerror) {
|
$errors[] = $singleerror;
|
||||||
$errors[] = $singleerror;
|
if ($singleerror[0] == 'ERROR') $stopprocessing = true;
|
||||||
if ($singleerror[0] == 'ERROR') $stopprocessing = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$stopprocessing) {
|
|
||||||
// modify attributes
|
|
||||||
if (isset($attributes[$DNs[$i]]['modify']) && !$stopprocessing) {
|
|
||||||
$success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']);
|
|
||||||
if (!$success) {
|
|
||||||
$errors[] = array ('ERROR', sprintf(_('Was unable to modify attribtues from DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server()));
|
|
||||||
$stopprocessing = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add attributes
|
if (!$stopprocessing) {
|
||||||
if (isset($attributes[$DNs[$i]]['add']) && !$stopprocessing) {
|
// modify attributes
|
||||||
$success = @ldap_mod_add($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['add']);
|
if (isset($attributes[$DNs[$i]]['modify']) && !$stopprocessing) {
|
||||||
if (!$success) {
|
$success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']);
|
||||||
$errors[] = array ('ERROR', sprintf(_('Was unable to add attribtues to DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server()));
|
if (!$success) {
|
||||||
$stopprocessing = true;
|
$errors[] = array ('ERROR', sprintf(_('Was unable to modify attribtues from DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server()));
|
||||||
|
$stopprocessing = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// add attributes
|
||||||
// removce attributes
|
if (isset($attributes[$DNs[$i]]['add']) && !$stopprocessing) {
|
||||||
if (isset($attributes[$DNs[$i]]['remove']) && !$stopprocessing) {
|
$success = @ldap_mod_add($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['add']);
|
||||||
$success = @ldap_mod_del($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['remove']);
|
if (!$success) {
|
||||||
if (!$success) {
|
$errors[] = array ('ERROR', sprintf(_('Was unable to add attribtues to DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server()));
|
||||||
$errors[] = array ('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server()));
|
$stopprocessing = true;
|
||||||
$stopprocessing = true;
|
}
|
||||||
|
}
|
||||||
|
// removce attributes
|
||||||
|
if (isset($attributes[$DNs[$i]]['remove']) && !$stopprocessing) {
|
||||||
|
$success = @ldap_mod_del($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['remove']);
|
||||||
|
if (!$success) {
|
||||||
|
$errors[] = array ('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server()));
|
||||||
|
$stopprocessing = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,10 +213,10 @@ if ($_POST['delete']) {
|
||||||
$errors = deleteDN($_SESSION['delete_dn'][$m]);
|
$errors = deleteDN($_SESSION['delete_dn'][$m]);
|
||||||
if (sizeof($errors) > 0) $stopprocessing = true;
|
if (sizeof($errors) > 0) $stopprocessing = true;
|
||||||
}
|
}
|
||||||
|
// post delete actions
|
||||||
if (!$stopprocessing) {
|
if (!$stopprocessing) {
|
||||||
// post delete actions
|
|
||||||
foreach ($module as $singlemodule) {
|
foreach ($module as $singlemodule) {
|
||||||
$_SESSION['account']->module[$singlemodule]->postDeleteActions();
|
$_SESSION['account']->module[$singlemodule]->postDeleteActions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$stopprocessing) {
|
if (!$stopprocessing) {
|
||||||
|
|
Loading…
Reference in New Issue