You are here

function uc_addresses_menu in Ubercart Addresses 5

Same name and namespace in other branches
  1. 5.2 uc_addresses.module \uc_addresses_menu()
  2. 6.2 uc_addresses.module \uc_addresses_menu()
  3. 6 uc_addresses.module \uc_addresses_menu()
  4. 7 uc_addresses.module \uc_addresses_menu()

Implementation of hook_menu().

Parameters

$may_cache A boolean that is TRUE if menu items will be cached.:

Return value

A array of menu items.

File

./uc_addresses.module, line 56

Code

function uc_addresses_menu($may_cache) {
  global $user;
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/store/settings/addresses',
      'title' => t('Address settings'),
      'description' => t('Configure the address settings.'),
      'callback' => 'uc_addresses_settings_overview',
      'access' => user_access('administer store'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/store/settings/addresses/overview',
      'title' => t('Overview'),
      'access' => user_access('administer store'),
      'description' => t('View the address settings.'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/store/settings/addresses/edit',
      'title' => t('Edit'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_addresses_settings_form',
      ),
      'access' => user_access('administer store'),
      'description' => t('Edit the address settings.'),
      'type' => MENU_LOCAL_TASK,
      'weight' => -5,
    );
  }
  else {
    drupal_add_css(drupal_get_path('module', 'uc_order') . '/uc_order.css');
    if (is_numeric(arg(1)) && intval(arg(1)) == arg(1)) {
      $items[] = array(
        'path' => 'user/' . arg(1) . '/addresses',
        'title' => t('Addresses'),
        'description' => t('Manage your addresses'),
        'callback' => 'uc_addresses_list_addresses',
        'callback arguments' => array(
          arg(1),
        ),
        'access' => user_access(UC_ADDRESSES_ACCESS_VIEW_DEFAULT) || user_access(UC_ADDRESSES_ACCESS_VIEW_ALL) || user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == arg(1),
        'type' => MENU_LOCAL_TASK,
        'weight' => 1,
      );
      if (!(is_numeric(arg(3)) && intval(arg(3)) == arg(3))) {
        $items[] = array(
          'path' => 'user/' . arg(1) . '/addresses/list',
          'title' => t('Address list'),
          'description' => t('Manage your addresses'),
          'access' => user_access(UC_ADDRESSES_ACCESS_VIEW_DEFAULT) || user_access(UC_ADDRESSES_ACCESS_VIEW_ALL) || user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == arg(1),
          'type' => MENU_DEFAULT_LOCAL_TASK,
          'weight' => 0,
        );
        $items[] = array(
          'path' => 'user/' . arg(1) . '/addresses/add',
          'title' => t('Add address'),
          'description' => t('Add a new address.'),
          'callback' => 'uc_addresses_get_address',
          'callback arguments' => array(
            arg(1),
            NULL,
            'add',
          ),
          'access' => user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == arg(1),
          'type' => MENU_LOCAL_TASK,
          'weight' => 3,
        );
      }
      else {
        $items[] = array(
          'path' => 'user/' . arg(1) . '/addresses/' . arg(3),
          'title' => t('View Address'),
          'description' => t('View one saved address'),
          'callback' => 'uc_addresses_list_addresses',
          'callback arguments' => array(
            arg(1),
            arg(3),
          ),
          'access' => user_access(UC_ADDRESSES_ACCESS_VIEW_DEFAULT) || user_access(UC_ADDRESSES_ACCESS_VIEW_ALL) || user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == arg(1),
          'type' => MENU_CALLBACK,
        );
        $items[] = array(
          'path' => 'user/' . arg(1) . '/addresses/' . arg(3) . '/edit',
          'title' => t('Edit address'),
          'callback' => 'uc_addresses_get_address',
          'callback arguments' => array(
            arg(1),
            arg(3),
            'edit',
          ),
          'access' => user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == arg(1),
          'type' => MENU_CALLBACK,
        );
        $items[] = array(
          'path' => 'user/' . arg(1) . '/addresses/' . arg(3) . '/delete',
          'title' => t('Delete address'),
          'callback' => 'uc_addresses_delete_address_confirm',
          'callback arguments' => array(
            arg(1),
            arg(3),
          ),
          'access' => user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == arg(1),
          'type' => MENU_CALLBACK,
        );
      }
    }
  }
  return $items;
}