diff --git a/views/views_bulk_operations.views.inc b/views/views_bulk_operations.views.inc index 1c7078a..a740ab3 100644 --- a/views/views_bulk_operations.views.inc +++ b/views/views_bulk_operations.views.inc @@ -6,11 +6,11 @@ function views_bulk_operations_views_data_alter(&$data) { foreach (entity_get_info() as $entity_type => $info) { if (isset($info['base table']) && isset($data[$info['base table']]['table'])) { - $data[$info['base table']]['views_bulk_operations'] = array( + $data[$info['base table']]['views_bulk_operations']['moved to'] = array('views_entity_' . $entity_type, 'views_bulk_operations'); + $data['views_entity_' . $entity_type]['views_bulk_operations'] = array( 'title' => $data[$info['base table']]['table']['group'], 'group' => t('Bulk operations'), 'help' => t('Provide a checkbox to select the row for bulk operations.'), - 'real field' => $info['entity keys']['id'], 'field' => array( 'handler' => 'views_bulk_operations_handler_field_operations', 'click sortable' => FALSE, diff --git a/views/views_bulk_operations_handler_field_operations.inc b/views/views_bulk_operations_handler_field_operations.inc index 1fdb60d..1b7069a 100644 --- a/views/views_bulk_operations_handler_field_operations.inc +++ b/views/views_bulk_operations_handler_field_operations.inc @@ -6,7 +6,7 @@ * Implements the Views Form API. */ -class views_bulk_operations_handler_field_operations extends views_handler_field { +class views_bulk_operations_handler_field_operations extends views_handler_field_entity { var $revision = FALSE; function init(&$view, &$options) { @@ -234,7 +234,9 @@ class views_bulk_operations_handler_field_operations extends views_handler_field // At this point, the query has already been run, so we can access the results // in order to get the base key value (for example, nid for nodes). foreach ($this->view->result as $row_index => $row) { - $entity_id = $this->get_value($row); + $this->view->row_index = $row_index; + $entity = $this->get_value($row); + list($entity_id, , ) = entity_extract_ids($this->get_entity_type(), $entity); if ($this->options['vbo_settings']['force_single']) { $form[$this->options['id']][$row_index] = array( @@ -289,29 +291,6 @@ class views_bulk_operations_handler_field_operations extends views_handler_field * the entity type that VBO is operating on. */ public function get_entity_type() { - $base_table = $this->view->base_table; - - // If the current field is under a relationship you can't be sure that the - // base table of the view is the base table of the current field. - // For example a field from a node author on a node view does have users as base table. - if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { - $relationships = $this->view->display_handler->get_option('relationships'); - $options = $relationships[$this->options['relationship']]; - $data = views_fetch_data($options['table']); - $base_table = $data[$options['field']]['relationship']['base']; - } - // The base table is now known, use it to determine the entity type. - foreach (entity_get_info() as $entity_type => $info) { - if (isset($info['base table']) && $info['base table'] == $base_table) { - return $entity_type; - } - elseif (isset($info['revision table']) && $info['revision table'] == $base_table) { - $this->revision = TRUE; - return $entity_type; - } - } - // This should never happen. - _views_bulk_operations_report_error("Could not determine the entity type for VBO field on views base table %table", array('%table' => $base_table)); - return FALSE; + return $this->entity_type; } }