[drupal-devel] [feature] Patch To Add User Profile Search

jjeff drupal-devel at drupal.org
Sat Aug 6 22:50:26 UTC 2005


Issue status update for 
http://drupal.org/node/28325
Post a follow up: 
http://drupal.org/project/comments/add/28325

 Project:      Drupal
 Version:      cvs
 Component:    profile.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  jjeff
 Updated by:   jjeff
 Status:       patch (code needs review)

Moshe, are you suggesting some sort of hook that modules would/should
implement in order to have their contributions searchable? Say for
instance:



<?php
hook_user($op, $blah, $blah){
  switch ($op) {
    case 'search':
      // return an array with SQL additions to user search
       $array = array('joins' => array('my_table')), 'columns'
=> array('column1' , 'column2'));
       // array of returned 'joins' will be impleded with "LEFT
JOIN"
       // array of returned 'columns' will be imploded with ', '
       /* end result looks something like
        "SELECT * FROM {users} u LEFT JOIN {my_table} x ON
u.uid = x.uid WHERE (u.username LIKE '%%s%') OR (x.column1 LIKE '%%s%')
OR (x.column2 LIKE '%%s%')";
        */
    return $array;
    case 'search results':
      // return rendering for search results??
      // does 'view' work for this?
?>




I don't really think that there should be separate searches for "user"
and "profile", but I'm having a hard time coming up with a good way of
creating a SQL call that doesn't make the server cough and sputter...
Like for instance, I don't think that all of those ORs above are going
to work very efficiently.


Anyone know of a good way to incorporate the SQL stuff in my patch into
the SQL for the user search? Is there a way to search for the same thing
accross several columns? That would at least unify the searching for
user.module and profile.module. (Why are these separate modules
anyway?)


Then  (if this seems like the right way to go) we can tackle some kind
of an additional case in the user_hook to handle injections into the
search.


As always, comments are appreciated!


-Jeff




jjeff



Previous comments:
------------------------------------------------------------------------

Sat, 06 Aug 2005 02:49:19 +0000 : jjeff

Attachment: http://drupal.org/files/issues/profilesearch.patch (1.88 KB)

Here's a patch that adds a search function for user profiles.


Users with "access user profiles" privileges can search all public
profile fields, while users with 'administer users' privileges can
search both private and public profile fields.


Search results display username (as a link) along with a snippet of the
user's profile.


-Jeff Robbins




------------------------------------------------------------------------

Sat, 06 Aug 2005 03:16:25 +0000 : moshe weitzman

profile.module is only 1 component of the profile page. other modules
plug in using hook_user, and i'd like for those same modules to
participate in profile search.


this patch is useful still, but i'm hoping we can do better.







More information about the drupal-devel mailing list