131        $this->validation = 
true;
 
  158    public static function lookupEffectiveHiddenStatusByTarget($a_target_ref_id)
 
  162        $obj_definition = 
$DIC[
"objDefinition"];
 
  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();
 
  198        $query = 
'SELECT hidden_status FROM conditions ' .
 
  199                'WHERE target_ref_id = ' . 
$ilDB->quote($a_target_ref_id, 
'integer');
 
  202            return $row->hidden_status;
 
  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')) {
 
  255        $query = 
"SELECT DISTINCT target_ref_id ref FROM conditions ";
 
  258            $ref_ids[] = 
$row->ref;
 
  260        return $ref_ids ? $ref_ids : array();
 
  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';
 
  514                $reflection = 
new ReflectionClass(
$name);
 
  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';
 
  559        $reflection = 
new ReflectionClass($full_class);
 
  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);
 
  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()) {
 
  624        $query = 
"SELECT * FROM conditions " .
 
  632        return $res->numRows() ? true : 
false;
 
  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');
 
  668        $query = 
'UPDATE conditions SET ' .
 
  669                'hidden_status = ' . 
$ilDB->quote($a_status, 
'integer') . 
' ' .
 
  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)
 
  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');
 
  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');
 
  739        $query = 
"DELETE FROM conditions " .
 
  740            "WHERE condition_id = " . 
$ilDB->quote($a_id, 
'integer');
 
  759        $query = 
'select count(*) num from conditions ' .
 
  764        return (
int) 
$row->num;
 
  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"];
 
  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()
 
  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) {
 
  924        self::$cond_for_target_cache[$a_target_ref_id . 
":" . $a_target_obj_id . 
":" .
 
  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();
 
  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']) {
 
 1069            if ($con[
'obligatory']) {
 
 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)';
 
 1116        $all = self::_getEffectiveConditionsOfTarget($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;
 
 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) {
 
 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');
 
 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';
 
 1226            if (
$tree->isDeleted($condition[
'trigger_ref_id'])) {
 
 1233                if ($passed >= $num_required) {
 
 1237                if (!count($optional)) {
 
 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()) {
 
An exception for terminatinating execution or to throw for unit testing.
INTERNAL CLASS: Please do not use in consumer code.
getOperatorsByTriggerType($a_type)
Get operators by trigger type.
static _checkCondition($condition, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
getTargetType()
get target obj type
static calculatePersistedRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
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
setTargetType($a_target_type)
set target object type
static _getCondition($a_id)
setTargetObjId($a_target_obj_id)
set target object id
getTriggerRefId()
get target ref id
setTriggerRefId($a_trigger_ref_id)
set trigger ref id
getTargetRefId()
get target ref id
getTriggerType()
get trigger obj type
__construct()
constructor @access public
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.
getOperator()
get operator
deleteCondition($a_id)
delete condition
getReferenceHandlingType()
get reference handling type
getObligatory()
Get obligatory status.
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
static calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='')
calculate number of obligatory items
storeCondition()
store new condition in database
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 getNumberOfConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
setTargetRefId($a_target_ref_id)
set target ref id
setOperator($a_operator)
set operator
enableAutomaticValidation($a_validate=true)
enable automated validation
setReferenceHandlingType($a_type)
set reference handling type
static _getDistinctTargetRefIds()
Get all target ref ids.
static lookupPersistedHiddenStatusByTarget($a_target_ref_id)
Lookup persistedhidden status.
setObligatory($a_obl)
Set obligatory status.
static cloneDependencies($a_src_ref_id, $a_target_ref_id, $a_copy_id)
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
static $cond_for_target_cache
static _getPersistedConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
Get all persisted conditions of trigger object Note: This only gets persisted conditions NOT (dynamic...
setTriggerType($a_trigger_type)
set trigger object type
updateHiddenStatus($a_status)
Update hidden status @global type $ilDB.
checkCircle($a_ref_id, $a_obj_id)
getTargetObjId()
get target obj id
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted 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...
setHiddenStatus($a_status)
updateCondition($a_id)
update condition
setTriggerObjId($a_trigger_obj_id)
set trigger object id
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
const OPERATOR_NOT_FINISHED
getTriggerObjId()
get trigger obj id
const OPERATOR_NOT_MEMBER
static _isReferenceHandlingOptional($a_type)
is reference handling optional
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
const OPERATOR_ACCREDITED_OR_PASSED
setValue($a_value)
set value
static lookupObligatoryConditionsOfTarget($a_target_ref_id, $a_target_obj_id)
Lookup obligatory conditions of target.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static getInstance()
Get instance.
static _checkCondition($trigger_obj_id, $operator, $value, $a_usr_id=0)
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static isSupportedObjectType($a_type)
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
foreach($_POST as $key=> $value) $res