You are here

function casetracker_views_tables in Case Tracker 5

Implementation of hook_views_table().

File

./casetracker_views.module, line 11
Enables Views integration for Case Tracker.

Code

function casetracker_views_tables() {
  $tables['casetracker_case'] = array(
    'name' => 'casetracker_case',
    'join' => array(
      'left' => array(
        'table' => 'node',
        'field' => 'vid',
      ),
      'right' => array(
        'field' => 'vid',
        'type' => 'inner',
      ),
    ),
    'fields' => array(
      'pid' => array(
        'handler' => 'casetracker_views_project_name',
        'help' => t('Display the name of the Case Tracker project.'),
        'name' => t('Case Tracker: Project'),
        'sortable' => TRUE,
      ),
      'case_number' => array(
        'help' => t('Display the number of the Case Tracker case.'),
        'name' => t('Case Tracker: Case Number'),
        'sortable' => TRUE,
      ),
      'assign_to' => array(
        'handler' => 'casetracker_views_user_name',
        'help' => t('Display the user name the case has been assigned to.'),
        'name' => t('Case Tracker: Assigned To'),
        'sortable' => TRUE,
      ),
      'case_priority_id' => array(
        'handler' => 'casetracker_views_priority_name',
        'help' => t('Display the priority state of the case.'),
        'name' => t('Case Tracker: Case Priority'),
        'sortable' => TRUE,
      ),
      'case_status_id' => array(
        'handler' => 'casetracker_views_status_name',
        'help' => t('Display the status state of the case.'),
        'name' => t('Case Tracker: Case Status'),
        'sortable' => TRUE,
      ),
      'case_type_id' => array(
        'handler' => 'casetracker_views_type_name',
        'help' => t('Display the type state of the case.'),
        'name' => t('Case Tracker: Case Type'),
        'sortable' => TRUE,
      ),
    ),
    'sorts' => array(
      'case_number' => array(
        'help' => t('Sort by Case Tracker case number.'),
        'name' => t('Case Tracker: Case Number'),
        'sortable' => TRUE,
      ),
      'case_status_id' => array(
        'help' => t('Sort by Case Tracker status state.'),
        'name' => t('Case Tracker: Case Status'),
        'sortable' => TRUE,
      ),
      'case_priority_id' => array(
        'help' => t('Sort by Case Tracker priority state .'),
        'name' => t('Case Tracker: Case Priority'),
        'sortable' => TRUE,
      ),
    ),
    'filters' => array(
      'assign_to' => array(
        'help' => t('Filter Case Tracker cases by the assigned user.'),
        'list' => 'casetracker_views_user_options',
        'name' => t('Case Tracker: Assigned To'),
        'operator' => views_handler_operator_andor(),
        'value-type' => 'array',
      ),
      'case_priority_id' => array(
        'help' => t('Filter Case Tracker cases by its priority state.'),
        'list' => 'casetracker_views_priority_options',
        'name' => t('Case Tracker: Case Priority'),
        'operator' => views_handler_operator_andor(),
        'value-type' => 'array',
      ),
      'case_status_id' => array(
        'help' => t('Filter Case Tracker cases by its status state.'),
        'list' => 'casetracker_views_status_options',
        'name' => t('Case Tracker: Case Status'),
        'operator' => views_handler_operator_andor(),
        'value-type' => 'array',
      ),
      'case_type_id' => array(
        'help' => t('Filter Case Tracker cases by its type state.'),
        'list' => 'casetracker_views_type_options',
        'name' => t('Case Tracker: Case Type'),
        'operator' => views_handler_operator_andor(),
        'value-type' => 'array',
      ),
      'assign_to_currentuid' => array(
        'help' => t('Filter Case Tracker cases by the current logged in user.'),
        'list' => 'views_handler_filter_usercurrent',
        'list-type' => 'select',
        'name' => t('Case Tracker: Assigned to current logged in User'),
        'field' => 'assign_to',
        'operator' => 'views_handler_operator_eqneq',
      ),
    ),
  );
  $tables['casetracker_project'] = array(
    'name' => 'casetracker_project',
    'join' => array(
      'left' => array(
        'table' => 'casetracker_case',
        'field' => 'pid',
      ),
      'right' => array(
        'field' => 'nid',
        'type' => 'inner',
      ),
    ),
    'fields' => array(
      'project_number' => array(
        'handler' => 'casetracker_views_project_number',
        'help' => t('Display the Project number.'),
        'name' => t('Case Tracker: Project number'),
        'sortable' => TRUE,
      ),
      'project_number_full' => array(
        'notafield' => TRUE,
        'handler' => 'casetracker_views_case_number_full',
        'help' => t('Display the full Project-Case number.'),
        'name' => t('Case Tracker: Project-Case number'),
        'sortable' => FALSE,
      ),
    ),
    'filters' => array(
      'project_number' => array(
        'help' => t('Filter Case Tracker cases by their project.'),
        'list' => 'casetracker_views_project_options',
        'name' => t('Case Tracker: Project'),
        'operator' => views_handler_operator_andor(),
        'value-type' => 'array',
      ),
    ),
  );
  $tables['casetracker_case_states'] = array(
    'name' => 'casetracker_case',
    'join' => array(
      'left' => array(
        'table' => 'casetracker_case',
        'field' => 'case_status_id',
      ),
      'right' => array(
        'field' => 'csid',
        'type' => 'inner',
      ),
    ),
    'sorts' => array(
      'case_state_name' => array(
        'name' => t('Case Tracker: State Name'),
        'help' => t('Sort by Case Tracker state name.'),
        'sortable' => TRUE,
      ),
    ),
  );
  $tables['casetracker_case_node'] = array(
    'name' => 'node',
    'join' => array(
      'left' => array(
        'table' => 'node',
        'field' => 'vid',
      ),
      'right' => array(
        'field' => 'vid',
        'type' => 'inner',
      ),
    ),
    'fields' => array(
      'nid' => array(
        'handler' => 'casetracker_views_field_createCaseLink_handler',
        'name' => t('Case Tracker: Add Case link'),
        'option' => 'string',
        'notafield' => TRUE,
        'help' => t('Display a link to add a new Case for a Project. Enter the text of this link into the option field; if blank the default "Add Case" will be used.'),
      ),
      'view_cases' => array(
        'handler' => 'casetracker_views_field_viewProjectCases_link_handler',
        'name' => t('Case Tracker: View Cases link'),
        'option' => 'string',
        'notafield' => TRUE,
        'help' => t('Display a link to view all Project Cases. Enter the text of this link into the option field; if blank the default "View Cases" will be used.'),
      ),
    ),
  );
  return $tables;
}