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

CommentFileSizeAuthor
permissions_api.patch7.89 KBtwistor

Comments

ebeyrent’s picture

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!

twistor’s picture

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.

twistor’s picture

Status: Closed (fixed) » Active
ebeyrent’s picture

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.

ebeyrent’s picture

Version: 6.x-2.x-dev » 6.x-2.3
Assigned: Unassigned » ebeyrent
ebeyrent’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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