ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 _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 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 107 of file class.ilConditionHandler.php.

References $ilDB, $lng, and validation.

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

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

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

References $ilBench, $ilUser, _checkCondition(), _getConditionsOfTarget(), and ilMemberViewSettings\getInstance().

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

989  {
990  global $ilBench,$ilUser,$tree;
991 
992  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
993 
994  $conditions = ilConditionHandler::_getConditionsOfTarget($a_target_ref_id,$a_target_id, $a_target_type);
995 
996  if(!count($conditions))
997  {
998  return true;
999  }
1000 
1001  // @todo check this
1002  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
1003  if(ilMemberViewSettings::getInstance()->isActive())
1004  {
1005  return true;
1006  }
1007 
1008  // First check obligatory conditions
1009  $optional = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1010  $num_required = self::calculateRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1011  $passed = 0;
1012  foreach($conditions as $condition)
1013  {
1014  if($tree->isDeleted($condition['trigger_ref_id']))
1015  {
1016  continue;
1017  }
1018  $check = ilConditionHandler::_checkCondition($condition['id'],$a_usr_id);
1019 
1020  if($check)
1021  {
1022  ++$passed;
1023  if($passed >= $num_required)
1024  {
1025  return true;
1026  }
1027  }
1028  else
1029  {
1030  if(!count($optional))
1031  {
1032  return false;
1033  }
1034  }
1035  }
1036  // not all optional conditions passed
1037  return false;
1038  }
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 843 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().

844  {
845  global $ilUser, $objDefinition;
846 
847  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
848 
849  $condition = ilConditionHandler::_getCondition($a_id);
850 
851  // check lp
852  if($condition['operator'] == self::OPERATOR_LP)
853  {
854  include_once './Services/Tracking/classes/class.ilLPStatus.php';
855  return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
856  }
857 
858  switch($condition['trigger_type'])
859  {
860  case 'crsg':
861  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
862  return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value'],$a_usr_id);
863  }
864 
865  $class = $objDefinition->getClassName($condition['trigger_type']);
866  $location = $objDefinition->getLocation($condition['trigger_type']);
867  $full_class = "ilObj".$class."Access";
868  include_once($location."/class.".$full_class.".php");
869 
870  $fullfilled = call_user_func(
871  array($full_class, 'checkCondition'),
872  $condition['trigger_obj_id'],
873  $condition['operator'],
874  $condition['value'],
875  $a_usr_id
876  );
877  return $fullfilled;
878  }
static _checkCondition($trigger_obj_id, $operator,$value, $a_usr_id=0)
$location
Definition: buildRTE.php:44
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 219 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

Referenced by ilRBACTest\testConditions().

220  {
221  global $ilDB;
222 
223  $query = "DELETE FROM conditions ".
224  "WHERE target_ref_id = ".$ilDB->quote($a_target_ref_id,'integer')." ".
225  "AND target_type != 'st' ";
226  $res = $ilDB->manipulate($query);
227  return true;
228  }
global $ilDB
+ Here is the caller graph for this function:

◆ _getCondition()

static ilConditionHandler::_getCondition (   $a_id)
static

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

809  {
810  global $ilDB;
811 
812  $query = "SELECT * FROM conditions ".
813  "WHERE condition_id = ".$ilDB->quote($a_id,'integer');
814 
815  $res = $ilDB->query($query);
816  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
817  {
818  $tmp_array['id'] = $row->condition_id;
819  $tmp_array['target_ref_id'] = $row->target_ref_id;
820  $tmp_array['target_obj_id'] = $row->target_obj_id;
821  $tmp_array['target_type'] = $row->target_type;
822  $tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
823  $tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
824  $tmp_array['trigger_type'] = $row->trigger_type;
825  $tmp_array['operator'] = $row->operator;
826  $tmp_array['value'] = $row->value;
827  $tmp_array['ref_handling'] = $row->ref_handling;
828  $tmp_array['obligatory'] = $row->obligatory;
829  $tmp_array['hidden_status'] = $row->hidden_status;
830 
831  return $tmp_array;
832  }
833  return false;
834  }
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 715 of file class.ilConditionHandler.php.

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

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

716  {
717  global $ilDB, $ilBench;
718 
719  // get type if no type given
720  if ($a_target_type == "")
721  {
722  $a_target_type = ilObject::_lookupType($a_target_obj_id);
723  }
724 
725  // check conditions for target cache
726  if (isset(self::$cond_for_target_cache[$a_target_ref_id.":".$a_target_obj_id.":".
727  $a_target_type]))
728  {
729  return self::$cond_for_target_cache[$a_target_ref_id.":".$a_target_obj_id.":".
730  $a_target_type];
731  }
732 
733  // check rows cache
734  if (isset(self::$cond_target_rows[$a_target_type.":".$a_target_obj_id]))
735  {
736  $rows = self::$cond_target_rows[$a_target_type.":".$a_target_obj_id];
737  }
738  else
739  {
740  // query data from db
741  $query = "SELECT * FROM conditions ".
742  "WHERE target_obj_id = ".$ilDB->quote($a_target_obj_id,'integer')." ".
743  " AND target_type = ".$ilDB->quote($a_target_type,'text');
744 
745  $res = $ilDB->query($query);
746  $rows = array();
747  while ($row = $ilDB->fetchAssoc($res))
748  {
749  $rows[] = $row;
750  }
751  }
752 
753  reset($rows);
754  $conditions = array();
755  foreach ($rows as $row)
756  {
757  if ($row["ref_handling"] == self::UNIQUE_CONDITIONS)
758  {
759  if ($row["target_ref_id"] != $a_target_ref_id)
760  {
761  continue;
762  }
763  }
764 
765  $row["id"] = $row["condition_id"];
766  $conditions[] = $row;
767  }
768 
769  // write conditions for target cache
770  self::$cond_for_target_cache[$a_target_ref_id.":".$a_target_obj_id.":".
771  $a_target_type] = $conditions;
772 
773  return $conditions;
774  }
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
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 674 of file class.ilConditionHandler.php.

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

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

675  {
676  global $ilDB;
677 
678  $query = "SELECT * FROM conditions ".
679  "WHERE trigger_obj_id = ".$ilDB->quote($a_trigger_id,'integer')." ".
680  " AND trigger_type = ".$ilDB->quote($a_trigger_obj_type,'text');
681 
682  $res = $ilDB->query($query);
683  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
684  {
685  $tmp_array['id'] = $row->condition_id;
686  $tmp_array['target_ref_id'] = $row->target_ref_id;
687  $tmp_array['target_obj_id'] = $row->target_obj_id;
688  $tmp_array['target_type'] = $row->target_type;
689  $tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
690  $tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
691  $tmp_array['trigger_type'] = $row->trigger_type;
692  $tmp_array['operator'] = $row->operator;
693  $tmp_array['value'] = $row->value;
694  $tmp_array['ref_handling'] = $row->ref_handling;
695  $tmp_array['obligatory'] = $row->obligatory;
696  $tmp_array['hidden_status'] = $row->hidden_status;
697 
698  $conditions[] = $tmp_array;
699  unset($tmp_array);
700  }
701 
702  return $conditions ? $conditions : array();
703  }
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 196 of file class.ilConditionHandler.php.

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

Referenced by ilRBACTest\testConditions().

197  {
198  global $ilDB;
199 
200  $query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
201  $res = $ilDB->query($query);
202  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
203  {
204  $ref_ids[] = $row->ref;
205  }
206  return $ref_ids ? $ref_ids : array();
207  }
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 124 of file class.ilConditionHandler.php.

References $a_type.

Referenced by ilConditionHandlerGUI\initFormCondition().

125  {
126  switch($a_type)
127  {
128  case 'st':
129  return true;
130 
131  default:
132  return false;
133  }
134  }
$a_type
Definition: workflow.php:93
+ 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 931 of file class.ilConditionHandler.php.

References $ilDB, and $result.

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

932  {
933  global $ilDB;
934 
935  // Get all conditions
936  $all = self::_getConditionsOfTarget($a_target_ref_id,$a_target_obj_id,$a_target_obj_type);
937  $opt = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id,$a_target_obj_type);
938 
939  $set_obl = 0;
940  if(isset($all[0]))
941  {
942  $set_obl = $all[0]['num_obligatory'];
943  }
944 
945  // existing value is valid
946  if($set_obl > 0 and
947  $set_obl < count($all) and
948  $set_obl > (count($all) - count($opt) + 1))
949  {
950  return $set_obl;
951  }
952 
953  if(count($opt))
954  {
955  $result = count($all) - count($opt) + 1;
956  }
957  else
958  {
959  $result = count($all);
960  }
961  if($a_force_update)
962  {
963  self::saveNumberOfRequiredTriggers($a_target_ref_id,$a_target_obj_id,$result);
964  }
965  return $result;
966  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ checkCircle()

ilConditionHandler::checkCircle (   $a_ref_id,
  $a_obj_id 
)

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

References _getConditionsOfTarget(), and getOperator().

Referenced by validate().

1078  {
1079  foreach(ilConditionHandler::_getConditionsOfTarget($a_ref_id,$a_obj_id) as $condition)
1080  {
1081  if($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator())
1082  {
1083  $this->circle = true;
1084  break;
1085  }
1086  else
1087  {
1088  $this->checkCircle($condition['trigger_ref_id'],$condition['trigger_obj_id']);
1089  }
1090  }
1091  return $this->circle;
1092  }
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 556 of file class.ilConditionHandler.php.

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

557  {
558  global $ilDB;
559 
560  $query = "SELECT * FROM conditions ".
561  "WHERE target_ref_id = ".$ilDB->quote($this->getTargetRefId(),'integer')." ".
562  "AND target_obj_id = ".$ilDB->quote($this->getTargetObjId(),'integer')." ".
563  "AND trigger_ref_id = ".$ilDB->quote($this->getTriggerRefId(),'integer')." ".
564  "AND trigger_obj_id = ".$ilDB->quote($this->getTriggerObjId(),'integer')." ".
565  "AND operator = ".$ilDB->quote($this->getOperator(),'text');
566  $res = $ilDB->query($query);
567 
568  return $res->numRows() ? true : false;
569  }
getTriggerRefId()
get target ref id
getTargetRefId()
get target ref id
getTargetObjId()
get target obj id
getTriggerObjId()
get trigger obj id
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 1094 of file class.ilConditionHandler.php.

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

Referenced by ilObject\cloneDependencies().

1095  {
1096  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1097  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1098  $mappings = $cwo->getMappings();
1099 
1100  $valid = 0;
1102  foreach($conditions as $con)
1103  {
1104  if($mappings[$con['trigger_ref_id']])
1105  {
1106  $newCondition = new ilConditionHandler();
1107 
1108  $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1109  $target_typ = ilObject::_lookupType($target_obj);
1110 
1111  $newCondition->setTargetRefId($a_target_ref_id);
1112  $newCondition->setTargetObjId($target_obj);
1113  $newCondition->setTargetType($target_typ);
1114 
1115  $trigger_ref = $mappings[$con['trigger_ref_id']];
1116  $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1117  $trigger_typ = ilObject::_lookupType($trigger_obj);
1118 
1119  $newCondition->setTriggerRefId($trigger_ref);
1120  $newCondition->setTriggerObjId($trigger_obj);
1121  $newCondition->setTriggerType($trigger_typ);
1122  $newCondition->setOperator($con['operator']);
1123  $newCondition->setValue($con['value']);
1124  $newCondition->setReferenceHandlingType($con['ref_handling']);
1125  $newCondition->setObligatory($con['obligatory']);
1126 
1127  // :TODO: not sure about this
1128  $newCondition->setHiddenStatus(self::lookupHiddenStatusByTarget($a_src_ref_id));
1129 
1130  if($newCondition->storeCondition())
1131  {
1132  $valid++;
1133  }
1134  }
1135  }
1136  if($valid)
1137  {
1138  $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1139 
1140  // num_obligatory
1141  self::calculateRequiredTriggers($a_target_ref_id, $tgt_obj_id, ilObject::_lookupType($tgt_obj_id), true);
1142  }
1143  }
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 629 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

630  {
631  global $ilDB;
632 
633  $query = "DELETE FROM conditions WHERE ".
634  "target_ref_id = ".$ilDB->quote($a_ref_id,'integer')." ".
635  "OR trigger_ref_id = ".$ilDB->quote($a_ref_id,'integer');
636  $res = $ilDB->manipulate($query);
637 
638  return true;
639  }
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 644 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

645  {
646  global $ilDB;
647 
648  $query = "DELETE FROM conditions WHERE ".
649  "target_obj_id = ".$ilDB->quote($a_obj_id,'integer')." ".
650  "OR trigger_obj_id = ".$ilDB->quote($a_obj_id,'integer');
651  $res = $ilDB->manipulate($query);
652 
653  return true;
654  }
global $ilDB

◆ deleteCondition()

ilConditionHandler::deleteCondition (   $a_id)

delete condition

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

References $ilDB, $query, and $res.

Referenced by storeCondition().

660  {
661  global $ilDB;
662 
663  $query = "DELETE FROM conditions ".
664  "WHERE condition_id = ".$ilDB->quote($a_id,'integer');
665  $res = $ilDB->manipulate($query);
666 
667  return true;
668  }
global $ilDB
+ Here is the caller graph for this function:

◆ enableAutomaticValidation()

ilConditionHandler::enableAutomaticValidation (   $a_validate = true)

enable automated validation

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

References validation.

424  {
425  $this->validation = $a_validate;
426  }
Set data validation

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

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

References $error_message.

259  {
260  return $this->error_message;
261  }

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

References $hidden_status.

Referenced by storeCondition().

415  {
416  return $this->hidden_status;
417  }
+ Here is the caller graph for this function:

◆ getObligatory()

ilConditionHandler::getObligatory ( )

Get obligatory status.

Returns
obligatory status

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

References $obligatory.

Referenced by storeCondition(), and updateCondition().

405  {
406  return (bool) $this->obligatory;
407  }
+ Here is the caller graph for this function:

◆ getOperator()

ilConditionHandler::getOperator ( )

get operator

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

References $operator.

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

371  {
372  return $this->operator;
373  }
+ 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 475 of file class.ilConditionHandler.php.

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

Referenced by getTriggerTypes().

476  {
477  global $objDefinition;
478 
479  switch($a_type)
480  {
481  case 'crsg':
482  return array('not_member');
483  }
484 
485  $class = $objDefinition->getClassName($a_type);
486  $location = $objDefinition->getLocation($a_type);
487  $full_class = "ilObj".$class."Access";
488  include_once($location."/class.".$full_class.".php");
489 
490  include_once './Services/AccessControl/interfaces/interface.ilConditionHandling.php';
491 
492  $reflection = new ReflectionClass($full_class);
493  if(!$reflection->implementsInterface('ilConditionHandling'))
494  {
495  return array();
496  }
497 
498 
499  $operators = call_user_func(
500  array($full_class, 'getConditionOperators'),
501  $a_type
502  );
503 
504  // Add operator lp
505  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
507  {
508  // only if object type has lp
509  include_once("Services/Object/classes/class.ilObjectLP.php");
511  {
512  array_unshift($operators,self::OPERATOR_LP);
513  }
514  }
515  return $operators;
516  }
$location
Definition: buildRTE.php:44
static isSupportedObjectType($a_type)
$a_type
Definition: workflow.php:93
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 885 of file class.ilConditionHandler.php.

References array.

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

886  {
887  $conditions = self::_getConditionsOfTarget($a_target_ref_id,$a_target_obj_id);
888 
889  $opt = array();
890  foreach($conditions as $con)
891  {
892  if($con['obligatory'])
893  {
894  continue;
895  }
896 
897  $opt[] = $con;
898  }
899  return $opt;
900  }
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 248 of file class.ilConditionHandler.php.

Referenced by storeCondition(), and updateCondition().

249  {
250  return (int) $this->condition_reference_type;
251  }
+ Here is the caller graph for this function:

◆ getTargetObjId()

ilConditionHandler::getTargetObjId ( )

get target obj id

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

References $target_obj_id.

Referenced by checkExists(), and storeCondition().

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

◆ getTargetRefId()

ilConditionHandler::getTargetRefId ( )

get target ref id

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

References $target_ref_id.

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

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

◆ getTargetType()

ilConditionHandler::getTargetType ( )

get target obj type

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

References $target_type.

Referenced by storeCondition().

307  {
308  return $this->target_type;
309  }
+ Here is the caller graph for this function:

◆ getTriggerObjId()

ilConditionHandler::getTriggerObjId ( )

get trigger obj id

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

References $trigger_obj_id.

Referenced by checkExists(), and storeCondition().

339  {
340  return $this->trigger_obj_id;
341  }
+ Here is the caller graph for this function:

◆ getTriggerRefId()

ilConditionHandler::getTriggerRefId ( )

get target ref id

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

References $trigger_ref_id.

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

323  {
324  return $this->trigger_ref_id;
325  }
+ Here is the caller graph for this function:

◆ getTriggerType()

ilConditionHandler::getTriggerType ( )

get trigger obj type

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

References $trigger_type.

Referenced by storeCondition().

355  {
356  return $this->trigger_type;
357  }
+ Here is the caller graph for this function:

◆ getTriggerTypes()

ilConditionHandler::getTriggerTypes ( )

get all possible trigger types NOT STATIC public

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

References array, and getOperatorsByTargetType().

434  {
435  global $objDefinition;
436 
437  $trigger_types = array('crs','exc','tst','sahs', 'svy', 'lm', 'iass');
438 
439  foreach($objDefinition->getPlugins() as $p_type => $p_info)
440  {
441  if(@include_once $p_info['location'].'/class.ilObj'.$p_info['class_name'].'Access.php')
442  {
443  include_once './Services/AccessControl/interfaces/interface.ilConditionHandling.php';
444  $name = 'ilObj'.$p_info['class_name'].'Access';
445  $refection = new ReflectionClass($name);
446  if($refection->implementsInterface('ilConditionHandling'))
447  {
448  $trigger_types[] = $p_type;
449  }
450  }
451  }
452 
453 
454  $active_triggers = array();
455  foreach($trigger_types as $type)
456  {
457  if(count($this->getOperatorsByTargetType($type)))
458  {
459  $active_triggers[] = $type;
460  }
461  }
462 
463 
464 
465 
466  return $active_triggers;
467  }
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 386 of file class.ilConditionHandler.php.

References $value.

Referenced by storeCondition(), and updateCondition().

387  {
388  return $this->value;
389  }
+ 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(), ilAccessHandler\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  {
150  return $row->hidden_status;
151  }
152  return FALSE;
153  }
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 907 of file class.ilConditionHandler.php.

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

Referenced by ilConditionHandlerGUI\showObligatoryForm().

908  {
909  global $ilDB;
910 
911  $query = 'SELECT max(num_obligatory) obl from conditions WHERE '.
912  'target_ref_id = '.$ilDB->quote($a_target_ref_id,'integer').' '.
913  'AND target_obj_id = '.$ilDB->quote($a_target_obj_id,'integer').' '.
914  'GROUP BY (num_obligatory)';
915  $res = $ilDB->query($query);
916 
917  $obl = 0;
918  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
919  {
920  $obl = $row->obl;
921  }
922  return $obl;
923  }
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 782 of file class.ilConditionHandler.php.

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

Referenced by ilObjectListGUIPreloader\preload().

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

References $ilDB, and $query.

Referenced by ilConditionHandlerGUI\saveObligatorySettings().

974  {
975  global $ilDB;
976 
977  $query = 'UPDATE conditions '.
978  'SET num_obligatory = '.$ilDB->quote($a_num,'integer').' '.
979  'WHERE target_ref_id = '.$ilDB->quote($a_target_ref_id,'integer').' '.
980  'AND target_obj_id = '.$ilDB->quote($a_target_obj_id,'integer');
981  $ilDB->manipulate($query);
982  return;
983  }
global $ilDB
+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage (   $a_msg)

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

Referenced by validate().

255  {
256  $this->error_message = $a_msg;
257  }
+ Here is the caller graph for this function:

◆ setHiddenStatus()

ilConditionHandler::setHiddenStatus (   $a_status)

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

410  {
411  $this->hidden_status = $a_status;
412  }

◆ setObligatory()

ilConditionHandler::setObligatory (   $a_obl)

Set obligatory status.

Parameters
bool$a_obl

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

396  {
397  $this->obligatory = $a_obl;
398  }

◆ setOperator()

ilConditionHandler::setOperator (   $a_operator)

set operator

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

363  {
364  return $this->operator = $a_operator;
365  }

◆ setReferenceHandlingType()

ilConditionHandler::setReferenceHandlingType (   $a_type)

set reference handling type

Parameters
intpublic

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

References $a_type.

238  {
239  return $this->condition_reference_type = $a_type;
240  }
$a_type
Definition: workflow.php:93

◆ setTargetObjId()

ilConditionHandler::setTargetObjId (   $a_target_obj_id)

set target object id

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

283  {
284  return $this->target_obj_id = $a_target_obj_id;
285  }

◆ setTargetRefId()

ilConditionHandler::setTargetRefId (   $a_target_ref_id)

set target ref id

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

267  {
268  return $this->target_ref_id = $a_target_ref_id;
269  }

◆ setTargetType()

ilConditionHandler::setTargetType (   $a_target_type)

set target object type

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

299  {
300  return $this->target_type = $a_target_type;
301  }

◆ setTriggerObjId()

ilConditionHandler::setTriggerObjId (   $a_trigger_obj_id)

set trigger object id

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

331  {
332  return $this->trigger_obj_id = $a_trigger_obj_id;
333  }

◆ setTriggerRefId()

ilConditionHandler::setTriggerRefId (   $a_trigger_ref_id)

set trigger ref id

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

315  {
316  return $this->trigger_ref_id = $a_trigger_ref_id;
317  }

◆ setTriggerType()

ilConditionHandler::setTriggerType (   $a_trigger_type)

set trigger object type

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

347  {
348  return $this->trigger_type = $a_trigger_type;
349  }

◆ setValue()

ilConditionHandler::setValue (   $a_value)

set value

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

379  {
380  return $this->value = $a_value;
381  }

◆ storeCondition()

ilConditionHandler::storeCondition ( )

store new condition in database NOT STATIC public

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

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

524  {
525  global $ilDB;
526 
527  // first insert, then validate: it's easier to check for circles if the new condition is in the db table
528  $next_id = $ilDB->nextId('conditions');
529  $query = 'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,'.
530  'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) '.
531  'VALUES ('.
532  $ilDB->quote($next_id,'integer').','.
533  $ilDB->quote($this->getTargetRefId(),'integer').",".
534  $ilDB->quote($this->getTargetObjId(),'integer').",".
535  $ilDB->quote($this->getTargetType(),'text').",".
536  $ilDB->quote($this->getTriggerRefId(),'integer').",".
537  $ilDB->quote($this->getTriggerObjId(),'integer').",".
538  $ilDB->quote($this->getTriggerType(),'text').",".
539  $ilDB->quote($this->getOperator(),'text').",".
540  $ilDB->quote($this->getValue(),'text').", ".
541  $ilDB->quote($this->getReferenceHandlingType(),'integer').', '.
542  $ilDB->quote($this->getObligatory(),'integer').', '.
543  $ilDB->quote($this->getHiddenStatus(),'integer').' '.
544  ')';
545 
546  $res = $ilDB->manipulate($query);
547 
548  if ($this->validation && !$this->validate())
549  {
550  $this->deleteCondition($next_id);
551  return false;
552  }
553  return true;
554  }
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
getTriggerObjId()
get trigger obj id
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 573 of file class.ilConditionHandler.php.

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

574  {
575  global $ilDB;
576 
577  $query = "UPDATE conditions SET ".
578  "target_ref_id = ".$ilDB->quote($this->getTargetRefId(),'integer').", ".
579  "operator = ".$ilDB->quote($this->getOperator(),'text').", ".
580  "value = ".$ilDB->quote($this->getValue(),'text').", ".
581  "ref_handling = ".$this->db->quote($this->getReferenceHandlingType(),'integer').", ".
582  'obligatory = '.$this->db->quote($this->getObligatory(),'integer').' '.
583  "WHERE condition_id = ".$ilDB->quote($a_id,'integer');
584  $res = $ilDB->manipulate($query);
585 
586  return true;
587  }
getObligatory()
Get obligatory status.
getReferenceHandlingType()
get reference handling type
getTargetRefId()
get target ref id
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 596 of file class.ilConditionHandler.php.

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

597  {
598  global $ilDB;
599 
600  $query = 'UPDATE conditions SET '.
601  'hidden_status = '.$ilDB->quote($a_status,'integer').' '.
602  'WHERE target_ref_id = '.$ilDB->quote($this->getTargetRefId(),'integer');
603  $ilDB->manipulate($query);
604  return TRUE;
605  }
getTargetRefId()
get target ref id
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 613 of file class.ilConditionHandler.php.

References $ilDB, $query, and $res.

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

614  {
615  global $ilDB;
616 
617  $query = "UPDATE conditions SET ".
618  'obligatory = '.$ilDB->quote($a_status,'integer').' '.
619  "WHERE condition_id = ".$ilDB->quote($a_id,'integer');
620  $res = $ilDB->manipulate($query);
621 
622  return true;
623  }
global $ilDB
+ Here is the caller graph for this function:

◆ validate()

ilConditionHandler::validate ( )

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

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

Referenced by storeCondition().

1042  {
1043  global $ilDB;
1044 
1045  // check if obj_id is already assigned
1046  $trigger_obj =& ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1047  $target_obj =& ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1048 
1049 
1050  $query = "SELECT * FROM conditions WHERE ".
1051  "trigger_ref_id = ".$ilDB->quote($trigger_obj->getRefId(),'integer')." ".
1052  "AND target_ref_id = ".$ilDB->quote($target_obj->getRefId(),'integer');
1053 
1054  $res = $this->db->query($query);
1055  if($res->numRows() > 1)
1056  {
1057  $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1058 
1059  unset($trigger_obj);
1060  unset($target_obj);
1061  return false;
1062  }
1063 
1064  // check for circle
1065  $this->target_obj_id = $target_obj->getId();
1066  if($this->checkCircle($this->getTargetRefId(),$target_obj->getId()))
1067  {
1068  $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1069 
1070  unset($trigger_obj);
1071  unset($target_obj);
1072  return false;
1073  }
1074  return true;
1075  }
getTriggerRefId()
get target ref id
getTargetRefId()
get target ref id
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 99 of file class.ilConditionHandler.php.

◆ $cond_target_rows

ilConditionHandler::$cond_target_rows = array()
static

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

◆ $conditions

ilConditionHandler::$conditions

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

Referenced by _getConditionsOfTarget(), and _getConditionsOfTrigger().

◆ $db

ilConditionHandler::$db

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

◆ $error_message

ilConditionHandler::$error_message

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

Referenced by getErrorMessage().

◆ $hidden_status

ilConditionHandler::$hidden_status = FALSE
private

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

Referenced by getHiddenStatus().

◆ $lng

ilConditionHandler::$lng

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

Referenced by __construct().

◆ $obligatory

ilConditionHandler::$obligatory = true
private

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

Referenced by getObligatory().

◆ $operator

ilConditionHandler::$operator

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

Referenced by getOperator().

◆ $target_obj_id

ilConditionHandler::$target_obj_id

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

Referenced by getTargetObjId().

◆ $target_ref_id

ilConditionHandler::$target_ref_id

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

Referenced by getTargetRefId().

◆ $target_type

ilConditionHandler::$target_type

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

Referenced by getTargetType().

◆ $trigger_obj_id

ilConditionHandler::$trigger_obj_id

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

Referenced by getTriggerObjId().

◆ $trigger_ref_id

ilConditionHandler::$trigger_ref_id

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

Referenced by getTriggerRefId().

◆ $trigger_type

ilConditionHandler::$trigger_type

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

Referenced by getTriggerType().

◆ $validation

ilConditionHandler::$validation

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

◆ $value

ilConditionHandler::$value

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

Referenced by getValue().

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