102 $this->validation =
true;
139 if($tree->checkForParentType($a_ref_id,
'crs'))
146 $childs = $tree->getSubTree($tree->getNodeData($a_ref_id),
false);
149 foreach(array_intersect(
$conditions,$childs) as $target_ref)
151 if(!$tree->checkForParentType($target_ref,
'crs'))
170 $query =
"SELECT DISTINCT target_ref_id ref FROM conditions ";
174 $ref_ids[] =
$row->ref;
176 return $ref_ids ? $ref_ids : array();
193 $query =
"DELETE FROM conditions ".
194 "WHERE target_ref_id = ".$ilDB->quote($a_target_ref_id,
'integer').
" ".
195 "AND target_type != 'st' ";
209 return $this->condition_reference_type = $a_type;
220 return (
int) $this->condition_reference_type;
226 $this->error_message = $a_msg;
238 return $this->target_ref_id = $a_target_ref_id;
254 return $this->target_obj_id = $a_target_obj_id;
270 return $this->target_type = $a_target_type;
286 return $this->trigger_ref_id = $a_trigger_ref_id;
302 return $this->trigger_obj_id = $a_trigger_obj_id;
318 return $this->trigger_type = $a_trigger_type;
334 return $this->
operator = $a_operator;
350 return $this->value = $a_value;
366 $this->validation = $a_validate;
376 return array(
'crs',
'exc',
'tst',
'sahs',
'svy');
386 return array(
'passed');
389 return array(
'passed',
'finished',
'not_finished');
392 return array(
'not_member');
395 return array(
'finished');
398 return array(
'finished');
415 $next_id = $ilDB->nextId(
'conditions');
416 $query =
'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,'.
417 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling) '.
419 $ilDB->quote($next_id,
'integer').
','.
427 $ilDB->quote($this->
getValue(),
'text').
", ".
433 if ($this->validation && !$this->
validate())
445 $query =
"SELECT * FROM conditions ".
446 "WHERE target_ref_id = ".$ilDB->quote($this->
getTargetRefId(),
'integer').
" ".
447 "AND target_obj_id = ".$ilDB->quote($this->
getTargetObjId(),
'integer').
" ".
448 "AND trigger_ref_id = ".$ilDB->quote($this->
getTriggerRefId(),
'integer').
" ".
449 "AND trigger_obj_id = ".$ilDB->quote($this->
getTriggerObjId(),
'integer').
" ".
450 "AND operator = ".$ilDB->quote($this->
getOperator(),
'text');
453 return $res->numRows() ?
true :
false;
462 $query =
"UPDATE conditions SET ".
463 "target_ref_id = ".$ilDB->quote($this->
getTargetRefId(),
'integer').
", ".
464 "operator = ".$ilDB->quote($this->
getOperator(),
'text').
", ".
465 "value = ".$ilDB->quote($this->
getValue(),
'text').
", ".
467 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
478 function delete($a_ref_id)
482 $query =
"DELETE FROM conditions WHERE ".
483 "target_ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ".
484 "OR trigger_ref_id = ".$ilDB->quote($a_ref_id,
'integer');
497 $query =
"DELETE FROM conditions WHERE ".
498 "target_obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
499 "OR trigger_obj_id = ".$ilDB->quote($a_obj_id,
'integer');
512 $query =
"DELETE FROM conditions ".
513 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
527 $query =
"SELECT * FROM conditions ".
528 "WHERE trigger_obj_id = ".$ilDB->quote($a_trigger_id,
'integer').
" ".
529 " AND trigger_type = ".$ilDB->quote($a_trigger_obj_type,
'text');
534 $tmp_array[
'id'] =
$row->condition_id;
535 $tmp_array[
'target_ref_id'] =
$row->target_ref_id;
536 $tmp_array[
'target_obj_id'] =
$row->target_obj_id;
537 $tmp_array[
'target_type'] =
$row->target_type;
538 $tmp_array[
'trigger_ref_id'] =
$row->trigger_ref_id;
539 $tmp_array[
'trigger_obj_id'] =
$row->trigger_obj_id;
540 $tmp_array[
'trigger_type'] =
$row->trigger_type;
541 $tmp_array[
'operator'] =
$row->operator;
542 $tmp_array[
'value'] =
$row->value;
543 $tmp_array[
'ref_handling'] =
$row->ref_handling;
567 if ($a_target_type ==
"")
573 if (isset(self::$cond_for_target_cache[$a_target_ref_id.
":".$a_target_obj_id.
":".
576 return self::$cond_for_target_cache[$a_target_ref_id.
":".$a_target_obj_id.
":".
581 if (isset(self::$cond_target_rows[$a_target_type.
":".$a_target_obj_id]))
583 $rows = self::$cond_target_rows[$a_target_type.
":".$a_target_obj_id];
588 $query =
"SELECT * FROM conditions ".
589 "WHERE target_obj_id = ".$ilDB->quote($a_target_obj_id,
'integer').
" ".
590 " AND target_type = ".$ilDB->quote($a_target_type,
'text');
594 while (
$row = $ilDB->fetchAssoc(
$res))
602 foreach ($rows as
$row)
604 if ($row[
"ref_handling"] == self::UNIQUE_CONDITIONS)
606 if ($row[
"target_ref_id"] != $a_target_ref_id)
612 $row[
"id"] = $row[
"condition_id"];
617 self::$cond_for_target_cache[$a_target_ref_id.
":".$a_target_obj_id.
":".
633 if (is_array($a_obj_ids) && count($a_obj_ids) > 0)
635 $res = $ilDB->query(
"SELECT * FROM conditions ".
636 "WHERE ".$ilDB->in(
"target_obj_id", $a_obj_ids,
false,
"integer").
637 " AND target_type = ".$ilDB->quote($a_type,
'text'));
639 while (
$row = $ilDB->fetchAssoc(
$res))
641 self::$cond_target_rows[$a_type.
":".
$row[
"target_obj_id"]][]
645 foreach ($a_obj_ids as $obj_id)
647 if (!is_array(self::$cond_target_rows[$a_type.
":".$obj_id]))
649 self::$cond_target_rows[$a_type.
":".$obj_id] = array();
659 $query =
"SELECT * FROM conditions ".
660 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
665 $tmp_array[
'id'] =
$row->condition_id;
666 $tmp_array[
'target_ref_id'] =
$row->target_ref_id;
667 $tmp_array[
'target_obj_id'] =
$row->target_obj_id;
668 $tmp_array[
'target_type'] =
$row->target_type;
669 $tmp_array[
'trigger_ref_id'] =
$row->trigger_ref_id;
670 $tmp_array[
'trigger_obj_id'] =
$row->trigger_obj_id;
671 $tmp_array[
'trigger_type'] =
$row->trigger_type;
672 $tmp_array[
'operator'] =
$row->operator;
673 $tmp_array[
'value'] =
$row->value;
674 $tmp_array[
'ref_handling'] =
$row->ref_handling;
692 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
696 switch($condition[
'trigger_type'])
699 include_once
'./Modules/Test/classes/class.ilObjTestAccess.php';
703 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
707 include_once
'./Modules/Exercise/classes/class.ilObjExercise.php';
711 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
715 include_once
'./Services/Tracking/classes/class.ilLPStatusWrapper.php';
719 include_once
'./Modules/Survey/classes/class.ilObjSurvey.php';
736 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
740 if($tree->isDeleted($condition[
'trigger_ref_id']))
745 $ilBench->start(
"ilConditionHandler",
"checkCondition");
747 $ilBench->stop(
"ilConditionHandler",
"checkCondition");
749 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
768 $query =
"SELECT * FROM conditions WHERE ".
769 "trigger_ref_id = ".$ilDB->quote($trigger_obj->getId(),
'integer').
" ".
770 "AND target_ref_id = ".$ilDB->quote($target_obj->getId(),
'integer');
773 if(
$res->numRows() > 1)
783 $this->target_obj_id = $target_obj->getId();
799 if($condition[
'trigger_obj_id'] == $this->target_obj_id and $condition[
'operator'] == $this->
getOperator())
801 $this->circle =
true;
806 $this->
checkCircle($condition[
'trigger_ref_id'],$condition[
'trigger_obj_id']);
809 return $this->circle;