Allow switch user block to show only autocomplete field

joelstein - October 8, 2009 - 15:29
Project:Devel
Version:6.x-1.x-dev
Component:devel
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

On the "Switch user" block, I want the option to hide the list of users, and only show the autocomplete form. However, if "number of users to display in the list" is configured at 0, then the block doesn't appear at all.

I'm submitting a patch which displays the block when "number of users" is 0, so that the autocomplete form remains. If someone wants the block to disappear, disabling it is better and faster, since it avoids the unnecessary processing and database queries.

Additionally, I couldn't find any obvious reason to for the logic in devel_switch_user_list() to have its own function, so I merged it with the devel_block_switch_user() function. If that is a problem, I can roll another patch to maintain the two separate functions.

AttachmentSize
devel.module.patch4.64 KB

#1

joelstein - October 8, 2009 - 16:04
Version:6.x-1.9» 6.x-1.18
Status:active» needs review

Sorry, I realized that I tagged this with the wrong version. Also, I added a field description on the block configuration form to explain this new behavior.

AttachmentSize
devel.module.patch 5.01 KB

#2

salvis - October 24, 2009 - 16:26
Status:needs review» needs work

The separate devel_switch_user_list() function might be useful to a module like admin_menu. I don't see eliminating this function as an improvement.

Your patch should be against the -dev version, otherwise we can't apply it.

The patch is surprisingly big. I agree with you that the current behavior is not useful, but I'd expect your change to be only a few lines...

Remember that our focus is at least as much on D7 as on D6. We won't commit a patch to D6 and not to D7. If your patch were really short and sweet, you might find someone willing to port it to D7, but this is not likely for a big one like yours. Your best bet for getting this in is to provide two slim patches against both -dev versions.

#3

joelstein - October 28, 2009 - 14:35

Well, it looks big because I merged the two functions. But it's really quite simple. I'll resubmit a slimmer patch against dev. Thanks for the feedback.

#4

joelstein - October 28, 2009 - 15:15
Version:6.x-1.18» 6.x-1.x-dev
Status:needs work» needs review

Here's two slimmed-down patches.

AttachmentSize
devel.module-d6.patch 739 bytes
devel.module-d7.patch 867 bytes

#5

salvis - October 28, 2009 - 16:44

It still seems overly complex.

<?php
 
if (!empty($links) || user_access('switch users')) {
?>

should do the same thing, no?

I have some doubts whether theme('links', array()); is safe though... Anyone?

#6

joelstein - November 11, 2009 - 23:05

Okay, here are the two patches, both just one line long. Sending theme_links() a blank array is safe (have a look at http://api.drupal.org/api/function/theme_links -- if the array is empty, it returns a blank string). Is this satisfactory to get committed?

AttachmentSize
devel.module-d6.patch 206 bytes
devel.module-d7.patch 403 bytes

#7

joelstein - November 11, 2009 - 23:07

Hmm, somehow the d6 patch was messed up.

AttachmentSize
devel.module-d6.patch 375 bytes

#8

salvis - November 11, 2009 - 23:23
Status:needs review» reviewed & tested by the community

Yes, this looks good to me.

 
 

Drupal is a registered trademark of Dries Buytaert.