Download & Extend

had a problem with permissions_revoke_permissions

Project:Permissions API
Version:6.x-2.3
Component:Code
Category:bug report
Priority:normal
Assigned:ebeyrent
Status:closed (fixed)

Issue Summary

there were two problems with permissions_revoke_permissions() here's a patch.

AttachmentSize
permissions_api.patch7.89 KB

Comments

#1

Status:active» closed (fixed)

Thank you for the bug report - these issues were fixed already in v2.2 and 2.3 of the module. Please download the latest stable release of the module and let me know if you encounter any issues!

#2

Ok , so I downloaded 2.3 and I still have a problem:
If you try to revoke permissions for a role and $new_permissions is all of the permissions for that role it revokes all but one.

function permissions_revoke_permissions($role_name, $new_permissions) {
  $permissions = array();
  $updated_permissions = '';
  $role = permissions_get_role($role_name);
  if (is_array($new_permissions)) {
    $permissions = permissions_get_permissions_for_role($role->name);
    if (count($permissions) > 0) {
      // Unset the permission from the array
      foreach ($new_permissions as $permission) {
        $index = array_search($permission, $permissions);
-        if ($index) {
+        if ($index >=0) {
          unset($permissions[$index]);
        }
      }

      // rebuild the permission string
      $updated_permissions = join(', ', $permissions);
      db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $updated_permissions, $role->rid);
    }
  }
  return;
}

Also, it seems that cvs is out of date.

#3

Status:closed (fixed)» active

#4

You're absolutely correct - good catch. I made the change that you documented in the permissions_revoke_permissions() function as well as the permissions_revoke_all_permissions_by_module() function.

#5

Version:6.x-2.x-dev» 6.x-2.3
Assigned to:Anonymous» ebeyrent

#6

Status:active» fixed

#7

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here