Permalink
Browse files

Maintain insert prefill value

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@957 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 1589362 commit db46fc24cb90bd03869b0dbafb26abcfa6c772b0 jakubvrana committed Aug 3, 2009
Showing with 22 additions and 16 deletions.
  1. +10 −4 adminer/edit.inc.php
  2. +1 −1 adminer/include/functions.inc.php
  3. +11 −11 adminer/select.inc.php
View
@@ -8,10 +8,16 @@
}
}
if ($_POST && !$error && !isset($_GET["select"])) {
- $location = ($_POST["insert"] // continue edit or insert
- ? $_SERVER["REQUEST_URI"]
- : ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]) //! append &set converted to &where
- );
+ $location = $_SERVER["REQUEST_URI"]; // continue edit or insert
+ if (!$_POST["insert"]) {
+ $location = ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]);
+ $i = 0; // append &set converted to &where
+ foreach ((array) $_GET["set"] as $key => $val) {
+ if ($val == $_POST["fields"][$key]) {
+ $location .= where_link($i++, bracket_escape($key, "back"), $val);
+ }
+ }
+ }
$set = array();
foreach ($fields as $name => $field) {
$val = process_input($field);
@@ -94,7 +94,7 @@ function where_check($val) {
}
function where_link($i, $column, $value) {
- return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value);
+ return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value);
}
function redirect($location, $message = null) {
@@ -220,14 +220,15 @@ function apply_sql_function($function, $column) {
$val = nl2br(h($val));
}
- // link related items
- foreach ((array) $foreign_keys[$key] as $foreign_key) {
- if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
- foreach ($foreign_key["source"] as $i => $source) {
- $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
+ if (!$link) { // link related items
+ foreach ((array) $foreign_keys[$key] as $foreign_key) {
+ if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
+ foreach ($foreign_key["source"] as $i => $source) {
+ $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
+ }
+ $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys
+ break;
}
- $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"])) . $link; // InnoDB supports non-UNIQUE keys
- break;
}
}
}
@@ -242,13 +243,12 @@ function apply_sql_function($function, $column) {
echo "<td>";
foreach ($table_names as $table => $name) {
foreach ($backward_keys[$table] as $columns) {
- echo " <a href='" . h(ME) . 'select=' . urlencode($table);
+ $link = ME . 'select=' . urlencode($table);
$i = 0;
foreach ($columns as $column => $val) {
- echo where_link($i, $column, $rows[$n][$val]);
- $i++;
+ $link .= where_link($i++, $column, $rows[$n][$val]);
}
- echo "'>$name</a>";
+ echo " <a href='" . h($link) . "'>$name</a>";
}
}
}

0 comments on commit db46fc2

Please sign in to comment.