function flag_views_data_alter in Flag 7.3
Same name and namespace in other branches
- 8.4 flag.views.inc \flag_views_data_alter()
- 6.2 includes/flag.views.inc \flag_views_data_alter()
- 6 includes/flag.views.inc \flag_views_data_alter()
- 7.2 includes/flag.views.inc \flag_views_data_alter()
Implements hook_views_data_alter().
File
- includes/
views/ flag.views.inc, line 206 - Provides support for the Views module.
Code
function flag_views_data_alter(&$data) {
foreach (array_keys(flag_fetch_definition()) as $flag_type) {
$flag = flag_flag::factory_by_entity_type($flag_type);
$info = $flag
->get_views_info();
if (!isset($info)) {
continue;
}
if (!empty($info['join field'])) {
// Add the flag relationship.
$data[$info['views table']]['flag_content_rel'] = array(
'group' => t('Flags'),
'title' => $info['title'],
'help' => $info['help'],
'relationship' => array(
'flag type' => $flag_type,
'handler' => 'flag_handler_relationship_content',
'label' => t('flag'),
'base' => 'flagging',
'base field' => 'entity_id',
'relationship field' => $info['join field'],
),
);
// Add the flag counter relationship.
$data[$info['views table']]['flag_count_rel'] = array(
'group' => t('Flags'),
'title' => $info['counter title'],
'help' => $info['counter help'],
'relationship' => array(
'flag type' => $flag_type,
'handler' => 'flag_handler_relationship_counts',
'label' => t('counter'),
'base' => 'flag_counts',
'base field' => 'entity_id',
'relationship field' => $info['join field'],
),
);
}
}
// Add a relationship for the user that flagged any type of content.
$data['users']['flag_user_content_rel'] = array(
'group' => t('Flags'),
'title' => t("User's flaggings"),
'help' => t('Relate users to the flaggings they have made on objects, using a particular flag.'),
'relationship' => array(
'base' => 'flagging',
'base field' => 'uid',
'relationship field' => 'uid',
'handler' => 'flag_handler_relationship_user_content',
'label' => t('user flagged content'),
),
);
}