Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Inform about dropped routine, trigger and view

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1188 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
commit 32d5b9ccb6b00aa5f0e57021a712c304964f2a4f 1 parent 5438087
jakubvrana authored
12 adminer/include/editing.inc.php
View
@@ -275,3 +275,15 @@ function grant($grant, $privileges, $columns, $on) {
}
return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
}
+
+function drop_create($drop, $create, $location, $message_drop, $message_alter, $message_create, $name) {
+ if ($_POST["drop"]) {
+ return query_redirect($drop, $location, $message_drop, true, !$_POST["dropped"]);
+ }
+ $dropped = strlen($name) && ($_POST["dropped"] || queries($drop));
+ $created = queries($create);
+ if (!query_redirect(queries(), $location, (strlen($name) ? $message_alter : $message_create), $created, false, !$created) && $dropped) {
+ $_SESSION["messages"][] = $message_drop;
+ }
+ return $dropped;
+}
33 adminer/procedure.inc.php
View
@@ -4,24 +4,23 @@
$dropped = false;
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
- if (strlen($PROCEDURE)) {
- $dropped = query_redirect("DROP $routine " . idf_escape($PROCEDURE), substr(ME, 0, -1), lang('Routine has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
- }
- if (!$_POST["drop"]) {
- $set = array();
- $fields = (array) $_POST["fields"];
- ksort($fields); // enforce fields order
- foreach ($fields as $field) {
- if (strlen($field["field"])) {
- $set[] = (in_array($field["inout"], $inout) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
- }
+ $set = array();
+ $fields = (array) $_POST["fields"];
+ ksort($fields); // enforce fields order
+ foreach ($fields as $field) {
+ if (strlen($field["field"])) {
+ $set[] = (in_array($field["inout"], $inout) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
}
- query_redirect("CREATE $routine " . idf_escape($_POST["name"])
- . " (" . implode(", ", $set) . ")"
- . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "")
- . "\n$_POST[definition]"
- , substr(ME, 0, -1), (strlen($PROCEDURE) ? lang('Routine has been altered.') : lang('Routine has been created.')));
}
+ $dropped = drop_create(
+ "DROP $routine " . idf_escape($PROCEDURE),
+ "CREATE $routine " . idf_escape($_POST["name"]) . " (" . implode(", ", $set) . ")" . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . "\n$_POST[definition]",
+ substr(ME, 0, -1),
+ lang('Routine has been dropped.'),
+ lang('Routine has been altered.'),
+ lang('Routine has been created.'),
+ $PROCEDURE
+ );
}
page_header((strlen($PROCEDURE) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
@@ -42,7 +41,7 @@
<form action="" method="post" id="form">
<table cellspacing="0">
<?php edit_fields($row["fields"], $collations, $routine); ?>
-<?php if (isset($_GET["function"])) { ?><tr><td><?php echo lang('Return type') . edit_type("returns", $row["returns"], $collations); ?><?php } ?>
+<?php if (isset($_GET["function"])) { ?><tr><td><?php echo lang('Return type'); edit_type("returns", $row["returns"], $collations); ?><?php } ?>
</table>
<p><textarea name="definition" rows="10" cols="80" style="width: 98%;"><?php echo h($row["definition"]); ?></textarea>
<p>
19 adminer/trigger.inc.php
View
@@ -4,15 +4,16 @@
$trigger_event = array("INSERT", "UPDATE", "DELETE");
$dropped = false;
-if ($_POST && !$error) {
- if (strlen($_GET["name"])) {
- $dropped = query_redirect("DROP TRIGGER " . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Trigger has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
- }
- if (!$_POST["drop"]) {
- if (in_array($_POST["Timing"], $trigger_time) && in_array($_POST["Event"], $trigger_event)) {
- query_redirect("CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . " $_POST[Timing] $_POST[Event] ON " . idf_escape($TABLE) . " FOR EACH ROW\n$_POST[Statement]", ME . "table=" . urlencode($TABLE), (strlen($_GET["name"]) ? lang('Trigger has been altered.') : lang('Trigger has been created.')));
- }
- }
+if ($_POST && !$error && in_array($_POST["Timing"], $trigger_time) && in_array($_POST["Event"], $trigger_event)) {
+ $dropped = drop_create(
+ "DROP TRIGGER " . idf_escape($_GET["name"]),
+ "CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . " $_POST[Timing] $_POST[Event] ON " . idf_escape($TABLE) . " FOR EACH ROW\n$_POST[Statement]",
+ ME . "table=" . urlencode($TABLE),
+ lang('Trigger has been dropped.'),
+ lang('Trigger has been altered.'),
+ lang('Trigger has been created.'),
+ $_GET["name"]
+ );
}
page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE));
13 adminer/view.inc.php
View
@@ -2,10 +2,15 @@
$TABLE = $_GET["view"];
$dropped = false;
if ($_POST && !$error) {
- if (strlen($TABLE)) {
- $dropped = query_redirect("DROP VIEW " . idf_escape($TABLE), substr(ME, 0, -1), lang('View has been dropped.'), false, !$_POST["dropped"]);
- }
- query_redirect("CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]", ME . "table=" . urlencode($_POST["name"]), (strlen($TABLE) ? lang('View has been altered.') : lang('View has been created.')));
+ $dropped = drop_create(
+ "DROP VIEW " . idf_escape($TABLE),
+ "CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]",
+ substr(ME, 0, -1),
+ lang('View has been dropped.'),
+ lang('View has been altered.'),
+ lang('View has been created.'),
+ $TABLE
+ );
}
page_header((strlen($TABLE) ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);
Please sign in to comment.
Something went wrong with that request. Please try again.