ILIAS  trunk Revision v11.0_alpha-1862-g4e205cb56d4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilConditionHandler Class Reference

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

+ Collaboration diagram for ilConditionHandler:

Public Member Functions

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

Static Public Member Functions

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

Data Fields

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

Static Public Attributes

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

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

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

Private Attributes

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

Detailed Description

INTERNAL CLASS: Please do not use in consumer code.

Handles conditions for accesses to different ILIAS objects A condition consists of four elements:

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

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

Constructor & Destructor Documentation

◆ __construct()

ilConditionHandler::__construct ( )

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

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

122  {
123  global $DIC;
124 
125  $this->db = $DIC->database();
126  $this->lng = $DIC->language();
127  $this->objDefinition = $DIC['objDefinition'];
128  $this->tree = $DIC->repositoryTree();
129  $this->logger = $DIC->logger()->ac();
130  $this->validation = true;
131  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ _adjustMovedObjectConditions()

static ilConditionHandler::_adjustMovedObjectConditions ( int  $a_ref_id)
static

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

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

Todo:
check if something needs to be done here

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

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

198  : bool
199  {
200  return true;
201  }
+ Here is the caller graph for this function:

◆ _checkAllConditionsOfTarget()

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

checks wether all conditions of a target object are fulfilled

Todo:
check member view passthrough

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

References $check, $DIC, ilMemberViewSettings\getInstance(), and ilTree\isDeleted().

Referenced by ilObjContentObject\_checkPreconditionsOfPage(), ilAccess\doConditionCheck(), ilRepositoryExplorerGUI\getChildsOfNode(), ilObjStudyProgrammeReferenceListGUI\initItem(), ilRepositoryExplorer\isClickable(), ilRepositoryExplorer\showChilds(), and ilCourseContentGUI\showStartObjects().

1017  : bool {
1018  global $DIC;
1019 
1020  $ilUser = $DIC['ilUser'];
1021  $tree = $DIC['tree'];
1022  $logger = $DIC->logger()->ac();
1023 
1024  $a_usr_id = $a_usr_id ?: $ilUser->getId();
1025  $conditions = self::_getEffectiveConditionsOfTarget(
1026  $a_target_ref_id,
1027  $a_target_id,
1028  $a_target_type
1029  );
1030  if (!count($conditions)) {
1031  return true;
1032  }
1033 
1034  if (ilMemberViewSettings::getInstance()->isActive()) {
1035  return true;
1036  }
1037 
1038  // First check obligatory conditions
1039  $optional = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1040  $num_required = self::calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1041  $passed = 0;
1042  foreach ($conditions as $condition) {
1043  if ($tree->isDeleted($condition['trigger_ref_id'])) {
1044  continue;
1045  }
1046  $check = self::_checkCondition($condition, $a_usr_id);
1047 
1048  if ($check) {
1049  ++$passed;
1050  } else {
1051  // #0027223 if condition is obligatory => return false
1052  if ($condition['obligatory']) {
1053  return false;
1054  }
1055  }
1056  }
1057  return $passed >= $num_required;
1058  }
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
global $DIC
Definition: shib_login.php:22
$check
Definition: buildRTE.php:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkCondition()

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

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

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

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

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

830  : bool
831  {
832  global $DIC;
833 
834  $ilUser = $DIC['ilUser'];
835  $objDefinition = $DIC['objDefinition'];
836  $a_usr_id = $a_usr_id ?: $ilUser->getId();
837 
838  // check lp
839  if ($condition['operator'] === self::OPERATOR_LP) {
840  return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
841  }
842  switch ($condition['trigger_type']) {
843  case 'crsg':
845  (int) $condition['trigger_obj_id'],
846  (string) $condition['operator'],
847  (string) $condition['value'],
848  (int) $a_usr_id
849  );
850  }
851  $class = $objDefinition->getClassName($condition['trigger_type']);
852  $location = $objDefinition->getLocation($condition['trigger_type']);
853  $full_class = "ilObj" . $class . "Access";
854 
855  if (!(is_a($full_class, "ilConditionHandling", true))) {
856  return false;
857  }
858 
859  $fullfilled = call_user_func(
860  array($full_class, 'checkCondition'),
861  (int) $condition['trigger_obj_id'],
862  (string) $condition['operator'],
863  (string) $condition['value'],
864  (int) $a_usr_id
865  );
866  return $fullfilled;
867  }
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
$location
Definition: buildRTE.php:22
static _checkCondition(int $trigger_obj_id, string $operator, $value, int $a_usr_id=0)
global $DIC
Definition: shib_login.php:22
getClassName(string $obj_name)
ilObjectDefinition $objDefinition
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteTargetConditionsByRefId()

static ilConditionHandler::_deleteTargetConditionsByRefId ( int  $a_target_ref_id)
staticprotected

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

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

References $DIC, $ilDB, and $res.

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

◆ _getCondition()

static ilConditionHandler::_getCondition ( int  $a_id)
static

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

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

Referenced by ilConditionHandlerGUI\confirmDeleteConditionTrigger(), ilConditionHandlerGUI\edit(), ilConditionHandlerGUI\editConditionTrigger(), ilConditionHandlerGUI\initConditionTriggerForm(), ilConditionHandlerGUI\initFormCondition(), ilConditionHandlerGUI\updateCondition(), and ilConditionHandlerGUI\updateConditionTrigger().

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

◆ _getDistinctTargetRefIds()

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

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

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

206  : array
207  {
208  global $DIC;
209 
210  $ilDB = $DIC['ilDB'];
211 
212  $query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
213  $res = $ilDB->query($query);
214  $ref_ids = [];
215  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
216  $ref_ids[] = (int) $row->ref;
217  }
218  return $ref_ids;
219  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ _getPersistedConditionsOfTarget()

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

get all persisted conditions of target object

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

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

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

Referenced by ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), ilObjContentObject\_getMissingPreconditionsOfPage(), ilObjContentObject\_getMissingPreconditionsTopChapter(), ilConditionHandlerGUI\adjustConditionsAfterDeletion(), ilConditionHandlerGUI\confirmDeleteConditionTrigger(), ilConditionHandlerGUI\getConditionsOfTarget(), ilConditionHandlerGUI\initCompulsoryForm(), ILIAS\Conditions\Configuration\ConditionTriggerProvider\read(), ilConditionHandlerGUI\saveCompulsoryForm(), ilConditionHandlerGUI\saveCompulsoryStatus(), and ilConditionHandlerGUI\showObligatoryForm().

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

◆ _getPersistedConditionsOfTrigger()

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

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

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

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

References $c, $DIC, $ilDB, $location, $obligatory, $res, ilObject\_lookupObjId(), ilObject\_lookupType(), ilDBConstants\FETCHMODE_OBJECT, ilTree\getParentId(), and ILIAS\Repository\int().

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

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

◆ _isReferenceHandlingOptional()

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

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

References $DIC, $location, ilObject\_lookupObjId(), ilObject\_lookupType(), and ilTree\getParentId().

Referenced by ilConditionHandlerGUI\initFormCondition().

142  : bool
143  {
144  return $a_type === 'st';
145  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateEffectiveRequiredTriggers()

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

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

References $DIC, and $ilDB.

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

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

◆ calculatePersistedRequiredTriggers()

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

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

References $DIC, and $ilDB.

Referenced by ilConditionHandlerGUI\saveCompulsoryStatus().

960  : int {
961  global $DIC;
962 
963  $ilDB = $DIC['ilDB'];
964 
965  // Get all conditions
966 
967  self::resetCache();
968  $all = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
969  $opt = self::getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
970 
971  $set_obl = 0;
972  if (isset($all[0])) {
973  $set_obl = $all[0]['num_obligatory'];
974  }
975 
976  // existing value is valid
977  if ($set_obl > 0 &&
978  $set_obl < count($all) &&
979  $set_obl > (count($all) - count($opt) + 1)) {
980  return $set_obl;
981  }
982 
983  if (count($opt)) {
984  $result = count($all) - count($opt) + 1;
985  } else {
986  $result = count($all);
987  }
988  if ($a_force_update) {
989  self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $result);
990  }
991  return $result;
992  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ checkCircle()

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

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

References $circle, and getOperator().

Referenced by validate().

1082  : bool
1083  {
1084  foreach (self::_getPersistedConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
1085  if ($condition['trigger_obj_id'] == $this->target_obj_id && $condition['operator'] === $this->getOperator()) {
1086  $this->circle = true;
1087  break;
1088  }
1089 
1090  $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
1091  }
1092  return $this->circle;
1093  }
checkCircle(int $a_ref_id, int $a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExists()

ilConditionHandler::checkExists ( )

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

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

486  : bool
487  {
488  $query = "SELECT * FROM conditions " .
489  "WHERE target_ref_id = " . $this->db->quote($this->getTargetRefId(), 'integer') . " " .
490  "AND target_obj_id = " . $this->db->quote($this->getTargetObjId(), 'integer') . " " .
491  "AND trigger_ref_id = " . $this->db->quote($this->getTriggerRefId(), 'integer') . " " .
492  "AND trigger_obj_id = " . $this->db->quote($this->getTriggerObjId(), 'integer') . " " .
493  "AND operator = " . $this->db->quote($this->getOperator(), 'text');
494  $res = $this->db->query($query);
495  return (bool) $res->numRows();
496  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ cloneDependencies()

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

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

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

Referenced by ilObject\cloneDependencies().

1095  : void
1096  {
1097  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1098  $mappings = $cwo->getMappings();
1099 
1100  $valid = 0;
1101  $conditions = self::_getPersistedConditionsOfTarget(
1102  $a_src_ref_id,
1103  ilObject::_lookupObjId($a_src_ref_id)
1104  );
1105  foreach ($conditions as $con) {
1106  if ($mappings[$con['trigger_ref_id']] ?? false) {
1107  $newCondition = new ilConditionHandler();
1108 
1109  $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1110  $target_typ = ilObject::_lookupType($target_obj);
1111 
1112  $newCondition->setTargetRefId($a_target_ref_id);
1113  $newCondition->setTargetObjId($target_obj);
1114  $newCondition->setTargetType($target_typ);
1115 
1116  $trigger_ref = $mappings[$con['trigger_ref_id']];
1117  $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1118  $trigger_typ = ilObject::_lookupType($trigger_obj);
1119 
1120  $newCondition->setTriggerRefId($trigger_ref);
1121  $newCondition->setTriggerObjId($trigger_obj);
1122  $newCondition->setTriggerType($trigger_typ);
1123  $newCondition->setOperator($con['operator']);
1124  $newCondition->setValue($con['value']);
1125  $newCondition->setReferenceHandlingType($con['ref_handling']);
1126  $newCondition->setObligatory($con['obligatory']);
1127 
1128  // :TODO: not sure about this
1129  $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1130 
1131  if ($newCondition->storeCondition()) {
1132  $valid++;
1133 
1134  //Copy num_obligatory, to be checked below
1135  self::saveNumberOfRequiredTriggers(
1136  $a_target_ref_id,
1137  $target_obj,
1138  $con['num_obligatory']
1139  );
1140  }
1141  }
1142  }
1143  if ($valid) {
1144  $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1145 
1146  // num_obligatory
1147  self::calculatePersistedRequiredTriggers(
1148  $a_target_ref_id,
1149  $tgt_obj_id,
1150  ilObject::_lookupType($tgt_obj_id),
1151  true
1152  );
1153  }
1154  }
$valid
static _lookupObjId(int $ref_id)
static _getInstance(int $a_copy_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilConditionHandler::delete ( int  $a_ref_id)

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

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

References $res.

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

◆ deleteByObjId()

ilConditionHandler::deleteByObjId ( int  $a_obj_id)

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

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

References $res.

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

◆ deleteCondition()

ilConditionHandler::deleteCondition ( int  $a_id)

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

References $res.

Referenced by storeCondition().

556  : void
557  {
558  $query = "DELETE FROM conditions " .
559  "WHERE condition_id = " . $this->db->quote($a_id, 'integer');
560  $res = $this->db->manipulate($query);
561  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ enableAutomaticValidation()

ilConditionHandler::enableAutomaticValidation ( bool  $a_validate = true)

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

377  : void
378  {
379  $this->validation = $a_validate;
380  }

◆ getEffectiveOptionalConditionsOfTarget()

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

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

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

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

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

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

References $error_message.

254  : string
255  {
256  return $this->error_message;
257  }

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

References $hidden_status.

Referenced by storeCondition().

372  : bool
373  {
374  return $this->hidden_status;
375  }
+ Here is the caller graph for this function:

◆ getNumberOfConditionsOfTrigger()

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

get all conditions of trigger object

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

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

Referenced by ilScormLP\checkSCORMPreconditions().

566  : int
567  {
568  global $DIC;
569  $db = $DIC->database();
570 
571  $query = 'select count(*) num from conditions ' .
572  'where trigger_obj_id = ' . $db->quote($a_trigger_id, ilDBConstants::T_INTEGER) . ' ' .
573  'and trigger_type = ' . $db->quote($a_trigger_obj_type, ilDBConstants::T_TEXT);
574  $res = $db->query($query);
575  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
576  return (int) $row->num;
577  }
$res
Definition: ltiservices.php:66
quote($value, string $type)
global $DIC
Definition: shib_login.php:22
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObligatory()

ilConditionHandler::getObligatory ( )

Get obligatory status.

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

References $obligatory.

Referenced by storeCondition(), and updateCondition().

362  : bool
363  {
364  return $this->obligatory;
365  }
+ Here is the caller graph for this function:

◆ getOperator()

ilConditionHandler::getOperator ( )

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

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

336  : string
337  {
338  return $this->operator;
339  }
+ Here is the caller graph for this function:

◆ getOperatorsByTriggerType()

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

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

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

Referenced by getTriggerTypes().

419  : array
420  {
421  global $DIC;
422 
423  $objDefinition = $DIC['objDefinition'];
424 
425  if ($a_type === 'crsg') {
426  return ['not_member'];
427  }
428 
429  $class = $objDefinition->getClassName($a_type);
431  $full_class = "ilObj" . $class . "Access";
432  $reflection = new ReflectionClass($full_class);
433  if ($reflection->implementsInterface('ilConditionHandling')) {
434  $operators = call_user_func(
435  array($full_class, 'getConditionOperators'),
436  $a_type
437  );
438  } else {
439  $operators = [];
440  }
441 
442  // Add operator lp
444  // only if object type has lp
445 
446  if (ilObjectLP::isSupportedObjectType($a_type)) {
447  array_unshift($operators, self::OPERATOR_LP);
448  }
449  }
450  return $operators;
451  }
static isSupportedObjectType(string $type)
$location
Definition: buildRTE.php:22
global $DIC
Definition: shib_login.php:22
getClassName(string $obj_name)
ilObjectDefinition $objDefinition
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPersistedOptionalConditionsOfTarget()

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

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

Referenced by ilConditionHandlerGUI\adjustConditionsAfterDeletion(), ilConditionHandlerGUI\initCompulsoryForm(), ilConditionHandlerGUI\listConditions(), and ilConditionHandlerGUI\saveCompulsoryForm().

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

◆ getReferenceHandlingType()

ilConditionHandler::getReferenceHandlingType ( )

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

References $condition_reference_type.

Referenced by storeCondition(), and updateCondition().

244  : int
245  {
247  }
+ Here is the caller graph for this function:

◆ getTargetObjId()

ilConditionHandler::getTargetObjId ( )

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

References $target_obj_id.

Referenced by checkExists(), and storeCondition().

274  : int
275  {
276  return $this->target_obj_id;
277  }
+ Here is the caller graph for this function:

◆ getTargetRefId()

ilConditionHandler::getTargetRefId ( )

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

References $target_ref_id.

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

264  : int
265  {
266  return $this->target_ref_id;
267  }
+ Here is the caller graph for this function:

◆ getTargetType()

ilConditionHandler::getTargetType ( )

get target obj type

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

References $target_type.

Referenced by storeCondition().

290  : string
291  {
292  return $this->target_type;
293  }
+ Here is the caller graph for this function:

◆ getTriggerObjId()

ilConditionHandler::getTriggerObjId ( )

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

References $trigger_obj_id.

Referenced by checkExists(), and storeCondition().

310  : int
311  {
312  return $this->trigger_obj_id;
313  }
+ Here is the caller graph for this function:

◆ getTriggerRefId()

ilConditionHandler::getTriggerRefId ( )

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

References $trigger_ref_id.

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

300  : int
301  {
302  return $this->trigger_ref_id;
303  }
+ Here is the caller graph for this function:

◆ getTriggerType()

ilConditionHandler::getTriggerType ( )

get trigger obj type

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

References $trigger_type.

Referenced by storeCondition().

326  : string
327  {
328  return $this->trigger_type;
329  }
+ Here is the caller graph for this function:

◆ getTriggerTypes()

ilConditionHandler::getTriggerTypes ( )

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

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

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

◆ getValue()

ilConditionHandler::getValue ( )

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

References $value.

Referenced by storeCondition(), and updateCondition().

346  : string
347  {
348  return $this->value;
349  }
+ Here is the caller graph for this function:

◆ lookupObligatoryConditionsOfTarget()

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

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

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

Referenced by ilConditionHandlerGUI\adjustConditionsAfterDeletion(), ilConditionHandlerGUI\initCompulsoryForm(), and ilConditionHandlerGUI\showObligatoryForm().

903  : int
904  {
905  global $DIC;
906 
907  $ilDB = $DIC['ilDB'];
908 
909  $query = 'SELECT max(num_obligatory) obl from conditions WHERE ' .
910  'target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
911  'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer') . ' ' .
912  'GROUP BY (num_obligatory)';
913  $res = $ilDB->query($query);
914 
915  $obl = 0;
916  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
917  $obl = (int) $row->obl;
918  }
919  return $obl;
920  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupPersistedHiddenStatusByTarget()

static ilConditionHandler::lookupPersistedHiddenStatusByTarget ( int  $a_target_ref_id)
static

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

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

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

177  : bool
178  {
179  global $DIC;
180 
181  $ilDB = $DIC->database();
182 
183  $query = 'SELECT hidden_status FROM conditions ' .
184  'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer');
185  $res = $ilDB->query($query);
186  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
187  return (bool) $row->hidden_status;
188  }
189  return false;
190  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ preloadPersistedConditionsForTargetRecords()

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

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

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

Referenced by ilObjectListGUIPreloader\preload().

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

◆ resetCache()

static ilConditionHandler::resetCache ( )
static

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

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

◆ saveNumberOfRequiredTriggers()

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

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

References $DIC, and $ilDB.

Referenced by ilConditionHandlerGUI\adjustConditionsAfterDeletion(), and ilConditionHandlerGUI\saveCompulsoryForm().

994  : void
995  {
996  global $DIC;
997 
998  $ilDB = $DIC['ilDB'];
999 
1000  $query = 'UPDATE conditions ' .
1001  'SET num_obligatory = ' . $ilDB->quote($a_num, 'integer') . ' ' .
1002  'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
1003  'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer');
1004 
1005  $ilDB->manipulate($query);
1006  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage ( string  $a_msg)

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

Referenced by validate().

249  : void
250  {
251  $this->error_message = $a_msg;
252  }
+ Here is the caller graph for this function:

◆ setHiddenStatus()

ilConditionHandler::setHiddenStatus ( bool  $a_status)

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

367  : void
368  {
369  $this->hidden_status = $a_status;
370  }

◆ setObligatory()

ilConditionHandler::setObligatory ( bool  $a_obl)

Set obligatory status.

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

354  : void
355  {
356  $this->obligatory = $a_obl;
357  }

◆ setOperator()

ilConditionHandler::setOperator ( string  $a_operator)

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

331  : void
332  {
333  $this->operator = $a_operator;
334  }

◆ setReferenceHandlingType()

ilConditionHandler::setReferenceHandlingType ( int  $a_type)

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

239  : void
240  {
241  $this->condition_reference_type = $a_type;
242  }

◆ setTargetObjId()

ilConditionHandler::setTargetObjId ( int  $a_target_obj_id)

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

269  : void
270  {
271  $this->target_obj_id = $a_target_obj_id;
272  }

◆ setTargetRefId()

ilConditionHandler::setTargetRefId ( int  $a_target_ref_id)

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

259  : void
260  {
261  $this->target_ref_id = $a_target_ref_id;
262  }

◆ setTargetType()

ilConditionHandler::setTargetType ( string  $a_target_type)

set target object type

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

282  : void
283  {
284  $this->target_type = $a_target_type;
285  }

◆ setTriggerObjId()

ilConditionHandler::setTriggerObjId ( int  $a_trigger_obj_id)

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

305  : void
306  {
307  $this->trigger_obj_id = $a_trigger_obj_id;
308  }

◆ setTriggerRefId()

ilConditionHandler::setTriggerRefId ( int  $a_trigger_ref_id)

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

295  : void
296  {
297  $this->trigger_ref_id = $a_trigger_ref_id;
298  }

◆ setTriggerType()

ilConditionHandler::setTriggerType ( string  $a_trigger_type)

set trigger object type

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

318  : void
319  {
320  $this->trigger_type = $a_trigger_type;
321  }

◆ setValue()

ilConditionHandler::setValue ( string  $a_value)

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

341  : void
342  {
343  $this->value = $a_value;
344  }

◆ storeCondition()

ilConditionHandler::storeCondition ( )

store new condition in database

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

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

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

◆ updateCondition()

ilConditionHandler::updateCondition ( int  $a_id)

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

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

498  : void
499  {
500  $query = "UPDATE conditions SET " .
501  "target_ref_id = " . $this->db->quote($this->getTargetRefId(), 'integer') . ", " .
502  "operator = " . $this->db->quote($this->getOperator(), 'text') . ", " .
503  "value = " . $this->db->quote($this->getValue(), 'text') . ", " .
504  "ref_handling = " . $this->db->quote($this->getReferenceHandlingType(), 'integer') . ", " .
505  'obligatory = ' . $this->db->quote($this->getObligatory(), 'integer') . ' ' .
506  "WHERE condition_id = " . $this->db->quote($a_id, 'integer');
507  $res = $this->db->manipulate($query);
508  }
$res
Definition: ltiservices.php:66
getObligatory()
Get obligatory status.
+ Here is the call graph for this function:

◆ updateHiddenStatus()

ilConditionHandler::updateHiddenStatus ( bool  $a_status)

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

References getTargetRefId().

510  : void
511  {
512  $query = 'UPDATE conditions SET ' .
513  'hidden_status = ' . $this->db->quote($a_status, 'integer') . ' ' .
514  'WHERE target_ref_id = ' . $this->db->quote($this->getTargetRefId(), 'integer');
515  $this->db->manipulate($query);
516  }
+ Here is the call graph for this function:

◆ updateObligatory()

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

Toggle condition obligatory status.

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

References $DIC, $ilDB, and $res.

Referenced by ilConditionHandlerGUI\adjustConditionsAfterDeletion(), ilConditionHandlerGUI\saveCompulsoryForm(), and ilConditionHandlerGUI\saveCompulsoryStatus().

521  : void
522  {
523  global $DIC;
524 
525  $ilDB = $DIC->database();
526  $query = "UPDATE conditions SET " .
527  'obligatory = ' . $ilDB->quote($a_status, 'integer') . ' ' .
528  "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
529  $res = $ilDB->manipulate($query);
530  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ validate()

ilConditionHandler::validate ( )
protected

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

References checkCircle(), ilObjectFactory\getInstanceByRefId(), getTargetRefId(), getTriggerRefId(), ILIAS\Repository\lng(), null, and setErrorMessage().

Referenced by storeCondition().

1061  : bool
1062  {
1063  // check if obj_id is already assigned
1064  $trigger_obj = ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1065  $target_obj = ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1066 
1067  if ($trigger_obj !== null && $target_obj !== null) {
1068  // check for circle
1069  $this->target_obj_id = $target_obj->getId();
1070 
1071  if ($this->checkCircle($this->getTargetRefId(), $target_obj->getId())) {
1072  $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1073 
1074  unset($trigger_obj, $target_obj);
1075  return false;
1076  }
1077  return true;
1078  }
1079  return false;
1080  }
checkCircle(int $a_ref_id, int $a_obj_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getInstanceByRefId(int $ref_id, bool $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

◆ $circle

bool ilConditionHandler::$circle = false
private

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

Referenced by checkCircle().

◆ $cond_for_target_cache

array ilConditionHandler::$cond_for_target_cache = array()
static

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

◆ $cond_target_rows

array ilConditionHandler::$cond_target_rows = array()
static

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

◆ $condition_reference_type

int ilConditionHandler::$condition_reference_type = 0
private

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

Referenced by getReferenceHandlingType().

◆ $db

ilDBInterface ilConditionHandler::$db
protected

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

◆ $error_message

string ilConditionHandler::$error_message = ''
protected

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

Referenced by getErrorMessage().

◆ $hidden_status

bool ilConditionHandler::$hidden_status = false
private

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

Referenced by getHiddenStatus().

◆ $lng

ilLanguage ilConditionHandler::$lng
protected

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

◆ $logger

ilLogger ilConditionHandler::$logger
protected

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

◆ $objDefinition

ilObjectDefinition ilConditionHandler::$objDefinition
protected

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

◆ $obligatory

bool ilConditionHandler::$obligatory = true
private

◆ $operator=''

string ilConditionHandler::$operator=''
protected

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

◆ $target_obj_id

int ilConditionHandler::$target_obj_id = 0
protected

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

Referenced by getTargetObjId().

◆ $target_ref_id

int ilConditionHandler::$target_ref_id = 0
protected

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

Referenced by getTargetRefId().

◆ $target_type

string ilConditionHandler::$target_type = ''
protected

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

Referenced by getTargetType().

◆ $tree

ilTree ilConditionHandler::$tree
protected

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

◆ $trigger_obj_id

int ilConditionHandler::$trigger_obj_id = 0
protected

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

Referenced by getTriggerObjId().

◆ $trigger_ref_id

int ilConditionHandler::$trigger_ref_id = 0
protected

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

Referenced by getTriggerRefId().

◆ $trigger_type

string ilConditionHandler::$trigger_type = ''
protected

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

Referenced by getTriggerType().

◆ $validation

bool ilConditionHandler::$validation = true
protected

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

◆ $value

string ilConditionHandler::$value = ''
protected

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

Referenced by getValue().

◆ OPERATOR_ACCREDITED_OR_PASSED

const ilConditionHandler::OPERATOR_ACCREDITED_OR_PASSED = 'accredited_or_passed'

◆ OPERATOR_FAILED

◆ OPERATOR_FINISHED

◆ OPERATOR_LP

const ilConditionHandler::OPERATOR_LP = 'learning_progress'

◆ OPERATOR_NOT_FINISHED

const ilConditionHandler::OPERATOR_NOT_FINISHED = 'not_finished'

◆ OPERATOR_NOT_MEMBER

const ilConditionHandler::OPERATOR_NOT_MEMBER = 'not_member'

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

Referenced by ilConditionOperatorFactory\notMember().

◆ OPERATOR_PASSED

◆ OPERATOR_RESULT_RANGE_PERCENTAGE

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