rsvp_menu

Definition

rsvp_menu($may_cache)
rsvp/rsvp.module, line 77

Description

Implementation of hook_menu().

Code

<?php
function rsvp_menu($may_cache) {
  global $user;
  $items = array();

  if ($may_cache) {
    // user account tabs
    if ($user->uid != 0) {
      $items[] = array('path' => 'user/'. $user->uid .'/rsvp',
                       'title' => t('RSVP'),
                       'access' => user_access('access content'),
                       'callback' => 'rsvp_view_invites',
                       'type' => MENU_LOCAL_TASK,
                     );
      $items[] = array('path' => 'user/'. $user->uid .'/rsvp/invites',
                       'title' => t('Your invites'),
                       'access' => user_access('access content'),
                       'type' => MENU_DEFAULT_LOCAL_TASK,
                       'weight' => '0');
      $items[] = array('path' => 'user/'. $user->uid .'/rsvp/manage',
                       'title' => t('Your RSVPs'),
                       'access' => user_access('access content'),
                       'callback' => 'rsvp_manage',
                       'type' => MENU_LOCAL_TASK,
                       'weight' => '1');
    }

  }
  else {
    drupal_set_html_head(_rsvp_html_head());
    // email response path
    $items[] = array('path' => 'rsvp/email',
                     'title' => t('View invite'),
                     'callback' => 'rsvp_view_invite',
                     'callback arguments' => array(arg(2), arg(3)),
                     'access' => user_access('access content'),
                     'type' => MENU_CALLBACK);

    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $nid = arg(1);
      $node = node_load($nid);
      $rid = arg(3);
      $access = (user_access('administer rsvp') || user_access('rsvp on events') || ($node->uid == $user->uid && user_access('rsvp on own events')));
      if (event_is_enabled($node->type)) {
        // define access rights
        // viewing tabs
        $items[] = array('path' => 'node/'. $nid .'/rsvp',
                         'title' => t('RSVP'),
                         'access' => $access,
                         'type' => MENU_LOCAL_TASK,
                         'callback' => 'rsvp_manage',
                         'callback arguments' => array($nid),
                         'weight' => 3,
                       );
        $items[] = array('path' => 'node/'. $nid .'/rsvp/create',
                         'title' => t('Create RSVP'),
                         'access' => $access,
                         'callback' => 'drupal_get_form',
                         'callback arguments' => array('rsvp_addedit_form', $nid),
                         'type' => MENU_CALLBACK);
        // management tabs
        if (is_numeric($rid)) {
          // rsvp paths
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/view',
                           'title' => t('View'),
                           'access' => $access,
                           'callback' => 'rsvp_view',
                           'callback arguments' => array($rid),
                           'type' => MENU_LOCAL_TASK,
                           'weight' => '0');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/edit',
                           'title' => t('Edit'),
                           'access' => $access,
                           'callback' => 'drupal_get_form',
                           'callback arguments' => array('rsvp_addedit_form', $nid, $rid),
                           'type' => MENU_LOCAL_TASK,
                           'weight' => '1');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/attendees',
                           'title' => t('Manage attendees'),
                           'access' => $access,
                           'callback' => 'rsvp_attendees',
                           'callback arguments' => array($rid),
                           'type' => MENU_LOCAL_TASK,
                           'weight' => '2');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/attendees/send',
                           'title' => t('Send invites'),
                           'access' => $access,
                           'callback' => 'rsvp_attendees_send_invites',
                           'callback arguments' => array($rid, 'node/'. $nid .'/rsvp/'. $rid .'/attendees'),
                           'type' => MENU_CALLBACK,
                           'weight' => '2');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/attendees/csv',
                           'title' => t('manage attendees'),
                           'access' => $access,
                           'callback' => 'rsvp_attendees_csv',
                           'callback arguments' => array($rid),
                           'type' => MENU_CALLBACK,
                           'weight' => '2');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/attendees/simplenews',
                           'access' => ($access && user_access('rsvp newsletters subscribers')),
                           'callback' => 'rsvp_attendees_simplenews',
                           'callback arguments' => array(arg(6)),
                           'type' => MENU_CALLBACK,
                           'weight' => '2');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/attendees/role',
                           'access' => ($access && user_access('rsvp system users')),
                           'callback' => 'rsvp_attendees_users',
                           'callback arguments' => array(arg(6)),
                           'type' => MENU_CALLBACK,
                           'weight' => '2');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/message',
                           'title' => t('Send message'),
                           'access' => $access,
                           'callback' => 'drupal_get_form',
                           'callback arguments' => array('rsvp_message_form', $rid),
                           'type' => MENU_LOCAL_TASK,
                           'weight' => '3');
          $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/delete',
                           'title' => t('Delete RSVP'),
                           'access' => $access,
                           'callback' => 'drupal_get_form',
                           'callback arguments' => array('rsvp_delete_form', $rid),
                           'type' => MENU_CALLBACK);
        }
      }
    }

  }
  return $items;
}
?>