1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 17:44:07 +02:00

Simplify process_fields()

This commit is contained in:
Jakub Vrana
2013-05-08 11:43:53 -07:00
parent 046da00eb6
commit c38655418b
3 changed files with 51 additions and 55 deletions

View File

@@ -260,7 +260,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
/** Move fields up and down or add field
* @param array
* @return null
* @return bool
*/
function process_fields(&$fields) {
ksort($fields);
@@ -278,8 +278,7 @@ function process_fields(&$fields) {
}
$offset++;
}
}
if ($_POST["down"]) {
} elseif ($_POST["down"]) {
$found = false;
foreach ($fields as $key => $field) {
if (isset($field["field"]) && $found) {
@@ -292,11 +291,13 @@ function process_fields(&$fields) {
}
$offset++;
}
}
$fields = array_values($fields);
if ($_POST["add"]) {
} elseif ($_POST["add"]) {
$fields = array_values($fields);
array_splice($fields, key($_POST["add"]), 0, array(array()));
} elseif (!$_POST["drop_col"]) {
return false;
}
return true;
}
/** Callback used in routine()