Révision cf490feb
Ajouté par Assos Assos il y a environ 6 ans
drupal7/modules/file/file.module | ||
---|---|---|
140 | 140 |
} |
141 | 141 |
|
142 | 142 |
// Find out which (if any) fields of this type contain the file. |
143 |
$references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type); |
|
143 |
$references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type, FALSE);
|
|
144 | 144 |
|
145 | 145 |
// Stop processing if there are no references in order to avoid returning |
146 | 146 |
// headers for files controlled by other modules. Make an exception for |
... | ... | |
1067 | 1067 |
* @param $field_type |
1068 | 1068 |
* (optional) The name of a field type. If given, limits the reference check |
1069 | 1069 |
* to fields of the given type. |
1070 |
* @param $check_access |
|
1071 |
* (optional) A boolean that specifies whether the permissions of the current |
|
1072 |
* user should be checked when retrieving references. If FALSE, all |
|
1073 |
* references to the file are returned. If TRUE, only references from |
|
1074 |
* entities that the current user has access to are returned. Defaults to |
|
1075 |
* TRUE for backwards compatibility reasons, but FALSE is recommended for |
|
1076 |
* most situations. |
|
1070 | 1077 |
* |
1071 | 1078 |
* @return |
1072 | 1079 |
* An integer value. |
1073 | 1080 |
*/ |
1074 |
function file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISION, $field_type = 'file') { |
|
1081 |
function file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISION, $field_type = 'file', $check_access = TRUE) {
|
|
1075 | 1082 |
$references = drupal_static(__FUNCTION__, array()); |
1076 | 1083 |
$fields = isset($field) ? array($field['field_name'] => $field) : field_info_fields(); |
1077 | 1084 |
|
... | ... | |
1082 | 1089 |
$query |
1083 | 1090 |
->fieldCondition($file_field, 'fid', $file->fid) |
1084 | 1091 |
->age($age); |
1092 |
if (!$check_access) { |
|
1093 |
// Neutralize the 'entity_field_access' query tag added by |
|
1094 |
// field_sql_storage_field_storage_query(). |
|
1095 |
$query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT'); |
|
1096 |
} |
|
1085 | 1097 |
$references[$field_name] = $query->execute(); |
1086 | 1098 |
} |
1087 | 1099 |
} |
Formats disponibles : Unified diff
Update to 7.57