summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-08-01 15:16:15 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-08-01 15:16:15 (GMT)
commitfe46c72139e6f717ea30ef15405405dac0a8bd8e (patch)
tree2261daa5e9c47ec98e8a8047315d19acfc51a6a7
parent6d7dffe35e0ae3ee09b34031c3f4f279cba2ddd1 (diff)
downloadkolab-wap-fe46c72139e6f717ea30ef15405405dac0a8bd8e.tar.gz
Find a resource
-rw-r--r--lib/api/kolab_api_service_resource.php44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/api/kolab_api_service_resource.php b/lib/api/kolab_api_service_resource.php
index f5d095f..7fa454b 100644
--- a/lib/api/kolab_api_service_resource.php
+++ b/lib/api/kolab_api_service_resource.php
@@ -146,21 +146,31 @@ class kolab_api_service_resource extends kolab_api_service
}
/**
- * User information.
+ * Find resource and return its data.
+ * It is a combination of resource.info and resources.list with search capabilities
+ * If the search returns only one record we'll return resource data.
*
* @param array $get GET parameters
* @param array $post POST parameters
*
- * @return array|bool User attributes, False on error
+ * @return array|bool Resource attributes, False on error
*/
- public function resource_info($getdata, $postdata)
+ public function resource_find($get, $post)
{
- if (!isset($getdata['id'])) {
+ $auth = Auth::get_instance();
+ $attributes = array('');
+ $params = array('page_size' => 2);
+ $search = $this->parse_list_search($post);
+
+ // find resource(s)
+ $resources = $auth->list_resources(null, $attributes, $search, $params);
+
+ if (empty($resources) || empty($resources['list']) || $resources['count'] > 1) {
return false;
}
- $auth = Auth::get_instance();
- $result = $auth->resource_info($getdata['id']);
+ // get resource data
+ $result = $auth->resource_info(key($resources['list']));
// normalize result
$result = $this->parse_result_attributes('resource', $result);
@@ -173,31 +183,21 @@ class kolab_api_service_resource extends kolab_api_service
}
/**
- * Find resource and return its data.
- * It is a combination of resource.info and resources.list with search capabilities
- * If the search returns only one record we'll return resource data.
+ * User information.
*
* @param array $get GET parameters
* @param array $post POST parameters
*
- * @return array|bool Resource attributes, False on error
+ * @return array|bool User attributes, False on error
*/
- public function resource_find($get, $post)
+ public function resource_info($getdata, $postdata)
{
- $auth = Auth::get_instance();
- $attributes = array('');
- $params = array('page_size' => 2);
- $search = $this->parse_list_search($post);
-
- // find resource(s)
- $resources = $auth->list_resources(null, $attributes, $search, $params);
-
- if (empty($resources) || empty($resources['list']) || $resources['count'] > 1) {
+ if (!isset($getdata['id'])) {
return false;
}
- // get resource data
- $result = $auth->resource_info(key($resources['list']));
+ $auth = Auth::get_instance();
+ $result = $auth->resource_info($getdata['id']);
// normalize result
$result = $this->parse_result_attributes('resource', $result);