getConfiguredType($_POST['type']) === null)) { logNewMessage(LOG_ERR, 'Invalid type: ' . $_POST['type']); die(); } if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { $typeId = $_GET['type']; $type = $typeManager->getConfiguredType($typeId); if ($type === null) { logNewMessage(LOG_ERR, 'Invalid type: ' . $type->getId()); die(); } if (!checkIfDeleteEntriesIsAllowed($type->getId()) || !checkIfWriteAccessIsAllowed($type->getId())) { logNewMessage(LOG_ERR, 'User tried to delete entries of forbidden type '. $type->getId()); die(); } // Create account list foreach ($_SESSION['delete_dn'] as $dn) { $start = strpos ($dn, "=")+1; $end = strpos ($dn, ","); $users[] = substr($dn, $start, $end-$start); } //load account $_SESSION['account'] = new \accountContainer($type, 'account'); // Show HTML Page include 'main_header.php'; echo "
getScope() . "-bright smallPaddingContent\">"; echo "
\n"; echo "
\n"; echo ''; echo "getId() . "\">\n"; echo "" . _("Do you really want to remove the following accounts?") . ""; echo "

\n"; echo "\n"; $userCount = sizeof($users); for ($i = 0; $i < $userCount; $i++) { echo "\n"; echo "\n"; echo "\n"; $_SESSION['account']->load_account($_SESSION['delete_dn'][$i]); if (!$_SESSION['account']->hasOnlyVirtualChildren()) { $childCount = getChildCount($_SESSION['delete_dn'][$i]); if ($childCount > 0) { echo "\n"; } } echo "\n"; } echo "
" . _("Account name:") . " " . htmlspecialchars($users[$i]) . "  " . _('DN') . ": " . htmlspecialchars($_SESSION['delete_dn'][$i]) . "  " . _('Number of child entries') . ": " . $childCount . "
\n"; echo "
\n"; // Print delete rows from modules echo "\n
"; $modules = $_SESSION['config']->get_AccountModules($type->getId()); $values = array(); $tabindex = 100; foreach ($modules as $module) { $module = \moduleCache::getModule($module, $type->getScope()); parseHtml(get_class($module), $module->display_html_delete(), $values, true, $tabindex, $type->getScope()); } echo "
\n"; echo "
\n"; echo " \n"; echo "\n"; echo "
\n"; echo "
\n"; ?> getConfiguredType($typeId); if (!checkIfDeleteEntriesIsAllowed($type->getId()) || !checkIfWriteAccessIsAllowed($type->getId())) { logNewMessage(LOG_ERR, 'User tried to delete entries of forbidden type '. $type->getId()); die(); } // Show HTML Page include 'main_header.php'; echo "
\n"; echo ''; echo "getId() . "\">\n"; echo "
getScope() . "-bright smallPaddingContent\">
\n"; echo "
\n"; // Delete dns $allOk = true; $allErrors = array(); foreach ($_SESSION['delete_dn'] as $deleteDN) { // Set to true if an real error has happened $stopprocessing = false; // First load DN. $_SESSION['account']->load_account($deleteDN); // get commands and changes of each attribute $moduleNames = array_keys($_SESSION['account']->getAccountModules()); $modules = $_SESSION['account']->getAccountModules(); $attributes = array(); $errors = array(); // predelete actions if (!$stopprocessing) { foreach ($moduleNames as $singlemodule) { $success = true; $messages = $modules[$singlemodule]->preDeleteActions(); foreach ($messages as $message) { $errors[] = $message; if ($message[0] == 'ERROR') { $success = false; $allOk = false; } elseif ($message[0] == 'WARN') { $allOk = false; } } if (!$success) { $stopprocessing = true; break; } } } if (!$stopprocessing) { // load attributes foreach ($moduleNames as $singlemodule) { // load changes $temp = $modules[$singlemodule]->delete_attributes(); if (is_array($temp)) { // merge changes $DNs = array_keys($temp); $attributes = array_merge_recursive($temp, $attributes); foreach ($DNs as $dn) { $ops = array_keys($temp[$dn]); foreach ($ops as $op) { $attrs = array_keys($temp[$dn][$op]); foreach ($attrs as $attribute) { $attributes[$dn][$op][$attribute] = array_unique($attributes[$dn][$op][$attribute]); } } } } } $DNs = array_keys($attributes); foreach ($DNs as $dn) { if (isset($attributes[$dn]['errors'])) { foreach ($attributes[$dn]['errors'] as $singleerror) { $errors[] = $singleerror; if ($singleerror[0] == 'ERROR') { $stopprocessing = true; $allOk = false; } } } if (!$stopprocessing) { // modify attributes if (isset($attributes[$dn]['modify']) && !$stopprocessing) { $success = @ldap_mod_replace($_SESSION['ldap']->server(), $dn, $attributes[$dn]['modify']); if (!$success) { $errors[] = array ('ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())); $stopprocessing = true; $allOk = false; } } // add attributes if (isset($attributes[$dn]['add']) && !$stopprocessing) { $success = @ldap_mod_add($_SESSION['ldap']->server(), $dn, $attributes[$dn]['add']); if (!$success) { $errors[] = array ('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())); $stopprocessing = true; $allOk = false; } } // remove attributes if (isset($attributes[$dn]['remove']) && !$stopprocessing) { $success = @ldap_mod_del($_SESSION['ldap']->server(), $dn, $attributes[$dn]['remove']); if (!$success) { $errors[] = array ('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())); $stopprocessing = true; $allOk = false; } } } } } if (!$stopprocessing) { $recursive = !$_SESSION['account']->hasOnlyVirtualChildren(); $messages = deleteDN($deleteDN, $recursive); $errors = array_merge($errors, $messages); if (sizeof($errors) > 0) { $stopprocessing = true; $allOk = false; } } // post delete actions if (!$stopprocessing) { foreach ($moduleNames as $singlemodule) { $messages = $modules[$singlemodule]->postDeleteActions(); foreach ($messages as $message) { $errors[] = $message; if (($message[0] == 'ERROR') || ($message[0] == 'WARN')) { $allOk = false; } } } } if (!$stopprocessing) { echo sprintf(_('Deleted DN: %s'), $deleteDN) . "
\n"; foreach ($errors as $error) { call_user_func_array('StatusMessage', $error); } echo "
\n"; flush(); } else { echo sprintf(_('Error while deleting DN: %s'), $deleteDN) . "
\n"; foreach ($errors as $error) { call_user_func_array('StatusMessage', $error); } echo "
\n"; } $allErrors = array_merge($allErrors, $errors); } echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; ?>