126 $ilDB = $DIC[
'ilDB'];
131 $this->validation =
true;
158 public static function lookupEffectiveHiddenStatusByTarget($a_target_ref_id)
162 $obj_definition = $DIC[
"objDefinition"];
163 $tree = $DIC->repositoryTree();
166 $parent_ref_id =
$tree->getParentId($a_target_ref_id);
170 $class = $obj_definition->getClassName($parent_type);
171 $class_name =
"il" . $class .
"ConditionController";
172 $location = $obj_definition->getLocation($parent_type);
175 if ($class !=
"" && is_file(
$location .
"/class." . $class_name .
".php")) {
177 $controller =
new $class_name();
178 if ($controller->isContainerConditionController($parent_ref_id)) {
179 $set = $controller->getConditionSetForRepositoryObject($a_target_ref_id);
180 return $set->getHiddenStatus();
184 return self::lookupPersistedHiddenStatusByTarget($a_target_ref_id);
196 $ilDB = $DIC[
'ilDB'];
198 $query =
'SELECT hidden_status FROM conditions ' .
199 'WHERE target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer');
202 return $row->hidden_status;
223 $tree = $DIC[
'tree'];
225 if (
$tree->checkForParentType($a_ref_id,
'crs')) {
231 $childs =
$tree->getSubTree(
$tree->getNodeData($a_ref_id),
false);
234 foreach (array_intersect(
$conditions, $childs) as $target_ref) {
235 if (!
$tree->checkForParentType($target_ref,
'crs')) {
236 self::_deleteTargetConditionsByRefId($target_ref);
253 $ilDB = $DIC[
'ilDB'];
255 $query =
"SELECT DISTINCT target_ref_id ref FROM conditions ";
258 $ref_ids[] =
$row->ref;
260 return $ref_ids ? $ref_ids : array();
277 $ilDB = $DIC[
'ilDB'];
279 $query =
"DELETE FROM conditions " .
280 "WHERE target_ref_id = " .
$ilDB->quote($a_target_ref_id,
'integer') .
" " .
281 "AND target_type != 'st' ";
295 return $this->condition_reference_type =
$a_type;
306 return (
int) $this->condition_reference_type;
312 $this->error_message = $a_msg;
324 return $this->target_ref_id = $a_target_ref_id;
340 return $this->target_obj_id = $a_target_obj_id;
356 return $this->target_type = $a_target_type;
372 return $this->trigger_ref_id = $a_trigger_ref_id;
388 return $this->trigger_obj_id = $a_trigger_obj_id;
404 return $this->trigger_type = $a_trigger_type;
420 return $this->
operator = $a_operator;
436 return $this->value = $a_value;
453 $this->obligatory = $a_obl;
467 $this->hidden_status = $a_status;
481 $this->validation = $a_validate;
489 public function getTriggerTypes()
494 $objDefinition = $DIC[
'objDefinition'];
496 $trigger_types = array(
'crs',
'exc',
'tst',
'sahs',
'svy',
'lm',
'iass',
'prg',
'copa');
501 foreach ($objDefinition->getAllRepositoryTypes() as
$t) {
503 if (!in_array(
$t, $trigger_types)) {
504 $trigger_types[] =
$t;
510 foreach ($objDefinition->getPlugins() as $p_type => $p_info) {
511 if (@include_once $p_info[
'location'] .
'/class.ilObj' . $p_info[
'class_name'] .
'Access.php') {
512 include_once
'./Services/Conditions/interfaces/interface.ilConditionHandling.php';
513 $name =
'ilObj' . $p_info[
'class_name'] .
'Access';
515 if ($reflection->implementsInterface(
'ilConditionHandling')) {
516 $trigger_types[] = $p_type;
522 $active_triggers = array();
523 foreach ($trigger_types as
$type) {
525 $active_triggers[] =
$type;
532 return $active_triggers;
545 $objDefinition = $DIC[
'objDefinition'];
549 return array(
'not_member');
552 $class = $objDefinition->getClassName(
$a_type);
554 $full_class =
"ilObj" . $class .
"Access";
555 include_once(
$location .
"/class." . $full_class .
".php");
557 include_once
'./Services/Conditions/interfaces/interface.ilConditionHandling.php';
560 if ($reflection->implementsInterface(
'ilConditionHandling')) {
561 $operators = call_user_func(
562 array($full_class,
'getConditionOperators'),
570 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
573 include_once(
"Services/Object/classes/class.ilObjectLP.php");
575 array_unshift($operators, self::OPERATOR_LP);
588 $ilDB = $DIC[
'ilDB'];
591 $next_id =
$ilDB->nextId(
'conditions');
592 $query =
'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
593 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
595 $ilDB->quote($next_id,
'integer') .
',' .
611 if ($this->validation && !$this->
validate()) {
622 $ilDB = $DIC[
'ilDB'];
624 $query =
"SELECT * FROM conditions " .
632 return $res->numRows() ? true :
false;
641 $ilDB = $DIC[
'ilDB'];
643 $query =
"UPDATE conditions SET " .
646 "value = " .
$ilDB->quote($this->
getValue(),
'text') .
", " .
648 'obligatory = ' . $this->db->quote($this->
getObligatory(),
'integer') .
' ' .
649 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
666 $ilDB = $DIC[
'ilDB'];
668 $query =
'UPDATE conditions SET ' .
669 'hidden_status = ' .
$ilDB->quote($a_status,
'integer') .
' ' .
685 $ilDB = $DIC[
'ilDB'];
687 $query =
"UPDATE conditions SET " .
688 'obligatory = ' .
$ilDB->quote($a_status,
'integer') .
' ' .
689 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
699 public function delete($a_ref_id)
703 $ilDB = $DIC[
'ilDB'];
705 $query =
"DELETE FROM conditions WHERE " .
706 "target_ref_id = " .
$ilDB->quote($a_ref_id,
'integer') .
" " .
707 "OR trigger_ref_id = " .
$ilDB->quote($a_ref_id,
'integer');
720 $ilDB = $DIC[
'ilDB'];
722 $query =
"DELETE FROM conditions WHERE " .
723 "target_obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
724 "OR trigger_obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
737 $ilDB = $DIC[
'ilDB'];
739 $query =
"DELETE FROM conditions " .
740 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
757 $db = $DIC->database();
759 $query =
'select count(*) num from conditions ' .
764 return (
int)
$row->num;
775 $ilDB = $DIC[
'ilDB'];
777 $query =
"SELECT * FROM conditions " .
778 "WHERE trigger_obj_id = " .
$ilDB->quote($a_trigger_id,
'integer') .
" " .
779 " AND trigger_type = " .
$ilDB->quote($a_trigger_obj_type,
'text');
783 $tmp_array[
'id'] =
$row->condition_id;
784 $tmp_array[
'target_ref_id'] =
$row->target_ref_id;
785 $tmp_array[
'target_obj_id'] =
$row->target_obj_id;
786 $tmp_array[
'target_type'] =
$row->target_type;
787 $tmp_array[
'trigger_ref_id'] =
$row->trigger_ref_id;
788 $tmp_array[
'trigger_obj_id'] =
$row->trigger_obj_id;
789 $tmp_array[
'trigger_type'] =
$row->trigger_type;
790 $tmp_array[
'operator'] =
$row->operator;
791 $tmp_array[
'value'] =
$row->value;
792 $tmp_array[
'ref_handling'] =
$row->ref_handling;
793 $tmp_array[
'obligatory'] =
$row->obligatory;
794 $tmp_array[
'hidden_status'] =
$row->hidden_status;
810 public static function _getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type =
"")
814 $obj_definition = $DIC[
"objDefinition"];
815 $tree = $DIC->repositoryTree();
818 if ($a_target_type ==
"") {
823 $parent_ref_id =
$tree->getParentId($a_target_ref_id);
827 $class = $obj_definition->getClassName($parent_type);
828 $class_name =
"il" . $class .
"ConditionController";
829 $location = $obj_definition->getLocation($parent_type);
832 if ($class !=
"" && is_file(
$location .
"/class." . $class_name .
".php")
835 $controller =
new $class_name();
836 if ($controller->isContainerConditionController($parent_ref_id)) {
838 $set = $controller->getConditionSetForRepositoryObject($a_target_ref_id);
842 foreach ($set->getConditions() as
$c) {
845 :
$c->getObligatory();
846 $trigger =
$c->getTrigger();
848 "target_ref_id" => $a_target_ref_id,
849 "target_obj_id" => $a_target_obj_id,
850 "target_type" => $a_target_type,
851 "trigger_ref_id" => $trigger->getRefId(),
852 "trigger_obj_id" => $trigger->getObjId(),
853 "trigger_type" => $trigger->getType(),
854 "operator" =>
$c->getOperator(),
855 "value" =>
$c->getValue(),
858 "num_obligatory" => $set->getNumObligatory(),
859 "hidden_status" => (int) $set->getHiddenStatus()
866 return self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type);
880 $ilDB = $DIC[
'ilDB'];
883 if ($a_target_type ==
"") {
888 if (isset(self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
890 return self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
895 if (isset(self::$cond_target_rows[$a_target_type .
":" . $a_target_obj_id])) {
896 $rows = self::$cond_target_rows[$a_target_type .
":" . $a_target_obj_id];
899 $query =
"SELECT * FROM conditions " .
900 "WHERE target_obj_id = " .
$ilDB->quote($a_target_obj_id,
'integer') .
" " .
901 " AND target_type = " .
$ilDB->quote($a_target_type,
'text');
913 if ($row[
"ref_handling"] == self::UNIQUE_CONDITIONS) {
914 if ($row[
"target_ref_id"] != $a_target_ref_id) {
919 $row[
"id"] = $row[
"condition_id"];
924 self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
940 $ilDB = $DIC[
'ilDB'];
942 if (is_array($a_obj_ids) && count($a_obj_ids) > 0) {
943 $res =
$ilDB->query(
"SELECT * FROM conditions " .
944 "WHERE " .
$ilDB->in(
"target_obj_id", $a_obj_ids,
false,
"integer") .
948 self::$cond_target_rows[
$a_type .
":" .
$row[
"target_obj_id"]][]
952 foreach ($a_obj_ids as $obj_id) {
953 if (!is_array(self::$cond_target_rows[
$a_type .
":" . $obj_id])) {
954 self::$cond_target_rows[
$a_type .
":" . $obj_id] = array();
964 $ilDB = $DIC[
'ilDB'];
966 $query =
"SELECT * FROM conditions " .
967 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
971 $tmp_array[
'id'] =
$row->condition_id;
972 $tmp_array[
'target_ref_id'] =
$row->target_ref_id;
973 $tmp_array[
'target_obj_id'] =
$row->target_obj_id;
974 $tmp_array[
'target_type'] =
$row->target_type;
975 $tmp_array[
'trigger_ref_id'] =
$row->trigger_ref_id;
976 $tmp_array[
'trigger_obj_id'] =
$row->trigger_obj_id;
977 $tmp_array[
'trigger_type'] =
$row->trigger_type;
978 $tmp_array[
'operator'] =
$row->operator;
979 $tmp_array[
'value'] =
$row->value;
980 $tmp_array[
'ref_handling'] =
$row->ref_handling;
981 $tmp_array[
'obligatory'] =
$row->obligatory;
982 $tmp_array[
'hidden_status'] =
$row->hidden_status;
1001 $objDefinition = $DIC[
'objDefinition'];
1003 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
1008 if ($condition[
'operator'] == self::OPERATOR_LP) {
1009 include_once
'./Services/Tracking/classes/class.ilLPStatus.php';
1013 switch ($condition[
'trigger_type']) {
1015 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
1019 $class = $objDefinition->getClassName($condition[
'trigger_type']);
1020 $location = $objDefinition->getLocation($condition[
'trigger_type']);
1021 $full_class =
"ilObj" . $class .
"Access";
1022 include_once(
$location .
"/class." . $full_class .
".php");
1024 $fullfilled = call_user_func(
1025 array($full_class,
'checkCondition'),
1026 $condition[
'trigger_obj_id'],
1027 $condition[
'operator'],
1028 $condition[
'value'],
1043 $conditions = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1047 if ($con[
'obligatory']) {
1065 $conditions = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1069 if ($con[
'obligatory']) {
1088 $ilDB = $DIC[
'ilDB'];
1090 $query =
'SELECT max(num_obligatory) obl from conditions WHERE ' .
1091 'target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer') .
' ' .
1092 'AND target_obj_id = ' .
$ilDB->quote($a_target_obj_id,
'integer') .
' ' .
1093 'GROUP BY (num_obligatory)';
1113 $ilDB = $DIC[
'ilDB'];
1116 $all = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1117 $opt = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1120 if (isset($all[0])) {
1121 $set_obl = $all[0][
'num_obligatory'];
1125 if ($set_obl > 0
and 1126 $set_obl < count($all)
and 1127 $set_obl > (count($all) - count($opt) + 1)) {
1132 $result = count($all) - count($opt) + 1;
1149 $ilDB = $DIC[
'ilDB'];
1152 $all = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1153 $opt = self::getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1156 if (isset($all[0])) {
1157 $set_obl = $all[0][
'num_obligatory'];
1161 if ($set_obl > 0
and 1162 $set_obl < count($all)
and 1163 $set_obl > (count($all) - count($opt) + 1)) {
1168 $result = count($all) - count($opt) + 1;
1172 if ($a_force_update) {
1173 self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id,
$result);
1187 $ilDB = $DIC[
'ilDB'];
1189 $query =
'UPDATE conditions ' .
1190 'SET num_obligatory = ' .
$ilDB->quote($a_num,
'integer') .
' ' .
1191 'WHERE target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer') .
' ' .
1192 'AND target_obj_id = ' .
$ilDB->quote($a_target_obj_id,
'integer');
1205 $tree = $DIC[
'tree'];
1207 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
1209 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1216 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
1222 $optional = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1223 $num_required = self::calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1226 if (
$tree->isDeleted($condition[
'trigger_ref_id'])) {
1233 if ($passed >= $num_required) {
1237 if (!count($optional)) {
1251 $ilDB = $DIC[
'ilDB'];
1258 $query =
"SELECT * FROM conditions WHERE " .
1259 "trigger_ref_id = " .
$ilDB->quote($trigger_obj->getRefId(),
'integer') .
" " .
1260 "AND target_ref_id = " .
$ilDB->quote($target_obj->getRefId(),
'integer');
1263 if (
$res->numRows() > 1) {
1264 $this->
setErrorMessage($this->lng->txt(
'condition_already_assigned'));
1266 unset($trigger_obj);
1272 $this->target_obj_id = $target_obj->getId();
1276 unset($trigger_obj);
1286 if ($condition[
'trigger_obj_id'] == $this->target_obj_id
and $condition[
'operator'] == $this->
getOperator()) {
1287 $this->circle =
true;
1290 $this->
checkCircle($condition[
'trigger_ref_id'], $condition[
'trigger_obj_id']);
1293 return $this->circle;
1298 include_once
'./Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1300 $mappings = $cwo->getMappings();
1305 if ($mappings[$con[
'trigger_ref_id']]) {
1311 $newCondition->setTargetRefId($a_target_ref_id);
1312 $newCondition->setTargetObjId($target_obj);
1313 $newCondition->setTargetType($target_typ);
1315 $trigger_ref = $mappings[$con[
'trigger_ref_id']];
1319 $newCondition->setTriggerRefId($trigger_ref);
1320 $newCondition->setTriggerObjId($trigger_obj);
1321 $newCondition->setTriggerType($trigger_typ);
1322 $newCondition->setOperator($con[
'operator']);
1323 $newCondition->setValue($con[
'value']);
1324 $newCondition->setReferenceHandlingType($con[
'ref_handling']);
1325 $newCondition->setObligatory($con[
'obligatory']);
1328 $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1330 if ($newCondition->storeCondition()) {
1339 self::calculatePersistedRequiredTriggers($a_target_ref_id, $tgt_obj_id,
ilObject::_lookupType($tgt_obj_id),
true);
storeCondition()
store new condition in database
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
static _getPersistedConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
Get all persisted conditions of trigger object Note: This only gets persisted conditions NOT (dynamic...
deleteByObjId($a_obj_id)
delete all trigger and target entries This method is called from ilObject::delete() if an object is r...
setValue($a_value)
set value
setTargetType($a_target_type)
set target object type
static isSupportedObjectType($a_type)
getOperator()
get operator
static _checkCondition($condition, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
setTargetRefId($a_target_ref_id)
set target ref id
getTriggerRefId()
get target ref id
static calculatePersistedRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
getObligatory()
Get obligatory status.
static lookupPersistedHiddenStatusByTarget($a_target_ref_id)
Lookup persistedhidden status.
static $cond_for_target_cache
getReferenceHandlingType()
get reference handling type
static lookupObligatoryConditionsOfTarget($a_target_ref_id, $a_target_obj_id)
Lookup obligatory conditions of target.
setTriggerObjId($a_trigger_obj_id)
set trigger object id
getTargetRefId()
get target ref id
__construct()
constructor public
static calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='')
calculate number of obligatory items
static _checkCondition($trigger_obj_id, $operator, $value, $a_usr_id=0)
getTargetObjId()
get target obj id
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static _lookupObjId($a_id)
static _getDistinctTargetRefIds()
Get all target ref ids.
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
getTriggerObjId()
get trigger obj id
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
const OPERATOR_ACCREDITED_OR_PASSED
const OPERATOR_NOT_FINISHED
static _lookupType($a_id, $a_reference=false)
lookup object type
checkCircle($a_ref_id, $a_obj_id)
setTriggerType($a_trigger_type)
set trigger object type
getOperatorsByTriggerType($a_type)
Get operators by trigger type.
INTERNAL CLASS: Please do not use in consumer code.
setTriggerRefId($a_trigger_ref_id)
set trigger ref id
getTriggerType()
get trigger obj type
static preloadPersistedConditionsForTargetRecords($a_type, $a_obj_ids)
Preload conditions for target records.
static getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
setTargetObjId($a_target_obj_id)
set target object id
static _isReferenceHandlingOptional($a_type)
is reference handling optional
setOperator($a_operator)
set operator
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
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 getInstance()
Get instance.
updateHiddenStatus($a_status)
Update hidden status type $ilDB.
setReferenceHandlingType($a_type)
set reference handling type
setObligatory($a_obl)
Set obligatory status.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
static _getCondition($a_id)
static cloneDependencies($a_src_ref_id, $a_target_ref_id, $a_copy_id)
deleteCondition($a_id)
delete condition
updateCondition($a_id)
update condition
setHiddenStatus($a_status)
const OPERATOR_NOT_MEMBER
static getNumberOfConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
getTargetType()
get target obj type
enableAutomaticValidation($a_validate=true)
enable automated validation