You are here

function commerce_coupon_batch_menu in Commerce coupon batch 7

Same name and namespace in other branches
  1. 7.2 commerce_coupon_batch.module \commerce_coupon_batch_menu()

Implements hook_menu().

File

./commerce_coupon_batch.module, line 11
Batch generation functionalities for commerce_coupon module.

Code

function commerce_coupon_batch_menu() {
  $items['admin/commerce/coupons/batch'] = array(
    'title' => 'Batch create coupons',
    'page callback' => 'commerce_coupon_batch_overview_page',
    'access arguments' => array(
      'commerce coupon batch creation',
    ),
  );
  $coupon_types = commerce_coupon_get_types();
  foreach ($coupon_types as $type => $info) {
    $entity = commerce_coupon_create($type);
    $type_arg = strtr($type, '_', '-');
    $items['admin/commerce/coupons/batch/' . $type_arg] = array(
      'tab_parent' => 'admin/commerce/coupons/batch',
      'title' => 'Batch create @name',
      'title arguments' => array(
        '@name' => $info->label,
      ),
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'commerce_coupon_batch_form',
        $entity,
      ),
      'file' => 'includes/commerce_coupon_batch.form.inc',
      'access callback' => 'commerce_coupon_access',
      'access arguments' => array(
        'create',
        $entity,
      ),
    );
    $items['admin/commerce/coupons/batch/' . $type_arg . '/generate'] = array(
      'title' => 'Edit',
      'access callback' => 'commerce_coupon_access',
      'access arguments' => array(
        'create',
        $entity,
      ),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    );
  }
  return $items;
}