function bootstrap_tour_access in Bootstrap Tour 7.2
Checks access for user for tour.
Parameters
Loaded tour event.:
$account: An account object, default to current user.
Return value
True if user has access, false if they don't.
1 call to bootstrap_tour_access()
- bootstrap_tour_run_tour in ./
bootstrap_tour.module - Helper function to actually run a tour. Can be called from anywhere.
File
- ./
bootstrap_tour.module, line 410 - bootstrap_tour.module
Code
function bootstrap_tour_access($tour, $account = NULL) {
if (!$account) {
global $user;
$account = $user;
}
if (empty($tour) || empty($tour->enabled)) {
return FALSE;
}
$access = TRUE;
if ($account->uid != 1 && !empty($tour->roles)) {
// Compare the tour's roles to the user's roles and if there aren't any overlaps and
// the user isn't user 1, cancel running the tour.
$tour_roles = explode(',', $tour->roles);
$account_roles = array_keys($account->roles);
$compare = array_intersect($tour_roles, $account_roles);
if (empty($compare)) {
$access = FALSE;
}
}
$access_array = module_invoke_all('bootstrap_tour_access', $tour, $account, $access);
return !in_array(FALSE, $access_array, TRUE) && $access;
}