You are here

heartbeat_views.views.inc in Heartbeat 6.3

Same filename and directory in other branches
  1. 6.4 views/heartbeat_views.views.inc

File

views/heartbeat_views.views.inc
View source
<?php

/**
 * Implementation of views hook hook_views_data()
 * @see http://blue.live4all.co.il/~mooffie/tmp/views_illustrated/
 * @see http://views.doc.logrus.com/
 *
 * @return array views data
 */
function heartbeat_views_data() {
  $data = array(
    'heartbeat_activity' => array(
      // Table to join
      'table' => array(
        'group' => t('User activity log table'),
        'base' => array(
          'field' => 'uaid',
          'title' => t('Heartbeat activities'),
          'help' => t("User activities on the site"),
        ),
        'join' => array(
          'heartbeat_messages' => array(
            'handler' => 'views_join',
            // this is actually optional
            'left_table' => 'heartbeat_activity',
            // Because this is a direct link it could be left out.
            'type' => 'INNER',
            'left_field' => 'message_id',
            'field' => 'message_id',
          ),
        ),
      ),
      // Fields to use or as filter, arguments, ...
      'uid' => array(
        'title' => t('User'),
        'help' => t('The user who carried out the activity'),
        'relationship' => array(
          'base' => 'users',
          'field' => 'uid',
          'handler' => 'views_handler_relationship',
          'label' => t('User'),
        ),
      ),
      'uid_current' => array(
        'real field' => 'uid',
        'title' => t('Currently logged in user carried out the activity'),
        'help' => t('The user who did the activity is the currently logged in user'),
        'filter' => array(
          'handler' => 'views_handler_filter_user_current',
        ),
      ),
      'uid_requested' => array(
        'real field' => 'uid',
        'title' => t('Currently requested user (url argument) carried out the activity'),
        'help' => t('The user who did the activity is third argument in url heartbeat/user/% '),
        'argument' => array(
          'handler' => 'views_handler_argument_user_uid',
        ),
      ),
      'uid_target' => array(
        'title' => t('Target User'),
        'help' => t('The user who was the target of the activity (if present)'),
        'relationship' => array(
          'base' => 'users',
          'field' => 'uid',
          'handler' => 'views_handler_relationship',
          'label' => t('User'),
        ),
      ),
      'message_id' => array(
        'title' => t('Heartbeat message id'),
        'help' => t('The id of the hearbeat message that was used.'),
        'relationship' => array(
          'base' => 'heartbeat_messages',
          'field' => 'message_id',
          'handler' => 'views_handler_relationship',
          'label' => t('Heartbeat message'),
        ),
        'field' => array(
          'handler' => 'views_handler_field',
        ),
        'filter' => array(
          'handler' => 'views_handler_filter_string',
        ),
      ),
      'message' => array(
        'title' => t('Message'),
        'help' => t('Logged Message'),
        'field' => array(
          'handler' => 'views_handler_field_markup',
          'format' => FILTER_FORMAT_DEFAULT,
        ),
        'filter' => array(
          'handler' => 'views_handler_filter_string',
        ),
      ),
      // Language field
      'language' => array(
        'title' => t('Display language is current language(usertime)'),
        'help' => t('The language the content is in.'),
        'field' => array(
          'handler' => 'views_handler_field',
        ),
        'filter' => array(
          'handler' => 'views_handler_filter_heartbeat_language',
        ),
      ),
      'timestamp' => array(
        'title' => t('Action\'s timestamp'),
        'help' => t('When the action happened'),
        'field' => array(
          'handler' => 'views_handler_field_date',
          'click sortable' => TRUE,
        ),
        'sort' => array(
          'handler' => 'views_handler_sort_date',
        ),
        'filter' => array(
          'handler' => 'views_handler_filter_date',
        ),
      ),
      'access_type' => array(
        'real field' => 'uid',
        'title' => t('access type messages'),
        'help' => t('Restict with access types'),
        'filter' => array(
          'handler' => 'views_handler_filter_heartbeat_access',
        ),
      ),
    ),
    //heartbeat messages
    'heartbeat_messages' => array(
      // Table to join
      'table' => array(
        'group' => t('Heartbeat messages table'),
      ),
      'message_id' => array(
        'title' => t('Heartbeat message id'),
        'help' => t('ID of the hearbeat message'),
        'field' => array(
          'handler' => 'views_handler_field_markup',
        ),
      ),
      'message' => array(
        'title' => t('Heartbeat message'),
        'help' => t('Hearbeat message'),
        'field' => array(
          'handler' => 'views_handler_field_markup',
        ),
      ),
      'hid' => array(
        'title' => t('Numeric heartbeat message id'),
        'help' => t('Numeric heartbeat message id'),
        'field' => array(
          'handler' => 'views_handler_field_numeric',
        ),
      ),
      'perms' => array(
        'title' => t('Permissions'),
        'help' => t('Permissions of the message'),
        'filter' => array(
          'handler' => 'views_handler_filter_heartbeat_perms',
        ),
      ),
      'module' => array(
        'title' => t('Module'),
        'help' => t('Module to which to message is related'),
        'filter' => array(
          'handler' => 'views_handler_filter_heartbeat_module',
        ),
      ),
    ),
  );
  return $data;
}

/**
 * Implementation of hook_views_handlers
 *
 * @return unknown
 */
function heartbeat_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'heartbeat') . '/views/handlers',
    ),
    'handlers' => array(
      'views_handler_filter_heartbeat_language' => array(
        'parent' => 'views_handler_filter_boolean_operator',
      ),
      'views_handler_filter_heartbeat_user_requested' => array(
        'parent' => 'views_handler_filter_boolean_operator',
      ),
      'views_handler_field_heartbeat_message' => array(
        'parent' => 'views_handler_field_markup',
      ),
      'views_handler_filter_heartbeat_perms' => array(
        'parent' => 'views_handler_filter_in_operator',
      ),
      'views_handler_filter_heartbeat_access' => array(
        'parent' => 'views_handler_filter_numeric',
      ),
      'views_handler_filter_heartbeat_module' => array(
        'parent' => 'views_handler_filter_numeric',
      ),
      'views_plugin_row_heartbeat_view' => array(
        'parent' => 'views_plugin_row',
      ),
    ),
  );
}

/**
 * Implementation of hook_views_plugins
 */
function heartbeat_views_plugins() {
  $hb_path = drupal_get_path('module', 'heartbeat');
  return array(
    'module' => 'heartbeat',
    // This just tells our themes are elsewhere.
    'row' => array(
      'heartbeat' => array(
        'title' => t('Heartbeat'),
        'help' => t('Display the heartbeat messages in a heartbeat view.'),
        'handler' => 'views_plugin_row_heartbeat_view',
        'path' => "{$hb_path}/views/plugins",
        'theme' => 'views_view_row_heartbeat',
        'theme file' => 'theme.inc',
        'theme path' => "{$hb_path}/views/theme",
        'uses options' => TRUE,
        'type' => 'normal',
        'help topic' => 'style-heartbeat',
      ),
    ),
  );
}

Functions

Namesort descending Description
heartbeat_views_data Implementation of views hook hook_views_data()
heartbeat_views_handlers Implementation of hook_views_handlers
heartbeat_views_plugins Implementation of hook_views_plugins