ILIAS  release_7 Revision v7.30-3-g800a261c036
ilConditionHandler Class Reference

INTERNAL CLASS: Please do not use in consumer code. More...

+ Collaboration diagram for ilConditionHandler:

Public Member Functions

 __construct ()
 constructor @access public More...
 
 setReferenceHandlingType ($a_type)
 set reference handling type More...
 
 getReferenceHandlingType ()
 get reference handling type More...
 
 setErrorMessage ($a_msg)
 
 getErrorMessage ()
 
 setTargetRefId ($a_target_ref_id)
 set target ref id More...
 
 getTargetRefId ()
 get target ref id More...
 
 setTargetObjId ($a_target_obj_id)
 set target object id More...
 
 getTargetObjId ()
 get target obj id More...
 
 setTargetType ($a_target_type)
 set target object type More...
 
 getTargetType ()
 get target obj type More...
 
 setTriggerRefId ($a_trigger_ref_id)
 set trigger ref id More...
 
 getTriggerRefId ()
 get target ref id More...
 
 setTriggerObjId ($a_trigger_obj_id)
 set trigger object id More...
 
 getTriggerObjId ()
 get trigger obj id More...
 
 setTriggerType ($a_trigger_type)
 set trigger object type More...
 
 getTriggerType ()
 get trigger obj type More...
 
 setOperator ($a_operator)
 set operator More...
 
 getOperator ()
 get operator More...
 
 setValue ($a_value)
 set value More...
 
 getValue ()
 get value More...
 
 setObligatory ($a_obl)
 Set obligatory status. More...
 
 getObligatory ()
 Get obligatory status. More...
 
 setHiddenStatus ($a_status)
 
 getHiddenStatus ()
 
 enableAutomaticValidation ($a_validate=true)
 enable automated validation More...
 
 getOperatorsByTriggerType ($a_type)
 Get operators by trigger type. More...
 
 storeCondition ()
 store new condition in database More...
 
 checkExists ()
 
 updateCondition ($a_id)
 update condition More...
 
 updateHiddenStatus ($a_status)
 Update hidden status @global type $ilDB. More...
 
 delete ($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 ($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 ($a_id)
 delete condition More...
 

Static Public Member Functions

static resetCache ()
 
static _isReferenceHandlingOptional ($a_type)
 is reference handling optional More...
 
static lookupPersistedHiddenStatusByTarget ($a_target_ref_id)
 Lookup persistedhidden status. More...
 
static _adjustMovedObjectConditions ($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 ($a_id, $a_status)
 Toggle condition obligatory status. More...
 
static getNumberOfConditionsOfTrigger ($a_trigger_obj_type, $a_trigger_id)
 get all conditions of trigger object More...
 
static _getPersistedConditionsOfTrigger ($a_trigger_obj_type, $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 ($a_target_ref_id, $a_target_obj_id, $a_target_type="")
 get all persisted conditions of target object More...
 
static preloadPersistedConditionsForTargetRecords ($a_type, $a_obj_ids)
 Preload conditions for target records. More...
 
static _getCondition ($a_id)
 
static _checkCondition ($condition, $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 ($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
 Get optional conditions. More...
 
static getPersistedOptionalConditionsOfTarget ($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
 Get optional conditions. More...
 
static lookupObligatoryConditionsOfTarget ($a_target_ref_id, $a_target_obj_id)
 Lookup obligatory conditions of target. More...
 
static calculateEffectiveRequiredTriggers ($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='')
 calculate number of obligatory items More...
 
static calculatePersistedRequiredTriggers ($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
 calculate number of obligatory items More...
 
static saveNumberOfRequiredTriggers ($a_target_ref_id, $a_target_obj_id, $a_num)
 Save number of obigatory triggers. More...
 
static _checkAllConditionsOfTarget ($a_target_ref_id, $a_target_id, $a_target_type="", $a_usr_id=0)
 checks wether all conditions of a target object are fulfilled More...
 
static cloneDependencies ($a_src_ref_id, $a_target_ref_id, $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
 
 $db
 
 $lng
 
 $error_message
 
 $target_obj_id
 
 $target_ref_id
 
 $target_type
 
 $trigger_obj_id
 
 $trigger_ref_id
 
 $trigger_type
 
 $operator
 
 $value
 
 $validation
 
 $conditions
 

Static Public Attributes

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

Protected Member Functions

 validate ()
 
 checkCircle ($a_ref_id, $a_obj_id)
 

Static Protected Member Functions

static _getDistinctTargetRefIds ()
 Get all target ref ids. More...
 
static _deleteTargetConditionsByRefId ($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...
 

Private Attributes

 $obligatory = true
 
 $hidden_status = false
 

Detailed Description

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 79 of file class.ilConditionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilConditionHandler::__construct ( )

constructor @access public

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

123 {
124 global $DIC;
125
126 $ilDB = $DIC['ilDB'];
127 $lng = $DIC['lng'];
128
129 $this->db = &$ilDB;
130 $this->lng = &$lng;
131 $this->validation = true;
132 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, $ilDB, and $lng.

Member Function Documentation

◆ _adjustMovedObjectConditions()

static ilConditionHandler::_adjustMovedObjectConditions (   $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

@access public

Parameters
intreference id of moved object

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

224 {
225 global $DIC;
226
227 return true;
228
229 $tree = $DIC['tree'];
230
231 if ($tree->checkForParentType($a_ref_id, 'crs')) {
232 // Nothing to do
233 return true;
234 }
235
236 // Need another implementation that has better performance
237 $childs = $tree->getSubTree($tree->getNodeData($a_ref_id), false);
239
240 foreach (array_intersect($conditions, $childs) as $target_ref) {
241 if (!$tree->checkForParentType($target_ref, 'crs')) {
243 }
244 }
245 return true;
246 }
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
static _getDistinctTargetRefIds()
Get all target ref ids.

References $conditions, $DIC, _deleteTargetConditionsByRefId(), and _getDistinctTargetRefIds().

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

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

◆ _checkAllConditionsOfTarget()

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

checks wether all conditions of a target object are fulfilled

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

1209 {
1210 global $DIC;
1211
1212 $ilUser = $DIC['ilUser'];
1213 $tree = $DIC['tree'];
1214 $logger = $DIC->logger()->ac();
1215
1216 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1217
1218 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1219
1220 if (!count($conditions)) {
1221 return true;
1222 }
1223
1224 // @todo check this
1225 include_once './Services/Container/classes/class.ilMemberViewSettings.php';
1226 if (ilMemberViewSettings::getInstance()->isActive()) {
1227 return true;
1228 }
1229
1230 // First check obligatory conditions
1231 $optional = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1232 $num_required = self::calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1233 $passed = 0;
1234 foreach ($conditions as $condition) {
1235 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1236 continue;
1237 }
1238 $check = ilConditionHandler::_checkCondition($condition, $a_usr_id);
1239
1240 if ($check) {
1241 ++$passed;
1242 } else {
1243 // #0027223 if condition is obligatory => return false
1244 if ($condition['obligatory']) {
1245 return false;
1246 }
1247 }
1248 }
1249 if ($passed >= $num_required) {
1250 return true;
1251 }
1252
1253 // not all optional conditions passed
1254 return false;
1255 }
static _checkCondition($condition, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
static getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
static calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='')
calculate number of obligatory items
$ilUser
Definition: imgupload.php:18

References $conditions, $DIC, $ilUser, _checkCondition(), calculateEffectiveRequiredTriggers(), getEffectiveOptionalConditionsOfTarget(), and ilMemberViewSettings\getInstance().

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

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

◆ _checkCondition()

static ilConditionHandler::_checkCondition (   $condition,
  $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 1002 of file class.ilConditionHandler.php.

1003 {
1004 global $DIC;
1005
1006 $ilUser = $DIC['ilUser'];
1007 $objDefinition = $DIC['objDefinition'];
1008
1009 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1010
1011 //$condition = ilConditionHandler::_getCondition($a_id);
1012
1013 // check lp
1014 if ($condition['operator'] == self::OPERATOR_LP) {
1015 include_once './Services/Tracking/classes/class.ilLPStatus.php';
1016 return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
1017 }
1018
1019 switch ($condition['trigger_type']) {
1020 case 'crsg':
1021 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
1022 return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
1023 }
1024
1025 $class = $objDefinition->getClassName($condition['trigger_type']);
1026 $location = $objDefinition->getLocation($condition['trigger_type']);
1027 $full_class = "ilObj" . $class . "Access";
1028 include_once($location . "/class." . $full_class . ".php");
1029
1030 $fullfilled = call_user_func(
1031 array($full_class, 'checkCondition'),
1032 $condition['trigger_obj_id'],
1033 $condition['operator'],
1034 $condition['value'],
1035 $a_usr_id
1036 );
1037 return $fullfilled;
1038 }
$location
Definition: buildRTE.php:44
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static _checkCondition($trigger_obj_id, $operator, $value, $a_usr_id=0)

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

Referenced by _checkAllConditionsOfTarget(), ilObjContentObject\_getMissingPreconditionsOfPage(), ilObjContentObject\_getMissingPreconditionsTopChapter(), ilInfoScreenGUI\addPreconditionSection(), and ilObjectListGUI\parseConditions().

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

◆ _deleteTargetConditionsByRefId()

static ilConditionHandler::_deleteTargetConditionsByRefId (   $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.

@access public

Parameters
intref id of target

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

280 {
281 global $DIC;
282
283 $ilDB = $DIC['ilDB'];
284
285 $query = "DELETE FROM conditions " .
286 "WHERE target_ref_id = " . $ilDB->quote($a_target_ref_id, 'integer') . " " .
287 "AND target_type != 'st' ";
288 $res = $ilDB->manipulate($query);
289 return true;
290 }
$query
foreach($_POST as $key=> $value) $res

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

Referenced by _adjustMovedObjectConditions(), and ilRBACTest\testConditions().

+ Here is the caller graph for this function:

◆ _getCondition()

static ilConditionHandler::_getCondition (   $a_id)
static

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

967 {
968 global $DIC;
969
970 $ilDB = $DIC['ilDB'];
971
972 $query = "SELECT * FROM conditions " .
973 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
974
975 $res = $ilDB->query($query);
976 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
977 $tmp_array['id'] = $row->condition_id;
978 $tmp_array['target_ref_id'] = $row->target_ref_id;
979 $tmp_array['target_obj_id'] = $row->target_obj_id;
980 $tmp_array['target_type'] = $row->target_type;
981 $tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
982 $tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
983 $tmp_array['trigger_type'] = $row->trigger_type;
984 $tmp_array['operator'] = $row->operator;
985 $tmp_array['value'] = $row->value;
986 $tmp_array['ref_handling'] = $row->ref_handling;
987 $tmp_array['obligatory'] = $row->obligatory;
988 $tmp_array['hidden_status'] = $row->hidden_status;
989
990 return $tmp_array;
991 }
992 return false;
993 }

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

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

+ Here is the caller graph for this function:

◆ _getDistinctTargetRefIds()

static ilConditionHandler::_getDistinctTargetRefIds ( )
staticprotected

Get all target ref ids.

@access public

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

256 {
257 global $DIC;
258
259 $ilDB = $DIC['ilDB'];
260
261 $query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
262 $res = $ilDB->query($query);
263 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
264 $ref_ids[] = $row->ref;
265 }
266 return $ref_ids ? $ref_ids : array();
267 }

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

Referenced by _adjustMovedObjectConditions(), and ilRBACTest\testConditions().

+ Here is the caller graph for this function:

◆ _getPersistedConditionsOfTarget()

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

get all persisted conditions of target object

Parameters
int$a_target_ref_id
int$a_target_obj_id
string$a_target_type
Returns
array

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

883 {
884 global $DIC;
885
886 $ilDB = $DIC['ilDB'];
887
888 // get type if no type given
889 if ($a_target_type == "") {
890 $a_target_type = ilObject::_lookupType($a_target_obj_id);
891 }
892
893 // check conditions for target cache
894 if (isset(self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
895 $a_target_type])) {
896 return self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
897 $a_target_type];
898 }
899
900 // check rows cache
901 if (isset(self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id])) {
902 $rows = self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id];
903 } else {
904 // query data from db
905 $query = "SELECT * FROM conditions " .
906 "WHERE target_obj_id = " . $ilDB->quote($a_target_obj_id, 'integer') . " " .
907 " AND target_type = " . $ilDB->quote($a_target_type, 'text');
908
909 $res = $ilDB->query($query);
910 $rows = array();
911 while ($row = $ilDB->fetchAssoc($res)) {
912 $rows[] = $row;
913 }
914 }
915
916 reset($rows);
917 $conditions = array();
918 foreach ($rows as $row) {
919 if ($row["ref_handling"] == self::UNIQUE_CONDITIONS) {
920 if ($row["target_ref_id"] != $a_target_ref_id) {
921 continue;
922 }
923 }
924
925 $row["id"] = $row["condition_id"];
926 $conditions[] = $row;
927 }
928
929 // write conditions for target cache
930 self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
931 $a_target_type] = $conditions;
932
933 return $conditions;
934 }
static _lookupType($a_id, $a_reference=false)
lookup object type
$rows
Definition: xhr_table.php:10

References $conditions, $DIC, $ilDB, $query, $res, $rows, and ilObject\_lookupType().

Referenced by ilConditionHandlerGUI\__getConditionsOfTarget(), ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), ilObjContentObject\_getMissingPreconditionsOfPage(), ilObjContentObject\_getMissingPreconditionsTopChapter(), calculatePersistedRequiredTriggers(), checkCircle(), cloneDependencies(), getPersistedOptionalConditionsOfTarget(), ilConditionHandlerGUI\listConditions(), ilConditionHandlerGUI\saveObligatoryList(), ilConditionHandlerGUI\saveObligatorySettings(), ilConditionHandlerGUI\showObligatoryForm(), and ilRBACTest\testConditions().

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

◆ _getPersistedConditionsOfTrigger()

static ilConditionHandler::_getPersistedConditionsOfTrigger (   $a_trigger_obj_type,
  $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.

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

778 {
779 global $DIC;
780
781 $ilDB = $DIC['ilDB'];
782
783 $query = "SELECT * FROM conditions " .
784 "WHERE trigger_obj_id = " . $ilDB->quote($a_trigger_id, 'integer') . " " .
785 " AND trigger_type = " . $ilDB->quote($a_trigger_obj_type, 'text');
786
787 $res = $ilDB->query($query);
788 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
789 $tmp_array['id'] = $row->condition_id;
790 $tmp_array['target_ref_id'] = $row->target_ref_id;
791 $tmp_array['target_obj_id'] = $row->target_obj_id;
792 $tmp_array['target_type'] = $row->target_type;
793 $tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
794 $tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
795 $tmp_array['trigger_type'] = $row->trigger_type;
796 $tmp_array['operator'] = $row->operator;
797 $tmp_array['value'] = $row->value;
798 $tmp_array['ref_handling'] = $row->ref_handling;
799 $tmp_array['obligatory'] = $row->obligatory;
800 $tmp_array['hidden_status'] = $row->hidden_status;
801
802 $conditions[] = $tmp_array;
803 unset($tmp_array);
804 }
805
806 return $conditions ? $conditions : array();
807 }

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

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

+ Here is the caller graph for this function:

◆ _isReferenceHandlingOptional()

static ilConditionHandler::_isReferenceHandlingOptional (   $a_type)
static

is reference handling optional

@access public

Parameters
stringtarget type ILIAS obj type

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

149 {
150 switch ($a_type) {
151 case 'st':
152 return true;
153
154 default:
155 return false;
156 }
157 }

Referenced by ilConditionHandlerGUI\initFormCondition().

+ Here is the caller graph for this function:

◆ calculateEffectiveRequiredTriggers()

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

calculate number of obligatory items

Parameters
int$a_target_ref_id
int$a_target_obj_id
Returns
int

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

1116 {
1117 global $DIC;
1118
1119 $ilDB = $DIC['ilDB'];
1120
1121 // Get all conditions
1122 $all = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1123 $opt = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1124
1125 $set_obl = 0;
1126 if (isset($all[0])) {
1127 $set_obl = $all[0]['num_obligatory'];
1128 }
1129
1130 // existing value is valid
1131 if ($set_obl > 0 and
1132 $set_obl < count($all) and
1133 $set_obl > (count($all) - count($opt) + 1)) {
1134 return $set_obl;
1135 }
1136
1137 if (count($opt)) {
1138 $result = count($all) - count($opt) + 1;
1139 } else {
1140 $result = count($all);
1141 }
1142 return $result;
1143 }
$result

References $DIC, $ilDB, $result, and getEffectiveOptionalConditionsOfTarget().

Referenced by _checkAllConditionsOfTarget(), ilInfoScreenGUI\addPreconditionSection(), and ilObjectListGUI\parseConditions().

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

◆ calculatePersistedRequiredTriggers()

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

calculate number of obligatory items

Parameters
int$a_target_ref_id
int$a_target_obj_id
Returns
int

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

1152 {
1153 global $DIC;
1154
1155 $ilDB = $DIC['ilDB'];
1156
1157 // Get all conditions
1158
1160 $all = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1161 $opt = self::getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1162
1163 $set_obl = 0;
1164 if (isset($all[0])) {
1165 $set_obl = $all[0]['num_obligatory'];
1166 }
1167
1168 // existing value is valid
1169 if ($set_obl > 0 and
1170 $set_obl < count($all) and
1171 $set_obl > (count($all) - count($opt) + 1)) {
1172 return $set_obl;
1173 }
1174
1175 if (count($opt)) {
1176 $result = count($all) - count($opt) + 1;
1177 } else {
1178 $result = count($all);
1179 }
1180 if ($a_force_update) {
1181 self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $result);
1182 }
1183 return $result;
1184 }
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.

References $DIC, $ilDB, $result, _getPersistedConditionsOfTarget(), getPersistedOptionalConditionsOfTarget(), resetCache(), and saveNumberOfRequiredTriggers().

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

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

◆ checkCircle()

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

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

1295 {
1296 foreach (ilConditionHandler::_getPersistedConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
1297 if ($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator()) {
1298 $this->circle = true;
1299 break;
1300 } else {
1301 $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
1302 }
1303 }
1304 return $this->circle;
1305 }
checkCircle($a_ref_id, $a_obj_id)

References _getPersistedConditionsOfTarget(), checkCircle(), and getOperator().

Referenced by checkCircle(), and validate().

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

◆ checkExists()

ilConditionHandler::checkExists ( )

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

625 {
626 global $DIC;
627
628 $ilDB = $DIC['ilDB'];
629
630 $query = "SELECT * FROM conditions " .
631 "WHERE target_ref_id = " . $ilDB->quote($this->getTargetRefId(), 'integer') . " " .
632 "AND target_obj_id = " . $ilDB->quote($this->getTargetObjId(), 'integer') . " " .
633 "AND trigger_ref_id = " . $ilDB->quote($this->getTriggerRefId(), 'integer') . " " .
634 "AND trigger_obj_id = " . $ilDB->quote($this->getTriggerObjId(), 'integer') . " " .
635 "AND operator = " . $ilDB->quote($this->getOperator(), 'text');
636 $res = $ilDB->query($query);
637
638 return $res->numRows() ? true : false;
639 }
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
getTriggerRefId()
get target ref id
getTargetRefId()
get target ref id
getTargetObjId()
get target obj id
getTriggerObjId()
get trigger obj id

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

+ Here is the call graph for this function:

◆ cloneDependencies()

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

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

1308 {
1309 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1310 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1311 $mappings = $cwo->getMappings();
1312
1313 $valid = 0;
1315 foreach ($conditions as $con) {
1316 if ($mappings[$con['trigger_ref_id']]) {
1317 $newCondition = new ilConditionHandler();
1318
1319 $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1320 $target_typ = ilObject::_lookupType($target_obj);
1321
1322 $newCondition->setTargetRefId($a_target_ref_id);
1323 $newCondition->setTargetObjId($target_obj);
1324 $newCondition->setTargetType($target_typ);
1325
1326 $trigger_ref = $mappings[$con['trigger_ref_id']];
1327 $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1328 $trigger_typ = ilObject::_lookupType($trigger_obj);
1329
1330 $newCondition->setTriggerRefId($trigger_ref);
1331 $newCondition->setTriggerObjId($trigger_obj);
1332 $newCondition->setTriggerType($trigger_typ);
1333 $newCondition->setOperator($con['operator']);
1334 $newCondition->setValue($con['value']);
1335 $newCondition->setReferenceHandlingType($con['ref_handling']);
1336 $newCondition->setObligatory($con['obligatory']);
1337
1338 // :TODO: not sure about this
1339 $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1340
1341 if ($newCondition->storeCondition()) {
1342 $valid++;
1343
1344 //Copy num_obligatory, to be checked below
1346 $a_target_ref_id,
1347 $target_obj,
1348 $con['num_obligatory']
1349 );
1350 }
1351 }
1352 }
1353 if ($valid) {
1354 $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1355
1356 // num_obligatory
1357 self::calculatePersistedRequiredTriggers($a_target_ref_id, $tgt_obj_id, ilObject::_lookupType($tgt_obj_id), true);
1358 }
1359 }
INTERNAL CLASS: Please do not use in consumer code.
static calculatePersistedRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _lookupObjId($a_id)
$valid

References $conditions, $valid, ilCopyWizardOptions\_getInstance(), _getPersistedConditionsOfTarget(), ilObject\_lookupObjId(), ilObject\_lookupType(), calculatePersistedRequiredTriggers(), and saveNumberOfRequiredTriggers().

Referenced by ilObject\cloneDependencies().

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

◆ delete()

ilConditionHandler::delete (   $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 705 of file class.ilConditionHandler.php.

706 {
707 global $DIC;
708
709 $ilDB = $DIC['ilDB'];
710
711 $query = "DELETE FROM conditions WHERE " .
712 "target_ref_id = " . $ilDB->quote($a_ref_id, 'integer') . " " .
713 "OR trigger_ref_id = " . $ilDB->quote($a_ref_id, 'integer');
714 $res = $ilDB->manipulate($query);
715
716 return true;
717 }

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

◆ deleteByObjId()

ilConditionHandler::deleteByObjId (   $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 722 of file class.ilConditionHandler.php.

723 {
724 global $DIC;
725
726 $ilDB = $DIC['ilDB'];
727
728 $query = "DELETE FROM conditions WHERE " .
729 "target_obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
730 "OR trigger_obj_id = " . $ilDB->quote($a_obj_id, 'integer');
731 $res = $ilDB->manipulate($query);
732
733 return true;
734 }

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

◆ deleteCondition()

ilConditionHandler::deleteCondition (   $a_id)

delete condition

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

740 {
741 global $DIC;
742
743 $ilDB = $DIC['ilDB'];
744
745 $query = "DELETE FROM conditions " .
746 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
747 $res = $ilDB->manipulate($query);
748
749 return true;
750 }

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

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ enableAutomaticValidation()

ilConditionHandler::enableAutomaticValidation (   $a_validate = true)

enable automated validation

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

486 {
487 $this->validation = $a_validate;
488 }

◆ getEffectiveOptionalConditionsOfTarget()

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

Get optional conditions.

Parameters
int$a_target_ref_id
int$a_target_obj_id
string$a_obj_type
Returns
array

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

1048 {
1049 $conditions = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1050
1051 $opt = array();
1052 foreach ($conditions as $con) {
1053 if ($con['obligatory']) {
1054 continue;
1055 }
1056
1057 $opt[] = $con;
1058 }
1059 return $opt;
1060 }

References $conditions.

Referenced by _checkAllConditionsOfTarget(), ilInfoScreenGUI\addPreconditionSection(), calculateEffectiveRequiredTriggers(), and ilObjectListGUI\parseConditions().

+ Here is the caller graph for this function:

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

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

References $error_message.

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

References $hidden_status.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ getNumberOfConditionsOfTrigger()

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

get all conditions of trigger object

Parameters
string$a_trigger_obj_type
int$a_trigger_id
Returns
int
Exceptions
ilDatabaseException

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

761 {
762 global $DIC;
763 $db = $DIC->database();
764
765 $query = 'select count(*) num from conditions ' .
766 'where trigger_obj_id = ' . $db->quote($a_trigger_id, ilDBConstants::T_INTEGER) . ' ' .
767 'and trigger_type = ' . $db->quote($a_trigger_obj_type, ilDBConstants::T_TEXT);
768 $res = $db->query($query);
769 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
770 return (int) $row->num;
771 }

References $db, $DIC, $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Referenced by ilScormLP\checkSCORMPreconditions().

+ Here is the caller graph for this function:

◆ getObligatory()

ilConditionHandler::getObligatory ( )

Get obligatory status.

Returns
obligatory status

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

467 {
468 return (bool) $this->obligatory;
469 }

References $obligatory.

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getOperator()

ilConditionHandler::getOperator ( )

get operator

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

References $operator.

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

+ Here is the caller graph for this function:

◆ getOperatorsByTriggerType()

ilConditionHandler::getOperatorsByTriggerType (   $a_type)

Get operators by trigger type.

Parameters
string$a_type
Returns
string[]

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

548 {
549 global $DIC;
550
551 $objDefinition = $DIC['objDefinition'];
552
553 switch ($a_type) {
554 case 'crsg':
555 return array('not_member');
556 }
557
558 $class = $objDefinition->getClassName($a_type);
559 $location = $objDefinition->getLocation($a_type);
560 $full_class = "ilObj" . $class . "Access";
561 include_once($location . "/class." . $full_class . ".php");
562
563 include_once './Services/Conditions/interfaces/interface.ilConditionHandling.php';
564
565 $reflection = new ReflectionClass($full_class);
566 if ($reflection->implementsInterface('ilConditionHandling')) {
567 $operators = call_user_func(
568 array($full_class, 'getConditionOperators'),
569 $a_type
570 );
571 } else {
572 $operators = [];
573 }
574
575 // Add operator lp
576 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
578 // only if object type has lp
579 include_once("Services/Object/classes/class.ilObjectLP.php");
581 array_unshift($operators, self::OPERATOR_LP);
582 }
583 }
584 return $operators;
585 }
static _enabledLearningProgress()
check wether learing progress is enabled or not
static isSupportedObjectType($type)

References $DIC, $location, ilObjUserTracking\_enabledLearningProgress(), and ilObjectLP\isSupportedObjectType().

+ Here is the call graph for this function:

◆ getPersistedOptionalConditionsOfTarget()

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

Get optional conditions.

Parameters
int$a_target_ref_id
int$a_target_obj_id
string$a_obj_type
Returns
array

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

1070 {
1071 $conditions = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1072
1073 $opt = array();
1074 foreach ($conditions as $con) {
1075 if ($con['obligatory']) {
1076 continue;
1077 }
1078
1079 $opt[] = $con;
1080 }
1081 return $opt;
1082 }

References $conditions, and _getPersistedConditionsOfTarget().

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

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

◆ getReferenceHandlingType()

ilConditionHandler::getReferenceHandlingType ( )

get reference handling type

@access public

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

311 {
312 return (int) $this->condition_reference_type;
313 }

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getTargetObjId()

ilConditionHandler::getTargetObjId ( )

get target obj id

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

References $target_obj_id.

Referenced by checkExists(), and storeCondition().

+ Here is the caller graph for this function:

◆ getTargetRefId()

ilConditionHandler::getTargetRefId ( )

get target ref id

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

References $target_ref_id.

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

+ Here is the caller graph for this function:

◆ getTargetType()

ilConditionHandler::getTargetType ( )

get target obj type

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

References $target_type.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ getTriggerObjId()

ilConditionHandler::getTriggerObjId ( )

get trigger obj id

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

References $trigger_obj_id.

Referenced by checkExists(), and storeCondition().

+ Here is the caller graph for this function:

◆ getTriggerRefId()

ilConditionHandler::getTriggerRefId ( )

get target ref id

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

References $trigger_ref_id.

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

+ Here is the caller graph for this function:

◆ getTriggerType()

ilConditionHandler::getTriggerType ( )

get trigger obj type

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

References $trigger_type.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ getValue()

ilConditionHandler::getValue ( )

get value

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

References $value.

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ lookupObligatoryConditionsOfTarget()

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

Lookup obligatory conditions of target.

Parameters
type$a_target_ref_id
type$a_target_obj_id

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

1091 {
1092 global $DIC;
1093
1094 $ilDB = $DIC['ilDB'];
1095
1096 $query = 'SELECT max(num_obligatory) obl from conditions WHERE ' .
1097 'target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
1098 'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer') . ' ' .
1099 'GROUP BY (num_obligatory)';
1100 $res = $ilDB->query($query);
1101
1102 $obl = 0;
1103 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1104 $obl = $row->obl;
1105 }
1106 return $obl;
1107 }

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

Referenced by ilConditionHandlerGUI\showObligatoryForm().

+ Here is the caller graph for this function:

◆ lookupPersistedHiddenStatusByTarget()

static ilConditionHandler::lookupPersistedHiddenStatusByTarget (   $a_target_ref_id)
static

Lookup persistedhidden status.

Parameters
int$a_target_ref_id
Returns
bool

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

199 {
200 global $DIC;
201
202 $ilDB = $DIC['ilDB'];
203
204 $query = 'SELECT hidden_status FROM conditions ' .
205 'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer');
206 $res = $ilDB->query($query);
207 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
208 return $row->hidden_status;
209 }
210 return false;
211 }

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

Referenced by ilConditionHandlerGUI\assign(), and ilConditionHandlerGUI\showObligatoryForm().

+ Here is the caller graph for this function:

◆ preloadPersistedConditionsForTargetRecords()

static ilConditionHandler::preloadPersistedConditionsForTargetRecords (   $a_type,
  $a_obj_ids 
)
static

Preload conditions for target records.

Parameters

return

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

943 {
944 global $DIC;
945
946 $ilDB = $DIC['ilDB'];
947
948 if (is_array($a_obj_ids) && count($a_obj_ids) > 0) {
949 $res = $ilDB->query("SELECT * FROM conditions " .
950 "WHERE " . $ilDB->in("target_obj_id", $a_obj_ids, false, "integer") .
951 " AND target_type = " . $ilDB->quote($a_type, 'text'));
952 $rows = array();
953 while ($row = $ilDB->fetchAssoc($res)) {
954 self::$cond_target_rows[$a_type . ":" . $row["target_obj_id"]][]
955 = $row;
956 }
957 // init obj ids without any record
958 foreach ($a_obj_ids as $obj_id) {
959 if (!is_array(self::$cond_target_rows[$a_type . ":" . $obj_id])) {
960 self::$cond_target_rows[$a_type . ":" . $obj_id] = array();
961 }
962 }
963 }
964 }

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

Referenced by ilObjectListGUIPreloader\preload().

+ Here is the caller graph for this function:

◆ resetCache()

static ilConditionHandler::resetCache ( )
static

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

134 : void
135 {
136 self::$cond_for_target_cache = [];
137 self::$cond_target_rows = [];
138 }

Referenced by calculatePersistedRequiredTriggers().

+ Here is the caller graph for this function:

◆ saveNumberOfRequiredTriggers()

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

Save number of obigatory triggers.

Parameters
int$a_target_ref_id
int$a_target_obj_id

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

1192 {
1193 global $DIC;
1194
1195 $ilDB = $DIC['ilDB'];
1196
1197 $query = 'UPDATE conditions ' .
1198 'SET num_obligatory = ' . $ilDB->quote($a_num, 'integer') . ' ' .
1199 'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
1200 'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer');
1201 $ilDB->manipulate($query);
1202 return;
1203 }

References $DIC, $ilDB, and $query.

Referenced by calculatePersistedRequiredTriggers(), cloneDependencies(), and ilConditionHandlerGUI\saveObligatorySettings().

+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage (   $a_msg)

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

317 {
318 $this->error_message = $a_msg;
319 }

Referenced by validate().

+ Here is the caller graph for this function:

◆ setHiddenStatus()

ilConditionHandler::setHiddenStatus (   $a_status)

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

472 {
473 $this->hidden_status = $a_status;
474 }

◆ setObligatory()

ilConditionHandler::setObligatory (   $a_obl)

Set obligatory status.

Parameters
bool$a_obl

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

458 {
459 $this->obligatory = $a_obl;
460 }

◆ setOperator()

ilConditionHandler::setOperator (   $a_operator)

set operator

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

425 {
426 return $this->operator = $a_operator;
427 }

◆ setReferenceHandlingType()

ilConditionHandler::setReferenceHandlingType (   $a_type)

set reference handling type

Parameters
int@access public

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

300 {
301 return $this->condition_reference_type = $a_type;
302 }

◆ setTargetObjId()

ilConditionHandler::setTargetObjId (   $a_target_obj_id)

set target object id

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

345 {
346 return $this->target_obj_id = $a_target_obj_id;
347 }

◆ setTargetRefId()

ilConditionHandler::setTargetRefId (   $a_target_ref_id)

set target ref id

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

329 {
330 return $this->target_ref_id = $a_target_ref_id;
331 }

◆ setTargetType()

ilConditionHandler::setTargetType (   $a_target_type)

set target object type

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

361 {
362 return $this->target_type = $a_target_type;
363 }

◆ setTriggerObjId()

ilConditionHandler::setTriggerObjId (   $a_trigger_obj_id)

set trigger object id

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

393 {
394 return $this->trigger_obj_id = $a_trigger_obj_id;
395 }

◆ setTriggerRefId()

ilConditionHandler::setTriggerRefId (   $a_trigger_ref_id)

set trigger ref id

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

377 {
378 return $this->trigger_ref_id = $a_trigger_ref_id;
379 }

◆ setTriggerType()

ilConditionHandler::setTriggerType (   $a_trigger_type)

set trigger object type

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

409 {
410 return $this->trigger_type = $a_trigger_type;
411 }

◆ setValue()

ilConditionHandler::setValue (   $a_value)

set value

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

441 {
442 return $this->value = $a_value;
443 }

◆ storeCondition()

ilConditionHandler::storeCondition ( )

store new condition in database

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

591 {
592 global $DIC;
593
594 $ilDB = $DIC['ilDB'];
595
596 // first insert, then validate: it's easier to check for circles if the new condition is in the db table
597 $next_id = $ilDB->nextId('conditions');
598 $query = 'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
599 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
600 'VALUES (' .
601 $ilDB->quote($next_id, 'integer') . ',' .
602 $ilDB->quote($this->getTargetRefId(), 'integer') . "," .
603 $ilDB->quote($this->getTargetObjId(), 'integer') . "," .
604 $ilDB->quote($this->getTargetType(), 'text') . "," .
605 $ilDB->quote($this->getTriggerRefId(), 'integer') . "," .
606 $ilDB->quote($this->getTriggerObjId(), 'integer') . "," .
607 $ilDB->quote($this->getTriggerType(), 'text') . "," .
608 $ilDB->quote($this->getOperator(), 'text') . "," .
609 $ilDB->quote($this->getValue(), 'text') . ", " .
610 $ilDB->quote($this->getReferenceHandlingType(), 'integer') . ', ' .
611 $ilDB->quote($this->getObligatory(), 'integer') . ', ' .
612 $ilDB->quote($this->getHiddenStatus(), 'integer') . ' ' .
613 ')';
614
615 $res = $ilDB->manipulate($query);
616
617 if ($this->validation && !$this->validate()) {
618 $this->deleteCondition($next_id);
619 return false;
620 }
621 return true;
622 }
getTargetType()
get target obj type
getTriggerType()
get trigger obj type
deleteCondition($a_id)
delete condition
getReferenceHandlingType()
get reference handling type
getObligatory()
Get obligatory status.

References $DIC, $ilDB, $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 (   $a_id)

update condition

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

644 {
645 global $DIC;
646
647 $ilDB = $DIC['ilDB'];
648
649 $query = "UPDATE conditions SET " .
650 "target_ref_id = " . $ilDB->quote($this->getTargetRefId(), 'integer') . ", " .
651 "operator = " . $ilDB->quote($this->getOperator(), 'text') . ", " .
652 "value = " . $ilDB->quote($this->getValue(), 'text') . ", " .
653 "ref_handling = " . $this->db->quote($this->getReferenceHandlingType(), 'integer') . ", " .
654 'obligatory = ' . $this->db->quote($this->getObligatory(), 'integer') . ' ' .
655 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
656 $res = $ilDB->manipulate($query);
657
658 return true;
659 }

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

+ Here is the call graph for this function:

◆ updateHiddenStatus()

ilConditionHandler::updateHiddenStatus (   $a_status)

Update hidden status @global type $ilDB.

Parameters
type$a_target_ref_id
type$a_status
Returns
boolean

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

669 {
670 global $DIC;
671
672 $ilDB = $DIC['ilDB'];
673
674 $query = 'UPDATE conditions SET ' .
675 'hidden_status = ' . $ilDB->quote($a_status, 'integer') . ' ' .
676 'WHERE target_ref_id = ' . $ilDB->quote($this->getTargetRefId(), 'integer');
677 $ilDB->manipulate($query);
678 return true;
679 }

References $DIC, $ilDB, $query, and getTargetRefId().

+ Here is the call graph for this function:

◆ updateObligatory()

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

Toggle condition obligatory status.

Parameters
int$a_id
bool$a_status

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

688 {
689 global $DIC;
690
691 $ilDB = $DIC['ilDB'];
692
693 $query = "UPDATE conditions SET " .
694 'obligatory = ' . $ilDB->quote($a_status, 'integer') . ' ' .
695 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
696 $res = $ilDB->manipulate($query);
697
698 return true;
699 }

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 1258 of file class.ilConditionHandler.php.

1259 {
1260 global $DIC;
1261
1262 $ilDB = $DIC['ilDB'];
1263
1264 // check if obj_id is already assigned
1265 $trigger_obj = &ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1266 $target_obj = &ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1267
1268
1269 $query = "SELECT * FROM conditions WHERE " .
1270 "trigger_ref_id = " . $ilDB->quote($trigger_obj->getRefId(), 'integer') . " " .
1271 "AND target_ref_id = " . $ilDB->quote($target_obj->getRefId(), 'integer');
1272
1273 $res = $this->db->query($query);
1274 if ($res->numRows() > 1) {
1275 $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1276
1277 unset($trigger_obj);
1278 unset($target_obj);
1279 return false;
1280 }
1281
1282 // check for circle
1283 $this->target_obj_id = $target_obj->getId();
1284 if ($this->checkCircle($this->getTargetRefId(), $target_obj->getId())) {
1285 $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1286
1287 unset($trigger_obj);
1288 unset($target_obj);
1289 return false;
1290 }
1291 return true;
1292 }
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

References $DIC, $ilDB, $query, $res, checkCircle(), ilObjectFactory\getInstanceByRefId(), getTargetRefId(), getTriggerRefId(), and setErrorMessage().

Referenced by storeCondition().

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

Field Documentation

◆ $cond_for_target_cache

ilConditionHandler::$cond_for_target_cache = array()
static

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

◆ $cond_target_rows

ilConditionHandler::$cond_target_rows = array()
static

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

◆ $conditions

◆ $db

ilConditionHandler::$db

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

Referenced by getNumberOfConditionsOfTrigger().

◆ $error_message

ilConditionHandler::$error_message

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

Referenced by getErrorMessage().

◆ $hidden_status

ilConditionHandler::$hidden_status = false
private

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

Referenced by getHiddenStatus().

◆ $lng

ilConditionHandler::$lng

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

Referenced by __construct().

◆ $obligatory

ilConditionHandler::$obligatory = true
private

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

Referenced by getObligatory().

◆ $operator

ilConditionHandler::$operator

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

Referenced by getOperator().

◆ $target_obj_id

ilConditionHandler::$target_obj_id

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

Referenced by getTargetObjId().

◆ $target_ref_id

ilConditionHandler::$target_ref_id

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

Referenced by getTargetRefId().

◆ $target_type

ilConditionHandler::$target_type

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

Referenced by getTargetType().

◆ $trigger_obj_id

ilConditionHandler::$trigger_obj_id

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

Referenced by getTriggerObjId().

◆ $trigger_ref_id

ilConditionHandler::$trigger_ref_id

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

Referenced by getTriggerRefId().

◆ $trigger_type

ilConditionHandler::$trigger_type

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

Referenced by getTriggerType().

◆ $validation

ilConditionHandler::$validation

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

◆ $value

ilConditionHandler::$value

Definition at line 106 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 84 of file class.ilConditionHandler.php.

Referenced by ilConditionOperatorFactory\notMember().

◆ OPERATOR_PASSED

◆ SHARED_CONDITIONS

const ilConditionHandler::SHARED_CONDITIONS = 0

◆ UNIQUE_CONDITIONS

const ilConditionHandler::UNIQUE_CONDITIONS = 1

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