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))
81 if(!$ilAccess->checkAccess(
'write',
'',$this->getTargetRefId()))
83 $ilErr->raiseError($lng->txt(
'permission_denied'),$ilErr->WARNING);
86 $next_class = $this->ctrl->getNextClass($this);
87 $cmd = $this->ctrl->getCmd();
103 $this->automatic_validation = $a_status;
116 $this->target_id = $a_target_id;
132 $this->target_ref_id = $a_target_ref_id;
148 $this->target_type = $a_target_type;
164 $this->target_title = $a_target_title;
175 function chi_init(&$chi_target_obj,$a_ref_id = null)
179 include_once
"./classes/class.ilConditionHandler.php";
189 $this->target_obj =& $this->object;
198 global $ilObjDataCache;
200 $this->lng->loadLanguageModule(
'crs');
202 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit.html');
203 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
205 $this->tpl->setVariable(
"COLL_TITLE_IMG_ALT",$this->lng->txt(
'obj_'.$this->getTargetType()));
206 $this->tpl->setVariable(
"TABLE_TITLE",$this->
getTargetTitle().
' ('.$this->lng->txt(
'preconditions').
')');
209 $this->tpl->setVariable(
"HEAD_TITLE",$this->lng->txt(
'title'));
210 $this->tpl->setVariable(
"HEAD_CONDITION",$this->lng->txt(
'condition'));
213 $this->tpl->setVariable(
"BTN_DELETE",$this->lng->txt(
'delete'));
214 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
'add_condition'));
220 $this->tpl->setVariable(
"EMPTY_TXT",$this->lng->txt(
'no_conditions_found'));
225 foreach($conditions as $condition)
227 if($condition[
'trigger_type'] ==
'crsg')
232 $this->tpl->setCurrentBlock(
"table_content");
234 $this->tpl->setVariable(
'TRIGGER_SRC',
ilUtil::getImagePath(
'icon_'.$condition[
'trigger_type'].
'_s.gif'));
235 $this->tpl->setVariable(
'TRIGGER_ALT',$this->lng->txt(
'obj_'.$condition[
'trigger_type']));
238 $this->tpl->setVariable(
"TITLE",$ilObjDataCache->lookupTitle($condition[
'trigger_obj_id']));
239 if(strlen($desc = $ilObjDataCache->lookupDescription($condition[
'trigger_obj_id'])))
241 $this->tpl->setVariable(
"DESCRIPTION",$desc);
243 $this->tpl->setVariable(
"OBJ_CONDITION",$this->lng->txt(
'condition_'.$condition[
'operator']));
246 $this->tpl->setVariable(
"EDIT",$this->lng->txt(
'edit'));
248 $this->ctrl->setParameter($this,
'condition_id',$condition[
'id']);
249 $this->tpl->setVariable(
"EDIT_LINK",$this->ctrl->getLinkTarget($this,
'edit'));
250 $this->ctrl->clearParameters($this);
251 $this->tpl->parseCurrentBlock();
258 global $ilObjDataCache;
260 if(!
$_GET[
'condition_id'])
268 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit_condition.html');
269 $this->ctrl->setParameter($this,
'condition_id',(
int) $_GET[
'condition_id']);
271 $this->
initFormCondition($condition[
'trigger_ref_id'],(
int) $_GET[
'condition_id'],
'edit');
272 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
277 global $ilObjDataCache;
279 if(!
$_GET[
'condition_id'])
287 include_once
'classes/class.ilConditionHandler.php';
291 $condition_handler->setOperator(
$_POST[
'operator']);
293 $condition_handler->setValue(
'');
297 $condition_handler->setReferenceHandlingType(
$_POST[
'ref_handling']);
304 $condition_handler->updateCondition($condition[
'id']);
307 if($condition[
'trigger_type'] ==
'sahs')
309 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
311 $lp_collection->deleteAll();
313 $items = is_array(
$_POST[
'item_ids']) ?
$_POST[
'item_ids'] : array();
314 foreach($items as $item_id)
316 $lp_collection->add($item_id);
327 if(!count(
$_POST[
'conditions']))
334 foreach(
$_POST[
'conditions'] as $condition_id)
336 $this->ch_obj->deleteCondition($condition_id);
346 include_once (
"classes/class.ilConditionSelector.php");
348 $this->tpl->addBlockFile(
'ADM_CONTENT',
"adm_content",
"tpl.condition_selector.html");
353 $exp->
setExpand(
$_GET[
"condition_selector_expand"] ?
$_GET[
"condition_selector_expand"] : $this->tree->readRootId());
354 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'selector'));
355 $exp->setTargetGet(
"ref_id");
358 $exp->addFilter(
'crs');
359 $exp->addFilter(
'tst');
360 $exp->addFilter(
'sahs');
361 $exp->addFilter(
'svy');
363 $exp->setSelectableTypes($this->ch_obj->getTriggerTypes());
364 $exp->setControlClass($this);
368 $this->tpl->setCurrentBlock(
"adm_content");
369 $this->tpl->setVariable(
"EXPLORER",$exp->getOutput());
370 $this->tpl->parseCurrentBlock();
375 global $ilObjDataCache;
377 if(!
$_GET[
'source_id'])
385 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_add.html');
386 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
395 if(!isset(
$_GET[
'source_id']))
397 echo
"class.ilConditionHandlerInterface: no source_id given";
401 if(!strlen(
$_POST[
'operator']))
411 $this->ch_obj->setTargetObjId($this->
getTargetId());
417 $this->ch_obj->setReferenceHandlingType(
$_POST[
'ref_handling']);
427 echo
'ilConditionHandler: Trigger object does not exist';
429 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
430 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
431 $this->ch_obj->setTriggerType($trigger_obj->getType());
432 $this->ch_obj->setOperator(
$_POST[
'operator']);
433 $this->ch_obj->setValue(
'');
436 if($this->ch_obj->getTriggerType() ==
'sahs')
438 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
439 $lp_collection =
new ilLPCollections($this->ch_obj->getTriggerObjId());
442 $items = is_array(
$_POST[
'item_ids']) ?
$_POST[
'item_ids'] : array();
443 foreach($items as $item_id)
445 $lp_collection->add($item_id);
450 if(!$this->ch_obj->storeCondition())
466 #if(in_array('',$_POST['operator']))
468 # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
474 $this->ch_obj->setOperator(
$_POST[
'operator'][$condition[
"id"]]);
475 $this->ch_obj->setValue(
$_POST[
'value'][$condition[
"id"]]);
476 $this->ch_obj->updateCondition($condition[
'id']);
481 $this->ctrl->returnToParent($this);
487 include_once
'./classes/class.ilConditionHandler.php';
491 if($condition[
'operator'] ==
'not_member')
497 $cond[] = $condition;
500 return $cond ? $cond : array();
510 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
513 $this->tpl->setCurrentBlock(
"btn_cell");
514 $this->tpl->setVariable(
"BTN_LINK",$link);
515 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt($name));
516 $this->tpl->parseCurrentBlock();
534 if(is_object($this->form))
538 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
540 $this->ctrl->setParameter($this,
'source_id',$a_source_id);
541 $this->form->setFormAction($this->ctrl->getFormAction($this));
544 include_once
"./classes/class.ilConditionHandler.php";
546 $operators[0] = $this->lng->txt(
'select_one');
547 foreach(
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
549 $operators[$operator] = $this->lng->txt(
'condition_'.$operator);
551 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
552 $sel->setOptions($operators);
553 $sel->setRequired(
true);
554 $this->form->addItem($sel);
561 $opt2 =
new ilRadioOption($this->lng->txt(
'cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
562 $rad_opt->addOption($opt2);
565 $rad_opt->addOption($opt1);
567 $this->form->addItem($rad_opt);
571 if($trigger_type ==
'sahs')
573 $this->lng->loadLanguageModule(
'trac');
574 include_once
'Services/Tracking/classes/class.ilLPCollections.php';
577 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
580 $tpl =
new ilTemplate(
'tpl.condition_handler_sco_row.html',
true,
true);
585 $tpl->setCurrentBlock(
"sco_row");
586 $tpl->setVariable(
'SCO_ID',$item_id);
587 $tpl->setVariable(
'SCO_TITLE',$sahs_item[
'title']);
588 $tpl->setVariable(
'CHECKED',$lp_collections->isAssigned($item_id) ?
'checked="checked"' :
'');
589 $tpl->parseCurrentBlock();
592 $tpl->setVariable(
'INFO_SEL',$this->lng->txt(
'trac_lp_determination_info_sco'));
593 $cus->setHTML(
$tpl->get());
594 $this->form->addItem($cus);
600 $this->form->setTitle($this->lng->txt(
'precondition').
' ('.
603 $this->form->addCommandButton(
'updateCondition',$this->lng->txt(
'save'));
604 $this->form->addCommandButton(
'listConditions',$this->lng->txt(
'cancel'));
610 $this->form->setTitle($this->lng->txt(
'add_condition').
' ('.
613 $this->form->addCommandButton(
'assign',$this->lng->txt(
'save'));
614 $this->form->addCommandButton(
'selector',$this->lng->txt(
'back'));