113 $this->validation =
true;
145 $query =
'SELECT hidden_status FROM conditions '.
146 'WHERE target_ref_id = '.$ilDB->quote($a_target_ref_id,
'integer');
150 return $row->hidden_status;
169 if($tree->checkForParentType($a_ref_id,
'crs'))
176 $childs = $tree->getSubTree($tree->getNodeData($a_ref_id),
false);
179 foreach(array_intersect(
$conditions,$childs) as $target_ref)
181 if(!$tree->checkForParentType($target_ref,
'crs'))
200 $query =
"SELECT DISTINCT target_ref_id ref FROM conditions ";
204 $ref_ids[] =
$row->ref;
206 return $ref_ids ? $ref_ids : array();
223 $query =
"DELETE FROM conditions ".
224 "WHERE target_ref_id = ".$ilDB->quote($a_target_ref_id,
'integer').
" ".
225 "AND target_type != 'st' ";
239 return $this->condition_reference_type = $a_type;
250 return (
int) $this->condition_reference_type;
256 $this->error_message = $a_msg;
268 return $this->target_ref_id = $a_target_ref_id;
284 return $this->target_obj_id = $a_target_obj_id;
300 return $this->target_type = $a_target_type;
316 return $this->trigger_ref_id = $a_trigger_ref_id;
332 return $this->trigger_obj_id = $a_trigger_obj_id;
348 return $this->trigger_type = $a_trigger_type;
364 return $this->
operator = $a_operator;
380 return $this->value = $a_value;
397 $this->obligatory = $a_obl;
411 $this->hidden_status = $a_status;
425 $this->validation = $a_validate;
435 global $objDefinition;
437 $trigger_types = array(
'crs',
'exc',
'tst',
'sahs',
'svy',
'lm');
439 foreach($objDefinition->getPlugins() as $p_type => $p_info)
441 if(@include_once $p_info[
'location'].
'/class.ilObj'.$p_info[
'class_name'].
'Access.php')
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'))
448 $trigger_types[] = $p_type;
454 $active_triggers = array();
455 foreach($trigger_types as $type)
459 $active_triggers[] = $type;
466 return $active_triggers;
477 global $objDefinition;
482 return array(
'not_member');
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");
490 include_once
'./Services/AccessControl/interfaces/interface.ilConditionHandling.php';
492 $reflection =
new ReflectionClass($full_class);
493 if(!$reflection->implementsInterface(
'ilConditionHandling'))
499 $operators = call_user_func(
500 array($full_class,
'getConditionOperators'),
505 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
509 include_once(
"Services/Object/classes/class.ilObjectLP.php");
512 array_unshift($operators,self::OPERATOR_LP);
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) '.
532 $ilDB->quote($next_id,
'integer').
','.
540 $ilDB->quote($this->
getValue(),
'text').
", ".
548 if ($this->validation && !$this->
validate())
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');
568 return $res->numRows() ?
true :
false;
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').
", ".
582 'obligatory = '.$this->db->quote($this->
getObligatory(),
'integer').
' '.
583 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
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);
617 $query =
"UPDATE conditions SET ".
618 'obligatory = '.$ilDB->quote($a_status,
'integer').
' '.
619 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
629 function delete($a_ref_id)
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');
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');
663 $query =
"DELETE FROM conditions ".
664 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
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');
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;
720 if ($a_target_type ==
"")
726 if (isset(self::$cond_for_target_cache[$a_target_ref_id.
":".$a_target_obj_id.
":".
729 return self::$cond_for_target_cache[$a_target_ref_id.
":".$a_target_obj_id.
":".
734 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];
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');
747 while (
$row = $ilDB->fetchAssoc(
$res))
755 foreach ($rows as
$row)
757 if ($row[
"ref_handling"] == self::UNIQUE_CONDITIONS)
759 if ($row[
"target_ref_id"] != $a_target_ref_id)
765 $row[
"id"] = $row[
"condition_id"];
770 self::$cond_for_target_cache[$a_target_ref_id.
":".$a_target_obj_id.
":".
786 if (is_array($a_obj_ids) && count($a_obj_ids) > 0)
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'));
792 while (
$row = $ilDB->fetchAssoc(
$res))
794 self::$cond_target_rows[$a_type.
":".
$row[
"target_obj_id"]][]
798 foreach ($a_obj_ids as $obj_id)
800 if (!is_array(self::$cond_target_rows[$a_type.
":".$obj_id]))
802 self::$cond_target_rows[$a_type.
":".$obj_id] = array();
812 $query =
"SELECT * FROM conditions ".
813 "WHERE condition_id = ".$ilDB->quote($a_id,
'integer');
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;
845 global
$ilUser, $objDefinition;
847 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
852 if($condition[
'operator'] == self::OPERATOR_LP)
854 include_once
'./Services/Tracking/classes/class.ilLPStatus.php';
858 switch($condition[
'trigger_type'])
861 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
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");
870 $fullfilled = call_user_func(
871 array($full_class,
'checkCondition'),
872 $condition[
'trigger_obj_id'],
873 $condition[
'operator'],
892 if($con[
'obligatory'])
919 $set_obl = $all[0][
'num_obligatory'];
924 $set_obl < count($all) and
925 $set_obl > (count($all) - count($opt) + 1))
932 $result = count($all) - count($opt) + 1;
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);
969 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
979 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
991 if($tree->isDeleted($condition[
'trigger_ref_id']))
1000 if($passed >= $num_required)
1007 if(!count($optional))
1027 $query =
"SELECT * FROM conditions WHERE ".
1028 "trigger_ref_id = ".$ilDB->quote($trigger_obj->getId(),
'integer').
" ".
1029 "AND target_ref_id = ".$ilDB->quote($target_obj->getId(),
'integer');
1032 if(
$res->numRows() > 1)
1034 $this->
setErrorMessage($this->lng->txt(
'condition_already_assigned'));
1036 unset($trigger_obj);
1042 $this->target_obj_id = $target_obj->getId();
1047 unset($trigger_obj);
1058 if($condition[
'trigger_obj_id'] == $this->target_obj_id and $condition[
'operator'] == $this->
getOperator())
1060 $this->circle =
true;
1065 $this->
checkCircle($condition[
'trigger_ref_id'],$condition[
'trigger_obj_id']);
1068 return $this->circle;