function yandex_metrics_show_counter_for_role in Yandex.Metrics 7
Same name and namespace in other branches
- 8.3 yandex_metrics.module \yandex_metrics_show_counter_for_role()
- 8.2 yandex_metrics.module \yandex_metrics_show_counter_for_role()
- 6.2 yandex_metrics.module \yandex_metrics_show_counter_for_role()
- 6 yandex_metrics.module \yandex_metrics_show_counter_for_role()
- 7.3 yandex_metrics.module \yandex_metrics_show_counter_for_role()
- 7.2 yandex_metrics.module \yandex_metrics_show_counter_for_role()
Returns FALSE if we need to disable counter for role.
Return value
bool
1 call to yandex_metrics_show_counter_for_role()
- yandex_metrics_page_build in ./
yandex_metrics.module - Implementation of hook_page_build(). Adds Yandex.Metrics counter code to the site footer. See http://drupal.org/node/224333#hook_footer
File
- ./
yandex_metrics.module, line 940 - The main code of Yandex.Metrics module.
Code
function yandex_metrics_show_counter_for_role() {
global $user;
$visibility = variable_get('yandex_metrics_visibility_roles', 0);
$enabled = $visibility;
$roles = variable_get('yandex_metrics_roles', array());
if (array_sum($roles) > 0) {
// One or more roles are selected.
foreach (array_keys($user->roles) as $rid) {
// Is the current user a member of one of these roles?
if (isset($roles[$rid]) && $rid == $roles[$rid]) {
// Current user is a member of a role that should be tracked/excluded from tracking.
$enabled = !$visibility;
break;
}
}
}
else {
// No role is selected for tracking, therefore all roles should be tracked.
$enabled = TRUE;
}
return $enabled;
}