37 include_once
"./classes/class.ilConditionHandler.php";
42 $this->gui_obj =& $gui_obj;
53 $this->target_obj =& $this->gui_obj->object;
58 if (is_object($this->target_obj))
79 $next_class = $this->ctrl->getNextClass($this);
80 $cmd = $this->ctrl->getCmd();
96 $this->automatic_validation = $a_status;
109 $this->target_id = $a_target_id;
125 $this->target_ref_id = $a_target_ref_id;
141 $this->target_type = $a_target_type;
157 $this->target_title = $a_target_title;
168 function chi_init(&$chi_target_obj,$a_ref_id = null)
172 include_once
"./classes/class.ilConditionHandler.php";
182 $this->target_obj =& $this->object;
191 global $ilObjDataCache;
193 $this->lng->loadLanguageModule(
'crs');
195 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit.html');
196 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
198 $this->tpl->setVariable(
"COLL_TITLE_IMG_ALT",$this->lng->txt(
'obj_'.$this->getTargetType()));
199 $this->tpl->setVariable(
"TABLE_TITLE",$this->
getTargetTitle().
' ('.$this->lng->txt(
'preconditions').
')');
202 $this->tpl->setVariable(
"HEAD_TITLE",$this->lng->txt(
'title'));
203 $this->tpl->setVariable(
"HEAD_CONDITION",$this->lng->txt(
'condition'));
206 $this->tpl->setVariable(
"BTN_DELETE",$this->lng->txt(
'delete'));
207 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
'add_condition'));
213 $this->tpl->setVariable(
"EMPTY_TXT",$this->lng->txt(
'no_conditions_found'));
218 foreach($conditions as $condition)
220 if($condition[
'trigger_type'] ==
'crsg')
225 $this->tpl->setCurrentBlock(
"table_content");
227 $this->tpl->setVariable(
'TRIGGER_SRC',
ilUtil::getImagePath(
'icon_'.$condition[
'trigger_type'].
'_s.gif'));
228 $this->tpl->setVariable(
'TRIGGER_ALT',$this->lng->txt(
'obj_'.$condition[
'trigger_type']));
231 $this->tpl->setVariable(
"TITLE",$ilObjDataCache->lookupTitle($condition[
'trigger_obj_id']));
232 if(strlen(
$desc = $ilObjDataCache->lookupDescription($condition[
'trigger_obj_id'])))
234 $this->tpl->setVariable(
"DESCRIPTION",
$desc);
236 $this->tpl->setVariable(
"OBJ_CONDITION",$this->lng->txt(
'condition_'.$condition[
'operator']));
239 $this->tpl->setVariable(
"EDIT",$this->lng->txt(
'edit'));
241 $this->ctrl->setParameter($this,
'condition_id',$condition[
'id']);
242 $this->tpl->setVariable(
"EDIT_LINK",$this->ctrl->getLinkTarget($this,
'edit'));
243 $this->ctrl->clearParameters($this);
244 $this->tpl->parseCurrentBlock();
251 global $ilObjDataCache;
253 if(!
$_GET[
'condition_id'])
261 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit_condition.html');
262 $this->ctrl->setParameter($this,
'condition_id',(
int) $_GET[
'condition_id']);
264 $this->
initFormCondition($condition[
'trigger_ref_id'],(
int) $_GET[
'condition_id'],
'edit');
265 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
270 global $ilObjDataCache;
272 if(!
$_GET[
'condition_id'])
280 include_once
'classes/class.ilConditionHandler.php';
284 $condition_handler->setOperator(
$_POST[
'operator']);
286 $condition_handler->setValue(
'');
290 $condition_handler->setReferenceHandlingType(
$_POST[
'ref_handling']);
297 $condition_handler->updateCondition($condition[
'id']);
300 if($condition[
'trigger_type'] ==
'sahs')
302 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
304 $lp_collection->deleteAll();
306 $items = is_array(
$_POST[
'item_ids']) ?
$_POST[
'item_ids'] : array();
307 foreach($items as $item_id)
309 $lp_collection->add($item_id);
320 if(!count(
$_POST[
'conditions']))
327 foreach(
$_POST[
'conditions'] as $condition_id)
329 $this->ch_obj->deleteCondition($condition_id);
339 include_once (
"classes/class.ilConditionSelector.php");
341 $this->tpl->addBlockFile(
'ADM_CONTENT',
"adm_content",
"tpl.condition_selector.html");
346 $exp->
setExpand(
$_GET[
"condition_selector_expand"] ?
$_GET[
"condition_selector_expand"] : $this->tree->readRootId());
347 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'selector'));
348 $exp->setTargetGet(
"ref_id");
351 $exp->addFilter(
'crs');
352 $exp->addFilter(
'tst');
353 $exp->addFilter(
'sahs');
354 $exp->addFilter(
'svy');
356 $exp->setSelectableTypes($this->ch_obj->getTriggerTypes());
357 $exp->setControlClass($this);
361 $this->tpl->setCurrentBlock(
"adm_content");
362 $this->tpl->setVariable(
"EXPLORER",$exp->getOutput());
363 $this->tpl->parseCurrentBlock();
368 global $ilObjDataCache;
370 if(!
$_GET[
'source_id'])
378 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_add.html');
379 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
388 if(!isset(
$_GET[
'source_id']))
390 echo
"class.ilConditionHandlerInterface: no source_id given";
394 if(!strlen(
$_POST[
'operator']))
404 $this->ch_obj->setTargetObjId($this->
getTargetId());
410 $this->ch_obj->setReferenceHandlingType(
$_POST[
'ref_handling']);
420 echo
'ilConditionHandler: Trigger object does not exist';
422 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
423 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
424 $this->ch_obj->setTriggerType($trigger_obj->getType());
425 $this->ch_obj->setOperator(
$_POST[
'operator']);
426 $this->ch_obj->setValue(
'');
429 if($this->ch_obj->getTriggerType() ==
'sahs')
431 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
432 $lp_collection =
new ilLPCollections($this->ch_obj->getTriggerObjId());
435 $items = is_array(
$_POST[
'item_ids']) ?
$_POST[
'item_ids'] : array();
436 foreach($items as $item_id)
438 $lp_collection->add($item_id);
443 if(!$this->ch_obj->storeCondition())
459 #if(in_array('',$_POST['operator']))
461 # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
467 $this->ch_obj->setOperator(
$_POST[
'operator'][$condition[
"id"]]);
468 $this->ch_obj->setValue(
$_POST[
'value'][$condition[
"id"]]);
469 $this->ch_obj->updateCondition($condition[
'id']);
474 $this->ctrl->returnToParent($this);
480 include_once
'./classes/class.ilConditionHandler.php';
484 if($condition[
'operator'] ==
'not_member')
490 $cond[] = $condition;
493 return $cond ? $cond : array();
503 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
506 $this->tpl->setCurrentBlock(
"btn_cell");
507 $this->tpl->setVariable(
"BTN_LINK",$link);
508 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt(
$name));
509 $this->tpl->parseCurrentBlock();
527 if(is_object($this->form))
531 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
533 $this->ctrl->setParameter($this,
'source_id',$a_source_id);
534 $this->form->setFormAction($this->ctrl->getFormAction($this));
537 include_once
"./classes/class.ilConditionHandler.php";
539 $operators[0] = $this->lng->txt(
'select_one');
540 foreach(
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
542 $operators[$operator] = $this->lng->txt(
'condition_'.$operator);
544 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
545 $sel->setOptions($operators);
546 $sel->setRequired(
true);
547 $this->form->addItem($sel);
554 $opt2 =
new ilRadioOption($this->lng->txt(
'cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
555 $rad_opt->addOption($opt2);
558 $rad_opt->addOption($opt1);
560 $this->form->addItem($rad_opt);
564 if($trigger_type ==
'sahs')
566 $this->lng->loadLanguageModule(
'trac');
567 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
570 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
573 $tpl =
new ilTemplate(
'tpl.condition_handler_sco_row.html',
true,
true);
578 $tpl->setCurrentBlock(
"sco_row");
579 $tpl->setVariable(
'SCO_ID',$item_id);
580 $tpl->setVariable(
'SCO_TITLE',$sahs_item[
'title']);
581 $tpl->setVariable(
'CHECKED',$lp_collections->isAssigned($item_id) ?
'checked="checked"' :
'');
582 $tpl->parseCurrentBlock();
585 $tpl->setVariable(
'INFO_SEL',$this->lng->txt(
'trac_lp_determination_info_sco'));
586 $cus->setHTML(
$tpl->get());
587 $this->form->addItem($cus);
593 $this->form->setTitle($this->lng->txt(
'precondition').
' ('.
596 $this->form->addCommandButton(
'updateCondition',$this->lng->txt(
'save'));
597 $this->form->addCommandButton(
'listConditions',$this->lng->txt(
'cancel'));
603 $this->form->setTitle($this->lng->txt(
'add_condition').
' ('.
606 $this->form->addCommandButton(
'assign',$this->lng->txt(
'save'));
607 $this->form->addCommandButton(
'selector',$this->lng->txt(
'back'));