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))
90 if(!$ilAccess->checkAccess(
'write',
'',$this->getTargetRefId()))
92 $ilErr->raiseError($lng->txt(
'permission_denied'),$ilErr->WARNING);
95 $next_class = $this->ctrl->getNextClass($this);
96 $cmd = $this->ctrl->getCmd();
112 $this->automatic_validation = $a_status;
125 $this->target_id = $a_target_id;
141 $this->target_ref_id = $a_target_ref_id;
157 $this->target_type = $a_target_type;
173 $this->target_title = $a_target_title;
193 function chi_init(&$chi_target_obj,$a_ref_id = null)
197 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
207 $this->target_obj =& $this->object;
221 $ilToolbar->addButton($this->lng->txt(
'add_condition'),$this->ctrl->getLinkTarget($this,
'selector'));
223 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.list_conditions.html',
'Services/AccessControl');
230 if(count($optional_conditions))
242 $this->tpl->setVariable(
'TABLE_SETTINGS',$form->getHTML());
244 include_once
'./Services/AccessControl/classes/class.ilConditionHandlerTableGUI.php';
246 $table->setConditions(
254 $this->tpl->setVariable(
'TABLE_CONDITIONS',$table->getHTML());
255 $this->tpl->setContent($table->getHTML());
264 if($form->checkInput())
266 $old_mode = $form->getInput(
"old_list_mode");
267 switch($form->getInput(
"list_mode"))
270 if($old_mode !=
"all")
272 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
279 foreach((array) $optional_conditions as $item)
287 $num_req = $form->getInput(
'required');
288 if($old_mode !=
"subset")
295 foreach($all_conditions as $item)
310 $this->ctrl->redirect($this,
'listConditions');
313 $form->setValuesByPost();
315 $this->tpl->setContent($form->getHTML());
329 if(
$_POST[
"obl"] &&
sizeof(
$_POST[
"obl"]) >
sizeof($all_conditions)-2)
332 $this->ctrl->redirect($this,
'listConditions');
335 foreach($all_conditions as $item)
338 if(
$_POST[
"obl"] && in_array($item[
"condition_id"],
$_POST[
"obl"]))
354 $this->ctrl->redirect($this,
'listConditions');
374 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
376 $form->setFormAction($this->ctrl->getFormAction($this),
'listConditions');
377 $form->setTitle($this->lng->txt(
'precondition_obligatory_settings'));
378 $form->addCommandButton(
'saveObligatorySettings', $this->lng->txt(
'save'));
381 $form->addItem($mode);
384 $mall =
new ilRadioOption($this->lng->txt(
"rbac_precondition_mode_all"),
"all");
385 $mall->
setInfo($this->lng->txt(
"rbac_precondition_mode_all_info"));
386 $mode->addOption($mall);
388 $msubset =
new ilRadioOption($this->lng->txt(
"rbac_precondition_mode_subset"),
"subset");
389 $msubset->
setInfo($this->lng->txt(
"rbac_precondition_mode_subset_info"));
390 $mode->addOption($msubset);
392 $obl =
new ilNumberInputGUI($this->lng->txt(
'precondition_num_obligatory'),
'required');
393 $obl->
setInfo($this->lng->txt(
'precondition_num_optional_info'));
401 $min = count($all) - count($opt) + 1;
402 $max = count($all) - 1;
406 $obligatory = $min = $max = 1;
408 $obl->setValue($obligatory);
409 $obl->setRequired(
true);
411 $obl->setMinValue($min);
412 $obl->setMaxValue($max);
413 $msubset->addSubItem($obl);
416 $old_mode->setValue(
$_REQUEST[
"list_mode"]);
417 $form->addItem($old_mode);
425 global $ilObjDataCache;
427 if(!
$_GET[
'condition_id'])
435 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_edit_condition.html',
436 "Services/AccessControl");
437 $this->ctrl->setParameter($this,
'condition_id',(
int) $_GET[
'condition_id']);
439 $this->
initFormCondition($condition[
'trigger_ref_id'],(
int) $_GET[
'condition_id'],
'edit');
440 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
445 global $ilObjDataCache;
447 if(!
$_GET[
'condition_id'])
455 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
459 $condition_handler->setOperator(
$_POST[
'operator']);
460 $condition_handler->setObligatory((
int)
$_POST[
'obligatory']);
462 $condition_handler->setValue(
'');
466 $condition_handler->setReferenceHandlingType($_POST[
'ref_handling']);
473 $condition_handler->updateCondition($condition[
'id']);
476 if($condition[
'trigger_type'] ==
'sahs')
478 include_once
'Services/Object/classes/class.ilObjectLP.php';
480 $collection = $olp->getCollectionInstance();
483 $collection->delete();
486 if(is_array($_POST[
'item_ids']))
488 $collection->activateEntries($_POST[
'item_ids']);
491 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
496 $this->ctrl->redirect($this,
'listConditions');
503 if(!count(
$_POST[
'conditions']))
511 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
513 $cgui->setFormAction($this->ctrl->getFormAction($this,
"listConditions"));
514 $cgui->setHeaderText($this->lng->txt(
"rbac_condition_delete_sure"));
515 $cgui->setCancel($this->lng->txt(
"cancel"),
"listConditions");
516 $cgui->setConfirm($this->lng->txt(
"delete"),
"delete");
519 foreach(
$_POST[
'conditions'] as $condition_id)
524 " (".$this->lng->txt(
"condition").
": ".
525 $this->lng->txt(
'condition_'.$condition[
'operator']).
")";
527 $alt = $this->lng->txt(
'obj_'.$condition[
'trigger_type']);
529 $cgui->addItem(
"conditions[]", $condition_id, $title, $icon, $alt);
532 $tpl->setContent($cgui->getHTML());
537 if(!count(
$_POST[
'conditions']))
544 foreach(
$_POST[
'conditions'] as $condition_id)
546 $this->ch_obj->deleteCondition($condition_id);
549 $this->ctrl->redirect($this,
'listConditions');
558 include_once (
"./Services/AccessControl/classes/class.ilConditionSelector.php");
560 $this->tpl->addBlockFile(
'ADM_CONTENT',
"adm_content",
"tpl.condition_selector.html",
561 "Services/AccessControl");
566 $exp->
setExpand(
$_GET[
"condition_selector_expand"] ?
$_GET[
"condition_selector_expand"] : $this->tree->readRootId());
567 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'selector'));
568 $exp->setTargetGet(
"ref_id");
575 $exp->setForceOpenPath(
$path);
578 $exp->addFilter(
'crs');
579 $exp->addFilter(
'tst');
580 $exp->addFilter(
'sahs');
581 $exp->addFilter(
'svy');
583 $exp->setSelectableTypes($this->ch_obj->getTriggerTypes());
584 $exp->setControlClass($this);
588 $this->tpl->setCurrentBlock(
"adm_content");
589 $this->tpl->setVariable(
"EXPLORER",$exp->getOutput());
590 $this->tpl->parseCurrentBlock();
595 global $ilObjDataCache;
597 if(!
$_GET[
'source_id'])
605 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.condition_handler_add.html',
606 "Services/AccessControl");
607 $this->tpl->setVariable(
'CONDITION_TABLE',$this->form->getHTML());
616 if(!isset(
$_GET[
'source_id']))
618 echo
"class.ilConditionHandlerInterface: no source_id given";
630 $this->ch_obj->setTargetObjId($this->
getTargetId());
636 $this->ch_obj->setReferenceHandlingType(
$_POST[
'ref_handling']);
646 echo
'ilConditionHandler: Trigger object does not exist';
648 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
649 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
650 $this->ch_obj->setTriggerType($trigger_obj->getType());
651 $this->ch_obj->setOperator(
$_POST[
'operator']);
652 $this->ch_obj->setObligatory((
int)
$_POST[
'obligatory']);
653 $this->ch_obj->setValue(
'');
656 if($this->ch_obj->getTriggerType() ==
'sahs')
658 include_once
'Services/Object/classes/class.ilObjectLP.php';
660 $collection = $olp->getCollectionInstance();
663 $collection->delete();
666 if(is_array($_POST[
'item_ids']))
668 $collection->activateEntries($_POST[
'item_ids']);
673 if(!$this->ch_obj->storeCondition())
682 $this->ctrl->redirect($this,
'listConditions');
689 #if(in_array('',$_POST['operator']))
691 # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
697 $this->ch_obj->setOperator(
$_POST[
'operator'][$condition[
"id"]]);
698 $this->ch_obj->setValue(
$_POST[
'value'][$condition[
"id"]]);
699 $this->ch_obj->updateCondition($condition[
'id']);
704 $this->ctrl->returnToParent($this);
710 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
714 if($condition[
'operator'] ==
'not_member')
720 $cond[] = $condition;
723 return $cond ? $cond : array();
733 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
736 $this->tpl->setCurrentBlock(
"btn_cell");
737 $this->tpl->setVariable(
"BTN_LINK",$link);
738 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt($name));
739 $this->tpl->parseCurrentBlock();
757 if(is_object($this->form))
761 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
763 $this->ctrl->setParameter($this,
'source_id',$a_source_id);
764 $this->form->setFormAction($this->ctrl->getFormAction($this));
768 $this->form->addItem($info_source);
772 $this->form->addItem($info_target);
791 $obl->setValue($condition[
'obligatory']);
797 $this->form->addItem($obl);
800 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
804 $operators[0] = $this->lng->txt(
'select_one');
806 foreach(
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
808 $operators[$operator] = $this->lng->txt(
'condition_'.$operator);
810 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
811 $sel->setOptions($operators);
812 $sel->setRequired(
true);
813 $this->form->addItem($sel);
820 $opt2 =
new ilRadioOption($this->lng->txt(
'cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
821 $rad_opt->addOption($opt2);
824 $rad_opt->addOption($opt1);
826 $this->form->addItem($rad_opt);
830 if($trigger_type ==
'sahs')
832 $this->lng->loadLanguageModule(
'trac');
834 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
837 $tpl =
new ilTemplate(
'tpl.condition_handler_sco_row.html',
true,
true,
838 "Services/AccessControl");
841 include_once
'Services/Object/classes/class.ilObjectLP.php';
843 $collection = $olp->getCollectionInstance();
846 foreach($collection->getPossibleItems() as $item_id => $sahs_item)
848 $tpl->setCurrentBlock(
"sco_row");
849 $tpl->setVariable(
'SCO_ID',$item_id);
850 $tpl->setVariable(
'SCO_TITLE',$sahs_item[
'title']);
851 $tpl->setVariable(
'CHECKED',$collection->isAssignedEntry($item_id) ?
'checked="checked"' :
'');
852 $tpl->parseCurrentBlock();
856 $tpl->setVariable(
'INFO_SEL',$this->lng->txt(
'trac_lp_determination_info_sco'));
857 $cus->setHTML(
$tpl->get());
858 $this->form->addItem($cus);
864 $this->form->setTitle($this->lng->txt(
'rbac_edit_condition'));
865 $this->form->addCommandButton(
'updateCondition',$this->lng->txt(
'save'));
866 $this->form->addCommandButton(
'listConditions',$this->lng->txt(
'cancel'));
872 $this->form->setTitle($this->lng->txt(
'add_condition'));
873 $this->form->addCommandButton(
'assign',$this->lng->txt(
'save'));
874 $this->form->addCommandButton(
'selector',$this->lng->txt(
'back'));