ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilConditionHandler Class Reference

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

+ Collaboration diagram for ilConditionHandler:

Public Member Functions

 __construct ()
 constructor 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 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 public

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

References $DIC, $ilDB, and $lng.

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: saml.php:7
global $ilDB

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

public

Parameters
intreference id of moved object

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

References $conditions, $DIC, and $tree.

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

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);
232  $conditions = self::_getDistinctTargetRefIds();
233 
234  foreach (array_intersect($conditions, $childs) as $target_ref) {
235  if (!$tree->checkForParentType($target_ref, 'crs')) {
236  self::_deleteTargetConditionsByRefId($target_ref);
237  }
238  }
239  return true;
240  }
global $DIC
Definition: saml.php:7
+ 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.

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

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

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

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

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

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  }
global $DIC
Definition: saml.php:7
$location
Definition: buildRTE.php:44
static _checkCondition($trigger_obj_id, $operator, $value, $a_usr_id=0)
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
$ilUser
Definition: imgupload.php:18
+ 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.

public

Parameters
intref id of target

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

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

Referenced by ilRBACTest\testConditions().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _getCondition()

static ilConditionHandler::_getCondition (   $a_id)
static

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

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _getDistinctTargetRefIds()

static ilConditionHandler::_getDistinctTargetRefIds ( )
staticprotected

Get all target ref ids.

public

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

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

Referenced by ilRBACTest\testConditions().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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.

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
static _lookupType($a_id, $a_reference=false)
lookup object type
$row
$rows
Definition: xhr_table.php:10
global $ilDB
+ 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.

References $c, $conditions, $DIC, $ilDB, $location, $obligatory, $query, $res, $row, $tree, ilObject\_lookupObjId(), ilObject\_lookupType(), and ilDBConstants\FETCHMODE_OBJECT.

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isReferenceHandlingOptional()

static ilConditionHandler::_isReferenceHandlingOptional (   $a_type)
static

is reference handling optional

public

Parameters
stringtarget type ILIAS obj type

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

References $a_type, $DIC, $location, $tree, ilObject\_lookupObjId(), and ilObject\_lookupType().

Referenced by ilConditionHandlerGUI\initFormCondition().

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
+ Here is the call graph for this function:
+ 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.

References $DIC, $ilDB, and $result.

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

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
global $DIC
Definition: saml.php:7
global $ilDB
+ 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.

References $DIC, $ilDB, and $result.

Referenced by ilConditionHandlerGUI\saveObligatoryList().

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  }
$result
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ checkCircle()

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

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

References _getPersistedConditionsOfTarget(), and getOperator().

Referenced by validate().

1284  {
1285  foreach (ilConditionHandler::_getPersistedConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
1286  if ($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator()) {
1287  $this->circle = true;
1288  break;
1289  } else {
1290  $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
1291  }
1292  }
1293  return $this->circle;
1294  }
checkCircle($a_ref_id, $a_obj_id)
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
+ 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.

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

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  }
global $DIC
Definition: saml.php:7
getTriggerRefId()
get target ref id
getTargetRefId()
get target ref id
getTargetObjId()
get target obj id
foreach($_POST as $key=> $value) $res
getTriggerObjId()
get trigger obj id
$query
global $ilDB
+ 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 1296 of file class.ilConditionHandler.php.

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

Referenced by ilObject\cloneDependencies().

1297  {
1298  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1299  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1300  $mappings = $cwo->getMappings();
1301 
1302  $valid = 0;
1304  foreach ($conditions as $con) {
1305  if ($mappings[$con['trigger_ref_id']]) {
1306  $newCondition = new ilConditionHandler();
1307 
1308  $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1309  $target_typ = ilObject::_lookupType($target_obj);
1310 
1311  $newCondition->setTargetRefId($a_target_ref_id);
1312  $newCondition->setTargetObjId($target_obj);
1313  $newCondition->setTargetType($target_typ);
1314 
1315  $trigger_ref = $mappings[$con['trigger_ref_id']];
1316  $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1317  $trigger_typ = ilObject::_lookupType($trigger_obj);
1318 
1319  $newCondition->setTriggerRefId($trigger_ref);
1320  $newCondition->setTriggerObjId($trigger_obj);
1321  $newCondition->setTriggerType($trigger_typ);
1322  $newCondition->setOperator($con['operator']);
1323  $newCondition->setValue($con['value']);
1324  $newCondition->setReferenceHandlingType($con['ref_handling']);
1325  $newCondition->setObligatory($con['obligatory']);
1326 
1327  // :TODO: not sure about this
1328  $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1329 
1330  if ($newCondition->storeCondition()) {
1331  $valid++;
1332  }
1333  }
1334  }
1335  if ($valid) {
1336  $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1337 
1338  // num_obligatory
1339  self::calculatePersistedRequiredTriggers($a_target_ref_id, $tgt_obj_id, ilObject::_lookupType($tgt_obj_id), true);
1340  }
1341  }
$valid
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
INTERNAL CLASS: Please do not use in consumer code.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
+ 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.

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ 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.

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ deleteCondition()

ilConditionHandler::deleteCondition (   $a_id)

delete condition

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

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

Referenced by storeCondition().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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.

References $DIC, $name, $t, $type, ilObjUserTracking\_enabledLearningProgress(), getOperatorsByTriggerType(), and ilObjectLP\isSupportedObjectType().

480  {
481  $this->validation = $a_validate;
482  }
+ Here is the call graph for this function:

◆ 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.

References $conditions.

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

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  }
+ Here is the caller graph for this function:

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

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

References $error_message.

315  {
316  return $this->error_message;
317  }

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

References $hidden_status.

Referenced by storeCondition().

471  {
472  return $this->hidden_status;
473  }
+ 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.

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

Referenced by ilScormLP\checkSCORMPreconditions().

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);
764  return (int) $row->num;
765  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
+ 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.

References $obligatory.

Referenced by storeCondition(), and updateCondition().

461  {
462  return (bool) $this->obligatory;
463  }
+ 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().

427  {
428  return $this->operator;
429  }
+ 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.

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

Referenced by enableAutomaticValidation().

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  }
global $DIC
Definition: saml.php:7
$location
Definition: buildRTE.php:44
static isSupportedObjectType($a_type)
$a_type
Definition: workflow.php:92
static _enabledLearningProgress()
check wether learing progress is enabled or not
+ Here is the call graph for this function:
+ Here is the caller 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.

References $conditions.

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

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  }
+ Here is the caller graph for this function:

◆ getReferenceHandlingType()

ilConditionHandler::getReferenceHandlingType ( )

get reference handling type

public

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

Referenced by storeCondition(), and updateCondition().

305  {
306  return (int) $this->condition_reference_type;
307  }
+ 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().

347  {
348  return $this->target_obj_id;
349  }
+ 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().

331  {
332  return $this->target_ref_id;
333  }
+ 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().

363  {
364  return $this->target_type;
365  }
+ 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().

395  {
396  return $this->trigger_obj_id;
397  }
+ 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().

379  {
380  return $this->trigger_ref_id;
381  }
+ 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().

411  {
412  return $this->trigger_type;
413  }
+ 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().

443  {
444  return $this->value;
445  }
+ 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.

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

Referenced by ilConditionHandlerGUI\showObligatoryForm().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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.

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ preloadPersistedConditionsForTargetRecords()

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

Preload conditions for target records.

Parameters

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

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

Referenced by ilObjectListGUIPreloader\preload().

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  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
$row
$rows
Definition: xhr_table.php:10
global $ilDB
+ 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.

References $DIC, $ilDB, and $query.

Referenced by ilConditionHandlerGUI\saveObligatorySettings().

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  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage (   $a_msg)

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

Referenced by validate().

311  {
312  $this->error_message = $a_msg;
313  }
+ 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
intpublic

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

References $a_type.

294  {
295  return $this->condition_reference_type = $a_type;
296  }
$a_type
Definition: workflow.php:92

◆ 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.

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

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  }
global $DIC
Definition: saml.php:7
getTriggerRefId()
get target ref id
getObligatory()
Get obligatory status.
getReferenceHandlingType()
get reference handling type
getTargetRefId()
get target ref id
getTargetObjId()
get target obj id
foreach($_POST as $key=> $value) $res
getTriggerObjId()
get trigger obj id
$query
getTriggerType()
get trigger obj type
global $ilDB
deleteCondition($a_id)
delete condition
getTargetType()
get target obj type
+ Here is the call graph for this function:

◆ updateCondition()

ilConditionHandler::updateCondition (   $a_id)

update condition

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

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

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  }
global $DIC
Definition: saml.php:7
getObligatory()
Get obligatory status.
getReferenceHandlingType()
get reference handling type
getTargetRefId()
get target ref id
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ updateHiddenStatus()

ilConditionHandler::updateHiddenStatus (   $a_status)

Update hidden status type $ilDB.

Parameters
type$a_target_ref_id
type$a_status
Returns
boolean

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

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

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  }
global $DIC
Definition: saml.php:7
getTargetRefId()
get target ref id
$query
global $ilDB
+ 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.

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ validate()

ilConditionHandler::validate ( )
protected

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

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

Referenced by storeCondition().

1248  {
1249  global $DIC;
1250 
1251  $ilDB = $DIC['ilDB'];
1252 
1253  // check if obj_id is already assigned
1254  $trigger_obj = &ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1255  $target_obj = &ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1256 
1257 
1258  $query = "SELECT * FROM conditions WHERE " .
1259  "trigger_ref_id = " . $ilDB->quote($trigger_obj->getRefId(), 'integer') . " " .
1260  "AND target_ref_id = " . $ilDB->quote($target_obj->getRefId(), 'integer');
1261 
1262  $res = $this->db->query($query);
1263  if ($res->numRows() > 1) {
1264  $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1265 
1266  unset($trigger_obj);
1267  unset($target_obj);
1268  return false;
1269  }
1270 
1271  // check for circle
1272  $this->target_obj_id = $target_obj->getId();
1273  if ($this->checkCircle($this->getTargetRefId(), $target_obj->getId())) {
1274  $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1275 
1276  unset($trigger_obj);
1277  unset($target_obj);
1278  return false;
1279  }
1280  return true;
1281  }
global $DIC
Definition: saml.php:7
getTriggerRefId()
get target ref id
getTargetRefId()
get target ref id
foreach($_POST as $key=> $value) $res
$query
checkCircle($a_ref_id, $a_obj_id)
global $ilDB
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ 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

◆ $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: