You are here

function commerce_coupon_ui_menu_alter in Commerce Coupon 7

Implements hook_menu_alter().

File

./commerce_coupon_ui.module, line 170
Coupon User Interface for Drupal Commerce

Code

function commerce_coupon_ui_menu_alter(&$items) {

  // Transform the field UI tabs into contextual links.
  foreach (commerce_coupon_get_types() as $type => $coupon_type) {

    // Convert underscores to hyphens for the menu item argument.
    $type_arg = strtr($type, '_', '-');
    if (!empty($coupon_type->status)) {
      $items['admin/commerce/coupons/types/' . $type_arg . '/fields']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
      $items['admin/commerce/coupons/types/' . $type_arg . '/display']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
    }
    else {

      // Hide the menu if the coupon type is not enabled.
      $items['admin/commerce/coupons/types/' . $type_arg . '/fields']['access callback'] = FALSE;
      $items['admin/commerce/coupons/types/' . $type_arg . '/display']['access callback'] = FALSE;
    }
  }
}