summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-01-19 09:26:49 +0100
committerAleksander Machniak <alec@alec.pl>2012-01-19 09:26:49 +0100
commit852dfa881c482449eef173569d27cd0e6025d50f (patch)
tree335dfc8d72849e89dd9a679a448304e1cc7baea6
parent51ce1fc7c19e16a4ae8f431d0aac83999108bac0 (diff)
parente2c3f3df5aed98ab2050850c0e7c081d98aa83c2 (diff)
downloadwebadmin-852dfa881c482449eef173569d27cd0e6025d50f.tar.gz
Merge branch 'master' of ssh://git.klab.cc/git/machniak/kolab-wap
-rw-r--r--lib/api/kolab_domains_actions.php40
-rw-r--r--lib/api/kolab_groups_actions.php40
-rw-r--r--lib/api/kolab_users_actions.php16
3 files changed, 59 insertions, 37 deletions
diff --git a/lib/api/kolab_domains_actions.php b/lib/api/kolab_domains_actions.php
index 9d9a511..c9694fc 100644
--- a/lib/api/kolab_domains_actions.php
+++ b/lib/api/kolab_domains_actions.php
@@ -1,23 +1,27 @@
<?php
- /**
- *
- */
- class kolab_domains_actions extends kolab_api_service
+/**
+ *
+ */
+class kolab_domains_actions extends kolab_api_service
+{
+ public function capabilities($domain)
{
- public function capabilities($domain)
- {
- return array(
- 'list' => 'r',
-// 'search' => 'r',
- );
- }
-
- public function domains_list($get, $post) {
- $auth = Auth::get_instance();
- $domains = $auth->list_domains();
- return $domains;
- }
+ return array(
+ 'list' => 'r',
+// 'search' => 'r',
+ );
}
-?>
+ public function domains_list($get, $post) {
+ $auth = Auth::get_instance();
+
+ $domains = $auth->list_domains();
+ $count = count($domains);
+
+ return array(
+ 'list' => $domains,
+ 'count' => $count,
+ );
+ }
+}
diff --git a/lib/api/kolab_groups_actions.php b/lib/api/kolab_groups_actions.php
index 193fe4e..6ce3701 100644
--- a/lib/api/kolab_groups_actions.php
+++ b/lib/api/kolab_groups_actions.php
@@ -1,24 +1,28 @@
<?php
- /**
- *
- */
- class kolab_groups_actions extends kolab_api_service
+/**
+ *
+ */
+class kolab_groups_actions extends kolab_api_service
+{
+ public function capabilities($domain)
{
- public function capabilities($domain)
- {
- return array(
- 'list' => 'r',
- 'search' => 'r',
- );
- }
+ return array(
+ 'list' => 'r',
+ 'search' => 'r',
+ );
+ }
- public function groups_list($get, $post) {
- $auth = Auth::get_instance();
- $groups = $auth->list_groups();
- return $groups;
+ public function groups_list($get, $post)
+ {
+ $auth = Auth::get_instance();
- }
- }
+ $groups = $auth->list_groups();
+ $count = count($groups);
-?>
+ return array(
+ 'list' => $groups,
+ 'count' => $count,
+ );
+ }
+}
diff --git a/lib/api/kolab_users_actions.php b/lib/api/kolab_users_actions.php
index 0e73622..4ee3c06 100644
--- a/lib/api/kolab_users_actions.php
+++ b/lib/api/kolab_users_actions.php
@@ -75,8 +75,22 @@ class kolab_users_actions extends kolab_api_service
}
$users = $auth->list_users(null, $attributes, $search, $params);
+ $count = count($users);
- return $users;
+ // pagination
+ if (!empty($post['page_size']) && $count) {
+ $size = (int) $post['page_size'];
+ $page = !empty($post['page']) ? $post['page'] : 1;
+ $page = max(1, (int) $page);
+ $offset = ($page - 1) * $size;
+
+ $users = array_slice($users, $offset, $size, true);
+ }
+
+ return array(
+ 'list' => $users,
+ 'count' => $count,
+ );
}
}