summaryrefslogtreecommitdiffstats
path: root/lib/kolab_client_task.php
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2017-12-28 10:47:16 +0100
committerAleksander Machniak <machniak@kolabsys.com>2017-12-28 10:47:16 +0100
commit8741dfd6d72967d8095daf86d04cb2ce71310faa (patch)
treeadf3c1547999df62d38876dfed7119f796a57a3e /lib/kolab_client_task.php
parent47b30c2a0f52a67e4df86c464b999e15e9e52160 (diff)
downloadwebadmin-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.
Diffstat (limited to 'lib/kolab_client_task.php')
-rw-r--r--lib/kolab_client_task.php38
1 files changed, 34 insertions, 4 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');