ILIAS  release_8 Revision v8.24
ilConditionHandlerGUI Class Reference

class ilConditionHandlerGUI More...

+ Collaboration diagram for ilConditionHandlerGUI:

Public Member Functions

 __construct (int $a_ref_id=null)
 
 setBackButtons (array $a_btn_arr)
 
 getBackButtons ()
 
 executeCommand ()
 
 setAutomaticValidation (bool $a_status)
 
 getAutomaticValidation ()
 
 setTargetId (int $a_target_id)
 
 getTargetId ()
 
 setTargetRefId (int $a_target_ref_id)
 
 getTargetRefId ()
 
 setTargetType (string $a_target_type)
 
 getTargetType ()
 
 setTargetTitle (string $a_target_title)
 
 isTargetReferenced ()
 Check if target has refernce id. More...
 
 getTargetTitle ()
 
 edit (?ilPropertyFormGUI $form=null)
 
 updateCondition ()
 
 askDelete ()
 
 delete ()
 
 selector ()
 
 add (?ilPropertyFormGUI $form=null)
 
 assign ()
 assign new trigger condition to target More...
 
 getConditionsOfTarget ()
 

Static Public Member Functions

static translateOperator (int $a_obj_id, string $a_operator)
 

Protected Member Functions

 initConditionIdFromQuery ()
 
 initConditionsIdsFromPost ()
 
 initItemIdsFromPost ()
 
 initObligatoryItemsFromPost ()
 
 initListModeFromPost ()
 
 initSourceIdFromQuery ()
 
 getConditionHandler ()
 
 listConditions ()
 
 saveObligatorySettings ()
 
 saveObligatoryList ()
 
 showObligatoryForm (string $list_mode=self::LIST_MODE_ALL)
 

Protected Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilTree $tree
 
ilAccessHandler $access
 
ilToolbarGUI $toolbar
 
ilConditionUtil $conditionUtil
 
ilObjectDefinition $objectDefinition
 
ilConditionHandler $ch_obj
 
ilObject $target_obj = null
 
int $target_id = 0
 
string $target_type = ''
 
string $target_title = ''
 
int $target_ref_id = 0
 
bool $automatic_validation = true
 

Private Member Functions

 initFormCondition (int $a_source_id, int $a_condition_id=0, string $a_mode='add')
 

Private Attributes

const LIST_MODE_UNDEFINED = 'undefined'
 
const LIST_MODE_ALL = 'all'
 
const LIST_MODE_SUBSET = 'subset'
 
GlobalHttpState $http
 
Factory $refinery
 

Detailed Description

class ilConditionHandlerGUI

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$ This class is aggregated in folders, groups which have a parent course object Since it is something like an interface, all varirables, methods have there own name space (names start with cci) to avoid collisions @ilCtrl_Calls ilConditionHandlerGUI:

Definition at line 32 of file class.ilConditionHandlerGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilConditionHandlerGUI::__construct ( int  $a_ref_id = null)

Definition at line 58 of file class.ilConditionHandlerGUI.php.

59 {
60 global $DIC;
61
62 $this->ch_obj = new ilConditionHandler();
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();
72 $this->objectDefinition = $DIC['objDefinition'];
73 $this->http = $DIC->http();
74 $this->refinery = $DIC->refinery();
75
76 if ($a_ref_id) {
78 if ($target_obj !== null) {
79 $this->setTargetId($target_obj->getId());
83 }
84 }
85 }
setTargetType(string $a_target_type)
setTargetRefId(int $a_target_ref_id)
setTargetTitle(string $a_target_title)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, $target_obj, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilObject\getId(), ilObjectFactory\getInstanceByRefId(), ilObject\getRefId(), ilObject\getTitle(), ilObject\getType(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\objectDefinition(), ILIAS\Repository\refinery(), setTargetId(), setTargetRefId(), setTargetTitle(), setTargetType(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilConditionHandlerGUI::add ( ?ilPropertyFormGUI  $form = null)

Definition at line 618 of file class.ilConditionHandlerGUI.php.

618 : void
619 {
620 $source_id = $this->initSourceIdFromQuery();
621 if (!$source_id) {
622 $this->tpl->setOnScreenMessage('failure', "Missing id: condition_id");
623 $this->selector();
624 return;
625 }
626 if (!$form instanceof ilPropertyFormGUI) {
627 $form = $this->initFormCondition($source_id, 0, 'add');
628 }
629 $this->tpl->setContent($form->getHTML());
630 }
initFormCondition(int $a_source_id, int $a_condition_id=0, string $a_mode='add')
This class represents a property form user interface.

◆ askDelete()

ilConditionHandlerGUI::askDelete ( )

Definition at line 552 of file class.ilConditionHandlerGUI.php.

552 : void
553 {
554 $condition_ids = $this->initConditionsIdsFromPost();
555 if (!count($condition_ids)) {
556 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_condition_selected'));
557 $this->listConditions();
558 return;
559 }
560
561 // display confirmation message
562 $cgui = new ilConfirmationGUI();
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");
567
568 // list conditions that should be deleted
569 foreach ($condition_ids as $condition_id) {
570 $condition = ilConditionHandler::_getCondition($condition_id);
571
572 $title = ilObject::_lookupTitle($condition['trigger_obj_id']) .
573 " (" . $this->lng->txt("condition") . ": " .
574 $this->lng->txt('condition_' . $condition['operator']) . ")";
575 $icon = ilUtil::getImagePath('icon_' . $condition['trigger_type'] . '.svg');
576 $alt = $this->lng->txt('obj_' . $condition['trigger_type']);
577
578 $cgui->addItem("conditions[]", (string) $condition_id, $title, $icon, $alt);
579 }
580
581 $this->tpl->setContent($cgui->getHTML());
582 }
static _getCondition(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References ilConditionHandler\_getCondition(), ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), ilUtil\getImagePath(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ assign()

ilConditionHandlerGUI::assign ( )

assign new trigger condition to target

Definition at line 635 of file class.ilConditionHandlerGUI.php.

635 : void
636 {
637 $source_id = $this->initSourceIdFromQuery();
638 if (!$source_id) {
639 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_condition_selected'));
640 $this->selector();
641 return;
642 }
643
644 $form = $this->initFormCondition($source_id, 0, 'add');
645 if (!$form->checkInput()) {
646 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
647 $this->add($form);
648 return;
649 }
650 $this->ch_obj->setTargetRefId($this->getTargetRefId());
651 $this->ch_obj->setTargetObjId($this->getTargetId());
652 $this->ch_obj->setTargetType($this->getTargetType());
653
654 switch ($this->getTargetType()) {
655 case 'st':
656 $this->ch_obj->setReferenceHandlingType((int) $form->getInput('ref_handling'));
657 break;
658
659 default:
660 $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
661 break;
662 }
663 // this has to be changed, if non referenced trigger are implemted
664 $trigger_obj = ilObjectFactory::getInstanceByRefId($source_id);
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());
669 }
670 $this->ch_obj->setOperator($form->getInput('operator'));
671 $this->ch_obj->setObligatory((bool) $form->getInput('obligatory'));
672 $this->ch_obj->setHiddenStatus(ilConditionHandler::lookupPersistedHiddenStatusByTarget($this->getTargetRefId()));
673 $this->ch_obj->setValue('');
674
675 // Save assigned sco's
676 if ($this->ch_obj->getTriggerType() === 'sahs') {
677 $olp = ilObjectLP::getInstance($this->ch_obj->getTriggerObjId());
678 $collection = $olp->getCollectionInstance();
679 if ($collection) {
680 $collection->delete();
681 }
682
683 $items_ids = $this->initItemIdsFromPost();
684 if (count($items_ids)) { // #12901
685 $collection->activateEntries($items_ids->toArray());
686 }
687 }
688 $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
689 if (!$this->ch_obj->storeCondition()) {
690 $this->tpl->setOnScreenMessage('failure', $this->ch_obj->getErrorMessage(), true);
691 } else {
692 $this->tpl->setOnScreenMessage('success', $this->lng->txt('added_new_condition'), true);
693 }
694 $this->ctrl->redirect($this, 'listConditions');
695 }
add(?ilPropertyFormGUI $form=null)
static lookupPersistedHiddenStatusByTarget(int $a_target_ref_id)
static getInstance(int $obj_id)

References ILIAS\UI\examples\Symbol\Glyph\Add\add(), ILIAS\Repository\ctrl(), ilObjectLP\getInstance(), ilObjectFactory\getInstanceByRefId(), ILIAS\Repository\lng(), ilConditionHandler\lookupPersistedHiddenStatusByTarget(), and ilConditionHandler\UNIQUE_CONDITIONS.

+ Here is the call graph for this function:

◆ delete()

ilConditionHandlerGUI::delete ( )

Definition at line 584 of file class.ilConditionHandlerGUI.php.

584 : void
585 {
586 $condition_ids = $this->initConditionsIdsFromPost();
587 if (!count($condition_ids)) {
588 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_condition_selected'));
589 $this->listConditions();
590 return;
591 }
592
593 foreach ($condition_ids as $condition_id) {
594 $this->ch_obj->deleteCondition($condition_id);
595 }
596 $this->tpl->setOnScreenMessage('success', $this->lng->txt('condition_deleted'), true);
597 $this->ctrl->redirect($this, 'listConditions');
598 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ edit()

ilConditionHandlerGUI::edit ( ?ilPropertyFormGUI  $form = null)

Definition at line 479 of file class.ilConditionHandlerGUI.php.

479 : void
480 {
481 $condition_id = $this->initConditionIdFromQuery();
482 if (!$condition_id) {
483 $this->tpl->setOnScreenMessage('failure', "Missing id: condition_id");
484 $this->listConditions();
485 return;
486 }
487 $this->ctrl->setParameter($this, 'condition_id', $condition_id);
488 $condition = ilConditionHandler::_getCondition($condition_id);
489
490 if (!$form instanceof ilPropertyFormGUI) {
491 $form = $this->initFormCondition($condition['trigger_ref_id'], $condition_id, 'edit');
492 }
493 $this->tpl->setContent($form->getHTML());
494 }

References ilConditionHandler\_getCondition(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ executeCommand()

ilConditionHandlerGUI::executeCommand ( )

Definition at line 201 of file class.ilConditionHandlerGUI.php.

201 : void
202 {
203 global $DIC;
204
205 $ilErr = $DIC['ilErr'];
206
207 if (!$this->access->checkAccess('write', '', $this->getTargetRefId())) {
208 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
209 }
210
211 $next_class = $this->ctrl->getNextClass($this);
212 $cmd = $this->ctrl->getCmd();
213 switch ($next_class) {
214 default:
215 if (empty($cmd)) {
216 $cmd = "view";
217 }
218 $this->$cmd();
219 break;
220 }
221 }
$ilErr
Definition: raiseError.php:17

References $DIC, $ilErr, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getAutomaticValidation()

ilConditionHandlerGUI::getAutomaticValidation ( )

Definition at line 228 of file class.ilConditionHandlerGUI.php.

228 : bool
229 {
231 }

References $automatic_validation.

◆ getBackButtons()

ilConditionHandlerGUI::getBackButtons ( )

Definition at line 193 of file class.ilConditionHandlerGUI.php.

193 : array
194 {
195 if (ilSession::has('precon_btn')) {
196 return ilSession::get('precon_btn');
197 }
198 return [];
199 }
static get(string $a_var)
static has($a_var)

References ilSession\get(), and ilSession\has().

+ Here is the call graph for this function:

◆ getConditionHandler()

ilConditionHandlerGUI::getConditionHandler ( )
protected

Definition at line 183 of file class.ilConditionHandlerGUI.php.

184 {
185 return $this->ch_obj;
186 }

References $ch_obj.

◆ getConditionsOfTarget()

ilConditionHandlerGUI::getConditionsOfTarget ( )

Definition at line 697 of file class.ilConditionHandlerGUI.php.

697 : array
698 {
699 $cond = [];
701 $this->getTargetRefId(),
702 $this->getTargetId(),
703 $this->getTargetType()
704 ) as $condition) {
705 if ($condition['operator'] === 'not_member') {
706 continue;
707 }
708
709 $cond[] = $condition;
710 }
711 return $cond;
712 }
static _getPersistedConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_target_type="")
get all persisted conditions of target object

References ilConditionHandler\_getPersistedConditionsOfTarget().

+ Here is the call graph for this function:

◆ getTargetId()

ilConditionHandlerGUI::getTargetId ( )

Definition at line 238 of file class.ilConditionHandlerGUI.php.

238 : int
239 {
240 return $this->target_id;
241 }

References $target_id.

Referenced by listConditions(), saveObligatoryList(), and saveObligatorySettings().

+ Here is the caller graph for this function:

◆ getTargetRefId()

ilConditionHandlerGUI::getTargetRefId ( )

Definition at line 248 of file class.ilConditionHandlerGUI.php.

248 : int
249 {
251 }

References $target_ref_id.

Referenced by isTargetReferenced(), listConditions(), saveObligatoryList(), and saveObligatorySettings().

+ Here is the caller graph for this function:

◆ getTargetTitle()

ilConditionHandlerGUI::getTargetTitle ( )

Definition at line 276 of file class.ilConditionHandlerGUI.php.

276 : string
277 {
278 return $this->target_title;
279 }

References $target_title.

◆ getTargetType()

ilConditionHandlerGUI::getTargetType ( )

Definition at line 258 of file class.ilConditionHandlerGUI.php.

258 : string
259 {
260 return $this->target_type;
261 }

References $target_type.

Referenced by listConditions(), saveObligatoryList(), and saveObligatorySettings().

+ Here is the caller graph for this function:

◆ initConditionIdFromQuery()

ilConditionHandlerGUI::initConditionIdFromQuery ( )
protected

Definition at line 87 of file class.ilConditionHandlerGUI.php.

87 : int
88 {
89 if ($this->http->wrapper()->query()->has('condition_id')) {
90 return $this->http->wrapper()->query()->retrieve(
91 'condition_id',
92 $this->refinery->kindlyTo()->int()
93 );
94 }
95 return 0;
96 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ initConditionsIdsFromPost()

ilConditionHandlerGUI::initConditionsIdsFromPost ( )
protected

Definition at line 98 of file class.ilConditionHandlerGUI.php.

98 : SplFixedArray
99 {
100 if ($this->http->wrapper()->post()->has('conditions')) {
101 return SplFixedArray::fromArray(
102 $this->http->wrapper()->post()->retrieve(
103 'conditions',
104 $this->refinery->kindlyTo()->listOf(
105 $this->refinery->kindlyTo()->int()
106 )
107 )
108 );
109 }
110 return new SplFixedArray(0);
111 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ initFormCondition()

ilConditionHandlerGUI::initFormCondition ( int  $a_source_id,
int  $a_condition_id = 0,
string  $a_mode = 'add' 
)
private

Definition at line 714 of file class.ilConditionHandlerGUI.php.

719 $trigger_obj_id = ilObject::_lookupObjId($a_source_id);
720 $trigger_type = ilObject::_lookupType($trigger_obj_id);
721
722 $condition = ilConditionHandler::_getCondition($a_condition_id);
723 $form = new ilPropertyFormGUI();
724 $this->ctrl->setParameter($this, 'source_id', $a_source_id);
725 $form->setFormAction($this->ctrl->getFormAction($this));
726
727 $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source"));
728 $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id)));
729 $form->addItem($info_source);
730
731 $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target"));
732 $info_target->setValue($this->getTargetTitle());
733 $form->addItem($info_target);
734
735 $obl = new ilHiddenInputGUI('obligatory');
736 if ($a_condition_id) {
737 $obl->setValue((string) (bool) $condition['obligatory']);
738 } else {
739 $obl->setValue("1");
740 }
741 $form->addItem($obl);
742
743 $sel = new ilSelectInputGUI($this->lng->txt('condition'), 'operator');
745 $operators = [];
746 if ($a_mode === 'add') {
747 $operators[''] = $this->lng->txt('select_one');
748 }
749 foreach ($ch_obj->getOperatorsByTriggerType($trigger_type) as $operator) {
750 $operators[$operator] = $this->lng->txt('condition_' . $operator);
751 }
752 $sel->setValue($condition['operator'] ?? '');
753 $sel->setOptions($operators);
754 $sel->setRequired(true);
755 $form->addItem($sel);
756
758 $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'), 'ref_handling');
759 $rad_opt->setValue((string) ($condition['ref_handling'] ?? ilConditionHandler::SHARED_CONDITIONS));
760
761 $opt2 = new ilRadioOption(
762 $this->lng->txt('cond_ref_shared'),
763 (string) ilConditionHandler::SHARED_CONDITIONS
764 );
765 $rad_opt->addOption($opt2);
766
767 $opt1 = new ilRadioOption(
768 $this->lng->txt('cond_ref_unique'),
770 );
771 $rad_opt->addOption($opt1);
772
773 $form->addItem($rad_opt);
774 }
775
776 // Additional settings for SCO's
777 if ($trigger_type === 'sahs') {
778 $this->lng->loadLanguageModule('trac');
779
780 $cus = new ilCheckboxGroupInputGUI($this->lng->txt('trac_sahs_relevant_items'), 'item_ids');
781 $cus->setInfo($this->lng->txt('trac_lp_determination_info_sco'));
782 $cus->setRequired(true);
783
784 $olp = ilObjectLP::getInstance($trigger_obj_id);
785 $collection = $olp->getCollectionInstance();
786 $checked = [];
787 if ($collection) {
788 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
789 $sco = new ilCheckboxOption($sahs_item['title'], (string) $item_id);
790 if ($collection->isAssignedEntry($item_id)) {
791 $checked[] = $item_id;
792 }
793 $cus->addOption($sco);
794 }
795 }
796 $cus->setValue($checked);
797 $form->addItem($cus);
798 }
799 switch ($a_mode) {
800 case 'edit':
801 $form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg'));
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'));
805 break;
806
807 case 'add':
808 $form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg'));
809 $form->setTitle($this->lng->txt('add_condition'));
810 $form->addCommandButton('assign', $this->lng->txt('save'));
811 $form->addCommandButton('selector', $this->lng->txt('back'));
812 break;
813 }
814 return $form;
815 }
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...
getOperatorsByTriggerType(string $a_type)
static _isReferenceHandlingOptional(string $a_type)
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 _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.

◆ initItemIdsFromPost()

ilConditionHandlerGUI::initItemIdsFromPost ( )
protected

Definition at line 113 of file class.ilConditionHandlerGUI.php.

113 : SplFixedArray
114 {
115 if ($this->http->wrapper()->post()->has('item_ids')) {
116 return SplFixedArray::fromArray(
117 $this->http->wrapper()->post()->retrieve(
118 'item_ids',
119 $this->refinery->kindlyTo()->listOf(
120 $this->refinery->kindlyTo()->int()
121 )
122 )
123 );
124 }
125 return new SplFixedArray(0);
126 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ initListModeFromPost()

ilConditionHandlerGUI::initListModeFromPost ( )
protected

Definition at line 143 of file class.ilConditionHandlerGUI.php.

143 : string
144 {
145 return $this->http->wrapper()->post()->retrieve(
146 'list_mode',
147 $this->refinery->byTrying([
148 $this->refinery->kindlyTo()->string(),
149 $this->refinery->always(self::LIST_MODE_UNDEFINED)
150 ])
151 );
152 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by listConditions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initObligatoryItemsFromPost()

ilConditionHandlerGUI::initObligatoryItemsFromPost ( )
protected

Definition at line 128 of file class.ilConditionHandlerGUI.php.

128 : SplFixedArray
129 {
130 if ($this->http->wrapper()->post()->has('obl')) {
131 return SplFixedArray::fromArray(
132 $this->http->wrapper()->post()->retrieve(
133 'obl',
134 $this->refinery->kindlyTo()->listOf(
135 $this->refinery->kindlyTo()->int()
136 )
137 )
138 );
139 }
140 return new SplFixedArray(0);
141 }

References ILIAS\FileDelivery\http().

Referenced by saveObligatoryList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSourceIdFromQuery()

ilConditionHandlerGUI::initSourceIdFromQuery ( )
protected

Definition at line 154 of file class.ilConditionHandlerGUI.php.

154 : int
155 {
156 if ($this->http->wrapper()->query()->has('source_id')) {
157 return $this->http->wrapper()->query()->retrieve(
158 'source_id',
159 $this->refinery->kindlyTo()->int()
160 );
161 }
162 return 0;
163 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ isTargetReferenced()

ilConditionHandlerGUI::isTargetReferenced ( )

Check if target has refernce id.

Definition at line 271 of file class.ilConditionHandlerGUI.php.

271 : bool
272 {
273 return (bool) $this->getTargetRefId();
274 }

References getTargetRefId().

+ Here is the call graph for this function:

◆ listConditions()

ilConditionHandlerGUI::listConditions ( )
protected

Definition at line 281 of file class.ilConditionHandlerGUI.php.

281 : void
282 {
283 // check if parent deals with conditions
284 if (
285 $this->getTargetRefId() > 0 &&
286 $this->conditionUtil->isUnderParentControl($this->getTargetRefId())
287 ) {
288 $this->tpl->setOnScreenMessage('info', $this->lng->txt("cond_under_parent_control"));
289 return;
290 }
291
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');
294
296 $this->getTargetRefId(),
297 $this->getTargetId(),
298 $this->getTargetType()
299 );
300 $list_mode = $this->initListModeFromPost();
301 if (count($optional_conditions)) {
302 if ($list_mode === self::LIST_MODE_UNDEFINED) {
303 $list_mode = self::LIST_MODE_SUBSET;
304 }
305 } elseif ($list_mode === self::LIST_MODE_UNDEFINED) {
306 $list_mode = self::LIST_MODE_ALL;
307 }
308
309 // Show form only if conditions are availabe
311 $this->getTargetRefId(),
312 $this->getTargetId(),
313 $this->getTargetType()
314 ))
315 ) {
316 $form = $this->showObligatoryForm($list_mode);
317 if ($form instanceof ilPropertyFormGUI) {
318 $this->tpl->setVariable('TABLE_SETTINGS', $form->getHTML());
319 }
320 }
321
322 $table = new ilConditionHandlerTableGUI($this, 'listConditions', $list_mode !== self::LIST_MODE_ALL);
323 $table->setConditions(
325 $this->getTargetRefId(),
326 $this->getTargetId(),
327 $this->getTargetType()
328 )
329 );
330
331 $h = $table->getHTML();
332 $this->tpl->setVariable('TABLE_CONDITIONS', $h);
333 }
showObligatoryForm(string $list_mode=self::LIST_MODE_ALL)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPersistedOptionalConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')

References ilConditionHandler\_getPersistedConditionsOfTarget(), ilConditionHandler\getPersistedOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), initListModeFromPost(), LIST_MODE_ALL, LIST_MODE_SUBSET, ILIAS\Repository\lng(), showObligatoryForm(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ saveObligatoryList()

ilConditionHandlerGUI::saveObligatoryList ( )
protected

Definition at line 388 of file class.ilConditionHandlerGUI.php.

388 : void
389 {
391 $this->getTargetRefId(),
392 $this->getTargetId(),
393 $this->getTargetType()
394 );
395
396 $obligatory_ids = $this->initObligatoryItemsFromPost();
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');
400 }
401
402 foreach ($all_conditions as $item) {
403 $status = false;
404 if (in_array($item['condition_id'], $obligatory_ids->toArray(), true)) {
405 $status = true;
406 }
407 ilConditionHandler::updateObligatory($item["condition_id"], $status);
408 }
409
410 // re-calculate
412 $this->getTargetRefId(),
413 $this->getTargetId(),
414 $this->getTargetType(),
415 true
416 );
417
418 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
419 $this->ctrl->redirect($this, 'listConditions');
420 }
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)

References ilConditionHandler\_getPersistedConditionsOfTarget(), ilConditionHandler\calculatePersistedRequiredTriggers(), ILIAS\Repository\ctrl(), getTargetId(), getTargetRefId(), getTargetType(), initObligatoryItemsFromPost(), ILIAS\Repository\lng(), and ilConditionHandler\updateObligatory().

+ Here is the call graph for this function:

◆ saveObligatorySettings()

ilConditionHandlerGUI::saveObligatorySettings ( )
protected

Definition at line 335 of file class.ilConditionHandlerGUI.php.

335 : void
336 {
337 $form = $this->showObligatoryForm();
338 if ($form !== null && $form->checkInput()) {
339 $old_mode = $form->getInput("old_list_mode");
340 switch ($form->getInput("list_mode")) {
341 case "all":
342 if ($old_mode !== "all") {
344 $this->getTargetRefId(),
345 $this->getTargetId(),
346 $this->getTargetType()
347 );
348 // Set all optional conditions to obligatory
349 foreach ($optional_conditions as $item) {
350 ilConditionHandler::updateObligatory($item["condition_id"], true);
351 }
352 }
353 break;
354
355 case "subset":
356 $num_req = $form->getInput('required');
357 if ($old_mode !== "subset") {
359 $this->getTargetRefId(),
360 $this->getTargetId(),
361 $this->getTargetType()
362 );
363 foreach ($all_conditions as $item) {
364 ilConditionHandler::updateObligatory($item["condition_id"], false);
365 }
366 }
368 $this->getTargetRefId(),
369 $this->getTargetId(),
370 (int) $num_req
371 );
372 break;
373 }
374
375 $cond = new ilConditionHandler();
376 $cond->setTargetRefId($this->getTargetRefId());
377 $cond->updateHiddenStatus((bool) $form->getInput('hidden'));
378
379 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
380 $this->ctrl->redirect($this, 'listConditions');
381 }
382
383 $form->setValuesByPost();
384 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
385 $this->tpl->setContent($form->getHTML());
386 }
static saveNumberOfRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, int $a_num)

References ilConditionHandler\_getPersistedConditionsOfTarget(), ILIAS\Repository\ctrl(), ilConditionHandler\getPersistedOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), ILIAS\Repository\lng(), ilConditionHandler\saveNumberOfRequiredTriggers(), showObligatoryForm(), and ilConditionHandler\updateObligatory().

+ Here is the call graph for this function:

◆ selector()

ilConditionHandlerGUI::selector ( )

Definition at line 600 of file class.ilConditionHandlerGUI.php.

600 : void
601 {
602 $this->tpl->setOnScreenMessage('info', $this->lng->txt("condition_select_object"));
603
604 $exp = new ilConditionSelector($this, "selector");
605 $exp->setTypeWhiteList(array_merge(
606 $this->getConditionHandler()->getTriggerTypes(),
607 array("root", "cat", "grp", "fold", "crs", "prg")
608 ));
609 //setRefId have to be after setTypeWhiteList!
610 $exp->setRefId($this->getTargetRefId());
611 $exp->setClickableTypes($this->getConditionHandler()->getTriggerTypes());
612
613 if (!$exp->handleCommand()) {
614 $this->tpl->setContent($exp->getHTML());
615 }
616 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setAutomaticValidation()

ilConditionHandlerGUI::setAutomaticValidation ( bool  $a_status)

Definition at line 223 of file class.ilConditionHandlerGUI.php.

223 : void
224 {
225 $this->automatic_validation = $a_status;
226 }

◆ setBackButtons()

ilConditionHandlerGUI::setBackButtons ( array  $a_btn_arr)

Definition at line 188 of file class.ilConditionHandlerGUI.php.

188 : void
189 {
190 ilSession::set('precon_btn', $a_btn_arr);
191 }
static set(string $a_var, $a_val)
Set a value.

References ilSession\set().

+ Here is the call graph for this function:

◆ setTargetId()

ilConditionHandlerGUI::setTargetId ( int  $a_target_id)

Definition at line 233 of file class.ilConditionHandlerGUI.php.

233 : void
234 {
235 $this->target_id = $a_target_id;
236 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTargetRefId()

ilConditionHandlerGUI::setTargetRefId ( int  $a_target_ref_id)

Definition at line 243 of file class.ilConditionHandlerGUI.php.

243 : void
244 {
245 $this->target_ref_id = $a_target_ref_id;
246 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTargetTitle()

ilConditionHandlerGUI::setTargetTitle ( string  $a_target_title)

Definition at line 263 of file class.ilConditionHandlerGUI.php.

263 : void
264 {
265 $this->target_title = $a_target_title;
266 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTargetType()

ilConditionHandlerGUI::setTargetType ( string  $a_target_type)

Definition at line 253 of file class.ilConditionHandlerGUI.php.

253 : void
254 {
255 $this->target_type = $a_target_type;
256 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ showObligatoryForm()

ilConditionHandlerGUI::showObligatoryForm ( string  $list_mode = self::LIST_MODE_ALL)
protected

Definition at line 422 of file class.ilConditionHandlerGUI.php.

425 if (!$this->objectDefinition->isRBACObject($this->getTargetType())) {
426 return null;
427 }
428
430 $form = new ilPropertyFormGUI();
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'));
434
435 $hide = new ilCheckboxInputGUI($this->lng->txt('rbac_precondition_hide'), 'hidden');
437 $hide->setValue("1");
438 $hide->setInfo($this->lng->txt('rbac_precondition_hide_info'));
439 $form->addItem($hide);
440
441 $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
442 $form->addItem($mode);
443 $mode->setValue($list_mode);
444
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);
448
449 if (count($all) > 1) {
450 $min = 1;
451 $max = count($all) - 1;
452
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);
456
457 $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
458 $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
459
461 $this->getTargetRefId(),
462 $this->getTargetId()
463 );
464 $obl->setValue($num_required > 0 ? (string) $num_required : null);
465 $obl->setRequired(true);
466 $obl->setSize(1);
467 $obl->setMinValue($min);
468 $obl->setMaxValue($max);
469 $msubset->addSubItem($obl);
470 }
471
472 $old_mode = new ilHiddenInputGUI("old_list_mode");
473 $old_mode->setValue($list_mode);
474 $form->addItem($old_mode);
475
476 return $form;
477 }
This class represents a checkbox property in a property form.
static lookupObligatoryConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id)
This class represents a number property in a property form.

Referenced by listConditions(), and saveObligatorySettings().

+ Here is the caller graph for this function:

◆ translateOperator()

static ilConditionHandlerGUI::translateOperator ( int  $a_obj_id,
string  $a_operator 
)
static

Definition at line 165 of file class.ilConditionHandlerGUI.php.

165 : string
166 {
167 global $DIC;
168
169 $lng = $DIC->language();
170 switch ($a_operator) {
172 $lng->loadLanguageModule('trac');
173
174 $obj_settings = new ilLPObjSettings($a_obj_id);
175 return ilLPObjSettings::_mode2Text($obj_settings->getMode());
176
177 default:
178 $lng->loadLanguageModule('rbac');
179 return $lng->txt('condition_' . $a_operator);
180 }
181 }
static _mode2Text(int $a_mode)
loadLanguageModule(string $a_module)
Load language module.
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...

References $DIC, $lng, ilLPObjSettings\_mode2Text(), ilLanguage\loadLanguageModule(), ilConditionHandler\OPERATOR_LP, and ilLanguage\txt().

Referenced by ilObjectListGUI\parseConditions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCondition()

ilConditionHandlerGUI::updateCondition ( )

Definition at line 496 of file class.ilConditionHandlerGUI.php.

496 : void
497 {
498 $condition_id = $this->initConditionIdFromQuery();
499 if (!$condition_id) {
500 $this->tpl->setOnScreenMessage('failure', "Missing id: condition_id");
501 $this->listConditions();
502 return;
503 }
504 // Update condition
505 $condition_handler = new ilConditionHandler();
506 $condition = ilConditionHandler::_getCondition($condition_id);
507
508 $form = $this->initFormCondition(
509 $condition['trigger_ref_id'],
510 $condition_id,
511 'edit'
512 );
513
514 if (!$form->checkInput()) {
515 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
516 $this->edit($form);
517 return;
518 }
519
520 $condition_handler->setOperator((string) $form->getInput('operator'));
521 $condition_handler->setObligatory((bool) $form->getInput('obligatory'));
522 $condition_handler->setTargetRefId($this->getTargetRefId());
523 $condition_handler->setValue('');
524 switch ($this->getTargetType()) {
525 case 'st':
526 $condition_handler->setReferenceHandlingType((int) $form->getInput('ref_handling'));
527 break;
528
529 default:
530 $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
531 break;
532 }
533 $condition_handler->updateCondition($condition['id']);
534
535 // Update relevant sco's
536 if ($condition['trigger_type'] === 'sahs') {
537 $olp = ilObjectLP::getInstance($condition['trigger_obj_id']);
538 $collection = $olp->getCollectionInstance();
539 if ($collection) {
540 $collection->delete();
541 }
542 $item_ids = $this->initItemIdsFromPost();
543 if (count($item_ids)) { // #12901
544 $collection->activateEntries($item_ids->toArray());
545 }
546 ilLPStatusWrapper::_refreshStatus($condition['trigger_obj_id']);
547 }
548 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
549 $this->ctrl->redirect($this, 'listConditions');
550 }
edit(?ilPropertyFormGUI $form=null)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)

References ilConditionHandler\_getCondition(), ilLPStatusWrapper\_refreshStatus(), ILIAS\Repository\ctrl(), ilObjectLP\getInstance(), ILIAS\Repository\lng(), and ilConditionHandler\UNIQUE_CONDITIONS.

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilConditionHandlerGUI::$access
protected

Definition at line 42 of file class.ilConditionHandlerGUI.php.

◆ $automatic_validation

bool ilConditionHandlerGUI::$automatic_validation = true
protected

Definition at line 56 of file class.ilConditionHandlerGUI.php.

Referenced by getAutomaticValidation().

◆ $ch_obj

ilConditionHandler ilConditionHandlerGUI::$ch_obj
protected

Definition at line 49 of file class.ilConditionHandlerGUI.php.

Referenced by getConditionHandler().

◆ $conditionUtil

ilConditionUtil ilConditionHandlerGUI::$conditionUtil
protected

Definition at line 44 of file class.ilConditionHandlerGUI.php.

◆ $ctrl

ilCtrl ilConditionHandlerGUI::$ctrl
protected

Definition at line 38 of file class.ilConditionHandlerGUI.php.

◆ $http

GlobalHttpState ilConditionHandlerGUI::$http
private

Definition at line 46 of file class.ilConditionHandlerGUI.php.

◆ $lng

ilLanguage ilConditionHandlerGUI::$lng
protected

Definition at line 39 of file class.ilConditionHandlerGUI.php.

Referenced by translateOperator().

◆ $objectDefinition

ilObjectDefinition ilConditionHandlerGUI::$objectDefinition
protected

Definition at line 45 of file class.ilConditionHandlerGUI.php.

◆ $refinery

Factory ilConditionHandlerGUI::$refinery
private

Definition at line 47 of file class.ilConditionHandlerGUI.php.

◆ $target_id

int ilConditionHandlerGUI::$target_id = 0
protected

Definition at line 51 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetId().

◆ $target_obj

ilObject ilConditionHandlerGUI::$target_obj = null
protected

Definition at line 50 of file class.ilConditionHandlerGUI.php.

Referenced by __construct().

◆ $target_ref_id

int ilConditionHandlerGUI::$target_ref_id = 0
protected

Definition at line 54 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetRefId().

◆ $target_title

string ilConditionHandlerGUI::$target_title = ''
protected

Definition at line 53 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetTitle().

◆ $target_type

string ilConditionHandlerGUI::$target_type = ''
protected

Definition at line 52 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetType().

◆ $toolbar

ilToolbarGUI ilConditionHandlerGUI::$toolbar
protected

Definition at line 43 of file class.ilConditionHandlerGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilConditionHandlerGUI::$tpl
protected

Definition at line 40 of file class.ilConditionHandlerGUI.php.

◆ $tree

ilTree ilConditionHandlerGUI::$tree
protected

Definition at line 41 of file class.ilConditionHandlerGUI.php.

◆ LIST_MODE_ALL

const ilConditionHandlerGUI::LIST_MODE_ALL = 'all'
private

Definition at line 35 of file class.ilConditionHandlerGUI.php.

Referenced by listConditions().

◆ LIST_MODE_SUBSET

const ilConditionHandlerGUI::LIST_MODE_SUBSET = 'subset'
private

Definition at line 36 of file class.ilConditionHandlerGUI.php.

Referenced by listConditions().

◆ LIST_MODE_UNDEFINED

const ilConditionHandlerGUI::LIST_MODE_UNDEFINED = 'undefined'
private

Definition at line 34 of file class.ilConditionHandlerGUI.php.


The documentation for this class was generated from the following file: