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 $this->tpl->setCurrentBlock(
"table_content");
222 $this->tpl->setVariable(
'TRIGGER_SRC',
ilUtil::getImagePath(
'icon_'.$condition[
'trigger_type'].
'_s.gif'));
223 $this->tpl->setVariable(
'TRIGGER_ALT',$this->lng->txt(
'obj_'.$condition[
'trigger_type']));
226 $this->tpl->setVariable(
"TITLE",$ilObjDataCache->lookupTitle($condition[
'trigger_obj_id']));
227 if(strlen(
$desc = $ilObjDataCache->lookupDescription($condition[
'trigger_obj_id'])))
229 $this->tpl->setVariable(
"DESCRIPTION",
$desc);
231 $this->tpl->setVariable(
"OBJ_CONDITION",$this->lng->txt(
'condition_'.$condition[
'operator']));
234 $this->tpl->setVariable(
"EDIT",$this->lng->txt(
'edit'));
236 $this->ctrl->setParameter($this,
'condition_id',$condition[
'id']);
237 $this->tpl->setVariable(
"EDIT_LINK",$this->ctrl->getLinkTarget($this,
'edit'));
238 $this->ctrl->clearParameters($this);
239 $this->tpl->parseCurrentBlock();
246 global $ilObjDataCache;
248 if(!
$_GET[
'condition_id'])
256 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit_condition.html');
257 $this->ctrl->setParameter($this,
'condition_id',(
int) $_GET[
'condition_id']);
259 $this->
initFormCondition($condition[
'trigger_ref_id'],(
int) $_GET[
'condition_id'],
'edit');
260 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
265 global $ilObjDataCache;
267 if(!
$_GET[
'condition_id'])
275 include_once
'classes/class.ilConditionHandler.php';
279 $condition_handler->setOperator(
$_POST[
'operator']);
281 $condition_handler->setValue(
'');
285 $condition_handler->setReferenceHandlingType(
$_POST[
'ref_handling']);
292 $condition_handler->updateCondition($condition[
'id']);
295 if($condition[
'trigger_type'] ==
'sahs')
297 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
299 $lp_collection->deleteAll();
301 $items = is_array(
$_POST[
'item_ids']) ?
$_POST[
'item_ids'] : array();
302 foreach($items as $item_id)
304 $lp_collection->add($item_id);
315 if(!count(
$_POST[
'conditions']))
322 foreach(
$_POST[
'conditions'] as $condition_id)
324 $this->ch_obj->deleteCondition($condition_id);
334 include_once (
"classes/class.ilConditionSelector.php");
336 $this->tpl->addBlockFile(
'ADM_CONTENT',
"adm_content",
"tpl.condition_selector.html");
341 $exp->
setExpand(
$_GET[
"condition_selector_expand"] ?
$_GET[
"condition_selector_expand"] : $this->tree->readRootId());
342 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'selector'));
343 $exp->setTargetGet(
"ref_id");
346 $exp->addFilter(
'crs');
347 $exp->addFilter(
'tst');
348 $exp->addFilter(
'sahs');
349 $exp->addFilter(
'svy');
351 $exp->setSelectableTypes($this->ch_obj->getTriggerTypes());
352 $exp->setControlClass($this);
356 $this->tpl->setCurrentBlock(
"adm_content");
357 $this->tpl->setVariable(
"EXPLORER",$exp->getOutput());
358 $this->tpl->parseCurrentBlock();
363 global $ilObjDataCache;
365 if(!
$_GET[
'source_id'])
373 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_add.html');
374 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
383 if(!isset(
$_GET[
'source_id']))
385 echo
"class.ilConditionHandlerInterface: no source_id given";
389 if(!strlen(
$_POST[
'operator']))
399 $this->ch_obj->setTargetObjId($this->
getTargetId());
405 $this->ch_obj->setReferenceHandlingType(
$_POST[
'ref_handling']);
415 echo
'ilConditionHandler: Trigger object does not exist';
417 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
418 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
419 $this->ch_obj->setTriggerType($trigger_obj->getType());
420 $this->ch_obj->setOperator(
$_POST[
'operator']);
421 $this->ch_obj->setValue(
'');
424 if($this->ch_obj->getTriggerType() ==
'sahs')
426 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
427 $lp_collection =
new ilLPCollections($this->ch_obj->getTriggerObjId());
430 $items = is_array(
$_POST[
'item_ids']) ?
$_POST[
'item_ids'] : array();
431 foreach($items as $item_id)
433 $lp_collection->add($item_id);
438 if(!$this->ch_obj->storeCondition())
454 #if(in_array('',$_POST['operator']))
456 # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
462 $this->ch_obj->setOperator(
$_POST[
'operator'][$condition[
"id"]]);
463 $this->ch_obj->setValue(
$_POST[
'value'][$condition[
"id"]]);
464 $this->ch_obj->updateCondition($condition[
'id']);
469 $this->ctrl->returnToParent($this);
475 include_once
'./classes/class.ilConditionHandler.php';
479 if($condition[
'operator'] ==
'not_member')
485 $cond[] = $condition;
488 return $cond ? $cond : array();
498 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
501 $this->tpl->setCurrentBlock(
"btn_cell");
502 $this->tpl->setVariable(
"BTN_LINK",$link);
503 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt(
$name));
504 $this->tpl->parseCurrentBlock();
522 if(is_object($this->form))
526 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
528 $this->ctrl->setParameter($this,
'source_id',$a_source_id);
529 $this->form->setFormAction($this->ctrl->getFormAction($this));
532 include_once
"./classes/class.ilConditionHandler.php";
534 $operators[0] = $this->lng->txt(
'select_one');
535 foreach(
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
537 $operators[$operator] = $this->lng->txt(
'condition_'.$operator);
539 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
540 $sel->setOptions($operators);
541 $sel->setRequired(
true);
542 $this->form->addItem($sel);
549 $opt2 =
new ilRadioOption($this->lng->txt(
'cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
550 $rad_opt->addOption($opt2);
553 $rad_opt->addOption($opt1);
555 $this->form->addItem($rad_opt);
559 if($trigger_type ==
'sahs')
561 $this->lng->loadLanguageModule(
'trac');
562 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
565 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
568 $tpl =
new ilTemplate(
'tpl.condition_handler_sco_row.html',
true,
true);
573 $tpl->setCurrentBlock(
"sco_row");
574 $tpl->setVariable(
'SCO_ID',$item_id);
575 $tpl->setVariable(
'SCO_TITLE',$sahs_item[
'title']);
576 $tpl->setVariable(
'CHECKED',$lp_collections->isAssigned($item_id) ?
'checked="checked"' :
'');
577 $tpl->parseCurrentBlock();
580 $tpl->setVariable(
'INFO_SEL',$this->lng->txt(
'trac_lp_determination_info_sco'));
581 $cus->setHTML(
$tpl->get());
582 $this->form->addItem($cus);
588 $this->form->setTitle($this->lng->txt(
'precondition').
' ('.
591 $this->form->addCommandButton(
'updateCondition',$this->lng->txt(
'save'));
592 $this->form->addCommandButton(
'listConditions',$this->lng->txt(
'cancel'));
598 $this->form->setTitle($this->lng->txt(
'add_condition').
' ('.
601 $this->form->addCommandButton(
'assign',$this->lng->txt(
'save'));
602 $this->form->addCommandButton(
'selector',$this->lng->txt(
'back'));