Révision 3acd948f
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/file_entity/file_entity.admin.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* File administration and module settings UI. |
... | ... | |
178 | 179 |
* Array of key/value pairs with file field names and the |
179 | 180 |
* value to update that field to. |
180 | 181 |
*/ |
181 |
function file_entity_mass_update($files, $updates) {
|
|
182 |
function file_entity_mass_update(array $files, array $updates) {
|
|
182 | 183 |
// We use batch processing to prevent timeout when updating a large number |
183 | 184 |
// of files. |
184 | 185 |
if (count($files) > 10) { |
... | ... | |
323 | 324 |
'timestamp' => array( |
324 | 325 |
'data' => t('Updated'), |
325 | 326 |
'field' => 'fm.timestamp', |
326 |
'sort' => 'desc'), |
|
327 |
'sort' => 'desc', |
|
328 |
), |
|
327 | 329 |
'usage' => array('data' => t('Used in'), 'field' => 'total_count'), |
328 | 330 |
'operations' => array('data' => t('Operations')), |
329 | 331 |
); |
330 | 332 |
|
333 |
if (variable_get('file_entity_total_count_optimization', FALSE)) { |
|
334 |
// If the total_count is being retrieved by subqueries, |
|
335 |
// the table is not sortable by this column. |
|
336 |
unset($header['usage']['field']); |
|
337 |
} |
|
338 |
|
|
331 | 339 |
$query = db_select('file_managed', 'fm')->extend('PagerDefault')->extend('TableSort'); |
332 |
$query->leftJoin('file_usage', 'fu', 'fm.fid = fu.fid'); |
|
333 |
$query->groupBy('fm.fid'); |
|
334 |
$query->groupBy('fm.uid'); |
|
335 |
$query->groupBy('fm.timestamp'); |
|
336 |
$query->addExpression('SUM(fu.count)', 'total_count'); |
|
340 |
if (!variable_get('file_entity_total_count_optimization', FALSE)) { |
|
341 |
$query->leftJoin('file_usage', 'fu', 'fm.fid = fu.fid'); |
|
342 |
$query->groupBy('fm.fid'); |
|
343 |
$query->groupBy('fm.uid'); |
|
344 |
$query->groupBy('fm.timestamp'); |
|
345 |
$query->addExpression('SUM(fu.count)', 'total_count'); |
|
346 |
} |
|
337 | 347 |
file_entity_build_filter_query($query); |
338 | 348 |
|
339 | 349 |
$result = $query |
... | ... | |
343 | 353 |
->addTag('file_access') |
344 | 354 |
->execute() |
345 | 355 |
->fetchAllAssoc('fid'); |
356 |
|
|
357 |
if (variable_get('file_entity_total_count_optimization', FALSE)) { |
|
358 |
// Get the total_count in separate queries, otherwise the main |
|
359 |
// query will take too long. |
|
360 |
// This setting can be configured under /admin/config/development/performance. |
|
361 |
foreach ($result as &$file_result) { |
|
362 |
$count_query = db_select('file_usage', 'fu') |
|
363 |
->fields('fu', array('fid', 'count')) |
|
364 |
->condition('fu.fid', $file_result->fid, '='); |
|
365 |
$count_query->addExpression('SUM(fu.count)', 'total_count'); |
|
366 |
$count_result = $count_query->execute()->fetchAll(); |
|
367 |
|
|
368 |
if (!empty($count_result[0]->total_count)) { |
|
369 |
$file_result->total_count = $count_result[0]->total_count; |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
|
|
346 | 374 |
$files = file_load_multiple(array_keys($result)); |
347 | 375 |
|
348 | 376 |
$uids = array(); |
... | ... | |
931 | 959 |
$form_state['redirect'] = 'admin/structure/file-types'; |
932 | 960 |
} |
933 | 961 |
|
934 |
|
|
935 | 962 |
/** |
936 | 963 |
* Menu callback; disable a single file type. |
937 | 964 |
*/ |
... | ... | |
942 | 969 |
return confirm_form($form, $message, 'admin/structure/file-types', '', t('Enable')); |
943 | 970 |
} |
944 | 971 |
|
945 |
|
|
946 | 972 |
/** |
947 | 973 |
* Process file type disable confirm submissions. |
948 | 974 |
*/ |
... | ... | |
952 | 978 |
drupal_set_message(t('The file type %label has been enabled.', $t_args)); |
953 | 979 |
watchdog('file_entity', 'Enabled file type %label.', $t_args, WATCHDOG_NOTICE); |
954 | 980 |
$form_state['redirect'] = 'admin/structure/file-types'; |
955 |
return; |
|
956 | 981 |
} |
957 | 982 |
|
958 |
|
|
959 | 983 |
/** |
960 | 984 |
* Menu callback; disable a single file type. |
961 | 985 |
*/ |
... | ... | |
989 | 1013 |
drupal_set_message(t('The file type %label has been disabled.', $t_args)); |
990 | 1014 |
watchdog('file_entity', 'Disabled file type %label.', $t_args, WATCHDOG_NOTICE); |
991 | 1015 |
$form_state['redirect'] = 'admin/structure/file-types'; |
992 |
return; |
|
993 | 1016 |
} |
994 | 1017 |
|
995 |
|
|
996 | 1018 |
/** |
997 | 1019 |
* Menu callback; revert a single file type. |
998 | 1020 |
*/ |
... | ... | |
1003 | 1025 |
return confirm_form($form, $message, 'admin/structure/file-types', '', t('Revert')); |
1004 | 1026 |
} |
1005 | 1027 |
|
1006 |
|
|
1007 | 1028 |
/** |
1008 | 1029 |
* Process file type delete confirm submissions. |
1009 | 1030 |
*/ |
... | ... | |
1014 | 1035 |
drupal_set_message(t('The file type %label has been reverted.', $t_args)); |
1015 | 1036 |
watchdog('file_entity', 'Reverted file type %label.', $t_args, WATCHDOG_NOTICE); |
1016 | 1037 |
$form_state['redirect'] = 'admin/structure/file-types'; |
1017 |
return; |
|
1018 | 1038 |
} |
1019 | 1039 |
|
1020 |
|
|
1021 | 1040 |
/** |
1022 | 1041 |
* Menu callback; delete a single file type. |
1023 | 1042 |
*/ |
... | ... | |
1049 | 1068 |
watchdog('file_entity', 'Deleted file type %label.', $t_args, WATCHDOG_NOTICE); |
1050 | 1069 |
|
1051 | 1070 |
$form_state['redirect'] = 'admin/structure/file-types'; |
1052 |
return; |
|
1053 | 1071 |
} |
1054 | 1072 |
|
1055 | 1073 |
/** |
Formats disponibles : Unified diff
Weekly update of contrib modules