function _googleanalytics_visibility_roles in Google Analytics 5
Same name and namespace in other branches
- 6.4 googleanalytics.module \_googleanalytics_visibility_roles()
- 6 googleanalytics.module \_googleanalytics_visibility_roles()
- 6.2 googleanalytics.module \_googleanalytics_visibility_roles()
- 6.3 googleanalytics.module \_googleanalytics_visibility_roles()
- 7.2 googleanalytics.module \_googleanalytics_visibility_roles()
- 7 googleanalytics.module \_googleanalytics_visibility_roles()
Based on visibility setting this function returns TRUE if GA code should be added for the current role and otherwise FALSE.
2 calls to _googleanalytics_visibility_roles()
- googleanalytics_user in ./
googleanalytics.module - Implementation of hook_user().
- _googleanalytics_visibility_user in ./
googleanalytics.module - Tracking visibility check for an user object.
File
- ./
googleanalytics.module, line 622
Code
function _googleanalytics_visibility_roles($account) {
$enabled = FALSE;
$roles = variable_get('googleanalytics_roles', array());
if (array_sum($roles) > 0) {
// One or more roles are selected for tracking.
foreach (array_keys($account->roles) as $rid) {
// Is the current user a member of one role enabled for tracking?
if (isset($roles[$rid]) && $rid == $roles[$rid]) {
// Current user is a member of a role that should be tracked.
$enabled = TRUE;
break;
}
}
}
else {
// No role is selected for tracking, therefor all roles should be tracked.
$enabled = TRUE;
}
return $enabled;
}