Révision 7547bb19
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/views_bulk_operations/views_bulk_operations.module | ||
---|---|---|
45 | 45 |
'archive.action', |
46 | 46 |
'argument_selector.action', |
47 | 47 |
'book.action', |
48 |
'change_owner.action', |
|
48 | 49 |
'delete.action', |
49 | 50 |
'modify.action', |
50 | 51 |
'script.action', |
... | ... | |
75 | 76 |
*/ |
76 | 77 |
function views_bulk_operations_cron() { |
77 | 78 |
db_delete('queue') |
78 |
->condition('name', db_like('views_bulk_operations_active_queue_'), 'LIKE') |
|
79 |
->condition('name', db_like('views_bulk_operations_active_queue_') . '%', 'LIKE')
|
|
79 | 80 |
->condition('created', REQUEST_TIME - 86400, '<') |
80 | 81 |
->execute(); |
81 | 82 |
} |
... | ... | |
214 | 215 |
function views_bulk_operations_get_operation($operation_id, $entity_type, $options) { |
215 | 216 |
$operations = &drupal_static(__FUNCTION__); |
216 | 217 |
|
217 |
if (!isset($operations[$operation_id])) { |
|
218 |
// Create a unique hash of the options. |
|
219 |
$cid = md5(serialize($options)); |
|
220 |
|
|
221 |
// See if there's a cached copy of the operation, including entity type and |
|
222 |
// options. |
|
223 |
if (!isset($operations[$operation_id][$entity_type][$cid])) { |
|
218 | 224 |
// Intentionally not using views_bulk_operations_get_operation_info() here |
219 | 225 |
// since it's an expensive function that loads all the operations on the |
220 | 226 |
// system, despite the fact that we might only need a few. |
... | ... | |
223 | 229 |
$operation_info = $plugin['list callback']($operation_id); |
224 | 230 |
|
225 | 231 |
if ($operation_info) { |
226 |
$operations[$operation_id] = new $plugin['handler']['class']($operation_id, $entity_type, $operation_info, $options); |
|
232 |
$operations[$operation_id][$entity_type][$cid] = new $plugin['handler']['class']($operation_id, $entity_type, $operation_info, $options);
|
|
227 | 233 |
} |
228 | 234 |
else { |
229 |
$operations[$operation_id] = FALSE; |
|
235 |
$operations[$operation_id][$entity_type][$cid] = FALSE;
|
|
230 | 236 |
} |
231 | 237 |
} |
232 | 238 |
|
233 |
return $operations[$operation_id]; |
|
239 |
return $operations[$operation_id][$entity_type][$cid];
|
|
234 | 240 |
} |
235 | 241 |
|
236 | 242 |
/** |
... | ... | |
638 | 644 |
// All rows on all pages have been selected, so show a count of additional items. |
639 | 645 |
if ($select_all_pages) { |
640 | 646 |
$more_count = $vbo->view->total_rows - count($vbo->view->result); |
641 |
$items[] = t('...and <strong>!count</strong> more.', array('!count' => $more_count));
|
|
647 |
$items[] = t('...and %count more.', array('%count' => $more_count));
|
|
642 | 648 |
} |
643 | 649 |
|
644 | 650 |
$count = format_plural(count($entities), 'item', '@count items'); |
645 |
$output = theme('item_list', array('items' => $items, 'title' => t('You selected the following <strong>!count</strong>:', array('!count' => $count))));
|
|
651 |
$output = theme('item_list', array('items' => $items, 'title' => t('You selected the following %count:', array('%count' => $count))));
|
|
646 | 652 |
return $output; |
647 | 653 |
} |
648 | 654 |
|
... | ... | |
902 | 908 |
} |
903 | 909 |
|
904 | 910 |
$vbo = _views_bulk_operations_get_field($view); |
911 |
|
|
912 |
// Call views_handler_field_entity::pre_render() to get the entities. |
|
913 |
$vbo->pre_render($view->result); |
|
914 |
|
|
905 | 915 |
$rows = array(); |
906 | 916 |
foreach ($view->result as $row_index => $result) { |
917 |
// Set the row index. |
|
918 |
$view->row_index = $row_index; |
|
907 | 919 |
$rows[$row_index] = array( |
908 |
'entity_id' => $vbo->get_value($result), |
|
920 |
'entity_id' => $vbo->get_value($result, $vbo->real_field),
|
|
909 | 921 |
'views_row' => array(), |
910 | 922 |
'position' => array( |
911 | 923 |
'current' => ++$context['sandbox']['progress'], |
... | ... | |
1075 | 1087 |
} |
1076 | 1088 |
|
1077 | 1089 |
// If the current entity can't be accessed, skip it and log a notice. |
1078 |
if (!_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) { |
|
1090 |
$skip_permission_check = $operation->getAdminOption('skip_permission_check'); |
|
1091 |
if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) { |
|
1079 | 1092 |
$message = 'Skipped %operation on @type %title due to insufficient permissions.'; |
1080 | 1093 |
$arguments = array( |
1081 | 1094 |
'%operation' => $operation->label(), |
... | ... | |
1127 | 1140 |
if ($field_name != $vbo->options['id']) { |
1128 | 1141 |
unset($view->field[$field_name]); |
1129 | 1142 |
} |
1143 |
else { |
|
1144 |
// Get hold of the new VBO field. |
|
1145 |
$new_vbo = $view->field[$field_name]; |
|
1146 |
} |
|
1130 | 1147 |
} |
1131 | 1148 |
|
1132 | 1149 |
$view->execute($vbo->view->current_display); |
1150 |
|
|
1151 |
// Call views_handler_field_entity::pre_render() to get the entities. |
|
1152 |
$new_vbo->pre_render($view->result); |
|
1153 |
|
|
1133 | 1154 |
$results = array(); |
1134 | 1155 |
foreach ($view->result as $row_index => $result) { |
1135 |
$results[$row_index] = $vbo->get_value($result); |
|
1156 |
// Set the row index. |
|
1157 |
$view->row_index = $row_index; |
|
1158 |
$results[$row_index] = $new_vbo->get_value($result, $new_vbo->real_field); |
|
1136 | 1159 |
} |
1137 | 1160 |
$selection = $results; |
1138 | 1161 |
} |
... | ... | |
1160 | 1183 |
} |
1161 | 1184 |
$entities = _views_bulk_operations_entity_load($entity_type, $entity_ids, $options['revision']); |
1162 | 1185 |
|
1186 |
$skip_permission_check = $operation->getAdminOption('skip_permission_check'); |
|
1163 | 1187 |
// Filter out entities that can't be accessed. |
1164 | 1188 |
foreach ($entities as $id => $entity) { |
1165 |
if (!_views_bulk_operations_entity_access($operation, $entity_type, $entity)) {
|
|
1189 |
if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) {
|
|
1166 | 1190 |
$context['results']['log'][] = t('Skipped %operation on @type %title due to insufficient permissions.', array( |
1167 | 1191 |
'%operation' => $operation->label(), |
1168 | 1192 |
'@type' => $entity_type, |
Formats disponibles : Unified diff
Weekly update of contrib modules