function _signup_menu_access in Signup 6
Same name and namespace in other branches
- 6.2 signup.module \_signup_menu_access()
- 7 signup.module \_signup_menu_access()
Determine menu access for a given type of signup menu item.
This ensures that the node is signup enabled, and that that the current user should have permission to view the requested menu item type.
Parameters
$node: The fully loaded node object from the menu autoloader.
$menu_type: String specifying what kind of menu item to test access for. Can be: 'signup': the signup form 'list': the signup attendee listing 'list-tab': the signup attendee listing tab 'admin': the signup administration tab 'add': the signup administration tab to add other users (requires that signups are currently open on the given node). 'broadcast': for the broadcast tab 'any': if the user has permission to see any of these
Return value
TRUE if the current node is signup enabled and the current user has permisison to access to requested menu item, otherwise FALSE.
See also
6 calls to _signup_menu_access()
- signup_confirm_email_alter_signup_form in modules/
signup_confirm_email/ signup_confirm_email.inc - Alter the signup form to add the e-mail confirmation functionality.
- signup_edit_form in includes/
signup_edit_form.inc - Build the form for editing existing signups.
- signup_handler_field_signup_node_link::check_access in views/
handlers/ signup_handler_field_signup_node_link.inc - signup_node_tab_page in ./
signup.module - Menu callback to handle the default tab at node/N/signups
- signup_user_list_output in includes/
node_output.inc - Helper function to generate the list of users signed up for a node.
1 string reference to '_signup_menu_access'
- signup_menu in ./
signup.module - Implementation of hook_menu().
File
- ./
signup.module, line 438 - The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…
Code
function _signup_menu_access($node, $menu_type = 'node') {
global $user;
// If the node isn't signup enabled, immediately return failure.
if (empty($node->signup)) {
return FALSE;
}
// For certain menu types, invoke a hook to allow other modules to alter the
// access behavior for signup menu items. Just relying on hook_menu_alter()
// for this won't work, since there are places outside of the menu system,
// where we call this function to decide if a user should have access to
// something. If multiple modules return a value, the logical OR is used, so
// if anyone returns TRUE, access is granted.
if (in_array($menu_type, array(
'signup',
'list',
'admin',
'add',
'broadcast',
))) {
$access_array = module_invoke_all('signup_menu_access', $node, $menu_type);
if (!empty($access_array)) {
// Return TRUE if any values are TRUE, otherwise, FALSE.
return in_array(TRUE, $access_array);
}
}
// No module returned a value in hook_signup_menu_access, so continue with
// the main logic.
switch ($menu_type) {
case 'signup':
// See if this user can signup, if the node is configured to display the
// signup form on a separate tab, and if the node has signup output.
return user_access('sign up for content') && variable_get('signup_form_location', 'node') == 'tab' && _signup_needs_output($node);
case 'list':
return user_access('view all signups') || _signup_menu_access($node, 'admin');
case 'list-tab':
// See if this user can view signups, and if the site is configured to
// display the signup user list as a tab.
$user_list = variable_get('signup_display_signup_user_list', 'embed-view');
if ($user_list == 'embed-view-tab') {
$user_list_tab = TRUE;
}
else {
$user_list_tab = FALSE;
}
$list_access = _signup_menu_access($node, 'list');
return $list_access && $user_list_tab && _signup_needs_output($node);
case 'admin':
$admin_all = user_access('administer all signups');
$admin_own = user_access('administer signups for own content') && $user->uid == $node->uid;
return $admin_all || $admin_own;
case 'add':
return $node->signup_status && _signup_menu_access($node, 'admin');
case 'broadcast':
$email_all = user_access('email all signed up users');
$email_own = user_access('email users signed up for own content') && $user->uid == $node->uid;
return $email_all || $email_own;
case 'any':
$signup = _signup_menu_access($node, 'signup');
$list = _signup_menu_access($node, 'list-tab');
$admin = _signup_menu_access($node, 'admin');
$email = _signup_menu_access($node, 'broadcast');
return $signup || $list || $admin || $email;
}
}