User Management Batch Update Options should include assign and remove role
| Project: | Role Delegation |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
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
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.
#2
#3
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
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.
#5
#6
I tested the patch in #4. Works great!
Thanks Andrew.
#7
#8
Comment cleanups.