- <?php
-
- * Implementation of hook_nap_handler().
- */
- function uc_nap_nap_handler() {
- return array(
-
- 'name' => 'Node Access Product for Ubercart',
-
- 'integration' => 'Ubercart',
-
- 'recurring module' => 'uc_recurring',
-
- 'settings path' => 'admin/store/settings',
-
- 'reports path' => 'admin/store',
- );
- }
-
- * Implementation of hook_enable().
- */
- function uc_nap_enable() {
- drupal_load('module', 'nap');
- nap_notify('enable', 'uc_nap');
- }
-
- * Implementation of hook_disable().
- */
- function uc_nap_disable() {
- drupal_load('module', 'nap');
- nap_notify('disable', 'uc_nap');
- }
-
- * Implementation of hook_order().
- */
- function uc_nap_order($op, $order, $status) {
- if ($op == 'update' && $status == 'payment_received') {
-
- if (module_exists("uc_recurring")) {
-
- $dates = array();
- $fees = uc_recurring_get_fees($order, TRUE);
- foreach ($fees as $fee) {
- $dates[$fee->order_product_id][] = $fee->next_charge;
- }
-
- foreach ($dates as $key => $value) {
- $dates[$key] = min($value);
- }
- }
-
-
- foreach ($order->products as $i => &$node) {
- if (isset($dates[$node->order_product_id])) {
-
- $node->nap_recurring_date = strftime('%Y-%m-%d %H:%M:%S', $dates[$node->order_product_id]);
- }
- else {
-
- $node->nap_recurring_date = 0;
- }
- }
-
- nap_save_purchase($order->order_id, $order->uid, $order->products);
- }
- }
-
- * Implementation of hook_nap_form_is_product().
- */
- function uc_nap_nap_form_is_product($form, $form_state, $form_id) {
- return uc_product_is_product($form['#node']);
- }
-
- * Implementation of hook_nap_save_purchase().
- */
- function uc_nap_nap_save_purchase($nap_purchases, $nap_transaction) {
- if (module_exists('ca')) {
- $order = uc_order_load($nap_transaction->txn_id);
- ca_pull_trigger('uc_nap_purchase', $order);
- }
- }
-
- * Implementation of hook_ca_trigger().
- */
- function uc_nap_ca_trigger() {
- $triggers = array();
-
- $triggers['uc_nap_purchase'] = array(
- '#title' => t('A user purchases a NAP product.'),
- '#category' => t('Node access product'),
- '#arguments' => array(
- 'product' => array(
- '#entity' => 'uc_order',
- '#title' => t('Order'),
- ),
- ),
- );
-
- return $triggers;
- }