You are here

function vote_up_down_menu in Vote Up/Down 5

Same name and namespace in other branches
  1. 6 vote_up_down.module \vote_up_down_menu()

Implementation of hook_menu().

File

./vote_up_down.module, line 142
vote_up_down is a module that adds a widget for +1/-1 votes on nodes. It depends upon Voting API. It's based upon "simplevote.module".

Code

function vote_up_down_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/voteupdown',
      'title' => t('Vote up/down'),
      'description' => t('Control the functions of Vote up/down.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'vote_up_down_admin_settings',
      'access' => user_access('administer up-down vote'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'vote_up_down',
      'title' => t('Vote on content'),
      'callback' => 'vote_up_down_vote',
      'access' => user_access('use up-down vote'),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    $items[] = array(
      'path' => 'voteupdown',
      'title' => t('Vote up/down'),
      'description' => t('Vote up/down vote summaries.'),
      'callback' => 'vote_up_down_page',
      'access' => user_access('access up-down vote statistic'),
    );
    $items[] = array(
      'path' => 'voteupdown/usersvotes',
      'title' => t('Users by votes'),
      'callback' => 'vote_up_down_page',
      'access' => user_access('access up-down vote statistic'),
    );
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      $vote_access = user_access('access up-down vote statistic') && in_array($node->type, variable_get('vote_up_down_node_types', array()), TRUE);
      $items[] = array(
        'path' => 'node/' . arg(1) . '/votesupdown',
        'title' => t('Votes'),
        'callback' => 'vote_up_down_tracker',
        'access' => $vote_access,
        'weight' => 5,
        'type' => MENU_LOCAL_TASK,
      );
    }
    if (arg(0) == 'user' && is_numeric(arg(1))) {
      $items[] = array(
        'path' => 'user/' . arg(1) . '/votesupdown',
        'title' => t('Votes'),
        'callback' => 'vote_up_down_user_votes',
        'access' => user_access('access up-down vote statistic'),
        'weight' => 5,
        'type' => MENU_LOCAL_TASK,
      );
    }
    drupal_add_css(drupal_get_path('module', 'vote_up_down') . '/vote_up_down.css');
    drupal_add_js(drupal_get_path('module', 'vote_up_down') . '/ajax_vote_up_down.js');
  }
  return $items;
}