46 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
51 $this->gui_obj =&$gui_obj;
53 $this->lng->loadLanguageModule(
'rbac');
60 $this->target_obj =&$this->gui_obj->object;
65 if (is_object($this->target_obj)) {
79 switch ($a_operator) {
81 $GLOBALS[
'lng']->loadLanguageModule(
'trac');
82 include_once
'./Services/Tracking/classes/class.ilLPObjSettings.php';
87 $GLOBALS[
'lng']->loadLanguageModule(
'rbac');
88 return $GLOBALS[
'lng']->txt(
'condition_' . $a_operator);
114 if (!$ilAccess->checkAccess(
'write',
'', $this->getTargetRefId())) {
115 $ilErr->raiseError($lng->txt(
'permission_denied'), $ilErr->WARNING);
118 $next_class = $this->ctrl->getNextClass($this);
119 $cmd = $this->ctrl->getCmd();
121 switch ($next_class) {
133 $this->automatic_validation = $a_status;
146 $this->target_id = $a_target_id;
162 $this->target_ref_id = $a_target_ref_id;
178 $this->target_type = $a_target_type;
194 $this->target_title = $a_target_title;
214 public function chi_init(&$chi_target_obj, $a_ref_id = null)
218 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
225 $this->target_obj =&$this->object;
239 $ilToolbar->addButton($this->lng->txt(
'add_condition'), $this->ctrl->getLinkTarget($this,
'selector'));
241 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.list_conditions.html',
'Services/AccessControl');
248 if (count($optional_conditions)) {
249 if (!$_REQUEST[
"list_mode"]) {
250 $_REQUEST[
"list_mode"] =
"subset";
252 } elseif (!$_REQUEST[
"list_mode"]) {
253 $_REQUEST[
"list_mode"] =
"all";
265 $this->tpl->setVariable(
'TABLE_SETTINGS',
$form->getHTML());
269 include_once
'./Services/AccessControl/classes/class.ilConditionHandlerTableGUI.php';
280 $this->tpl->setVariable(
'TABLE_CONDITIONS',
$h);
290 if (
$form->checkInput()) {
291 $old_mode =
$form->getInput(
"old_list_mode");
292 switch (
$form->getInput(
"list_mode")) {
294 if ($old_mode !=
"all") {
295 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
302 foreach ((
array) $optional_conditions as $item) {
309 $num_req =
$form->getInput(
'required');
310 if ($old_mode !=
"subset") {
316 foreach ($all_conditions as $item) {
330 $cond->updateHiddenStatus((
int)
$form->getInput(
'hidden'));
333 $this->ctrl->redirect($this,
'listConditions');
336 $form->setValuesByPost();
338 $this->tpl->setContent(
$form->getHTML());
352 if (
$_POST[
"obl"] &&
sizeof(
$_POST[
"obl"]) >
sizeof($all_conditions)-2) {
354 $this->ctrl->redirect($this,
'listConditions');
357 foreach ($all_conditions as $item) {
359 if (
$_POST[
"obl"] && in_array($item[
"condition_id"],
$_POST[
"obl"])) {
374 $this->ctrl->redirect($this,
'listConditions');
398 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
400 $form->setFormAction($this->ctrl->getFormAction($this),
'listConditions');
401 $form->setTitle($this->lng->txt(
'precondition_obligatory_settings'));
402 $form->addCommandButton(
'saveObligatorySettings', $this->lng->txt(
'save'));
407 $hide->setInfo($this->lng->txt(
'rbac_precondition_hide_info'));
408 $form->addItem($hide);
411 $form->addItem($mode);
412 $mode->setValue($_REQUEST[
"list_mode"]);
414 $mall =
new ilRadioOption($this->lng->txt(
"rbac_precondition_mode_all"),
"all");
415 $mall->
setInfo($this->lng->txt(
"rbac_precondition_mode_all_info"));
416 $mode->addOption($mall);
419 if (count($all) > 1) {
421 $max = count($all) - 1;
423 $msubset =
new ilRadioOption($this->lng->txt(
"rbac_precondition_mode_subset"),
"subset");
424 $msubset->
setInfo($this->lng->txt(
"rbac_precondition_mode_subset_info"));
425 $mode->addOption($msubset);
427 $obl =
new ilNumberInputGUI($this->lng->txt(
'precondition_num_obligatory'),
'required');
428 $obl->
setInfo($this->lng->txt(
'precondition_num_optional_info'));
431 $obl->setValue($num_required > 0 ? $num_required : null);
432 $obl->setRequired(
true);
434 $obl->setMinValue($min);
435 $obl->setMaxValue($max);
436 $msubset->addSubItem($obl);
440 $old_mode->setValue($_REQUEST[
"list_mode"]);
441 $form->addItem($old_mode);
449 global $ilObjDataCache;
451 if (!
$_GET[
'condition_id']) {
458 $this->tpl->addBlockfile(
461 'tpl.condition_handler_edit_condition.html',
462 "Services/AccessControl" 464 $this->ctrl->setParameter($this,
'condition_id', (
int) $_GET[
'condition_id']);
466 $this->
initFormCondition($condition[
'trigger_ref_id'], (
int) $_GET[
'condition_id'],
'edit');
467 $this->tpl->setVariable(
'CONDITION_TABLE', $this->form->getHTML());
472 global $ilObjDataCache;
474 if (!
$_GET[
'condition_id']) {
481 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
485 $condition_handler->setOperator(
$_POST[
'operator']);
486 $condition_handler->setObligatory((
int)
$_POST[
'obligatory']);
488 $condition_handler->setValue(
'');
491 $condition_handler->setReferenceHandlingType($_POST[
'ref_handling']);
498 $condition_handler->updateCondition($condition[
'id']);
501 if ($condition[
'trigger_type'] ==
'sahs') {
502 include_once
'Services/Object/classes/class.ilObjectLP.php';
504 $collection = $olp->getCollectionInstance();
506 $collection->delete();
509 if (is_array($_POST[
'item_ids'])) {
510 $collection->activateEntries($_POST[
'item_ids']);
513 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
518 $this->ctrl->redirect($this,
'listConditions');
525 if (!count(
$_POST[
'conditions'])) {
532 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
534 $cgui->setFormAction($this->ctrl->getFormAction($this,
"listConditions"));
535 $cgui->setHeaderText($this->lng->txt(
"rbac_condition_delete_sure"));
536 $cgui->setCancel($this->lng->txt(
"cancel"),
"listConditions");
537 $cgui->setConfirm($this->lng->txt(
"delete"),
"delete");
540 foreach (
$_POST[
'conditions'] as $condition_id) {
544 " (" . $this->lng->txt(
"condition") .
": " .
545 $this->lng->txt(
'condition_' . $condition[
'operator']) .
")";
547 $alt = $this->lng->txt(
'obj_' . $condition[
'trigger_type']);
549 $cgui->addItem(
"conditions[]", $condition_id,
$title, $icon, $alt);
552 $tpl->setContent($cgui->getHTML());
555 public function delete()
557 if (!count(
$_POST[
'conditions'])) {
563 foreach (
$_POST[
'conditions'] as $condition_id) {
564 $this->ch_obj->deleteCondition($condition_id);
567 $this->ctrl->redirect($this,
'listConditions');
574 include_once(
"./Services/AccessControl/classes/class.ilConditionSelector.php");
579 $exp->setTypeWhiteList(array_merge(
581 array(
"root",
"cat",
"grp",
"fold",
"crs",
"prg")
587 if (!$exp->handleCommand()) {
588 $this->tpl->setContent($exp->getHTML());
594 global $ilObjDataCache;
596 if (!
$_GET[
'source_id']) {
603 $this->tpl->addBlockfile(
606 'tpl.condition_handler_add.html',
607 "Services/AccessControl" 609 $this->tpl->setVariable(
'CONDITION_TABLE', $this->form->getHTML());
618 if (!isset(
$_GET[
'source_id'])) {
619 echo
"class.ilConditionHandlerGUI: no source_id given";
623 if (!
$_POST[
'operator']) {
630 $this->ch_obj->setTargetObjId($this->
getTargetId());
635 $this->ch_obj->setReferenceHandlingType(
$_POST[
'ref_handling']);
644 echo
'ilConditionHandler: Trigger object does not exist';
646 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
647 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
648 $this->ch_obj->setTriggerType($trigger_obj->getType());
649 $this->ch_obj->setOperator(
$_POST[
'operator']);
650 $this->ch_obj->setObligatory((
int)
$_POST[
'obligatory']);
652 $this->ch_obj->setValue(
'');
655 if ($this->ch_obj->getTriggerType() ==
'sahs') {
656 include_once
'Services/Object/classes/class.ilObjectLP.php';
658 $collection = $olp->getCollectionInstance();
660 $collection->delete();
663 if (is_array($_POST[
'item_ids'])) {
664 $collection->activateEntries($_POST[
'item_ids']);
669 if (!$this->ch_obj->storeCondition()) {
675 $this->ctrl->redirect($this,
'listConditions');
682 #if(in_array('',$_POST['operator'])) 684 # ilUtil::sendInfo($this->lng->txt('select_one_operator')); 689 $this->ch_obj->setOperator(
$_POST[
'operator'][$condition[
"id"]]);
690 $this->ch_obj->setValue(
$_POST[
'value'][$condition[
"id"]]);
691 $this->ch_obj->updateCondition($condition[
'id']);
695 $this->ctrl->returnToParent($this);
701 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
704 if ($condition[
'operator'] ==
'not_member') {
707 $cond[] = $condition;
710 return $cond ? $cond :
array();
727 if (is_object($this->form)) {
730 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
732 $this->ctrl->setParameter($this,
'source_id', $a_source_id);
733 $this->form->setFormAction($this->ctrl->getFormAction($this));
737 $this->form->addItem($info_source);
741 $this->form->addItem($info_target);
758 if ($a_condition_id) {
759 $obl->setValue($condition[
'obligatory']);
763 $this->form->addItem($obl);
766 include_once
"./Services/AccessControl/classes/class.ilConditionHandler.php";
768 if ($a_mode ==
'add') {
769 $operators[0] = $this->lng->txt(
'select_one');
771 foreach (
$ch_obj->getOperatorsByTargetType($trigger_type) as $operator) {
772 $operators[$operator] = $this->lng->txt(
'condition_' . $operator);
774 $sel->setValue(isset($condition[
'operator']) ? $condition[
'operator'] : 0);
775 $sel->setOptions($operators);
776 $sel->setRequired(
true);
777 $this->form->addItem($sel);
784 $rad_opt->addOption($opt2);
787 $rad_opt->addOption($opt1);
789 $this->form->addItem($rad_opt);
793 if ($trigger_type ==
'sahs') {
794 $this->lng->loadLanguageModule(
'trac');
796 $cus =
new ilCustomInputGUI($this->lng->txt(
'trac_sahs_relevant_items'),
'item_ids[]');
800 'tpl.condition_handler_sco_row.html',
803 "Services/AccessControl" 807 include_once
'Services/Object/classes/class.ilObjectLP.php';
809 $collection = $olp->getCollectionInstance();
811 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
812 $tpl->setCurrentBlock(
"sco_row");
813 $tpl->setVariable(
'SCO_ID', $item_id);
814 $tpl->setVariable(
'SCO_TITLE', $sahs_item[
'title']);
815 $tpl->setVariable(
'CHECKED', $collection->isAssignedEntry($item_id) ?
'checked="checked"' :
'');
816 $tpl->parseCurrentBlock();
820 $tpl->setVariable(
'INFO_SEL', $this->lng->txt(
'trac_lp_determination_info_sco'));
821 $cus->setHTML(
$tpl->get());
822 $this->form->addItem($cus);
827 $this->form->setTitle($this->lng->txt(
'rbac_edit_condition'));
828 $this->form->addCommandButton(
'updateCondition', $this->lng->txt(
'save'));
829 $this->form->addCommandButton(
'listConditions', $this->lng->txt(
'cancel'));
835 $this->form->setTitle($this->lng->txt(
'add_condition'));
836 $this->form->addCommandButton(
'assign', $this->lng->txt(
'save'));
837 $this->form->addCommandButton(
'selector', $this->lng->txt(
'back'));
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
listConditions()
list conditions ilToolbar
getTargetType()
get target type
This class represents an option in a radio group.
class ilConditionHandlerGUI
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
setValue($a_value)
Set Value.
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
setBackButtons($a_btn_arr)
static lookupHiddenStatusByTarget($a_target_ref_id)
Lookup hidden status type $ilDB.
static translateOperator($a_obj_id, $a_operator)
Translate operator.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
initFormCondition($a_source_id, $a_condition_id=0, $a_mode='add')
Init form for condition table.
setTargetId($a_target_id)
set target id
__getConditionsOfTarget()
static _lookupTitle($a_id)
lookup object title
assign()
assign new trigger condition to target
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static lookupObligatoryConditionsOfTarget($a_target_ref_id, $a_target_obj_id)
Lookup obligatory conditions of target.
setInfo($a_info)
Set Info.
static calculateRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
getTargetRefId()
get target ref id
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct($gui_obj, $a_ref_id=null)
Constructor <type> $lng <type> $tpl <type> $tree <type> $ilCtrl.
setTargetRefId($a_target_ref_id)
set target ref id
if(isset($_POST['submit'])) $form
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getConditionHandler()
Get condition handler.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Table presentation of conditions.
static getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
setTargetTitle($a_target_title)
set target title
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Handles conditions for accesses to different ILIAS objects.
setAutomaticValidation($a_status)
saveObligatorySettings()
Save obligatory settings.
static _isReferenceHandlingOptional($a_type)
is reference handling optional
saveObligatoryList()
Save obligatory settings.
This class represents a non editable value in a property form.
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
chi_init(&$chi_target_obj, $a_ref_id=null)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getCondition($a_id)
getTargetId()
get target id
getTargetTitle()
get target title
setTargetType($a_target_type)
set target type
if(empty($password)) $table
isTargetReferenced()
Check if target has refernce id.
static getInstance($a_obj_id)
showObligatoryForm($opt=array())
Show obligatory form.
Confirmation screen class.
static _mode2Text($a_mode)