Projet

Général

Profil

Révision 7547bb19

Ajouté par Assos Assos il y a environ 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc
6 6
* Implements the Views Form API.
7 7
*/
8 8

  
9
class views_bulk_operations_handler_field_operations extends views_handler_field {
9
class views_bulk_operations_handler_field_operations extends views_handler_field_entity {
10 10
  var $revision = FALSE;
11 11

  
12 12
  function init(&$view, &$options) {
......
46 46
        unset($operation_options['use_queue']);
47 47
      }
48 48
    }
49

  
50
    // Check whether this is a revision.
51
    $table_data = views_fetch_data($this->table);
52
    if (!empty($table_data['table']['revision'])) {
53
      $this->revision = TRUE;
54
    }
49 55
  }
50 56

  
51 57
  function option_definition() {
......
186 192
          $dom_id . '-selected' => array(1),
187 193
        ),
188 194
      );
195
      $form['vbo_operations'][$operation_id]['skip_permission_check'] = array(
196
        '#type' => 'checkbox',
197
        '#title' => t('Skip permission step'),
198
        '#default_value' => !empty($operation_options['skip_permission_check']),
199
        '#dependency' => array(
200
          $dom_id . '-selected' => array(1),
201
        ),
202
      );
189 203

  
190 204
      $form['vbo_operations'][$operation_id] += $operation->adminOptionsForm($dom_id, $this);
191 205
    }
......
263 277
    // At this point, the query has already been run, so we can access the results
264 278
    // in order to get the base key value (for example, nid for nodes).
265 279
    foreach ($this->view->result as $row_index => $row) {
266
      $entity_id = $this->get_value($row);
280
      $this->view->row_index = $row_index;
281
      $id = $this->get_value($row, $this->real_field);
267 282

  
268 283
      if ($this->options['vbo_settings']['force_single']) {
269 284
        $form[$this->options['id']][$row_index] = array(
270 285
          '#type' => 'radio',
271 286
          '#parents' => array($this->options['id']),
272
          '#return_value' => $entity_id,
287
          '#return_value' => $id,
273 288
        );
274 289
      }
275 290
      else {
276 291
        $form[$this->options['id']][$row_index] = array(
277 292
          '#type' => 'checkbox',
278
          '#return_value' => $entity_id,
293
          '#return_value' => $id,
279 294
          '#default_value' => FALSE,
280 295
          '#attributes' => array('class' => array('vbo-select')),
281 296
        );
......
293 308
        if (empty($options['selected'])) {
294 309
          continue;
295 310
        }
296

  
297 311
        $operation = views_bulk_operations_get_operation($operation_id, $entity_type, $options);
298
        if (!$operation || !$operation->access($user)) {
312
        if (!$operation) {
313
          continue;
314
        }
315
        $skip_permission_check = $operation->getAdminOption('skip_permission_check', FALSE);
316
        if (!$operation->access($user) && !$skip_permission_check) {
299 317
          continue;
300 318
        }
301 319
        $selected[$operation_id] = $operation;
......
318 336
   * the entity type that VBO is operating on.
319 337
   */
320 338
  public function get_entity_type() {
321
    $base_table = $this->view->base_table;
322

  
323
    // If the current field is under a relationship you can't be sure that the
324
    // base table of the view is the base table of the current field.
325
    // For example a field from a node author on a node view does have users as base table.
326
    if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
327
      $relationships = $this->view->display_handler->get_option('relationships');
328
      $options = $relationships[$this->options['relationship']];
329
      $data = views_fetch_data($options['table']);
330
      $base_table = $data[$options['field']]['relationship']['base'];
331
    }
332
    // The base table is now known, use it to determine the entity type.
333
    foreach (entity_get_info() as $entity_type => $info) {
334
      if (isset($info['base table']) && $info['base table'] == $base_table) {
335
        return $entity_type;
336
      }
337
      elseif (isset($info['revision table']) && $info['revision table'] == $base_table) {
338
        $this->revision = TRUE;
339
        return $entity_type;
340
      }
341
    }
342
    // This should never happen.
343
    _views_bulk_operations_report_error("Could not determine the entity type for VBO field on views base table %table", array('%table' => $base_table));
344
    return FALSE;
339
    return $this->entity_type;
345 340
  }
341

  
346 342
}

Formats disponibles : Unified diff