Closed (fixed)
Project:
Privatemsg
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
18 Mar 2011 at 10:13 UTC
Updated:
7 Apr 2011 at 13:02 UTC
Jump to comment: Most recent file
First of all, great module. Reviewing the code i got alot of ideas on how to refactor my own modules.
To the issue.
I might be going crazy here but in the api.php file (drupal 7 version)
function hook_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) {
global $user;
// Extend the query that searches for usernames
// $fragments is explained in the api documentation in detail
// The query is already set up, it's searching for usernames which start with
// $search and are not $names (may be empty)
// the main table is {user} a
// for example, add a join on a table where the user connections are stored
// and specify that only users connected with the current user should be
// loaded.
$fragments['inner_join'] = 'INNER JOIN {my_table} m ON (m.user1 = u.uid AND m.user2 = %d)';
$fragments['query_args'][] = $user->uid;
}
Well that sounded fantastic, exactly what i need. So I tried it in my module. Could never get it to work, put a die() in there, and it's not been runned. So I started to look for the drupal_alter(privatemsg_sql_autocomplete) and could not found it anywhere in the source. Am i doing it wrong? Feel free to punch me in the face (prefferably virtually, as i like my face)
Same for the non dev-version btw.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | fix_outdated_query_documentation2.patch | 11.51 KB | berdir |
| #4 | fix_outdated_query_documentation.patch | 11.48 KB | berdir |
Comments
Comment #1
Cristobal Wetzig commentedComment #2
berdirUhm, erm... yeah...
Unfortunately, this is the D6 documentation and it hasn't been updated yet.
In Drupal 7, we switched to using SelectQuery for this.
This basically means that you can now implement hook_query_privatemsg_autocomplete_alter($query) instead. See http://drupal.org/node/310075 for more information on how to change the query.
Comment #3
Cristobal Wetzig commentedCheers for the fast reply, and for the suggestion, and the link.
Comment #4
berdirAttaching a first patch, will trigger an update of http://api.worldempire.ch asap.
Comment #5
berdirSlightly updated patch, the result is now visible at http://api.worldempire.ch/api/privatemsg/privatemsg.api.php/group/sql/7-1
Comment #6
berdirCommited.