function privatemsg_file_download_access in Privatemsg 7.2
Same name and namespace in other branches
- 7 privatemsg.module \privatemsg_file_download_access()
Implements hook_file_download_access().
File
- ./
privatemsg.module, line 2892 - Allows users to send private messages to other users.
Code
function privatemsg_file_download_access($field, $entity_type, $entity) {
global $user;
if ($entity_type == 'privatemsg_message') {
// Users with read all private messages permission can view all files too.
if (user_access('read all private messages')) {
return TRUE;
}
// Check if user is a recipient of this message.
return (bool) db_query_range("SELECT 1 FROM {pm_index} WHERE recipient = :uid AND type IN ('user', 'hidden') AND mid = :mid", 0, 1, array(
':uid' => $user->uid,
':mid' => $entity->mid,
))
->fetchField();
}
}