|
@@ -12,46 +12,53 @@ class LuticatePermissionsGroupsBusiness extends LuBusiness {
|
12
|
12
|
return new LuticatePermissionsGroupsDataAccess();
|
13
|
13
|
}
|
14
|
14
|
|
15
|
|
- public static function get($group_id, $permission_name)
|
|
15
|
+ public static function checkPermissionGroupName($group_id, $permission_name)
|
16
|
16
|
{
|
|
17
|
+ LuticateGroupsBusiness::checkGroupId($group_id);
|
|
18
|
+ LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
17
|
19
|
return LuticatePermissionsGroupsDataAccess::getByName($group_id, $permission_name);
|
18
|
20
|
}
|
19
|
21
|
|
20
|
|
- public static function add($group_id, $permission_name, $permission_value)
|
|
22
|
+ public static function get($group_id, $permission_name)
|
21
|
23
|
{
|
22
|
|
- LuticateGroupsBusiness::checkGroupId($group_id);
|
23
|
|
- LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
24
|
|
- $perm = LuticatePermissionsGroupsDataAccess::getByName($group_id, $permission_name);
|
|
24
|
+ $perm = self::checkPermissionGroupName($group_id, $permission_name);
|
25
|
25
|
if (is_null($perm)) {
|
26
|
26
|
$perm = new LuticatePermissionsGroupsDbo();
|
27
|
27
|
$perm->setName($permission_name);
|
28
|
|
- $perm->setValue($permission_value);
|
|
28
|
+ $perm->setValue(null);
|
29
|
29
|
$perm->setGroupId($group_id);
|
30
|
|
- LuticatePermissionsGroupsDataAccess::add($perm);
|
31
|
|
- return true;
|
32
|
30
|
}
|
33
|
|
- self::badInput("Group permission already exists");
|
34
|
|
- return false;
|
|
31
|
+ return $perm;
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ public static function add($group_id, $permission_name, $permission_value)
|
|
35
|
+ {
|
|
36
|
+ $perm = self::checkPermissionGroupName($group_id, $permission_name);
|
|
37
|
+ if (!is_null($perm)) {
|
|
38
|
+ self::badInput("Group permission already exists");
|
|
39
|
+ }
|
|
40
|
+ $perm = new LuticatePermissionsGroupsDbo();
|
|
41
|
+ $perm->setName($permission_name);
|
|
42
|
+ $perm->setValue($permission_value);
|
|
43
|
+ $perm->setGroupId($group_id);
|
|
44
|
+ LuticatePermissionsGroupsDataAccess::add($perm);
|
|
45
|
+ return true;
|
35
|
46
|
}
|
36
|
47
|
|
37
|
48
|
public static function del($group_id, $permission_name)
|
38
|
49
|
{
|
39
|
|
- LuticateGroupsBusiness::checkGroupId($group_id);
|
40
|
|
- LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
|
50
|
+ self::checkPermissionGroupName($group_id, $permission_name);
|
41
|
51
|
LuticatePermissionsGroupsDataAccess::delete($group_id, $permission_name);
|
42
|
52
|
return true;
|
43
|
53
|
}
|
44
|
54
|
|
45
|
55
|
public static function edit($group_id, $permission_name, $permission_value)
|
46
|
56
|
{
|
47
|
|
- LuticateGroupsBusiness::checkGroupId($group_id);
|
48
|
|
- LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
49
|
|
- $perm = LuticatePermissionsGroupsDataAccess::getByName($group_id, $permission_name);
|
50
|
|
- if (!is_null($perm)) {
|
51
|
|
- LuticatePermissionsGroupsDataAccess::edit($group_id, $permission_name, $permission_value);
|
52
|
|
- return true;
|
|
57
|
+ $perm = self::checkPermissionGroupName($group_id, $permission_name);
|
|
58
|
+ if (is_null($perm)) {
|
|
59
|
+ self::badInput("Permission not found");
|
53
|
60
|
}
|
54
|
|
- self::badInput("Permission not found");
|
55
|
|
- return false;
|
|
61
|
+ LuticatePermissionsGroupsDataAccess::edit($group_id, $permission_name, $permission_value);
|
|
62
|
+ return true;
|
56
|
63
|
}
|
57
|
64
|
}
|