public function loadPlanObject($testmi = false, $quick = false) { if (empty($this->usage) && !empty($this->passthrough['usage'])) { $this->usage = $this->passthrough['usage']; } if (!$this->isCart()) { // get the payment plan $this->plan = new SubscriptionPlan(); $this->plan->load($this->usage); if (empty($this->processor)) { // Recover from missing processor selection if (!empty($this->invoice->made_free) || $this->plan->params['full_free'] && empty($this->invoice->counter) && empty($this->plan->params['trial_period']) || $this->plan->params['full_free'] && $this->invoice->counter || $this->plan->params['trial_free'] && empty($this->invoice->counter)) { if (!isset($this->recurring)) { $this->recurring = 0; } // Only allow clearing while recurring if everything is free if (!($this->recurring && (empty($this->plan->params['full_free']) || empty($this->plan->params['trial_free'])))) { $this->processor = 'free'; } } if (empty($this->processor)) { // It's not free, so select the only processor we have available if (!empty($this->plan->params['processors'])) { foreach ($this->plan->params['processors'] as $proc) { $pp = new PaymentProcessor(); if (!$pp->loadId($proc)) { continue; } $this->processor = $pp->processor_name; break; } } } } if (!is_object($this->plan)) { return getView('access_denied'); } } elseif (!empty($this->usage)) { if (empty($this->metaUser)) { return getView('access_denied'); } if (!isset($this->cartprocexceptions)) { $this->getCart(); $this->usage = 'c.' . $this->cartobject->id; $procs = aecCartHelper::getCartProcessorList($this->cartobject); if (count($procs) > 1) { $this->recurring = null; $this->cartItemsPPselectForm(); } else { if (isset($procs[0])) { $pgroups = aecCartHelper::getCartProcessorGroups($this->cartobject, $this->recurring); $proc = $pgroups[0]['processors'][0]; if (strpos($proc, '_recurring')) { $this->recurring = 1; $proc = str_replace('_recurring', '', $proc); } $procname = PaymentProcessorHandler::getProcessorNamefromId($proc); if (!empty($procname)) { $this->processor = $procname; } $this->plan = aecCartHelper::getCartItemObject($this->cartobject, 0); } else { $am = $this->cartobject->getAmount($this->metaUser, 0, $this); if ($am['amount'] == "0.00") { $this->processor = 'free'; } else { $this->processor = 'none'; } } } $this->cartprocexceptions = true; } if (!isset($this->mi_error)) { $this->mi_error = array(); } $offset = 0; if (!empty($this->exceptions)) { $offset = count($this->exceptions); } if (empty($this->cart) || $quick) { return null; } foreach ($this->cart as $cid => $cartitem) { if (empty($cartitem['obj'])) { continue; } $mi_form = $cartitem['obj']->getMIformParams($this->metaUser, $this->mi_error); $lists = null; if (isset($mi_form['lists']) && !empty($mi_form['lists'])) { $lists = $mi_form['lists']; unset($mi_form['lists']); } if (empty($mi_form)) { continue; } if (!empty($lists)) { // Rewrite lists so they fit a multi-plan context foreach ($lists as $lkey => $litem) { $mi_form['lists'][$offset . '_' . $lkey] = str_replace($lkey, $offset . '_' . $lkey, $litem); } } $this->mi_error = array(); $check = $this->verifyMIForms($cartitem['obj'], $mi_form, $offset . '_'); $offset++; if (!$check) { $ex = array(); $ex['head'] = ""; if (!empty($this->mi_error)) { $ex['desc'] = "<p>" . implode("</p><p>", $this->mi_error) . "</p>"; } else { $ex['desc'] = ""; } $ex['rows'] = $mi_form; $this->raiseException($ex); } if (is_array($this->passthrough)) { foreach ($mi_form as $mik => $miv) { if ($mik == 'lists') { continue; } foreach ($this->passthrough as $pid => $pk) { if (!is_array($pk)) { continue; } if ($pk[0] == $mik || $pk[0] == $mik . '[]') { unset($this->passthrough[$pid]); } } } } } } }