You are here

function invite_menu in Invite 5.2

Same name and namespace in other branches
  1. 5 invite.module \invite_menu()
  2. 6.2 invite.module \invite_menu()
  3. 7.4 invite.module \invite_menu()
  4. 7.2 invite.module \invite_menu()

Implementation of hook_menu().

File

./invite.module, line 94
Allows your users to send and track invitations to join your site.

Code

function invite_menu($may_cache) {
  global $user;
  $items = array();
  $send_access = user_access('send invitations');
  $track_access = user_access('track invitations');
  $admin_access = user_access('administer invitations');
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/user/invite',
      'title' => t('Invites'),
      'callback' => 'invite_admin_overview',
      'access' => $admin_access,
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/user/invite/list',
      'title' => t('Inviters'),
      'access' => $admin_access,
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -5,
    );
    $items[] = array(
      'path' => 'admin/user/invite/settings',
      'title' => t('Settings'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'invite_settings',
      'access' => $admin_access,
      'type' => MENU_LOCAL_TASK,
      'weight' => 5,
    );
    $items[] = array(
      'path' => 'invite',
      'title' => variable_get('invite_page_title', t('Invite a friend')),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'invite_form',
        'page',
        array(),
      ),
      'access' => $send_access,
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'invite/accept',
      'callback' => 'invite_controller',
      'access' => TRUE,
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'invite/withdraw',
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'invite_cancel',
      ),
      'access' => $track_access,
      'type' => MENU_CALLBACK,
    );
  }
  else {

    // Notify current user about newly joined invitees.
    if (!empty($user->invite_sent) && !module_invoke('throttle', 'status')) {
      invite_notify($user->uid);
    }
    if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) == $user->uid) {
      $items[] = array(
        'path' => 'user/' . arg(1) . '/invites',
        'title' => t('Invitations'),
        'callback' => 'invite_user_overview',
        'access' => $track_access,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'user/' . arg(1) . '/invites/accepted',
        'title' => t('Accepted'),
        'callback' => 'invite_user_overview',
        'callback arguments' => array(
          'accepted',
        ),
        'access' => $track_access,
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'weight' => -5,
      );
      $items[] = array(
        'path' => 'user/' . arg(1) . '/invites/pending',
        'title' => t('Pending'),
        'callback' => 'invite_user_overview',
        'callback arguments' => array(
          'pending',
        ),
        'access' => $track_access,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'user/' . arg(1) . '/invites/expired',
        'title' => t('Expired'),
        'callback' => 'invite_user_overview',
        'callback arguments' => array(
          'expired',
        ),
        'access' => $track_access,
        'type' => MENU_LOCAL_TASK,
        'weight' => 5,
      );
      $items[] = array(
        'path' => 'user/' . arg(1) . '/invites/new',
        'title' => t('New invitation'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'invite_form',
          'page',
          array(),
        ),
        'access' => $send_access,
        'type' => MENU_LOCAL_TASK,
        'weight' => 10,
      );
    }
    else {
      if (arg(2) == 'invite' && arg(3) == 'details' && arg(4)) {
        if ($account = user_load(array(
          'uid' => arg(4),
        ))) {
          $items[] = array(
            'path' => 'admin/user/invite/details/' . arg(4),
            'title' => t('Invitees of @name', array(
              '@name' => $account->name,
            )),
            'callback' => 'invite_admin_details',
            'callback arguments' => array(
              arg(4),
            ),
            'access' => $admin_access,
            'type' => MENU_LOCAL_TASK,
          );
        }
      }
      else {
        if (arg(0) == 'invite' && arg(1) == 'resend' && arg(2)) {
          $items[] = array(
            'path' => 'invite/resend/' . arg(2),
            'title' => t('Resend invitation'),
            'callback' => 'invite_resend',
            'callback arguments' => array(
              arg(2),
            ),
            'access' => $send_access,
            'type' => MENU_CALLBACK,
          );
        }
      }
    }
  }
  return $items;
}