show messages on same page

This commit is contained in:
Roland Gruber 2010-05-26 19:47:02 +00:00
parent c4955f49bc
commit c8fe819a02
1 changed files with 19 additions and 21 deletions

View File

@ -53,6 +53,9 @@ if (isset($_POST['abort'])) {
exit; exit;
} }
$error = null;
$message = null;
// check if submit button was pressed // check if submit button was pressed
if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) { if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
// new ou // new ou
@ -97,7 +100,9 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array("")); $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array(""));
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
if ($sr && $info['count'] == 0) { if ($sr && $info['count'] == 0) {
$text = "<br>\n" . // print header
include 'main_header.php';
echo "<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['deleteableOU'] . "</p>\n" . "<br>\n<p>" . $_POST['deleteableOU'] . "</p>\n" .
"<br>\n" . "<br>\n" .
@ -107,40 +112,33 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
"<input type=\"submit\" name=\"sure\" value=\"" . _("Delete") . "\">\n" . "<input type=\"submit\" name=\"sure\" value=\"" . _("Delete") . "\">\n" .
"<input type=\"submit\" name=\"abort\" value=\"" . _("Cancel") . "\">\n" . "<input type=\"submit\" name=\"abort\" value=\"" . _("Cancel") . "\">\n" .
"</form>"; "</form>";
echo "</body></html>\n";
exit();
} }
else { else {
$error = _("OU is not empty or invalid!"); $error = _("OU is not empty or invalid!");
} }
} }
// print header
include 'main_header.php';
// display messages
if ($error || $message || $text) {
if (isset($text)) echo $text;
elseif (isset($error)) {
StatusMessage("ERROR", "", $error);
echo ("<br><a href=\"ou_edit.php\">" . _("Back to OU-Editor") . "</a>\n");
}
else {
StatusMessage("INFO", "", $message);
echo ("<br><a href=\"ou_edit.php\">" . _("Back to OU-Editor") . "</a>\n");
}
}
echo ("</body></html>\n");
exit;
} }
display_main(); display_main($message, $error);
/** /**
* Displays the main page of the OU editor * Displays the main page of the OU editor
*
* @param String $message info message
* @param String $error error message
*/ */
function display_main() { function display_main($message, $error) {
// display main page // display main page
include 'main_header.php'; include 'main_header.php';
echo "<h1>" . _("OU editor") . "</h1>"; echo "<h1>" . _("OU editor") . "</h1>";
if (isset($error)) {
StatusMessage("ERROR", "", $error);
}
elseif (isset($message)) {
StatusMessage("INFO", "", $message);
}
echo ("<br>\n"); echo ("<br>\n");
echo ("<form action=\"ou_edit.php\" method=\"post\">\n"); echo ("<form action=\"ou_edit.php\" method=\"post\">\n");