Issue #1245220 by plach, dpolant, xjm, bfroehle: Fixed file_file_download() passed bogus to field_access().
parent
10b65594b7
commit
98509c1af6
|
@ -172,7 +172,7 @@ function file_file_download($uri, $field_type = 'file') {
|
|||
// Find the field item with the matching URI.
|
||||
foreach ($field_items as $field_item) {
|
||||
if ($field_item['uri'] == $uri) {
|
||||
$field = $field_item;
|
||||
$field = field_info_field($field_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,3 +69,16 @@ function file_module_test_form_submit($form, &$form_state) {
|
|||
}
|
||||
drupal_set_message(t('The file id is %fid.', array('%fid' => $fid)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_file_download_access().
|
||||
*/
|
||||
function file_module_test_file_download_access($field, $entity_type, $entity) {
|
||||
list(,, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
$instance = field_info_instance($entity_type, $field['field_name'], $bundle);
|
||||
// Allow the file to be downloaded only if the given arguments are correct.
|
||||
// If any are wrong, $instance will be NULL.
|
||||
if (empty($instance)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue