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"));
         }
     }
     // user agreement
     $field = new ilFormSectionHeaderGUI();
     $field->setTitle($lng->txt("usr_agreement"));
     $this->form->addItem($field);
     $field = new ilCustomInputGUI();
     $field->setHTML('<div id="agreement">' . ilUserAgreement::_getText() . '</div>');
     $this->form->addItem($field);
     $field = new ilCheckboxInputGUI($lng->txt("accept_usr_agreement"), "usr_agreement");
     $field->setRequired(true);
     $field->setValue(1);
     $this->form->addItem($field);
     $this->form->addCommandButton("saveForm", $lng->txt("register"));
 }
 /**
  * show user agreement
  */
 function showUserAgreement()
 {
     global $lng, $tpl, $ilUser;
     require_once "./Services/User/classes/class.ilUserAgreement.php";
     $tpl->addBlockFile("CONTENT", "content", "tpl.startup_screen.html", "Services/Init");
     $tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
     $tpl->addBlockFile("STARTUP_CONTENT", "startup_content", "tpl.view_usr_agreement.html", "Services/Init");
     $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
     //		ilUtil::sendInfo();
     // display infopanel if something happened
     ilUtil::infoPanel();
     // language selection
     $languages = $lng->getInstalledLanguages();
     // #11237
     if (sizeof($languages) > 1) {
         $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
         $tpl->setVariable("TXT_OK", $lng->txt("ok"));
         $count = (int) round(count($languages) / 2);
         $num = 1;
         foreach ($languages as $lang_key) {
             $tpl->setCurrentBlock("languages");
             $tpl->setVariable("LANG_VAL_CMD", $this->ctrl->getCmd());
             $tpl->setVariable("AGR_LANG_ACTION", $this->ctrl->getFormAction($this));
             $tpl->setVariable("LANG_NAME", ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key));
             $tpl->setVariable("LANG_ICON", $lang_key);
             $tpl->setVariable("LANG_KEY", $lang_key);
             $tpl->setVariable("BORDER", 0);
             $tpl->setVariable("VSPACE", 0);
             $tpl->parseCurrentBlock();
             $num++;
         }
     }
     $tpl->setCurrentBlock("content");
     // display tabs
     $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("usr_agreement"));
     $tpl->setVariable("TXT_PAGETITLE", "ILIAS3 - " . $lng->txt("usr_agreement"));
     $tpl->setVariable("TXT_USR_AGREEMENT", ilUserAgreement::_getText());
     if ($this->ctrl->getCmd() == "getAcceptance") {
         if ($_POST["status"] == "accepted") {
             $ilUser->writeAccepted();
             ilUtil::redirect("index.php?target=" . $_GET["target"] . "&client_id=" . CLIENT_ID);
         }
         $tpl->setVariable("VAL_CMD", "getAcceptance");
         $tpl->setVariable("AGR_LANG_ACTION", $this->ctrl->getFormAction($this));
         $tpl->setCurrentBlock("get_acceptance");
         $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
         $tpl->setVariable("ACCEPT_CHECKBOX", ilUtil::formCheckbox(0, "status", "accepted"));
         $tpl->setVariable("ACCEPT_AGREEMENT", $lng->txt("accept_usr_agreement"));
         $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
         $tpl->parseCurrentBlock();
     } else {
         $tpl->setCurrentBlock("back");
         $tpl->setVariable("BACK", $lng->txt("back"));
         $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTargetByClass("ilstartupgui", "showLogin"));
         $tpl->parseCurrentBlock();
     }
     $tpl->show();
 }