You are here

function user_badges_menu in User Badges 5

Same name and namespace in other branches
  1. 6.2 user_badges.module \user_badges_menu()
  2. 6 user_badges.module \user_badges_menu()
  3. 7.4 user_badges.module \user_badges_menu()
  4. 7 user_badges.module \user_badges_menu()
  5. 7.2 user_badges.module \user_badges_menu()
  6. 7.3 user_badges.module \user_badges_menu()

Implementation of hook_menu().

File

./user_badges.module, line 53
@brief User Badges module file

Code

function user_badges_menu($may_cache) {
  $access = user_access('manage badges');
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/user/user_badges',
      'title' => t('Badges'),
      'callback' => 'user_badges_settings_page',
      'access' => $access,
    );
  }
  else {
    $items[] = array(
      'path' => 'admin/user/user_badges/list',
      'title' => t('Edit user badges'),
      'access' => $access,
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/user/user_badges/images',
      'title' => t('Images'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'user_badges_images_form',
      ),
      'access' => $access,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/user/user_badges/roles',
      'title' => t('Roles'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'user_badges_roles_form',
      ),
      'access' => $access,
      'type' => MENU_LOCAL_TASK,
    );
    if (module_exists('product')) {
      $items[] = array(
        'path' => 'admin/user/user_badges/products',
        'title' => t('Products'),
        'callback' => 'user_badges_products_page',
        'weight' => 8,
        'access' => $access,
        'type' => MENU_LOCAL_TASK,
      );
    }
    $items[] = array(
      'path' => 'admin/user/user_badges/settings',
      'title' => t('Settings'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'user_badges_settings_form',
      ),
      'access' => $access,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/user/user_badges/delete',
      'title' => t('Delete badge'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'user_badges_delete_form',
      ),
      'access' => $access,
      'type' => MENU_CALLBACK,
    );
    if (arg(0) == 'user') {
      if ($access) {
        $uid = arg(1);
      }
      if (is_numeric($uid)) {
        $items[] = array(
          'path' => "user/{$uid}/badges",
          'title' => t('Badges'),
          'callback' => 'user_badges_page',
          'access' => $access,
          'type' => MENU_LOCAL_TASK,
          'weight' => 5,
        );
      }
    }
  }
  return $items;
}