summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_api_service_domains.php
blob: bedce8521ea7ac4e310656c606f4ec73ce372a24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 *
 */
class kolab_api_service_domains extends kolab_api_service
{
    public function capabilities($domain)
    {
        return array(
            'list' => 'r',
//             'search' => 'r',
        );
    }

    public function domains_list($get, $post) {
        $auth = Auth::get_instance();

        $domains = $auth->list_domains();
        $count   = count($domains);

        // 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;

            $domains = array_slice($domains, $offset, $size, true);
        }

        return array(
            'list'  => $domains,
            'count' => $count,
        );
    }
}