Permalink
Browse files

Remove Delete button from Edit page

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@887 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
jakubvrana
jakubvrana committed Jul 23, 2009
1 parent a78c941 commit 90b8a2f927c972d3bdb7183d231f77f251d6572e
View
@@ -12,74 +12,70 @@
}
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
- if ($_POST["drop"]) {
- query_redirect("DROP TABLE " . idf_escape($_GET["create"]), substr($SELF, 0, -1), lang('Table has been dropped.'));
- } else {
- $auto_increment_index = " PRIMARY KEY";
- // don't overwrite primary key by auto_increment
- if (strlen($_GET["create"]) && strlen($_POST["fields"][$_POST["auto_increment_col"]]["orig"])) {
- foreach (indexes($_GET["create"]) as $index) {
- foreach ($index["columns"] as $column) {
- if ($column === $_POST["fields"][$_POST["auto_increment_col"]]["orig"]) {
- $auto_increment_index = "";
- break 2;
- }
- }
- if ($index["type"] == "PRIMARY") {
- $auto_increment_index = " UNIQUE";
+ $auto_increment_index = " PRIMARY KEY";
+ // don't overwrite primary key by auto_increment
+ if (strlen($_GET["create"]) && strlen($_POST["fields"][$_POST["auto_increment_col"]]["orig"])) {
+ foreach (indexes($_GET["create"]) as $index) {
+ foreach ($index["columns"] as $column) {
+ if ($column === $_POST["fields"][$_POST["auto_increment_col"]]["orig"]) {
+ $auto_increment_index = "";
+ break 2;
}
}
- }
- $fields = array();
- ksort($_POST["fields"]);
- $after = "FIRST";
- foreach ($_POST["fields"] as $key => $field) {
- $type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
- if (strlen($field["field"]) && $type_field) {
- $fields[] = "\n" . (strlen($_GET["create"]) ? (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ") : " ")
- . idf_escape($field["field"]) . process_type($type_field)
- . ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
- . (strlen($_GET["create"]) && strlen($field["orig"]) && isset($orig_fields[$field["orig"]]["default"]) && $field["type"] != "timestamp" ? " DEFAULT " . $dbh->quote($orig_fields[$field["orig"]]["default"]) : "") //! timestamp
- . ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
- . " COMMENT " . $dbh->quote($field["comment"])
- . (strlen($_GET["create"]) ? " $after" : "")
- ;
- $after = "AFTER " . idf_escape($field["field"]);
- if (!isset($types[$field["type"]])) {
- $fields[] = (strlen($_GET["create"]) ? " ADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")";
- }
- } elseif (strlen($field["orig"])) {
- $fields[] = "\nDROP " . idf_escape($field["orig"]);
+ if ($index["type"] == "PRIMARY") {
+ $auto_increment_index = " UNIQUE";
}
}
- $status = ($_POST["Engine"] ? "ENGINE=" . $dbh->quote($_POST["Engine"]) : "")
- . ($_POST["Collation"] ? " COLLATE " . $dbh->quote($_POST["Collation"]) : "")
- . (strlen($_POST["Auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["Auto_increment"]) : "")
- . " COMMENT=" . $dbh->quote($_POST["Comment"])
- ;
- if (in_array($_POST["partition_by"], $partition_by)) {
- $partitions = array();
- if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
- foreach (array_filter($_POST["partition_names"]) as $key => $val) {
- $value = $_POST["partition_values"][$key];
- $partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . (strlen($value) ? " ($value)" : " MAXVALUE"); //! SQL injection
- }
+ }
+ $fields = array();
+ ksort($_POST["fields"]);
+ $after = "FIRST";
+ foreach ($_POST["fields"] as $key => $field) {
+ $type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
+ if (strlen($field["field"]) && $type_field) {
+ $fields[] = "\n" . (strlen($_GET["create"]) ? (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ") : " ")
+ . idf_escape($field["field"]) . process_type($type_field)
+ . ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
+ . (strlen($_GET["create"]) && strlen($field["orig"]) && isset($orig_fields[$field["orig"]]["default"]) && $field["type"] != "timestamp" ? " DEFAULT " . $dbh->quote($orig_fields[$field["orig"]]["default"]) : "") //! timestamp
+ . ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
+ . " COMMENT " . $dbh->quote($field["comment"])
+ . (strlen($_GET["create"]) ? " $after" : "")
+ ;
+ $after = "AFTER " . idf_escape($field["field"]);
+ if (!isset($types[$field["type"]])) {
+ $fields[] = (strlen($_GET["create"]) ? " ADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")";
}
- $status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
- ? " (" . implode(",", $partitions) . "\n)"
- : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
- );
- } elseif ($dbh->server_info >= 5.1 && strlen($_GET["create"])) {
- $status .= "\nREMOVE PARTITIONING";
+ } elseif (strlen($field["orig"])) {
+ $fields[] = "\nDROP " . idf_escape($field["orig"]);
}
- $location = $SELF . "table=" . urlencode($_POST["name"]);
- if (strlen($_GET["create"])) {
- query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
- } else {
- $path = preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]);
- setcookie("adminer_engine", $_POST["Engine"], gmmktime(0, 0, 0, gmdate("n") + 1), $path);
- query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . implode(",", $fields) . "\n) $status", $location, lang('Table has been created.'));
+ }
+ $status = ($_POST["Engine"] ? "ENGINE=" . $dbh->quote($_POST["Engine"]) : "")
+ . ($_POST["Collation"] ? " COLLATE " . $dbh->quote($_POST["Collation"]) : "")
+ . (strlen($_POST["Auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["Auto_increment"]) : "")
+ . " COMMENT=" . $dbh->quote($_POST["Comment"])
+ ;
+ if (in_array($_POST["partition_by"], $partition_by)) {
+ $partitions = array();
+ if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
+ foreach (array_filter($_POST["partition_names"]) as $key => $val) {
+ $value = $_POST["partition_values"][$key];
+ $partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . (strlen($value) ? " ($value)" : " MAXVALUE"); //! SQL injection
+ }
}
+ $status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
+ ? " (" . implode(",", $partitions) . "\n)"
+ : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
+ );
+ } elseif ($dbh->server_info >= 5.1 && strlen($_GET["create"])) {
+ $status .= "\nREMOVE PARTITIONING";
+ }
+ $location = $SELF . "table=" . urlencode($_POST["name"]);
+ if (strlen($_GET["create"])) {
+ query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
+ } else {
+ $path = preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]);
+ setcookie("adminer_engine", $_POST["Engine"], gmmktime(0, 0, 0, gmdate("n") + 1), $path);
+ query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . implode(",", $fields) . "\n) $status", $location, lang('Table has been created.'));
}
}
@@ -153,7 +149,6 @@
<p>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if (strlen($_GET["create"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
<?php
if ($dbh->server_info >= 5.1) {
$partition_table = ereg('RANGE|LIST', $row["partition_by"]);
View
@@ -9,35 +9,31 @@
}
if ($_POST && !$error && !isset($_GET["select"])) {
$location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"])); // "insert" to continue edit or insert
- if (isset($_POST["delete"])) {
- query_redirect("DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE $where LIMIT 1", $location, lang('Item has been deleted.'));
- } else {
- $set = array();
- foreach ($fields as $name => $field) {
- $val = process_input($name, $field);
- if (!isset($_GET["default"])) {
- if ($val !== false || !$update) {
- $set[] = "\n" . idf_escape($name) . " = " . ($val !== false ? $val : "''");
- }
- } elseif ($val !== false) {
- if ($field["type"] == "timestamp" && $val != "NULL") { //! doesn't allow DEFAULT NULL and no ON UPDATE
- $set[] = "\nMODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val" . ($_POST["on_update"][bracket_escape($name)] ? " ON UPDATE CURRENT_TIMESTAMP" : "");
- } else {
- $set[] = "\nALTER " . idf_escape($name) . ($val == "NULL" ? " DROP DEFAULT" : " SET DEFAULT $val");
- }
+ $set = array();
+ foreach ($fields as $name => $field) {
+ $val = process_input($name, $field);
+ if (!isset($_GET["default"])) {
+ if ($val !== false || !$update) {
+ $set[] = "\n" . idf_escape($name) . " = " . ($val !== false ? $val : "''");
+ }
+ } elseif ($val !== false) {
+ if ($field["type"] == "timestamp" && $val != "NULL") { //! doesn't allow DEFAULT NULL and no ON UPDATE
+ $set[] = "\nMODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val" . ($_POST["on_update"][bracket_escape($name)] ? " ON UPDATE CURRENT_TIMESTAMP" : "");
+ } else {
+ $set[] = "\nALTER " . idf_escape($name) . ($val == "NULL" ? " DROP DEFAULT" : " SET DEFAULT $val");
}
- }
- if (!$set) {
- redirect($location);
- }
- if (isset($_GET["default"])) {
- query_redirect("ALTER TABLE " . idf_escape($_GET["edit"]) . implode(",", $set), $location, lang('Default values has been set.'));
- } elseif ($update) {
- query_redirect("UPDATE " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set) . "\nWHERE $where\nLIMIT 1", $location, lang('Item has been updated.'));
- } else {
- query_redirect("INSERT INTO " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set), $location, lang('Item has been inserted.'));
}
}
+ if (!$set) {
+ redirect($location);
+ }
+ if (isset($_GET["default"])) {
+ query_redirect("ALTER TABLE " . idf_escape($_GET["edit"]) . implode(",", $set), $location, lang('Default values has been set.'));
+ } elseif ($update) {
+ query_redirect("UPDATE " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set) . "\nWHERE $where\nLIMIT 1", $location, lang('Item has been updated.'));
+ } else {
+ query_redirect("INSERT INTO " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set), $location, lang('Item has been inserted.'));
+ }
}
$table_name = adminer_table_name(table_status($_GET["edit"]));
@@ -106,8 +102,5 @@
echo "<input type='submit' name='insert' value='" . ($update ? lang('Save and continue edit') : lang('Save and insert next')) . "'>\n";
}
}
-if ($update) {
- echo "<input type='submit' name='delete' value='" . lang('Delete') . "'$confirm>\n";
-}
?>
</form>
View
@@ -10,7 +10,6 @@
'Select database' => 'Vybrat databázi',
'Invalid database.' => 'Nesprávná databáze.',
'Create new database' => 'Vytvořit novou databázi',
- 'Table has been dropped.' => 'Tabulka byla odstraněna.',
'Table has been altered.' => 'Tabulka byla změněna.',
'Table has been created.' => 'Tabulka byla vytvořena.',
'Alter table' => 'Pozměnit tabulku',
@@ -40,7 +39,6 @@
'No tables.' => 'Žádné tabulky.',
'select' => 'vypsat',
'Create new table' => 'Vytvořit novou tabulku',
- 'Item has been deleted.' => 'Položka byla smazána.',
'Item has been updated.' => 'Položka byla aktualizována.',
'Item has been inserted.' => 'Položka byla vložena.',
'Edit' => 'Upravit',
View
@@ -10,7 +10,6 @@
'Select database' => 'Datenbank auswählen',
'Invalid database.' => 'Datenbank ungültig.',
'Create new database' => 'Neue Datenbank',
- 'Table has been dropped.' => 'Tabelle entfernt.',
'Table has been altered.' => 'Tabelle geändert.',
'Table has been created.' => 'Tabelle erstellt.',
'Alter table' => 'Tabelle ändern',
@@ -40,7 +39,6 @@
'No tables.' => 'Keine Tabellen.',
'select' => 'zeigen',
'Create new table' => 'Neue Tabelle',
- 'Item has been deleted.' => 'Datensatz gelöscht.',
'Item has been updated.' => 'Datensatz geändert.',
'Item has been inserted.' => 'Datensatz hinzugefügt.',
'Edit' => 'Ändern',
View
@@ -10,7 +10,6 @@
'Select database' => 'Seleccionar Base de datos',
'Invalid database.' => 'Base de datos inválida.',
'Create new database' => 'Nueva Base de datos',
- 'Table has been dropped.' => 'Tabla eliminada.',
'Table has been altered.' => 'Tabla modificada.',
'Table has been created.' => 'Tabla creada.',
'Alter table' => 'Modificar tabla',
@@ -40,7 +39,6 @@
'No tables.' => 'No existen tablas.',
'select' => 'registros',
'Create new table' => 'Nueva tabla',
- 'Item has been deleted.' => 'Registro eliminado.',
'Item has been updated.' => 'Registro modificado.',
'Item has been inserted.' => 'Registro insertado.',
'Edit' => 'Modificar',
View
@@ -10,7 +10,6 @@
'Select database' => 'Vali andmebaas',
'Invalid database.' => 'Tundmatu andmebaas.',
'Create new database' => 'Loo uus andmebaas',
- 'Table has been dropped.' => 'Tabel on edukalt kustutatud.',
'Table has been altered.' => 'Tabeli andmed on edukalt muudetud.',
'Table has been created.' => 'Tabel on edukalt loodud.',
'Alter table' => 'Muuda tabeli struktuuri',
@@ -40,7 +39,6 @@
'No tables.' => 'Tabeleid ei leitud.',
'select' => 'kuva',
'Create new table' => 'Loo uus tabel',
- 'Item has been deleted.' => 'Kustutamine õnnestus.',
'Item has been updated.' => 'Uuendamine õnnestus.',
'Item has been inserted.' => 'Lisamine õnnestus.',
'Edit' => 'Muuda',
View
@@ -10,7 +10,6 @@
'Select database' => 'Selectionner la base de donnée',
'Invalid database.' => 'Base de donnée invalide',
'Create new database' => 'Créer une base de donnée',
- 'Table has been dropped.' => 'Table effacée',
'Table has been altered.' => 'Table modifiée',
'Table has been created.' => 'Table créée.',
'Alter table' => 'Modifier la table',
@@ -40,7 +39,6 @@
'No tables.' => 'Aucunes tables.',
'select' => 'select',
'Create new table' => 'Créer une table',
- 'Item has been deleted.' => 'Élément supprimé.',
'Item has been updated.' => 'Élément modifié.',
'Item has been inserted.' => 'Élément inseré.',
'Edit' => 'Modifier',
View
@@ -10,7 +10,6 @@
'Select database' => 'Seleziona database',
'Invalid database.' => 'Database non valido.',
'Create new database' => 'Crea nuovo database',
- 'Table has been dropped.' => 'Tabella eliminata.',
'Table has been altered.' => 'Tabella modificata.',
'Table has been created.' => 'Tabella creata.',
'Alter table' => 'Modifica tabella',
@@ -40,7 +39,6 @@
'No tables.' => 'No tabelle.',
'select' => 'seleziona',
'Create new table' => 'Crea nuova tabella',
- 'Item has been deleted.' => 'Elemento eliminato.',
'Item has been updated.' => 'Elemento aggiornato.',
'Item has been inserted.' => 'Elemento inserito.',
'Edit' => 'Modifica',
View
@@ -10,7 +10,6 @@
'Select database' => 'Database selecteren',
'Invalid database.' => 'Ongeldige database.',
'Create new database' => 'Nieuwe database',
- 'Table has been dropped.' => 'Tabel verwijderd.',
'Table has been altered.' => 'Tabel aangepast.',
'Table has been created.' => 'Tabel aangemaakt.',
'Alter table' => 'Tabel aanpassen',
@@ -40,7 +39,6 @@
'No tables.' => 'Geen tabellen.',
'select' => 'kies',
'Create new table' => 'Nieuwe tabel',
- 'Item has been deleted.' => 'Item verwijderd.',
'Item has been updated.' => 'Item aangepast.',
'Item has been inserted.' => 'Item toegevoegd.',
'Edit' => 'Bewerk',
View
@@ -10,7 +10,6 @@
'Select database' => 'Выбрать базу данных',
'Invalid database.' => 'Плохая база данных.',
'Create new database' => 'Создать новую базу данных',
- 'Table has been dropped.' => 'Таблица была удалена.',
'Table has been altered.' => 'Таблица была изменена.',
'Table has been created.' => 'Таблица была создана.',
'Alter table' => 'Изменить таблицу',
@@ -40,7 +39,6 @@
'No tables.' => 'В базе данных нет таблиц.',
'select' => 'выбрать',
'Create new table' => 'Создать новую таблицу',
- 'Item has been deleted.' => 'Запись удалена.',
'Item has been updated.' => 'Запись обновлена.',
'Item has been inserted.' => 'Запись вставлена.',
'Edit' => 'Редактировать',
View
@@ -10,7 +10,6 @@
'Select database' => 'Vybrať databázu',
'Invalid database.' => 'Nesprávna databáza.',
'Create new database' => 'Vytvoriť novú databázu',
- 'Table has been dropped.' => 'Tabuľka bola odstránená.',
'Table has been altered.' => 'Tabuľka bola zmenená.',
'Table has been created.' => 'Tabuľka bola vytvorená.',
'Alter table' => 'Zmeniť tabuľku',
@@ -40,7 +39,6 @@
'No tables.' => 'Žiadne tabuľky.',
'select' => 'vypísať',
'Create new table' => 'Vytvoriť novú tabuľku',
- 'Item has been deleted.' => 'Položka bola vymazaná.',
'Item has been updated.' => 'Položka bola aktualizovaná.',
'Item has been inserted.' => 'Položka bola vložená.',
'Edit' => 'Upraviť',
View
@@ -10,7 +10,6 @@
'Select database' => '选择数据库',
'Invalid database.' => '无效数据库。',
'Create new database' => '创建新数据库',
- 'Table has been dropped.' => '已丢弃表。',
'Table has been altered.' => '已更改表。',
'Table has been created.' => '已创建表。',
'Alter table' => '更改表',
@@ -40,7 +39,6 @@
'No tables.' => '没有表。',
'select' => '选择',
'Create new table' => '创建新表',
- 'Item has been deleted.' => '已删除项目。',
'Item has been updated.' => '已更新项目。',
'Item has been inserted.' => '已插入项目。',
'Edit' => '编辑',
View
@@ -8,6 +8,7 @@ Separate types to groups in table creation
Show type in field name title (thanks to Jakub Sochor)
Preselect now() for timestamp columns (thanks to paranoiq)
Clear history (thanks to paranoiq)
+Remove Delete button from Edit page - use mass operation for it
Faster multiple update, clone and delete
Use HTML Strict instead of XHTML
Fix grant ALL PRIVILEGES with GRANT OPTION

0 comments on commit 90b8a2f

Please sign in to comment.