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')) {
179 self::_deleteTargetConditionsByRefId($target_ref);
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;
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';
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';
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') .
", " .
545 $query =
"SELECT * FROM conditions " .
546 "WHERE target_ref_id = " . $ilDB->quote($this->
getTargetRefId(),
'integer') .
" " .
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 " .
563 "target_ref_id = " . $ilDB->quote($this->
getTargetRefId(),
'integer') .
", " .
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') .
' ' .
587 'WHERE target_ref_id = ' . $ilDB->quote($this->
getTargetRefId(),
'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');
664 $db = $DIC->database();
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');
745 while (
$row = $ilDB->fetchAssoc(
$res)) {
753 if ($row[
"ref_handling"] == self::UNIQUE_CONDITIONS) {
754 if ($row[
"target_ref_id"] != $a_target_ref_id) {
759 $row[
"id"] = $row[
"condition_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") .
783 " AND target_type = " . $ilDB->quote(
$a_type,
'text'));
785 while (
$row = $ilDB->fetchAssoc(
$res)) {
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'],
874 $conditions = self::_getConditionsOfTarget($a_target_ref_id, $a_target_obj_id);
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)';
920 $all = self::_getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
921 $opt = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_obj_type);
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) {
941 self::saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id,
$result);
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');
959 $ilDB->manipulate(
$query);
970 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
979 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
985 $optional = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
986 $num_required = self::calculateRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
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()) {
1100 self::calculateRequiredTriggers($a_target_ref_id, $tgt_obj_id,
ilObject::_lookupType($tgt_obj_id),
true);
static _checkCondition($a_id, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
storeCondition()
store new condition in database NOT STATIC public
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
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...
setValue($a_value)
set value
setTargetType($a_target_type)
set target object type
static lookupHiddenStatusByTarget($a_target_ref_id)
Lookup hidden status type $ilDB.
static isSupportedObjectType($a_type)
getOperator()
get operator
static _getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
setTargetRefId($a_target_ref_id)
set target ref id
getTriggerRefId()
get target ref id
getObligatory()
Get obligatory 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
static calculateRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
getTargetRefId()
get target ref id
__construct()
constructor public
getTriggerTypes()
get all possible trigger types NOT STATIC public
static _checkCondition($trigger_obj_id, $operator, $value, $a_usr_id=0)
getTargetObjId()
get target obj id
static preloadConditionsForTargetRecords($a_type, $a_obj_ids)
Preload conditions for target records.
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 _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static _lookupObjId($a_id)
static getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
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
Create styles array
The data for the language used.
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
Handles conditions for accesses to different ILIAS objects.
setTriggerRefId($a_trigger_ref_id)
set trigger ref id
getTriggerType()
get trigger obj type
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 _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
getOperatorsByTargetType($a_type)
Get operators by target type.
static getNumberOfConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
getTargetType()
get target obj type
enableAutomaticValidation($a_validate=true)
enable automated validation