|
@@ -11,4 +11,42 @@ class LuticatePermissionsUsersBusiness extends LuBusiness {
|
11
|
11
|
{
|
12
|
12
|
return new LuticatePermissionsUsersDataAccess();
|
13
|
13
|
}
|
|
14
|
+
|
|
15
|
+ public static function add($user_id, $permission_name, $permission_value)
|
|
16
|
+ {
|
|
17
|
+ LuticateUsersBusiness::checkUserId($user_id);
|
|
18
|
+ LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
|
19
|
+ $perm = LuticatePermissionsUsersDataAccess::getByName($user_id, $permission_name);
|
|
20
|
+ if (is_null($perm)) {
|
|
21
|
+ $perm = new LuticatePermissionsUsersDbo();
|
|
22
|
+ $perm->setName($permission_name);
|
|
23
|
+ $perm->setValue($permission_value);
|
|
24
|
+ $perm->setUserId($user_id);
|
|
25
|
+ LuticatePermissionsUsersDataAccess::add($perm);
|
|
26
|
+ return true;
|
|
27
|
+ }
|
|
28
|
+ self::badInput("User permission already exists");
|
|
29
|
+ return false;
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+ public static function del($user_id, $permission_name)
|
|
33
|
+ {
|
|
34
|
+ LuticateUsersBusiness::checkUserId($user_id);
|
|
35
|
+ LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
|
36
|
+ LuticatePermissionsUsersDataAccess::delete($user_id, $permission_name);
|
|
37
|
+ return true;
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ public static function edit($user_id, $permission_name, $permission_value)
|
|
41
|
+ {
|
|
42
|
+ LuticateUsersBusiness::checkUserId($user_id);
|
|
43
|
+ LuticatePermissionsBusiness::checkPermissionName($permission_name);
|
|
44
|
+ $perm = LuticatePermissionsUsersDataAccess::getByName($user_id, $permission_name);
|
|
45
|
+ if (!is_null($perm)) {
|
|
46
|
+ LuticatePermissionsUsersDataAccess::edit($user_id, $permission_name, $permission_value);
|
|
47
|
+ return true;
|
|
48
|
+ }
|
|
49
|
+ self::badInput("Permission not found");
|
|
50
|
+ return false;
|
|
51
|
+ }
|
14
|
52
|
}
|