You are here

function commerce_backoffice_product_menu in Commerce Backoffice 7

Implements hook_menu().

File

./commerce_backoffice_product.module, line 16

Code

function commerce_backoffice_product_menu() {

  // Megarow callbacks.
  $items['commerce_backoffice/variations/%node'] = array(
    'page callback' => 'commerce_backoffice_product_variations_view',
    'page arguments' => array(
      2,
    ),
    'access callback' => 'node_access',
    'access arguments' => array(
      'update',
      2,
    ),
    'delivery callback' => 'ajax_deliver',
  );

  // The overriden node/add type listing.
  $base = array(
    'page callback' => 'node_add_page',
    'file' => 'node.pages.inc',
    'file path' => drupal_get_path('module', 'node'),
  );
  $items['node/add/add-content'] = array(
    'title' => 'Add content',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'access callback' => '_node_add_access',
  ) + $base;
  $items['node/add/add-product'] = array(
    'title' => 'Add product',
    'type' => MENU_LOCAL_TASK,
    'access callback' => '_commerce_backoffice_product_node_add_product_access',
  ) + $base;

  // Product variation types UI.
  $items['admin/commerce/config/product-variation-types'] = array(
    'title' => 'Product variation types',
    'description' => 'Manage product variation types.',
    'page callback' => 'commerce_backoffice_product_variation_types_overview',
    'access arguments' => array(
      'administer product types',
    ),
    'file' => 'includes/commerce_backoffice_product.product_variation_types.inc',
  );
  $items['admin/commerce/config/product-variation-types/add'] = array(
    'title' => 'Add product variation type',
    'page callback' => 'commerce_backoffice_product_variation_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_backoffice_product.product_variation_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/config/product-variation-types/' . $type_arg] = array(
      'title' => $product_type['name'],
      'page callback' => 'commerce_backoffice_product_variation_type_form_wrapper',
      'page arguments' => array(
        $type,
      ),
      'access arguments' => array(
        'administer product types',
      ),
      'file' => 'includes/commerce_backoffice_product.product_variation_types.inc',
    );
    if ($product_type['module'] == 'commerce_product_ui') {
      $items['admin/commerce/config/product-variation-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/config/product-variation-types/' . $type_arg . '/delete'] = array(
        'title' => 'Delete',
        'page callback' => 'commerce_backoffice_product_variation_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_backoffice_product.product_variation_types.inc',
      );
    }
  }
  return $items;
}