You are here

function state_flow_views_data_alter in State Machine 7.3

Implements hook_views_data_alter().

File

modules/state_flow/includes/views/state_flow.views.inc, line 24
Views integration for State Flow

Code

function state_flow_views_data_alter(&$data) {
  $data['state_flow_states']['table']['join']['node_revision'] = array(
    'left_field' => 'vid',
    'field' => 'revision_id',
    'type' => 'INNER',
    'extra' => array(
      array(
        'field' => 'entity_type',
        'value' => 'node',
        'operator' => '=',
      ),
    ),
  );
  $data['state_flow_states']['table']['join']['node'] = array(
    'left_field' => 'vid',
    'field' => 'revision_id',
    'type' => 'INNER',
    'extra' => array(
      array(
        'field' => 'entity_type',
        'value' => 'node',
        'operator' => '=',
      ),
    ),
  );
  $data['state_flow_history']['table']['join']['node_revision'] = array(
    'left_field' => 'vid',
    'field' => 'revision_id',
    'type' => 'INNER',
  );
  $data['state_flow_history']['table']['join']['node'] = array(
    'left_field' => 'nid',
    'field' => 'entity_id',
    'type' => 'INNER',
    'extra' => array(
      array(
        'field' => 'entity_type',
        'value' => 'node',
        'operator' => '=',
      ),
    ),
  );
  $data['state_flow_history']['revision_id']['relationship'] = array(
    'title' => t('Content Revision'),
    'label' => t('Content Revision'),
    'base' => 'node_revision',
    'base field' => 'vid',
    'type' => 'INNER',
  );
  $data['state_flow_history']['nid'] = array(
    'title' => t('Node'),
    'help' => t('The node according to the State Flow.'),
    'relationship' => array(
      'base' => 'node',
      'field' => 'entity_id',
      'handler' => 'views_handler_relationship',
      'label' => t('Node'),
    ),
  );
  $data['node_revision']['is_published'] = array(
    'real field' => 'vid',
    'title' => t('Is this revision published?'),
    'help' => t('Checks whether this is the revision that is also in the node table and that its status is 1'),
    'field' => array(
      'handler' => 'state_flow_handler_field_is_node_revision_published',
      'click sortable' => FALSE,
    ),
  );

  // Ensure the node_revision is joinable - seems be missing in views.
  if (!isset($data['node']['table']['join'])) {
    $data['node']['table']['join'] = array();
  }

  // Directly links to the node_revision table.
  $data['node']['table']['join']['node_revision'] = array(
    'left_field' => 'nid',
    'field' => 'nid',
  );
}