You are here

function uc_product_menu in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_product/uc_product.module \uc_product_menu()
  2. 7.3 uc_product/uc_product.module \uc_product_menu()

Implementation of hook_menu().

File

uc_product/uc_product.module, line 21
The product module for Ubercart.

Code

function uc_product_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'products',
      'title' => t('Products'),
      'description' => t('List all published product nodes.'),
      'access' => user_access('access content'),
      'callback' => 'uc_product_default',
      'type' => MENU_SUGGESTED_ITEM,
    );
    $items[] = array(
      'path' => 'admin/store/products',
      'title' => t('Products'),
      'description' => t('Administer products, classes, and more.'),
      'access' => user_access('administer products'),
      'callback' => 'uc_product_administration',
      'type' => MENU_NORMAL_ITEM,
      'weight' => -2,
    );
    $items[] = array(
      'path' => 'admin/store/products/view',
      'title' => t('View products'),
      'description' => t('Build and view a list of product nodes.'),
      'access' => user_access('administer products'),
      'type' => MENU_NORMAL_ITEM,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/store/products/classes',
      'title' => t('Manage classes'),
      'description' => t('Create and edit product node types.'),
      'access' => user_access('administer product classes'),
      'callback' => 'uc_product_class_default',
      'type' => MENU_NORMAL_ITEM,
      'weight' => -2,
    );
    $items[] = array(
      'path' => 'admin/store/settings/products',
      'title' => t('Product settings'),
      'description' => t('Configure product settings.'),
      'access' => user_access('administer products'),
      'callback' => 'uc_product_settings_overview',
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/store/settings/products/overview',
      'title' => t('Overview'),
      'weight' => -10,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/store/settings/products/edit',
      'title' => t('Edit'),
      'access' => user_access('administer products'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_product_settings_form',
      ),
      'weight' => -5,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/store/settings/products/edit/general',
      'title' => t('Product settings'),
      'access' => user_access('administer products'),
      'weight' => -10,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/store/settings/products/edit/fields',
      'title' => t('Product fields'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_product_field_settings_form',
      ),
      'access' => user_access('administer products'),
      'weight' => -5,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/store/settings/products/edit/features',
      'title' => t('Product features'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_product_feature_settings_form',
      ),
      'access' => user_access('administer product features'),
      'weight' => 0,
      'type' => MENU_LOCAL_TASK,
    );
  }
  else {

    // Insert subitems into the edit node page for product types.
    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit') {
      $node = node_load(arg(1));
      if ($node->nid && in_array($node->type, module_invoke_all('product_types'))) {
        $items[] = array(
          'path' => 'node/' . arg(1) . '/edit/product',
          'title' => t('Product'),
          'weight' => -10,
          'type' => MENU_DEFAULT_LOCAL_TASK,
        );
        $features = module_invoke_all('product_feature');
        if (!empty($features)) {
          $items[] = array(
            'path' => 'node/' . arg(1) . '/edit/features',
            'title' => t('Features'),
            'callback' => 'uc_product_features',
            'callback arguments' => array(
              $node,
            ),
            'access' => user_access('administer product features'),
            'weight' => 10,
            'type' => MENU_LOCAL_TASK,
          );
        }
      }
    }
    $items[] = array(
      'path' => 'admin/store/settings/products/defaults/' . arg(5),
      'title' => t('Imagecache default settings'),
      'access' => user_access('administer products'),
      'callback' => 'uc_product_image_defaults',
      'callback arguments' => array(
        arg(5),
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/store/products/classes/' . arg(4),
      'title' => t('Product class'),
      'access' => user_access('administer product classes'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_product_class_form',
        arg(4),
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/store/products/classes/' . arg(4) . '/edit',
      'title' => t('Edit'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -5,
    );
    $items[] = array(
      'path' => 'admin/store/products/classes/' . arg(4) . '/delete',
      'access' => user_access('administer product classes'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'uc_product_class_delete_confirm',
        arg(4),
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'products/field_image_cache/' . arg(2),
      'access' => true,
      'callback' => '_uc_product_get_image_field_filepath',
      'callback arguments' => array(
        arg(2),
      ),
      'type' => MENU_CALLBACK,
    );
    drupal_add_css(drupal_get_path('module', 'uc_product') . '/uc_product.css');
  }
  return $items;
}