function fn_delete_corresponding_subscription($order_ids, $not_confirmed = true) { $subscriptions = db_get_hash_single_array("SELECT subscription_id, order_id FROM ?:recurring_subscriptions WHERE order_id IN (?n)", array('subscription_id', 'order_id'), $order_ids); if (!empty($subscriptions)) { if ($not_confirmed) { $_SESSION['subscriptions'] = $subscriptions; $_SESSION['order_ids'] = $order_ids; return false; } else { fn_delete_recurring_subscriptions(array_keys($subscriptions)); } } foreach ($order_ids as $v) { $subs = db_get_array("SELECT subscription_id, order_ids FROM ?:recurring_subscriptions WHERE FIND_IN_SET(?i, order_ids)", $v); if (!empty($subs)) { foreach ($subs as $val) { $new_order_ids = explode(',', $val['order_ids']); $new_order_ids = array_diff($new_order_ids, $order_ids); db_query("UPDATE ?:recurring_subscriptions SET order_ids = ?s WHERE subscription_id = ?i", implode(',', $new_order_ids), $val['subscription_id']); } } } return true; }
} elseif ($mode == 'update') { $subscription = fn_get_recurring_subscription_info($_REQUEST['subscription_id'], true, true); if (empty($subscription)) { return array(CONTROLLER_STATUS_NO_PAGE); } fn_add_breadcrumb(fn_get_lang_var('rb_subscriptions'), "subscriptions.manage.reset_view"); fn_add_breadcrumb(fn_get_lang_var('search_results'), "subscriptions.manage.last_view"); Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'linked_products' => array('title' => fn_get_lang_var('products'), 'js' => true), 'paids' => array('title' => fn_get_lang_var('orders'), 'js' => true))); $view->assign('subscription', $subscription); } elseif ($mode == 'manage') { list($subscriptions, $search) = fn_get_recurring_subscriptions($_REQUEST); $view->assign('subscriptions', $subscriptions); $view->assign('search', $search); } elseif ($mode == 'delete') { if (!empty($_REQUEST['subscription_id'])) { fn_delete_recurring_subscriptions((array) $_REQUEST['subscription_id']); } return array(CONTROLLER_STATUS_REDIRECT, "subscriptions.manage"); } elseif ($mode == 'update_status') { $old_status = db_get_field("SELECT status FROM ?:recurring_subscriptions WHERE subscription_id = ?i", $_REQUEST['id']); if (!fn_change_recurring_subscription_status($_REQUEST['id'], $_REQUEST['status'], $old_status, fn_get_notification_rules($_REQUEST), true)) { $ajax->assign('return_status', $old_status); } exit; } elseif ($mode == 'charge') { define('ORDER_MANAGEMENT', true); if (!empty($_REQUEST['subscription_id'])) { fn_charge_subscription($_REQUEST['subscription_id']); fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('rb_subscription_charged')); } return array(CONTROLLER_STATUS_REDIRECT, "subscriptions.manage");