Browse Source

fixed get all; user get

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
8e5ab5aae0

+ 2
- 2
src/Auth/Business/LuticateBusiness.php View File

55
 
55
 
56
         $route->post("$prefix/users/login", "${ns}LuticateUsersController", "login");
56
         $route->post("$prefix/users/login", "${ns}LuticateUsersController", "login");
57
         $route->post("$prefix/users/logout", "${ns}LuticateUsersController", "logout");
57
         $route->post("$prefix/users/logout", "${ns}LuticateUsersController", "logout");
58
-        $route->get("$prefix/users/$user_id", "${ns}LuticateUsersController", "getById", LuticatePermissions::USER_GET);
59
-        $route->get("$prefix/users", "${ns}LuticateUsersController", "getAll", LuticatePermissions::USER_GET);
58
+        $route->get("$prefix/users/$user_id", "${ns}LuticateUsersController", "getLightById", LuticatePermissions::USER_GET);
59
+        $route->get("$prefix/users", "${ns}LuticateUsersController", "getAllLight", LuticatePermissions::USER_GET);
60
         $route->post("$prefix/users/add", "${ns}LuticateUsersController", "add",
60
         $route->post("$prefix/users/add", "${ns}LuticateUsersController", "add",
61
             array(LuticatePermissions::USER_ADD, LuticatePermissions::USER_GET));
61
             array(LuticatePermissions::USER_ADD, LuticatePermissions::USER_GET));
62
         $route->post("$prefix/users/$user_id/del", "${ns}LuticateUsersController", "del",
62
         $route->post("$prefix/users/$user_id/del", "${ns}LuticateUsersController", "del",

+ 19
- 0
src/Auth/Business/LuticateUsersBusiness.php View File

100
         return true;
100
         return true;
101
     }
101
     }
102
 
102
 
103
+    public static function getAllLight($page = 0, $perPage = PHP_INT_MAX)
104
+    {
105
+        $users = self::getAll($page, $perPage);
106
+        $usersLight = array();
107
+        foreach ($users as $user) {
108
+            $usersLight[] = LuticateUsersLightDbo::fromUserDbo($user);
109
+        }
110
+        return $usersLight;
111
+    }
112
+
113
+    public static function getLightById($user_id)
114
+    {
115
+        $user = self::getById($user_id);
116
+        if (is_null($user)) {
117
+            self::notFound(self::getResourceName() . " not found");
118
+        }
119
+        return LuticateUsersLightDbo::fromUserDbo($user);
120
+    }
121
+
103
     public static function add($username, $email, $password)
122
     public static function add($username, $email, $password)
104
     {
123
     {
105
         $hash = self::hashPassword($password);
124
         $hash = self::hashPassword($password);

+ 11
- 0
src/Auth/Controller/LuticateGroupsController.php View File

22
         return LuticateGroupsBusiness::getById($group_id);
22
         return LuticateGroupsBusiness::getById($group_id);
23
     }
23
     }
24
 
24
 
25
+    /**
26
+     * Get all groups
27
+     * @param int $page The page number, 0 based
28
+     * @param int $perPage The number of items per page
29
+     * @return \Luticate\Utils\LuMultipleDbo
30
+     */
31
+    public function getAll($page = 0, $perPage = PHP_INT_MAX)
32
+    {
33
+        return LuticateGroupsBusiness::getAll($page, $perPage);
34
+    }
35
+
25
     /**
36
     /**
26
      * Add a new group
37
      * Add a new group
27
      * @param $group_name string The group name
38
      * @param $group_name string The group name

+ 13
- 2
src/Auth/Controller/LuticateUsersController.php View File

38
      * @param $user_id int The user id
38
      * @param $user_id int The user id
39
      * @return \Luticate\Utils\LuDbo
39
      * @return \Luticate\Utils\LuDbo
40
      */
40
      */
41
-    public function getById($user_id)
41
+    public function getLightById($user_id)
42
     {
42
     {
43
-        return LuticateUsersBusiness::getById($user_id);
43
+        return LuticateUsersBusiness::getLightById($user_id);
44
+    }
45
+
46
+    /**
47
+     * Get all users
48
+     * @param int $page The page number, 0 based
49
+     * @param int $perPage The number of items per page
50
+     * @return array
51
+     */
52
+    public function getAllLight($page = 0, $perPage = PHP_INT_MAX)
53
+    {
54
+        return LuticateUsersBusiness::getAllLight($page, $perPage);
44
     }
55
     }
45
 
56
 
46
     /**
57
     /**

Loading…
Cancel
Save