protected function initForm() { $this->setTitle($this->pl->txt('form_title')); $te = new ilSelectInputGUI($this->txt(self::F_UDF_FIELD_ID), self::F_UDF_FIELD_ID); $te->setDisabled(!$this->is_new); $te->setRequired(true); $te->setOptions(ilUDFCheck::getDefinitionData()); $this->addItem($te); if (!$this->is_new) { $te = new ilHiddenInputGUI($this->txt(self::F_UDF_FIELD_ID), self::F_UDF_FIELD_ID); $this->addItem($te); switch (ilUDFCheck::getDefinitionTypeForId($this->object->getUdfFieldId())) { case ilUDFCheck::TYPE_TEXT: $se = new ilTextInputGUI($this->pl->txt(self::F_CHECK_VALUE), self::F_CHECK_VALUE); $this->addItem($se); break; case ilUDFCheck::TYPE_SELECT: $se = new ilSelectInputGUI($this->pl->txt(self::F_CHECK_VALUE), self::F_CHECK_VALUE); $se->setOptions(ilUDFCheck::getDefinitionValuesForId($this->object->getUdfFieldId())); $this->addItem($se); break; } } $this->addCommandButtons(); }
/** * Add standard fields to form */ function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL) { global $ilSetting, $lng, $rbacreview, $ilias; // custom registration settings if (self::$mode == self::MODE_REGISTRATION) { include_once 'Services/Registration/classes/class.ilRegistrationSettings.php'; $registration_settings = new ilRegistrationSettings(); self::$user_field["username"]["group"] = "login_data"; self::$user_field["password"]["group"] = "login_data"; self::$user_field["language"]["default"] = $lng->lang_key; // different position for role $roles = self::$user_field["roles"]; unset(self::$user_field["roles"]); self::$user_field["roles"] = $roles; self::$user_field["roles"]["group"] = "settings"; } $fields = $this->getStandardFields(); $current_group = ""; $custom_fields_done = false; foreach ($fields as $f => $p) { // next group? -> diplay subheader if ($p["group"] != $current_group && ilUserProfile::userSettingVisible($f)) { if (is_array($custom_fields) && !$custom_fields_done) { // should be appended to "other" or at least before "settings" if ($current_group == "other" || $p["group"] == "settings") { // add "other" subheader if ($current_group != "other") { $sh = new ilFormSectionHeaderGUI(); $sh->setTitle($lng->txt("other")); $a_form->addItem($sh); } foreach ($custom_fields as $custom_field) { $a_form->addItem($custom_field); } $custom_fields_done = true; } } $sh = new ilFormSectionHeaderGUI(); $sh->setTitle($lng->txt($p["group"])); $a_form->addItem($sh); $current_group = $p["group"]; } $m = ""; if (isset($p["method"])) { $m = $p["method"]; } $lv = isset($p["lang_var"]) && $p["lang_var"] != "" ? $p["lang_var"] : $f; switch ($p["input"]) { case "login": if ((int) $ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION) { $val = new ilTextInputGUI($lng->txt('username'), 'username'); if ($a_user) { $val->setValue($a_user->getLogin()); } $val->setMaxLength(32); $val->setSize(40); $val->setRequired(true); } else { // user account name $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un'); if ($a_user) { $val->setValue($a_user->getLogin()); } } $a_form->addItem($val); break; case "text": if (ilUserProfile::userSettingVisible($f)) { $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f); if ($a_user) { $ti->setValue($a_user->{$m}()); } $ti->setMaxLength($p["maxlength"]); $ti->setSize($p["size"]); $ti->setRequired($ilSetting->get("require_" . $f)); if (!$ti->getRequired() || $ti->getValue()) { $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } $a_form->addItem($ti); } break; case "sel_country": if (ilUserProfile::userSettingVisible($f)) { include_once "./Services/Form/classes/class.ilCountrySelectInputGUI.php"; $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_" . $f); if ($a_user) { $ci->setValue($a_user->{$m}()); } $ci->setRequired($ilSetting->get("require_" . $f)); if (!$ci->getRequired() || $ci->getValue()) { $ci->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } $a_form->addItem($ci); } break; case "birthday": if (ilUserProfile::userSettingVisible($f)) { $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_" . $f); include_once "./Services/Calendar/classes/class.ilDateTime.php"; $date = null; if ($a_user && strlen($a_user->{$m}())) { $date = new ilDateTime($a_user->{$m}(), IL_CAL_DATE); $bi->setDate($date); } $bi->setShowEmpty(true); $bi->setStartYear(1900); $bi->setRequired($ilSetting->get("require_" . $f)); if (!$bi->getRequired() || $date) { $bi->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } $a_form->addItem($bi); } break; case "radio": if (ilUserProfile::userSettingVisible($f)) { $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_" . $f); if ($a_user) { $rg->setValue($a_user->{$m}()); } foreach ($p["values"] as $k => $v) { $op = new ilRadioOption($lng->txt($v), $k); $rg->addOption($op); } $rg->setRequired($ilSetting->get("require_" . $f)); if (!$rg->getRequired() || $rg->getValue()) { $rg->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } $a_form->addItem($rg); } break; case "picture": if (ilUserProfile::userSettingVisible("upload") && $a_user) { $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile"); $ii->setDisabled($ilSetting->get("usr_settings_disable_upload")); $upload = $a_form->getFileUpload("userfile"); if ($upload["name"]) { $ii->setPending($upload["name"]); } else { $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true, true); if ($im != "") { $ii->setImage($im); $ii->setAlt($lng->txt("personal_picture")); } } // ilinc link as info if (ilUserProfile::userSettingVisible("upload") and $ilSetting->get("ilinc_active")) { include_once './Modules/ILinc/classes/class.ilObjiLincUser.php'; $ilinc_user = new ilObjiLincUser($a_user); if ($ilinc_user->id) { include_once './Modules/ILinc/classes/class.ilnetucateXMLAPI.php'; $ilincAPI = new ilnetucateXMLAPI(); $ilincAPI->uploadPicture($ilinc_user); $response = $ilincAPI->sendRequest("uploadPicture"); // return URL to user's personal page $url = trim($response->data['url']['cdata']); $desc = $lng->txt("ilinc_upload_pic_text") . " " . '<a href="' . $url . '">' . $lng->txt("ilinc_upload_pic_linktext") . '</a>'; $ii->setInfo($desc); } } $a_form->addItem($ii); } break; case "roles": if (self::$mode == self::MODE_DESKTOP) { if (ilUserProfile::userSettingVisible("roles")) { $global_roles = $rbacreview->getGlobalRoles(); foreach ($global_roles as $role_id) { if (in_array($role_id, $rbacreview->assignedRoles($a_user->getId()))) { $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id); $role_names .= $roleObj->getTitle() . ", "; unset($roleObj); } } $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr"); $dr->setValue(substr($role_names, 0, -2)); $a_form->addItem($dr); } } else { if (self::$mode == self::MODE_REGISTRATION) { if ($registration_settings->roleSelectionEnabled()) { include_once "./Services/AccessControl/classes/class.ilObjRole.php"; $options = array(); foreach (ilObjRole::_lookupRegisterAllowed() as $role) { $options[$role["id"]] = $role["title"]; } // registration form validation will take care of missing field / value if ($options) { if (sizeof($options) > 1) { $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_" . $f); $ta->setOptions($options); $ta->setRequired($ilSetting->get("require_" . $f)); if (!$ta->getRequired()) { $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } } else { $ta = new ilHiddenInputGUI("usr_" . $f); $ta->setValue(array_shift(array_keys($options))); } $a_form->addItem($ta); } } } } break; case "email": if (ilUserProfile::userSettingVisible($f)) { $em = new ilEMailInputGUI($lng->txt($lv), "usr_" . $f); if ($a_user) { $em->setValue($a_user->{$m}()); } $em->setRequired($ilSetting->get("require_" . $f)); if (!$em->getRequired() || $em->getValue()) { $em->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } if (self::MODE_REGISTRATION == self::$mode) { $em->setRetype(true); } $a_form->addItem($em); } break; case "textarea": if (ilUserProfile::userSettingVisible($f)) { $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_" . $f); if ($a_user) { $ta->setValue($a_user->{$m}()); } $ta->setRows($p["rows"]); $ta->setCols($p["cols"]); $ta->setRequired($ilSetting->get("require_" . $f)); if (!$ta->getRequired() || $ta->getValue()) { $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } $a_form->addItem($ta); } break; case "messenger": if (ilUserProfile::userSettingVisible("instant_messengers")) { $im_arr = $p["types"]; foreach ($im_arr as $im_name) { $im = new ilTextInputGUI($lng->txt("im_" . $im_name), "usr_im_" . $im_name); if ($a_user) { $im->setValue($a_user->getInstantMessengerId($im_name)); } $im->setMaxLength($p["maxlength"]); $im->setSize($p["size"]); $im->setRequired($ilSetting->get("require_" . "instant_messengers")); if (!$im->getRequired() || $im->getValue()) { $im->setDisabled($ilSetting->get("usr_settings_disable_" . "instant_messengers")); } $a_form->addItem($im); } } break; case "password": if (self::$mode == self::MODE_REGISTRATION) { if (!$registration_settings->passwordGenerationEnabled()) { $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_" . $f); $ta->setRequired(true); // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f)); } else { $ta = new ilNonEditableValueGUI($lng->txt($lv)); $ta->setValue($lng->txt("reg_passwd_via_mail")); } $a_form->addItem($ta); } break; case "language": if (ilUserProfile::userSettingVisible($f)) { $ta = new ilSelectInputGUI($lng->txt($lv), "usr_" . $f); if ($a_user) { $ta->setValue($a_user->{$m}()); } $options = array(); $lng->loadLanguageModule("meta"); foreach ($lng->getInstalledLanguages() as $lang_key) { $options[$lang_key] = $lng->txt("meta_l_" . $lang_key); } asort($options); // #9728 $ta->setOptions($options); $ta->setRequired($ilSetting->get("require_" . $f)); if (!$ta->getRequired() || $ta->getValue()) { $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } $a_form->addItem($ta); } break; case "multitext": if (ilUserProfile::userSettingVisible($f)) { $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f); $ti->setMulti(true); if ($a_user) { $ti->setValue($a_user->{$m}()); } $ti->setMaxLength($p["maxlength"]); $ti->setSize($p["size"]); $ti->setRequired($ilSetting->get("require_" . $f)); if (!$ti->getRequired() || $ti->getValue()) { $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f)); } if ($this->ajax_href) { // add field to ajax call $ti->setDataSource($this->ajax_href . "&f=" . $f); } $a_form->addItem($ti); } break; } } // append custom fields as "other" if (is_array($custom_fields) && !$custom_fields_done) { // add "other" subheader if ($current_group != "other") { $sh = new ilFormSectionHeaderGUI(); $sh->setTitle($lng->txt("other")); $a_form->addItem($sh); } foreach ($custom_fields as $custom_field) { $a_form->addItem($custom_field); } } }
/** * @param assFormulaQuestionUnitCategory $category * @param assFormulaQuestionUnit $unit * @return ilPropertyFormGUI */ protected function initUnitForm(assFormulaQuestionUnitCategory $category = null, assFormulaQuestionUnit $unit = null) { if ($this->unit_form instanceof ilPropertyFormGUI) { return $this->unit_form; } $unit_in_use = false; if ($unit instanceof assFormulaQuestionUnit && $this->repository->isUnitInUse($unit->getId())) { $unit_in_use = true; } $this->unit_form = new ilPropertyFormGUI(); $title = new ilTextInputGUI($this->lng->txt('unit'), 'unit_title'); $title->setDisabled($unit_in_use); $title->setRequired(true); $this->unit_form->addItem($title); $baseunit = new ilSelectInputGUI($this->lng->txt('baseunit'), 'base_unit'); $items = $this->repository->getCategorizedUnits(); $options = array(); $category_name = ''; $new_category = false; foreach ((array) $items as $item) { if ($unit instanceof assFormulaQuestionUnit && $unit->getId() == $item->getId()) { continue; } /** * @var $item assFormulaQuestionUnitCategory|assFormulaQuestionUnitCategory */ if ($item instanceof assFormulaQuestionUnitCategory) { if ($category_name != $item->getDisplayString()) { $new_category = true; $category_name = $item->getDisplayString(); } continue; } $options[$item->getId()] = $item->getDisplayString() . ($new_category ? ' (' . $category_name . ')' : ''); $new_category = false; } $baseunit->setDisabled($unit_in_use); $baseunit->setOptions(array(0 => $this->lng->txt('no_selection')) + $options); $this->unit_form->addItem($baseunit); $factor = new ilNumberInputGUI($this->lng->txt('factor'), 'factor'); $factor->setRequired(true); $factor->setSize(3); $factor->setMinValue(0); $factor->allowDecimals(true); $factor->setDisabled($unit_in_use); $this->unit_form->addItem($factor); if (null === $unit) { $this->unit_form->setTitle($this->lng->txt('new_unit')); $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'addUnit')); $this->unit_form->addCommandButton('addUnit', $this->lng->txt('save')); } else { $this->ctrl->setParameter($this, 'unit_id', $unit->getId()); if ($unit_in_use) { $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'showUnitsOfCategory')); } else { $this->unit_form->addCommandButton('saveUnit', $this->lng->txt('save')); $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'saveUnit')); } $this->unit_form->setTitle(sprintf($this->lng->txt('un_sel_cat_sel_unit'), $category->getDisplayString(), $unit->getDisplayString())); } $this->unit_form->addCommandButton('showUnitsOfCategory', $this->lng->txt('cancel')); return $this->unit_form; }
/** * Init general settings form. * */ public function initGeneralSettingsForm() { global $lng, $ilUser, $styleDefinition, $ilSetting; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $this->form = new ilPropertyFormGUI(); // language if ($this->userSettingVisible("language")) { $languages = $this->lng->getInstalledLanguages(); $options = array(); foreach ($languages as $lang_key) { $options[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key); } $si = new ilSelectInputGUI($this->lng->txt("language"), "language"); $si->setOptions($options); $si->setValue($ilUser->getLanguage()); $si->setDisabled($ilSetting->get("usr_settings_disable_language")); $this->form->addItem($si); } // skin/style include_once "./Services/Style/classes/class.ilObjStyleSettings.php"; if ($this->userSettingVisible("skin_style")) { $templates = $styleDefinition->getAllTemplates(); if (is_array($templates)) { $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style"); $options = array(); foreach ($templates as $template) { // get styles information of template $styleDef = new ilStyleDefinition($template["id"]); $styleDef->startParsing(); $styles = $styleDef->getStyles(); foreach ($styles as $style) { if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"])) { continue; } $options[$template["id"] . ":" . $style["id"]] = $styleDef->getTemplateName() . " / " . $style["name"]; } } $si->setOptions($options); $si->setValue($ilUser->skin . ":" . $ilUser->prefs["style"]); $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style")); $this->form->addItem($si); } } // screen reader optimization if ($this->userSettingVisible("screen_reader_optimization")) { $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization"); $cb->setChecked($ilUser->prefs["screen_reader_optimization"]); $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization")); $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info")); $this->form->addItem($cb); } // hits per page if ($this->userSettingVisible("hits_per_page")) { $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page"); $hits_options = array(10, 15, 20, 30, 40, 50, 100, 9999); $options = array(); foreach ($hits_options as $hits_option) { $hstr = $hits_option == 9999 ? $this->lng->txt("no_limit") : $hits_option; $options[$hits_option] = $hstr; } $si->setOptions($options); $si->setValue($ilUser->prefs["hits_per_page"]); $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page")); $this->form->addItem($si); } // Users Online if ($this->userSettingVisible("show_users_online")) { $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online"); $options = array("y" => $this->lng->txt("users_online_show_y"), "associated" => $this->lng->txt("users_online_show_associated"), "n" => $this->lng->txt("users_online_show_n")); $si->setOptions($options); $si->setValue($ilUser->prefs["show_users_online"]); $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online")); $this->form->addItem($si); } // Store last visited $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited"); $options = array(0 => $this->lng->txt("user_lv_keep_entries"), 1 => $this->lng->txt("user_lv_keep_only_for_session"), 2 => $this->lng->txt("user_lv_do_not_store")); $lv->setOptions($options); $lv->setValue((int) $ilUser->prefs["store_last_visited"]); $this->form->addItem($lv); // hide_own_online_status if ($this->userSettingVisible("hide_own_online_status")) { $cb = new ilCheckboxInputGUI($this->lng->txt("hide_own_online_status"), "hide_own_online_status"); $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y"); $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status")); $this->form->addItem($cb); } include_once 'Services/Authentication/classes/class.ilSessionReminder.php'; if (ilSessionReminder::isGloballyActivated()) { $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled'); $cb->setInfo($this->lng->txt('session_reminder_info')); $cb->setValue(1); $cb->setChecked((int) $ilUser->getPref('session_reminder_enabled')); $expires = ilSession::getSessionExpireValue(); $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time'); $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilFormat::_secondsToString($expires, true))); $min_value = ilSessionReminder::MIN_LEAD_TIME; $max_value = max($min_value, (int) $expires / 60 - 1); $current_user_value = $ilUser->getPref('session_reminder_lead_time'); if ($current_user_value < $min_value || $current_user_value > $max_value) { $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME; } $value = min(max($min_value, $current_user_value), $max_value); $lead_time_gui->setValue($value); $lead_time_gui->setSize(3); $lead_time_gui->setMinValue($min_value); $lead_time_gui->setMaxValue($max_value); $cb->addSubItem($lead_time_gui); $this->form->addItem($cb); } // calendar settings (copied here to be reachable when calendar is inactive) // they cannot be hidden/deactivated include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; $lng->loadLanguageModule("dateplaner"); $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'), 'timezone'); $select->setOptions(ilCalendarUtil::_getShortTimeZoneList()); $select->setInfo($lng->txt('cal_timezone_info')); $select->setValue($user_settings->getTimeZone()); $this->form->addItem($select); $year = date("Y"); $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'), 'date_format'); $select->setOptions(array(ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year, ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31", ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year)); $select->setInfo($lng->txt('cal_date_format_info')); $select->setValue($user_settings->getDateFormat()); $this->form->addItem($select); $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'), 'time_format'); $select->setOptions(array(ilCalendarSettings::TIME_FORMAT_24 => '13:00', ilCalendarSettings::TIME_FORMAT_12 => '1:00pm')); $select->setInfo($lng->txt('cal_time_format_info')); $select->setValue($user_settings->getTimeFormat()); $this->form->addItem($select); // starting point include_once "Services/User/classes/class.ilUserUtil.php"; if (ilUserUtil::hasPersonalStartingPoint()) { $this->lng->loadLanguageModule("administration"); $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start"); $si->setRequired(true); $si->setInfo($this->lng->txt("adm_user_starting_point_info")); foreach (ilUserUtil::getPossibleStartingPoints() as $value => $caption) { $si->addOption(new ilRadioOption($caption, $value)); } $si->setValue(ilUserUtil::getPersonalStartingPoint()); $this->form->addItem($si); // starting point: repository object $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ); $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id"); $repobj_id->setRequired(true); $repobj_id->setSize(5); if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) { $start_ref_id = ilUserUtil::getPersonalStartingObject(); $repobj_id->setValue($start_ref_id); if ($start_ref_id) { $start_obj_id = ilObject::_lookupObjId($start_ref_id); if ($start_obj_id) { $repobj_id->setInfo($lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) . ": " . ilObject::_lookupTitle($start_obj_id)); } } } $repobj->addSubItem($repobj_id); $si->addOption($repobj); } // selector for unicode characters global $ilSetting; if ($ilSetting->get('char_selector_availability') > 0) { require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_USER); $char_selector->getConfig()->setAvailability($ilUser->getPref('char_selector_availability')); $char_selector->getConfig()->setDefinition($ilUser->getPref('char_selector_definition')); $char_selector->addFormProperties($this->form); $char_selector->setFormValues($this->form); } $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save")); $this->form->setTitle($lng->txt("general_settings")); $this->form->setFormAction($this->ctrl->getFormAction($this)); }
/** * Show special form for ecs start * * @access private * @param object ilAdvMDFieldDefinition */ private function showECSStart($def) { global $ilUser; $this->lng->loadLanguageModule('ecs'); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; $value_start = ilAdvancedMDValue::_getInstance($this->obj_id, $def->getFieldId()); $unixtime = $value_start->getValue() ? $value_start->getValue() : mktime(8, 0, 0, date('m'), date('d'), date('Y')); $time = new ilDateTimeInputGUI($this->lng->txt('ecs_event_appointment'), 'md[' . $def->getFieldId() . ']'); $time->setShowTime(true); $time->setDate(new ilDateTime($unixtime, IL_CAL_UNIX)); $time->enableDateActivation($this->lng->txt('enabled'), 'md_activated[' . $def->getFieldId() . ']', $value_start->getValue() ? true : false); $time->setDisabled($value_start->isDisabled()); $mapping = ilECSDataMappingSettings::_getInstance(); if ($field_id = $mapping->getMappingByECSName('end')) { $value_end = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); list($hours, $minutes) = $this->parseDuration($value_start->getValue(), $value_end->getValue()); $duration = new ilDurationInputGUI($this->lng->txt('ecs_duration'), 'ecs_duration'); $duration->setHours($hours); $duration->setMinutes($minutes); #$duration->setInfo($this->lng->txt('ecs_duration_info')); $duration->setShowHours(true); $duration->setShowMinutes(true); $time->addSubItem($duration); } if ($field_id = $mapping->getMappingByECSName('cycle')) { $value = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $cycle_def = ilAdvancedMDFieldDefinition::getInstance($field_id); switch ($cycle_def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($cycle_def->getTitle(), 'md[' . $cycle_def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(20); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $time->addSubItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($cycle_def->getTitle(), 'md[' . $cycle_def->getFieldId() . ']'); $select->setOptions($cycle_def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $time->addSubItem($select); break; } } if ($field_id = $mapping->getMappingByECSName('room')) { $value = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $room_def = ilAdvancedMDFieldDefinition::getInstance($field_id); switch ($room_def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($room_def->getTitle(), 'md[' . $room_def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(20); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $time->addSubItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($room_def->getTitle(), 'md[' . $room_def->getFieldId() . ']'); $select->setOptions($cycle_def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $time->addSubItem($select); break; } } $this->form->addItem($time); }
/** * Ini form for room size * @param ilPropertyFormGUI $form * @return bool */ protected function initFormRoomSize(ilPropertyFormGUI $form, $a_create = true) { $room_size_list = ilViteroUtils::getRoomSizeList(); if (!count($room_size_list)) { return false; } $room_size = new ilSelectInputGUI(ilViteroPlugin::getInstance()->txt('room_size'), 'room_size'); $room_size->setOptions($room_size_list); if (!$a_create) { $room_size->setDisabled(true); } $form->addItem($room_size); return true; }
/** * Initializes a form for either displaying a room, adding a new room or editing an existing * room. The difference between those three forms is subtle but important: the form for * displaying rooms displays the information of the room without the ability of editing them. * The form for creating a room allows the input of values but contains no values initially. The * form for editing a room contains information that have been set before. * The creation of either those forms is determined by the mode parameter. * * @param string $a_mode the mode this form is centered around * * @return ilPropertyFormGUI the form with the given mode */ private function initForm($a_mode = "show") { $form_gui =& new ilPropertyFormGUI(); $form_gui->setMultipart(true); $form_gui->setTitle($this->lng->txt("rep_robj_xrs_room_properties")); $form_gui->setDescription($this->lng->txt("rep_robj_xrs_room_prop_description")); $name = new ilRoomSharingTextInputGUI($this->lng->txt("rep_robj_xrs_room_name"), "name"); $name->setDisabled(true); $form_gui->addItem($name); $type = new ilRoomSharingTextInputGUI($this->lng->txt("rep_robj_xrs_room_type"), "type"); $type->setDisabled(true); $form_gui->addItem($type); $min_alloc = new ilRoomSharingNumberInputGUI($this->lng->txt("rep_robj_xrs_room_min_alloc"), "min_alloc"); $min_alloc->setDisabled(true); $form_gui->addItem($min_alloc); $max_alloc = new ilRoomSharingNumberInputGUI($this->lng->txt("rep_robj_xrs_room_max_alloc"), "max_alloc"); $max_alloc->setDisabled(true); $form_gui->addItem($max_alloc); $floor_plan = new ilSelectInputGUI($this->lng->txt("rep_robj_xrs_room_floor_plans"), "file_id"); $floor_plan->setOptions($this->room_obj->getAllFloorplans()); $floor_plan->setDisabled(true); $form_gui->addItem($floor_plan); if (count($this->room_obj->getAllAvailableAttributes())) { $defined_attributes = $this->room_obj->getAttributes(); $show_mode_with_exist_attrs = $a_mode == "show" && count($defined_attributes) > 0; if ($a_mode == "edit" || $a_mode == "create" || $show_mode_with_exist_attrs) { $attributes_header = new ilFormSectionHeaderGUI(); $attribute_header_text = $this->createAttributeHeaderText(); $attributes_header->setTitle($this->lng->txt("rep_robj_xrs_room_attributes") . $attribute_header_text); $form_gui->addItem($attributes_header); } foreach ($this->room_obj->getAllAvailableAttributes() as $attr) { $attribute_amount_by_id = $this->room_obj->getAttributeAmountById($attr['id']); $amount_not_given = !ilRoomSharingNumericUtils::isPositiveNumber($attribute_amount_by_id, true); if ($a_mode == "show" && $amount_not_given) { continue; } else { $attr_field = new ilRoomSharingNumberInputGUI($attr['name'], self::ATTRIBUTE_ID_PREFIX . $attr['id']); $attr_field->setValue($attribute_amount_by_id); $attr_field->setMinValue(0); $attr_field->setDisabled($a_mode == "show"); $form_gui->addItem($attr_field); } } } if ($a_mode == "edit" || $a_mode == "create") { $name->setDisabled(false); $name->setRequired(true); $type->setDisabled(false); $min_alloc->setDisabled(false); $min_alloc->setMinValue(0); $max_alloc->setDisabled(false); $max_alloc->setRequired(true); $max_alloc->setMinValue(0); $floor_plan->setDisabled(false); if ($a_mode == "create") { $min_alloc->setValue("0"); $form_gui->addCommandButton($this->ctrl->getLinkTarget($this, "addRoom"), $this->lng->txt("rep_robj_xrs_add_room")); } else { $form_gui->addCommandButton("saveRoom", $this->lng->txt("save")); } } if ($a_mode == "edit" || $a_mode == "show") { $name->setValue($this->room_obj->getName()); $type->setValue($this->room_obj->getType()); $min_alloc->setValue($this->room_obj->getMinAlloc()); $max_alloc->setValue($this->room_obj->getMaxAlloc()); $floor_plan->setValue($this->room_obj->getFileId()); if ($a_mode == "show") { $floor_plan->setDisabled(true); $mobj = new ilObjMediaObject($this->room_obj->getFileId()); $mitems = $mobj->getMediaItems(); if (!empty($mitems)) { $med = $mobj->getMediaItem("Standard"); $target = $med->getThumbnailTarget(); $image_with_link = "<br><a target='_blank' href='" . $mobj->getDataDirectory() . "/" . $med->getLocation() . "'>" . ilUtil::img($target) . "</a>"; $floor_plan->setInfo($image_with_link); } } } $form_gui->setFormAction($this->ctrl->getFormAction($this)); return $form_gui; }
/** * Initialises the mail options form * * @access private * */ private function initMailOptionsForm() { global $ilCtrl, $ilSetting, $lng, $ilUser; include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $this->form = new ilPropertyFormGUI(); $this->form->setFormAction($ilCtrl->getFormAction($this, 'saveOptions')); $this->form->setTitle($lng->txt('mail_settings')); // BEGIN INCOMING if ($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1') { $options = array(IL_MAIL_LOCAL => $lng->txt('mail_incoming_local'), IL_MAIL_EMAIL => $lng->txt('mail_incoming_smtp'), IL_MAIL_BOTH => $lng->txt('mail_incoming_both')); $si = new ilSelectInputGUI($lng->txt('mail_incoming'), 'incoming_type'); $si->setOptions($options); if (!strlen(ilObjUser::_lookupEmail($ilUser->getId())) || $ilSetting->get('usr_settings_disable_mail_incoming_mail') == '1') { $si->setDisabled(true); } $this->form->addItem($si); } // BEGIN LINEBREAK_OPTIONS $options = array(); for ($i = 50; $i <= 80; $i++) { $options[$i] = $i; } $si = new ilSelectInputGUI($lng->txt('linebreak'), 'linebreak'); $si->setOptions($options); $this->form->addItem($si); // BEGIN SIGNATURE $ta = new ilTextAreaInputGUI($lng->txt('signature'), 'signature'); $ta->setRows(10); $ta->setCols(60); $this->form->addItem($ta); // BEGIN CRONJOB NOTIFICATION if ($ilSetting->get('mail_notification')) { $cb = new ilCheckboxInputGUI($lng->txt('cron_mail_notification'), 'cronjob_notification'); $cb->setInfo($lng->txt('mail_cronjob_notification_info')); $cb->setValue(1); $this->form->addItem($cb); } $this->form->addCommandButton('saveOptions', $lng->txt('save')); }
/** * Creates a form to add a heading to a survey * * @param integer $question_id The id of the question directly after the heading. If the id is given, an existing heading will be edited * @access public */ function addHeadingObject($checkonly = false, $question_id = "") { $this->questionsSubtabs("questions"); global $ilAccess; $save = strcmp($this->ctrl->getCmd(), "saveHeading") == 0 ? TRUE : FALSE; include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $form->setTableWidth("100%"); $form->setId("survey_heading"); // general properties $header = new ilFormSectionHeaderGUI(); if ($question_id) { $header->setTitle($this->lng->txt("edit_heading")); } else { $header->setTitle($this->lng->txt("add_heading")); } $form->addItem($header); $survey_questions =& $this->object->getSurveyQuestions(); // heading $heading = new ilTextAreaInputGUI($this->lng->txt("heading"), "heading"); $heading->setValue($this->object->prepareTextareaOutput(array_key_exists('heading', $_POST) ? $_POST['heading'] : $survey_questions[$question_id]["heading"])); $heading->setRows(10); $heading->setCols(80); $heading->setUseRte(TRUE); include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $heading->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey")); $heading->removePlugin(ilRTE::ILIAS_IMG_MANAGER_PLUGIN); $heading->setRTESupport($this->object->getId(), "svy", "survey", null, false, "3.4.7"); $heading->setRequired(true); $form->addItem($heading); $insertbefore = new ilSelectInputGUI($this->lng->txt("insert"), "insertbefore"); $options = array(); foreach ($survey_questions as $key => $value) { $options[$key] = $this->lng->txt("before") . ": \"" . $value["title"] . "\""; } $insertbefore->setOptions($options); $insertbefore->setValue(array_key_exists('insertbefore', $_REQUEST) ? $_REQUEST['insertbefore'] : $question_id); $insertbefore->setRequired(true); if ($question_id || array_key_exists('insertbefore', $_REQUEST)) { $insertbefore->setDisabled(true); } $form->addItem($insertbefore); if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { $form->addCommandButton("saveHeading", $this->lng->txt("save")); } if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { $form->addCommandButton("cancelHeading", $this->lng->txt("cancel")); } $errors = false; if ($save) { $errors = !$form->checkInput(); $form->setValuesByPost(); if ($errors) { $checkonly = false; } } if (!$checkonly) { $this->tpl->setVariable("ADM_CONTENT", $form->getHTML()); } return $errors; }
/** * Init form */ protected function initForm() { $this->setFormAction($this->ctrl->getFormAction($this->parent_gui)); $title = $this->isNew ? $this->pl->txt('choose_cert_type') : $this->pl->txt('edit_settings'); // Certificate Type $type = $this->getTypeInput(); $n_types = count($type->getOptions()); if ($this->isNew) { if (!$n_types) { ilUtil::sendInfo($this->pl->txt('msg_no_types_available')); } else { $this->setTitle($title); $this->addItem($type); $this->addCommandButton('createDefinition', $this->pl->txt('save')); } return; } else { if ($n_types > 1) { $this->setTitle($title); $checkbox = new ilCheckboxInputGUI($this->pl->txt('change_cert_type'), 'change_type'); $checkbox->addSubItem($type); $checkbox->setInfo($this->pl->txt('current_type') . ' ' . $this->definition->getType()->getTitle()); $this->addItem($checkbox); } } // Add all settings inputs $settings_inputs = $this->getSettingsInputs(); $header = new ilFormSectionHeaderGUI(); $header->setTitle($this->pl->txt('certificate')); $this->addItem($header); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_DEFAULT_LANG]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_VALIDITY_TYPE]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_GENERATION]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_DOWNLOADABLE]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_SCORM_TIMING]); // Custom settings /** @var srCertificateCustomDefinitionSetting $setting */ foreach ($this->definition->getCustomSettings() as $setting) { switch ($setting->getSettingTypeId()) { case srCertificateCustomTypeSetting::SETTING_TYPE_BOOLEAN: $item = new ilCheckboxInputGUI($setting->getLabel($this->user->getLanguage()), 'custom_setting_' . $setting->getIdentifier()); if ($setting->getValue()) { $item->setChecked(true); } break; case srCertificateCustomTypeSetting::SETTING_TYPE_SELECT: $item = new ilSelectInputGUI($setting->getLabel($this->user->getLanguage()), 'custom_setting_' . $setting->getIdentifier()); $item->setValue($setting->getValue()); $item->setOptions($setting->getCustomTypeSetting()->getData(true)); break; } $item->setDisabled(!$setting->isEditable()); $this->addItem($item); } // Notification $header = new ilFormSectionHeaderGUI(); $header->setTitle($this->pl->txt('setting_id_notification')); $this->addItem($header); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_NOTIFICATION]); if (isset($settings_inputs[srCertificateTypeSetting::IDENTIFIER_NOTIFICATION_USER])) { $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_NOTIFICATION_USER]); } $this->addCommandButton("updateDefinition", "Save"); }