114 $this->validation =
true;
145 $query =
'SELECT hidden_status FROM conditions ' .
146 'WHERE target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer');
149 return $row->hidden_status;
168 if ($tree->checkForParentType($a_ref_id,
'crs')) {
174 $childs = $tree->getSubTree($tree->getNodeData($a_ref_id),
false);
177 foreach (array_intersect(
$conditions, $childs) as $target_ref) {
178 if (!$tree->checkForParentType($target_ref,
'crs')) {
196 $query =
"SELECT DISTINCT target_ref_id ref FROM conditions ";
199 $ref_ids[] =
$row->ref;
201 return $ref_ids ? $ref_ids : array();
218 $query =
"DELETE FROM conditions " .
219 "WHERE target_ref_id = " .
$ilDB->quote($a_target_ref_id,
'integer') .
" " .
220 "AND target_type != 'st' ";
234 return $this->condition_reference_type =
$a_type;
245 return (
int) $this->condition_reference_type;
251 $this->error_message = $a_msg;
263 return $this->target_ref_id = $a_target_ref_id;
279 return $this->target_obj_id = $a_target_obj_id;
295 return $this->target_type = $a_target_type;
311 return $this->trigger_ref_id = $a_trigger_ref_id;
327 return $this->trigger_obj_id = $a_trigger_obj_id;
343 return $this->trigger_type = $a_trigger_type;
359 return $this->
operator = $a_operator;
375 return $this->value = $a_value;
392 $this->obligatory = $a_obl;
406 $this->hidden_status = $a_status;
420 $this->validation = $a_validate;
430 global $objDefinition;
432 $trigger_types = array(
'crs',
'exc',
'tst',
'sahs',
'svy',
'lm',
'iass',
'prg');
434 foreach ($objDefinition->getPlugins() as $p_type => $p_info) {
435 if (@include_once $p_info[
'location'] .
'/class.ilObj' . $p_info[
'class_name'] .
'Access.php') {
436 include_once
'./Services/AccessControl/interfaces/interface.ilConditionHandling.php';
437 $name =
'ilObj' . $p_info[
'class_name'] .
'Access';
438 $reflection =
new ReflectionClass(
$name);
439 if ($reflection->implementsInterface(
'ilConditionHandling')) {
440 $trigger_types[] = $p_type;
446 $active_triggers = array();
447 foreach ($trigger_types as
$type) {
449 $active_triggers[] =
$type;
456 return $active_triggers;
467 global $objDefinition;
471 return array(
'not_member');
474 $class = $objDefinition->getClassName(
$a_type);
476 $full_class =
"ilObj" . $class .
"Access";
477 include_once(
$location .
"/class." . $full_class .
".php");
479 include_once
'./Services/AccessControl/interfaces/interface.ilConditionHandling.php';
481 $reflection =
new ReflectionClass($full_class);
482 if (!$reflection->implementsInterface(
'ilConditionHandling')) {
487 $operators = call_user_func(
488 array($full_class,
'getConditionOperators'),
493 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
496 include_once(
"Services/Object/classes/class.ilObjectLP.php");
498 array_unshift($operators, self::OPERATOR_LP);
514 $next_id =
$ilDB->nextId(
'conditions');
515 $query =
'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
516 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
518 $ilDB->quote($next_id,
'integer') .
',' .
526 $ilDB->quote($this->
getValue(),
'text') .
", " .
534 if ($this->validation && !$this->
validate()) {
545 $query =
"SELECT * FROM conditions " .
547 "AND target_obj_id = " . $ilDB->quote($this->
getTargetObjId(),
'integer') .
" " .
548 "AND trigger_ref_id = " . $ilDB->quote($this->
getTriggerRefId(),
'integer') .
" " .
549 "AND trigger_obj_id = " . $ilDB->quote($this->
getTriggerObjId(),
'integer') .
" " .
550 "AND operator = " . $ilDB->quote($this->
getOperator(),
'text');
553 return $res->numRows() ? true :
false;
562 $query =
"UPDATE conditions SET " .
564 "operator = " . $ilDB->quote($this->
getOperator(),
'text') .
", " .
565 "value = " . $ilDB->quote($this->
getValue(),
'text') .
", " .
567 'obligatory = ' . $this->db->quote($this->
getObligatory(),
'integer') .
' ' .
568 "WHERE condition_id = " . $ilDB->quote($a_id,
'integer');
585 $query =
'UPDATE conditions SET ' .
586 'hidden_status = ' .
$ilDB->quote($a_status,
'integer') .
' ' .
588 $ilDB->manipulate(
$query);
602 $query =
"UPDATE conditions SET " .
603 'obligatory = ' .
$ilDB->quote($a_status,
'integer') .
' ' .
604 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
614 public function delete($a_ref_id)
618 $query =
"DELETE FROM conditions WHERE " .
619 "target_ref_id = " .
$ilDB->quote($a_ref_id,
'integer') .
" " .
620 "OR trigger_ref_id = " .
$ilDB->quote($a_ref_id,
'integer');
633 $query =
"DELETE FROM conditions WHERE " .
634 "target_obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
635 "OR trigger_obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
648 $query =
"DELETE FROM conditions " .
649 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
666 $query =
'select count(*) num from conditions ' .
671 return (
int)
$row->num;
682 $query =
"SELECT * FROM conditions " .
683 "WHERE trigger_obj_id = " .
$ilDB->quote($a_trigger_id,
'integer') .
" " .
684 " AND trigger_type = " .
$ilDB->quote($a_trigger_obj_type,
'text');
688 $tmp_array[
'id'] =
$row->condition_id;
689 $tmp_array[
'target_ref_id'] =
$row->target_ref_id;
690 $tmp_array[
'target_obj_id'] =
$row->target_obj_id;
691 $tmp_array[
'target_type'] =
$row->target_type;
692 $tmp_array[
'trigger_ref_id'] =
$row->trigger_ref_id;
693 $tmp_array[
'trigger_obj_id'] =
$row->trigger_obj_id;
694 $tmp_array[
'trigger_type'] =
$row->trigger_type;
695 $tmp_array[
'operator'] =
$row->operator;
696 $tmp_array[
'value'] =
$row->value;
697 $tmp_array[
'ref_handling'] =
$row->ref_handling;
698 $tmp_array[
'obligatory'] =
$row->obligatory;
699 $tmp_array[
'hidden_status'] =
$row->hidden_status;
723 if ($a_target_type ==
"") {
728 if (isset(self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
730 return self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
735 if (isset(self::$cond_target_rows[$a_target_type .
":" . $a_target_obj_id])) {
736 $rows = self::$cond_target_rows[$a_target_type .
":" . $a_target_obj_id];
739 $query =
"SELECT * FROM conditions " .
740 "WHERE target_obj_id = " .
$ilDB->quote($a_target_obj_id,
'integer') .
" " .
741 " AND target_type = " .
$ilDB->quote($a_target_type,
'text');
753 if (
$row[
"ref_handling"] == self::UNIQUE_CONDITIONS) {
754 if (
$row[
"target_ref_id"] != $a_target_ref_id) {
764 self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
780 if (is_array($a_obj_ids) && count($a_obj_ids) > 0) {
781 $res =
$ilDB->query(
"SELECT * FROM conditions " .
782 "WHERE " .
$ilDB->in(
"target_obj_id", $a_obj_ids,
false,
"integer") .
786 self::$cond_target_rows[
$a_type .
":" .
$row[
"target_obj_id"]][]
790 foreach ($a_obj_ids as $obj_id) {
791 if (!is_array(self::$cond_target_rows[
$a_type .
":" . $obj_id])) {
792 self::$cond_target_rows[
$a_type .
":" . $obj_id] = array();
802 $query =
"SELECT * FROM conditions " .
803 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
807 $tmp_array[
'id'] =
$row->condition_id;
808 $tmp_array[
'target_ref_id'] =
$row->target_ref_id;
809 $tmp_array[
'target_obj_id'] =
$row->target_obj_id;
810 $tmp_array[
'target_type'] =
$row->target_type;
811 $tmp_array[
'trigger_ref_id'] =
$row->trigger_ref_id;
812 $tmp_array[
'trigger_obj_id'] =
$row->trigger_obj_id;
813 $tmp_array[
'trigger_type'] =
$row->trigger_type;
814 $tmp_array[
'operator'] =
$row->operator;
815 $tmp_array[
'value'] =
$row->value;
816 $tmp_array[
'ref_handling'] =
$row->ref_handling;
817 $tmp_array[
'obligatory'] =
$row->obligatory;
818 $tmp_array[
'hidden_status'] =
$row->hidden_status;
834 global
$ilUser, $objDefinition;
836 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
841 if ($condition[
'operator'] == self::OPERATOR_LP) {
842 include_once
'./Services/Tracking/classes/class.ilLPStatus.php';
846 switch ($condition[
'trigger_type']) {
848 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
852 $class = $objDefinition->getClassName($condition[
'trigger_type']);
853 $location = $objDefinition->getLocation($condition[
'trigger_type']);
854 $full_class =
"ilObj" . $class .
"Access";
855 include_once(
$location .
"/class." . $full_class .
".php");
857 $fullfilled = call_user_func(
858 array($full_class,
'checkCondition'),
859 $condition[
'trigger_obj_id'],
860 $condition[
'operator'],
878 if ($con[
'obligatory']) {
896 $query =
'SELECT max(num_obligatory) obl from conditions WHERE ' .
897 'target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer') .
' ' .
898 'AND target_obj_id = ' .
$ilDB->quote($a_target_obj_id,
'integer') .
' ' .
899 'GROUP BY (num_obligatory)';
924 if (isset($all[0])) {
925 $set_obl = $all[0][
'num_obligatory'];
930 $set_obl < count($all) and
931 $set_obl > (count($all) - count($opt) + 1)) {
936 $result = count($all) - count($opt) + 1;
940 if ($a_force_update) {
955 $query =
'UPDATE conditions ' .
956 'SET num_obligatory = ' .
$ilDB->quote($a_num,
'integer') .
' ' .
957 'WHERE target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer') .
' ' .
958 'AND target_obj_id = ' .
$ilDB->quote($a_target_obj_id,
'integer');
970 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
979 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
989 if ($tree->isDeleted($condition[
'trigger_ref_id'])) {
996 if ($passed >= $num_required) {
1000 if (!count($optional)) {
1019 $query =
"SELECT * FROM conditions WHERE " .
1020 "trigger_ref_id = " . $ilDB->quote($trigger_obj->getRefId(),
'integer') .
" " .
1021 "AND target_ref_id = " .
$ilDB->quote($target_obj->getRefId(),
'integer');
1024 if (
$res->numRows() > 1) {
1025 $this->
setErrorMessage($this->lng->txt(
'condition_already_assigned'));
1027 unset($trigger_obj);
1033 $this->target_obj_id = $target_obj->getId();
1037 unset($trigger_obj);
1047 if ($condition[
'trigger_obj_id'] == $this->target_obj_id and $condition[
'operator'] == $this->
getOperator()) {
1048 $this->circle =
true;
1051 $this->
checkCircle($condition[
'trigger_ref_id'], $condition[
'trigger_obj_id']);
1054 return $this->circle;
1059 include_once
'./Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1061 $mappings = $cwo->getMappings();
1066 if ($mappings[$con[
'trigger_ref_id']]) {
1072 $newCondition->setTargetRefId($a_target_ref_id);
1073 $newCondition->setTargetObjId($target_obj);
1074 $newCondition->setTargetType($target_typ);
1076 $trigger_ref = $mappings[$con[
'trigger_ref_id']];
1080 $newCondition->setTriggerRefId($trigger_ref);
1081 $newCondition->setTriggerObjId($trigger_obj);
1082 $newCondition->setTriggerType($trigger_typ);
1083 $newCondition->setOperator($con[
'operator']);
1084 $newCondition->setValue($con[
'value']);
1085 $newCondition->setReferenceHandlingType($con[
'ref_handling']);
1086 $newCondition->setObligatory($con[
'obligatory']);
1089 $newCondition->setHiddenStatus(self::lookupHiddenStatusByTarget($a_src_ref_id));
1091 if ($newCondition->storeCondition()) {
An exception for terminatinating execution or to throw for unit testing.
Handles conditions for accesses to different ILIAS objects.
getTargetType()
get target obj type
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
setTargetType($a_target_type)
set target object type
static _getCondition($a_id)
setTargetObjId($a_target_obj_id)
set target object id
getTriggerRefId()
get target ref id
setTriggerRefId($a_trigger_ref_id)
set trigger ref id
getTriggerTypes()
get all possible trigger types NOT STATIC @access public
getTargetRefId()
get target ref id
getTriggerType()
get trigger obj type
__construct()
constructor @access public
getOperator()
get operator
deleteCondition($a_id)
delete condition
static getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
getOperatorsByTargetType($a_type)
Get operators by target type.
getReferenceHandlingType()
get reference handling type
static _checkCondition($a_id, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
getObligatory()
Get obligatory status.
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
storeCondition()
store new condition in database NOT STATIC @access public
static _adjustMovedObjectConditions($a_ref_id)
In the moment it is not allowed to create preconditions on objects that are located outside of a cour...
static calculateRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
static getNumberOfConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
setTargetRefId($a_target_ref_id)
set target ref id
setOperator($a_operator)
set operator
enableAutomaticValidation($a_validate=true)
enable automated validation
setReferenceHandlingType($a_type)
set reference handling type
static _getDistinctTargetRefIds()
Get all target ref ids.
setObligatory($a_obl)
Set obligatory status.
static cloneDependencies($a_src_ref_id, $a_target_ref_id, $a_copy_id)
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
static $cond_for_target_cache
static _getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
setTriggerType($a_trigger_type)
set trigger object type
updateHiddenStatus($a_status)
Update hidden status @global type $ilDB.
checkCircle($a_ref_id, $a_obj_id)
getTargetObjId()
get target obj id
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
deleteByObjId($a_obj_id)
delete all trigger and target entries This method is called from ilObject::delete() if an object is r...
static lookupHiddenStatusByTarget($a_target_ref_id)
Lookup hidden status @global type $ilDB.
setHiddenStatus($a_status)
updateCondition($a_id)
update condition
setTriggerObjId($a_trigger_obj_id)
set trigger object id
const OPERATOR_NOT_FINISHED
getTriggerObjId()
get trigger obj id
const OPERATOR_NOT_MEMBER
static _isReferenceHandlingOptional($a_type)
is reference handling optional
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
const OPERATOR_ACCREDITED_OR_PASSED
setValue($a_value)
set value
static preloadConditionsForTargetRecords($a_type, $a_obj_ids)
Preload conditions for target records.
static lookupObligatoryConditionsOfTarget($a_target_ref_id, $a_target_obj_id)
Lookup obligatory conditions of target.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static getInstance()
Get instance.
static _checkCondition($trigger_obj_id, $operator, $value, $a_usr_id=0)
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static isSupportedObjectType($a_type)
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
foreach($_POST as $key=> $value) $res