function filefield_sources_file_access in FileField Sources 6
Same name and namespace in other branches
- 7 filefield_sources.module \filefield_sources_file_access()
Check the current user's access to a file through hook_file_download().
Parameters
$uri: A file URI as loaded from the database.
Return value
Boolean TRUE if the user has access, FALSE otherwise.
See also
1 call to filefield_sources_file_access()
- filefield_source_reference_value in sources/
reference.inc - A #filefield_value_callback function.
File
- ./
filefield_sources.module, line 307 - Extend FileField to allow files from multiple sources.
Code
function filefield_sources_file_access($filepath) {
$headers = array();
foreach (module_implements('file_download') as $module) {
$function = $module . '_file_download';
$result = $function($filepath);
if ($result == -1) {
// Throw away the headers received so far.
$headers = array();
break;
}
if (isset($result) && is_array($result)) {
$headers = array_merge($headers, $result);
}
}
return !empty($headers);
}