function heartbeat_views_data in Heartbeat 6.4
Same name and namespace in other branches
- 8 heartbeat.views.inc \heartbeat_views_data()
- 6.2 user_activity_views/user_activity_views.views.inc \heartbeat_views_data()
- 6.3 views/heartbeat_views.views.inc \heartbeat_views_data()
- 7 heartbeat.views.inc \heartbeat_views_data()
Implementation of views hook hook_views_data().
Return value
array views data
See also
http://www.lullabot.com/articles/hacking-views-part-1-basic-concepts
File
- views/
heartbeat_views.views.inc, line 15 - Views integration for heartbeat.
Code
function heartbeat_views_data() {
//heartbeat messages
$data['heartbeat_messages'] = array(
// Table to join
'table' => array(
'group' => t('Heartbeat messages'),
),
'message_id' => array(
'title' => t('Heartbeat message id'),
'help' => t('Message Id of the hearbeat message'),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
),
'message' => array(
'title' => t('Heartbeat message'),
'help' => t('Hearbeat message'),
),
'hid' => array(
'title' => t('heartbeat message id'),
'help' => t('Numeric heartbeat message id'),
),
'perms' => array(
'title' => t('Permissions'),
'help' => t('Permissions of the message'),
'filter' => array(
'handler' => 'views_handler_filter_heartbeat_perms',
),
),
);
// Heartbeat activity table
$data['heartbeat_activity'] = array(
// Table to join
'table' => array(
'group' => t('Heartbeat activity'),
'base' => array(
'field' => 'uaid',
'title' => t('Heartbeat activity messages'),
'help' => t("All activity logged by heartbeat"),
),
),
// uaid.
'uaid' => array(
'title' => t('Uaid'),
'help' => t('The unique ID of the activity message.'),
// The help that appears on the UI,
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
),
// Delete link for activity.
'delete_link' => array(
'real field' => 'uaid',
'field' => array(
'title' => t('Delete link'),
'help' => t('Provide a simple link to delete the activity message.'),
'handler' => 'views_handler_field_heartbeat_activity_link_delete',
),
),
// Fields to use or as filter, arguments, relationships ...
'uid' => array(
'title' => t('Message owner'),
'help' => t('The owner of the heartbeat message.'),
'relationship' => array(
'label' => t('Heartbeat message owner'),
'base' => 'users',
'base field' => 'uid',
'left_field' => 'uid',
'field' => 'uid',
),
),
'message_id' => array(
'title' => t('Heartbeat message id'),
'help' => t('The id of the hearbeat message.'),
'relationship' => array(
'label' => t('Activity message id'),
'base' => 'heartbeat_messages',
'base field' => 'message_id',
'left_field' => 'message_id',
'field' => 'message_id',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'field' => array(
'handler' => 'views_handler_field_markup',
'format' => FILTER_FORMAT_DEFAULT,
),
),
'uid_current' => array(
'real field' => 'uid',
'title' => t('The user who\'s activity is beeing displayed'),
'help' => t('Sets the displayed user to the currently logged in user or by uid in url'),
'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',
),
),
'message' => array(
'title' => t('Message'),
'help' => t('Logged Message'),
'field' => array(
'handler' => 'views_handler_field_markup',
'format' => FILTER_HTML_ESCAPE,
),
),
// Language field
'language' => array(
'title' => t('Display language is current language(usertime)'),
'help' => t('The language the content is in.'),
'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',
'handler' => 'views_handler_sort_date',
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
),
'access_type' => array(
'real field' => 'uid',
'title' => t('Heartbeat user access'),
'help' => t('Restict with access types'),
'filter' => array(
'handler' => 'views_handler_filter_heartbeat_access',
),
),
'nid' => array(
'title' => t('Node'),
'help' => t('The node where the activity occurred.'),
'argument' => array(
'handler' => 'views_handler_argument_node_nid',
),
'relationship' => array(
'label' => t('Message node id'),
'base' => 'node',
'base field' => 'nid',
'left_field' => 'nid',
'field' => 'nid',
),
),
'nid_target' => array(
'title' => t('Node Target'),
'help' => t('The target node the activity occured.'),
'argument' => array(
'handler' => 'views_handler_argument_node_nid',
),
'relationship' => array(
'label' => t('Message node target id'),
'base' => 'node',
'base field' => 'nid',
'left_field' => 'nid_target',
'field' => 'nid_target',
),
),
);
if (module_exists('og_views')) {
$data['heartbeat_activity']['og_rel'] = array(
'group' => t('Heartbeat'),
'title' => t('Organic group'),
'help' => t('Create a relationship to nodes organic groups.'),
'relationship' => array(
'relationship table' => 'heartbeat_activity',
'relationship field' => 'nid_target',
'handler' => 'views_handler_relationship',
'base' => 'og_ancestry',
'base field' => 'nid',
'label' => t('Group'),
),
);
$data['heartbeat_activity']['og_relation'] = array(
'group' => t('Heartbeat'),
'title' => t('Organic group'),
'help' => t('Create a relationship to organic group nodes.'),
'relationship' => array(
'relationship table' => 'heartbeat_activity',
'relationship field' => 'nid',
'handler' => 'views_handler_relationship',
'base' => 'og_ancestry',
'base field' => 'nid',
'label' => t('Group'),
),
);
}
return $data;
}