You are here

function uc_recurring_menu in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 uc_recurring.module \uc_recurring_menu()
  2. 6 uc_recurring.module \uc_recurring_menu()

Implements hook_menu().

File

./uc_recurring.module, line 57
Allows you to add a recurring fee to a product/SKU to handle subscription type services.

Code

function uc_recurring_menu() {
  $items = array();
  $items['admin/store/settings/recurring'] = array(
    'title' => 'Recurring payments',
    'description' => 'Edit the recurring payment settings.',
    'access arguments' => array(
      'administer store',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'uc_recurring_payment_form',
    ),
    'weight' => 0,
    'file' => 'uc_recurring.admin.inc',
  );
  $items['admin/store/orders/recurring'] = array(
    'title' => 'Recurring fees',
    'description' => 'View the recurring fees on your orders.',
    'page callback' => 'uc_recurring_admin',
    'page arguments' => array(
      NULL,
      NULL,
    ),
    'access arguments' => array(
      'administer recurring fees',
    ),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 5,
    'file' => 'uc_recurring.admin.inc',
  );
  $items['admin/store/orders/recurring/view/fee/%'] = array(
    'title' => 'Recurring fees',
    'description' => 'View a specific recurring fee.',
    'page callback' => 'uc_recurring_admin',
    'page arguments' => array(
      5,
      6,
    ),
    'access arguments' => array(
      'administer recurring fees',
    ),
    'type' => MENU_CALLBACK,
    'weight' => 5,
    'file' => 'uc_recurring.admin.inc',
  );
  $items['admin/store/orders/recurring/view/order/%'] = array(
    'title' => 'Recurring fees',
    'description' => 'View the recurring fees on a specific order.',
    'page callback' => 'uc_recurring_admin',
    'page arguments' => array(
      5,
      6,
    ),
    'access arguments' => array(
      'administer recurring fees',
    ),
    'type' => MENU_CALLBACK,
    'weight' => 5,
    'file' => 'uc_recurring.admin.inc',
  );
  $items['user/%user/recurring-fees'] = array(
    'title' => 'Recurring fees',
    'description' => 'View current recurring fees.',
    'page callback' => 'uc_recurring_user_fees',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'uc_recurring_user_access',
    'access arguments' => array(
      1,
    ),
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/store/orders/%/recurring'] = array(
    'title' => 'Recurring fees',
    'description' => 'Recurring fees associated with this order.',
    'page callback' => 'uc_recurring_order_information',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'administer recurring fees',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'uc_recurring.admin.inc',
  );

  // Recurring fee payment methods and gateways can define their own list of
  // user operations via the same standard menu structure.
  $info = uc_recurring_get_recurring_info();
  foreach ($info as $handler => $value) {
    if (!empty($value['menu'])) {
      foreach ($value['menu'] as $path => $menu_item) {
        if ($menu_item != UC_RECURRING_MENU_DISABLED) {
          if ($menu_item == UC_RECURRING_MENU_DEFAULT) {
            $menu_item = !empty($info['default']['menu'][$path]) ? $info['default']['menu'][$path] : array();
          }
          $default_menu_fields = array(
            'title' => $path,
            'page callback' => 'drupal_get_form',
            'access callback' => 'uc_recurring_user_access',
            'type' => MENU_CALLBACK,
            'file path' => drupal_get_path('module', $value['module']),
          );
          $admin_path = 'admin/store/orders/recurring/%/' . $path . '/' . $value['fee handler'];
          $items[$admin_path] = array_merge($default_menu_fields, $menu_item);
          $items[$admin_path]['page arguments'][] = 4;

          // Add rfid as an arguments.
          $items[$admin_path]['page arguments'][] = 6;

          // Add fee_handler as an arguments.
          $user_path = 'user/%user/recurring/%/' . $path . '/' . $value['fee handler'];
          $default_menu_fields['access arguments'] = array(
            1,
            3,
            4,
          );
          $items[$user_path] = array_merge($default_menu_fields, $menu_item);
          $items[$user_path]['page arguments'][] = 3;

          // Add rfid as an arguments.
          $items[$user_path]['page arguments'][] = 5;

          // Add fee_handler as an arguments.
        }
      }
    }
  }
  return $items;
}