function privatemsg_roles_privatemsg_name_lookup in Privatemsg 7.2
Same name and namespace in other branches
- 6.2 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_privatemsg_name_lookup()
- 7 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_privatemsg_name_lookup()
Implements hook_privatemsg_name_lookup().
File
- privatemsg_roles/
privatemsg_roles.module, line 165 - 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,
);
}
}