]> git.joonet.de Git - adminer.git/commitdiff
Add support for "where" field privilege
authorPeter Knut <peter@pematon.com>
Sun, 4 Apr 2021 22:08:42 +0000 (00:08 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sat, 8 Mar 2025 22:05:16 +0000 (23:05 +0100)
In Elasticsearch, only indexed fields are searchable.

13 files changed:
adminer/drivers/mongo.inc.php
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/adminer.inc.php
adminer/include/functions.inc.php
adminer/select.inc.php
changes.txt
plugins/drivers/clickhouse.php
plugins/drivers/elastic.php
plugins/drivers/firebird.php
todo.txt

index 2029f08b386ea6d91a33c84071f4d84a25b697f3..8cb56cfc846ea775cecfb236ef53ba5941233aa2 100644 (file)
@@ -181,6 +181,7 @@ if (isset($_GET["mongo"])) {
                                                                        "insert" => 1,
                                                                        "select" => 1,
                                                                        "update" => 1,
+                                                                       "where" => 1,
                                                                ),
                                                        );
                                                }
index 34df787c7f709b048fbb508a4146e73a8cc148b7..da68829ac5a84de06598a32c8982aab870132fb1 100644 (file)
@@ -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),
+                               "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1),
                                "primary" => $row["is_primary_key"],
                                "comment" => $comments[$row["name"]],
                        );
index 8e2df305d02bebc529d3223c422f4bc5a5894456..71f5bb0cb9289eaea45b7db6324c6b31cf49d00b 100644 (file)
@@ -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"])),
+                               "privileges" => array_flip(explode(",", "$row[PRIVILEGES],where")),
                                "comment" => $row["COLUMN_COMMENT"],
                                "primary" => ($row["COLUMN_KEY"] == "PRI"),
                                "generated" => ($generated[1] == "PERSISTENT" ? "STORED" : $generated[1]),
index 941ce8521fac7ac99b5d1dcce10315217b9ee281..46de876fb9a7656cc2379b7633551621f45b58c4 100644 (file)
@@ -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),
+                               "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1),
                                //! "comment" => $row["Comment"],
                                //! "primary" => ($row["Key"] == "PRI"),
                        );
index 8b72701144c75ee26243590b70ceed1eb55b3b58..969c294a4f3b2c71908bccf7665ffe5aeea9c0cd 100644 (file)
@@ -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),
+                               "privileges" => array("select" => 1, "insert" => 1, "update" => 1, "where" => 1),
                                "primary" => $row["pk"],
                        );
                        if ($row["pk"]) {
index 17c8706f6517cb73c05b60111851df5b456fff00..c427038e97478b3686597a597cd72ed0d948331c 100644 (file)
@@ -571,7 +571,8 @@ class Adminer {
                                        $cols = array();
                                        foreach ($fields as $name => $field) {
                                                if (
-                                                       (preg_match('~^[-\d.' . (preg_match('~IN$~', $val["op"]) ? ',' : '') . ']+$~', $val["val"]) || !preg_match('~' . number_type() . '|bit~', $field["type"]))
+                                                       isset($field["privileges"]["where"])
+                                                       && (preg_match('~^[-\d.' . (preg_match('~IN$~', $val["op"]) ? ',' : '') . ']+$~', $val["val"]) || !preg_match('~' . number_type() . '|bit~', $field["type"]))
                                                        && (!preg_match("~[\x80-\xFF]~", $val["val"]) || preg_match('~char|text|enum|set~', $field["type"]))
                                                        && (!preg_match('~date|timestamp~', $field["type"]) || preg_match('~^\d+-\d+-\d+~', $val["val"]))
                                                ) {
index 070bfe648277bb7da6e587464fb7ed268aedc76c..155b521f76f9f3cb48c266052c642e1c513188fb 100644 (file)
@@ -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),
+                       "privileges" => array("insert" => 1, "update" => 1, "where" => 1),
                        "null" => 1,
                        "auto_increment" => ($key == $driver->primary),
                );
index ab94ce7e1439042ae3d6b1a081bffaeffaf134b0..db8a0ed938941318f637c68379e2f77955d0826a 100644 (file)
@@ -11,6 +11,7 @@ parse_str($_COOKIE["adminer_import"], $adminer_import);
 
 $rights = array(); // privilege => 0
 $columns = array(); // selectable columns
+$search_columns = array(); // searchable columns
 $text_length = null;
 foreach ($fields as $key => $field) {
        $name = $adminer->fieldName($field);
@@ -20,6 +21,9 @@ foreach ($fields as $key => $field) {
                        $text_length = $adminer->selectLengthProcess();
                }
        }
+       if (isset($field["privileges"]["where"]) && $name != "") {
+               $search_columns[$key] = html_entity_decode(strip_tags($name), ENT_QUOTES);
+       }
        $rights += $field["privileges"];
 }
 
@@ -252,7 +256,7 @@ if (!$columns && support("table")) {
        echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
        echo "</div>\n";
        $adminer->selectColumnsPrint($select, $columns);
-       $adminer->selectSearchPrint($where, $columns, $indexes);
+       $adminer->selectSearchPrint($where, $search_columns, $indexes);
        $adminer->selectOrderPrint($order, $columns, $indexes);
        $adminer->selectLimitPrint($limit);
        $adminer->selectLengthPrint($text_length);
@@ -343,7 +347,7 @@ if (!$columns && support("table")) {
                                                echo apply_sql_function($val["fun"], $name) . "</a>"; //! columns looking like functions
                                                echo "<span class='column hidden'>";
                                                echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>";
-                                               if (!$val["fun"]) {
+                                               if (!$val["fun"] && isset($field["privileges"]["where"])) {
                                                        echo '<a href="#fieldset-search" title="' . lang('Search') . '" class="text jsonly"> =</a>';
                                                        echo script("qsl('a').onclick = partial(selectSearch, '" . js_escape($key) . "');");
                                                }
index e664e773150ed8ba6fe2a16fe835a19e549f0d9b..43c95f8d39bc7c2a483e0a8669e3ccc862ec7dae 100644 (file)
@@ -1,12 +1,14 @@
 Adminer dev:
 PostgreSQL: Fix setting NULL and original value on enum (bug #884)
 CockroachDB: Add support via PostgreSQL driver
+Elasticsearch: Add support for "where" field privilege
 
 Adminer 5.0.1 (released 2025-03-07):
 Fix bulk operations with tables (regression from 5.0.0)
 Remove duplicate columns from select (bug #670)
 MariaDB: Fix link to status variable doc (bug #658)
 PostgreSQL: Support indexes on materialized views (PR #467)
+Elasticsearch: Drop support for version < 7
 
 Adminer 5.0.0 (released 2025-03-07):
 Speed up with disabled output buffering
index b1ab464799ad812012a0c3486602d440e8957803..804818c7fbac1d449774b5c6bcd0df6f4af70c24 100644 (file)
@@ -340,7 +340,7 @@ if (isset($_GET["clickhouse"])) {
                                "default" => trim($row['default_expression']),
                                "null" => $nullable,
                                "auto_increment" => '0',
-                               "privileges" => array("insert" => 1, "select" => 1, "update" => 0),
+                               "privileges" => array("insert" => 1, "select" => 1, "update" => 0, "where" => 1),
                        );
                }
 
index 151b23321ebe682d488f450a615dd57e5f5aa7c7..210ac5c38d17f15b60fe17408acdf7775e55f5dc 100644 (file)
@@ -471,11 +471,6 @@ if (isset($_GET["elastic"])) {
                );
 
                foreach ($mappings as $name => $field) {
-                       $has_index = !isset($field["index"]) || $field["index"];
-
-                       // TODO: privileges: where => $has_index
-                       // TODO: privileges: sort => $field["type"] != "text"
-
                        $result[$name] = array(
                                "field" => $name,
                                "full_type" => $field["type"],
index 2e22084dec830aecf5f4437403a113172dc07d07..0ae27236c729fad561489c247c7c59eb7a7c9b42 100644 (file)
@@ -254,7 +254,7 @@ ORDER BY r.RDB$FIELD_POSITION';
                                "null" => (trim($row["FIELD_NOT_NULL_CONSTRAINT"]) == "YES"),
                                "auto_increment" => '0',
                                "collation" => trim($row["FIELD_COLLATION"]),
-                               "privileges" => array("insert" => 1, "select" => 1, "update" => 1),
+                               "privileges" => array("insert" => 1, "select" => 1, "update" => 1, "where" => 1),
                                "comment" => trim($row["FIELD_DESCRIPTION"]),
                        );
                }
index 872a907f05000d1979cb78f225b33e5f1f0a984c..56937c314ab2f0bc492ca1f1cc30f4318f5f55e8 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -15,7 +15,6 @@ Skinnable plus.gif and other images - http://typo3.org/extensions/repository/vie
 
 https://github.com/vrana/adminer/compare/master...adminneo-org:adminneo:main
 Add drag-n-drop moving of rows in table editing
-Elasticsearch: Add support for "where" field privilege
 Elasticsearch: Add support for "order" field privilege
 Elasticsearch: New condition operators as the combination of query type and match type