protected function __initForm()
 {
     global $lng, $ilUser;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($this->ctrl->getFormAction($this));
     // code handling
     if ($this->code_enabled) {
         include_once 'Services/Registration/classes/class.ilRegistrationCode.php';
         $code = new ilTextInputGUI($lng->txt("registration_code"), "usr_registration_code");
         $code->setSize(40);
         $code->setMaxLength(ilRegistrationCode::CODE_LENGTH);
         if ((bool) $this->registration_settings->registrationCodeRequired()) {
             $code->setRequired(true);
             $code->setInfo($lng->txt("registration_code_required_info"));
         } else {
             $code->setInfo($lng->txt("registration_code_optional_info"));
         }
         $this->form->addItem($code);
     }
     // user defined fields
     $user_defined_data = $ilUser->getUserDefinedData();
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     $user_defined_fields =& ilUserDefinedFields::_getInstance();
     $custom_fields = array();
     foreach ($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition) {
         if ($definition['field_type'] == UDF_TYPE_TEXT) {
             $custom_fields["udf_" . $definition['field_id']] = new ilTextInputGUI($definition['field_name'], "udf_" . $definition['field_id']);
             $custom_fields["udf_" . $definition['field_id']]->setValue($user_defined_data["f_" . $field_id]);
             $custom_fields["udf_" . $definition['field_id']]->setMaxLength(255);
             $custom_fields["udf_" . $definition['field_id']]->setSize(40);
         } else {
             if ($definition['field_type'] == UDF_TYPE_WYSIWYG) {
                 $custom_fields["udf_" . $definition['field_id']] = new ilTextAreaInputGUI($definition['field_name'], "udf_" . $definition['field_id']);
                 $custom_fields["udf_" . $definition['field_id']]->setValue($user_defined_data["f_" . $field_id]);
                 $custom_fields["udf_" . $definition['field_id']]->setUseRte(true);
             } else {
                 $custom_fields["udf_" . $definition['field_id']] = new ilSelectInputGUI($definition['field_name'], "udf_" . $definition['field_id']);
                 $custom_fields["udf_" . $definition['field_id']]->setValue($user_defined_data["f_" . $field_id]);
                 $custom_fields["udf_" . $definition['field_id']]->setOptions($user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
             }
         }
         if ($definition['required']) {
             $custom_fields["udf_" . $definition['field_id']]->setRequired(true);
         }
     }
     // standard fields
     include_once "./Services/User/classes/class.ilUserProfile.php";
     $up = new ilUserProfile();
     $up->setMode(ilUserProfile::MODE_REGISTRATION);
     $up->skipGroup("preferences");
     // add fields to form
     $up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
     unset($custom_fields);
     // set language selection to current display language
     $flang = $this->form->getItemByPostVar("usr_language");
     if ($flang) {
         $flang->setValue($lng->getLangKey());
     }
     // add information to role selection (if not hidden)
     if ($this->code_enabled) {
         $role = $this->form->getItemByPostVar("usr_roles");
         if ($role && $role->getType() == "select") {
             $role->setInfo($lng->txt("registration_code_role_info"));
         }
     }
     // #11407
     $domains = array();
     foreach ($this->registration_settings->getAllowedDomains() as $item) {
         if (trim($item)) {
             $domains[] = $item;
         }
     }
     if (sizeof($domains)) {
         $mail_obj = $this->form->getItemByPostVar('usr_email');
         $mail_obj->setInfo(sprintf($lng->txt("reg_email_domains"), implode(", ", $domains)) . "<br />" . ($this->code_enabled ? $lng->txt("reg_email_domains_code") : ""));
     }
     if (ilTermsOfServiceHelper::isEnabled()) {
         try {
             require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
             $document = ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng);
             $field = new ilFormSectionHeaderGUI();
             $field->setTitle($lng->txt('usr_agreement'));
             $this->form->addItem($field);
             $field = new ilCustomInputGUI();
             $field->setHTML('<div id="agreement">' . $document->getContent() . '</div>');
             $this->form->addItem($field);
             $field = new ilCheckboxInputGUI($lng->txt('accept_usr_agreement'), 'accept_terms_of_service');
             $field->setRequired(true);
             $field->setValue(1);
             $this->form->addItem($field);
         } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) {
         }
     }
     require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
     if (ilCaptchaUtil::isActiveForRegistration()) {
         require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
         $captcha = new ilCaptchaInputGUI($lng->txt("captcha_code"), 'captcha_code');
         $captcha->setRequired(true);
         $this->form->addItem($captcha);
     }
     $this->form->addCommandButton("saveForm", $lng->txt("register"));
 }
 function initFormValues()
 {
     if ($this->registration_settings->roleSelectionEnabled()) {
         $role_type = IL_REG_ROLES_FIXED;
     } else {
         if ($this->registration_settings->automaticRoleAssignmentEnabled()) {
             $role_type = IL_REG_ROLES_EMAIL;
         }
     }
     require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
     $values = array('reg_type' => $this->registration_settings->getRegistrationType(), 'reg_hash_life_time' => (int) $this->registration_settings->getRegistrationHashLifetime(), 'reg_pwd' => $this->registration_settings->passwordGenerationEnabled(), 'reg_approver' => $this->registration_settings->getApproveRecipientLogins(), 'reg_role_type' => $role_type, 'reg_access_limitation' => $this->registration_settings->getAccessLimitation(), 'reg_allowed_domains' => implode(';', $this->registration_settings->getAllowedDomains()), 'activate_captcha_anonym' => ilCaptchaUtil::isActiveForRegistration());
     $allow_codes = $this->registration_settings->getAllowCodes();
     $reg_type = $this->registration_settings->getRegistrationType();
     if ($allow_codes && in_array($reg_type, array(IL_REG_DIRECT, IL_REG_APPROVE, IL_REG_ACTIVATION))) {
         $values['reg_codes_' . $reg_type] = true;
     }
     $this->form_gui->setValuesByArray($values);
 }