58 include_once
"./classes/class.ilConditionHandler.php";
63 $this->gui_obj =& $gui_obj;
74 $this->target_obj =& $this->gui_obj->object;
79 if (is_object($this->target_obj))
100 $next_class = $this->ctrl->getNextClass($this);
101 $cmd = $this->ctrl->getCmd();
117 $this->automatic_validation = $a_status;
130 $this->target_id = $a_target_id;
146 $this->target_ref_id = $a_target_ref_id;
162 $this->target_type = $a_target_type;
178 $this->target_title = $a_target_title;
189 function chi_init(&$chi_target_obj,$a_ref_id = null)
193 include_once
"./classes/class.ilConditionHandler.php";
203 $this->target_obj =& $this->object;
212 global $ilObjDataCache;
214 $this->lng->loadLanguageModule(
'crs');
216 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit.html');
217 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
219 $this->tpl->setVariable(
"COLL_TITLE_IMG_ALT",$this->lng->txt(
'obj_'.$this->getTargetType()));
220 $this->tpl->setVariable(
"TABLE_TITLE",$this->
getTargetTitle().
' ('.$this->lng->txt(
'preconditions').
')');
223 $this->tpl->setVariable(
"HEAD_TITLE",$this->lng->txt(
'title'));
224 $this->tpl->setVariable(
"HEAD_CONDITION",$this->lng->txt(
'condition'));
227 $this->tpl->setVariable(
"BTN_DELETE",$this->lng->txt(
'delete'));
228 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
'add_condition'));
234 $this->tpl->setVariable(
"EMPTY_TXT",$this->lng->txt(
'no_conditions_found'));
239 foreach($conditions as $condition)
241 $this->tpl->setCurrentBlock(
"table_content");
243 $this->tpl->setVariable(
'TRIGGER_SRC',
ilUtil::getImagePath(
'icon_'.$condition[
'trigger_type'].
'_s.gif'));
244 $this->tpl->setVariable(
'TRIGGER_ALT',$this->lng->txt(
'obj_'.$condition[
'trigger_type']));
247 $this->tpl->setVariable(
"TITLE",$ilObjDataCache->lookupTitle($condition[
'trigger_obj_id']));
248 if(strlen($desc = $ilObjDataCache->lookupDescription($condition[
'trigger_obj_id'])))
250 $this->tpl->setVariable(
"DESCRIPTION",$desc);
252 $this->tpl->setVariable(
"OBJ_CONDITION",$this->lng->txt(
'condition_'.$condition[
'operator']));
255 $this->tpl->setVariable(
"EDIT",$this->lng->txt(
'edit'));
257 $this->ctrl->setParameter($this,
'condition_id',$condition[
'id']);
258 $this->tpl->setVariable(
"EDIT_LINK",$this->ctrl->getLinkTarget($this,
'edit'));
259 $this->ctrl->clearParameters($this);
260 $this->tpl->parseCurrentBlock();
267 global $ilObjDataCache;
269 if(!
$_GET[
'condition_id'])
277 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit_condition.html');
278 $this->ctrl->setParameter($this,
'condition_id',(
int) $_GET[
'condition_id']);
280 $this->
initFormCondition($condition[
'trigger_ref_id'],(
int) $_GET[
'condition_id'],
'edit');
281 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
286 global $ilObjDataCache;
288 if(!
$_GET[
'condition_id'])
296 include_once
'classes/class.ilConditionHandler.php';
300 $condition_handler->setOperator($_POST[
'operator']);
302 $condition_handler->setValue(
'');
306 $condition_handler->setReferenceHandlingType($_POST[
'ref_handling']);
313 $condition_handler->updateCondition($condition[
'id']);
316 if($condition[
'trigger_type'] ==
'sahs')
318 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
320 $lp_collection->deleteAll();
322 $items = is_array($_POST[
'item_ids']) ? $_POST[
'item_ids'] : array();
323 foreach($items as $item_id)
325 $lp_collection->add($item_id);
336 if(!count($_POST[
'conditions']))
343 foreach($_POST[
'conditions'] as $condition_id)
345 $this->ch_obj->deleteCondition($condition_id);
355 include_once (
"classes/class.ilConditionSelector.php");
357 $this->tpl->addBlockFile(
'ADM_CONTENT',
"adm_content",
"tpl.condition_selector.html");
362 $exp->
setExpand(
$_GET[
"condition_selector_expand"] ?
$_GET[
"condition_selector_expand"] : $this->tree->readRootId());
363 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'selector'));
364 $exp->setTargetGet(
"ref_id");
367 $exp->addFilter(
'crs');
368 $exp->addFilter(
'tst');
369 $exp->addFilter(
'sahs');
370 $exp->addFilter(
'svy');
372 $exp->setSelectableTypes($this->ch_obj->getTriggerTypes());
373 $exp->setControlClass($this);
377 $this->tpl->setCurrentBlock(
"adm_content");
378 $this->tpl->setVariable(
"EXPLORER",$exp->getOutput());
379 $this->tpl->parseCurrentBlock();
384 global $ilObjDataCache;
386 if(!
$_GET[
'source_id'])
394 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_add.html');
395 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
404 if(!isset(
$_GET[
'source_id']))
406 echo
"class.ilConditionHandlerInterface: no source_id given";
410 if(!strlen($_POST[
'operator']))
420 $this->ch_obj->setTargetObjId($this->
getTargetId());
426 $this->ch_obj->setReferenceHandlingType($_POST[
'ref_handling']);
436 echo
'ilConditionHandler: Trigger object does not exist';
438 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
439 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
440 $this->ch_obj->setTriggerType($trigger_obj->getType());
441 $this->ch_obj->setOperator($_POST[
'operator']);
442 $this->ch_obj->setValue(
'');
445 if($this->ch_obj->getTriggerType() ==
'sahs')
447 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
448 $lp_collection =
new ilLPCollections($this->ch_obj->getTriggerObjId());
451 $items = is_array($_POST[
'item_ids']) ? $_POST[
'item_ids'] : array();
452 foreach($items as $item_id)
454 $lp_collection->add($item_id);
459 if(!$this->ch_obj->storeCondition())
475 #if(in_array('',$_POST['operator']))
477 # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
483 $this->ch_obj->setOperator($_POST[
'operator'][$condition[
"id"]]);
484 $this->ch_obj->setValue($_POST[
'value'][$condition[
"id"]]);
485 $this->ch_obj->updateCondition($condition[
'id']);
490 $this->ctrl->returnToParent($this);
496 include_once
'./classes/class.ilConditionHandler.php';
500 if($condition[
'operator'] ==
'not_member')
506 $cond[] = $condition;
509 return $cond ? $cond : array();
519 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
522 $this->tpl->setCurrentBlock(
"btn_cell");
523 $this->tpl->setVariable(
"BTN_LINK",$link);
524 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt($name));
525 $this->tpl->parseCurrentBlock();
543 if(is_object($this->form))
547 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
549 $this->ctrl->setParameter($this,
'source_id',$a_source_id);
550 $this->form->setFormAction($this->ctrl->getFormAction($this));
553 include_once
"./classes/class.ilConditionHandler.php";
555 $operators[0] = $this->lng->txt(
'select_one');
556 foreach(
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
558 $operators[$operator] = $this->lng->txt(
'condition_'.$operator);
560 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
561 $sel->setOptions($operators);
562 $sel->setRequired(
true);
563 $this->form->addItem($sel);
570 $opt2 =
new ilRadioOption($this->lng->txt(
'cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
571 $rad_opt->addOption($opt2);
574 $rad_opt->addOption($opt1);
576 $this->form->addItem($rad_opt);
580 if($trigger_type ==
'sahs')
582 $this->lng->loadLanguageModule(
'trac');
583 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
586 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
589 $tpl =
new ilTemplate(
'tpl.condition_handler_sco_row.html',
true,
true);
594 $tpl->setCurrentBlock(
"sco_row");
595 $tpl->setVariable(
'SCO_ID',$item_id);
596 $tpl->setVariable(
'SCO_TITLE',$sahs_item[
'title']);
597 $tpl->setVariable(
'CHECKED',$lp_collections->isAssigned($item_id) ?
'checked="checked"' :
'');
598 $tpl->parseCurrentBlock();
601 $tpl->setVariable(
'INFO_SEL',$this->lng->txt(
'trac_lp_determination_info_sco'));
602 $cus->setHTML(
$tpl->get());
603 $this->form->addItem($cus);
609 $this->form->setTitle($this->lng->txt(
'precondition').
' ('.
612 $this->form->addCommandButton(
'updateCondition',$this->lng->txt(
'save'));
613 $this->form->addCommandButton(
'listConditions',$this->lng->txt(
'cancel'));
619 $this->form->setTitle($this->lng->txt(
'add_condition').
' ('.
622 $this->form->addCommandButton(
'assign',$this->lng->txt(
'save'));
623 $this->form->addCommandButton(
'selector',$this->lng->txt(
'back'));