summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_api_service_user.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-04-12 12:25:41 +0200
committerAleksander Machniak <alec@alec.pl>2013-04-12 12:25:41 +0200
commit5a9a69958ddf0428cf4a6c2333715e254e6a83d6 (patch)
tree30a8eca86f6204a3a92196f18884e16f9b06aaf6 /lib/api/kolab_api_service_user.php
parentd1b909c124910576a6b22cca11ebd08344e10e3c (diff)
downloadwebadmin-5a9a69958ddf0428cf4a6c2333715e254e6a83d6.tar.gz
Implemented user.find, role.find, resource.find and group.find actions
Diffstat (limited to 'lib/api/kolab_api_service_user.php')
-rw-r--r--lib/api/kolab_api_service_user.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index a8b286d..ffe6637 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -61,6 +61,7 @@ class kolab_api_service_user extends kolab_api_service
if (in_array('read', $effective_rights['entryLevelRights'])) {
$rights['info'] = "r";
+ $rights['find'] = "r";
}
$rights['effective_rights'] = "r";
@@ -177,4 +178,42 @@ class kolab_api_service_user extends kolab_api_service
return false;
}
+
+ /**
+ * Find user and return his data.
+ * It is a combination of user.info and users.list with search capabilities
+ * If the search returns only one record we'll return user data.
+ *
+ * @param array $get GET parameters
+ * @param array $post POST parameters
+ *
+ * @return array|bool User attributes, False on error
+ */
+ public function user_find($get, $post)
+ {
+ $auth = Auth::get_instance();
+ $attributes = array('');
+ $params = array('page_size' => 2);
+ $search = $this->parse_list_search($post);
+
+ // find user(s)
+ $users = $auth->list_users(null, $attributes, $search, $params);
+
+ if (empty($users) || empty($users['list']) || $users['count'] > 1) {
+ return false;
+ }
+
+ // get user data
+ $result = $auth->user_info(key($users['list']));
+
+ // normalize result
+ $result = $this->parse_result_attributes('user', $result);
+
+ if ($result) {
+ return $result;
+ }
+
+ return false;
+ }
+
}