diff --git a/views/views_bulk_operations_handler_field_operations.inc b/views/views_bulk_operations_handler_field_operations.inc index 1fdb60d..2776b2f 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,11 @@ 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); + // Get the entity for the row. + $this->view->row_index = $row_index; + $entity = (isset($row->entity) && is_object($row->entity)) ? $row->entity : $this->entities[$row_index]; + // Get the entity ID. + list($entity_id, $entity_vid, $bundle) = entity_extract_ids($this->get_entity_type(), $entity); if ($this->options['vbo_settings']['force_single']) { $form[$this->options['id']][$row_index] = array( @@ -289,29 +293,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; } }