コード例 #1
0
 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;
 }