User Management Batch Update Options should include assign and remove role

shark - October 8, 2009 - 07:05
Project:Role Delegation
Version:6.x-1.2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

On a default Drupal install, users with 'administer permissions' and 'administer users' permissions can go to Administer » User management (/admin/user/user), select multiple users, and then either add or remove roles by using the "Update options" drop down and selecting a role under "Add a role to the selected users" or "Remove a role from the selected users".

However, with Role Delegation this is not possible. Instead, the individual users accounts have to be edited one at a time (on the user edit pages /user/[uid]/edit).

The RoleAssign module is able to implement this functionality, so I assume it must be possible for a module to do. Also, since Role Delegation claims to supersede RoleAssign, implementing this functionality is important in order for that claim to remain true.

I'm happy to provide more info or test patches if needed. Thanks!

#1

Andrew Schulman - October 12, 2009 - 09:13

shark, I agree that this is an essential feature.

I'm attaching a patch that I believe implements this. Please review and test. After applying the patch, be sure to clear your Drupal cache before going to admin/user/user to see the new batch operations.

Note to role_delegation maintainer(s): I borrowed most of role_delegation_user_operations() from user_user_operations() in user.module.

AttachmentSize
role_delegation_batch_update.patch 2.09 KB

#2

Andrew Schulman - October 10, 2009 - 20:55
Status:active» needs review

#3

Andrew Schulman - October 10, 2009 - 21:17
Status:needs review» needs work

Hm. Although this works, it causes the user module to emit a 'Detected malicious attempt to alter protected user fields' warning in the log. I'll look into this.

#4

Andrew Schulman - October 11, 2009 - 01:07

OK, here's a revised patch that fixes the log warnings. I had to change the operation names from e.g. add_role to role_delegation_add_role, so that user_user_operations() wouldn't worry about the permissions. Please test.

AttachmentSize
role_delegation_batch_update-2.patch 2.36 KB

#5

Andrew Schulman - October 10, 2009 - 22:01
Status:needs work» needs review

#6

shark - October 17, 2009 - 22:39

I tested the patch in #4. Works great!

Thanks Andrew.

#7

Andrew Schulman - October 18, 2009 - 07:24
Status:needs review» reviewed & tested by the community

#8

Andrew Schulman - October 18, 2009 - 22:30

Comment cleanups.

AttachmentSize
role_delegation_batch_update.patch 2.33 KB
 
 

Drupal is a registered trademark of Dries Buytaert.