function views_accelerator_analyse in Views Accelerator 7
Special message display function. Messages to selected user names only.
Parameters
string $message: The message string to be output as a message. Use NULL to test if messages are on for the current user.
string $type: Message type. Defaults to 'status'.
string $repeat: Whether to repeat identical messages. Defaults to TRUE.
Return value
bool|array FALSE if messages are disabled for the current user. TRUE if enabled for the current user without a message argument, otherwise a multi-dimensional array with keys corresponding to the set message types. The array contains the set messages for each message type.
See also
2 calls to views_accelerator_analyse()
- views_accelerator_page_alter in ./
views_accelerator.module - Implements hook_page_alter().
- views_accelerator_views_post_render in ./
views_accelerator.module - Implements hook_views_post_render().
File
- ./
views_accelerator.module, line 423 - Views Accelerator module.
Code
function views_accelerator_analyse($message = NULL, $type = 'status', $repeat = TRUE) {
$analysis_level = (int) variable_get('views_accelerator_analysis_level', 0);
if (!$analysis_level) {
return FALSE;
}
global $user;
// Check if the current user qualifies based on their role.
// Cannot use user_access() as it will always return TRUE for uid==1
foreach (user_role_permissions($user->roles) as $role_permissions) {
if (in_array('views accelerator view analyse mode', array_keys($role_permissions))) {
// Yes, user qualifies. Set msg if there is one, otherwise return level.
return $message ? drupal_set_message($message, $type, $repeat) : $analysis_level;
}
}
// If user does not qualify by role, see if their name is white-listed.
$user_names = explode(',', check_plain(variable_get('views_accelerator_priv_users')));
foreach ($user_names as $user_name) {
$user_name = drupal_strtolower(trim($user_name));
$match = $user->uid ? $user_name == drupal_strtolower(trim($user->name)) : $user_name == 'anon' || $user_name == 'anonymous';
if ($match) {
return $message ? drupal_set_message($message, $type, $repeat) : $analysis_level;
}
}
return FALSE;
}