/** * Init form for condition table * * @access private * @param * */ private function initFormCondition($a_source_id, $a_condition_id = 0, $a_mode = 'add') { $trigger_obj_id = ilObject::_lookupObjId($a_source_id); $trigger_type = ilObject::_lookupType($trigger_obj_id); $condition = ilConditionHandler::_getCondition($a_condition_id); if (is_object($this->form)) { return true; } include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $this->form = new ilPropertyFormGUI(); $this->ctrl->setParameter($this, 'source_id', $a_source_id); $this->form->setFormAction($this->ctrl->getFormAction($this)); $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source")); $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id))); $this->form->addItem($info_source); $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target")); $info_target->setValue($this->getTargetTitle()); $this->form->addItem($info_target); /* moved to list $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory'); $obl->setInfo($this->lng->txt('precondition_obligatory_info')); $obl->setValue(1); if($a_condition_id) { $obl->setChecked($condition['obligatory']); } else { $obl->setChecked(true); } $this->form->addItem($obl); */ $obl = new ilHiddenInputGUI('obligatory'); if ($a_condition_id) { $obl->setValue($condition['obligatory']); } else { $obl->setValue(1); } $this->form->addItem($obl); $sel = new ilSelectInputGUI($this->lng->txt('condition'), 'operator'); include_once "./Services/AccessControl/classes/class.ilConditionHandler.php"; $ch_obj = new ilConditionHandler(); if ($a_mode == 'add') { $operators[0] = $this->lng->txt('select_one'); } foreach ($ch_obj->getOperatorsByTargetType($trigger_type) as $operator) { $operators[$operator] = $this->lng->txt('condition_' . $operator); } $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0); $sel->setOptions($operators); $sel->setRequired(true); $this->form->addItem($sel); if (ilConditionHandler::_isReferenceHandlingOptional($this->getTargetType())) { $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'), 'ref_handling'); $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS); $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'), ilConditionHandler::SHARED_CONDITIONS); $rad_opt->addOption($opt2); $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'), ilConditionHandler::UNIQUE_CONDITIONS); $rad_opt->addOption($opt1); $this->form->addItem($rad_opt); } // Additional settings for SCO's if ($trigger_type == 'sahs') { $this->lng->loadLanguageModule('trac'); $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'), 'item_ids[]'); $cus->setRequired(true); $tpl = new ilTemplate('tpl.condition_handler_sco_row.html', true, true, "Services/AccessControl"); $counter = 0; include_once 'Services/Object/classes/class.ilObjectLP.php'; $olp = ilObjectLP::getInstance($trigger_obj_id); $collection = $olp->getCollectionInstance(); if ($collection) { foreach ($collection->getPossibleItems() as $item_id => $sahs_item) { $tpl->setCurrentBlock("sco_row"); $tpl->setVariable('SCO_ID', $item_id); $tpl->setVariable('SCO_TITLE', $sahs_item['title']); $tpl->setVariable('CHECKED', $collection->isAssignedEntry($item_id) ? 'checked="checked"' : ''); $tpl->parseCurrentBlock(); $counter++; } } $tpl->setVariable('INFO_SEL', $this->lng->txt('trac_lp_determination_info_sco')); $cus->setHTML($tpl->get()); $this->form->addItem($cus); } switch ($a_mode) { case 'edit': $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg')); $this->form->setTitle($this->lng->txt('rbac_edit_condition')); $this->form->addCommandButton('updateCondition', $this->lng->txt('save')); $this->form->addCommandButton('listConditions', $this->lng->txt('cancel')); break; case 'add': $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg')); $this->form->setTitle($this->lng->txt('add_condition')); $this->form->addCommandButton('assign', $this->lng->txt('save')); $this->form->addCommandButton('selector', $this->lng->txt('back')); break; } return true; }