function piwik_stats_tab_page_access in Piwik Statistic Integration 7.2
Statistics tab page access callback.
1 string reference to 'piwik_stats_tab_page_access'
- piwik_stats_menu in ./
piwik_stats.module - Implements hook_menu().
File
- ./
piwik_stats.module, line 110 - Integrates piwik statistics as entity fields.
Code
function piwik_stats_tab_page_access($entity_type, $entity) {
// Check whether the user is allowed to view the statistics page.
if (!user_access('access piwik information')) {
return FALSE;
}
// Extract entity bundle (type).
$ids = entity_extract_ids($entity_type, $entity);
// Get fields of this bundle.
$fields = field_info_instances($entity_type, $ids[2]);
// Count how many piwik fields exist and are visible for this bundle.
$visible_fields = 0;
foreach (array_keys($fields) as $field_name) {
// Get field information.
$field = field_info_field($field_name);
// A piwik field?
if ($field['type'] == 'piwik_stats') {
// If the "show in statistics page" setting is available,
// check its value. Otherwise the default is visible.
if ($field['settings']['show_in_statistics_page']) {
$visible_fields++;
}
}
}
return $visible_fields > 0;
}