diff options
author | Udo Walter | 2017-12-21 19:34:28 +0100 |
---|---|---|
committer | Udo Walter | 2017-12-21 19:34:28 +0100 |
commit | 8b46da3853636a313543b8d9154d93054ed1193f (patch) | |
tree | 959490e1f4069dbf615ce78894b3d37e64ab8f2b /modules-available/permissionmanager/inc/permissiondbupdate.inc.php | |
parent | [permissionmanager] fixed small bug (diff) | |
download | slx-admin-8b46da3853636a313543b8d9154d93054ed1193f.tar.gz slx-admin-8b46da3853636a313543b8d9154d93054ed1193f.tar.xz slx-admin-8b46da3853636a313543b8d9154d93054ed1193f.zip |
[permissionmanager] removed openRoleEdior function;
changed searchFieldFunction() to use jQuery; fixed checkboxes in
roleeditor not selecting on a click on the label; added selected row
highlighting; disabled buttons if there are no users/roles selected;
made role badges in user/location tables clickable; added phpdoc
comments to most php functions;
Diffstat (limited to 'modules-available/permissionmanager/inc/permissiondbupdate.inc.php')
-rw-r--r-- | modules-available/permissionmanager/inc/permissiondbupdate.inc.php | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/modules-available/permissionmanager/inc/permissiondbupdate.inc.php b/modules-available/permissionmanager/inc/permissiondbupdate.inc.php index f144b35e..ffe5fac0 100644 --- a/modules-available/permissionmanager/inc/permissiondbupdate.inc.php +++ b/modules-available/permissionmanager/inc/permissiondbupdate.inc.php @@ -2,7 +2,12 @@ class PermissionDbUpdate { - // insert new user_x_role to database. "ignore" to ignore duplicate entry try + /** + * Insert all user/role combinations into the user_x_role table. + * + * @param array $users userids + * @param array $roles roleids + */ public static function addRoleToUser($users, $roles) { $query = "INSERT IGNORE INTO user_x_role (userid, roleid) VALUES (:userid, :roleid)"; foreach($users AS $userid) { @@ -12,24 +17,34 @@ class PermissionDbUpdate { } } - // remove user_x_role entry from database + /** + * Remove all user/role combinations from the user_x_role table. + * + * @param array $users userids + * @param array $roles roleids + */ public static function removeRoleFromUser($users, $roles) { $query = "DELETE FROM user_x_role WHERE userid IN (:users) AND roleid IN (:roles)"; Database::exec($query, array("users" => $users, "roles" => $roles)); } - // delete role, delete user_x_role relationships, delete role_x_location relationships, delete role_x_permission relationships + /** + * Delete role from the role table. + * + * @param string $roleid roleid + */ public static function deleteRole($roleid) { - $query = "DELETE FROM role WHERE roleid = :roleid"; - Database::exec($query, array("roleid" => $roleid)); - $query = "DELETE FROM user_x_role WHERE roleid = :roleid"; - Database::exec($query, array("roleid" => $roleid)); - $query = "DELETE FROM role_x_location WHERE roleid = :roleid"; - Database::exec($query, array("roleid" => $roleid)); - $query = "DELETE FROM role_x_permission WHERE roleid = :roleid"; - Database::exec($query, array("roleid" => $roleid)); + Database::exec("DELETE FROM role WHERE roleid = :roleid", array("roleid" => $roleid)); } + /** + * Save changes to a role or create a new one. + * + * @param string $rolename rolename + * @param array $locations array of locations + * @param array $permissions array of permissions + * @param string|null $roleid roleid or null if the role does not exist yet + */ public static function saveRole($rolename, $locations, $permissions, $roleid = NULL) { if ($roleid) { Database::exec("UPDATE role SET rolename = :rolename WHERE roleid = :roleid", |