You are here

function commerce_product_ui_menu in Commerce Core 7

Implements hook_menu().

File

modules/product/commerce_product_ui.module, line 10

Code

function commerce_product_ui_menu() {
  $items = array();

  // Note: admin/commerce/products is defined by a default View.
  // Add a product.
  $items['admin/commerce/products/add'] = array(
    'title' => 'Add a product',
    'description' => 'Add a new product for sale.',
    'page callback' => 'commerce_product_ui_add_page',
    'access callback' => 'commerce_product_ui_product_add_any_access',
    'weight' => 10,
    'file' => 'includes/commerce_product_ui.products.inc',
  );
  foreach (commerce_product_types() as $type => $product_type) {
    $items['admin/commerce/products/add/' . strtr($type, array(
      '_' => '-',
    ))] = array(
      'title' => 'Create !name',
      'title arguments' => array(
        '!name' => $product_type['name'],
      ),
      'description' => $product_type['description'],
      'page callback' => 'commerce_product_ui_product_form_wrapper',
      'page arguments' => array(
        commerce_product_new($type),
      ),
      'access callback' => 'commerce_product_access',
      'access arguments' => array(
        'create',
        commerce_product_new($type),
      ),
      'file' => 'includes/commerce_product_ui.products.inc',
    );
  }
  $items['admin/commerce/products/%commerce_product'] = array(
    'title callback' => 'commerce_product_ui_product_title',
    'title arguments' => array(
      3,
    ),
    'page callback' => 'commerce_product_ui_product_form_wrapper',
    'page arguments' => array(
      3,
    ),
    'access callback' => 'commerce_product_access',
    'access arguments' => array(
      'update',
      3,
    ),
    'weight' => 0,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'file' => 'includes/commerce_product_ui.products.inc',
  );
  $items['admin/commerce/products/%commerce_product/edit'] = array(
    'title' => 'Edit',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items['admin/commerce/products/%commerce_product/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'commerce_product_ui_product_delete_form_wrapper',
    'page arguments' => array(
      3,
    ),
    'access callback' => 'commerce_product_access',
    'access arguments' => array(
      'delete',
      3,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 20,
    'context' => MENU_CONTEXT_INLINE,
    'file' => 'includes/commerce_product_ui.products.inc',
  );
  $items['admin/commerce/products/types'] = array(
    'title' => 'Product types',
    'description' => 'Manage products types for your store.',
    'page callback' => 'commerce_product_ui_types_overview',
    'access arguments' => array(
      'administer product types',
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
    'file' => 'includes/commerce_product_ui.types.inc',
  );
  $items['admin/commerce/products/types/add'] = array(
    'title' => 'Add product type',
    'page callback' => 'commerce_product_ui_product_type_form_wrapper',
    'page arguments' => array(
      commerce_product_ui_product_type_new(),
    ),
    'access arguments' => array(
      'administer product types',
    ),
    'type' => MENU_LOCAL_ACTION,
    'file' => 'includes/commerce_product_ui.types.inc',
  );
  foreach (commerce_product_types() as $type => $product_type) {

    // Convert underscores to hyphens for the menu item argument.
    $type_arg = strtr($type, '_', '-');
    $items['admin/commerce/products/types/' . $type_arg] = array(
      'title' => $product_type['name'],
      'page callback' => 'commerce_product_ui_product_type_form_wrapper',
      'page arguments' => array(
        $type,
      ),
      'access arguments' => array(
        'administer product types',
      ),
      'file' => 'includes/commerce_product_ui.types.inc',
    );
    if ($product_type['module'] == 'commerce_product_ui') {
      $items['admin/commerce/products/types/' . $type_arg . '/edit'] = array(
        'title' => 'Edit',
        'access callback' => 'commerce_product_ui_product_type_update_access',
        'access arguments' => array(
          $type,
        ),
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      );
      $items['admin/commerce/products/types/' . $type_arg . '/delete'] = array(
        'title' => 'Delete',
        'page callback' => 'commerce_product_ui_product_type_delete_form_wrapper',
        'page arguments' => array(
          $type,
        ),
        'access callback' => 'commerce_product_ui_product_type_update_access',
        'access arguments' => array(
          $type,
        ),
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_INLINE,
        'weight' => 10,
        'file' => 'includes/commerce_product_ui.types.inc',
      );
    }
  }
  return $items;
}