You are here

function notifications_menu in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications.module \notifications_menu()
  2. 6 notifications.module \notifications_menu()
  3. 6.2 notifications.module \notifications_menu()
  4. 6.3 notifications.module \notifications_menu()
  5. 7 notifications.module \notifications_menu()

Implementation of hook_menu().

File

./notifications.module, line 32
Notifications module

Code

function notifications_menu($may_cache) {
  global $user;

  // we need the user to to build some urls
  if ($may_cache) {

    // Administration. Override messaging main item
    $items[] = array(
      'title' => t('Messaging & Notifications'),
      'path' => 'admin/messaging',
      'callback' => 'messaging_admin_overview_page',
      'access' => user_access('administer messaging') || user_access('administer notifications'),
      'description' => t('Administration of messaging and notifications'),
    );

    // Notifications settings
    $items[] = array(
      'path' => 'admin/messaging/notifications',
      'title' => t('Notifications settings'),
      'description' => t('Site settings for user notifications.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'notifications_settings_form',
      'access' => user_access('administer site configuration'),
    );
    $items[] = array(
      'path' => 'admin/messaging/notifications/settings',
      'title' => t('Settings'),
      'weight' => -10,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );

    /*
    $items[] = array(
      'path' => 'admin/messaging/notifications/subscriptions',
      'title' => t('Subscription types'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'notifications_admin_subscriptions_form',
      'type' => MENU_LOCAL_TASK,
    );
    */
    $items[] = array(
      'path' => 'admin/messaging/notifications/intervals',
      'title' => t('Intervals'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'notifications_send_intervals_form',
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/messaging/notifications/events',
      'title' => t('Events'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'notifications_admin_events_form',
      'type' => MENU_LOCAL_TASK,
    );

    // Notifications status and queue management
    $items[] = array(
      'path' => 'admin/messaging/notifications-status',
      'title' => t('Notifications status'),
      'description' => t('Manage notifications status queue'),
      'callback' => 'notifications_admin_status_page',
      'access' => user_access('administer notifications'),
    );
    $items[] = array(
      'path' => 'admin/messaging/notifications-status/overview',
      'title' => t('Overview'),
      'description' => t('Notifications queue overview.'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/messaging/notifications-status/queue',
      'title' => t('Queue'),
      'description' => t('Manage notifications queue.'),
      'callback' => 'notifications_admin_queue',
      'type' => MENU_LOCAL_TASK,
    );

    // Subscribe links. For this items access will be checked later in the page
    $items[] = array(
      'path' => 'notifications/subscribe',
      'type' => MENU_CALLBACK,
      'callback' => 'notifications_page_subscribe',
      'access' => $user->uid,
    );

    // Unsubscribe links This page will need to work with anonymous users
    $items[] = array(
      'path' => 'notifications/unsubscribe',
      'type' => MENU_CALLBACK,
      'callback' => 'notifications_page_unsubscribe',
      'access' => TRUE,
    );
  }
  else {
    if (arg(0) == 'notifications' || arg(1) == 'notifications' || arg(2) == 'notifications' || arg(2) == 'notifications-status') {
      include_once drupal_get_path('module', 'notifications') . '/notifications.admin.inc';
    }
    if ($user->uid && arg(0) == 'user' && is_numeric(arg(1)) && ($user->uid == arg(1) && user_access('maintain own subscriptions') || user_access('administer notifications'))) {
      $account = $user->uid == arg(1) ? $user : user_load(array(
        'uid' => arg(1),
      ));
      $items[] = array(
        'path' => 'user/' . $account->uid . '/notifications',
        'type' => MENU_LOCAL_TASK,
        'title' => t('Notifications'),
        'callback' => 'notifications_page_user_overview',
        'callback arguments' => array(
          $account,
        ),
      );
      $items[] = array(
        'path' => 'user/' . $account->uid . '/notifications/overview',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'title' => t('Overview'),
        'weight' => -10,
      );
    }
  }
  return $items;
}