function _homebox_user_access_view_homebox in Homebox 6.3
Same name and namespace in other branches
- 6.2 homebox.module \_homebox_user_access_view_homebox()
- 7.3 homebox.module \_homebox_user_access_view_homebox()
- 7.2 homebox.module \_homebox_user_access_view_homebox()
Helper function to check if the current user can view a given homebox page
Parameters
$page: A page object
4 calls to _homebox_user_access_view_homebox()
- homebox_edit_access in ./
homebox.module - Check that a request is logged-in, has access to view the homebox, and has a valid token. Use tokens from homebox_get_token().
- homebox_og_override_group in homebox_og/
homebox_og.module - Override a group's homepage with a homebox
- _homebox_og_user_access_view_homebox in homebox_og/
homebox_og.module - Determine if a user can access the Homebox
- _homebox_user_access_view_user_homebox in ./
homebox.module - Helper function to check access permissions for user profile Homebox
1 string reference to '_homebox_user_access_view_homebox'
- homebox_menu in ./
homebox.module - Implementation of hook_menu().
File
- ./
homebox.module, line 1464 - Homebox main file, takes care of global functions settings constants, etc.
Code
function _homebox_user_access_view_homebox($page, $require_login = FALSE) {
global $user;
if ($require_login && !$user->uid) {
return FALSE;
}
// Admin is always allowed
if (user_access('administer site configuration') || user_access('administer homebox')) {
return TRUE;
}
elseif (!$page->settings['enabled']) {
return FALSE;
}
elseif ($page->settings['roles']) {
// Iterate each role to look for a match
foreach ($page->settings['roles'] as $role) {
if (array_search($role, $user->roles)) {
return TRUE;
}
}
// No matches on restricted role
return FALSE;
}
else {
// If here, no access
return FALSE;
}
}