public function savePayMethodsObject() { include_once './Services/Payment/classes/class.ilPayMethods.php'; global $rbacsystem; if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) { $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE); } $obj_paymethods = new ilPayMethods(); $paymethods = $obj_paymethods->readAll(); $askForDeletingAddresses = array(); $pm_enabled = (array) $_POST['pm_enabled']; $pm_addr = (array) $_POST['save_usr_adr']; if (!$pm_enabled) { ilUtil::sendInfo($this->lng->txt('shop_disabled_no_paymethods')); $this->genSetData->set('shop_enabled', 0, 'common'); $_SESSION['disable_shop'] = false; } $info_msg = array(); foreach ($paymethods as $paymethod) { if ((!isset($pm_enabled[$paymethod['pm_id']]) || !$pm_enabled[$paymethod['pm_id']]) && $paymethod['pm_enabled']) { if (ilPaymentObject::_getCountObjectsByPayMethod($paymethod['pm_id'])) { $info_msg[] = $this->lng->txt('pays_objects_' . $paymethod['pm_title'] . '_exist'); } } } if ($info_msg) { ilUtil::sendInfo(implode('<br />', $info_msg)); $this->payMethodsObject(); return; } $num_changed = 0; foreach ($paymethods as $paymethod) { if ((!isset($pm_enabled[$paymethod['pm_id']]) || !$pm_enabled[$paymethod['pm_id']]) && $paymethod['pm_enabled']) { ilPayMethods::_PMdisable($paymethod['pm_id']); ++$num_changed; } else { if (isset($pm_enabled[$paymethod['pm_id']]) && $pm_enabled[$paymethod['pm_id']] && !$paymethod['pm_enabled']) { ilPayMethods::_PMenable($paymethod['pm_id']); ++$num_changed; } } if ((!isset($pm_addr[$paymethod['pm_id']]) || !$pm_addr[$paymethod['pm_id']]) && $paymethod['save_usr_adr']) { $askForDeletingAddresses[] = $paymethod['pm_id']; } else { if ((!isset($pm_addr[$paymethod['pm_id']]) || !$pm_addr[$paymethod['pm_id']]) && !$paymethod['save_usr_adr']) { continue; } else { ilPayMethods::_enableSaveUserAddress($paymethod['pm_id']); ++$num_changed; } } } if ($num_changed && !$askForDeletingAddresses) { ilUtil::sendSuccess($this->lng->txt('pays_updated_pay_method')); } $this->payMethodsObject($askForDeletingAddresses); return true; }
public function savePayMethodsObject() { include_once './Services/Payment/classes/class.ilPayMethods.php'; global $rbacsystem; // MINIMUM ACCESS LEVEL = 'read' if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) { $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE); } $count_pm = ilPayMethods::countPM(); $askForDeletingAddresses = array(); $pm_enabled = array(); if (is_array($_POST['pm_enabled'])) { $pm_enabled = $_POST['pm_enabled']; } else { if ($_POST['pm_enabled'] == NULL) { ilUtil::sendInfo($this->lng->txt('shop_disabled_no_paymethods')); $this->genSetData->set('shop_enabled', 0, 'common'); $_SESSION['disable_shop'] = false; } } for ($i = 1; $i <= $count_pm; $i++) { if (!array_key_exists($i, $pm_enabled) && ilPayMethods::_PmEnabled($i) == 1) { if (ilPaymentObject::_getCountObjectsByPayMethod($i)) { ilUtil::sendInfo($this->lng->txt('pays_objects_bill_exist')); $this->payMethodsObject(); return false; } else { ilPayMethods::_PMdisable($i); } } else { if (!array_key_exists($i, $pm_enabled) && ilPayMethods::_PmEnabled($i) == 0) { continue; } else { ilPayMethods::_PMenable($i); } } if (!array_key_exists($i, (array) $_POST['save_usr_adr']) && ilPayMethods::_EnabledSaveUserAddress($i) == 1) { $askForDeletingAddresses[] = $i; } else { if (!array_key_exists($i, (array) $_POST['save_usr_adr']) && ilPayMethods::_EnabledSaveUserAddress($i) == 0) { continue; } else { ilPayMethods::_enableSaveUserAddress($i); } } } $tmp = $this->payMethodsObject($askForDeletingAddresses); if (!$askForDeletingAddresses) { ilUtil::sendSuccess($this->lng->txt('pays_updated_pay_method')); } return true; }