ILIAS  release_8 Revision v8.24
ilConditionHandler Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilConditionHandler:

Public Member Functions

 __construct ()
 
 setReferenceHandlingType (int $a_type)
 
 getReferenceHandlingType ()
 
 setErrorMessage (string $a_msg)
 
 getErrorMessage ()
 
 setTargetRefId (int $a_target_ref_id)
 
 getTargetRefId ()
 
 setTargetObjId (int $a_target_obj_id)
 
 getTargetObjId ()
 
 setTargetType (string $a_target_type)
 set target object type More...
 
 getTargetType ()
 get target obj type More...
 
 setTriggerRefId (int $a_trigger_ref_id)
 
 getTriggerRefId ()
 
 setTriggerObjId (int $a_trigger_obj_id)
 
 getTriggerObjId ()
 
 setTriggerType (string $a_trigger_type)
 set trigger object type More...
 
 getTriggerType ()
 get trigger obj type More...
 
 setOperator (string $a_operator)
 
 getOperator ()
 
 setValue (string $a_value)
 
 getValue ()
 
 setObligatory (bool $a_obl)
 Set obligatory status. More...
 
 getObligatory ()
 Get obligatory status. More...
 
 setHiddenStatus (bool $a_status)
 
 getHiddenStatus ()
 
 enableAutomaticValidation (bool $a_validate=true)
 
 getTriggerTypes ()
 
 getOperatorsByTriggerType (string $a_type)
 
 storeCondition ()
 store new condition in database More...
 
 checkExists ()
 
 updateCondition (int $a_id)
 
 updateHiddenStatus (bool $a_status)
 
 delete (int $a_ref_id)
 delete all trigger and target entries This method is called from ilObject::delete() if an object os removed from trash More...
 
 deleteByObjId (int $a_obj_id)
 delete all trigger and target entries This method is called from ilObject::delete() if an object is removed from trash More...
 
 deleteCondition (int $a_id)
 

Static Public Member Functions

static resetCache ()
 
static _isReferenceHandlingOptional (string $a_type)
 
static lookupPersistedHiddenStatusByTarget (int $a_target_ref_id)
 
static _adjustMovedObjectConditions (int $a_ref_id)
 In the moment it is not allowed to create preconditions on objects that are located outside of a course. More...
 
static updateObligatory (int $a_id, bool $a_status)
 Toggle condition obligatory status. More...
 
static getNumberOfConditionsOfTrigger (string $a_trigger_obj_type, int $a_trigger_id)
 get all conditions of trigger object More...
 
static _getPersistedConditionsOfTrigger (string $a_trigger_obj_type, int $a_trigger_id)
 Get all persisted conditions of trigger object Note: This only gets persisted conditions NOT (dynamic) conditions send by the parent container logic. More...
 
static _getPersistedConditionsOfTarget (int $a_target_ref_id, int $a_target_obj_id, string $a_target_type="")
 get all persisted conditions of target object More...
 
static preloadPersistedConditionsForTargetRecords (string $a_type, array $a_obj_ids)
 
static _getCondition (int $a_id)
 
static _checkCondition (array $condition, int $a_usr_id=0)
 checks wether a single condition is fulfilled every trigger object type must implement a static method _checkCondition($a_operator, $a_value) More...
 
static getEffectiveOptionalConditionsOfTarget (int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
 
static getPersistedOptionalConditionsOfTarget (int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
 
static lookupObligatoryConditionsOfTarget (int $a_target_ref_id, int $a_target_obj_id)
 
static calculateEffectiveRequiredTriggers (int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='')
 
static calculatePersistedRequiredTriggers (int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='', bool $a_force_update=false)
 
static saveNumberOfRequiredTriggers (int $a_target_ref_id, int $a_target_obj_id, int $a_num)
 
static _checkAllConditionsOfTarget (int $a_target_ref_id, int $a_target_id, string $a_target_type="", int $a_usr_id=0)
 checks wether all conditions of a target object are fulfilled More...
 
static cloneDependencies (int $a_src_ref_id, int $a_target_ref_id, int $a_copy_id)
 

Data Fields

const OPERATOR_PASSED = 'passed'
 
const OPERATOR_FINISHED = 'finished'
 
const OPERATOR_NOT_FINISHED = 'not_finished'
 
const OPERATOR_NOT_MEMBER = 'not_member'
 
const OPERATOR_FAILED = 'failed'
 
const OPERATOR_LP = 'learning_progress'
 
const OPERATOR_ACCREDITED_OR_PASSED = 'accredited_or_passed'
 
const UNIQUE_CONDITIONS = 1
 
const SHARED_CONDITIONS = 0
 

Static Public Attributes

static array $cond_for_target_cache = array()
 
static array $cond_target_rows = array()
 

Protected Member Functions

 validate ()
 
 checkCircle (int $a_ref_id, int $a_obj_id)
 

Static Protected Member Functions

static _getDistinctTargetRefIds ()
 
static _deleteTargetConditionsByRefId (int $a_target_ref_id)
 Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on e.g chapters are not handled. More...
 

Protected Attributes

ilDBInterface $db
 
ilLanguage $lng
 
ilObjectDefinition $objDefinition
 
ilTree $tree
 
ilLogger $logger
 
string $error_message = ''
 
int $target_obj_id = 0
 
int $target_ref_id = 0
 
string $target_type = ''
 
int $trigger_obj_id = 0
 
int $trigger_ref_id = 0
 
string $trigger_type = ''
 
string $operator = ''
 
string $value = ''
 
bool $validation = true
 

Private Attributes

int $condition_reference_type = 0
 
bool $circle = false
 
bool $obligatory = true
 
bool $hidden_status = false
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning INTERNAL CLASS: Please do not use in consumer code. Handles conditions for accesses to different ILIAS objects A condition consists of four elements:

  • a trigger object, e.g. a test or a survey question
  • an operator, e.g. "=", "<", "passed"
  • an (optional) value, e.g. "5"
  • a target object, e.g. a learning module If a condition is fulfilled for a certain user, (s)he may access the target object. This first implementation handles only one access type per object, which is usually "read" access. A possible future extension may implement different access types. The condition data is stored in the database table "condition" (Note: This table must not be accessed directly from other classes. The data should be accessed via the interface of class ilCondition.) cond_id INT condition id trigger_obj_type VARCHAR(10) "crs" | "tst" | ... trigger_ref_id INT obj id of trigger object (only exception where this is 0 are currently (5.3) course groupings this might be refactored trigger_obj_id INT obj id of trigger object operator varchar(10 "=", "<", ">", ">=", "<=", "passed", "contains", ... value VARCHAR(10) optional value target_obj_type VARCHAR(10) "lm" | "frm" | "st", "lobj", ... target_obj_id object id of target object target_ref_id reference id of target object Special current targets (5.3)
  • learning objectives: type: "lobj"; obj_id: objective id; ref_id: ref id of course
  • lm chapters: type: "st"; obj_id: chapter id, ref_id: ref id of learning module Trigger objects are always stored with their object id (if a test has been passed by a user, he doesn't need to repeat it in other contexts. But target objects are usually stored with their reference id if available, otherwise, if they are non-referenced objects (e.g. (survey) questions) they are stored with their object id. Stefan Meyer 10-08-2004 In addition we store the ref_id of the trigger object to allow the target object to link to the triggered object. But it's not possible to assign two or more linked (same obj_id) triggered objects to a target object Examples: Learning module 5 may only be accessed, if test 6 has been passed: trigger_obj_type "tst" trigger_id 6 (object id) trigger_ref_id 117 operator "passed" value target_obj_type "lm" target_id 5 (reference id) Survey question 10 should only be presented, if survey question 8 is answered with a value greater than 4. trigger_obj_type "qst" trigger_id 8 (question (instance) object id) trigger_ref_id 117 operator ">" value "4" target_obj_type "lm" target_id 10 (question (instance) object id)
    Author
    Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
    Version
    $Id$

Definition at line 77 of file class.ilConditionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilConditionHandler::__construct ( )

Definition at line 119 of file class.ilConditionHandler.php.

120 {
121 global $DIC;
122
123 $this->db = $DIC->database();
124 $this->lng = $DIC->language();
125 $this->objDefinition = $DIC['objDefinition'];
126 $this->tree = $DIC->repositoryTree();
127 $this->logger = $DIC->logger()->ac();
128 $this->validation = true;
129 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\lng(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ _adjustMovedObjectConditions()

static ilConditionHandler::_adjustMovedObjectConditions ( int  $a_ref_id)
static

In the moment it is not allowed to create preconditions on objects that are located outside of a course.

Therefore, after moving an object: check for parent type 'crs'. if that fails delete preconditions

Todo:
check if something needs to be done here

Definition at line 196 of file class.ilConditionHandler.php.

196 : bool
197 {
198 return true;
199 }

Referenced by ilSoapObjectAdministration\moveObject(), ilContainerGUI\pasteObject(), and ilContainerGUI\performPasteIntoMultipleObjectsObject().

+ Here is the caller graph for this function:

◆ _checkAllConditionsOfTarget()

static ilConditionHandler::_checkAllConditionsOfTarget ( int  $a_target_ref_id,
int  $a_target_id,
string  $a_target_type = "",
int  $a_usr_id = 0 
)
static

checks wether all conditions of a target object are fulfilled

Todo:
check member view passthrough

Definition at line 1011 of file class.ilConditionHandler.php.

1016 : bool {
1017 global $DIC;
1018
1019 $ilUser = $DIC['ilUser'];
1020 $tree = $DIC['tree'];
1021 $logger = $DIC->logger()->ac();
1022
1023 $a_usr_id = $a_usr_id ?: $ilUser->getId();
1024 $conditions = self::_getEffectiveConditionsOfTarget(
1025 $a_target_ref_id,
1026 $a_target_id,
1027 $a_target_type
1028 );
1029 if (!count($conditions)) {
1030 return true;
1031 }
1032
1033 if (ilMemberViewSettings::getInstance()->isActive()) {
1034 return true;
1035 }
1036
1037 // First check obligatory conditions
1038 $optional = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1039 $num_required = self::calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1040 $passed = 0;
1041 foreach ($conditions as $condition) {
1042 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1043 continue;
1044 }
1045 $check = self::_checkCondition($condition, $a_usr_id);
1046
1047 if ($check) {
1048 ++$passed;
1049 } else {
1050 // #0027223 if condition is obligatory => return false
1051 if ($condition['obligatory']) {
1052 return false;
1053 }
1054 }
1055 }
1056 return $passed >= $num_required;
1057 }
$check
Definition: buildRTE.php:81
static calculateEffectiveRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='')
static _checkCondition(array $condition, int $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
static getEffectiveOptionalConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
$ilUser
Definition: imgupload.php:34

Referenced by ilObjContentObject\_checkPreconditionsOfPage(), ilContainerObjectiveGUI\addItemDetails(), ilAccess\doConditionCheck(), ilRepositoryExplorerGUI\getChildsOfNode(), ilRepositoryExplorer\isClickable(), ilRepositoryExplorerGUI\isNodeClickable(), ilRepositoryExplorer\showChilds(), and ilCourseContentGUI\showStartObjects().

+ Here is the caller graph for this function:

◆ _checkCondition()

static ilConditionHandler::_checkCondition ( array  $condition,
int  $a_usr_id = 0 
)
static

checks wether a single condition is fulfilled every trigger object type must implement a static method _checkCondition($a_operator, $a_value)

Definition at line 829 of file class.ilConditionHandler.php.

829 : bool
830 {
831 global $DIC;
832
833 $ilUser = $DIC['ilUser'];
834 $objDefinition = $DIC['objDefinition'];
835 $a_usr_id = $a_usr_id ?: $ilUser->getId();
836
837 // check lp
838 if ($condition['operator'] === self::OPERATOR_LP) {
839 return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
840 }
841 switch ($condition['trigger_type']) {
842 case 'crsg':
844 (int) $condition['trigger_obj_id'],
845 (string) $condition['operator'],
846 (string) $condition['value'],
847 (int) $a_usr_id
848 );
849 }
850 $class = $objDefinition->getClassName($condition['trigger_type']);
851 $location = $objDefinition->getLocation($condition['trigger_type']);
852 $full_class = "ilObj" . $class . "Access";
853 include_once($location . "/class." . $full_class . ".php");
854
855 if (!(is_a($full_class, "ilConditionHandling", true))) {
856 return false;
857 }
858
859 $fullfilled = call_user_func(
860 array($full_class, 'checkCondition'),
861 (int) $condition['trigger_obj_id'],
862 (string) $condition['operator'],
863 (string) $condition['value'],
864 (int) $a_usr_id
865 );
866 return $fullfilled;
867 }
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
ilObjectDefinition $objDefinition
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
static _checkCondition(int $trigger_obj_id, string $operator, $value, int $a_usr_id=0)
getClassName(string $obj_name)

References $DIC, $ilUser, $location, ilObjCourseGrouping\_checkCondition(), ilLPStatus\_hasUserCompleted(), ilObjectDefinition\getClassName(), and ilObjectDefinition\getLocation().

Referenced by ilObjContentObject\_getMissingPreconditionsTopChapter(), and ilObjectListGUI\parseConditions().

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

◆ _deleteTargetConditionsByRefId()

static ilConditionHandler::_deleteTargetConditionsByRefId ( int  $a_target_ref_id)
staticprotected

Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on e.g chapters are not handled.

Definition at line 224 of file class.ilConditionHandler.php.

224 : bool
225 {
226 global $DIC;
227
228 $ilDB = $DIC['ilDB'];
229
230 $query = "DELETE FROM conditions " .
231 "WHERE target_ref_id = " . $ilDB->quote($a_target_ref_id, 'integer') . " " .
232 "AND target_type != 'st' ";
233 $res = $ilDB->manipulate($query);
234 return true;
235 }
$res
Definition: ltiservices.php:69
$query

References $DIC, $ilDB, $query, and $res.

◆ _getCondition()

static ilConditionHandler::_getCondition ( int  $a_id)
static

Definition at line 795 of file class.ilConditionHandler.php.

795 : array
796 {
797 global $DIC;
798
799 $ilDB = $DIC['ilDB'];
800
801 $query = "SELECT * FROM conditions " .
802 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
803
804 $res = $ilDB->query($query);
805 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
806 $tmp_array['id'] = (int) $row->condition_id;
807 $tmp_array['target_ref_id'] = (int) $row->target_ref_id;
808 $tmp_array['target_obj_id'] = (int) $row->target_obj_id;
809 $tmp_array['target_type'] = (string) $row->target_type;
810 $tmp_array['trigger_ref_id'] = (int) $row->trigger_ref_id;
811 $tmp_array['trigger_obj_id'] = (int) $row->trigger_obj_id;
812 $tmp_array['trigger_type'] = (string) $row->trigger_type;
813 $tmp_array['operator'] = (string) $row->operator;
814 $tmp_array['value'] = (string) $row->value;
815 $tmp_array['ref_handling'] = (int) $row->ref_handling;
816 $tmp_array['obligatory'] = (bool) $row->obligatory;
817 $tmp_array['hidden_status'] = (bool) $row->hidden_status;
818 $tmp_array['num_obligatory'] = (int) $row->num_obligatory;
819 return $tmp_array;
820 }
821 return [];
822 }

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilConditionHandlerGUI\askDelete(), ilConditionHandlerGUI\edit(), and ilConditionHandlerGUI\updateCondition().

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

◆ _getDistinctTargetRefIds()

static ilConditionHandler::_getDistinctTargetRefIds ( )
staticprotected
Returns
int[]

Definition at line 204 of file class.ilConditionHandler.php.

204 : array
205 {
206 global $DIC;
207
208 $ilDB = $DIC['ilDB'];
209
210 $query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
211 $res = $ilDB->query($query);
212 $ref_ids = [];
213 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
214 $ref_ids[] = (int) $row->ref;
215 }
216 return $ref_ids;
217 }

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ _getPersistedConditionsOfTarget()

static ilConditionHandler::_getPersistedConditionsOfTarget ( int  $a_target_ref_id,
int  $a_target_obj_id,
string  $a_target_type = "" 
)
static

get all persisted conditions of target object

Returns
array<int, array<string, mixed>>

Definition at line 687 of file class.ilConditionHandler.php.

691 : array {
692 global $DIC;
693
694 $ilDB = $DIC['ilDB'];
695
696 // get type if no type given
697 if ($a_target_type === "") {
698 $a_target_type = ilObject::_lookupType($a_target_obj_id);
699 }
700
701 // check conditions for target cache
702 if (isset(self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
703 $a_target_type])) {
704 return self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
705 $a_target_type];
706 }
707
708 // check rows cache
709 if (isset(self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id])) {
710 $rows = self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id];
711 } else {
712 // query data from db
713 $query = "SELECT * FROM conditions " .
714 "WHERE target_obj_id = " . $ilDB->quote($a_target_obj_id, 'integer') . " " .
715 " AND target_type = " . $ilDB->quote($a_target_type, 'text');
716
717 $res = $ilDB->query($query);
718 $rows = array();
719 while ($row = $ilDB->fetchAssoc($res)) {
720 $item = [];
721 $item['condition_id'] = (int) $row['condition_id'];
722 $item['target_ref_id'] = (int) $row['target_ref_id'];
723 $item['target_obj_id'] = (int) $row['target_obj_id'];
724 $item['trigger_ref_id'] = (int) $row['trigger_ref_id'];
725 $item['trigger_obj_id'] = (int) $row['trigger_obj_id'];
726 $item['target_type'] = (string) $row['target_type'];
727 $item['trigger_type'] = (string) $row['trigger_type'];
728 $item['operator'] = (string) $row['operator'];
729 $item['value'] = (string) $row['value'];
730 $item['ref_handling'] = (int) $row['ref_handling'];
731 $item['obligatory'] = (bool) $row['obligatory'];
732 $item['num_obligatory'] = (int) $row['num_obligatory'];
733 $item['hidden_status'] = (bool) $row['hidden_status'];
734
735 $rows[] = $item;
736 }
737 }
738
739 reset($rows);
740 $conditions = [];
741 foreach ($rows as $row) {
742 if (($row["ref_handling"] == self::UNIQUE_CONDITIONS) && $row["target_ref_id"] != $a_target_ref_id) {
743 continue;
744 }
745
746 $row["id"] = $row["condition_id"];
747 $conditions[] = $row;
748 }
749 // write conditions for target cache
750 self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
751 $a_target_type] = $conditions;
752 return $conditions;
753 }
static _lookupType(int $id, bool $reference=false)
$rows
Definition: xhr_table.php:10

References ilObject\_lookupType().

Referenced by ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), ilObjContentObject\_getMissingPreconditionsTopChapter(), ilConditionHandlerGUI\getConditionsOfTarget(), ilConditionHandlerGUI\listConditions(), ilConditionHandlerGUI\saveObligatoryList(), and ilConditionHandlerGUI\saveObligatorySettings().

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

◆ _getPersistedConditionsOfTrigger()

static ilConditionHandler::_getPersistedConditionsOfTrigger ( string  $a_trigger_obj_type,
int  $a_trigger_id 
)
static

Get all persisted conditions of trigger object Note: This only gets persisted conditions NOT (dynamic) conditions send by the parent container logic.

Returns
array<int, array<string, mixed>>

Definition at line 583 of file class.ilConditionHandler.php.

583 : array
584 {
585 global $DIC;
586
587 $ilDB = $DIC['ilDB'];
588
589 $query = "SELECT * FROM conditions " .
590 "WHERE trigger_obj_id = " . $ilDB->quote($a_trigger_id, 'integer') . " " .
591 " AND trigger_type = " . $ilDB->quote($a_trigger_obj_type, 'text');
592
593 $res = $ilDB->query($query);
594 $conditions = [];
595 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
596 $tmp_array = [];
597 $tmp_array['id'] = (int) $row->condition_id;
598 $tmp_array['target_ref_id'] = (int) $row->target_ref_id;
599 $tmp_array['target_obj_id'] = (int) $row->target_obj_id;
600 $tmp_array['target_type'] = (string) $row->target_type;
601 $tmp_array['trigger_ref_id'] = (int) $row->trigger_ref_id;
602 $tmp_array['trigger_obj_id'] = (int) $row->trigger_obj_id;
603 $tmp_array['trigger_type'] = (string) $row->trigger_type;
604 $tmp_array['operator'] = (string) $row->operator;
605 $tmp_array['value'] = (string) $row->value;
606 $tmp_array['ref_handling'] = (int) $row->ref_handling;
607 $tmp_array['obligatory'] = (bool) $row->obligatory;
608 $tmp_array['hidden_status'] = (bool) $row->hidden_status;
609 $conditions[] = $tmp_array;
610 }
611 return $conditions;
612 }

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), and ilObjCourseGrouping\getAssignedItems().

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

◆ _isReferenceHandlingOptional()

static ilConditionHandler::_isReferenceHandlingOptional ( string  $a_type)
static
Parameters
stringtarget type ILIAS obj type

Definition at line 140 of file class.ilConditionHandler.php.

140 : bool
141 {
142 return $a_type === 'st';
143 }

◆ calculateEffectiveRequiredTriggers()

static ilConditionHandler::calculateEffectiveRequiredTriggers ( int  $a_target_ref_id,
int  $a_target_obj_id,
string  $a_target_obj_type = '' 
)
static

Definition at line 922 of file class.ilConditionHandler.php.

926 : int {
927 global $DIC;
928
929 $ilDB = $DIC['ilDB'];
930
931 // Get all conditions
932 $all = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
933 $opt = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
934
935 $set_obl = 0;
936 if (isset($all[0])) {
937 $set_obl = $all[0]['num_obligatory'];
938 }
939
940 // existing value is valid
941 if ($set_obl > 0 &&
942 $set_obl < count($all) &&
943 $set_obl > (count($all) - count($opt) + 1)) {
944 return $set_obl;
945 }
946
947 if (count($opt)) {
948 $result = count($all) - count($opt) + 1;
949 } else {
950 $result = count($all);
951 }
952 return $result;
953 }

Referenced by ilObjectListGUI\parseConditions().

+ Here is the caller graph for this function:

◆ calculatePersistedRequiredTriggers()

static ilConditionHandler::calculatePersistedRequiredTriggers ( int  $a_target_ref_id,
int  $a_target_obj_id,
string  $a_target_obj_type = '',
bool  $a_force_update = false 
)
static

Definition at line 955 of file class.ilConditionHandler.php.

960 : int {
961 global $DIC;
962
963 $ilDB = $DIC['ilDB'];
964
965 // Get all conditions
966
968 $all = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
969 $opt = self::getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
970
971 $set_obl = 0;
972 if (isset($all[0])) {
973 $set_obl = $all[0]['num_obligatory'];
974 }
975
976 // existing value is valid
977 if ($set_obl > 0 &&
978 $set_obl < count($all) &&
979 $set_obl > (count($all) - count($opt) + 1)) {
980 return $set_obl;
981 }
982
983 if (count($opt)) {
984 $result = count($all) - count($opt) + 1;
985 } else {
986 $result = count($all);
987 }
988 if ($a_force_update) {
989 self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $result);
990 }
991 return $result;
992 }
static getPersistedOptionalConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
static _getPersistedConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_target_type="")
get all persisted conditions of target object
static saveNumberOfRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, int $a_num)

Referenced by ilConditionHandlerGUI\saveObligatoryList().

+ Here is the caller graph for this function:

◆ checkCircle()

ilConditionHandler::checkCircle ( int  $a_ref_id,
int  $a_obj_id 
)
protected

Definition at line 1093 of file class.ilConditionHandler.php.

1093 : bool
1094 {
1095 foreach (self::_getPersistedConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
1096 if ($condition['trigger_obj_id'] == $this->target_obj_id && $condition['operator'] === $this->getOperator()) {
1097 $this->circle = true;
1098 break;
1099 }
1100
1101 $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
1102 }
1103 return $this->circle;
1104 }
checkCircle(int $a_ref_id, int $a_obj_id)

◆ checkExists()

ilConditionHandler::checkExists ( )

Definition at line 485 of file class.ilConditionHandler.php.

485 : bool
486 {
487 $query = "SELECT * FROM conditions " .
488 "WHERE target_ref_id = " . $this->db->quote($this->getTargetRefId(), 'integer') . " " .
489 "AND target_obj_id = " . $this->db->quote($this->getTargetObjId(), 'integer') . " " .
490 "AND trigger_ref_id = " . $this->db->quote($this->getTriggerRefId(), 'integer') . " " .
491 "AND trigger_obj_id = " . $this->db->quote($this->getTriggerObjId(), 'integer') . " " .
492 "AND operator = " . $this->db->quote($this->getOperator(), 'text');
493 $res = $this->db->query($query);
494 return (bool) $res->numRows();
495 }

References $query, $res, getOperator(), getTargetObjId(), getTargetRefId(), getTriggerObjId(), and getTriggerRefId().

+ Here is the call graph for this function:

◆ cloneDependencies()

static ilConditionHandler::cloneDependencies ( int  $a_src_ref_id,
int  $a_target_ref_id,
int  $a_copy_id 
)
static

Definition at line 1106 of file class.ilConditionHandler.php.

1106 : void
1107 {
1108 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1109 $mappings = $cwo->getMappings();
1110
1111 $valid = 0;
1113 $a_src_ref_id,
1114 ilObject::_lookupObjId($a_src_ref_id)
1115 );
1116 foreach ($conditions as $con) {
1117 if ($mappings[$con['trigger_ref_id']] ?? false) {
1118 $newCondition = new ilConditionHandler();
1119
1120 $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1121 $target_typ = ilObject::_lookupType($target_obj);
1122
1123 $newCondition->setTargetRefId($a_target_ref_id);
1124 $newCondition->setTargetObjId($target_obj);
1125 $newCondition->setTargetType($target_typ);
1126
1127 $trigger_ref = $mappings[$con['trigger_ref_id']];
1128 $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1129 $trigger_typ = ilObject::_lookupType($trigger_obj);
1130
1131 $newCondition->setTriggerRefId($trigger_ref);
1132 $newCondition->setTriggerObjId($trigger_obj);
1133 $newCondition->setTriggerType($trigger_typ);
1134 $newCondition->setOperator($con['operator']);
1135 $newCondition->setValue($con['value']);
1136 $newCondition->setReferenceHandlingType($con['ref_handling']);
1137 $newCondition->setObligatory($con['obligatory']);
1138
1139 // :TODO: not sure about this
1140 $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1141
1142 if ($newCondition->storeCondition()) {
1143 $valid++;
1144
1145 //Copy num_obligatory, to be checked below
1147 $a_target_ref_id,
1148 $target_obj,
1149 $con['num_obligatory']
1150 );
1151 }
1152 }
1153 }
1154 if ($valid) {
1155 $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1156
1157 // num_obligatory
1159 $a_target_ref_id,
1160 $tgt_obj_id,
1161 ilObject::_lookupType($tgt_obj_id),
1162 true
1163 );
1164 }
1165 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static calculatePersistedRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='', bool $a_force_update=false)
static _getInstance(int $a_copy_id)
static _lookupObjId(int $ref_id)
$valid

References $valid, ilCopyWizardOptions\_getInstance(), ilObject\_lookupObjId(), and ilObject\_lookupType().

Referenced by ilObject\cloneDependencies().

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

◆ delete()

ilConditionHandler::delete ( int  $a_ref_id)

delete all trigger and target entries This method is called from ilObject::delete() if an object os removed from trash

Definition at line 535 of file class.ilConditionHandler.php.

535 : void
536 {
537 $query = "DELETE FROM conditions WHERE " .
538 "target_ref_id = " . $this->db->quote($a_ref_id, 'integer') . " " .
539 "OR trigger_ref_id = " . $this->db->quote($a_ref_id, 'integer');
540 $res = $this->db->manipulate($query);
541 }

References $query, and $res.

◆ deleteByObjId()

ilConditionHandler::deleteByObjId ( int  $a_obj_id)

delete all trigger and target entries This method is called from ilObject::delete() if an object is removed from trash

Definition at line 547 of file class.ilConditionHandler.php.

547 : void
548 {
549 $query = "DELETE FROM conditions WHERE " .
550 "target_obj_id = " . $this->db->quote($a_obj_id, 'integer') . " " .
551 "OR trigger_obj_id = " . $this->db->quote($a_obj_id, 'integer');
552 $res = $this->db->manipulate($query);
553 }

References $query, and $res.

◆ deleteCondition()

ilConditionHandler::deleteCondition ( int  $a_id)

Definition at line 555 of file class.ilConditionHandler.php.

555 : void
556 {
557 $query = "DELETE FROM conditions " .
558 "WHERE condition_id = " . $this->db->quote($a_id, 'integer');
559 $res = $this->db->manipulate($query);
560 }

References $query, and $res.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ enableAutomaticValidation()

ilConditionHandler::enableAutomaticValidation ( bool  $a_validate = true)

Definition at line 375 of file class.ilConditionHandler.php.

375 : void
376 {
377 $this->validation = $a_validate;
378 }

◆ getEffectiveOptionalConditionsOfTarget()

static ilConditionHandler::getEffectiveOptionalConditionsOfTarget ( int  $a_target_ref_id,
int  $a_target_obj_id,
string  $a_obj_type = '' 
)
static

Definition at line 869 of file class.ilConditionHandler.php.

873 : array {
874 $conditions = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
875
876 $opt = array();
877 foreach ($conditions as $con) {
878 if ($con['obligatory']) {
879 continue;
880 }
881 $opt[] = $con;
882 }
883 return $opt;
884 }

Referenced by ilObjectListGUI\parseConditions().

+ Here is the caller graph for this function:

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

Definition at line 252 of file class.ilConditionHandler.php.

252 : string
253 {
255 }

References $error_message.

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

Definition at line 370 of file class.ilConditionHandler.php.

370 : bool
371 {
373 }

References $hidden_status.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ getNumberOfConditionsOfTrigger()

static ilConditionHandler::getNumberOfConditionsOfTrigger ( string  $a_trigger_obj_type,
int  $a_trigger_id 
)
static

get all conditions of trigger object

Definition at line 565 of file class.ilConditionHandler.php.

565 : int
566 {
567 global $DIC;
568 $db = $DIC->database();
569
570 $query = 'select count(*) num from conditions ' .
571 'where trigger_obj_id = ' . $db->quote($a_trigger_id, ilDBConstants::T_INTEGER) . ' ' .
572 'and trigger_type = ' . $db->quote($a_trigger_obj_type, ilDBConstants::T_TEXT);
573 $res = $db->query($query);
574 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
575 return (int) $row->num;
576 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.

References $db, $DIC, $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilDBInterface\query(), ilDBInterface\quote(), ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Referenced by ilScormLP\checkSCORMPreconditions().

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

◆ getObligatory()

ilConditionHandler::getObligatory ( )

Get obligatory status.

Definition at line 360 of file class.ilConditionHandler.php.

360 : bool
361 {
362 return $this->obligatory;
363 }

References $obligatory.

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getOperator()

ilConditionHandler::getOperator ( )

Definition at line 334 of file class.ilConditionHandler.php.

334 : string
335 {
336 return $this->operator;
337 }

References $operator.

Referenced by checkExists(), storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getOperatorsByTriggerType()

ilConditionHandler::getOperatorsByTriggerType ( string  $a_type)
Returns
string[]

Definition at line 417 of file class.ilConditionHandler.php.

417 : array
418 {
419 global $DIC;
420
421 $objDefinition = $DIC['objDefinition'];
422
423 if ($a_type === 'crsg') {
424 return ['not_member'];
425 }
426
427 $class = $objDefinition->getClassName($a_type);
429 $full_class = "ilObj" . $class . "Access";
430 include_once($location . "/class." . $full_class . ".php");
431 $reflection = new ReflectionClass($full_class);
432 if ($reflection->implementsInterface('ilConditionHandling')) {
433 $operators = call_user_func(
434 array($full_class, 'getConditionOperators'),
435 $a_type
436 );
437 } else {
438 $operators = [];
439 }
440
441 // Add operator lp
443 // only if object type has lp
444
446 array_unshift($operators, self::OPERATOR_LP);
447 }
448 }
449 return $operators;
450 }
static isSupportedObjectType(string $type)

References $DIC, $location, $objDefinition, ilObjUserTracking\_enabledLearningProgress(), ilObjectDefinition\getClassName(), ilObjectDefinition\getLocation(), and ilObjectLP\isSupportedObjectType().

Referenced by getTriggerTypes().

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

◆ getPersistedOptionalConditionsOfTarget()

static ilConditionHandler::getPersistedOptionalConditionsOfTarget ( int  $a_target_ref_id,
int  $a_target_obj_id,
string  $a_obj_type = '' 
)
static

Definition at line 886 of file class.ilConditionHandler.php.

890 : array {
891 $conditions = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
892
893 $opt = array();
894 foreach ($conditions as $con) {
895 if ($con['obligatory']) {
896 continue;
897 }
898 $opt[] = $con;
899 }
900 return $opt;
901 }

Referenced by ilConditionHandlerGUI\listConditions(), and ilConditionHandlerGUI\saveObligatorySettings().

+ Here is the caller graph for this function:

◆ getReferenceHandlingType()

ilConditionHandler::getReferenceHandlingType ( )

Definition at line 242 of file class.ilConditionHandler.php.

242 : int
243 {
245 }

References $condition_reference_type.

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getTargetObjId()

ilConditionHandler::getTargetObjId ( )

Definition at line 272 of file class.ilConditionHandler.php.

272 : int
273 {
275 }

References $target_obj_id.

Referenced by checkExists(), and storeCondition().

+ Here is the caller graph for this function:

◆ getTargetRefId()

ilConditionHandler::getTargetRefId ( )

Definition at line 262 of file class.ilConditionHandler.php.

262 : int
263 {
265 }

References $target_ref_id.

Referenced by checkExists(), storeCondition(), updateCondition(), and updateHiddenStatus().

+ Here is the caller graph for this function:

◆ getTargetType()

ilConditionHandler::getTargetType ( )

get target obj type

Definition at line 288 of file class.ilConditionHandler.php.

288 : string
289 {
290 return $this->target_type;
291 }

References $target_type.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ getTriggerObjId()

ilConditionHandler::getTriggerObjId ( )

Definition at line 308 of file class.ilConditionHandler.php.

308 : int
309 {
311 }

References $trigger_obj_id.

Referenced by checkExists(), and storeCondition().

+ Here is the caller graph for this function:

◆ getTriggerRefId()

ilConditionHandler::getTriggerRefId ( )

Definition at line 298 of file class.ilConditionHandler.php.

298 : int
299 {
301 }

References $trigger_ref_id.

Referenced by checkExists(), and storeCondition().

+ Here is the caller graph for this function:

◆ getTriggerType()

ilConditionHandler::getTriggerType ( )

get trigger obj type

Definition at line 324 of file class.ilConditionHandler.php.

324 : string
325 {
326 return $this->trigger_type;
327 }

References $trigger_type.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ getTriggerTypes()

ilConditionHandler::getTriggerTypes ( )

Definition at line 380 of file class.ilConditionHandler.php.

380 : array
381 {
382 $trigger_types = array('crs', 'exc', 'tst', 'sahs', 'svy', 'lm', 'iass', 'prg', 'copa', 'lti', 'cmix');
383
384 // Add operator lp trigger
386 // only if object type has lp
387 foreach ($this->objDefinition->getAllRepositoryTypes() as $t) {
388 if (ilObjectLP::isSupportedObjectType($t) && !in_array($t, $trigger_types, true)) {
389 $trigger_types[] = $t;
390 }
391 }
392 }
393 foreach ($this->objDefinition->getPlugins() as $p_type => $p_info) {
394 try {
395 $name = 'ilObj' . $p_info['class_name'] . 'Access';
396 $reflection = new ReflectionClass($name);
397 if ($reflection->implementsInterface('ilConditionHandling')) {
398 $trigger_types[] = $p_type;
399 }
400 } catch (ReflectionException $e) {
401 $this->logger->warning('Cannot create instance for ' . $name);
402 $this->logger->warning($e->getMessage());
403 }
404 }
405 $active_triggers = array();
406 foreach ($trigger_types as $type) {
407 if (count($this->getOperatorsByTriggerType($type))) {
408 $active_triggers[] = $type;
409 }
410 }
411 return $active_triggers;
412 }
getOperatorsByTriggerType(string $a_type)
if($format !==null) $name
Definition: metadata.php:247
$type

References Vendor\Package\$e, $name, $type, ilObjUserTracking\_enabledLearningProgress(), getOperatorsByTriggerType(), ilObjectLP\isSupportedObjectType(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ getValue()

ilConditionHandler::getValue ( )

Definition at line 344 of file class.ilConditionHandler.php.

344 : string
345 {
346 return $this->value;
347 }

References $value.

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ lookupObligatoryConditionsOfTarget()

static ilConditionHandler::lookupObligatoryConditionsOfTarget ( int  $a_target_ref_id,
int  $a_target_obj_id 
)
static

Definition at line 903 of file class.ilConditionHandler.php.

903 : int
904 {
905 global $DIC;
906
907 $ilDB = $DIC['ilDB'];
908
909 $query = 'SELECT max(num_obligatory) obl from conditions WHERE ' .
910 'target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
911 'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer') . ' ' .
912 'GROUP BY (num_obligatory)';
913 $res = $ilDB->query($query);
914
915 $obl = 0;
916 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
917 $obl = (int) $row->obl;
918 }
919 return $obl;
920 }

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ lookupPersistedHiddenStatusByTarget()

static ilConditionHandler::lookupPersistedHiddenStatusByTarget ( int  $a_target_ref_id)
static

Definition at line 175 of file class.ilConditionHandler.php.

175 : bool
176 {
177 global $DIC;
178
179 $ilDB = $DIC->database();
180
181 $query = 'SELECT hidden_status FROM conditions ' .
182 'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer');
183 $res = $ilDB->query($query);
184 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
185 return (bool) $row->hidden_status;
186 }
187 return false;
188 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilConditionHandlerGUI\assign().

+ Here is the caller graph for this function:

◆ preloadPersistedConditionsForTargetRecords()

static ilConditionHandler::preloadPersistedConditionsForTargetRecords ( string  $a_type,
array  $a_obj_ids 
)
static
Parameters
int[]$a_obj_ids

Definition at line 758 of file class.ilConditionHandler.php.

758 : void
759 {
760 global $DIC;
761
762 $ilDB = $DIC['ilDB'];
763
764 if (is_array($a_obj_ids) && count($a_obj_ids) > 0) {
765 $res = $ilDB->query("SELECT * FROM conditions " .
766 "WHERE " . $ilDB->in("target_obj_id", $a_obj_ids, false, "integer") .
767 " AND target_type = " . $ilDB->quote($a_type, 'text'));
768 $rows = array();
769 while ($row = $ilDB->fetchAssoc($res)) {
770 $item = [];
771 $item['condition_id'] = (int) $row['condition_id'];
772 $item['target_ref_id'] = (int) $row['target_ref_id'];
773 $item['target_obj_id'] = (int) $row['target_obj_id'];
774 $item['trigger_ref_id'] = (int) $row['trigger_ref_id'];
775 $item['trigger_obj_id'] = (int) $row['trigger_obj_id'];
776 $item['target_type'] = (string) $row['target_type'];
777 $item['trigger_type'] = (string) $row['trigger_type'];
778 $item['operator'] = (string) $row['operator'];
779 $item['value'] = (string) $row['value'];
780 $item['ref_handling'] = (int) $row['ref_handling'];
781 $item['obligatory'] = (bool) $row['obligatory'];
782 $item['num_obligatory'] = (int) $row['num_obligatory'];
783 $item['hidden_status'] = (bool) $row['hidden_status'];
784 self::$cond_target_rows[$a_type . ":" . $row["target_obj_id"]][] = $item;
785 }
786 // init obj ids without any record
787 foreach ($a_obj_ids as $obj_id) {
788 if (!isset(self::$cond_target_rows[$a_type . ":" . $obj_id])) {
789 self::$cond_target_rows[$a_type . ":" . $obj_id] = array();
790 }
791 }
792 }
793 }

References $DIC, $ilDB, $res, $rows, and ILIAS\Repository\int().

Referenced by ilObjectListGUIPreloader\preload().

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

◆ resetCache()

static ilConditionHandler::resetCache ( )
static

Definition at line 131 of file class.ilConditionHandler.php.

131 : void
132 {
133 self::$cond_for_target_cache = [];
134 self::$cond_target_rows = [];
135 }

◆ saveNumberOfRequiredTriggers()

static ilConditionHandler::saveNumberOfRequiredTriggers ( int  $a_target_ref_id,
int  $a_target_obj_id,
int  $a_num 
)
static

Definition at line 994 of file class.ilConditionHandler.php.

994 : void
995 {
996 global $DIC;
997
998 $ilDB = $DIC['ilDB'];
999
1000 $query = 'UPDATE conditions ' .
1001 'SET num_obligatory = ' . $ilDB->quote($a_num, 'integer') . ' ' .
1002 'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
1003 'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer');
1004 $ilDB->manipulate($query);
1005 }

References $DIC, $ilDB, and $query.

Referenced by ilConditionHandlerGUI\saveObligatorySettings().

+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage ( string  $a_msg)

Definition at line 247 of file class.ilConditionHandler.php.

247 : void
248 {
249 $this->error_message = $a_msg;
250 }

◆ setHiddenStatus()

ilConditionHandler::setHiddenStatus ( bool  $a_status)

Definition at line 365 of file class.ilConditionHandler.php.

365 : void
366 {
367 $this->hidden_status = $a_status;
368 }

◆ setObligatory()

ilConditionHandler::setObligatory ( bool  $a_obl)

Set obligatory status.

Definition at line 352 of file class.ilConditionHandler.php.

352 : void
353 {
354 $this->obligatory = $a_obl;
355 }

◆ setOperator()

ilConditionHandler::setOperator ( string  $a_operator)

Definition at line 329 of file class.ilConditionHandler.php.

329 : void
330 {
331 $this->operator = $a_operator;
332 }

◆ setReferenceHandlingType()

ilConditionHandler::setReferenceHandlingType ( int  $a_type)

Definition at line 237 of file class.ilConditionHandler.php.

237 : void
238 {
239 $this->condition_reference_type = $a_type;
240 }

◆ setTargetObjId()

ilConditionHandler::setTargetObjId ( int  $a_target_obj_id)

Definition at line 267 of file class.ilConditionHandler.php.

267 : void
268 {
269 $this->target_obj_id = $a_target_obj_id;
270 }

◆ setTargetRefId()

ilConditionHandler::setTargetRefId ( int  $a_target_ref_id)

Definition at line 257 of file class.ilConditionHandler.php.

257 : void
258 {
259 $this->target_ref_id = $a_target_ref_id;
260 }

◆ setTargetType()

ilConditionHandler::setTargetType ( string  $a_target_type)

set target object type

Definition at line 280 of file class.ilConditionHandler.php.

280 : void
281 {
282 $this->target_type = $a_target_type;
283 }

◆ setTriggerObjId()

ilConditionHandler::setTriggerObjId ( int  $a_trigger_obj_id)

Definition at line 303 of file class.ilConditionHandler.php.

303 : void
304 {
305 $this->trigger_obj_id = $a_trigger_obj_id;
306 }

◆ setTriggerRefId()

ilConditionHandler::setTriggerRefId ( int  $a_trigger_ref_id)

Definition at line 293 of file class.ilConditionHandler.php.

293 : void
294 {
295 $this->trigger_ref_id = $a_trigger_ref_id;
296 }

◆ setTriggerType()

ilConditionHandler::setTriggerType ( string  $a_trigger_type)

set trigger object type

Definition at line 316 of file class.ilConditionHandler.php.

316 : void
317 {
318 $this->trigger_type = $a_trigger_type;
319 }

◆ setValue()

ilConditionHandler::setValue ( string  $a_value)

Definition at line 339 of file class.ilConditionHandler.php.

339 : void
340 {
341 $this->value = $a_value;
342 }

◆ storeCondition()

ilConditionHandler::storeCondition ( )

store new condition in database

Definition at line 455 of file class.ilConditionHandler.php.

455 : bool
456 {
457 // first insert, then validate: it's easier to check for circles if the new condition is in the db table
458 $next_id = $this->db->nextId('conditions');
459 $query = 'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
460 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
461 'VALUES (' .
462 $this->db->quote($next_id, 'integer') . ',' .
463 $this->db->quote($this->getTargetRefId(), 'integer') . "," .
464 $this->db->quote($this->getTargetObjId(), 'integer') . "," .
465 $this->db->quote($this->getTargetType(), 'text') . "," .
466 $this->db->quote($this->getTriggerRefId(), 'integer') . "," .
467 $this->db->quote($this->getTriggerObjId(), 'integer') . "," .
468 $this->db->quote($this->getTriggerType(), 'text') . "," .
469 $this->db->quote($this->getOperator(), 'text') . "," .
470 $this->db->quote($this->getValue(), 'text') . ", " .
471 $this->db->quote($this->getReferenceHandlingType(), 'integer') . ', ' .
472 $this->db->quote($this->getObligatory(), 'integer') . ', ' .
473 $this->db->quote($this->getHiddenStatus(), 'integer') . ' ' .
474 ')';
475
476 $res = $this->db->manipulate($query);
477
478 if ($this->validation && !$this->validate()) {
479 $this->deleteCondition($next_id);
480 return false;
481 }
482 return true;
483 }
getTargetType()
get target obj type
getTriggerType()
get trigger obj type
getObligatory()
Get obligatory status.

References $query, $res, deleteCondition(), getHiddenStatus(), getObligatory(), getOperator(), getReferenceHandlingType(), getTargetObjId(), getTargetRefId(), getTargetType(), getTriggerObjId(), getTriggerRefId(), getTriggerType(), getValue(), and validate().

+ Here is the call graph for this function:

◆ updateCondition()

ilConditionHandler::updateCondition ( int  $a_id)

Definition at line 497 of file class.ilConditionHandler.php.

497 : void
498 {
499 $query = "UPDATE conditions SET " .
500 "target_ref_id = " . $this->db->quote($this->getTargetRefId(), 'integer') . ", " .
501 "operator = " . $this->db->quote($this->getOperator(), 'text') . ", " .
502 "value = " . $this->db->quote($this->getValue(), 'text') . ", " .
503 "ref_handling = " . $this->db->quote($this->getReferenceHandlingType(), 'integer') . ", " .
504 'obligatory = ' . $this->db->quote($this->getObligatory(), 'integer') . ' ' .
505 "WHERE condition_id = " . $this->db->quote($a_id, 'integer');
506 $res = $this->db->manipulate($query);
507 }

References $query, $res, getObligatory(), getOperator(), getReferenceHandlingType(), getTargetRefId(), and getValue().

+ Here is the call graph for this function:

◆ updateHiddenStatus()

ilConditionHandler::updateHiddenStatus ( bool  $a_status)

Definition at line 509 of file class.ilConditionHandler.php.

509 : void
510 {
511 $query = 'UPDATE conditions SET ' .
512 'hidden_status = ' . $this->db->quote($a_status, 'integer') . ' ' .
513 'WHERE target_ref_id = ' . $this->db->quote($this->getTargetRefId(), 'integer');
514 $this->db->manipulate($query);
515 }

References $query, and getTargetRefId().

+ Here is the call graph for this function:

◆ updateObligatory()

static ilConditionHandler::updateObligatory ( int  $a_id,
bool  $a_status 
)
static

Toggle condition obligatory status.

Definition at line 520 of file class.ilConditionHandler.php.

520 : void
521 {
522 global $DIC;
523
524 $ilDB = $DIC->database();
525 $query = "UPDATE conditions SET " .
526 'obligatory = ' . $ilDB->quote($a_status, 'integer') . ' ' .
527 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
528 $res = $ilDB->manipulate($query);
529 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilConditionHandlerGUI\saveObligatoryList(), and ilConditionHandlerGUI\saveObligatorySettings().

+ Here is the caller graph for this function:

◆ validate()

ilConditionHandler::validate ( )
protected

Definition at line 1060 of file class.ilConditionHandler.php.

1060 : bool
1061 {
1062 // check if obj_id is already assigned
1065
1066 if ($trigger_obj !== null && $target_obj !== null) {
1067 $query = "SELECT * FROM conditions WHERE " .
1068 "trigger_ref_id = " . $this->db->quote($trigger_obj->getRefId(), 'integer') . " " .
1069 "AND target_ref_id = " . $this->db->quote($target_obj->getRefId(), 'integer');
1070
1071 $res = $this->db->query($query);
1072
1073 if ($res->numRows() > 1) {
1074 $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1075
1076 unset($trigger_obj, $target_obj);
1077 return false;
1078 }
1079 // check for circle
1080 $this->target_obj_id = $target_obj->getId();
1081
1082 if ($this->checkCircle($this->getTargetRefId(), $target_obj->getId())) {
1083 $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1084
1085 unset($trigger_obj, $target_obj);
1086 return false;
1087 }
1088 return true;
1089 }
1090 return false;
1091 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id

References $query, $res, ilObjectFactory\getInstanceByRefId(), and ILIAS\Repository\lng().

Referenced by storeCondition().

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

Field Documentation

◆ $circle

bool ilConditionHandler::$circle = false
private

Definition at line 114 of file class.ilConditionHandler.php.

◆ $cond_for_target_cache

array ilConditionHandler::$cond_for_target_cache = array()
static

Definition at line 93 of file class.ilConditionHandler.php.

◆ $cond_target_rows

array ilConditionHandler::$cond_target_rows = array()
static

Definition at line 94 of file class.ilConditionHandler.php.

◆ $condition_reference_type

int ilConditionHandler::$condition_reference_type = 0
private

Definition at line 110 of file class.ilConditionHandler.php.

Referenced by getReferenceHandlingType().

◆ $db

ilDBInterface ilConditionHandler::$db
protected

Definition at line 96 of file class.ilConditionHandler.php.

Referenced by getNumberOfConditionsOfTrigger().

◆ $error_message

string ilConditionHandler::$error_message = ''
protected

Definition at line 102 of file class.ilConditionHandler.php.

Referenced by getErrorMessage().

◆ $hidden_status

bool ilConditionHandler::$hidden_status = false
private

Definition at line 117 of file class.ilConditionHandler.php.

Referenced by getHiddenStatus().

◆ $lng

ilLanguage ilConditionHandler::$lng
protected

Definition at line 97 of file class.ilConditionHandler.php.

◆ $logger

ilLogger ilConditionHandler::$logger
protected

Definition at line 100 of file class.ilConditionHandler.php.

◆ $objDefinition

ilObjectDefinition ilConditionHandler::$objDefinition
protected

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

Referenced by getOperatorsByTriggerType().

◆ $obligatory

bool ilConditionHandler::$obligatory = true
private

Definition at line 116 of file class.ilConditionHandler.php.

Referenced by getObligatory().

◆ $operator

string ilConditionHandler::$operator = ''
protected

Definition at line 111 of file class.ilConditionHandler.php.

Referenced by getOperator().

◆ $target_obj_id

int ilConditionHandler::$target_obj_id = 0
protected

Definition at line 104 of file class.ilConditionHandler.php.

Referenced by getTargetObjId().

◆ $target_ref_id

int ilConditionHandler::$target_ref_id = 0
protected

Definition at line 105 of file class.ilConditionHandler.php.

Referenced by getTargetRefId().

◆ $target_type

string ilConditionHandler::$target_type = ''
protected

Definition at line 106 of file class.ilConditionHandler.php.

Referenced by getTargetType().

◆ $tree

ilTree ilConditionHandler::$tree
protected

Definition at line 99 of file class.ilConditionHandler.php.

◆ $trigger_obj_id

int ilConditionHandler::$trigger_obj_id = 0
protected

Definition at line 107 of file class.ilConditionHandler.php.

Referenced by getTriggerObjId().

◆ $trigger_ref_id

int ilConditionHandler::$trigger_ref_id = 0
protected

Definition at line 108 of file class.ilConditionHandler.php.

Referenced by getTriggerRefId().

◆ $trigger_type

string ilConditionHandler::$trigger_type = ''
protected

Definition at line 109 of file class.ilConditionHandler.php.

Referenced by getTriggerType().

◆ $validation

bool ilConditionHandler::$validation = true
protected

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

◆ $value

string ilConditionHandler::$value = ''
protected

Definition at line 112 of file class.ilConditionHandler.php.

Referenced by getValue().

◆ OPERATOR_ACCREDITED_OR_PASSED

const ilConditionHandler::OPERATOR_ACCREDITED_OR_PASSED = 'accredited_or_passed'

◆ OPERATOR_FAILED

◆ OPERATOR_FINISHED

◆ OPERATOR_LP

const ilConditionHandler::OPERATOR_LP = 'learning_progress'

◆ OPERATOR_NOT_FINISHED

const ilConditionHandler::OPERATOR_NOT_FINISHED = 'not_finished'

◆ OPERATOR_NOT_MEMBER

const ilConditionHandler::OPERATOR_NOT_MEMBER = 'not_member'

Definition at line 82 of file class.ilConditionHandler.php.

Referenced by ilConditionOperatorFactory\notMember().

◆ OPERATOR_PASSED

◆ SHARED_CONDITIONS

const ilConditionHandler::SHARED_CONDITIONS = 0

Definition at line 91 of file class.ilConditionHandler.php.

◆ UNIQUE_CONDITIONS

const ilConditionHandler::UNIQUE_CONDITIONS = 1

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