コード例 #1
0
 function save()
 {
     global $ilAccess, $ilErr;
     if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
         $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
     }
     $this->registration_settings->setRegistrationType((int) $_POST['reg_type']);
     $this->registration_settings->setPasswordGenerationStatus((int) $_POST['reg_pwd']);
     $this->registration_settings->setApproveRecipientLogins(ilUtil::stripSlashes($_POST['reg_approver']));
     $this->registration_settings->setRoleType((int) $_POST['reg_role_type']);
     $this->registration_settings->setAccessLimitation((int) $_POST['reg_access_limitation']);
     $this->registration_settings->setAllowedDomains($_POST['reg_allowed_domains']);
     $allow_codes = false;
     if (in_array((int) $_POST['reg_type'], array(IL_REG_DIRECT, IL_REG_APPROVE, IL_REG_ACTIVATION))) {
         $allow_codes = (bool) $_POST['reg_codes_' . (int) $_POST['reg_type']];
     }
     $this->registration_settings->setAllowCodes($allow_codes);
     if (!preg_match('/^([0]|([1-9][0-9]*))([\\.,][0-9][0-9]*)?$/', (int) $_POST['reg_hash_life_time'])) {
         $this->registration_settings->setRegistrationHashLifetime(ilRegistrationSettings::REG_HASH_LIFETIME_MIN_VALUE);
     } else {
         $this->registration_settings->setRegistrationHashLifetime(max((int) $_POST['reg_hash_life_time'], ilRegistrationSettings::REG_HASH_LIFETIME_MIN_VALUE));
     }
     if ($error_code = $this->registration_settings->validate()) {
         switch ($error_code) {
             case ilRegistrationSettings::ERR_UNKNOWN_RCP:
                 ilUtil::sendFailure($this->lng->txt('reg_unknown_recipients') . ' ' . $this->registration_settings->getUnknown());
                 $this->view();
                 return false;
             case ilRegistrationSettings::ERR_MISSING_RCP:
                 ilUtil::sendFailure($this->lng->txt('reg_approve_needs_recipient') . ' ' . $this->registration_settings->getUnknown());
                 $this->view();
                 return false;
         }
     }
     require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
     ilCaptchaUtil::setActiveForRegistration((bool) $_POST['activate_captcha_anonym']);
     $this->registration_settings->save();
     ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
     $this->view();
     return true;
 }