Browse Source

get all permissions for a group

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
4ff4a64920

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

@@ -107,6 +107,8 @@ class LuticateBusiness
107 107
 
108 108
         $route->get("$prefix/permissions/group/$group_id/$permission_name", "${ns}LuticatePermissionsGroupsController",
109 109
             "get", LuticatePermissions::PERM_GROUP_GET);
110
+        $route->get("$prefix/permissions/group/$group_id", "${ns}LuticatePermissionsGroupsController",
111
+            "getAllByGroup", LuticatePermissions::PERM_GROUP_GET);
110 112
         $route->post("$prefix/permissions/group/$group_id/add/$permission_name/$permission_value",
111 113
             "${ns}LuticatePermissionsGroupsController", "add", array(LuticatePermissions::PERM_GROUP_ADD,
112 114
                 LuticatePermissions::PERM_GROUP_GET));

+ 15
- 0
src/Auth/Business/LuticatePermissionsGroupsBusiness.php View File

@@ -2,9 +2,11 @@
2 2
 
3 3
 namespace Luticate\Auth\Business;
4 4
 
5
+use Luticate\Auth\DBO\LuticatePermissionsDbo;
5 6
 use Luticate\Utils\LuBusiness;
6 7
 use Luticate\Auth\DataAccess\LuticatePermissionsGroupsDataAccess;
7 8
 use Luticate\Auth\DBO\LuticatePermissionsGroupsDbo;
9
+use Luticate\Utils\LuMultipleDbo;
8 10
 
9 11
 class LuticatePermissionsGroupsBusiness extends LuBusiness {
10 12
     protected static function getDataAccess()
@@ -19,6 +21,19 @@ class LuticatePermissionsGroupsBusiness extends LuBusiness {
19 21
         return LuticatePermissionsGroupsDataAccess::getByName($group_id, $permission_name);
20 22
     }
21 23
 
24
+    public static function getAllByGroup($group_id, $page = 0, $perPage = PHP_INT_MAX)
25
+    {
26
+        $values = LuticatePermissionsGroupsDataAccess::getAllByGroup($group_id, $page, $perPage);
27
+        $dbos = [];
28
+        foreach ($values->getData() as $value) {
29
+            $dbo = new LuticatePermissionsDbo();
30
+            $dbo->setValue($value->getValue());
31
+            $dbo->setName($value->getName());
32
+            $dbos[] = $dbo;
33
+        }
34
+        return new LuMultipleDbo($values->getCount(), $dbos);
35
+    }
36
+
22 37
     public static function get($group_id, $permission_name)
23 38
     {
24 39
         $perm = self::checkPermissionGroupName($group_id, $permission_name);

+ 12
- 0
src/Auth/Controller/LuticatePermissionsGroupsController.php View File

@@ -12,6 +12,18 @@ class LuticatePermissionsGroupsController extends LuController {
12 12
         return new LuticatePermissionsGroupsBusiness();
13 13
     }
14 14
 
15
+    /**
16
+     * Get all permissions for a group
17
+     * @param $group_id int The group id
18
+     * @param int $page The page number, 0 based
19
+     * @param int $perPage The number of items per page
20
+     * @return \Luticate\Utils\LuMultipleDbo
21
+     */
22
+    public function getAllByGroup($group_id, $page = 0, $perPage = PHP_INT_MAX)
23
+    {
24
+        return LuticatePermissionsGroupsBusiness::getAllByGroup($group_id, $page, $perPage);
25
+    }
26
+
15 27
     /**
16 28
      * Get a permission group
17 29
      * @param $group_id int The group id

+ 5
- 0
src/Auth/DataAccess/LuticatePermissionsGroupsDataAccess.php View File

@@ -17,6 +17,11 @@ class LuticatePermissionsGroupsDataAccess extends LuDataAccess {
17 17
         return LuticatePermissionsGroups::where("name", "=", $permission_name)->where("group_id", "=", $group_id)->first();
18 18
     }
19 19
 
20
+    public static function getAllByGroup($group_id, $page = 0, $perPage = PHP_INT_MAX)
21
+    {
22
+        return self::getMultiple(array(array('group_id', '=', $group_id)), array(array("name", "ASC")), $page, $perPage);
23
+    }
24
+
20 25
     public static function getByName($group_id, $permission_name)
21 26
     {
22 27
         $perm = self::getModelByName($group_id, $permission_name);

Loading…
Cancel
Save