Commit 98509c1a authored by catch's avatar catch
Browse files

Issue #1245220 by plach, dpolant, xjm, bfroehle: Fixed file_file_download()...

Issue #1245220 by plach, dpolant, xjm, bfroehle: Fixed file_file_download() passed bogus  to field_access().
parent 10b65594
...@@ -172,7 +172,7 @@ function file_file_download($uri, $field_type = 'file') { ...@@ -172,7 +172,7 @@ function file_file_download($uri, $field_type = 'file') {
// Find the field item with the matching URI. // Find the field item with the matching URI.
foreach ($field_items as $field_item) { foreach ($field_items as $field_item) {
if ($field_item['uri'] == $uri) { if ($field_item['uri'] == $uri) {
$field = $field_item; $field = field_info_field($field_name);
break; break;
} }
} }
......
...@@ -69,3 +69,16 @@ function file_module_test_form_submit($form, &$form_state) { ...@@ -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))); 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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment