function webmaster_menu_enabled in Webmaster menu 7
Determines if user has access to webmaster menu
2 calls to webmaster_menu_enabled()
- webmaster_menu_overlay_child_initialize in ./
webmaster_menu.module - Implementation of hook_overlay_child_initialize();
- webmaster_menu_page_alter in ./
webmaster_menu.module - Implements hook_page_alter().
File
- ./
webmaster_menu.module, line 28 - Display a dropdown menu at the top of the window.
Code
function webmaster_menu_enabled() {
global $user;
// Determine if the "webmaster_menu_show_root" setting grants access
if ((int) $user->uid === 1 && (bool) variable_get('webmaster_menu_show_root', 1)) {
return TRUE;
}
// Determine if the "webmaster_menu_show_roles" setting grants access
// This is done by intersecting the roles that are enabled in webmaster menu
// settings with the roles that the current user has (plus anonymous).
$enabled_roles = variable_get('webmaster_menu_roles', array());
$user_roles = array_keys($user->roles);
// Add anonymous (role id: 1)
array_push($user_roles, 1);
$matched_roles = array_intersect($enabled_roles, $user_roles);
return !empty($matched_roles);
}