You are here

function signup_menu in Signup 5

Same name and namespace in other branches
  1. 5.2 signup.module \signup_menu()
  2. 6.2 signup.module \signup_menu()
  3. 6 signup.module \signup_menu()
  4. 7 signup.module \signup_menu()

Implementation of hook_menu().

Related topics

File

./signup.module, line 151

Code

function signup_menu($may_cache) {
  global $user;
  $items = array();
  $access = user_access('administer all signups');
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/signup',
      'description' => t('Configure settings for signups.'),
      'access' => $access,
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'signup_settings_page',
      ),
      'title' => user_access('access administration pages') ? t('Signup') : t('Signup settings'),
    );
    $items[] = array(
      'path' => 'admin/content/signup',
      'description' => t('View all signup-enabled posts, and open or close signups on them.'),
      'access' => $access,
      'callback' => 'signup_admin_page',
      'title' => t('Signup administration'),
    );

    // Callbacks to open and close signups on a specific node.
    $items[] = array(
      'path' => 'closesignup',
      'access' => $access,
      'type' => MENU_CALLBACK,
      'callback' => 'signup_close_signup_admin',
    );
    $items[] = array(
      'path' => 'opensignup',
      'access' => $access,
      'type' => MENU_CALLBACK,
      'callback' => 'signup_open_signup_admin',
    );
  }
  else {

    // !$may_cache: dynamic menu items
    // Include other php code that we need when not serving cached pages:
    require_once drupal_get_path('module', 'signup') . '/signup.theme';

    // User signup schedule callback
    $items[] = array(
      'path' => 'user/' . arg(1) . '/signups',
      'access' => $access || $user->uid == arg(1),
      'type' => MENU_CALLBACK,
      'callback' => 'signup_user_schedule',
      'callback arguments' => array(
        $uid => arg(1),
      ),
    );

    // If it's a signup-enabled node, then put in a signup tab for admins.
    if (arg(0) == 'node' && is_numeric(arg(1)) && db_num_rows(db_query("SELECT nid FROM {signup} WHERE nid = %d", arg(1)))) {
      $node = node_load(array(
        'nid' => arg(1),
      ));
      $access_own = user_access('administer signups for own content') && $user->uid == $node->uid;
      $items[] = array(
        'path' => 'node/' . arg(1) . '/signups',
        'title' => t('Signups'),
        'callback' => 'signup_user_signups_form',
        'callback arguments' => array(
          $node,
        ),
        'access' => $access || $access_own,
        'type' => MENU_LOCAL_TASK,
        'weight' => 20,
      );
    }
  }
  return $items;
}