ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 _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 $ilDB
$DIC
Definition: xapitoken.php:46

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

218 {
219 global $DIC;
220
221 return true;
222
223 $tree = $DIC['tree'];
224
225 if ($tree->checkForParentType($a_ref_id, 'crs')) {
226 // Nothing to do
227 return true;
228 }
229
230 // Need another implementation that has better performance
231 $childs = $tree->getSubTree($tree->getNodeData($a_ref_id), false);
233
234 foreach (array_intersect($conditions, $childs) as $target_ref) {
235 if (!$tree->checkForParentType($target_ref, 'crs')) {
237 }
238 }
239 return true;
240 }
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 1200 of file class.ilConditionHandler.php.

1201 {
1202 global $DIC;
1203
1204 $ilUser = $DIC['ilUser'];
1205 $tree = $DIC['tree'];
1206 $logger = $DIC->logger()->ac();
1207
1208 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1209
1210 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1211
1212 if (!count($conditions)) {
1213 return true;
1214 }
1215
1216 // @todo check this
1217 include_once './Services/Container/classes/class.ilMemberViewSettings.php';
1218 if (ilMemberViewSettings::getInstance()->isActive()) {
1219 return true;
1220 }
1221
1222 // First check obligatory conditions
1223 $optional = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1224 $num_required = self::calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1225 $passed = 0;
1226 foreach ($conditions as $condition) {
1227 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1228 continue;
1229 }
1230 $check = ilConditionHandler::_checkCondition($condition, $a_usr_id);
1231
1232 if ($check) {
1233 ++$passed;
1234 } else {
1235 // #0027223 if condition is obligatory => return false
1236 if ($condition['obligatory']) {
1237 return false;
1238 }
1239 }
1240 }
1241 if ($passed >= $num_required) {
1242 return true;
1243 }
1244
1245 // not all optional conditions passed
1246 return false;
1247 }
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 996 of file class.ilConditionHandler.php.

997 {
998 global $DIC;
999
1000 $ilUser = $DIC['ilUser'];
1001 $objDefinition = $DIC['objDefinition'];
1002
1003 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1004
1005 //$condition = ilConditionHandler::_getCondition($a_id);
1006
1007 // check lp
1008 if ($condition['operator'] == self::OPERATOR_LP) {
1009 include_once './Services/Tracking/classes/class.ilLPStatus.php';
1010 return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
1011 }
1012
1013 switch ($condition['trigger_type']) {
1014 case 'crsg':
1015 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
1016 return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
1017 }
1018
1019 $class = $objDefinition->getClassName($condition['trigger_type']);
1020 $location = $objDefinition->getLocation($condition['trigger_type']);
1021 $full_class = "ilObj" . $class . "Access";
1022 include_once($location . "/class." . $full_class . ".php");
1023
1024 $fullfilled = call_user_func(
1025 array($full_class, 'checkCondition'),
1026 $condition['trigger_obj_id'],
1027 $condition['operator'],
1028 $condition['value'],
1029 $a_usr_id
1030 );
1031 return $fullfilled;
1032 }
$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 273 of file class.ilConditionHandler.php.

274 {
275 global $DIC;
276
277 $ilDB = $DIC['ilDB'];
278
279 $query = "DELETE FROM conditions " .
280 "WHERE target_ref_id = " . $ilDB->quote($a_target_ref_id, 'integer') . " " .
281 "AND target_type != 'st' ";
282 $res = $ilDB->manipulate($query);
283 return true;
284 }
$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 960 of file class.ilConditionHandler.php.

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

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

250 {
251 global $DIC;
252
253 $ilDB = $DIC['ilDB'];
254
255 $query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
256 $res = $ilDB->query($query);
257 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
258 $ref_ids[] = $row->ref;
259 }
260 return $ref_ids ? $ref_ids : array();
261 }

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

877 {
878 global $DIC;
879
880 $ilDB = $DIC['ilDB'];
881
882 // get type if no type given
883 if ($a_target_type == "") {
884 $a_target_type = ilObject::_lookupType($a_target_obj_id);
885 }
886
887 // check conditions for target cache
888 if (isset(self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
889 $a_target_type])) {
890 return self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
891 $a_target_type];
892 }
893
894 // check rows cache
895 if (isset(self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id])) {
896 $rows = self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id];
897 } else {
898 // query data from db
899 $query = "SELECT * FROM conditions " .
900 "WHERE target_obj_id = " . $ilDB->quote($a_target_obj_id, 'integer') . " " .
901 " AND target_type = " . $ilDB->quote($a_target_type, 'text');
902
903 $res = $ilDB->query($query);
904 $rows = array();
905 while ($row = $ilDB->fetchAssoc($res)) {
906 $rows[] = $row;
907 }
908 }
909
910 reset($rows);
911 $conditions = array();
912 foreach ($rows as $row) {
913 if ($row["ref_handling"] == self::UNIQUE_CONDITIONS) {
914 if ($row["target_ref_id"] != $a_target_ref_id) {
915 continue;
916 }
917 }
918
919 $row["id"] = $row["condition_id"];
920 $conditions[] = $row;
921 }
922
923 // write conditions for target cache
924 self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
925 $a_target_type] = $conditions;
926
927 return $conditions;
928 }
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 771 of file class.ilConditionHandler.php.

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

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

143 {
144 switch ($a_type) {
145 case 'st':
146 return true;
147
148 default:
149 return false;
150 }
151 }
$a_type
Definition: workflow.php:92

References $a_type.

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

1110 {
1111 global $DIC;
1112
1113 $ilDB = $DIC['ilDB'];
1114
1115 // Get all conditions
1116 $all = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1117 $opt = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1118
1119 $set_obl = 0;
1120 if (isset($all[0])) {
1121 $set_obl = $all[0]['num_obligatory'];
1122 }
1123
1124 // existing value is valid
1125 if ($set_obl > 0 and
1126 $set_obl < count($all) and
1127 $set_obl > (count($all) - count($opt) + 1)) {
1128 return $set_obl;
1129 }
1130
1131 if (count($opt)) {
1132 $result = count($all) - count($opt) + 1;
1133 } else {
1134 $result = count($all);
1135 }
1136 return $result;
1137 }
$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 1145 of file class.ilConditionHandler.php.

1146 {
1147 global $DIC;
1148
1149 $ilDB = $DIC['ilDB'];
1150
1151 // Get all conditions
1152 $all = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1153 $opt = self::getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1154
1155 $set_obl = 0;
1156 if (isset($all[0])) {
1157 $set_obl = $all[0]['num_obligatory'];
1158 }
1159
1160 // existing value is valid
1161 if ($set_obl > 0 and
1162 $set_obl < count($all) and
1163 $set_obl > (count($all) - count($opt) + 1)) {
1164 return $set_obl;
1165 }
1166
1167 if (count($opt)) {
1168 $result = count($all) - count($opt) + 1;
1169 } else {
1170 $result = count($all);
1171 }
1172 if ($a_force_update) {
1173 self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $result);
1174 }
1175 return $result;
1176 }
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(), 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 1286 of file class.ilConditionHandler.php.

1287 {
1288 foreach (ilConditionHandler::_getPersistedConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
1289 if ($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator()) {
1290 $this->circle = true;
1291 break;
1292 } else {
1293 $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
1294 }
1295 }
1296 return $this->circle;
1297 }
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 618 of file class.ilConditionHandler.php.

619 {
620 global $DIC;
621
622 $ilDB = $DIC['ilDB'];
623
624 $query = "SELECT * FROM conditions " .
625 "WHERE target_ref_id = " . $ilDB->quote($this->getTargetRefId(), 'integer') . " " .
626 "AND target_obj_id = " . $ilDB->quote($this->getTargetObjId(), 'integer') . " " .
627 "AND trigger_ref_id = " . $ilDB->quote($this->getTriggerRefId(), 'integer') . " " .
628 "AND trigger_obj_id = " . $ilDB->quote($this->getTriggerObjId(), 'integer') . " " .
629 "AND operator = " . $ilDB->quote($this->getOperator(), 'text');
630 $res = $ilDB->query($query);
631
632 return $res->numRows() ? true : false;
633 }
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(), and getTriggerRefId().

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

1300 {
1301 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1302 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1303 $mappings = $cwo->getMappings();
1304
1305 $valid = 0;
1307 foreach ($conditions as $con) {
1308 if ($mappings[$con['trigger_ref_id']]) {
1309 $newCondition = new ilConditionHandler();
1310
1311 $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1312 $target_typ = ilObject::_lookupType($target_obj);
1313
1314 $newCondition->setTargetRefId($a_target_ref_id);
1315 $newCondition->setTargetObjId($target_obj);
1316 $newCondition->setTargetType($target_typ);
1317
1318 $trigger_ref = $mappings[$con['trigger_ref_id']];
1319 $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1320 $trigger_typ = ilObject::_lookupType($trigger_obj);
1321
1322 $newCondition->setTriggerRefId($trigger_ref);
1323 $newCondition->setTriggerObjId($trigger_obj);
1324 $newCondition->setTriggerType($trigger_typ);
1325 $newCondition->setOperator($con['operator']);
1326 $newCondition->setValue($con['value']);
1327 $newCondition->setReferenceHandlingType($con['ref_handling']);
1328 $newCondition->setObligatory($con['obligatory']);
1329
1330 // :TODO: not sure about this
1331 $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1332
1333 if ($newCondition->storeCondition()) {
1334 $valid++;
1335 }
1336 }
1337 }
1338 if ($valid) {
1339 $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1340
1341 // num_obligatory
1342 self::calculatePersistedRequiredTriggers($a_target_ref_id, $tgt_obj_id, ilObject::_lookupType($tgt_obj_id), true);
1343 }
1344 }
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(), and calculatePersistedRequiredTriggers().

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

700 {
701 global $DIC;
702
703 $ilDB = $DIC['ilDB'];
704
705 $query = "DELETE FROM conditions WHERE " .
706 "target_ref_id = " . $ilDB->quote($a_ref_id, 'integer') . " " .
707 "OR trigger_ref_id = " . $ilDB->quote($a_ref_id, 'integer');
708 $res = $ilDB->manipulate($query);
709
710 return true;
711 }

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

717 {
718 global $DIC;
719
720 $ilDB = $DIC['ilDB'];
721
722 $query = "DELETE FROM conditions WHERE " .
723 "target_obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
724 "OR trigger_obj_id = " . $ilDB->quote($a_obj_id, 'integer');
725 $res = $ilDB->manipulate($query);
726
727 return true;
728 }

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

◆ deleteCondition()

ilConditionHandler::deleteCondition (   $a_id)

delete condition

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

734 {
735 global $DIC;
736
737 $ilDB = $DIC['ilDB'];
738
739 $query = "DELETE FROM conditions " .
740 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
741 $res = $ilDB->manipulate($query);
742
743 return true;
744 }

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

480 {
481 $this->validation = $a_validate;
482 }

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

1042 {
1043 $conditions = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1044
1045 $opt = array();
1046 foreach ($conditions as $con) {
1047 if ($con['obligatory']) {
1048 continue;
1049 }
1050
1051 $opt[] = $con;
1052 }
1053 return $opt;
1054 }

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

References $error_message.

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

755 {
756 global $DIC;
757 $db = $DIC->database();
758
759 $query = 'select count(*) num from conditions ' .
760 'where trigger_obj_id = ' . $db->quote($a_trigger_id, ilDBConstants::T_INTEGER) . ' ' .
761 'and trigger_type = ' . $db->quote($a_trigger_obj_type, ilDBConstants::T_TEXT);
762 $res = $db->query($query);
763 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
764 return (int) $row->num;
765 }

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

461 {
462 return (bool) $this->obligatory;
463 }

References $obligatory.

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getOperator()

ilConditionHandler::getOperator ( )

get operator

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

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

References $a_type, $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 1063 of file class.ilConditionHandler.php.

1064 {
1065 $conditions = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1066
1067 $opt = array();
1068 foreach ($conditions as $con) {
1069 if ($con['obligatory']) {
1070 continue;
1071 }
1072
1073 $opt[] = $con;
1074 }
1075 return $opt;
1076 }

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

305 {
306 return (int) $this->condition_reference_type;
307 }

Referenced by storeCondition(), and updateCondition().

+ Here is the caller graph for this function:

◆ getTargetObjId()

ilConditionHandler::getTargetObjId ( )

get target obj id

Definition at line 346 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 330 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 362 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 394 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 378 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 410 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 442 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 1084 of file class.ilConditionHandler.php.

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

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

193 {
194 global $DIC;
195
196 $ilDB = $DIC['ilDB'];
197
198 $query = 'SELECT hidden_status FROM conditions ' .
199 'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer');
200 $res = $ilDB->query($query);
201 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
202 return $row->hidden_status;
203 }
204 return false;
205 }

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

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

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

Referenced by ilObjectListGUIPreloader\preload().

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

1184 {
1185 global $DIC;
1186
1187 $ilDB = $DIC['ilDB'];
1188
1189 $query = 'UPDATE conditions ' .
1190 'SET num_obligatory = ' . $ilDB->quote($a_num, 'integer') . ' ' .
1191 'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
1192 'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer');
1193 $ilDB->manipulate($query);
1194 return;
1195 }

References $DIC, $ilDB, and $query.

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

+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage (   $a_msg)

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

311 {
312 $this->error_message = $a_msg;
313 }

Referenced by validate().

+ Here is the caller graph for this function:

◆ setHiddenStatus()

ilConditionHandler::setHiddenStatus (   $a_status)

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

466 {
467 $this->hidden_status = $a_status;
468 }

◆ setObligatory()

ilConditionHandler::setObligatory (   $a_obl)

Set obligatory status.

Parameters
bool$a_obl

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

452 {
453 $this->obligatory = $a_obl;
454 }

◆ setOperator()

ilConditionHandler::setOperator (   $a_operator)

set operator

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

419 {
420 return $this->operator = $a_operator;
421 }

◆ setReferenceHandlingType()

ilConditionHandler::setReferenceHandlingType (   $a_type)

set reference handling type

Parameters
int@access public

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

294 {
295 return $this->condition_reference_type = $a_type;
296 }

References $a_type.

◆ setTargetObjId()

ilConditionHandler::setTargetObjId (   $a_target_obj_id)

set target object id

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

339 {
340 return $this->target_obj_id = $a_target_obj_id;
341 }

◆ setTargetRefId()

ilConditionHandler::setTargetRefId (   $a_target_ref_id)

set target ref id

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

323 {
324 return $this->target_ref_id = $a_target_ref_id;
325 }

◆ setTargetType()

ilConditionHandler::setTargetType (   $a_target_type)

set target object type

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

355 {
356 return $this->target_type = $a_target_type;
357 }

◆ setTriggerObjId()

ilConditionHandler::setTriggerObjId (   $a_trigger_obj_id)

set trigger object id

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

387 {
388 return $this->trigger_obj_id = $a_trigger_obj_id;
389 }

◆ setTriggerRefId()

ilConditionHandler::setTriggerRefId (   $a_trigger_ref_id)

set trigger ref id

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

371 {
372 return $this->trigger_ref_id = $a_trigger_ref_id;
373 }

◆ setTriggerType()

ilConditionHandler::setTriggerType (   $a_trigger_type)

set trigger object type

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

403 {
404 return $this->trigger_type = $a_trigger_type;
405 }

◆ setValue()

ilConditionHandler::setValue (   $a_value)

set value

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

435 {
436 return $this->value = $a_value;
437 }

◆ storeCondition()

ilConditionHandler::storeCondition ( )

store new condition in database

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

585 {
586 global $DIC;
587
588 $ilDB = $DIC['ilDB'];
589
590 // first insert, then validate: it's easier to check for circles if the new condition is in the db table
591 $next_id = $ilDB->nextId('conditions');
592 $query = 'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
593 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
594 'VALUES (' .
595 $ilDB->quote($next_id, 'integer') . ',' .
596 $ilDB->quote($this->getTargetRefId(), 'integer') . "," .
597 $ilDB->quote($this->getTargetObjId(), 'integer') . "," .
598 $ilDB->quote($this->getTargetType(), 'text') . "," .
599 $ilDB->quote($this->getTriggerRefId(), 'integer') . "," .
600 $ilDB->quote($this->getTriggerObjId(), 'integer') . "," .
601 $ilDB->quote($this->getTriggerType(), 'text') . "," .
602 $ilDB->quote($this->getOperator(), 'text') . "," .
603 $ilDB->quote($this->getValue(), 'text') . ", " .
604 $ilDB->quote($this->getReferenceHandlingType(), 'integer') . ', ' .
605 $ilDB->quote($this->getObligatory(), 'integer') . ', ' .
606 $ilDB->quote($this->getHiddenStatus(), 'integer') . ' ' .
607 ')';
608
609 $res = $ilDB->manipulate($query);
610
611 if ($this->validation && !$this->validate()) {
612 $this->deleteCondition($next_id);
613 return false;
614 }
615 return true;
616 }
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 637 of file class.ilConditionHandler.php.

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

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

663 {
664 global $DIC;
665
666 $ilDB = $DIC['ilDB'];
667
668 $query = 'UPDATE conditions SET ' .
669 'hidden_status = ' . $ilDB->quote($a_status, 'integer') . ' ' .
670 'WHERE target_ref_id = ' . $ilDB->quote($this->getTargetRefId(), 'integer');
671 $ilDB->manipulate($query);
672 return true;
673 }

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

682 {
683 global $DIC;
684
685 $ilDB = $DIC['ilDB'];
686
687 $query = "UPDATE conditions SET " .
688 'obligatory = ' . $ilDB->quote($a_status, 'integer') . ' ' .
689 "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
690 $res = $ilDB->manipulate($query);
691
692 return true;
693 }

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

1251 {
1252 global $DIC;
1253
1254 $ilDB = $DIC['ilDB'];
1255
1256 // check if obj_id is already assigned
1257 $trigger_obj = &ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1258 $target_obj = &ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1259
1260
1261 $query = "SELECT * FROM conditions WHERE " .
1262 "trigger_ref_id = " . $ilDB->quote($trigger_obj->getRefId(), 'integer') . " " .
1263 "AND target_ref_id = " . $ilDB->quote($target_obj->getRefId(), 'integer');
1264
1265 $res = $this->db->query($query);
1266 if ($res->numRows() > 1) {
1267 $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1268
1269 unset($trigger_obj);
1270 unset($target_obj);
1271 return false;
1272 }
1273
1274 // check for circle
1275 $this->target_obj_id = $target_obj->getId();
1276 if ($this->checkCircle($this->getTargetRefId(), $target_obj->getId())) {
1277 $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1278
1279 unset($trigger_obj);
1280 unset($target_obj);
1281 return false;
1282 }
1283 return true;
1284 }
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: