summaryrefslogtreecommitdiff
path: root/lib/kolab_api_service.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-06-27 13:21:23 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-06-27 13:21:23 (GMT)
commita0a64ebabd382c0de03ccb00a0a2b52eb369248d (patch)
tree458109a7fa5c243ee470b127abef4f5bb10de4ee /lib/kolab_api_service.php
parent9652212d7f584a4da1e15010c3cfdf639c17e89d (diff)
downloadkolab-wap-a0a64ebabd382c0de03ccb00a0a2b52eb369248d.tar.gz
Support 'id' in list results
Diffstat (limited to 'lib/kolab_api_service.php')
-rw-r--r--lib/kolab_api_service.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index 4cc526a..9cdc582 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -379,6 +379,11 @@ abstract class kolab_api_service
$attributes = array_intersect($this->list_attribs, $post['attributes']);
// need to fix array keys
$attributes = array_values($attributes);
+
+ // unique attribute is always allowed
+ if (($key = array_search('id', $post['attributes'])) !== false) {
+ $attributes[] = $this->unique_attribute();
+ }
}
if (empty($attributes)) {
@@ -388,6 +393,25 @@ abstract class kolab_api_service
return $attributes;
}
+ protected function parse_list_result($result)
+ {
+ if (!empty($result) && !empty($result['count'])) {
+ $unique_attr = $this->unique_attribute();
+
+ // replace back unique attribute name with 'id'
+ foreach ($result['list'] as $idx => $record) {
+ // if not set, we assume unique attribute wasn't requested
+ if (!isset($record[$unique_attr])) {
+ break;
+ }
+ $result['list'][$idx]['id'] = $record[$unique_attr];
+ unset($result['list'][$idx][$unique_attr]);
+ }
+ }
+
+ return $list;
+ }
+
protected function parse_list_params($post)
{
$params = Array();