You are here

function privatemsg_roles_privatemsg_name_lookup in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_privatemsg_name_lookup()
  2. 7.2 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_privatemsg_name_lookup()

Implements hook_privatemsg_name_lookup().

File

privatemsg_roles/privatemsg_roles.module, line 128
Allows to send messages to all members of a role.

Code

function privatemsg_roles_privatemsg_name_lookup($string) {

  // Remove optional role specifier.
  $string = str_replace(t('[role]'), '', $string);
  $role = db_query("SELECT *, rid AS recipient FROM {role} WHERE name = :name", array(
    ':name' => trim($string),
  ))
    ->fetchObject();
  if ($role) {
    $role->type = 'role';
    return array(
      privatemsg_recipient_key($role) => $role,
    );
  }
}