privatemsg_filter.pages.inc

  1. 7-1 privatemsg_filter/privatemsg_filter.pages.inc
  2. 7-2 privatemsg_filter/privatemsg_filter.pages.inc

User menu callbacks for privatemsg_filter module.

File

privatemsg_filter/privatemsg_filter.pages.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * User menu callbacks for privatemsg_filter module.
  5. */
  6. /**
  7. * Return autocomplete results for tags.
  8. *
  9. * Most of this code has been lifted/modified from privatemsg_user_name_autocomplete().
  10. */
  11. function privatemsg_filter_tags_autocomplete($string) {
  12. // 1: Parse $string and build a list of tags.
  13. $tags = array();
  14. $fragments = explode(',', $string);
  15. foreach ($fragments as $tag) {
  16. $tag = trim($tag);
  17. $tags[$tag] = $tag;
  18. }
  19. // 2: Find the next tag suggestion.
  20. $fragment = array_pop($tags);
  21. $matches = array();
  22. if (!empty($fragment)) {
  23. $query = _privatemsg_assemble_query(array('tags_autocomplete', 'privatemsg_filter'), $fragment, $tags);
  24. $prefix = count($tags) ? implode(", ", $tags) . ", " : '';
  25. // 3: Build proper suggestions and print.
  26. foreach ($query->execute() as $tag) {
  27. $matches[$prefix . $tag->tag . ", "] = $tag->tag;
  28. }
  29. }
  30. // convert to object to prevent drupal bug, see http://drupal.org/node/175361
  31. drupal_json_output((object)$matches);
  32. }

Functions

Namesort descending Description
privatemsg_filter_tags_autocomplete Return autocomplete results for tags.