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.

Comments

Cristobal Wetzig’s picture

Title: hook_privatemsg_sql_autocomplete_alter » hook_privatemsg_sql_autocomplete_alter, drupal_alter( not existing in source?
berdir’s picture

Title: hook_privatemsg_sql_autocomplete_alter, drupal_alter( not existing in source? » Update sql database documentation
Category: bug » task

Uhm, 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.

Cristobal Wetzig’s picture

Cheers for the fast reply, and for the suggestion, and the link.

berdir’s picture

StatusFileSize
new11.48 KB

Attaching a first patch, will trigger an update of http://api.worldempire.ch asap.

berdir’s picture

Status: Active » Needs review
Issue tags: -API
StatusFileSize
new11.51 KB

Slightly updated patch, the result is now visible at http://api.worldempire.ch/api/privatemsg/privatemsg.api.php/group/sql/7-1

berdir’s picture

Status: Needs review » Fixed

Commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.