]> git.joonet.de Git - adminer.git/commitdiff
Remove single item clone
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sun, 7 Jun 2009 23:53:51 +0000 (23:53 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sun, 7 Jun 2009 23:53:51 +0000 (23:53 +0000)
Load single row values in multi-edit

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@661 7c3ca157-0c34-0410-bff1-cbf682f78f5c

edit.inc.php
include/editing.inc.php
include/functions.inc.php
index.php
select.inc.php

index 367f017ffc4b164e5070ba0334930f1b40ce9e48..cbaf474918e955d544aedec934fcd8d758f4cc36 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-$where = (isset($_GET["select"]) ? array() : where($_GET));
-$update = ($where && !$_GET["clone"]);
+$where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : array()) : where($_GET));
+$update = ($where && !$_POST["clone"]);
 $fields = fields($_GET["edit"]);
 foreach ($fields as $name => $field) {
        if (isset($_GET["default"]) ? $field["auto_increment"] || preg_match('~text|blob~', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) {
@@ -39,15 +39,15 @@ if ($_POST && !$error && !isset($_GET["select"])) {
                }
        }
 }
-page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || isset($_GET["select"]) ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]);
+page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || (isset($_GET["select"]) && !$_POST["clone"]) ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]);
 
 unset($row);
-if ($_POST) {
+if ($_POST["save"]) {
        $row = (array) $_POST["fields"];
 } elseif ($where) {
        $select = array();
        foreach ($fields as $name => $field) {
-               if (isset($field["privileges"]["select"]) && (!$_GET["clone"] || !$field["auto_increment"])) {
+               if (isset($field["privileges"]["select"]) && (!$_POST["clone"] || !$field["auto_increment"])) {
                        $select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
                }
        }
@@ -67,11 +67,9 @@ if ($fields) {
        echo "<table cellspacing='0'>\n";
        foreach ($fields as $name => $field) {
                echo "<tr><th>" . htmlspecialchars($name) . "</th>";
-               $value = (!isset($row) ? $field["default"] :
-                       (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) :
-                       ($_POST["clone"] && $field["auto_increment"] ? "" :
-                       $row[$name]
-               )));
+               $value = (!isset($row) ? ($_POST["clone"] && $field["auto_increment"] ? "" : $field["default"])
+                       : (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
+               );
                input($name, $field, $value);
                if (isset($_GET["default"]) && $field["type"] == "timestamp") {
                        if (!isset($create) && !$_POST) {
@@ -88,10 +86,10 @@ if ($fields) {
 ?>
 <p>
 <input type="hidden" name="token" value="<?php echo $token; ?>" />
+<input type="hidden" name="save" value="1" />
 <?php
 if (isset($_GET["select"])) {
        hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
-       echo "<input type='hidden' name='save' value='1' />\n";
 }
 if ($fields) {
        echo '<input type="submit" value="' . lang('Save') . '" />';
index 812dd23ecbf1a871999580df38073361f78fae89..c362913237f8ba9ac1e8bfc18b1250fc2770f305 100644 (file)
@@ -25,7 +25,7 @@ function input($name, $field, $value, $separator = "</td><td>") { //! pass empty
                        if (preg_match('~char|date|time~', $field["type"])) {
                                $options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now"));
                        }
-                       if (!isset($_GET["clone"]) && !isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
+                       if (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
                                if (preg_match('~int|float|double|decimal~', $field["type"])) {
                                        $options = array("", "+", "-");
                                }
index a15e92c616eb77d2f1698e96ca44228d94abc7e5..42df67d07965537707a94fc922acf556bd454aa3 100644 (file)
@@ -75,6 +75,11 @@ function where($where) {
        return $return;
 }
 
+function where_check($val) {
+       parse_str($val, $check);
+       return where($check);
+}
+
 function process_length($length) {
        global $enum_length;
        return (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches) ? implode(",", $matches[0]) : preg_replace('~[^0-9,+-]~', '', $length));
index f713479f50336244b4c5d7d004f4706ba129954a..94a62ec6cf0349e0864969f49ad80d15e9e9e671 100644 (file)
--- a/index.php
+++ b/index.php
@@ -98,9 +98,6 @@ if (isset($_GET["download"])) {
                if (isset($_GET["function"])) {
                        $_GET["procedure"] = $_GET["function"];
                }
-               if (isset($_GET["clone"])) {
-                       $_GET["edit"] = $_GET["clone"];
-               }
                if (isset($_GET["sql"])) {
                        include "./sql.inc.php";
                } elseif (isset($_GET["edit"])) {
index 4da734a7a079ced6a462040e498d3accaf357cad..0fab31a4731348ac8cbe1e61097d25db6cc5b61f 100644 (file)
@@ -74,8 +74,7 @@ if ($_POST && !$error) {
                dump_table($_GET["select"], "");
                if (is_array($_POST["check"])) {
                        foreach ($_POST["check"] as $val) {
-                               parse_str($val, $check);
-                               dump_data($_GET["select"], "INSERT", "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($check)) . " LIMIT 1");
+                               dump_data($_GET["select"], "INSERT", "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where_check($val)) . " LIMIT 1");
                        }
                } else {
                        dump_data($_GET["select"], "INSERT", ($where ? "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", $where) : ""));
@@ -93,10 +92,10 @@ if ($_POST && !$error) {
                                if ($_POST["clone"]) {
                                        $set[] = ($val !== false ? $val : idf_escape($name));
                                } elseif ($val !== false) {
-                                       $set[] = idf_escape($name) . " = $val";
+                                       $set[] = "\n" . idf_escape($name) . " = $val";
                                }
                        }
-                       $command .= ($_POST["clone"] ? " SELECT " . implode(", ", $set) . " FROM " . idf_escape($_GET["select"]) : " SET " . implode(", ", $set));
+                       $command .= ($_POST["clone"] ? "\nSELECT " . implode(", ", $set) . " FROM " . idf_escape($_GET["select"]) : " SET" . implode(",", $set));
                }
                if (!$_POST["delete"] && !$set) {
                        // nothing
@@ -243,7 +242,7 @@ if (!$columns) {
                                        echo "</tr></thead>\n";
                                }
                                $unique_idf = implode('&amp;', unique_idf($row, $indexes));
-                               echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');" />' . (count($select) == count($group) && $_GET["db"] != "information_schema" ? ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a> <a href="' . htmlspecialchars($SELF) . 'clone=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('clone') . '</a></td>' : '');
+                               echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');" />' . (count($select) == count($group) && $_GET["db"] != "information_schema" ? ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
                                foreach ($row as $key => $val) {
                                        if (!isset($val)) {
                                                $val = "<i>NULL</i>";