You are here

function user_relationship_privatemsg_autocomplete in User Relationships 7

Return relationship autocomplete suggestions.

1 string reference to 'user_relationship_privatemsg_autocomplete'
user_relationship_privatemsg_privatemsg_recipient_type_info in user_relationship_privatemsg/user_relationship_privatemsg.module
Implements hook_privatemsg_recipient_types_info().

File

user_relationship_privatemsg/user_relationship_privatemsg.module, line 155
Allows to send messages to all members of a role.

Code

function user_relationship_privatemsg_autocomplete($search, $names, $limit) {
  global $user;
  $matches = array();
  $types = user_relationships_types_load();
  foreach ($types as $type) {

    // Only look for relationship types which start with $search but search
    // case insensitive.
    if (stripos($type->plural_name, $search) === 0 && !in_array($type->plural_name, $names)) {
      $type->type = 'user_relationship';
      $type->recipient = _user_relationship_privatemsg_get_recipient_id($type->rtid, $user->uid);
      $type->account = $user;
      $matches[privatemsg_recipient_key($type)] = $type;
      if (count($matches) >= $limit) {
        break;
      }
    }
  }
  return $matches;
}