Projet

Général

Profil

Révision b8087750

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views_bulk_operations/views_bulk_operations.module
13 13

  
14 14
/**
15 15
 * Implements hook_action_info().
16
 *
16 17
 * Registers custom VBO actions as Drupal actions.
17 18
 */
18 19
function views_bulk_operations_action_info() {
......
20 21
  $files = views_bulk_operations_load_action_includes();
21 22
  foreach ($files as $filename) {
22 23
    $action_info_fn = 'views_bulk_operations_'. str_replace('.', '_', basename($filename, '.inc')).'_info';
23
    $action_info = call_user_func($action_info_fn);
24
    if (is_array($action_info)) {
25
      $actions += $action_info;
24
    if (is_callable($action_info_fn)) {
25
      $action_info = call_user_func($action_info_fn);
26
      if (is_array($action_info)) {
27
        $actions += $action_info;
28
      }
29
    }
30
    else {
31
      watchdog('views bulk operations', 'views_bulk_operations_action_info() expects action filenames to have a matching valid callback function named: %function', array('%function' => $action_info_fn), WATCHDOG_WARNING);
26 32
    }
27 33
  }
28 34

  
......
190 196
      $operations += $plugin['list callback']();
191 197
    }
192 198

  
193
    uasort($operations, create_function('$a, $b', 'return strcasecmp($a["label"], $b["label"]);'));
199
    uasort($operations, '_views_bulk_operations_sort_operations_by_label');
194 200
  }
195 201

  
196 202
  if (!empty($operation_id)) {
......
201 207
  }
202 208
}
203 209

  
210
/**
211
 * Sort function used by uasort in views_bulk_operations_get_operation_info().
212
 *
213
 * A closure would be better suited for this, but closure support was added in
214
 * PHP 5.3 and D7 supports 5.2.
215
 */
216
function _views_bulk_operations_sort_operations_by_label($a, $b) {
217
  return strcasecmp($a['label'], $b['label']);
218
}
219

  
204 220
/**
205 221
 * Returns an operation instance.
206 222
 *
......
523 539
    $enable_select_all_pages = FALSE;
524 540
    // If the view is paginated, and "select all items on all pages" is
525 541
    // enabled, tell that to the theme function.
526
    if (count($vbo->view->result) != $vbo->view->total_rows && $vbo->get_vbo_option('enable_select_all_pages')) {
542
    if (isset($vbo->view->total_rows) && count($vbo->view->result) != $vbo->view->total_rows && $vbo->get_vbo_option('enable_select_all_pages')) {
527 543
      $enable_select_all_pages = TRUE;
528 544
    }
529 545
    $form['select_all_markup'] = array(
......
842 858

  
843 859
  // All items on all pages should be selected, add a batch job to gather
844 860
  // and enqueue them.
845
  if ($select_all_pages && $vbo->view->query->pager->has_more_records()) {
861
  if ($select_all_pages && ($vbo->view->query->pager->has_more_records() || $vbo->view->query->pager->get_current_page() > 0)) {
846 862
    $total_rows = $vbo->view->total_rows;
847 863

  
848 864
    $batch['operations'][] = array(
......
1186 1202
    $skip_permission_check = $operation->getAdminOption('skip_permission_check');
1187 1203
    // Filter out entities that can't be accessed.
1188 1204
    foreach ($entities as $id => $entity) {
1189
      if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) {
1205
      if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $user)) {
1190 1206
        $context['results']['log'][] = t('Skipped %operation on @type %title due to insufficient permissions.', array(
1191 1207
          '%operation' => $operation->label(),
1192 1208
          '@type' => $entity_type,

Formats disponibles : Unified diff