3 declare(strict_types=1);
63 $this->
ctrl = $DIC->ctrl();
64 $this->
lng = $DIC->language();
65 $this->
lng->loadLanguageModule(
'rbac');
66 $this->
lng->loadLanguageModule(
'cond');
67 $this->tpl = $DIC->ui()->mainTemplate();
68 $this->tree = $DIC->repositoryTree();
69 $this->
access = $DIC->access();
70 $this->
toolbar = $DIC->toolbar();
71 $this->conditionUtil = $DIC->conditions()->util();
73 $this->
http = $DIC->http();
78 if ($target_obj !== null) {
89 if ($this->
http->wrapper()->query()->has(
'condition_id')) {
90 return $this->
http->wrapper()->query()->retrieve(
100 if ($this->
http->wrapper()->post()->has(
'conditions')) {
101 return SplFixedArray::fromArray(
102 $this->
http->wrapper()->post()->retrieve(
104 $this->
refinery->kindlyTo()->listOf(
110 return new SplFixedArray(0);
115 if ($this->
http->wrapper()->post()->has(
'item_ids')) {
116 return SplFixedArray::fromArray(
117 $this->
http->wrapper()->post()->retrieve(
119 $this->
refinery->kindlyTo()->listOf(
125 return new SplFixedArray(0);
130 if ($this->
http->wrapper()->post()->has(
'obl')) {
131 return SplFixedArray::fromArray(
132 $this->
http->wrapper()->post()->retrieve(
134 $this->
refinery->kindlyTo()->listOf(
140 return new SplFixedArray(0);
145 return $this->
http->wrapper()->post()->retrieve(
148 $this->refinery->kindlyTo()->string(),
149 $this->
refinery->always(self::LIST_MODE_UNDEFINED)
156 if ($this->
http->wrapper()->query()->has(
'source_id')) {
157 return $this->
http->wrapper()->query()->retrieve(
169 $lng = $DIC->language();
170 switch ($a_operator) {
179 return $lng->
txt(
'condition_' . $a_operator);
207 if (!$this->
access->checkAccess(
'write',
'', $this->getTargetRefId())) {
208 $ilErr->raiseError($this->
lng->txt(
'permission_denied'),
$ilErr->WARNING);
211 $next_class = $this->
ctrl->getNextClass($this);
212 $cmd = $this->
ctrl->getCmd();
213 switch ($next_class) {
225 $this->automatic_validation = $a_status;
235 $this->target_id = $a_target_id;
245 $this->target_ref_id = $a_target_ref_id;
255 $this->target_type = $a_target_type;
265 $this->target_title = $a_target_title;
286 $this->conditionUtil->isUnderParentControl($this->getTargetRefId())
288 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cond_under_parent_control"));
292 $this->
toolbar->addButton($this->
lng->txt(
'add_condition'), $this->
ctrl->getLinkTarget($this,
'selector'));
293 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.list_conditions.html',
'Services/AccessControl');
301 if (count($optional_conditions)) {
302 if ($list_mode === self::LIST_MODE_UNDEFINED) {
303 $list_mode = self::LIST_MODE_SUBSET;
305 } elseif ($list_mode === self::LIST_MODE_UNDEFINED) {
306 $list_mode = self::LIST_MODE_ALL;
318 $this->tpl->setVariable(
'TABLE_SETTINGS', $form->getHTML());
323 $table->setConditions(
331 $h = $table->getHTML();
332 $this->tpl->setVariable(
'TABLE_CONDITIONS', $h);
338 if ($form !== null && $form->checkInput()) {
339 $old_mode = $form->getInput(
"old_list_mode");
340 switch ($form->getInput(
"list_mode")) {
342 if ($old_mode !==
"all") {
349 foreach ($optional_conditions as $item) {
356 $num_req = $form->getInput(
'required');
357 if ($old_mode !==
"subset") {
363 foreach ($all_conditions as $item) {
377 $cond->updateHiddenStatus((
bool) $form->getInput(
'hidden'));
379 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
380 $this->
ctrl->redirect($this,
'listConditions');
383 $form->setValuesByPost();
384 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
385 $this->tpl->setContent($form->getHTML());
397 if (count($obligatory_ids) > count($all_conditions) - 2) {
398 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"rbac_precondition_minimum_optional"),
true);
399 $this->
ctrl->redirect($this,
'listConditions');
402 foreach ($all_conditions as $item) {
404 if (in_array($item[
'condition_id'], $obligatory_ids->toArray(),
true)) {
418 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
419 $this->
ctrl->redirect($this,
'listConditions');
423 string $list_mode = self::LIST_MODE_ALL
431 $form->setFormAction($this->
ctrl->getFormAction($this,
'listConditions'));
432 $form->setTitle($this->
lng->txt(
'precondition_obligatory_settings'));
433 $form->addCommandButton(
'saveObligatorySettings', $this->
lng->txt(
'save'));
437 $hide->setValue(
"1");
438 $hide->setInfo($this->
lng->txt(
'rbac_precondition_hide_info'));
439 $form->addItem($hide);
442 $form->addItem($mode);
445 $mall =
new ilRadioOption($this->
lng->txt(
"rbac_precondition_mode_all"),
"all");
446 $mall->
setInfo($this->
lng->txt(
"rbac_precondition_mode_all_info"));
447 $mode->addOption($mall);
449 if (count($all) > 1) {
451 $max = count($all) - 1;
453 $msubset =
new ilRadioOption($this->
lng->txt(
"rbac_precondition_mode_subset"),
"subset");
454 $msubset->
setInfo($this->
lng->txt(
"rbac_precondition_mode_subset_info"));
455 $mode->addOption($msubset);
458 $obl->
setInfo($this->
lng->txt(
'precondition_num_optional_info'));
464 $obl->setValue($num_required > 0 ? (
string) $num_required : null);
465 $obl->setRequired(
true);
467 $obl->setMinValue($min);
468 $obl->setMaxValue($max);
469 $msubset->addSubItem($obl);
473 $old_mode->setValue($list_mode);
474 $form->addItem($old_mode);
482 if (!$condition_id) {
483 $this->tpl->setOnScreenMessage(
'failure',
"Missing id: condition_id");
487 $this->
ctrl->setParameter($this,
'condition_id', $condition_id);
491 $form = $this->
initFormCondition($condition[
'trigger_ref_id'], $condition_id,
'edit');
493 $this->tpl->setContent($form->getHTML());
499 if (!$condition_id) {
500 $this->tpl->setOnScreenMessage(
'failure',
"Missing id: condition_id");
509 $condition[
'trigger_ref_id'],
514 if (!$form->checkInput()) {
515 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
520 $condition_handler->setOperator((
string) $form->getInput(
'operator'));
521 $condition_handler->setObligatory((
bool) $form->getInput(
'obligatory'));
523 $condition_handler->setValue(
'');
526 $condition_handler->setReferenceHandlingType((
int) $form->getInput(
'ref_handling'));
533 $condition_handler->updateCondition($condition[
'id']);
536 if ($condition[
'trigger_type'] ===
'sahs') {
538 $collection = $olp->getCollectionInstance();
540 $collection->delete();
543 if (count($item_ids)) {
544 $collection->activateEntries($item_ids->toArray());
548 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
549 $this->
ctrl->redirect($this,
'listConditions');
555 if (!count($condition_ids)) {
556 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_condition_selected'));
563 $cgui->setFormAction($this->
ctrl->getFormAction($this,
"listConditions"));
564 $cgui->setHeaderText($this->
lng->txt(
"rbac_condition_delete_sure"));
565 $cgui->setCancel($this->
lng->txt(
"cancel"),
"listConditions");
566 $cgui->setConfirm($this->
lng->txt(
"delete"),
"delete");
569 foreach ($condition_ids as $condition_id) {
573 " (" . $this->
lng->txt(
"condition") .
": " .
574 $this->
lng->txt(
'condition_' . $condition[
'operator']) .
")";
576 $alt = $this->
lng->txt(
'obj_' . $condition[
'trigger_type']);
578 $cgui->addItem(
"conditions[]", (
string) $condition_id, $title, $icon, $alt);
581 $this->tpl->setContent($cgui->getHTML());
584 public function delete():
void 587 if (!count($condition_ids)) {
588 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_condition_selected'));
593 foreach ($condition_ids as $condition_id) {
594 $this->ch_obj->deleteCondition($condition_id);
596 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'condition_deleted'),
true);
597 $this->
ctrl->redirect($this,
'listConditions');
602 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"condition_select_object"));
605 $exp->setTypeWhiteList(array_merge(
607 array(
"root",
"cat",
"grp",
"fold",
"crs",
"prg")
613 if (!$exp->handleCommand()) {
614 $this->tpl->setContent($exp->getHTML());
622 $this->tpl->setOnScreenMessage(
'failure',
"Missing id: condition_id");
629 $this->tpl->setContent($form->getHTML());
639 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_condition_selected'));
645 if (!$form->checkInput()) {
646 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
651 $this->ch_obj->setTargetObjId($this->
getTargetId());
656 $this->ch_obj->setReferenceHandlingType((
int) $form->getInput(
'ref_handling'));
665 if ($trigger_obj !== null) {
666 $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
667 $this->ch_obj->setTriggerObjId($trigger_obj->getId());
668 $this->ch_obj->setTriggerType($trigger_obj->getType());
670 $this->ch_obj->setOperator($form->getInput(
'operator'));
671 $this->ch_obj->setObligatory((
bool) $form->getInput(
'obligatory'));
673 $this->ch_obj->setValue(
'');
676 if ($this->ch_obj->getTriggerType() ===
'sahs') {
678 $collection = $olp->getCollectionInstance();
680 $collection->delete();
684 if (count($items_ids)) {
685 $collection->activateEntries($items_ids->toArray());
689 if (!$this->ch_obj->storeCondition()) {
690 $this->tpl->setOnScreenMessage(
'failure', $this->ch_obj->getErrorMessage(),
true);
692 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'added_new_condition'),
true);
694 $this->
ctrl->redirect($this,
'listConditions');
705 if ($condition[
'operator'] ===
'not_member') {
709 $cond[] = $condition;
716 int $a_condition_id = 0,
717 string $a_mode =
'add' 724 $this->
ctrl->setParameter($this,
'source_id', $a_source_id);
725 $form->setFormAction($this->
ctrl->getFormAction($this));
729 $form->addItem($info_source);
733 $form->addItem($info_target);
736 if ($a_condition_id) {
737 $obl->setValue((
string) (
bool) $condition[
'obligatory']);
741 $form->addItem($obl);
746 if ($a_mode ===
'add') {
747 $operators[
''] = $this->
lng->txt(
'select_one');
749 foreach ($ch_obj->getOperatorsByTriggerType($trigger_type) as $operator) {
750 $operators[$operator] = $this->
lng->txt(
'condition_' . $operator);
752 $sel->setValue($condition[
'operator'] ??
'');
753 $sel->setOptions($operators);
754 $sel->setRequired(
true);
755 $form->addItem($sel);
762 $this->
lng->txt(
'cond_ref_shared'),
763 (string) ilConditionHandler::SHARED_CONDITIONS
765 $rad_opt->addOption($opt2);
768 $this->
lng->txt(
'cond_ref_unique'),
771 $rad_opt->addOption($opt1);
773 $form->addItem($rad_opt);
777 if ($trigger_type ===
'sahs') {
778 $this->
lng->loadLanguageModule(
'trac');
781 $cus->
setInfo($this->
lng->txt(
'trac_lp_determination_info_sco'));
782 $cus->setRequired(
true);
785 $collection = $olp->getCollectionInstance();
788 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
790 if ($collection->isAssignedEntry($item_id)) {
791 $checked[] = $item_id;
793 $cus->addOption($sco);
796 $cus->setValue($checked);
797 $form->addItem($cus);
802 $form->setTitle($this->
lng->txt(
'rbac_edit_condition'));
803 $form->addCommandButton(
'updateCondition', $this->
lng->txt(
'save'));
804 $form->addCommandButton(
'listConditions', $this->
lng->txt(
'cancel'));
809 $form->setTitle($this->
lng->txt(
'add_condition'));
810 $form->addCommandButton(
'assign', $this->
lng->txt(
'save'));
811 $form->addCommandButton(
'selector', $this->
lng->txt(
'back'));
Interface GlobalHttpState.
static get(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
class ilConditionHandlerGUI
initConditionIdFromQuery()
static _getCondition(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
bool $automatic_validation
static _isReferenceHandlingOptional(string $a_type)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static lookupObligatoryConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id)
setTargetRefId(int $a_target_ref_id)
static updateObligatory(int $a_id, bool $a_status)
Toggle condition obligatory status.
static calculatePersistedRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='', bool $a_force_update=false)
__construct(int $a_ref_id=null)
showObligatoryForm(string $list_mode=self::LIST_MODE_ALL)
ilObjectDefinition $objectDefinition
loadLanguageModule(string $a_module)
Load language module.
assign()
assign new trigger condition to target
static lookupPersistedHiddenStatusByTarget(int $a_target_ref_id)
setTargetTitle(string $a_target_title)
setTargetId(int $a_target_id)
setAutomaticValidation(bool $a_status)
static _lookupObjId(int $ref_id)
ilConditionHandler $ch_obj
static saveNumberOfRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, int $a_num)
parses the objects.xml it handles the xml-description of all ilias objects
static http()
Fetches the global http state from ILIAS.
add(?ilPropertyFormGUI $form=null)
static _lookupTitle(int $obj_id)
ilConditionUtil $conditionUtil
Condition utility object Wraps some ilConditionHandler methods (which will become deprecated) Depende...
initConditionsIdsFromPost()
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static translateOperator(int $a_obj_id, string $a_operator)
static getPersistedOptionalConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
setTargetType(string $a_target_type)
edit(?ilPropertyFormGUI $form=null)
initFormCondition(int $a_source_id, int $a_condition_id=0, string $a_mode='add')
isTargetReferenced()
Check if target has refernce id.
initObligatoryItemsFromPost()
static _lookupType(int $id, bool $reference=false)
const LIST_MODE_UNDEFINED
static getInstance(int $obj_id)
setBackButtons(array $a_btn_arr)
static set(string $a_var, $a_val)
Set a value.
static _getPersistedConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_target_type="")
get all persisted conditions of target object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _mode2Text(int $a_mode)