Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
attached patch adds mass editing capabilities to admin/user, similar to those at admin/node. i'm particularly fond of the mass role editing feature. :) not only does it allow you to edit multiple user's roles at the same time, but the dropdowns also give you a nice overview of who has what roles.
the mass operations dropdown is generated using the same logic as found in this patch, so other modules can also add their own mass editing operations to this form.
Comment | File | Size | Author |
---|---|---|---|
#22 | useradmin_9.patch | 11.07 KB | hunmonk |
#19 | useradmin_8.patch | 11.39 KB | hunmonk |
#17 | useradmin_7.patch | 11.35 KB | hunmonk |
#16 | useradmin_6.patch | 11.35 KB | hunmonk |
#13 | useradmin_5.patch | 11.7 KB | hunmonk |
Comments
Comment #1
hunmonk CreditAttribution: hunmonk commentedoh, and of course a nice demo site here:
http://useradmin.xcarnated.com/
Comment #2
MichelleAwesome! I run a site that lets anyone join but club members get a special role. This would make it much easier to see at a glance if I have everyone on the right role and correct any ones that aren't.
Michelle
Comment #3
hunmonk CreditAttribution: hunmonk commentedsome touchups to the patch. i changed the markings for roles that a user already has to a leading asterisk--seems easier to read to me. also added a 'Select/View' option to the dropdowns, as it seems to make the interface come together a little better, and allowed me to get rid of the conditional display code for the roles column.
Comment #4
eaton CreditAttribution: eaton commentedA major +1 for this functionality. Dealing with users in batches is a real pain, and role-adding is just as bad.
Haven't had a chance to apply the patch yet but I've used it on the test site. Will comment further when I am able to apply it.
Comment #5
hunmonk CreditAttribution: hunmonk commentedok, i've revamped the approach for roles, and i'm much happier with the result. roles column for users is now a collapsible fieldset which lists their current roles--this allows for a quick look at that detail w/o clogging the table with a constant display, plus all those dropdowns in the table were a bit ugly and confusing.
i moved the mass adding/deleting of roles straight to the update dropdown inside of optgroups, which seems more intuitive to me--just select the role to mass add/delete, check the users it applies to, and click update.
while this version loses the ability to mass add/delete different roles for different users at the same time, i don't think it's a big loss compared to how much cleaner and more intuitive the interface is now.
you can check out the upgrade here: http://useradmin.xcarnated.com/
Comment #6
hunmonk CreditAttribution: hunmonk commentedstupid me--not using theme_item_list where i should... :)
attached patch corrects this.
demo site: http://useradmin.xcarnated.com/
Comment #7
hunmonk CreditAttribution: hunmonk commentedlooks like a cache_clear_all was added to the admin/node submit function. since this function basically mirrors that, i figured i should throw that in here as well...
demo site: http://useradmin.xcarnated.com/
Comment #8
jivyb CreditAttribution: jivyb commentedI might have missed it on the demo, but I'd love to see an option to check all or uncheck all. I think the content admin page really needs this too...(sorry I know that is irrelevant here:)
Comment #9
hunmonk CreditAttribution: hunmonk commented@jivyb: would be nice, but out of scope for this patch, i think.
Comment #10
hunmonk CreditAttribution: hunmonk commentedsomewhere along the way i broke the updates for blocking and unblocking users--i'll attend to that shortly. also, after some discussion on irc, i'm persuaded to make some changes in the roles column display. the consensus seemed to be that if collapsible form groups are going to be used:
i'll play with those ideas tonight and get something posted which addresses those points.
Comment #11
hunmonk CreditAttribution: hunmonk commentedok, latest fixes to address the issues in the post above. all role rows are wrapped in collapsible fieldsets now, which gives a lot more visual consistency. for convenience, any users w/ 2 or less roles have the fieldset open so the roles can be viewed.
demo site: http://useradmin.xcarnated.com/
Comment #12
Dries CreditAttribution: Dries commentedCool feature but the fieldset looks really,really weird (please take it out, if the user filtering patch in is available, it shouldn't really matter). I'm traveling so I don't have time to review the code.
Comment #13
hunmonk CreditAttribution: hunmonk commentedattached patch removes the collapsible fieldsets from around the role column. i also removed the auth user from the roles listing--seems wasteful as every user has the role.
Comment #14
Dries CreditAttribution: Dries commentedCode looks good, functionality is great. Your test site is down though.
The only thing that looks a little bit weird is:
Is this proper use of the forms API?
Instead of writing:
write:
Comment #15
hunmonk CreditAttribution: hunmonk commentedThanks :) sorry about the test site--i'm out of town, the server is down, and won't be able to get it back up until later tonight.
this is the exact same implementation that admin/node uses, and i'm not really sure there's a better way to do it. the problem is that since it's a delete op, there's a confirmation screen, which kind of makes this page a two-stage form for deletions only. it doesn't really work very well to put the delete stuff in the _submit function, as you can't call another drupal_get_form while you're in the middle of executing another one... :) i'm open for suggestions for a better implementation...
attached patch corrects this.
Comment #16
hunmonk CreditAttribution: hunmonk commented...and the patch... :)
Comment #17
hunmonk CreditAttribution: hunmonk commentedbroken by the admin patch. updated patch attached. apologies for the test site not being up. i'll get that remedied shortly...
Comment #18
Dries CreditAttribution: Dries commentedPlease spit the user_operation callbacks in separate functions and document them properly (cfr. node operations). Thanks.
Comment #19
hunmonk CreditAttribution: hunmonk commentedok, broke out the mass ops into seperate functions, and properly doc'd. got rid of the call back arg stuff in the submit function. also fixed some bad paths in the delete confirm form b/c of the admin patch. i think she's ready to go!
test site is working again as well: http://useradmin.xcarnated.com/
Comment #20
chx CreditAttribution: chx commentedFor some reason, sorting on test site is by uid and not name though from teh code it looks OK.
array_diff($edit['accounts'], array(0));
isn't this a baroque way of saying
array_filter($edit['accounts'])
?form_set_error('', t('Please select some users to perform the delete operation.')); we sure that there is no better way to this? looks a very little bit hackish.
db_query('INSERT INTO {users_roles} VALUES(
there missing a space.these are just small things. nice job.
Comment #21
hunmonk CreditAttribution: hunmonk commented@chx: thanks for these. i'm busy today and tomorrow, but will attend to the patch the next day.
Comment #22
hunmonk CreditAttribution: hunmonk commented@chx: ok, all of your concerns have been addressed.
the sorting problem had to do w/ the fact that i wasn't including the data key in the $header array during the form building function, since i thought it wasn't really needed until the theming function. however, the tablesorting code does in fact need that key in order to process the sorting request. given the fact that sometimes the form building code and theming code are in different functions now, we might want to examine the tablesort code and streamline it for these cases--it seems wasteful to me to have to include the entire $header array in both the form building and form theming functions. for now, though, it does seem like the correct approach.
i decided to get rid of that whole optional message thing in the validation code--it seems like overkill to me. now if no users are selected, you simply get a "No users selected" warning message. btw, that dual message approach was copied from the node admin code, so we might want to clean that up as well. :)
updated patch attached.
test site: http://useradmin.xcarnated.com/
Comment #23
hunmonk CreditAttribution: hunmonk commentedComment #24
chx CreditAttribution: chx commentedThe test site seems working. I found no glaring code errors.
Comment #25
drummCommitted to HEAD.
Comment #26
(not verified) CreditAttribution: commented