You are here

function quotes_menu in Quotes 5

Same name and namespace in other branches
  1. 6 quotes.module \quotes_menu()
  2. 7 quotes.module \quotes_menu()

Implementation of hook_menu().

File

./quotes.module, line 69

Code

function quotes_menu($may_cache) {
  global $user;
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'node/add/quotes',
      'title' => t('Quotes'),
      'access' => user_access('create quotes') || user_access('import quotes') || user_access('edit own quotes'),
    );
    $items[] = array(
      'path' => 'node/add/quotes/add',
      'title' => t('Add'),
      'access' => user_access('create quotes') || user_access('edit own quotes'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'node/add/quotes/import',
      'title' => t('Import'),
      'access' => user_access('import quotes'),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'quotes',
      'title' => t('Quotes'),
      'access' => user_access('access content'),
      'callback' => '_quotes_page',
      'type' => MENU_SUGGESTED_ITEM,
    );
    $items[] = array(
      'path' => 'quotes/author',
      'title' => t('Quotes by author'),
      'access' => user_access('access content'),
      'callback' => 'quotes_author',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'quotes/feed',
      'title' => t('RSS feed'),
      'access' => user_access('access content'),
      'callback' => '_quotes_feed_last',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'quotes/autocomplete/author',
      'title' => 'Autocomplete Author Field',
      'access' => user_access('access quotes'),
      'callback' => '_quotes_autocomplete_author',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'quotes/autocomplete/citation',
      'title' => 'Autocomplete Citation Field',
      'access' => user_access('access quotes'),
      'callback' => '_quotes_autocomplete_citation',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/quotes',
      'title' => t('Quotes'),
      'description' => t('Configure Quotes module options and blocks.'),
      'access' => user_access('administer quotes'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        '_quotes_admin_settings',
      ),
    );
    $items[] = array(
      'path' => 'admin/settings/quotes/general',
      'title' => t('General'),
      'access' => user_access('administer quotes'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -1,
    );
    $items[] = array(
      'path' => 'admin/settings/quotes/blocks',
      'title' => t('Configure blocks'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        '_quotes_blocks',
      ),
      'access' => user_access('administer quotes'),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/quotes/export',
      'title' => t('Export'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'quotes_export',
      ),
      'access' => user_access('administer quotes'),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => BIOS_PATH,
      'title' => t('Bios'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'quotes_bios',
      ),
      'access' => user_access('administer quotes'),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/quotes/delete',
      'title' => t('Delete quote block'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        '_quotes_block_delete',
      ),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    drupal_add_css(drupal_get_path('module', 'quotes') . '/quotes.css');

    // User Edit quotes
    if (arg(0) == 'user' && is_numeric(arg(1))) {
      include drupal_get_path('module', 'quotes') . '/quotes.user.inc';
      $items[] = array(
        'path' => 'user/' . arg(1) . '/quotes',
        'title' => 'My Quotes',
        'callback' => 'quotes_user_page',
        'callback arguments' => array(
          arg(1),
        ),
        'access' => user_access('view my quotes'),
        'type' => MENU_LOCAL_TASK,
        'weight' => 2,
      );
    }
    $items[] = array(
      'path' => "quotes/{$user->uid}",
      'title' => t('My quotes'),
      'access' => $user->uid && (user_access('create quotes') || user_access('import quotes') || user_access('edit own quotes')),
      'type' => variable_get('quotes_show_myquotes', TRUE) ? MENU_NORMAL_ITEM : MENU_CALLBACK,
    );
  }
  return $items;
}