diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2017-12-28 10:47:16 +0100 |
---|---|---|
committer | Aleksander Machniak <machniak@kolabsys.com> | 2017-12-28 10:47:16 +0100 |
commit | 8741dfd6d72967d8095daf86d04cb2ce71310faa (patch) | |
tree | adf3c1547999df62d38876dfed7119f796a57a3e | |
parent | 47b30c2a0f52a67e4df86c464b999e15e9e52160 (diff) | |
download | webadmin-8741dfd6d72967d8095daf86d04cb2ce71310faa.tar.gz |
Support attribute=value search (Bifrost#T67329)
Search input accepts special entry format <attribute><operator><value> where
- <attribute> is an ldap attribute name,
- <operator> is one of: =, ~=, >=, <=,
- <value> is any string that can be * to match any value or can contain * at the end or start of the string for prefix/suffix search.
-rw-r--r-- | lib/kolab_client_task.php | 38 | ||||
-rw-r--r-- | public_html/skins/default/style.css | 1 |
2 files changed, 34 insertions, 5 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php index a420e24..e8c121d 100644 --- a/lib/kolab_client_task.php +++ b/lib/kolab_client_task.php @@ -1641,12 +1641,42 @@ class kolab_client_task $attrs = $this->get_search_attribs($field); $search_request = array(); - foreach ($attrs as $attr) { - $search_request[$attr] = array( - 'value' => $search, - 'type' => $method, + // Support attribute=value searches + if ($task != 'settings' && preg_match('/^([a-z0-9]+)([~<>]*=)(.+)$/i', $search, $m)) { + $search_attr = $m[1]; + $search_type = $m[2]; + $search_value = $m[3]; + + if ($search_value === '*') { + $search_type = 'exists'; + $search_value = ''; + } + else if ($search_value[0] === '*' && $search_value[strlen($search_value)-1] === '*') { + $search_type = 'both'; + $search_value = substr($search_value, 1, -1); + } + else if ($search_value[0] === '*') { + $search_type = 'suffix'; + $search_value = substr($search_value, 1); + } + else if ($search_value[strlen($search_value)-1] === '*') { + $search_type = 'prefix'; + $search_value = substr($search_value, 0, -1); + } + + $search_request[$search_attr] = array( + 'value' => $search_value, + 'type' => $search_type, ); } + else { + foreach ($attrs as $attr) { + $search_request[$attr] = array( + 'value' => $search, + 'type' => $method, + ); + } + } } else if (!empty($_POST['search_request'])) { $search_request = self::get_input('search_request', 'POST'); diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css index 856ea2d..ee00c91 100644 --- a/public_html/skins/default/style.css +++ b/public_html/skins/default/style.css @@ -385,7 +385,6 @@ table.list.tree td span.spacer { #searchinput { border: none; background-color: white; - margin-top: 2px; } #searchinput:focus { |