function _absolute_messages_visibility_roles in Absolute Messages 6
Same name and namespace in other branches
- 7 absolute_messages.module \_absolute_messages_visibility_roles()
Based on visibility setting this function returns TRUE if AM should be enabled for the current role or FALSE otherwise.
1 call to _absolute_messages_visibility_roles()
- theme_absolute_messages in ./
absolute_messages.module - Theme function, overriding Drupal's theme_status_messages().
File
- ./
absolute_messages.module, line 301 - Module displaying system messages in colored horizontal bars on top of the page, similar to Stack Overflow / Stack Exchange network notifications.
Code
function _absolute_messages_visibility_roles($account) {
$visibility = variable_get('absolute_messages_visibility_roles', 0);
$enabled = $visibility;
$roles = variable_get('absolute_messages_roles', array());
if (array_sum($roles) > 0) {
// One or more roles are selected.
foreach (array_keys($account->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 have AM enabled/disabled.
$enabled = !$visibility;
break;
}
}
}
else {
// No role is selected for tracking, therefore all roles should be tracked.
$enabled = TRUE;
}
return $enabled;
}