Having used drupal for a while now, I've found the user search form quite limiting - from a support standpoint that is. Most of the time, users send email about issues to something like support@example.com and do not include their site user name. However, more often than not, the user's email is the same as within drupal. Addressing issues using /admin/user/search using only the user name as criteria does not get you to the user's record very fast.

Attached is a patch to the user_search function that leverages the 'administer users' access perm.

If there are those who feel this addition to the search result clouds the results, then you could consider an additional permission to extend the search. I figure creating a module for simply extending the search is overkill when email is such a common everyday piece of information. Plus, this does not expose the user search (by users with access via 'access user profiles') to private email information.

CommentFileSizeAuthor
#52 user_search_by_email_DRUPAL-5.15.patch2.82 KBdamien_vancouver
#52 user.module_drupal-5.15_with_admin_user_search_applied.txt114.3 KBdamien_vancouver
#49 user.module_drupal-5.14_with_admin_user_search_applied.txt114.3 KBdamien_vancouver
#49 user_search_by_email_DRUPAL-5.14.patch2.82 KBdamien_vancouver
#48 user.module_drupal-5.12_with_admin_user_search_applied.txt114.3 KBdamien_vancouver
#48 user_search_by_email_DRUPAL-5.12.patch2.82 KBdamien_vancouver
#43 user.module.drupal-5.11_with_admin_user_search_applied.txt114.3 KBdamien_vancouver
#43 user_search_by_email_DRUPAL-5.11.patch2.82 KBdamien_vancouver
#41 user_search_by_email_DRUPAL-5.10.patch2.82 KBdamien_vancouver
#41 user.module_drupal-5.10_with_admin_user_search_applied.txt113.36 KBdamien_vancouver
#38 user_search_by_email_DRUPAL-5.9.patch2.82 KBdamien_vancouver
#38 user.module_drupal-5.9_with_admin_user_search_applied.txt113.36 KBdamien_vancouver
#32 user.module_drupal5.7_with_admin_user_search_patch_applied.txt113.27 KBdamien_vancouver
#31 user.module_drupal5.6_with_admin_user_search_patch_applied.txt113.27 KBdamien_vancouver
#30 user.module_drupal5.5_with_admin_user_search_patch.txt113.19 KBdamien_vancouver
#29 user_search_by_email_DRUPAL-5.4.patch2.82 KBdamien_vancouver
#29 user.module_drupal5.4_with_admin_user_search_patch.txt113.19 KBdamien_vancouver
#28 user.module_0.txt112.49 KBdamien_vancouver
#27 user_search_by_email_DRUPAL-5.3_0.patch2.81 KBdamien_vancouver
#26 user_search_by_email_DRUPAL-5.3.patch2.8 KBdamien_vancouver
#25 user_search_by_email-DRUPAL-5-2.patch2.85 KBdamien_vancouver
#22 user_search_by_email-HEAD_7.patch2.81 KBgábor hojtsy
#21 user_search_by_email-HEAD_6.patch2.65 KBdamien_vancouver
#15 user_search_by_email-HEAD_5.patch2.83 KBdww
#13 user_search_by_email-HEAD_4_0.patch2.83 KBdww
#12 user_search_by_email-HEAD_4.patch2.72 KBdamien_vancouver
#11 user_search_by_email-HEAD_3.patch2.72 KBdamien_vancouver
#7 user_search_by_email-HEAD_2.patch2.63 KBdamien_vancouver
#6 user_search_by_email-HEAD_1.patch2.63 KBdamien_vancouver
#2 user_search_by_email-HEAD.patch1.73 KBdamien_vancouver
#1 user_search_0.patch1.41 KBdamien_vancouver
user_search.txt1.39 KBmattman

Comments

damien_vancouver’s picture

Status: Active » Needs review
StatusFileSize
new1.41 KB

I too agree this functionality is so essential that i cannot believe it is still not in core.

I will explain by outlining my scenario - perhaps it's not obvious how important a feature this is.

One of the drupal sites we manage has over 4000 users and uses organic groups heavily. We also use og2list to create a mailing list gateway to the groups.

Every time a group manager wants to add someone to organic groups, they are totally unable to find their username, because there is no way to look the user up by e-mail. Guessing the user's username is about the best chance they have. Indeed you can't even list the users and see a summary list of their emails in a column (this is perhaps security motivated and maybe a good thing - but you DO need to be able to search on e-mail). For a CMS like Drupal this should be (in my opinion) a clearly labelled and easy to find feature for any user searches. But it is not and it seems to be the main complaint of my user base is that it's impossible to do any system administration without an ability to find users.

Anyway, I was excited to find this patch, as before I was solving this problem with the ldap_adddressbook module, which is not ported to 5.x yet. (besides, that was a kludge, the users are already in drupal, it should be simple to search for them by username or email!)

I tried mattman's patch on Drupal 5.1 and found that it worked, but there was one missing } in the patch that caused a whitescreen when I applied it.

I have attached the fixed patch for 6.x (the filename at the top needed to be edited, and the missing } added right before return $find). I am going to make a separate Drupal issue post for 5.x as I believe this feature is important and should be available (even if in a patch form for now).

Please consider adding this functionality (or an enhanced version of it) to HEAD and/or DRUPAL-5! Thanks!!

damien_vancouver’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.73 KB

OK that last _0 patch still had problems.

I have recreated a proper patch against HEAD.

I have also created backports for DRUPAL-5 and DRUPAL 5.1 release which I will post as seperate issues and follow up with links to.

Here is the new HEAD patch, should be ready to go:

damien_vancouver’s picture

The Drupal 5.1 release version of this patch can be found here: http://drupal.org/node/146573.

The DRUPAL-5 version against the current Drupal 5 CVS branch can be found here: http://drupal.org/node/146575.

recidive’s picture

Your patch doesn't conform with Drupal's coding standards, it contains 'tabs' and wrong comments.

recidive’s picture

Status: Reviewed & tested by the community » Needs work

Needs work.

damien_vancouver’s picture

Status: Needs work » Needs review
StatusFileSize
new2.63 KB

Attached is n updated patch with tabs and comments removed. I also fixed the positioning of the else's in if statements. Hopefully it should confirm to the coding standards.

I realized that something should also be displayed in hook_help for admin/user/search if it will allow email searching. I modified the hook_help for admin/user/search so that it will display a slightly modified help text.

In my drupal 6 install, I do not see the user search anywhere - admin/user management just says List,Add and Edit?? Anyway hopefully this patch is closer now, sorry for marking it ready to be committed. Please have another look.

damien_vancouver’s picture

StatusFileSize
new2.63 KB

Oops, I just realized I took out the only girl's name in the list.. here it is again using webmaster@brenda.com in the email example.

damien_vancouver’s picture

I got my search to show up (didn't have search module enabled). The patch works great for me, and the proper instructions show up for me as administrator.

moshe weitzman’s picture

code looks good and this is definately useful functionality.

dww’s picture

Category: task » feature
Status: Needs review » Needs work

I haven't tested it, but visually the latest patch mostly looks good. My only objection is the webmaster@brenda.com part. It would be evil if Drupal core printed an example email address pointing to a potentially real domain (and webmaster). So, please change that to: brenda@example.com.

Otherwise, this would be nice. +1.

Thanks,
-Derek

damien_vancouver’s picture

Status: Needs work » Needs review
StatusFileSize
new2.72 KB

OK, I have updated it as suggested in #10 - the e-mail example is now: "brenda@example.com"

The attached is against current HEAD user.module v1.802.

D.

damien_vancouver’s picture

StatusFileSize
new2.72 KB

Found and fixed an extra space before the displayed e-mail address in a search result.

It was reading: username ( user@example.com)
Should be reading: username (user@example.com)

dww’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.83 KB

Re-rolled to fix 2 minor problems:
1) The spacing was wrong, so results were showing up like this: test( test@example.com)

2) We like patches rolled relative from the root of core, not all the way down inside an individual module's directory.

However, this is so minor, I'm just going to RTBC it, even thought it's my own patch. ;)

Thanks,
-Derek

dww’s picture

Status: Reviewed & tested by the community » Needs work

tee hee, whoops. didn't notice your followup, but thanks for catching your own bug. ;)

however, now that i look at it, i notice a minor code-style problem: we don't put a space between the . and a string literal when cat'ing strings.

dww’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.83 KB

like so.

damien_vancouver’s picture

OK thanks, I see.

So now what, can I commit it now that it's RTBC?

thanks,

D.

Frando’s picture

No, you can't commit anything to Drupal core yourself ;)
Only very few people have the privileges to commit patches to Drupal core (for the current development for Drupal 6 it's just three). See also http://drupal.org/node/10261
Now that the issue is marked "Ready to be commited", one of them will hopefully pick this one up soon and commit it.

damien_vancouver’s picture

ah OK - but it is done then! Great!!

Thanks everyone for your help on this! :)

D.

dww’s picture

but it is done then!

Ha, not yet. ;) It's only done once one of the core committers actually commits it to CVS and marks the issue "fixed". However, sometimes even when people like me think it's RTBC, a core committer will see it and decide it needs work for some reason we didn't think of... So, don't start celebrating just yet. ;)

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

The multiple if ($admin) uses and only very small part of code inbetween makes this hard to read IMHO. I would do an if (user_access('administer users')) {} else {} wrap around the code. There is only a while(){} to repeat in them anyway. Otherwise this looks simple and acceptable to me.

damien_vancouver’s picture

Status: Needs work » Needs review
StatusFileSize
new2.65 KB

I made those changes as suggested in #20 and it is much more readable this way.

updated patch against v1.804 attached. Tests OK for me.

D.

gábor hojtsy’s picture

Status: Needs review » Fixed
StatusFileSize
new2.81 KB

OK, reviewed the patch even more closely and noticed some issues:

- the $admin variable had no use, it did distract from the understandability of the code
- a comment on why it is only possible to search by email for admins was required
- I noticed that the menu item explicitly said that the page offers search by name only, modified that
- then immediately noticed that the menu item for this page is only ever allowed access, if the user already has "administer users" privileges, so doing the check in the help hook again, and having two help texts is completely pointless, that page will only display for users having the privilege already

After fixed these, the patch seemed to be RTBC, attached for reference :) So comitted.

damien_vancouver’s picture

Thanks for your help Gábor!

Anonymous’s picture

Status: Fixed » Closed (fixed)
damien_vancouver’s picture

StatusFileSize
new2.85 KB

Here is an updated backport of the final patch for Drupal 5.2.

damien_vancouver’s picture

Version: 6.x-dev » 5.3
StatusFileSize
new2.8 KB

Here is the backport for DRUPAL-5.3. It shoudl apply cleanly to the 5.3 user.module.

damien_vancouver’s picture

StatusFileSize
new2.81 KB

Whoops, that one had a small bug - here is the correct version for 5.3.

damien_vancouver’s picture

StatusFileSize
new112.49 KB

And as requested by lpkb, here is the user.module file for Drupal 5.3 with the patch applied (for people who aren't so good with patching).

Just remove the .txt extension, rename up your old modules/user/user.module to user.module.bak
and put this one in place as modules/user/user.module

damien_vancouver’s picture

Version: 5.3 » 5.4
StatusFileSize
new113.19 KB
new2.82 KB

Here is the Drupal 5.4 backport of the admin user search by email patch that is comitted to Drupal 6.

I have also attached the patched user.module (for those who don't like patching!)

To use that, rename your old user.module to user.module.drupal54.bak and save and rename the attached user.module_drupal5.4_with_admin_user_search_patch.txt to user.module.

damien_vancouver’s picture

Version: 5.4 » 5.5
StatusFileSize
new113.19 KB

the Drupal 5.4 patch from #29 will apply to Drupal 5.5 cleanly as well.

OR, use the attached Drupal 5.5 user.module with the patch applied. Just rename your modules/user.module and save this one in its place as user.module.

damien_vancouver’s picture

Version: 5.5 » 5.6
StatusFileSize
new113.27 KB

As with Drupal 5.5, the drupal 5.4 patch from #29 will apply to the latest Drupal 5.6 release cleanly.

For those patch-shy, I've attached the patched modules/user/user.module file for Drupal 5.6 to this comment - just rename the attached file to user.module and save it over the existing modules/user/user.module file from Drupal 5.6.

damien_vancouver’s picture

Version: 5.6 » 5.7
StatusFileSize
new113.27 KB

attached is the patched modules/user/user.module for Drupal 5.7.

If you'd rather patch, the patch from [#29] / drupal 5.4 still works.

introfini’s picture

Hi,

I tested it on 5.7, and is working.

introfini

jpsalter’s picture

I too can confirm it works w/ 5.7.

Thanks for a great patch.

ericinwisconsin’s picture

This definitely works with 5.7.

How about incorporating this into the core, guys? Quite frankly, I'm amazed that it's not there already.

damien tournoud’s picture

Version: 5.7 » 7.x-dev

Yeah, it is in core (both Drupal 6.x and the development version Drupal 7.x). Please reassign to 5.x and to "patch (to be ported)" if you want to submit a port for inclusion in the 5.x branch.

thomasmurphy’s picture

Will I need a seperate patch for 5.8?

damien_vancouver’s picture

Version: 7.x-dev » 5.x-dev
Assigned: Unassigned » damien_vancouver
Status: Closed (fixed) » Patch (to be ported)
StatusFileSize
new113.36 KB
new2.82 KB

Here is the updated/backported patch for Drupal 5.9, as well as the user module with the patch applied.

HOW TO INSTALL ADMIN USER SEARCH

1. Update your site to Drupal 5.9.
2. Download the user.module_drupal-5.9_with_admin_user_search_applied.txt from this post
3. Rename it to user.module and save it over top of your stock Drupal 5.9 user.module
4. test it by going to your site's admin/user/search page. The prompt should mention an e-mail (brenda@example.com) and you should be able to get matches back searching by email.

@Damien T. - I keep updating and releasing this patch each minor drupal version here, but since it's in core it would be useful to just get it in future releases.

Thus I've marked it as 5.x-dev and patch (to be ported) as you suggested. I've tested this version of the patch on 3 or 4 of my sites, but someone else who also uses it every version needs to confirm it is working as expected and then mark it "Reviewed and Tested by the Community" to get it further along to inclusion in forthcoming maintenance releases.

If that never quite happens, then meet back here next minor version ;)

D.

moshe weitzman’s picture

Minor UI gripe ... I was expecting this in Admin => User => User and not on search page.

thomasmurphy’s picture

Hey, is there a 5.10 updated user.module on its way? Thanks for all the others.

damien_vancouver’s picture

The old 5.9 patch works for Drupal 5.10, but here is an updated patch and user.module. Follow the installation instructions from #38.

thomasmurphy’s picture

thanks

damien_vancouver’s picture

Drupal 5.11 patch and updated user.module for admin/user/search by e-mail address are attached.
See http://drupal.org/node/113983#comment-939950 (#38 on this thread) for install instructions.

laryn’s picture

Thanks for continuing to update these while we wait for it to be included... I appreciate it!

pasqualle’s picture

I don't think it will be ever included in D5, simply because new features are not added to stable versions..

damien_vancouver’s picture

@Pasqualle, yeah that's the situation as I understand it - this patch made it into HEAD in time for inclusion into drupal 6 I think.

I will keep on making new versions and posting them here as new minors of D5 come out, at least until I stop using it Drupal 5 everywhere (and with some coaxing by email, probably even after that).

What is the correct status for this situation? Fixed? By Design?

pasqualle’s picture

rolling :)

I don't think we have a good status for this case..

damien_vancouver’s picture

Here is the Drupal 5.12 patch file and pre-patched user.module.

See http://drupal.org/node/113983#comment-939950 (#38 on this thread) for the install instructions.

damien_vancouver’s picture

here is the Drupal 5.14 patch for administrative user search by email address.

a pre-patched modules/user/user.module attached as well.

alexandreracine’s picture

damien_vancouver’s picture

This admin user search patch is already in Drupal 6 and 7 (committed in #22 above),
see further explanation here: http://drupal.org/node/299784#comment-1189706.

damien_vancouver’s picture

Patch and user.module for Drupal 5.15.

See http://drupal.org/node/113983#comment-939950 for install instructions.

dww’s picture

Status: Patch (to be ported) » Closed (fixed)

@damien_vancouver: Can you please find another place to keep posting these backport patches? You keep bumping this issue for those of us unlucky enough to have commented previously. ;) Thanks.

laryn’s picture

If you start posting elsewhere please let me know where. We plan to upgrade to d6 within a few months but until then these are greatly appreciated. Thanks again.

damien_vancouver’s picture

Next version I will make a new thread and post it here... till then let's try and keep this issue quiet :) I am stuck on 5t though so I will keep posting these for the forseeable future, just in another spot.

If anyone has any suggestions as to where the best spot would be (that wouldn't involve it bumping lots of people) please let me know. I've never found a suitable "backports for 5" issues collection but there definitely should be one (stuff like this and the performance backports undertaken by the infrastructure team when drupal.org was really sucking last year... sadly these were never organized in one spot).

Maybe there should be a groups.drupal.org group for this? I dunno, but anyway if anyone has any ideas please private message me through the contact form rather than post on the issue.

Sorry to everyone we keep bothering! :D

pasqualle’s picture

summary:
1. The patch can't be committed because the new feature won't be included in the stable version.
2. As I see it is not possible to create a new module with the same functionality.
3. If the patch is useful for people then it should be available.
4. We encourage all developers and users to make Drupal better.

I believe you have all the rights to use the d.o infrastructure for the patch, and I think the issue queue is a good place for it. Just create a new issue with a clear description that the patch will not be committed. Provide a link between the new issue and old issue, so people could find it. Set the status to "patch (to be ported)", and you can even add a new tag, something like "Backported feature", so you can create a collection of issues with that one tag.

I do not use the patch as I don't have a D5 site, but I would like to say thanks for your contribution Damien.

chriscohen’s picture

Thank you very much for all the effort on this patch. It worked fine for me on Drupal 5.10 and it is very useful.