/**
  * init edit/create category form 
  *
  * @access protected
  * @return
  */
 protected function initFormCategory($a_mode)
 {
     global $rbacsystem, $ilUser;
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo((int) $_GET['category_id']);
     $this->form = new ilPropertyFormGUI();
     #$this->form->setTableWidth('40%');
     switch ($a_mode) {
         case 'edit':
             $category = new ilCalendarCategory((int) $_GET['category_id']);
             $this->form->setTitle($this->lng->txt('cal_edit_category'));
             $this->ctrl->saveParameter($this, array('seed', 'category_id'));
             $this->form->setFormAction($this->ctrl->getFormAction($this));
             if ($this->isEditable()) {
                 $this->form->addCommandButton('update', $this->lng->txt('save'));
                 /*
                 					if($cat_info['type'] == ilCalendarCategory::TYPE_USR)
                 					{
                 						$this->form->addCommandButton('shareSearch',$this->lng->txt('cal_share'));
                 					}
                 					$this->form->addCommandButton('confirmDelete',$this->lng->txt('delete'));
                 */
                 $this->form->addCommandButton('manage', $this->lng->txt('cancel'));
             }
             break;
         case 'create':
             $this->editable = true;
             $category = new ilCalendarCategory(0);
             $this->ctrl->saveParameter($this, array('category_id'));
             $this->form->setFormAction($this->ctrl->getFormAction($this));
             $this->form->setTitle($this->lng->txt('cal_add_category'));
             $this->form->addCommandButton('save', $this->lng->txt('save'));
             $this->form->addCommandButton('manage', $this->lng->txt('cancel'));
             break;
     }
     // Calendar name
     $title = new ilTextInputGUI($this->lng->txt('cal_calendar_name'), 'title');
     if ($a_mode == 'edit') {
         $title->setDisabled(!$this->isEditable());
     }
     $title->setRequired(true);
     $title->setMaxLength(64);
     $title->setSize(32);
     $title->setValue($category->getTitle());
     $this->form->addItem($title);
     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
     if ($a_mode == 'create' and $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId())) {
         $type = new ilRadioGroupInputGUI($this->lng->txt('cal_cal_type'), 'type');
         $type->setValue($category->getType());
         $type->setRequired(true);
         $opt = new ilRadioOption($this->lng->txt('cal_type_personal'), ilCalendarCategory::TYPE_USR);
         $type->addOption($opt);
         $opt = new ilRadioOption($this->lng->txt('cal_type_system'), ilCalendarCategory::TYPE_GLOBAL);
         $type->addOption($opt);
         $type->setInfo($this->lng->txt('cal_type_info'));
         $this->form->addItem($type);
     }
     $color = new ilColorPickerInputGUI($this->lng->txt('cal_calendar_color'), 'color');
     $color->setValue($category->getColor());
     if (!$this->isEditable()) {
         $color->setDisabled(true);
     }
     $color->setRequired(true);
     $this->form->addItem($color);
     $location = new ilRadioGroupInputGUI($this->lng->txt('cal_type_rl'), 'type_rl');
     $location->setDisabled($a_mode == 'edit');
     $location_local = new ilRadioOption($this->lng->txt('cal_type_local'), ilCalendarCategory::LTYPE_LOCAL);
     $location->addOption($location_local);
     $location_remote = new ilRadioOption($this->lng->txt('cal_type_remote'), ilCalendarCategory::LTYPE_REMOTE);
     $location->addOption($location_remote);
     $location->setValue($category->getLocationType());
     $url = new ilTextInputGUI($this->lng->txt('cal_remote_url'), 'remote_url');
     $url->setDisabled($a_mode == 'edit');
     $url->setValue($category->getRemoteUrl());
     $url->setMaxLength(500);
     $url->setSize(60);
     $url->setRequired(true);
     $location_remote->addSubItem($url);
     $user = new ilTextInputGUI($this->lng->txt('username'), 'remote_user');
     $user->setDisabled($a_mode == 'edit');
     $user->setValue($category->getRemoteUser());
     $user->setMaxLength(50);
     $user->setSize(20);
     $user->setRequired(false);
     $location_remote->addSubItem($user);
     $pass = new ilPasswordInputGUI($this->lng->txt('password'), 'remote_pass');
     $pass->setDisabled($a_mode == 'edit');
     $pass->setValue($category->getRemotePass());
     $pass->setMaxLength(50);
     $pass->setSize(20);
     $pass->setRetype(false);
     $pass->setInfo($this->lng->txt('remote_pass_info'));
     $location_remote->addSubItem($pass);
     $this->form->addItem($location);
 }
 /**
  * Insert property html
  *
  * @return	int	Size
  */
 function insert($a_tpl)
 {
     global $tpl;
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initColorPicker();
     $a_tpl->setCurrentBlock("prop_color");
     $js_tpl = new ilTemplate('tpl.color_picker.js', true, true, 'Services/Form');
     $js_tpl->setVariable('THUMB_PATH', ilUtil::getImagePath('color_picker_thumb.png', 'Services/Form'));
     $js_tpl->setVariable('HUE_THUMB_PATH', ilUtil::getImagePath('color_picker_hue_thumb.png', 'Services/Form'));
     $js_tpl->setVariable('COLOR_ID', $this->getFieldId());
     $ic = ilColorPickerInputGUI::determineHexcode($this->getHexcode());
     if ($ic == "") {
         $ic = "FFFFFF";
     }
     $js_tpl->setVariable('INIT_COLOR_SHORT', $ic);
     $js_tpl->setVariable('INIT_COLOR', '#' . $this->getHexcode());
     $js_tpl->setVariable('POST_VAR', $this->getPostVar());
     if ($this->getDisabled()) {
         $a_tpl->setVariable('COLOR_DISABLED', 'disabled="disabled"');
     } else {
         $a_tpl->setVariable('PROP_COLOR_JS', $js_tpl->get());
     }
     $a_tpl->setVariable("POST_VAR", $this->getPostVar());
     $a_tpl->setVariable("PROP_COLOR_ID", $this->getFieldId());
     if (substr(trim($this->getValue()), 0, 1) == "!" && $this->getAcceptNamedColors()) {
         $a_tpl->setVariable("PROPERTY_VALUE_COLOR", ilUtil::prepareFormOutput(trim($this->getValue())));
     } else {
         $a_tpl->setVariable("PROPERTY_VALUE_COLOR", ilUtil::prepareFormOutput($this->getHexcode()));
     }
     $a_tpl->parseCurrentBlock();
 }
 /**
  * Init color form
  */
 function initColorForm($a_mode = "create")
 {
     global $lng, $ilCtrl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form_gui = new ilPropertyFormGUI();
     $this->form_gui->setTitle($lng->txt("sty_add_color"));
     // name
     $name_input = new ilRegExpInputGUI($lng->txt("sty_color_name"), "color_name");
     $name_input->setPattern("/^[a-zA-Z]+[a-zA-Z0-9]*\$/");
     $name_input->setNoMatchMessage($lng->txt("sty_msg_color_must_only_include") . " A-Z, a-z, 1-9");
     $name_input->setRequired(true);
     $name_input->setSize(15);
     $name_input->setMaxLength(15);
     $this->form_gui->addItem($name_input);
     // code
     $color_input = new ilColorPickerInputGUI($lng->txt("sty_color_code"), "color_code");
     $color_input->setRequired(true);
     $color_input->setDefaultColor("");
     $this->form_gui->addItem($color_input);
     if ($a_mode == "create") {
         $this->form_gui->addCommandButton("saveColor", $lng->txt("save"));
         $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
     } else {
         $this->form_gui->addCommandButton("updateColor", $lng->txt("save"));
         $this->form_gui->addCommandButton("cancelColorSaving", $lng->txt("cancel"));
     }
     $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
 }
 private function buildSettingsForm()
 {
     /**
      * @var $ilAccess ilAccessHandler
      */
     global $ilAccess;
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTableWidth("100%");
     $form->setId("settings");
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt('settings'));
     $form->addItem($header);
     // question process locking behaviour (e.g. on saving users working data)
     $chb = new ilCheckboxInputGUI($this->lng->txt('ass_process_lock'), 'ass_process_lock');
     $chb->setChecked($this->object->getAssessmentProcessLockMode() != ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE);
     $chb->setInfo($this->lng->txt('ass_process_lock_desc'));
     $form->addItem($chb);
     $rg = new ilRadioGroupInputGUI($this->lng->txt('ass_process_lock_mode'), 'ass_process_lock_mode');
     $rg->setRequired(true);
     $opt = new ilRadioOption($this->lng->txt('ass_process_lock_mode_file'), ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_FILE);
     $opt->setInfo($this->lng->txt('ass_process_lock_mode_file_desc'));
     $rg->addOption($opt);
     $opt = new ilRadioOption($this->lng->txt('ass_process_lock_mode_db'), ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_DB);
     $opt->setInfo($this->lng->txt('ass_process_lock_mode_db_desc'));
     $rg->addOption($opt);
     if ($this->object->getAssessmentProcessLockMode() != ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE) {
         $rg->setValue($this->object->getAssessmentProcessLockMode());
     }
     $chb->addSubItem($rg);
     $assessmentSetting = new ilSetting('assessment');
     $imap_line_color = array_key_exists('imap_line_color', $_GET) ? $_GET['imap_line_color'] : $assessmentSetting->get('imap_line_color');
     if (strlen($imap_line_color) == 0) {
         $imap_line_color = 'FF0000';
     }
     $linepicker = new ilColorPickerInputGUI($this->lng->txt('assessment_imap_line_color'), 'imap_line_color');
     $linepicker->setValue($imap_line_color);
     $form->addItem($linepicker);
     $user_criteria = array_key_exists('user_criteria', $_GET) ? $_GET['user_criteria'] : $assessmentSetting->get('user_criteria');
     $userCriteria = new ilSelectInputGUI($this->lng->txt('user_criteria'), 'user_criteria');
     $userCriteria->setInfo($this->lng->txt('user_criteria_desc'));
     $userCriteria->setRequired(true);
     $fields = array('usr_id', 'login', 'email', 'matriculation', 'ext_account');
     $usr_fields = array();
     foreach ($fields as $field) {
         $usr_fields[$field] = $field;
     }
     $userCriteria->setOptions($usr_fields);
     $userCriteria->setValue($user_criteria);
     $form->addItem($userCriteria);
     // question settings
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("assf_questiontypes"));
     $form->addItem($header);
     // available question types
     $allowed = new ilCheckboxGroupInputGUI($this->lng->txt('assf_allowed_questiontypes'), "chb_allowed_questiontypes");
     $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
     $forbidden_types = $this->object->_getForbiddenQuestionTypes();
     $allowedtypes = array();
     foreach ($questiontypes as $qt) {
         if (!in_array($qt['question_type_id'], $forbidden_types)) {
             array_push($allowedtypes, $qt['question_type_id']);
         }
     }
     $allowed->setValue($allowedtypes);
     foreach ($questiontypes as $type_name => $qtype) {
         $allowed->addOption(new ilCheckboxOption($type_name, $qtype["question_type_id"]));
     }
     $allowed->setInfo($this->lng->txt('assf_allowed_questiontypes_desc'));
     $form->addItem($allowed);
     // manual scoring
     $manual = new ilCheckboxGroupInputGUI($this->lng->txt('assessment_log_manual_scoring_activate'), "chb_manual_scoring");
     $manscoring = $this->object->_getManualScoring();
     $manual->setValue($manscoring);
     foreach ($questiontypes as $type_name => $qtype) {
         $manual->addOption(new ilCheckboxOption($type_name, $qtype["question_type_id"]));
     }
     $manual->setInfo($this->lng->txt('assessment_log_manual_scoring_desc'));
     $form->addItem($manual);
     // scoring adjustment active
     $scoring_activation = new ilCheckboxInputGUI($this->lng->txt('assessment_scoring_adjust'), 'chb_scoring_adjust');
     $scoring_activation->setChecked($this->object->getScoringAdjustmentEnabled());
     $scoring_activation->setInfo($this->lng->txt('assessment_scoring_adjust_desc'));
     $form->addItem($scoring_activation);
     // scoring adjustment
     $scoring = new ilCheckboxGroupInputGUI($this->lng->txt('assessment_log_scoring_adjustment_activate'), "chb_scoring_adjustment");
     $scoring_active = $this->object->getScoringAdjustableQuestions();
     $scoring->setValue($scoring_active);
     foreach ($questiontypes as $type_name => $qtype) {
         $scoring->addOption(new ilCheckboxOption($type_name, $qtype["question_type_id"]));
     }
     $scoring->setInfo($this->lng->txt('assessment_log_scoring_adjustment_desc'));
     $form->addItem($scoring);
     if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
         $form->addCommandButton("saveSettings", $this->lng->txt("save"));
     }
     return $form;
 }
 /**
  * Default settings tab for Test & Assessment
  */
 public function defaultsObject()
 {
     global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl, $ilTabs;
     $ilTabs->activateTab('defaults');
     $assessmentSetting = new ilSetting("assessment");
     $use_javascript = array_key_exists("use_javascript", $_GET) ? $_GET["use_javascript"] : $assessmentSetting->get("use_javascript");
     $imap_line_color = array_key_exists("imap_line_color", $_GET) ? $_GET["imap_line_color"] : $assessmentSetting->get("imap_line_color");
     if (strlen($imap_line_color) == 0) {
         $imap_line_color = "FF0000";
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this));
     $form->setTitle($lng->txt("assessment_defaults"));
     // Enable javascript
     $enable = new ilCheckboxInputGUI($lng->txt("assessment_use_javascript"), "use_javascript");
     $enable->setChecked($use_javascript);
     $enable->setInfo($lng->txt("assessment_use_javascript_desc"));
     $form->addItem($enable);
     $linepicker = new ilColorPickerInputGUI($lng->txt("assessment_imap_line_color"), "imap_line_color");
     $linepicker->setValue($imap_line_color);
     $form->addItem($linepicker);
     if (@file_exists("./Modules/Test/classes/class.ilTestResultsToXML.php")) {
         global $ilDB;
         $user_criteria = array_key_exists("user_criteria", $_GET) ? $_GET["user_criteria"] : $assessmentSetting->get("user_criteria");
         $userCriteria = new ilSelectInputGUI($this->lng->txt("user_criteria"), "user_criteria");
         $userCriteria->setInfo($this->lng->txt("user_criteria_desc"));
         $userCriteria->setRequired(true);
         $userCriteria->setValue($isSingleline ? 0 : 1);
         $manager = $ilDB->db->loadModule('Manager');
         $fields = $manager->listTableFields('usr_data');
         $usr_fields = array();
         foreach ($fields as $field) {
             $usr_fields[$field] = $field;
         }
         $userCriteria->setOptions($usr_fields);
         $userCriteria->setValue($user_criteria);
         $form->addItem($userCriteria);
     }
     if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
         $form->addCommandButton("saveDefaults", $lng->txt("save"));
     }
     $tpl->setVariable("ADM_CONTENT", $form->getHTML());
 }
 /**
  * Insert property html
  *
  * @return	int	Size
  */
 function insert($a_tpl)
 {
     global $lng;
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initColorPicker();
     $layout_tpl = new ilTemplate("tpl.prop_trbl_layout.html", true, true, "Services/Style");
     $funcs = array("all" => "getAllValue", "top" => "getTopValue", "bottom" => "getBottomValue", "left" => "getLeftValue", "right" => "getRightValue");
     foreach ($this->dirs as $dir) {
         /*switch($dir)
         		{
         			case "all": $value = strtoupper(trim($this->getAllValue())); break;
         			case "top": $value = strtoupper(trim($this->getTopValue())); break;
         			case "bottom": $value = strtoupper(trim($this->getBottomValue())); break;
         			case "left": $value = strtoupper(trim($this->getLeftValue())); break;
         			case "right": $value = strtoupper(trim($this->getRightValue())); break;
         		}*/
         $value = trim($this->{$funcs}[$dir]());
         if (!$this->getAcceptNamedColors() || substr($value, 0, 1) != "!") {
             $value = strtoupper($value);
         }
         $ctpl = new ilTemplate("tpl.prop_trbl_color.html", true, true, "Services/Style");
         $js_tpl = new ilTemplate('tpl.trbl_color_picker.js', true, true, 'Services/Style');
         $js_tpl->setVariable('THUMB_PATH', ilUtil::getImagePath('color_picker_thumb.png', 'Services/Form'));
         $js_tpl->setVariable('HUE_THUMB_PATH', ilUtil::getImagePath('color_picker_hue_thumb.png', 'Services/Form'));
         $js_tpl->setVariable('COLOR_ID', $this->getFieldId() . "_" . $dir);
         $ic = ilColorPickerInputGUI::determineHexcode($value);
         if ($ic == "") {
             $ic = "FFFFFF";
         }
         $js_tpl->setVariable('INIT_COLOR_SHORT', $ic);
         $js_tpl->setVariable('INIT_COLOR', '#' . $value);
         $js_tpl->setVariable('POST_VAR', $this->getPostVar());
         $js_tpl->setVariable('DIR', $dir);
         if ($this->getDisabled()) {
             $ctpl->setVariable('COLOR_DISABLED', 'disabled="disabled"');
         } else {
             $ctpl->setVariable('PROP_COLOR_JS', $js_tpl->get());
         }
         $ctpl->setVariable("POST_VAR", $this->getPostVar());
         $ctpl->setVariable("PROP_COLOR_ID", $this->getFieldId() . "_" . $dir);
         $ctpl->setVariable("PROPERTY_VALUE_COLOR", $value);
         $ctpl->setVariable("DIR", $dir);
         $ctpl->setVariable("TXT_DIR", $lng->txt("sty_{$dir}"));
         $layout_tpl->setVariable(strtoupper($dir), $ctpl->get());
     }
     $a_tpl->setCurrentBlock("prop_generic");
     $a_tpl->setVariable("PROP_GENERIC", $layout_tpl->get());
     $a_tpl->parseCurrentBlock();
 }