You are here

function userpoints_menu in User Points 7.2

Same name and namespace in other branches
  1. 5.3 userpoints.module \userpoints_menu()
  2. 5 userpoints.module \userpoints_menu()
  3. 5.2 userpoints.module \userpoints_menu()
  4. 6 userpoints.module \userpoints_menu()
  5. 7 userpoints.module \userpoints_menu()

Implements hook_menu().

File

./userpoints.module, line 131

Code

function userpoints_menu() {
  $items = array();
  $items['admin/config/people/userpoints'] = array(
    'title' => '!Points',
    'title arguments' => userpoints_translation(),
    'description' => strtr('Manage !points', userpoints_translation()),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_admin_points',
    ),
    'access callback' => 'userpoints_admin_access',
    'access arguments' => array(
      'list',
    ),
    'file' => 'userpoints.admin.inc',
  );
  $items['admin/config/people/userpoints/list'] = array(
    'title' => 'Totals',
    'file' => 'userpoints.admin.inc',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -2,
  );
  $items['admin/config/people/userpoints/transaction'] = array(
    'title' => 'Transactions',
    'title arguments' => userpoints_translation(),
    'description' => 'List transactions',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_admin_transactions',
      FALSE,
    ),
    'access callback' => 'userpoints_admin_access',
    'access arguments' => array(
      'edit',
    ),
    'file' => 'userpoints.admin.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
  );
  $items['admin/config/people/userpoints/moderate'] = array(
    'title' => 'Moderation',
    'title arguments' => userpoints_translation(),
    'description' => strtr('Review !points in moderation', userpoints_translation()),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_admin_transactions',
      TRUE,
    ),
    'access callback' => 'userpoints_admin_access',
    'access arguments' => array(
      'moderate',
    ),
    'file' => 'userpoints.admin.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );
  $items['admin/config/people/userpoints/add'] = array(
    'title' => 'Add !points transaction',
    'title arguments' => userpoints_translation(),
    'description' => 'Admin add/delete userpoints',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_admin_txn',
      4,
      5,
    ),
    'access callback' => 'userpoints_admin_access',
    'access arguments' => array(
      'add',
    ),
    'file' => 'userpoints.admin.inc',
    'type' => MENU_LOCAL_ACTION,
  );
  $items['admin/config/people/userpoints/settings'] = array(
    'title' => '!Points settings',
    'description' => strtr('Settings for !points', userpoints_translation()),
    'title arguments' => userpoints_translation(),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_admin_settings',
    ),
    'access callback' => 'userpoints_admin_access',
    'access arguments' => array(
      'administer',
    ),
    'file' => 'userpoints.admin.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );
  $items['userpoints'] = array(
    'title' => 'Users by !points',
    'title arguments' => userpoints_translation(),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_list_users',
    ),
    'access arguments' => array(
      'view userpoints',
    ),
    'file' => 'userpoints.pages.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['userpoints/operation-autocomplete'] = array(
    'title' => 'Operation autocomplete',
    'page callback' => 'userpoints_operation_autocomplete',
    'access callback' => 'userpoints_admin_access',
    'access arguments' => array(
      'add',
    ),
    'file' => 'userpoints.admin.inc',
    'type' => MENU_CALLBACK,
  );
  $items['myuserpoints'] = array(
    'title' => 'My !points',
    'title arguments' => userpoints_translation(),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_list_transactions',
    ),
    'access callback' => 'userpoints_access_transactions',
    'file' => 'userpoints.pages.inc',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'user-menu',
  );
  $items['myuserpoints/%'] = array(
    'title' => 'My !points',
    'title arguments' => userpoints_translation(),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_list_transactions',
      NULL,
      1,
    ),
    'access callback' => 'userpoints_access_transactions',
    'file' => 'userpoints.pages.inc',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'user-menu',
  );
  $items['user/%user/points'] = array(
    'title' => '!Points',
    'title arguments' => userpoints_translation(),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'userpoints_list_transactions',
      1,
    ),
    'access callback' => 'userpoints_access_transactions',
    'access arguments' => array(
      1,
    ),
    'file' => 'userpoints.pages.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
  );

  // There are separate, duplicated local tasks for transactions in the
  // administrative area, myuserpoints and the userpoints of another user.
  // They all need to be created separately because local tasks must be menu
  // router items, but it can be done in a loop since the only difference is
  // the path prefix and position of the argument.
  $local_task_prefixes = array(
    'admin/config/people/userpoints/transaction',
    'myuserpoints/transaction',
    'user/%user/points',
  );
  foreach ($local_task_prefixes as $local_task_prefix) {

    // The dynamic argument is always the first after the prefix.
    $pos = count(explode('/', $local_task_prefix));
    $items[$local_task_prefix . '/list'] = array(
      'title' => 'List',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -15,
    );
    $items[$local_task_prefix . '/%userpoints_transaction/view'] = array(
      'title' => 'View',
      'page callback' => 'userpoints_view_transaction',
      'page arguments' => array(
        $pos,
      ),
      'access callback' => 'userpoints_access_view_transaction',
      'access arguments' => array(
        $pos,
      ),
      'file' => 'userpoints.pages.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => -10,
    );
    $items[$local_task_prefix . '/%userpoints_transaction/edit'] = array(
      'title' => 'Edit',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'userpoints_admin_txn',
        $pos + 1,
        $pos,
      ),
      'access callback' => 'userpoints_admin_access',
      'access arguments' => array(
        'edit',
      ),
      'file' => 'userpoints.admin.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => -5,
    );
    $items[$local_task_prefix . '/%userpoints_transaction/approve'] = array(
      'title' => 'Approve',
      'title arguments' => userpoints_translation(),
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'userpoints_confirm_approve',
        $pos + 1,
        $pos,
      ),
      'access callback' => 'userpoints_admin_access_transaction_pending',
      'access arguments' => array(
        $pos,
      ),
      'file' => 'userpoints.admin.inc',
      'type' => MENU_LOCAL_TASK,
    );
    $items['user/%user/points/%userpoints_transaction/decline'] = array(
      'title' => 'Decline',
      'title arguments' => userpoints_translation(),
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'userpoints_confirm_approve',
        $pos + 1,
        $pos,
      ),
      'access callback' => 'userpoints_admin_access_transaction_pending',
      'access arguments' => array(
        $pos,
      ),
      'file' => 'userpoints.admin.inc',
      'type' => MENU_LOCAL_TASK,
    );
  }
  return $items;
}