You are here

function uc_coupon_menu in Ubercart Discount Coupons 5

Same name and namespace in other branches
  1. 6 uc_coupon.module \uc_coupon_menu()
  2. 7.3 uc_coupon.module \uc_coupon_menu()
  3. 7.2 uc_coupon.module \uc_coupon_menu()

Implementation of hook_menu().

File

./uc_coupon.module, line 17
Provides discount coupons for Ubercart.

Code

function uc_coupon_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/store/customers/coupon',
      'title' => t('Coupons'),
      'description' => t('Manage store discount coupons.'),
      'callback' => 'uc_coupon_display',
      'callback arguments' => array(
        'active',
      ),
      'access' => user_access('view store coupons'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/store/customers/coupon/list',
      'title' => t('Active coupons'),
      'description' => t('View active coupons.'),
      'callback' => 'uc_coupon_display',
      'callback arguments' => array(
        'active',
      ),
      'access' => user_access('view store coupons'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/store/customers/coupon/inactive',
      'title' => t('Inactive coupons'),
      'description' => t('View inactive coupons.'),
      'callback' => 'uc_coupon_display',
      'callback arguments' => array(
        'inactive',
      ),
      'access' => user_access('view store coupons'),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/store/customers/coupon/add',
      'title' => t('Add new coupon'),
      'description' => t('Add a new coupon.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_coupon_add_form',
        'add',
      ),
      'access' => user_access('manage store coupons'),
      'type' => MENU_LOCAL_TASK,
      'weight' => 10,
    );
    $items[] = array(
      'path' => 'admin/store/reports/coupon',
      'title' => t('Coupon usage reports'),
      'description' => t('View coupon usage reports.'),
      'callback' => 'uc_coupon_reports',
      'access' => user_access('view reports'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'cart/checkout/coupon',
      'callback' => 'uc_coupon_checkout_apply',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'uc_coupon/autocomplete/node',
      'callback' => 'uc_coupon_autocomplete_node',
      'access' => user_access('manage store coupons'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'uc_coupon/autocomplete/term',
      'callback' => 'uc_coupon_autocomplete_term',
      'access' => user_access('manage store coupons'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'uc_coupon/autocomplete/user',
      'callback' => 'uc_coupon_autocomplete_user',
      'access' => user_access('manage store coupons'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'uc_coupon/autocomplete/role',
      'callback' => 'uc_coupon_autocomplete_role',
      'access' => user_access('manage store coupons'),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    if (arg(0) == 'admin' && arg(1) == 'store' && arg(2) == 'customers' && arg(3) == 'coupon' && is_numeric(arg(4))) {
      $items[] = array(
        'path' => 'admin/store/customers/coupon/' . arg(4) . '/edit',
        'title' => t('Edit coupon'),
        'description' => t('Edit an existing coupon.'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'uc_coupon_add_form',
          'edit',
          arg(4),
        ),
        'access' => user_access('manage store coupons'),
        'type' => MENU_DYNAMIC_ITEM,
      );
      $items[] = array(
        'path' => 'admin/store/customers/coupon/' . arg(4) . '/delete',
        'title' => t('Delete coupon'),
        'description' => t('Delete a coupon.'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'uc_coupon_delete_confirm',
          arg(4),
        ),
        'access' => user_access('manage store coupons'),
        'type' => MENU_DYNAMIC_ITEM,
      );
      $items[] = array(
        'path' => 'admin/store/customers/coupon/' . arg(4) . '/codes',
        'title' => t('Download bulk coupon codes'),
        'description' => t('Download the list of bulk coupon codes as a CSV file.'),
        'callback' => 'uc_coupon_codes_csv',
        'callback arguments' => array(
          arg(4),
        ),
        'access' => user_access('manage store coupons'),
        'type' => MENU_DYNAMIC_ITEM,
      );
    }
  }
  return $items;
}