function privatemsg_roles_autocomplete in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_autocomplete()
- 7 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_autocomplete()
Provides autocomplete suggestions for roles.
2 string references to 'privatemsg_roles_autocomplete'
- hook_privatemsg_recipient_type_info in ./
privatemsg.api.php - This hook is used to tell privatemsg about the recipient types defined by a module. Each type consists of an array keyed by the internal recipient type name and the following keys must be defined.
- privatemsg_roles_privatemsg_recipient_type_info in privatemsg_roles/
privatemsg_roles.module - Implements hook_privatemsg_recipient_type_info().
File
- privatemsg_roles/
privatemsg_roles.module, line 136 - Allows to send messages to all members of a role.
Code
function privatemsg_roles_autocomplete($fragment, $names, $limit) {
$query = _privatemsg_assemble_query(array(
'autocomplete_roles',
'privatemsg_roles',
), $fragment, $names);
$result = db_query_range($query['query'], $fragment, 0, $limit);
// 3: Build proper suggestions and print.
$roles = array();
while ($role = db_fetch_object($result)) {
if (user_access('write privatemsg to all roles') || user_access('write privatemsg to role ' . $role->name)) {
$role->type = 'role';
$role->recipient = $role->rid;
$roles[privatemsg_recipient_key($role)] = $role;
}
}
return $roles;
}