diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index 8cb56cfc..d61365d6 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -182,6 +182,7 @@ if (isset($_GET["mongo"])) { "select" => 1, "update" => 1, "where" => 1, + "order" => 1, ), ); } diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index da68829a..a5136c2b 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -380,7 +380,7 @@ WHERE c.object_id = " . q($table_id)) as $row "null" => $row["is_nullable"], "auto_increment" => $row["is_identity"], "collation" => $row["collation_name"], - "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1), + "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1, "order" => 1), "primary" => $row["is_primary_key"], "comment" => $comments[$row["name"]], ); diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 71f5bb0c..b4168e27 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -613,7 +613,7 @@ if (!defined('Adminer\DRIVER')) { "auto_increment" => ($extra == "auto_increment"), "on_update" => (preg_match('~\bon update (\w+)~i', $extra, $match) ? $match[1] : ""), //! available since MySQL 5.1.23 "collation" => $row["COLLATION_NAME"], - "privileges" => array_flip(explode(",", "$row[PRIVILEGES],where")), + "privileges" => array_flip(explode(",", "$row[PRIVILEGES],where,order")), "comment" => $row["COLUMN_COMMENT"], "primary" => ($row["COLUMN_KEY"] == "PRI"), "generated" => ($generated[1] == "PERSISTENT" ? "STORED" : $generated[1]), diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 46de876f..5282a972 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -334,7 +334,7 @@ ORDER BY 1") as $row "null" => ($row["NULLABLE"] == "Y"), //! "auto_increment" => false, //! "collation" => $row["CHARACTER_SET_NAME"], - "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1), + "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1, "order" => 1), //! "comment" => $row["Comment"], //! "primary" => ($row["Key"] == "PRI"), ); diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 969c294a..5c3394a3 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -266,7 +266,7 @@ if (isset($_GET["sqlite"])) { "full_type" => $type, "default" => (preg_match("~^'(.*)'$~", $default, $match) ? str_replace("''", "'", $match[1]) : ($default == "NULL" ? null : $default)), "null" => !$row["notnull"], - "privileges" => array("select" => 1, "insert" => 1, "update" => 1, "where" => 1), + "privileges" => array("select" => 1, "insert" => 1, "update" => 1, "where" => 1, "order" => 1), "primary" => $row["pk"], ); if ($row["pk"]) { diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 155b521f..c1f0a67c 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -1069,7 +1069,7 @@ function fields_from_edit() { $name = bracket_escape($key, 1); // 1 - back $return[$name] = array( "field" => $name, - "privileges" => array("insert" => 1, "update" => 1, "where" => 1), + "privileges" => array("insert" => 1, "update" => 1, "where" => 1, "order" => 1), "null" => 1, "auto_increment" => ($key == $driver->primary), ); diff --git a/adminer/select.inc.php b/adminer/select.inc.php index db8a0ed9..e467fd2a 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -12,6 +12,7 @@ parse_str($_COOKIE["adminer_import"], $adminer_import); $rights = array(); // privilege => 0 $columns = array(); // selectable columns $search_columns = array(); // searchable columns +$order_columns = array(); // searchable columns $text_length = null; foreach ($fields as $key => $field) { $name = $adminer->fieldName($field); @@ -24,6 +25,9 @@ foreach ($fields as $key => $field) { if (isset($field["privileges"]["where"]) && $name != "") { $search_columns[$key] = html_entity_decode(strip_tags($name), ENT_QUOTES); } + if (isset($field["privileges"]["order"]) && $name != "") { + $order_columns[$key] = html_entity_decode(strip_tags($name), ENT_QUOTES); + } $rights += $field["privileges"]; } @@ -257,7 +261,7 @@ if (!$columns && support("table")) { echo "\n"; $adminer->selectColumnsPrint($select, $columns); $adminer->selectSearchPrint($where, $search_columns, $indexes); - $adminer->selectOrderPrint($order, $columns, $indexes); + $adminer->selectOrderPrint($order, $order_columns, $indexes); $adminer->selectLimitPrint($limit); $adminer->selectLengthPrint($text_length); $adminer->selectActionPrint($indexes); @@ -342,11 +346,19 @@ if (!$columns && support("table")) { $column = idf_escape($key); $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key); $desc = "&desc%5B0%5D=1"; + $sortable = isset($field["privileges"]["order"]); echo "" . script("mixin(qsl('th'), {onmouseover: partial(columnMouse), onmouseout: partial(columnMouse, ' hidden')});", ""); - echo ''; // $order[0] == $key - COUNT(*) - echo apply_sql_function($val["fun"], $name) . ""; //! columns looking like functions + if ($sortable) { + echo ''; // $order[0] == $key - COUNT(*) + } + echo apply_sql_function($val["fun"], $name); //! columns looking like functions + if ($sortable) { + echo ""; + } echo "