function merci_permissions_revoke_permissions in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6
Same name and namespace in other branches
- 6.2 modules/merci_permissions/merci_permissions.module \merci_permissions_revoke_permissions()
Helper function to revoke permissions from a role.
1 call to merci_permissions_revoke_permissions()
- merci_permissions_settings_form_submit in modules/
merci_permissions/ merci_permissions.module
File
- modules/
merci_permissions/ merci_permissions.module, line 284 - Provides functions for resetting permissions on the permission page.
Code
function merci_permissions_revoke_permissions($role_name, $new_permissions) {
$permissions = array();
$updated_permissions = '';
$role = merci_permissions_get_role($role_name);
if (is_array($new_permissions)) {
$new_perms = array();
$permissions = merci_permissions_get_permissions_for_role($role->name);
foreach ($permissions as $perm) {
if (!in_array($perm, $new_permissions)) {
$new_perms[] = $perm;
}
}
// rebuild the permission string
$updated_permissions = join(', ', $new_perms);
db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $updated_permissions, $role->rid);
}
return;
}