/**
  * Add fields to form
  *
  * @param ilPropertyformGUI $form
  * @param array $prefs
  * @param object $parent
  * @param bool $a_anonymized
  */
 public function showPublicProfileFields(ilPropertyformGUI $form, array $prefs, $parent = null, $anonymized = false)
 {
     global $ilUser;
     $birthday = $ilUser->getBirthday();
     if ($birthday) {
         $birthday = ilDatePresentation::formatDate(new ilDate($birthday, IL_CAL_DATE));
     }
     $gender = $ilUser->getGender();
     if ($gender) {
         $gender = $this->lng->txt("gender_" . $gender);
     }
     if ($ilUser->getSelectedCountry() != "") {
         $this->lng->loadLanguageModule("meta");
         $txt_sel_country = $this->lng->txt("meta_c_" . $ilUser->getSelectedCountry());
     }
     // profile picture
     $pic = ilObjUser::_getPersonalPicturePath($ilUser->getId(), "xsmall", true, true);
     if ($pic) {
         $pic = "<img src=\"" . $pic . "\" />";
     }
     // personal data
     $val_array = array("title" => $ilUser->getUTitle(), "birthday" => $birthday, "gender" => $gender, "upload" => $pic, "interests_general" => $ilUser->getGeneralInterestsAsText(), "interests_help_offered" => $ilUser->getOfferingHelpAsText(), "interests_help_looking" => $ilUser->getLookingForHelpAsText(), "institution" => $ilUser->getInstitution(), "department" => $ilUser->getDepartment(), "street" => $ilUser->getStreet(), "zipcode" => $ilUser->getZipcode(), "city" => $ilUser->getCity(), "country" => $ilUser->getCountry(), "sel_country" => $txt_sel_country, "phone_office" => $ilUser->getPhoneOffice(), "phone_home" => $ilUser->getPhoneHome(), "phone_mobile" => $ilUser->getPhoneMobile(), "fax" => $ilUser->getFax(), "email" => $ilUser->getEmail(), "hobby" => $ilUser->getHobby(), "matriculation" => $ilUser->getMatriculation(), "delicious" => $ilUser->getDelicious());
     // location
     include_once "./Services/Maps/classes/class.ilMapUtil.php";
     if (ilMapUtil::isActivated()) {
         $val_array["location"] = "";
     }
     foreach ($val_array as $key => $value) {
         if ($anonymized) {
             $value = null;
         }
         if ($this->userSettingVisible($key)) {
             // public setting
             if ($key == "upload") {
                 $cb = new ilCheckboxInputGUI($this->lng->txt("personal_picture"), "chk_" . $key);
             } else {
                 $cb = new ilCheckboxInputGUI($this->lng->txt($key), "chk_" . $key);
             }
             if ($prefs["public_" . $key] == "y") {
                 $cb->setChecked(true);
             }
             //$cb->setInfo($value);
             $cb->setOptionTitle($value);
             if (!$parent) {
                 $form->addItem($cb);
             } else {
                 $parent->addSubItem($cb);
             }
         }
     }
     $im_arr = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
     if ($this->userSettingVisible("instant_messengers")) {
         foreach ($im_arr as $im) {
             // public setting
             $cb = new ilCheckboxInputGUI($this->lng->txt("im_" . $im), "chk_im_" . $im);
             //$cb->setInfo($ilUser->getInstantMessengerId($im));
             $cb->setOptionTitle($ilUser->getInstantMessengerId($im));
             if ($prefs["public_im_" . $im] != "n") {
                 $cb->setChecked(true);
             }
             if (!$parent) {
                 $form->addItem($cb);
             } else {
                 $parent->addSubItem($cb);
             }
         }
     }
     // additional defined user data fields
     $user_defined_data = array();
     if (!$anonymized) {
         $user_defined_data = $ilUser->getUserDefinedData();
     }
     foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
         // public setting
         $cb = new ilCheckboxInputGUI($definition["field_name"], "chk_udf_" . $definition["field_id"]);
         $cb->setOptionTitle($user_defined_data["f_" . $definition["field_id"]]);
         if ($prefs["public_udf_" . $definition["field_id"]] == "y") {
             $cb->setChecked(true);
         }
         if (!$parent) {
             $form->addItem($cb);
         } else {
             $parent->addSubItem($cb);
         }
     }
 }
 public function generateCodes($view = "choice")
 {
     $this->coupon_obj->setId($_GET['coupon_id']);
     $this->ctrl->setParameter($this, 'coupon_id', $_GET['coupon_id']);
     $this->__showButtons();
     $this->coupon_obj->getCouponById(ilUtil::stripSlashes($_GET['coupon_id']));
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     $oForm_1 = new ilPropertyFormGUI();
     $oForm_1->setId('save_frm');
     $oForm_1->setFormAction($this->ctrl->getFormAction($this), 'saveCodeForm');
     $oForm_1->setTitle($this->lng->txt("paya_coupons_coupon") . " " . $this->coupon_obj->getTitle() . ": " . $this->lng->txt('paya_coupons_code_generation'));
     if ($view == "choice") {
         $oTypeRadio = new ilRadioGroupInputGUI($this->lng->txt('paya_coupons_generate_codes'), 'generate_type');
         $radio_option = new ilRadioOption($this->lng->txt('paya_coupons_type_auto'), 'auto');
         $oTypeRadio->addOption($radio_option);
         $radio_option = new ilRadioOption($this->lng->txt('paya_coupons_type_self'), 'self');
         $oTypeRadio->addOption($radio_option);
         $oTypeRadio->setValue(isset($_POST["generate_type"]) ? $_POST["generate_type"] : "auto");
         $oTypeRadio->setPostVar('generate_type');
         $oForm_1->addItem($oTypeRadio);
         $oNumCodes = new ilNumberInputGUI($this->lng->txt("paya_coupons_number_of_codes"), 'generate_number');
         $oNumCodes->setSize(5);
         $oNumCodes->setValue($_POST['generate_number']);
         $oNumCodes->setRequired(true);
         $oForm_1->addItem($oNumCodes);
         $oLength = new ilNumberInputGUI($this->lng->txt("paya_coupons_code_length"), 'generate_length');
         $oLength->setSize(5);
         $oLength->setValue($_POST['generate_length']);
         $oLength->setRequired(true);
         $oLength->setInfo($this->lng->txt('paya_coupons_type_self'));
         $oForm_1->addItem($oLength);
         $oForm_1->addCommandButton('saveCodeForm', $this->lng->txt('save'));
         $this->tpl->setVariable('FORM', $oForm_1->getHTML());
         $oForm_2 = new ilPropertyformGUI();
         $oForm_2->setId('import_frm');
         $oForm_2->setFormAction($this->ctrl->getFormAction($this), 'showCodeImport');
         $oForm_2->addCommandButton('showCodeImport', $this->lng->txt('import'));
         $this->tpl->setVariable('FORM_2', $oForm_2->getHTML());
     } else {
         if ($view == "input") {
             if (is_numeric($_POST['generate_number']) && $_POST['generate_number'] > 0) {
                 for ($i = 0; $i < $_POST['generate_number']; $i++) {
                     $index = $i + 1;
                     $oLoopCode = new ilTextInputGUI('#' . $index, 'codes[' . $i . ']');
                     $oForm_1->addItem($oLoopCode);
                 }
                 $oForm_1->addCommandButton('saveCodeForm', $this->lng->txt('save'));
             }
             $this->tpl->setVariable('FORM', $oForm_1->getHTML());
             $oLoopCode = new ilTextInputGUI();
         }
     }
     return true;
 }