summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_user_types_actions.php
blob: b63957826a013cf2dd4a490501dd3b334671f613 (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
39
40
<?php

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

    public function user_types_list($get, $post)
    {
        $sql_result = $this->db->query("SELECT * FROM user_types");
        $user_types = array();

        while ($row = $this->db->fetch_assoc($sql_result)) {
            $user_types[$row['id']] = array();

            foreach ($row as $key => $value) {
                if ($key != "id") {
                    if ($key == "attributes") {
                        $user_types[$row['id']][$key] = json_decode(unserialize($value), true);
                    }
                    else {
                        $user_types[$row['id']][$key] = $value;
                    }
                }
            }
        }

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