public function save() { $row = new SubscriptionPlan(); $row->load($_POST['id']); $post = AECToolbox::cleanPOST($_POST, false); $row->savePOSTsettings($post); $row->storeload(); if ($_POST['id']) { $id = $_POST['id']; } else { $id = $row->getMax(); } if (empty($_POST['id'])) { ItemGroupHandler::setChildren(1, array($id), 'item'); } if (!empty($row->params['lifetime']) && !empty($row->params['full_period'])) { $this->log("Plan Warning", "You have selected a regular period for a plan that" . " already has the 'lifetime' (i.e. 'non expiring') flag set." . " The period you have set will be overridden by" . " that setting.", 'settings,plan'); } $terms = $row->getTerms(); if (!$terms->checkFree() && empty($row->params['processors'])) { $this->log("Plan Warning", "You have set a plan to be non-free, yet did not select a payment processor." . " Without a processor assigned, the plan will not show up on the frontend.", 'settings,plan'); } if (!empty($row->params['lifetime']) && !empty($row->params['processors'])) { $fcount = 0; $found = 0; foreach ($row->params['processors'] as $procid) { $fcount++; if (isset($row->custom_params[$procid . '_recurring'])) { if (0 < $row->custom_params[$procid . '_recurring'] && $row->custom_params[$procid . '_recurring'] < 2) { $found++; } elseif ($row->custom_params[$procid . '_recurring'] == 2) { $fcount++; } } else { $pp = new PaymentProcessor(); if (0 < $pp->is_recurring() && $pp->is_recurring() < 2) { $found++; } elseif ($pp->is_recurring() == 2) { $fcount++; } } } if ($found) { if ($found < $fcount && $fcount > 1) { $event = "You have selected one or more processors that only support recurring payments" . ", yet the plan is set to a lifetime period." . " This is not possible and the processors will not be displayed as options."; } else { $event = "You have selected a processor that only supports recurring payments" . ", yet the plan is set to a lifetime period." . " This is not possible and the plan will not be displayed."; } $short = "Plan Warning"; $tags = 'settings,plan'; $params = array(); $eventlog = new eventLog(); $eventlog->issue($short, $tags, $event, 32, $params); } } $this->setMessage(JText::_('AEC_MSG_SUCESSFULLY_SAVED')); }