126 $ilDB = $DIC[
'ilDB'];
131 $this->validation =
true;
136 self::$cond_for_target_cache = [];
137 self::$cond_target_rows = [];
164 public static function lookupEffectiveHiddenStatusByTarget($a_target_ref_id)
168 $obj_definition = $DIC[
"objDefinition"];
169 $tree = $DIC->repositoryTree();
172 $parent_ref_id = $tree->getParentId($a_target_ref_id);
176 $class = $obj_definition->getClassName($parent_type);
177 $class_name =
"il" . $class .
"ConditionController";
178 $location = $obj_definition->getLocation($parent_type);
181 if ($class !=
"" && is_file(
$location .
"/class." . $class_name .
".php")) {
183 $controller =
new $class_name();
184 if ($controller->isContainerConditionController($parent_ref_id)) {
185 $set = $controller->getConditionSetForRepositoryObject($a_target_ref_id);
186 return $set->getHiddenStatus();
190 return self::lookupPersistedHiddenStatusByTarget($a_target_ref_id);
202 $ilDB = $DIC[
'ilDB'];
204 $query =
'SELECT hidden_status FROM conditions ' .
205 'WHERE target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer');
208 return $row->hidden_status;
229 $tree = $DIC[
'tree'];
231 if ($tree->checkForParentType($a_ref_id,
'crs')) {
237 $childs = $tree->getSubTree($tree->getNodeData($a_ref_id),
false);
240 foreach (array_intersect(
$conditions, $childs) as $target_ref) {
241 if (!$tree->checkForParentType($target_ref,
'crs')) {
242 self::_deleteTargetConditionsByRefId($target_ref);
259 $ilDB = $DIC[
'ilDB'];
261 $query =
"SELECT DISTINCT target_ref_id ref FROM conditions ";
264 $ref_ids[] = $row->ref;
266 return $ref_ids ? $ref_ids : array();
283 $ilDB = $DIC[
'ilDB'];
285 $query =
"DELETE FROM conditions " .
286 "WHERE target_ref_id = " .
$ilDB->quote($a_target_ref_id,
'integer') .
" " .
287 "AND target_type != 'st' ";
301 return $this->condition_reference_type = $a_type;
312 return (
int) $this->condition_reference_type;
318 $this->error_message = $a_msg;
330 return $this->target_ref_id = $a_target_ref_id;
346 return $this->target_obj_id = $a_target_obj_id;
362 return $this->target_type = $a_target_type;
378 return $this->trigger_ref_id = $a_trigger_ref_id;
394 return $this->trigger_obj_id = $a_trigger_obj_id;
410 return $this->trigger_type = $a_trigger_type;
426 return $this->
operator = $a_operator;
442 return $this->value = $a_value;
459 $this->obligatory = $a_obl;
473 $this->hidden_status = $a_status;
487 $this->validation = $a_validate;
495 public function getTriggerTypes()
500 $objDefinition = $DIC[
'objDefinition'];
502 $trigger_types = array(
'crs',
'exc',
'tst',
'sahs',
'svy',
'lm',
'iass',
'prg',
'copa',
'lti',
'cmix');
507 foreach ($objDefinition->getAllRepositoryTypes() as $t) {
509 if (!in_array($t, $trigger_types)) {
510 $trigger_types[] = $t;
516 foreach ($objDefinition->getPlugins() as $p_type => $p_info) {
517 if (@include_once $p_info[
'location'] .
'/class.ilObj' . $p_info[
'class_name'] .
'Access.php') {
518 include_once
'./Services/Conditions/interfaces/interface.ilConditionHandling.php';
519 $name =
'ilObj' . $p_info[
'class_name'] .
'Access';
521 if ($reflection->implementsInterface(
'ilConditionHandling')) {
522 $trigger_types[] = $p_type;
528 $active_triggers = array();
529 foreach ($trigger_types as
$type) {
531 $active_triggers[] =
$type;
538 return $active_triggers;
551 $objDefinition = $DIC[
'objDefinition'];
555 return array(
'not_member');
558 $class = $objDefinition->getClassName($a_type);
559 $location = $objDefinition->getLocation($a_type);
560 $full_class =
"ilObj" . $class .
"Access";
561 include_once(
$location .
"/class." . $full_class .
".php");
563 include_once
'./Services/Conditions/interfaces/interface.ilConditionHandling.php';
566 if ($reflection->implementsInterface(
'ilConditionHandling')) {
567 $operators = call_user_func(
568 array($full_class,
'getConditionOperators'),
576 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
579 include_once(
"Services/Object/classes/class.ilObjectLP.php");
581 array_unshift($operators, self::OPERATOR_LP);
594 $ilDB = $DIC[
'ilDB'];
597 $next_id =
$ilDB->nextId(
'conditions');
598 $query =
'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,' .
599 'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory,hidden_status) ' .
601 $ilDB->quote($next_id,
'integer') .
',' .
617 if ($this->validation && !$this->
validate()) {
628 $ilDB = $DIC[
'ilDB'];
630 $query =
"SELECT * FROM conditions " .
638 return $res->numRows() ? true :
false;
647 $ilDB = $DIC[
'ilDB'];
649 $query =
"UPDATE conditions SET " .
652 "value = " .
$ilDB->quote($this->
getValue(),
'text') .
", " .
654 'obligatory = ' . $this->db->quote($this->
getObligatory(),
'integer') .
' ' .
655 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
672 $ilDB = $DIC[
'ilDB'];
674 $query =
'UPDATE conditions SET ' .
675 'hidden_status = ' .
$ilDB->quote($a_status,
'integer') .
' ' .
691 $ilDB = $DIC[
'ilDB'];
693 $query =
"UPDATE conditions SET " .
694 'obligatory = ' .
$ilDB->quote($a_status,
'integer') .
' ' .
695 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
705 public function delete($a_ref_id)
709 $ilDB = $DIC[
'ilDB'];
711 $query =
"DELETE FROM conditions WHERE " .
712 "target_ref_id = " .
$ilDB->quote($a_ref_id,
'integer') .
" " .
713 "OR trigger_ref_id = " .
$ilDB->quote($a_ref_id,
'integer');
726 $ilDB = $DIC[
'ilDB'];
728 $query =
"DELETE FROM conditions WHERE " .
729 "target_obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
730 "OR trigger_obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
743 $ilDB = $DIC[
'ilDB'];
745 $query =
"DELETE FROM conditions " .
746 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
763 $db = $DIC->database();
765 $query =
'select count(*) num from conditions ' .
770 return (
int) $row->num;
781 $ilDB = $DIC[
'ilDB'];
783 $query =
"SELECT * FROM conditions " .
784 "WHERE trigger_obj_id = " .
$ilDB->quote($a_trigger_id,
'integer') .
" " .
785 " AND trigger_type = " .
$ilDB->quote($a_trigger_obj_type,
'text');
789 $tmp_array[
'id'] = $row->condition_id;
790 $tmp_array[
'target_ref_id'] = $row->target_ref_id;
791 $tmp_array[
'target_obj_id'] = $row->target_obj_id;
792 $tmp_array[
'target_type'] = $row->target_type;
793 $tmp_array[
'trigger_ref_id'] = $row->trigger_ref_id;
794 $tmp_array[
'trigger_obj_id'] = $row->trigger_obj_id;
795 $tmp_array[
'trigger_type'] = $row->trigger_type;
796 $tmp_array[
'operator'] = $row->operator;
797 $tmp_array[
'value'] = $row->value;
798 $tmp_array[
'ref_handling'] = $row->ref_handling;
799 $tmp_array[
'obligatory'] = $row->obligatory;
800 $tmp_array[
'hidden_status'] = $row->hidden_status;
816 public static function _getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type =
"")
820 $obj_definition = $DIC[
"objDefinition"];
821 $tree = $DIC->repositoryTree();
824 if ($a_target_type ==
"") {
829 $parent_ref_id = $tree->getParentId($a_target_ref_id);
833 $class = $obj_definition->getClassName($parent_type);
834 $class_name =
"il" . $class .
"ConditionController";
835 $location = $obj_definition->getLocation($parent_type);
838 if ($class !=
"" && is_file(
$location .
"/class." . $class_name .
".php")
841 $controller =
new $class_name();
842 if ($controller->isContainerConditionController($parent_ref_id)) {
844 $set = $controller->getConditionSetForRepositoryObject($a_target_ref_id);
848 foreach ($set->getConditions() as
$c) {
851 :
$c->getObligatory();
852 $trigger =
$c->getTrigger();
854 "target_ref_id" => $a_target_ref_id,
855 "target_obj_id" => $a_target_obj_id,
856 "target_type" => $a_target_type,
857 "trigger_ref_id" => $trigger->getRefId(),
858 "trigger_obj_id" => $trigger->getObjId(),
859 "trigger_type" => $trigger->getType(),
860 "operator" =>
$c->getOperator(),
861 "value" =>
$c->getValue(),
864 "num_obligatory" => $set->getNumObligatory(),
865 "hidden_status" => (int) $set->getHiddenStatus()
872 return self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type);
886 $ilDB = $DIC[
'ilDB'];
889 if ($a_target_type ==
"") {
894 if (isset(self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
896 return self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
901 if (isset(self::$cond_target_rows[$a_target_type .
":" . $a_target_obj_id])) {
902 $rows = self::$cond_target_rows[$a_target_type .
":" . $a_target_obj_id];
905 $query =
"SELECT * FROM conditions " .
906 "WHERE target_obj_id = " .
$ilDB->quote($a_target_obj_id,
'integer') .
" " .
907 " AND target_type = " .
$ilDB->quote($a_target_type,
'text');
918 foreach (
$rows as $row) {
919 if ($row[
"ref_handling"] == self::UNIQUE_CONDITIONS) {
920 if ($row[
"target_ref_id"] != $a_target_ref_id) {
925 $row[
"id"] = $row[
"condition_id"];
930 self::$cond_for_target_cache[$a_target_ref_id .
":" . $a_target_obj_id .
":" .
946 $ilDB = $DIC[
'ilDB'];
948 if (is_array($a_obj_ids) && count($a_obj_ids) > 0) {
949 $res =
$ilDB->query(
"SELECT * FROM conditions " .
950 "WHERE " .
$ilDB->in(
"target_obj_id", $a_obj_ids,
false,
"integer") .
951 " AND target_type = " .
$ilDB->quote($a_type,
'text'));
954 self::$cond_target_rows[$a_type .
":" . $row[
"target_obj_id"]][]
958 foreach ($a_obj_ids as $obj_id) {
959 if (!is_array(self::$cond_target_rows[$a_type .
":" . $obj_id])) {
960 self::$cond_target_rows[$a_type .
":" . $obj_id] = array();
970 $ilDB = $DIC[
'ilDB'];
972 $query =
"SELECT * FROM conditions " .
973 "WHERE condition_id = " .
$ilDB->quote($a_id,
'integer');
977 $tmp_array[
'id'] = $row->condition_id;
978 $tmp_array[
'target_ref_id'] = $row->target_ref_id;
979 $tmp_array[
'target_obj_id'] = $row->target_obj_id;
980 $tmp_array[
'target_type'] = $row->target_type;
981 $tmp_array[
'trigger_ref_id'] = $row->trigger_ref_id;
982 $tmp_array[
'trigger_obj_id'] = $row->trigger_obj_id;
983 $tmp_array[
'trigger_type'] = $row->trigger_type;
984 $tmp_array[
'operator'] = $row->operator;
985 $tmp_array[
'value'] = $row->value;
986 $tmp_array[
'ref_handling'] = $row->ref_handling;
987 $tmp_array[
'obligatory'] = $row->obligatory;
988 $tmp_array[
'hidden_status'] = $row->hidden_status;
1007 $objDefinition = $DIC[
'objDefinition'];
1009 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
1014 if ($condition[
'operator'] == self::OPERATOR_LP) {
1015 include_once
'./Services/Tracking/classes/class.ilLPStatus.php';
1019 switch ($condition[
'trigger_type']) {
1021 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
1025 $class = $objDefinition->getClassName($condition[
'trigger_type']);
1026 $location = $objDefinition->getLocation($condition[
'trigger_type']);
1027 $full_class =
"ilObj" . $class .
"Access";
1028 include_once(
$location .
"/class." . $full_class .
".php");
1030 $fullfilled = call_user_func(
1031 array($full_class,
'checkCondition'),
1032 $condition[
'trigger_obj_id'],
1033 $condition[
'operator'],
1034 $condition[
'value'],
1049 $conditions = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1053 if ($con[
'obligatory']) {
1071 $conditions = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
1075 if ($con[
'obligatory']) {
1094 $ilDB = $DIC[
'ilDB'];
1096 $query =
'SELECT max(num_obligatory) obl from conditions WHERE ' .
1097 'target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer') .
' ' .
1098 'AND target_obj_id = ' .
$ilDB->quote($a_target_obj_id,
'integer') .
' ' .
1099 'GROUP BY (num_obligatory)';
1119 $ilDB = $DIC[
'ilDB'];
1122 $all = self::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1123 $opt = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1126 if (isset($all[0])) {
1127 $set_obl = $all[0][
'num_obligatory'];
1131 if ($set_obl > 0 and
1132 $set_obl < count($all) and
1133 $set_obl > (count($all) - count($opt) + 1)) {
1138 $result = count($all) - count($opt) + 1;
1155 $ilDB = $DIC[
'ilDB'];
1160 $all = self::_getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1161 $opt = self::getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
1164 if (isset($all[0])) {
1165 $set_obl = $all[0][
'num_obligatory'];
1169 if ($set_obl > 0 and
1170 $set_obl < count($all) and
1171 $set_obl > (count($all) - count($opt) + 1)) {
1176 $result = count($all) - count($opt) + 1;
1180 if ($a_force_update) {
1181 self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id,
$result);
1195 $ilDB = $DIC[
'ilDB'];
1197 $query =
'UPDATE conditions ' .
1198 'SET num_obligatory = ' .
$ilDB->quote($a_num,
'integer') .
' ' .
1199 'WHERE target_ref_id = ' .
$ilDB->quote($a_target_ref_id,
'integer') .
' ' .
1200 'AND target_obj_id = ' .
$ilDB->quote($a_target_obj_id,
'integer');
1213 $tree = $DIC[
'tree'];
1214 $logger = $DIC->logger()->ac();
1216 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
1218 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1225 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
1231 $optional = self::getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
1232 $num_required = self::calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
1235 if ($tree->isDeleted($condition[
'trigger_ref_id'])) {
1244 if ($condition[
'obligatory']) {
1249 if ($passed >= $num_required) {
1262 $ilDB = $DIC[
'ilDB'];
1269 $query =
"SELECT * FROM conditions WHERE " .
1270 "trigger_ref_id = " .
$ilDB->quote($trigger_obj->getRefId(),
'integer') .
" " .
1271 "AND target_ref_id = " .
$ilDB->quote($target_obj->getRefId(),
'integer');
1274 if (
$res->numRows() > 1) {
1275 $this->
setErrorMessage($this->lng->txt(
'condition_already_assigned'));
1277 unset($trigger_obj);
1283 $this->target_obj_id = $target_obj->getId();
1287 unset($trigger_obj);
1297 if ($condition[
'trigger_obj_id'] == $this->target_obj_id and $condition[
'operator'] == $this->
getOperator()) {
1298 $this->circle =
true;
1301 $this->
checkCircle($condition[
'trigger_ref_id'], $condition[
'trigger_obj_id']);
1304 return $this->circle;
1309 include_once
'./Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1311 $mappings = $cwo->getMappings();
1316 if ($mappings[$con[
'trigger_ref_id']]) {
1322 $newCondition->setTargetRefId($a_target_ref_id);
1323 $newCondition->setTargetObjId($target_obj);
1324 $newCondition->setTargetType($target_typ);
1326 $trigger_ref = $mappings[$con[
'trigger_ref_id']];
1330 $newCondition->setTriggerRefId($trigger_ref);
1331 $newCondition->setTriggerObjId($trigger_obj);
1332 $newCondition->setTriggerType($trigger_typ);
1333 $newCondition->setOperator($con[
'operator']);
1334 $newCondition->setValue($con[
'value']);
1335 $newCondition->setReferenceHandlingType($con[
'ref_handling']);
1336 $newCondition->setObligatory($con[
'obligatory']);
1339 $newCondition->setHiddenStatus(self::lookupPersistedHiddenStatusByTarget($a_src_ref_id));
1341 if ($newCondition->storeCondition()) {
1345 self::saveNumberOfRequiredTriggers(
1348 $con[
'num_obligatory']
1357 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
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 isSupportedObjectType($type)
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...
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