summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_api_service_role.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_role.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_role.php')
-rw-r--r--lib/api/kolab_api_service_role.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/api/kolab_api_service_role.php b/lib/api/kolab_api_service_role.php
index fc15d0b..05808c7 100644
--- a/lib/api/kolab_api_service_role.php
+++ b/lib/api/kolab_api_service_role.php
@@ -57,6 +57,7 @@ class kolab_api_service_role extends kolab_api_service
if (in_array('read', $effective_rights['entryLevelRights'])) {
$rights['info'] = "r";
+ $rights['find'] = "r";
$rights['members_list'] = "r";
}
@@ -179,6 +180,43 @@ class kolab_api_service_role extends kolab_api_service
}
/**
+ * Find role and return its data.
+ * It is a combination of role.info and roles.list with search capabilities
+ * If the search returns only one record we'll return role data.
+ *
+ * @param array $get GET parameters
+ * @param array $post POST parameters
+ *
+ * @return array|bool Role attributes, False on error
+ */
+ public function role_find($get, $post)
+ {
+ $auth = Auth::get_instance();
+ $attributes = array('');
+ $params = array('page_size' => 2);
+ $search = $this->parse_list_search($post);
+
+ // find role(s)
+ $roles = $auth->list_roles(null, $attributes, $search, $params);
+
+ if (empty($roles) || empty($roles['list']) || $roles['count'] > 1) {
+ return false;
+ }
+
+ // get role data
+ $result = $auth->role_info(key($roles['list']));
+
+ // normalize result
+ $result = $this->parse_result_attributes('role', $result);
+
+ if ($result) {
+ return $result;
+ }
+
+ return false;
+ }
+
+ /**
* Group members listing.
*
* @param array $get GET parameters