46 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
51 $this->gui_obj =& $gui_obj;
53 $this->lng->loadLanguageModule(
'rbac');
63 $this->target_obj =& $this->gui_obj->object;
68 if (is_object($this->target_obj))
86 $GLOBALS[
'lng']->loadLanguageModule(
'trac');
87 include_once
'./Services/Tracking/classes/class.ilLPObjSettings.php';
92 $GLOBALS[
'lng']->loadLanguageModule(
'rbac');
93 return $GLOBALS[
'lng']->txt(
'condition_'.$a_operator);
119 if(!$ilAccess->checkAccess(
'write',
'',$this->getTargetRefId()))
121 $ilErr->raiseError($lng->txt(
'permission_denied'),$ilErr->WARNING);
124 $next_class = $this->ctrl->getNextClass($this);
125 $cmd = $this->ctrl->getCmd();
141 $this->automatic_validation = $a_status;
154 $this->target_id = $a_target_id;
170 $this->target_ref_id = $a_target_ref_id;
186 $this->target_type = $a_target_type;
202 $this->target_title = $a_target_title;
222 function chi_init(&$chi_target_obj,$a_ref_id = null)
226 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
236 $this->target_obj =& $this->object;
250 $ilToolbar->addButton($this->lng->txt(
'add_condition'),$this->ctrl->getLinkTarget($this,
'selector'));
252 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.list_conditions.html',
'Services/AccessControl');
259 if(count($optional_conditions))
279 $this->tpl->setVariable(
'TABLE_SETTINGS',$form->getHTML());
282 include_once
'./Services/AccessControl/classes/class.ilConditionHandlerTableGUI.php';
284 $table->setConditions(
292 $this->tpl->setVariable(
'TABLE_CONDITIONS',$table->getHTML());
293 $this->tpl->setContent($table->getHTML());
302 if($form->checkInput())
304 $old_mode = $form->getInput(
"old_list_mode");
305 switch($form->getInput(
"list_mode"))
308 if($old_mode !=
"all")
310 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
317 foreach((array) $optional_conditions as $item)
325 $num_req = $form->getInput(
'required');
326 if($old_mode !=
"subset")
333 foreach($all_conditions as $item)
349 $cond->updateHiddenStatus((
int) $form->getInput(
'hidden'));
352 $this->ctrl->redirect($this,
'listConditions');
355 $form->setValuesByPost();
357 $this->tpl->setContent($form->getHTML());
371 if(
$_POST[
"obl"] &&
sizeof(
$_POST[
"obl"]) >
sizeof($all_conditions)-2)
374 $this->ctrl->redirect($this,
'listConditions');
377 foreach($all_conditions as $item)
380 if(
$_POST[
"obl"] && in_array($item[
"condition_id"],
$_POST[
"obl"]))
396 $this->ctrl->redirect($this,
'listConditions');
416 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
418 $form->setFormAction($this->ctrl->getFormAction($this),
'listConditions');
419 $form->setTitle($this->lng->txt(
'precondition_obligatory_settings'));
420 $form->addCommandButton(
'saveObligatorySettings', $this->lng->txt(
'save'));
425 $hide->setInfo($this->lng->txt(
'rbac_precondition_hide_info'));
426 $form->addItem($hide);
429 $form->addItem($mode);
432 $mall =
new ilRadioOption($this->lng->txt(
"rbac_precondition_mode_all"),
"all");
433 $mall->
setInfo($this->lng->txt(
"rbac_precondition_mode_all_info"));
434 $mode->addOption($mall);
436 $msubset =
new ilRadioOption($this->lng->txt(
"rbac_precondition_mode_subset"),
"subset");
437 $msubset->
setInfo($this->lng->txt(
"rbac_precondition_mode_subset_info"));
438 $mode->addOption($msubset);
440 $obl =
new ilNumberInputGUI($this->lng->txt(
'precondition_num_obligatory'),
'required');
441 $obl->
setInfo($this->lng->txt(
'precondition_num_optional_info'));
449 $min = count($all) - count($opt) + 1;
450 $max = count($all) - 1;
454 $obligatory = $min = $max = 1;
456 $obl->setValue($obligatory);
457 $obl->setRequired(
true);
459 $obl->setMinValue($min);
460 $obl->setMaxValue($max);
461 $msubset->addSubItem($obl);
464 $old_mode->setValue(
$_REQUEST[
"list_mode"]);
465 $form->addItem($old_mode);
473 global $ilObjDataCache;
475 if(!
$_GET[
'condition_id'])
483 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit_condition.html',
484 "Services/AccessControl");
485 $this->ctrl->setParameter($this,
'condition_id',(
int) $_GET[
'condition_id']);
487 $this->
initFormCondition($condition[
'trigger_ref_id'],(
int) $_GET[
'condition_id'],
'edit');
488 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
493 global $ilObjDataCache;
495 if(!
$_GET[
'condition_id'])
503 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
507 $condition_handler->setOperator(
$_POST[
'operator']);
508 $condition_handler->setObligatory((
int)
$_POST[
'obligatory']);
510 $condition_handler->setValue(
'');
514 $condition_handler->setReferenceHandlingType($_POST[
'ref_handling']);
521 $condition_handler->updateCondition($condition[
'id']);
524 if($condition[
'trigger_type'] ==
'sahs')
526 include_once
'Services/Object/classes/class.ilObjectLP.php';
528 $collection = $olp->getCollectionInstance();
531 $collection->delete();
534 if(is_array($_POST[
'item_ids']))
536 $collection->activateEntries($_POST[
'item_ids']);
539 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
544 $this->ctrl->redirect($this,
'listConditions');
551 if(!count(
$_POST[
'conditions']))
559 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
561 $cgui->setFormAction($this->ctrl->getFormAction($this,
"listConditions"));
562 $cgui->setHeaderText($this->lng->txt(
"rbac_condition_delete_sure"));
563 $cgui->setCancel($this->lng->txt(
"cancel"),
"listConditions");
564 $cgui->setConfirm($this->lng->txt(
"delete"),
"delete");
567 foreach(
$_POST[
'conditions'] as $condition_id)
572 " (".$this->lng->txt(
"condition").
": ".
573 $this->lng->txt(
'condition_'.$condition[
'operator']).
")";
575 $alt = $this->lng->txt(
'obj_'.$condition[
'trigger_type']);
577 $cgui->addItem(
"conditions[]", $condition_id, $title, $icon, $alt);
580 $tpl->setContent($cgui->getHTML());
585 if(!count(
$_POST[
'conditions']))
592 foreach(
$_POST[
'conditions'] as $condition_id)
594 $this->ch_obj->deleteCondition($condition_id);
597 $this->ctrl->redirect($this,
'listConditions');
604 include_once (
"./Services/AccessControl/classes/class.ilConditionSelector.php");
610 array(
"root",
"cat",
"grp",
"fold",
"crs")
616 if (!$exp->handleCommand())
618 $this->tpl->setContent($exp->getHTML());
624 global $ilObjDataCache;
626 if(!
$_GET[
'source_id'])
634 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_add.html',
635 "Services/AccessControl");
636 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
645 if(!isset(
$_GET[
'source_id']))
647 echo
"class.ilConditionHandlerGUI: no source_id given";
659 $this->ch_obj->setTargetObjId($this->
getTargetId());
665 $this->ch_obj->setReferenceHandlingType(
$_POST[
'ref_handling']);
675 echo
'ilConditionHandler: Trigger object does not exist';
677 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
678 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
679 $this->ch_obj->setTriggerType($trigger_obj->getType());
680 $this->ch_obj->setOperator(
$_POST[
'operator']);
681 $this->ch_obj->setObligatory((
int)
$_POST[
'obligatory']);
683 $this->ch_obj->setValue(
'');
686 if($this->ch_obj->getTriggerType() ==
'sahs')
688 include_once
'Services/Object/classes/class.ilObjectLP.php';
690 $collection = $olp->getCollectionInstance();
693 $collection->delete();
696 if(is_array($_POST[
'item_ids']))
698 $collection->activateEntries($_POST[
'item_ids']);
703 if(!$this->ch_obj->storeCondition())
712 $this->ctrl->redirect($this,
'listConditions');
719 #if(in_array('',$_POST['operator']))
721 # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
727 $this->ch_obj->setOperator(
$_POST[
'operator'][$condition[
"id"]]);
728 $this->ch_obj->setValue(
$_POST[
'value'][$condition[
"id"]]);
729 $this->ch_obj->updateCondition($condition[
'id']);
734 $this->ctrl->returnToParent($this);
740 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
744 if($condition[
'operator'] ==
'not_member')
750 $cond[] = $condition;
753 return $cond ? $cond : array();
770 if(is_object($this->form))
774 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
776 $this->ctrl->setParameter($this,
'source_id',$a_source_id);
777 $this->form->setFormAction($this->ctrl->getFormAction($this));
781 $this->form->addItem($info_source);
785 $this->form->addItem($info_target);
804 $obl->setValue($condition[
'obligatory']);
810 $this->form->addItem($obl);
813 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
817 $operators[0] = $this->lng->txt(
'select_one');
819 foreach(
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
821 $operators[$operator] = $this->lng->txt(
'condition_'.$operator);
823 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
824 $sel->setOptions($operators);
825 $sel->setRequired(
true);
826 $this->form->addItem($sel);
833 $opt2 =
new ilRadioOption($this->lng->txt(
'cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
834 $rad_opt->addOption($opt2);
837 $rad_opt->addOption($opt1);
839 $this->form->addItem($rad_opt);
843 if($trigger_type ==
'sahs')
845 $this->lng->loadLanguageModule(
'trac');
847 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
850 $tpl =
new ilTemplate(
'tpl.condition_handler_sco_row.html',
true,
true,
851 "Services/AccessControl");
854 include_once
'Services/Object/classes/class.ilObjectLP.php';
856 $collection = $olp->getCollectionInstance();
859 foreach($collection->getPossibleItems() as $item_id => $sahs_item)
861 $tpl->setCurrentBlock(
"sco_row");
862 $tpl->setVariable(
'SCO_ID',$item_id);
863 $tpl->setVariable(
'SCO_TITLE',$sahs_item[
'title']);
864 $tpl->setVariable(
'CHECKED',$collection->isAssignedEntry($item_id) ?
'checked="checked"' :
'');
865 $tpl->parseCurrentBlock();
869 $tpl->setVariable(
'INFO_SEL',$this->lng->txt(
'trac_lp_determination_info_sco'));
870 $cus->setHTML(
$tpl->get());
871 $this->form->addItem($cus);
877 $this->form->setTitle($this->lng->txt(
'rbac_edit_condition'));
878 $this->form->addCommandButton(
'updateCondition',$this->lng->txt(
'save'));
879 $this->form->addCommandButton(
'listConditions',$this->lng->txt(
'cancel'));
885 $this->form->setTitle($this->lng->txt(
'add_condition'));
886 $this->form->addCommandButton(
'assign',$this->lng->txt(
'save'));
887 $this->form->addCommandButton(
'selector',$this->lng->txt(
'back'));