2015-08-18 00:00:26 +00:00
< ? php
/**
* @ file
* Provide views data for tracker . module .
*/
/**
* Implements hook_views_data () .
*/
function tracker_views_data () {
2017-04-13 14:53:35 +00:00
$data = [];
2015-08-18 00:00:26 +00:00
$data [ 'tracker_node' ][ 'table' ][ 'group' ] = t ( 'Tracker' );
2017-04-13 14:53:35 +00:00
$data [ 'tracker_node' ][ 'table' ][ 'join' ] = [
'node_field_data' => [
2015-08-18 00:00:26 +00:00
'type' => 'INNER' ,
'left_field' => 'nid' ,
'field' => 'nid' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_node' ][ 'nid' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Nid' ),
'help' => t ( 'The node ID of the node.' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'node' ,
2017-04-13 14:53:35 +00:00
],
'argument' => [
2015-08-18 00:00:26 +00:00
'id' => 'node_nid' ,
'name field' => 'title' ,
'numeric' => TRUE ,
'validate type' => 'nid' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'id' => 'numeric' ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'standard' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_node' ][ 'published' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Published' ),
'help' => t ( 'Whether or not the node is published.' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'boolean' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'id' => 'boolean' ,
'label' => t ( 'Published' ),
'type' => 'yes-no' ,
'accept null' => TRUE ,
'use_equal' => TRUE ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'standard' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_node' ][ 'changed' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Updated date' ),
'help' => t ( 'The date the node was last updated.' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'date' ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'date' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'id' => 'date' ,
2017-04-13 14:53:35 +00:00
],
];
2015-08-18 00:00:26 +00:00
$data [ 'tracker_user' ][ 'table' ][ 'group' ] = t ( 'Tracker - User' );
2017-04-13 14:53:35 +00:00
$data [ 'tracker_user' ][ 'table' ][ 'join' ] = [
'node_field_data' => [
2015-08-18 00:00:26 +00:00
'type' => 'INNER' ,
'left_field' => 'nid' ,
'field' => 'nid' ,
2017-04-13 14:53:35 +00:00
],
'user_field_data' => [
2015-08-18 00:00:26 +00:00
'type' => 'INNER' ,
'left_field' => 'uid' ,
'field' => 'uid' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_user' ][ 'nid' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Nid' ),
'help' => t ( 'The node ID of the node a user created or commented on. You must use an argument or filter on UID or you will get misleading results using this field.' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'node' ,
2017-04-13 14:53:35 +00:00
],
'argument' => [
2015-08-18 00:00:26 +00:00
'id' => 'node_nid' ,
'name field' => 'title' ,
'numeric' => TRUE ,
'validate type' => 'nid' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'id' => 'numeric' ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'standard' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_user' ][ 'uid' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Uid' ),
'help' => t ( 'The user ID of a user who touched the node (either created or commented on it).' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'user_name' ,
2017-04-13 14:53:35 +00:00
],
'argument' => [
2015-08-18 00:00:26 +00:00
'id' => 'user_uid' ,
'name field' => 'name' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Name' ),
'id' => 'user_name' ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'standard' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_user' ][ 'published' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Published' ),
'help' => t ( 'Whether or not the node is published. You must use an argument or filter on UID or you will get misleading results using this field.' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'boolean' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'id' => 'boolean' ,
'label' => t ( 'Published' ),
'type' => 'yes-no' ,
'accept null' => TRUE ,
'use_equal' => TRUE ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'standard' ,
2017-04-13 14:53:35 +00:00
],
];
$data [ 'tracker_user' ][ 'changed' ] = [
2015-08-18 00:00:26 +00:00
'title' => t ( 'Updated date' ),
'help' => t ( 'The date the node was last updated or commented on. You must use an argument or filter on UID or you will get misleading results using this field.' ),
2017-04-13 14:53:35 +00:00
'field' => [
2015-08-18 00:00:26 +00:00
'id' => 'date' ,
2017-04-13 14:53:35 +00:00
],
'sort' => [
2015-08-18 00:00:26 +00:00
'id' => 'date' ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'id' => 'date' ,
2017-04-13 14:53:35 +00:00
],
];
2015-08-18 00:00:26 +00:00
return $data ;
}
/**
* Implements hook_views_data_alter () .
*/
function tracker_views_data_alter ( & $data ) {
// Provide additional uid_touch handlers which are handled by tracker
2017-04-13 14:53:35 +00:00
$data [ 'node_field_data' ][ 'uid_touch_tracker' ] = [
2015-08-18 00:00:26 +00:00
'group' => t ( 'Tracker - User' ),
'title' => t ( 'User posted or commented' ),
'help' => t ( 'Display nodes only if a user posted the node or commented on the node.' ),
2017-04-13 14:53:35 +00:00
'argument' => [
2015-08-18 00:00:26 +00:00
'field' => 'uid' ,
'name table' => 'users_field_data' ,
'name field' => 'name' ,
'id' => 'tracker_user_uid' ,
'no group by' => TRUE ,
2017-04-13 14:53:35 +00:00
],
'filter' => [
2015-08-18 00:00:26 +00:00
'field' => 'uid' ,
'name table' => 'users_field_data' ,
'name field' => 'name' ,
'id' => 'tracker_user_uid'
2017-04-13 14:53:35 +00:00
],
];
2015-08-18 00:00:26 +00:00
}