ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilConditionHandler Class Reference

Handles conditions for accesses to different ILIAS objects. 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...
 
 getTriggerTypes ()
 get all possible trigger types NOT STATIC public More...
 
 getOperatorsByTargetType ($a_type)
 Get operators by target type. More...
 
 storeCondition ()
 store new condition in database NOT STATIC public 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...
 
 validate ()
 
 checkCircle ($a_ref_id, $a_obj_id)
 

Static Public Member Functions

static _isReferenceHandlingOptional ($a_type)
 is reference handling optional More...
 
static lookupHiddenStatusByTarget ($a_target_ref_id)
 Lookup hidden status type $ilDB. 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 _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...
 
static updateObligatory ($a_id, $a_status)
 Toggle condition obligatory status. More...
 
static getNumberOfConditionsOfTrigger ($a_trigger_obj_type, $a_trigger_id)
 
static _getConditionsOfTrigger ($a_trigger_obj_type, $a_trigger_id)
 get all conditions of trigger object More...
 
static _getConditionsOfTarget ($a_target_ref_id, $a_target_obj_id, $a_target_type="")
 get all conditions of target object More...
 
static preloadConditionsForTargetRecords ($a_type, $a_obj_ids)
 Preload conditions for target records. More...
 
static _getCondition ($a_id)
 
static _checkCondition ($a_id, $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 getOptionalConditionsOfTarget ($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 calculateRequiredTriggers ($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()
 

Private Attributes

 $obligatory = true
 
 $hidden_status = false
 

Detailed Description

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" | "qst", ... trigger_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" | "pg", ... target_id object or reference id of target object

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

Constructor & Destructor Documentation

◆ __construct()

ilConditionHandler::__construct ( )

constructor public

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

References $ilDB, $lng, and validation.

109  {
110  global $ilDB,$lng;
111 
112  $this->db =&$ilDB;
113  $this->lng =&$lng;
114  $this->validation = true;
115  }
Set data validation
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 164 of file class.ilConditionHandler.php.

References $conditions.

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

165  {
166  global $tree;
167 
168  if ($tree->checkForParentType($a_ref_id, 'crs')) {
169  // Nothing to do
170  return true;
171  }
172 
173  // Need another implementation that has better performance
174  $childs = $tree->getSubTree($tree->getNodeData($a_ref_id), false);
175  $conditions = self::_getDistinctTargetRefIds();
176 
177  foreach (array_intersect($conditions, $childs) as $target_ref) {
178  if (!$tree->checkForParentType($target_ref, 'crs')) {
179  self::_deleteTargetConditionsByRefId($target_ref);
180  }
181  }
182  return true;
183  }
+ 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 966 of file class.ilConditionHandler.php.

References $conditions, $ilBench, $ilUser, _checkCondition(), _getConditionsOfTarget(), 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().

967  {
968  global $ilBench,$ilUser,$tree;
969 
970  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
971 
972  $conditions = ilConditionHandler::_getConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
973 
974  if (!count($conditions)) {
975  return true;
976  }
977 
978  // @todo check this
979  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
980  if (ilMemberViewSettings::getInstance()->isActive()) {
981  return true;
982  }
983 
984  // First check obligatory conditions
985  $optional = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
986  $num_required = self::calculateRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
987  $passed = 0;
988  foreach ($conditions as $condition) {
989  if ($tree->isDeleted($condition['trigger_ref_id'])) {
990  continue;
991  }
992  $check = ilConditionHandler::_checkCondition($condition['id'], $a_usr_id);
993 
994  if ($check) {
995  ++$passed;
996  if ($passed >= $num_required) {
997  return true;
998  }
999  } else {
1000  if (!count($optional)) {
1001  return false;
1002  }
1003  }
1004  }
1005  // not all optional conditions passed
1006  return false;
1007  }
static _checkCondition($a_id, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
$ilUser
Definition: imgupload.php:18
static getInstance()
Get instance.
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkCondition()

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

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

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

833  {
834  global $ilUser, $objDefinition;
835 
836  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
837 
838  $condition = ilConditionHandler::_getCondition($a_id);
839 
840  // check lp
841  if ($condition['operator'] == self::OPERATOR_LP) {
842  include_once './Services/Tracking/classes/class.ilLPStatus.php';
843  return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
844  }
845 
846  switch ($condition['trigger_type']) {
847  case 'crsg':
848  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
849  return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
850  }
851 
852  $class = $objDefinition->getClassName($condition['trigger_type']);
853  $location = $objDefinition->getLocation($condition['trigger_type']);
854  $full_class = "ilObj" . $class . "Access";
855  include_once($location . "/class." . $full_class . ".php");
856 
857  $fullfilled = call_user_func(
858  array($full_class, 'checkCondition'),
859  $condition['trigger_obj_id'],
860  $condition['operator'],
861  $condition['value'],
862  $a_usr_id
863  );
864  return $fullfilled;
865  }
$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
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteTargetConditionsByRefId()

static ilConditionHandler::_deleteTargetConditionsByRefId (   $a_target_ref_id)
static

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

References $ilDB, $query, and $res.

Referenced by ilRBACTest\testConditions().

215  {
216  global $ilDB;
217 
218  $query = "DELETE FROM conditions " .
219  "WHERE target_ref_id = " . $ilDB->quote($a_target_ref_id, 'integer') . " " .
220  "AND target_type != 'st' ";
221  $res = $ilDB->manipulate($query);
222  return true;
223  }
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 798 of file class.ilConditionHandler.php.

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

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

799  {
800  global $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'] = $row->condition_id;
808  $tmp_array['target_ref_id'] = $row->target_ref_id;
809  $tmp_array['target_obj_id'] = $row->target_obj_id;
810  $tmp_array['target_type'] = $row->target_type;
811  $tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
812  $tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
813  $tmp_array['trigger_type'] = $row->trigger_type;
814  $tmp_array['operator'] = $row->operator;
815  $tmp_array['value'] = $row->value;
816  $tmp_array['ref_handling'] = $row->ref_handling;
817  $tmp_array['obligatory'] = $row->obligatory;
818  $tmp_array['hidden_status'] = $row->hidden_status;
819 
820  return $tmp_array;
821  }
822  return false;
823  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _getConditionsOfTarget()

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

get all conditions of target object

Parameters
$a_target_ref_idtarget reference id
$a_target_obj_idtarget object id
$a_target_typetarget object type (must be provided only if object is not derived from ilObject and therefore stored in object_data; this is e.g. the case for chapters (type = "st"))

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

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

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

719  {
720  global $ilDB, $ilBench;
721 
722  // get type if no type given
723  if ($a_target_type == "") {
724  $a_target_type = ilObject::_lookupType($a_target_obj_id);
725  }
726 
727  // check conditions for target cache
728  if (isset(self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
729  $a_target_type])) {
730  return self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
731  $a_target_type];
732  }
733 
734  // check rows cache
735  if (isset(self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id])) {
736  $rows = self::$cond_target_rows[$a_target_type . ":" . $a_target_obj_id];
737  } else {
738  // query data from db
739  $query = "SELECT * FROM conditions " .
740  "WHERE target_obj_id = " . $ilDB->quote($a_target_obj_id, 'integer') . " " .
741  " AND target_type = " . $ilDB->quote($a_target_type, 'text');
742 
743  $res = $ilDB->query($query);
744  $rows = array();
745  while ($row = $ilDB->fetchAssoc($res)) {
746  $rows[] = $row;
747  }
748  }
749 
750  reset($rows);
751  $conditions = array();
752  foreach ($rows as $row) {
753  if ($row["ref_handling"] == self::UNIQUE_CONDITIONS) {
754  if ($row["target_ref_id"] != $a_target_ref_id) {
755  continue;
756  }
757  }
758 
759  $row["id"] = $row["condition_id"];
760  $conditions[] = $row;
761  }
762 
763  // write conditions for target cache
764  self::$cond_for_target_cache[$a_target_ref_id . ":" . $a_target_obj_id . ":" .
765  $a_target_type] = $conditions;
766 
767  return $conditions;
768  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
$rows
Definition: xhr_table.php:10
global $ilBench
Definition: ilias.php:18
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getConditionsOfTrigger()

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

get all conditions of trigger object

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

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

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

679  {
680  global $ilDB;
681 
682  $query = "SELECT * FROM conditions " .
683  "WHERE trigger_obj_id = " . $ilDB->quote($a_trigger_id, 'integer') . " " .
684  " AND trigger_type = " . $ilDB->quote($a_trigger_obj_type, 'text');
685 
686  $res = $ilDB->query($query);
687  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
688  $tmp_array['id'] = $row->condition_id;
689  $tmp_array['target_ref_id'] = $row->target_ref_id;
690  $tmp_array['target_obj_id'] = $row->target_obj_id;
691  $tmp_array['target_type'] = $row->target_type;
692  $tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
693  $tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
694  $tmp_array['trigger_type'] = $row->trigger_type;
695  $tmp_array['operator'] = $row->operator;
696  $tmp_array['value'] = $row->value;
697  $tmp_array['ref_handling'] = $row->ref_handling;
698  $tmp_array['obligatory'] = $row->obligatory;
699  $tmp_array['hidden_status'] = $row->hidden_status;
700 
701  $conditions[] = $tmp_array;
702  unset($tmp_array);
703  }
704 
705  return $conditions ? $conditions : array();
706  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _getDistinctTargetRefIds()

static ilConditionHandler::_getDistinctTargetRefIds ( )
static

Get all target ref ids.

public

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

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

Referenced by ilRBACTest\testConditions().

193  {
194  global $ilDB;
195 
196  $query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
197  $res = $ilDB->query($query);
198  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
199  $ref_ids[] = $row->ref;
200  }
201  return $ref_ids ? $ref_ids : array();
202  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ 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 125 of file class.ilConditionHandler.php.

References $a_type.

Referenced by ilConditionHandlerGUI\initFormCondition().

126  {
127  switch ($a_type) {
128  case 'st':
129  return true;
130 
131  default:
132  return false;
133  }
134  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ calculateRequiredTriggers()

static ilConditionHandler::calculateRequiredTriggers (   $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 915 of file class.ilConditionHandler.php.

References $ilDB, and $result.

Referenced by ilObjectListGUI\parseConditions(), and ilConditionHandlerGUI\saveObligatoryList().

916  {
917  global $ilDB;
918 
919  // Get all conditions
920  $all = self::_getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
921  $opt = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
922 
923  $set_obl = 0;
924  if (isset($all[0])) {
925  $set_obl = $all[0]['num_obligatory'];
926  }
927 
928  // existing value is valid
929  if ($set_obl > 0 and
930  $set_obl < count($all) and
931  $set_obl > (count($all) - count($opt) + 1)) {
932  return $set_obl;
933  }
934 
935  if (count($opt)) {
936  $result = count($all) - count($opt) + 1;
937  } else {
938  $result = count($all);
939  }
940  if ($a_force_update) {
941  self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $result);
942  }
943  return $result;
944  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ checkCircle()

ilConditionHandler::checkCircle (   $a_ref_id,
  $a_obj_id 
)

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

References _getConditionsOfTarget(), and getOperator().

Referenced by validate().

1045  {
1046  foreach (ilConditionHandler::_getConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
1047  if ($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator()) {
1048  $this->circle = true;
1049  break;
1050  } else {
1051  $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
1052  }
1053  }
1054  return $this->circle;
1055  }
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
checkCircle($a_ref_id, $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 541 of file class.ilConditionHandler.php.

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

542  {
543  global $ilDB;
544 
545  $query = "SELECT * FROM conditions " .
546  "WHERE target_ref_id = " . $ilDB->quote($this->getTargetRefId(), 'integer') . " " .
547  "AND target_obj_id = " . $ilDB->quote($this->getTargetObjId(), 'integer') . " " .
548  "AND trigger_ref_id = " . $ilDB->quote($this->getTriggerRefId(), 'integer') . " " .
549  "AND trigger_obj_id = " . $ilDB->quote($this->getTriggerObjId(), 'integer') . " " .
550  "AND operator = " . $ilDB->quote($this->getOperator(), 'text');
551  $res = $ilDB->query($query);
552 
553  return $res->numRows() ? true : false;
554  }
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 1057 of file class.ilConditionHandler.php.

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

Referenced by ilObject\cloneDependencies().

1058  {
1059  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1060  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1061  $mappings = $cwo->getMappings();
1062 
1063  $valid = 0;
1065  foreach ($conditions as $con) {
1066  if ($mappings[$con['trigger_ref_id']]) {
1067  $newCondition = new ilConditionHandler();
1068 
1069  $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1070  $target_typ = ilObject::_lookupType($target_obj);
1071 
1072  $newCondition->setTargetRefId($a_target_ref_id);
1073  $newCondition->setTargetObjId($target_obj);
1074  $newCondition->setTargetType($target_typ);
1075 
1076  $trigger_ref = $mappings[$con['trigger_ref_id']];
1077  $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1078  $trigger_typ = ilObject::_lookupType($trigger_obj);
1079 
1080  $newCondition->setTriggerRefId($trigger_ref);
1081  $newCondition->setTriggerObjId($trigger_obj);
1082  $newCondition->setTriggerType($trigger_typ);
1083  $newCondition->setOperator($con['operator']);
1084  $newCondition->setValue($con['value']);
1085  $newCondition->setReferenceHandlingType($con['ref_handling']);
1086  $newCondition->setObligatory($con['obligatory']);
1087 
1088  // :TODO: not sure about this
1089  $newCondition->setHiddenStatus(self::lookupHiddenStatusByTarget($a_src_ref_id));
1090 
1091  if ($newCondition->storeCondition()) {
1092  $valid++;
1093  }
1094  }
1095  }
1096  if ($valid) {
1097  $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1098 
1099  // num_obligatory
1100  self::calculateRequiredTriggers($a_target_ref_id, $tgt_obj_id, ilObject::_lookupType($tgt_obj_id), true);
1101  }
1102  }
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
$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
Handles conditions for accesses to different ILIAS objects.
+ 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 614 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

615  {
616  global $ilDB;
617 
618  $query = "DELETE FROM conditions WHERE " .
619  "target_ref_id = " . $ilDB->quote($a_ref_id, 'integer') . " " .
620  "OR trigger_ref_id = " . $ilDB->quote($a_ref_id, 'integer');
621  $res = $ilDB->manipulate($query);
622 
623  return true;
624  }
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 629 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

630  {
631  global $ilDB;
632 
633  $query = "DELETE FROM conditions WHERE " .
634  "target_obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
635  "OR trigger_obj_id = " . $ilDB->quote($a_obj_id, 'integer');
636  $res = $ilDB->manipulate($query);
637 
638  return true;
639  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ deleteCondition()

ilConditionHandler::deleteCondition (   $a_id)

delete condition

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

References $ilDB, $query, and $res.

Referenced by storeCondition().

645  {
646  global $ilDB;
647 
648  $query = "DELETE FROM conditions " .
649  "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
650  $res = $ilDB->manipulate($query);
651 
652  return true;
653  }
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 418 of file class.ilConditionHandler.php.

References validation.

419  {
420  $this->validation = $a_validate;
421  }
Set data validation

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

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

References $error_message.

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

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

References $hidden_status.

Referenced by storeCondition().

410  {
411  return $this->hidden_status;
412  }
+ Here is the caller graph for this function:

◆ getNumberOfConditionsOfTrigger()

static ilConditionHandler::getNumberOfConditionsOfTrigger (   $a_trigger_obj_type,
  $a_trigger_id 
)
static
Parameters
string$a_trigger_obj_type
int$a_trigger_id
Returns
int
Exceptions
ilDatabaseException

Definition at line 661 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().

662  {
663  global $DIC;
664  $db = $DIC->database();
665 
666  $query = 'select count(*) num from conditions ' .
667  'where trigger_obj_id = ' . $db->quote($a_trigger_id, ilDBConstants::T_INTEGER) . ' ' .
668  'and trigger_type = ' . $db->quote($a_trigger_obj_type, ilDBConstants::T_TEXT);
669  $res = $db->query($query);
671  return (int) $row->num;
672  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
+ Here is the caller graph for this function:

◆ getObligatory()

ilConditionHandler::getObligatory ( )

Get obligatory status.

Returns
obligatory status

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

References $obligatory.

Referenced by storeCondition(), and updateCondition().

400  {
401  return (bool) $this->obligatory;
402  }
+ Here is the caller graph for this function:

◆ getOperator()

ilConditionHandler::getOperator ( )

get operator

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

References $operator.

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

366  {
367  return $this->operator;
368  }
+ Here is the caller graph for this function:

◆ getOperatorsByTargetType()

ilConditionHandler::getOperatorsByTargetType (   $a_type)

Get operators by target type.

Parameters
string$a_type
Returns
type

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

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

Referenced by getTriggerTypes().

466  {
467  global $objDefinition;
468 
469  switch ($a_type) {
470  case 'crsg':
471  return array('not_member');
472  }
473 
474  $class = $objDefinition->getClassName($a_type);
475  $location = $objDefinition->getLocation($a_type);
476  $full_class = "ilObj" . $class . "Access";
477  include_once($location . "/class." . $full_class . ".php");
478 
479  include_once './Services/AccessControl/interfaces/interface.ilConditionHandling.php';
480 
481  $reflection = new ReflectionClass($full_class);
482  if (!$reflection->implementsInterface('ilConditionHandling')) {
483  return array();
484  }
485 
486 
487  $operators = call_user_func(
488  array($full_class, 'getConditionOperators'),
489  $a_type
490  );
491 
492  // Add operator lp
493  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
495  // only if object type has lp
496  include_once("Services/Object/classes/class.ilObjectLP.php");
498  array_unshift($operators, self::OPERATOR_LP);
499  }
500  }
501  return $operators;
502  }
$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
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptionalConditionsOfTarget()

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

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

References $conditions, and array.

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

873  {
874  $conditions = self::_getConditionsOfTarget($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 
882  $opt[] = $con;
883  }
884  return $opt;
885  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getReferenceHandlingType()

ilConditionHandler::getReferenceHandlingType ( )

get reference handling type

public

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

Referenced by storeCondition(), and updateCondition().

244  {
245  return (int) $this->condition_reference_type;
246  }
+ Here is the caller graph for this function:

◆ getTargetObjId()

ilConditionHandler::getTargetObjId ( )

get target obj id

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

References $target_obj_id.

Referenced by checkExists(), and storeCondition().

286  {
287  return $this->target_obj_id;
288  }
+ Here is the caller graph for this function:

◆ getTargetRefId()

ilConditionHandler::getTargetRefId ( )

get target ref id

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

References $target_ref_id.

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

270  {
271  return $this->target_ref_id;
272  }
+ Here is the caller graph for this function:

◆ getTargetType()

ilConditionHandler::getTargetType ( )

get target obj type

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

References $target_type.

Referenced by storeCondition().

302  {
303  return $this->target_type;
304  }
+ Here is the caller graph for this function:

◆ getTriggerObjId()

ilConditionHandler::getTriggerObjId ( )

get trigger obj id

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

References $trigger_obj_id.

Referenced by checkExists(), and storeCondition().

334  {
335  return $this->trigger_obj_id;
336  }
+ Here is the caller graph for this function:

◆ getTriggerRefId()

ilConditionHandler::getTriggerRefId ( )

get target ref id

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

References $trigger_ref_id.

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

318  {
319  return $this->trigger_ref_id;
320  }
+ Here is the caller graph for this function:

◆ getTriggerType()

ilConditionHandler::getTriggerType ( )

get trigger obj type

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

References $trigger_type.

Referenced by storeCondition().

350  {
351  return $this->trigger_type;
352  }
+ Here is the caller graph for this function:

◆ getTriggerTypes()

ilConditionHandler::getTriggerTypes ( )

get all possible trigger types NOT STATIC public

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

References $name, $type, array, and getOperatorsByTargetType().

429  {
430  global $objDefinition;
431 
432  $trigger_types = array('crs','exc','tst','sahs', 'svy', 'lm', 'iass', 'prg');
433 
434  foreach ($objDefinition->getPlugins() as $p_type => $p_info) {
435  if (@include_once $p_info['location'] . '/class.ilObj' . $p_info['class_name'] . 'Access.php') {
436  include_once './Services/AccessControl/interfaces/interface.ilConditionHandling.php';
437  $name = 'ilObj' . $p_info['class_name'] . 'Access';
438  $reflection = new ReflectionClass($name);
439  if ($reflection->implementsInterface('ilConditionHandling')) {
440  $trigger_types[] = $p_type;
441  }
442  }
443  }
444 
445 
446  $active_triggers = array();
447  foreach ($trigger_types as $type) {
448  if (count($this->getOperatorsByTargetType($type))) {
449  $active_triggers[] = $type;
450  }
451  }
452 
453 
454 
455 
456  return $active_triggers;
457  }
$type
if($format !==null) $name
Definition: metadata.php:146
Create styles array
The data for the language used.
getOperatorsByTargetType($a_type)
Get operators by target type.
+ Here is the call graph for this function:

◆ getValue()

ilConditionHandler::getValue ( )

get value

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

References $value.

Referenced by storeCondition(), and updateCondition().

382  {
383  return $this->value;
384  }
+ Here is the caller graph for this function:

◆ lookupHiddenStatusByTarget()

static ilConditionHandler::lookupHiddenStatusByTarget (   $a_target_ref_id)
static

Lookup hidden status type $ilDB.

Parameters
type$a_target_ref_id

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

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

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

142  {
143  global $ilDB;
144 
145  $query = 'SELECT hidden_status FROM conditions ' .
146  'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer');
147  $res = $ilDB->query($query);
148  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
149  return $row->hidden_status;
150  }
151  return false;
152  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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 892 of file class.ilConditionHandler.php.

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

Referenced by ilConditionHandlerGUI\showObligatoryForm().

893  {
894  global $ilDB;
895 
896  $query = 'SELECT max(num_obligatory) obl from conditions WHERE ' .
897  'target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
898  'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer') . ' ' .
899  'GROUP BY (num_obligatory)';
900  $res = $ilDB->query($query);
901 
902  $obl = 0;
903  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
904  $obl = $row->obl;
905  }
906  return $obl;
907  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ preloadConditionsForTargetRecords()

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

Preload conditions for target records.

Parameters

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

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

Referenced by ilObjectListGUIPreloader\preload().

777  {
778  global $ilDB;
779 
780  if (is_array($a_obj_ids) && count($a_obj_ids) > 0) {
781  $res = $ilDB->query("SELECT * FROM conditions " .
782  "WHERE " . $ilDB->in("target_obj_id", $a_obj_ids, false, "integer") .
783  " AND target_type = " . $ilDB->quote($a_type, 'text'));
784  $rows = array();
785  while ($row = $ilDB->fetchAssoc($res)) {
786  self::$cond_target_rows[$a_type . ":" . $row["target_obj_id"]][]
787  = $row;
788  }
789  // init obj ids without any record
790  foreach ($a_obj_ids as $obj_id) {
791  if (!is_array(self::$cond_target_rows[$a_type . ":" . $obj_id])) {
792  self::$cond_target_rows[$a_type . ":" . $obj_id] = array();
793  }
794  }
795  }
796  }
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
$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 951 of file class.ilConditionHandler.php.

References $ilDB, and $query.

Referenced by ilConditionHandlerGUI\saveObligatorySettings().

952  {
953  global $ilDB;
954 
955  $query = 'UPDATE conditions ' .
956  'SET num_obligatory = ' . $ilDB->quote($a_num, 'integer') . ' ' .
957  'WHERE target_ref_id = ' . $ilDB->quote($a_target_ref_id, 'integer') . ' ' .
958  'AND target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer');
959  $ilDB->manipulate($query);
960  return;
961  }
$query
global $ilDB
+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage (   $a_msg)

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

Referenced by validate().

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

◆ setHiddenStatus()

ilConditionHandler::setHiddenStatus (   $a_status)

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

405  {
406  $this->hidden_status = $a_status;
407  }

◆ setObligatory()

ilConditionHandler::setObligatory (   $a_obl)

Set obligatory status.

Parameters
bool$a_obl

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

391  {
392  $this->obligatory = $a_obl;
393  }

◆ setOperator()

ilConditionHandler::setOperator (   $a_operator)

set operator

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

358  {
359  return $this->operator = $a_operator;
360  }

◆ setReferenceHandlingType()

ilConditionHandler::setReferenceHandlingType (   $a_type)

set reference handling type

Parameters
intpublic

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

References $a_type.

233  {
234  return $this->condition_reference_type = $a_type;
235  }
$a_type
Definition: workflow.php:92

◆ setTargetObjId()

ilConditionHandler::setTargetObjId (   $a_target_obj_id)

set target object id

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

278  {
279  return $this->target_obj_id = $a_target_obj_id;
280  }

◆ setTargetRefId()

ilConditionHandler::setTargetRefId (   $a_target_ref_id)

set target ref id

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

262  {
263  return $this->target_ref_id = $a_target_ref_id;
264  }

◆ setTargetType()

ilConditionHandler::setTargetType (   $a_target_type)

set target object type

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

294  {
295  return $this->target_type = $a_target_type;
296  }

◆ setTriggerObjId()

ilConditionHandler::setTriggerObjId (   $a_trigger_obj_id)

set trigger object id

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

326  {
327  return $this->trigger_obj_id = $a_trigger_obj_id;
328  }

◆ setTriggerRefId()

ilConditionHandler::setTriggerRefId (   $a_trigger_ref_id)

set trigger ref id

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

310  {
311  return $this->trigger_ref_id = $a_trigger_ref_id;
312  }

◆ setTriggerType()

ilConditionHandler::setTriggerType (   $a_trigger_type)

set trigger object type

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

342  {
343  return $this->trigger_type = $a_trigger_type;
344  }

◆ setValue()

ilConditionHandler::setValue (   $a_value)

set value

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

374  {
375  return $this->value = $a_value;
376  }

◆ storeCondition()

ilConditionHandler::storeCondition ( )

store new condition in database NOT STATIC public

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

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

510  {
511  global $ilDB;
512 
513  // first insert, then validate: it's easier to check for circles if the new condition is in the db table
514  $next_id = $ilDB->nextId('conditions');
515  $query = 'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
516  'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
517  'VALUES (' .
518  $ilDB->quote($next_id, 'integer') . ',' .
519  $ilDB->quote($this->getTargetRefId(), 'integer') . "," .
520  $ilDB->quote($this->getTargetObjId(), 'integer') . "," .
521  $ilDB->quote($this->getTargetType(), 'text') . "," .
522  $ilDB->quote($this->getTriggerRefId(), 'integer') . "," .
523  $ilDB->quote($this->getTriggerObjId(), 'integer') . "," .
524  $ilDB->quote($this->getTriggerType(), 'text') . "," .
525  $ilDB->quote($this->getOperator(), 'text') . "," .
526  $ilDB->quote($this->getValue(), 'text') . ", " .
527  $ilDB->quote($this->getReferenceHandlingType(), 'integer') . ', ' .
528  $ilDB->quote($this->getObligatory(), 'integer') . ', ' .
529  $ilDB->quote($this->getHiddenStatus(), 'integer') . ' ' .
530  ')';
531 
532  $res = $ilDB->manipulate($query);
533 
534  if ($this->validation && !$this->validate()) {
535  $this->deleteCondition($next_id);
536  return false;
537  }
538  return true;
539  }
Set data validation
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 558 of file class.ilConditionHandler.php.

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

559  {
560  global $ilDB;
561 
562  $query = "UPDATE conditions SET " .
563  "target_ref_id = " . $ilDB->quote($this->getTargetRefId(), 'integer') . ", " .
564  "operator = " . $ilDB->quote($this->getOperator(), 'text') . ", " .
565  "value = " . $ilDB->quote($this->getValue(), 'text') . ", " .
566  "ref_handling = " . $this->db->quote($this->getReferenceHandlingType(), 'integer') . ", " .
567  'obligatory = ' . $this->db->quote($this->getObligatory(), 'integer') . ' ' .
568  "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
569  $res = $ilDB->manipulate($query);
570 
571  return true;
572  }
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 581 of file class.ilConditionHandler.php.

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

582  {
583  global $ilDB;
584 
585  $query = 'UPDATE conditions SET ' .
586  'hidden_status = ' . $ilDB->quote($a_status, 'integer') . ' ' .
587  'WHERE target_ref_id = ' . $ilDB->quote($this->getTargetRefId(), 'integer');
588  $ilDB->manipulate($query);
589  return true;
590  }
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 598 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

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

599  {
600  global $ilDB;
601 
602  $query = "UPDATE conditions SET " .
603  'obligatory = ' . $ilDB->quote($a_status, 'integer') . ' ' .
604  "WHERE condition_id = " . $ilDB->quote($a_id, 'integer');
605  $res = $ilDB->manipulate($query);
606 
607  return true;
608  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ validate()

ilConditionHandler::validate ( )

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

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

Referenced by storeCondition().

1011  {
1012  global $ilDB;
1013 
1014  // check if obj_id is already assigned
1015  $trigger_obj =&ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1016  $target_obj =&ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1017 
1018 
1019  $query = "SELECT * FROM conditions WHERE " .
1020  "trigger_ref_id = " . $ilDB->quote($trigger_obj->getRefId(), 'integer') . " " .
1021  "AND target_ref_id = " . $ilDB->quote($target_obj->getRefId(), 'integer');
1022 
1023  $res = $this->db->query($query);
1024  if ($res->numRows() > 1) {
1025  $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1026 
1027  unset($trigger_obj);
1028  unset($target_obj);
1029  return false;
1030  }
1031 
1032  // check for circle
1033  $this->target_obj_id = $target_obj->getId();
1034  if ($this->checkCircle($this->getTargetRefId(), $target_obj->getId())) {
1035  $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1036 
1037  unset($trigger_obj);
1038  unset($target_obj);
1039  return false;
1040  }
1041  return true;
1042  }
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 100 of file class.ilConditionHandler.php.

◆ $cond_target_rows

ilConditionHandler::$cond_target_rows = array()
static

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

◆ $conditions

◆ $db

ilConditionHandler::$db

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

Referenced by getNumberOfConditionsOfTrigger().

◆ $error_message

ilConditionHandler::$error_message

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

Referenced by getErrorMessage().

◆ $hidden_status

ilConditionHandler::$hidden_status = false
private

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

Referenced by getHiddenStatus().

◆ $lng

ilConditionHandler::$lng

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

Referenced by __construct().

◆ $obligatory

ilConditionHandler::$obligatory = true
private

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

Referenced by getObligatory().

◆ $operator

ilConditionHandler::$operator

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

Referenced by getOperator().

◆ $target_obj_id

ilConditionHandler::$target_obj_id

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

Referenced by getTargetObjId().

◆ $target_ref_id

ilConditionHandler::$target_ref_id

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

Referenced by getTargetRefId().

◆ $target_type

ilConditionHandler::$target_type

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

Referenced by getTargetType().

◆ $trigger_obj_id

ilConditionHandler::$trigger_obj_id

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

Referenced by getTriggerObjId().

◆ $trigger_ref_id

ilConditionHandler::$trigger_ref_id

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

Referenced by getTriggerRefId().

◆ $trigger_type

ilConditionHandler::$trigger_type

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

Referenced by getTriggerType().

◆ $validation

ilConditionHandler::$validation

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

◆ $value

ilConditionHandler::$value

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

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