ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilConditionHandler Class Reference

Handles conditions for accesses to different ILIAS objects. More...

+ Collaboration diagram for ilConditionHandler:

Public Member Functions

 __construct ()
 constructor @access public More...
 
 setReferenceHandlingType ($a_type)
 set reference handling type More...
 
 getReferenceHandlingType ()
 get reference handling type More...
 
 setErrorMessage ($a_msg)
 
 getErrorMessage ()
 
 setTargetRefId ($a_target_ref_id)
 set target ref id More...
 
 getTargetRefId ()
 get target ref id More...
 
 setTargetObjId ($a_target_obj_id)
 set target object id More...
 
 getTargetObjId ()
 get target obj id More...
 
 setTargetType ($a_target_type)
 set target object type More...
 
 getTargetType ()
 get target obj type More...
 
 setTriggerRefId ($a_trigger_ref_id)
 set trigger ref id More...
 
 getTriggerRefId ()
 get target ref id More...
 
 setTriggerObjId ($a_trigger_obj_id)
 set trigger object id More...
 
 getTriggerObjId ()
 get trigger obj id More...
 
 setTriggerType ($a_trigger_type)
 set trigger object type More...
 
 getTriggerType ()
 get trigger obj type More...
 
 setOperator ($a_operator)
 set operator More...
 
 getOperator ()
 get operator More...
 
 setValue ($a_value)
 set value More...
 
 getValue ()
 get value More...
 
 setObligatory ($a_obl)
 Set obligatory status. More...
 
 getObligatory ()
 Get obligatory status. More...
 
 setHiddenStatus ($a_status)
 
 getHiddenStatus ()
 
 enableAutomaticValidation ($a_validate=true)
 enable automated validation More...
 
 getTriggerTypes ()
 get all possible trigger types NOT STATIC @access public More...
 
 getOperatorsByTargetType ($a_type)
 Get operators by target type. More...
 
 storeCondition ()
 store new condition in database NOT STATIC @access public More...
 
 checkExists ()
 
 updateCondition ($a_id)
 update condition More...
 
 updateHiddenStatus ($a_status)
 Update hidden status @global type $ilDB. More...
 
 delete ($a_ref_id)
 delete all trigger and target entries This method is called from ilObject::delete() if an object os removed from trash More...
 
 deleteByObjId ($a_obj_id)
 delete all trigger and target entries This method is called from ilObject::delete() if an object is removed from trash More...
 
 deleteCondition ($a_id)
 delete condition More...
 
 preloadConditionsForTargetRecords ($a_type, $a_obj_ids)
 Preload conditions for target records. More...
 
 _getCondition ($a_id)
 
 _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...
 
 _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...
 
 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 @global 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...
 
 _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 getOptionalConditionsOfTarget ($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
 Get optional conditions. 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 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 @access public

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

108 {
109 global $ilDB,$lng;
110
111 $this->db =& $ilDB;
112 $this->lng =& $lng;
113 $this->validation = true;
114 }
global $ilDB

References $ilDB, and $lng.

Member Function Documentation

◆ _adjustMovedObjectConditions()

static ilConditionHandler::_adjustMovedObjectConditions (   $a_ref_id)
static

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

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

@access public

Parameters
intreference id of moved object

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

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);
178
179 foreach(array_intersect($conditions,$childs) as $target_ref)
180 {
181 if(!$tree->checkForParentType($target_ref,'crs'))
182 {
184 }
185 }
186 return true;
187 }
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
static _getDistinctTargetRefIds()
Get all target ref ids.

References $conditions, _deleteTargetConditionsByRefId(), and _getDistinctTargetRefIds().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkAllConditionsOfTarget()

ilConditionHandler::_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

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

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

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkCondition()

ilConditionHandler::_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)

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

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

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteTargetConditionsByRefId()

static ilConditionHandler::_deleteTargetConditionsByRefId (   $a_target_ref_id)
static

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

@access public

Parameters
intref id of target

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

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 }

References $ilDB, $query, and $res.

Referenced by _adjustMovedObjectConditions(), and ilRBACTest\testConditions().

+ Here is the caller graph for this function:

◆ _getCondition()

ilConditionHandler::_getCondition (   $a_id)

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

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(DB_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 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

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

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 }
static _lookupType($a_id, $a_reference=false)
lookup object type

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getConditionsOfTrigger()

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.

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(DB_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 }

References $conditions, $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

+ Here is the caller graph for this function:

◆ _getDistinctTargetRefIds()

static ilConditionHandler::_getDistinctTargetRefIds ( )
static

Get all target ref ids.

@access public

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

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(DB_FETCHMODE_OBJECT))
203 {
204 $ref_ids[] = $row->ref;
205 }
206 return $ref_ids ? $ref_ids : array();
207 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by _adjustMovedObjectConditions(), and ilRBACTest\testConditions().

+ Here is the caller graph for this function:

◆ _isReferenceHandlingOptional()

static ilConditionHandler::_isReferenceHandlingOptional (   $a_type)
static

is reference handling optional

@access public

Parameters
stringtarget type ILIAS obj type

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

125 {
126 switch($a_type)
127 {
128 case 'st':
129 return true;
130
131 default:
132 return false;
133 }
134 }

Referenced by ilConditionHandlerGUI\initFormCondition().

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

909 {
910 global $ilDB;
911
912 // Get all conditions
913 $all = self::_getConditionsOfTarget($a_target_ref_id,$a_target_obj_id,$a_target_obj_type);
914 $opt = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id,$a_target_obj_type);
915
916 $set_obl = 0;
917 if(isset($all[0]))
918 {
919 $set_obl = $all[0]['num_obligatory'];
920 }
921
922 // existing value is valid
923 if($set_obl > 0 and
924 $set_obl < count($all) and
925 $set_obl > (count($all) - count($opt) + 1))
926 {
927 return $set_obl;
928 }
929
930 if(count($opt))
931 {
932 $result = count($all) - count($opt) + 1;
933 }
934 else
935 {
936 $result = count($all);
937 }
938 if($a_force_update)
939 {
940 self::saveNumberOfRequiredTriggers($a_target_ref_id,$a_target_obj_id,$result);
941 }
942 return $result;
943 }
$result
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.

References $ilDB, $result, _getConditionsOfTarget(), getOptionalConditionsOfTarget(), and saveNumberOfRequiredTriggers().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkCircle()

ilConditionHandler::checkCircle (   $a_ref_id,
  $a_obj_id 
)

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

1055 {
1056 foreach(ilConditionHandler::_getConditionsOfTarget($a_ref_id,$a_obj_id) as $condition)
1057 {
1058 if($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator())
1059 {
1060 $this->circle = true;
1061 break;
1062 }
1063 else
1064 {
1065 $this->checkCircle($condition['trigger_ref_id'],$condition['trigger_obj_id']);
1066 }
1067 }
1068 return $this->circle;
1069 }
checkCircle($a_ref_id, $a_obj_id)

References _getConditionsOfTarget(), checkCircle(), and getOperator().

Referenced by checkCircle(), and validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExists()

ilConditionHandler::checkExists ( )

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

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

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

+ Here is the call graph for this function:

◆ cloneDependencies()

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

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

1072 {
1073 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1074 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1075 $mappings = $cwo->getMappings();
1076
1077 $valid = 0;
1079 foreach($conditions as $con)
1080 {
1081 if($mappings[$con['trigger_ref_id']])
1082 {
1083 $newCondition = new ilConditionHandler();
1084
1085 $target_obj = ilObject::_lookupObjId($a_target_ref_id);
1086 $target_typ = ilObject::_lookupType($target_obj);
1087
1088 $newCondition->setTargetRefId($a_target_ref_id);
1089 $newCondition->setTargetObjId($target_obj);
1090 $newCondition->setTargetType($target_typ);
1091
1092 $trigger_ref = $mappings[$con['trigger_ref_id']];
1093 $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1094 $trigger_typ = ilObject::_lookupType($trigger_obj);
1095
1096 $newCondition->setTriggerRefId($trigger_ref);
1097 $newCondition->setTriggerObjId($trigger_obj);
1098 $newCondition->setTriggerType($trigger_typ);
1099 $newCondition->setOperator($con['operator']);
1100 $newCondition->setValue($con['value']);
1101 $newCondition->setReferenceHandlingType($con['ref_handling']);
1102 $newCondition->setObligatory($con['obligatory']);
1103
1104 // :TODO: not sure about this
1105 $newCondition->setHiddenStatus(self::lookupHiddenStatusByTarget($a_src_ref_id));
1106
1107 if($newCondition->storeCondition())
1108 {
1109 $valid++;
1110 }
1111 }
1112 }
1113 if($valid)
1114 {
1115 $tgt_obj_id = ilObject::_lookupObjId($a_target_ref_id);
1116
1117 // num_obligatory
1118 self::calculateRequiredTriggers($a_target_ref_id, $tgt_obj_id, ilObject::_lookupType($tgt_obj_id), true);
1119 }
1120 }
Handles conditions for accesses to different ILIAS objects.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _lookupObjId($a_id)
$valid

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

Referenced by ilObject\cloneDependencies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilConditionHandler::delete (   $a_ref_id)

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

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

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 }

References $ilDB, $query, and $res.

◆ deleteByObjId()

ilConditionHandler::deleteByObjId (   $a_obj_id)

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

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

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 }

References $ilDB, $query, and $res.

◆ deleteCondition()

ilConditionHandler::deleteCondition (   $a_id)

delete condition

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

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 }

References $ilDB, $query, and $res.

Referenced by storeCondition().

+ Here is the caller graph for this function:

◆ enableAutomaticValidation()

ilConditionHandler::enableAutomaticValidation (   $a_validate = true)

enable automated validation

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

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

◆ getErrorMessage()

ilConditionHandler::getErrorMessage ( )

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

References $error_message.

◆ getHiddenStatus()

ilConditionHandler::getHiddenStatus ( )

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

References $hidden_status.

Referenced by storeCondition().

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

405 {
406 return (bool) $this->obligatory;
407 }

References $obligatory.

Referenced by storeCondition(), and updateCondition().

+ 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().

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

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 }
static _enabledLearningProgress()
check wether learing progress is enabled or not
static isSupportedObjectType($a_type)

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

Referenced by getTriggerTypes().

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

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 }

References $conditions, and _getConditionsOfTarget().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReferenceHandlingType()

ilConditionHandler::getReferenceHandlingType ( )

get reference handling type

@access public

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

249 {
250 return (int) $this->condition_reference_type;
251 }

Referenced by storeCondition(), and updateCondition().

+ 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().

+ 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().

+ 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().

+ 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().

+ 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().

+ 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().

+ Here is the caller graph for this function:

◆ getTriggerTypes()

ilConditionHandler::getTriggerTypes ( )

get all possible trigger types NOT STATIC @access public

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

434 {
435 global $objDefinition;
436
437 $trigger_types = array('crs','exc','tst','sahs', 'svy', 'lm');
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 }
getOperatorsByTargetType($a_type)
Get operators by target type.

References getOperatorsByTargetType().

+ 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().

+ Here is the caller graph for this function:

◆ lookupHiddenStatusByTarget()

static ilConditionHandler::lookupHiddenStatusByTarget (   $a_target_ref_id)
static

Lookup hidden status @global type $ilDB.

Parameters
type$a_target_ref_id

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

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(DB_FETCHMODE_OBJECT))
149 {
150 return $row->hidden_status;
151 }
152 return FALSE;
153 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

+ Here is the caller graph for this function:

◆ preloadConditionsForTargetRecords()

ilConditionHandler::preloadConditionsForTargetRecords (   $a_type,
  $a_obj_ids 
)

Preload conditions for target records.

Parameters

return

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

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 }

References $ilDB, $res, and $row.

Referenced by ilObjectListGUIPreloader\preload().

+ Here is the caller graph for this function:

◆ saveNumberOfRequiredTriggers()

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

Save number of obigatory triggers.

Parameters
int$a_target_ref_id
int$a_target_obj_id

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

951 {
952 global $ilDB;
953
954 $query = 'UPDATE conditions '.
955 'SET num_obligatory = '.$ilDB->quote($a_num,'integer').' '.
956 'WHERE target_ref_id = '.$ilDB->quote($a_target_ref_id,'integer').' '.
957 'AND target_obj_id = '.$ilDB->quote($a_target_obj_id,'integer');
958 $ilDB->manipulate($query);
959 return;
960 }

References $ilDB, and $query.

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

+ Here is the caller graph for this function:

◆ setErrorMessage()

ilConditionHandler::setErrorMessage (   $a_msg)

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

255 {
256 $this->error_message = $a_msg;
257 }

Referenced by validate().

+ 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
int@access public

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

238 {
239 return $this->condition_reference_type = $a_type;
240 }

◆ 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 @access public

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

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 }
getTargetType()
get target obj type
getTriggerType()
get trigger obj type
deleteCondition($a_id)
delete condition
getReferenceHandlingType()
get reference handling type
getObligatory()
Get obligatory status.

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

+ Here is the call graph for this function:

◆ updateCondition()

ilConditionHandler::updateCondition (   $a_id)

update condition

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

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 }

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

+ Here is the call graph for this function:

◆ updateHiddenStatus()

ilConditionHandler::updateHiddenStatus (   $a_status)

Update hidden status @global type $ilDB.

Parameters
type$a_target_ref_id
type$a_status
Returns
boolean

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

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 }

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

+ Here is the call graph for this function:

◆ updateObligatory()

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

Toggle condition obligatory status.

Parameters
int$a_id
bool$a_status

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

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 }

References $ilDB, $query, and $res.

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

+ Here is the caller graph for this function:

◆ validate()

ilConditionHandler::validate ( )

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

1019 {
1020 global $ilDB;
1021
1022 // check if obj_id is already assigned
1023 $trigger_obj =& ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
1024 $target_obj =& ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
1025
1026
1027 $query = "SELECT * FROM conditions WHERE ".
1028 "trigger_ref_id = ".$ilDB->quote($trigger_obj->getRefId(),'integer')." ".
1029 "AND target_ref_id = ".$ilDB->quote($target_obj->getRefId(),'integer');
1030
1031 $res = $this->db->query($query);
1032 if($res->numRows() > 1)
1033 {
1034 $this->setErrorMessage($this->lng->txt('condition_already_assigned'));
1035
1036 unset($trigger_obj);
1037 unset($target_obj);
1038 return false;
1039 }
1040
1041 // check for circle
1042 $this->target_obj_id = $target_obj->getId();
1043 if($this->checkCircle($this->getTargetRefId(),$target_obj->getId()))
1044 {
1045 $this->setErrorMessage($this->lng->txt('condition_circle_created'));
1046
1047 unset($trigger_obj);
1048 unset($target_obj);
1049 return false;
1050 }
1051 return true;
1052 }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

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

Referenced by storeCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cond_for_target_cache

ilConditionHandler::$cond_for_target_cache = array()
static

Definition at line 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

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