summaryrefslogtreecommitdiffstats
path: root/lib/api
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-01-17 14:23:11 +0100
committerAleksander Machniak <machniak@kolabsys.com>2012-01-17 14:23:11 +0100
commit22ebadaa3ab07a6f91a71f4c63874c2f2c4f7937 (patch)
tree2a3ae3397e6b28aac4bc6965a447a4446a0a2473 /lib/api
parentd2cd2b96d6cdf5f0bb7065290f52d811cdc9e701 (diff)
downloadwebadmin-22ebadaa3ab07a6f91a71f4c63874c2f2c4f7937.tar.gz
Users searching
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/kolab_users_actions.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/api/kolab_users_actions.php b/lib/api/kolab_users_actions.php
index 6686668..677bffb 100644
--- a/lib/api/kolab_users_actions.php
+++ b/lib/api/kolab_users_actions.php
@@ -26,6 +26,7 @@ class kolab_users_actions extends kolab_api_service
{
$auth = Auth::get_instance();
+ // returned attributes
if (!empty($post['attributes']) && is_array($post['attributes'])) {
// get only supported attributes
$attributes = array_intersect($this->list_attribs, $post['attributes']);
@@ -36,7 +37,31 @@ class kolab_users_actions extends kolab_api_service
$attributes = (array)$this->list_attribs[0];
}
- $users = $auth->list_users(null, $attributes);
+ // searching
+ $search = array();
+ if (!empty($post['search']) && is_array($post['search'])) {
+ $params = $post['search'];
+ foreach ($params as $idx => $param) {
+ // get only supported attributes
+ if (!in_array($idx, $this->list_attribs)) {
+ unset($params[$idx]);
+ continue;
+ }
+
+ // search string
+ if (empty($param['value'])) {
+ unset($params[$idx]);
+ continue;
+ }
+ }
+
+ $search['params'] = $params;
+ if (!empty($post['search_operator'])) {
+ $search['operator'] = $post['search_operator'];
+ }
+ }
+
+ $users = $auth->list_users(null, $attributes, $search);
$users = $auth->normalize_result($users);
return $users;