Same name and namespace in other branches
  1. 4.6.x modules/book.module \book_menu()
  2. 4.7.x modules/book.module \book_menu()
  3. 6.x modules/book/book.module \book_menu()
  4. 7.x modules/book/book.module \book_menu()

Implementation of hook_menu().

File

modules/book/book.module, line 87
Allows users to collaboratively author a book.

Code

function book_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/content/book',
      'title' => t('Books'),
      'description' => t("Manage site's books and orphaned book pages."),
      'callback' => 'book_admin',
      'access' => user_access('administer nodes'),
    );
    $items[] = array(
      'path' => 'admin/content/book/list',
      'title' => t('List'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/content/book/orphan',
      'title' => t('Orphan pages'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'book_admin_orphan',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 8,
    );
    $items[] = array(
      'path' => 'book',
      'title' => t('Books'),
      'callback' => 'book_render',
      'access' => user_access('access content'),
      'type' => MENU_SUGGESTED_ITEM,
    );
    $items[] = array(
      'path' => 'book/export',
      'callback' => 'book_export',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
  }
  else {

    // Add the CSS for this module
    // We put this in !$may_cache so it's only added once per request
    drupal_add_css(drupal_get_path('module', 'book') . '/book.css');

    // To avoid SQL overhead, check whether we are on a node page and whether the
    // user is allowed to outline posts in books.
    if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('outline posts in books')) {

      // Only add the outline-tab for non-book pages:
      $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.type != 'book'"), arg(1));
      if (db_num_rows($result) > 0) {
        $items[] = array(
          'path' => 'node/' . arg(1) . '/outline',
          'title' => t('Outline'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'book_outline',
            arg(1),
          ),
          'access' => user_access('outline posts in books'),
          'type' => MENU_LOCAL_TASK,
          'weight' => 2,
        );
      }
    }
  }
  return $items;
}