removed double checks, better error handling
This commit is contained in:
parent
b2448de10a
commit
d198a67671
|
@ -64,20 +64,12 @@ if ($_POST['submit']) {
|
||||||
}
|
}
|
||||||
// delete ou, user was sure
|
// delete ou, user was sure
|
||||||
elseif (($_POST['type'] == "del_usr") && ($_POST['sure'])) {
|
elseif (($_POST['type'] == "del_usr") && ($_POST['sure'])) {
|
||||||
// check for sub entries
|
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']);
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array(""));
|
if ($ret) {
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$message = _("OU deleted successfully.");
|
||||||
if ($info['count'] == 0) {
|
|
||||||
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']);
|
|
||||||
if ($ret) {
|
|
||||||
$message = _("OU deleted successfully.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$error = _("Unable to delete OU!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty!");
|
$error = _("Unable to delete OU!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do not delete ou
|
// do not delete ou
|
||||||
|
@ -88,9 +80,9 @@ if ($_POST['submit']) {
|
||||||
// ask if user is sure to delete
|
// ask if user is sure to delete
|
||||||
elseif ($_POST['type'] == "del_usr") {
|
elseif ($_POST['type'] == "del_usr") {
|
||||||
// check for sub entries
|
// check for sub entries
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array(""));
|
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array(""));
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
if ($info['count'] == 0) {
|
if ($sr && $info['count'] == 0) {
|
||||||
$text = "<br>\n" .
|
$text = "<br>\n" .
|
||||||
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
|
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
|
||||||
"<br>\n<p>" . $_POST['usersuff_d'] . "</p>\n" .
|
"<br>\n<p>" . $_POST['usersuff_d'] . "</p>\n" .
|
||||||
|
@ -104,7 +96,7 @@ if ($_POST['submit']) {
|
||||||
"</form>";
|
"</form>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty!");
|
$error = _("OU is not empty or invalid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,20 +129,12 @@ if ($_POST['submit']) {
|
||||||
}
|
}
|
||||||
// delete ou, user was sure
|
// delete ou, user was sure
|
||||||
elseif (($_POST['type'] == "del_grp") && ($_POST['sure'])) {
|
elseif (($_POST['type'] == "del_grp") && ($_POST['sure'])) {
|
||||||
// check for sub entries
|
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']);
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array(""));
|
if ($ret) {
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$message = _("OU deleted successfully.");
|
||||||
if ($info['count'] == 0) {
|
|
||||||
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']);
|
|
||||||
if ($ret) {
|
|
||||||
$message = _("OU deleted successfully.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$error = _("Unable to delete OU!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty!");
|
$error = _("Unable to delete OU!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do not delete ou
|
// do not delete ou
|
||||||
|
@ -161,9 +145,9 @@ if ($_POST['submit']) {
|
||||||
// ask if user is sure to delete
|
// ask if user is sure to delete
|
||||||
elseif ($_POST['type'] == "del_grp") {
|
elseif ($_POST['type'] == "del_grp") {
|
||||||
// check for sub entries
|
// check for sub entries
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array(""));
|
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array(""));
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
if ($info['count'] == 0) {
|
if ($sr && $info['count'] == 0) {
|
||||||
$text = "<br>\n" .
|
$text = "<br>\n" .
|
||||||
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
|
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
|
||||||
"<br>\n<p>" . $_POST['groupsuff_d'] . "</p>\n" .
|
"<br>\n<p>" . $_POST['groupsuff_d'] . "</p>\n" .
|
||||||
|
@ -177,7 +161,7 @@ if ($_POST['submit']) {
|
||||||
"</form>";
|
"</form>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty!");
|
$error = _("OU is not empty or invalid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,20 +194,12 @@ if ($_POST['submit']) {
|
||||||
}
|
}
|
||||||
// delete ou, user was sure
|
// delete ou, user was sure
|
||||||
elseif (($_POST['type'] == "del_hst") && ($_POST['sure'])) {
|
elseif (($_POST['type'] == "del_hst") && ($_POST['sure'])) {
|
||||||
// check for sub entries
|
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']);
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array(""));
|
if ($ret) {
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$message = _("OU deleted successfully.");
|
||||||
if ($info['count'] == 0) {
|
|
||||||
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']);
|
|
||||||
if ($ret) {
|
|
||||||
$message = _("OU deleted successfully.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$error = _("Unable to delete OU!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty!");
|
$error = _("Unable to delete OU!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do not delete ou
|
// do not delete ou
|
||||||
|
@ -234,9 +210,9 @@ if ($_POST['submit']) {
|
||||||
// ask if user is sure to delete
|
// ask if user is sure to delete
|
||||||
elseif ($_POST['type'] == "del_hst") {
|
elseif ($_POST['type'] == "del_hst") {
|
||||||
// check for sub entries
|
// check for sub entries
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array(""));
|
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array(""));
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
if ($info['count'] == 0) {
|
if ($sr && $info['count'] == 0) {
|
||||||
$text = "<br>\n" .
|
$text = "<br>\n" .
|
||||||
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
|
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
|
||||||
"<br>\n<p>" . $_POST['hostsuff_d'] . "</p>\n" .
|
"<br>\n<p>" . $_POST['hostsuff_d'] . "</p>\n" .
|
||||||
|
@ -250,7 +226,7 @@ if ($_POST['submit']) {
|
||||||
"</form>";
|
"</form>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty!");
|
$error = _("OU is not empty or invalid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue