You are here

function comment_menu in Drupal 4

Same name and namespace in other branches
  1. 5 modules/comment/comment.module \comment_menu()
  2. 6 modules/comment/comment.module \comment_menu()
  3. 7 modules/comment/comment.module \comment_menu()

Implementation of hook_menu().

File

modules/comment.module, line 98
Enables users to comment on published content.

Code

function comment_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $access = user_access('administer comments');
    $items[] = array(
      'path' => 'admin/comment',
      'title' => t('comments'),
      'callback' => 'comment_admin_overview',
      'access' => $access,
    );

    // Tabs:
    $items[] = array(
      'path' => 'admin/comment/list',
      'title' => t('list'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/comment/configure',
      'title' => t('configure'),
      'callback' => 'comment_configure',
      'access' => $access,
      'type' => MENU_LOCAL_TASK,
    );

    // Subtabs:
    $items[] = array(
      'path' => 'admin/comment/list/new',
      'title' => t('published comments'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/comment/list/approval',
      'title' => t('approval queue'),
      'callback' => 'comment_admin_overview',
      'access' => $access,
      'callback arguments' => array(
        'approval',
      ),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/comment/configure/settings',
      'title' => t('settings'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'comment/delete',
      'title' => t('delete comment'),
      'callback' => 'comment_delete',
      'access' => $access,
      'type' => MENU_CALLBACK,
    );
    $access = user_access('post comments');
    $items[] = array(
      'path' => 'comment/edit',
      'title' => t('edit comment'),
      'callback' => 'comment_edit',
      'access' => $access,
      'type' => MENU_CALLBACK,
    );
  }
  else {
    if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
      $node = node_load(arg(2));
      if ($node->nid) {
        $items[] = array(
          'path' => 'comment/reply',
          'title' => t('reply to comment'),
          'callback' => 'comment_reply',
          'access' => node_access('view', $node),
          'type' => MENU_CALLBACK,
        );
      }
    }
    if (arg(0) == 'node' && is_numeric(arg(1)) && is_numeric(arg(2))) {
      $items[] = array(
        'path' => 'node/' . arg(1) . '/' . arg(2),
        'title' => t('view'),
        'callback' => 'node_page',
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}