You are here

function ad_notify_menu in Advertisement 5.2

Same name and namespace in other branches
  1. 5 notify/ad_notify.module \ad_notify_menu()
  2. 6 notify/ad_notify.module \ad_notify_menu()

Implementation of hook_menu().

File

notify/ad_notify.module, line 28
Receive email notifications regarding ads.

Code

function ad_notify_menu($may_cache) {
  $items = array();
  if (!$may_cache) {
    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'adowners' && is_numeric(arg(3))) {
      $node = node_load(array(
        'nid' => arg(1),
      ));
      $ad_user = user_load(array(
        'uid' => arg(3),
      ));
      if (isset($node->adtype) && isset($ad_user->uid)) {
        $items[] = array(
          'path' => "node/{$node->nid}/adowners/{$ad_user->uid}/notifications",
          'title' => t('!owner\'s notifications', array(
            '!owner' => $ad_user->name,
          )),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'ad_notify_overview',
            $node->nid,
            $ad_user->uid,
          ),
          'type' => MENU_LOCAL_TASK,
          'weight' => 4,
        );
      }
    }
    if (arg(0) == 'node' && is_numeric(arg(1)) && (ad_permission(arg(1), 'manage own notifications') || ad_permission(arg(1), 'manage owners'))) {
      global $user;
      $node = node_load(array(
        'nid' => arg(1),
      ));

      // Only display "my notifications" tab if this is an ad, and we are one
      // of the ad's owners.
      if (isset($node->adtype) && db_result(db_query('SELECT oid FROM {ad_owners} WHERE aid = %d AND uid = %d', $node->nid, $user->uid))) {
        $items[] = array(
          'path' => "node/{$node->nid}/notifications",
          'title' => t('My notifications'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'ad_notify_overview',
            $node->nid,
            $user->uid,
          ),
          'type' => MENU_LOCAL_TASK,
          'weight' => 4,
        );
        if (is_numeric(arg(5)) && arg(6) == 'delete') {
          $notid = arg(5);
          $items[] = array(
            'path' => "node/{$node->nid}/adowners/{$ad_user->uid}/notifications/{$notid}/delete",
            'title' => t('delete notification'),
            'callback' => 'ad_notify_confirm_delete_page',
            'callback arguments' => array(
              ad_notify_load_notification($notid),
              $node->nid,
              $ad_user->uid,
            ),
            'type' => MENU_CALLBACK,
          );
        }
      }
    }
  }
  return $items;
}