ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilConditionHandler Class Reference

Handles conditions for accesses to different ILIAS objects. More...

+ Collaboration diagram for ilConditionHandler:

Public Member Functions

 ilConditionHandler ()
 constructor public
 setReferenceHandlingType ($a_type)
 set reference handling type
 getReferenceHandlingType ()
 get reference handling type
 setErrorMessage ($a_msg)
 getErrorMessage ()
 setTargetRefId ($a_target_ref_id)
 set target ref id
 getTargetRefId ()
 get target ref id
 setTargetObjId ($a_target_obj_id)
 set target object id
 getTargetObjId ()
 get target obj id
 setTargetType ($a_target_type)
 set target object type
 getTargetType ()
 get target obj type
 setTriggerRefId ($a_trigger_ref_id)
 set trigger ref id
 getTriggerRefId ()
 get target ref id
 setTriggerObjId ($a_trigger_obj_id)
 set trigger object id
 getTriggerObjId ()
 get trigger obj id
 setTriggerType ($a_trigger_type)
 set trigger object type
 getTriggerType ()
 get trigger obj type
 setOperator ($a_operator)
 set operator
 getOperator ()
 get operator
 setValue ($a_value)
 set value
 getValue ()
 get value
 setObligatory ($a_obl)
 Set obligatory status.
 getObligatory ()
 Get obligatory status.
 enableAutomaticValidation ($a_validate=true)
 enable automated validation
 getTriggerTypes ()
 get all possible trigger types NOT STATIC public
 getOperatorsByTargetType ($a_type)
 storeCondition ()
 store new condition in database NOT STATIC public
 checkExists ()
 updateCondition ($a_id)
 update condition
 delete ($a_ref_id)
 delete all trigger and target entries This method is called from ilObject::delete() if an object os removed from trash
 deleteByObjId ($a_obj_id)
 delete all trigger and target entries This method is called from ilObject::delete() if an object is removed from trash
 deleteCondition ($a_id)
 delete condition
 preloadConditionsForTargetRecords ($a_type, $a_obj_ids)
 Preload conditions for target records.
 _getCondition ($a_id)
 _checkCondition ($a_id, $a_usr_id=0)
 checks wether a single condition is fulfilled every trigger object type must implement a static method _checkCondition($a_operator, $a_value)
 _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
 validate ()
 checkCircle ($a_ref_id, $a_obj_id)

Static Public Member Functions

static _isReferenceHandlingOptional ($a_type)
 is reference handling optional
static _adjustMovedObjectConditions ($a_ref_id)
 In the moment it is not allowed to create preconditions on objects that are located outside of a course.
static _getDistinctTargetRefIds ()
 Get all target ref ids.
static _deleteTargetConditionsByRefId ($a_target_ref_id)
 Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on e.g chapters are not handled.
static updateObligatory ($a_id, $a_status)
 Toggle condition obligatory status.
 _getConditionsOfTrigger ($a_trigger_obj_type, $a_trigger_id)
 get all conditions of trigger object
static _getConditionsOfTarget ($a_target_ref_id, $a_target_obj_id, $a_target_type="")
 get all conditions of target object
static getOptionalConditionsOfTarget ($a_target_ref_id, $a_target_obj_id, $a_obj_type= '')
 Get optional conditions.
static calculateRequiredTriggers ($a_target_ref_id, $a_target_obj_id, $a_target_obj_type= '', $a_force_update=false)
 calculate number of obligatory items
static saveNumberOfRequiredTriggers ($a_target_ref_id, $a_target_obj_id, $a_num)
 Save number of obigatory triggers.

Data Fields

const UNIQUE_CONDITIONS = 1
const SHARED_CONDITIONS = 0
 $db
 $lng
 $error_message
 $target_obj_id
 $target_ref_id
 $target_type
 $trigger_obj_id
 $trigger_ref_id
 $trigger_type
 $operator
 $value
 $validation
 $conditions

Static Public Attributes

static $cond_for_target_cache = array()
static $cond_target_rows = array()

Private Attributes

 $obligatory = true

Detailed Description

Handles conditions for accesses to different ILIAS objects.

A condition consists of four elements:

  • a trigger object, e.g. a test or a survey question
  • an operator, e.g. "=", "<", "passed"
  • an (optional) value, e.g. "5"
  • a target object, e.g. a learning module

If a condition is fulfilled for a certain user, (s)he may access the target object. This first implementation handles only one access type per object, which is usually "read" access. A possible future extension may implement different access types.

The condition data is stored in the database table "condition" (Note: This table must not be accessed directly from other classes. The data should be accessed via the interface of class ilCondition.) cond_id INT condition id trigger_obj_type VARCHAR(10) "crs" | "tst" | "qst", ... trigger_id INT obj id of trigger object operator varchar(10 "=", "<", ">", ">=", "<=", "passed", "contains", ... value VARCHAR(10) optional value target_obj_type VARCHAR(10) "lm" | "frm" | "st" | "pg", ... target_id object or reference id of target object

Trigger objects are always stored with their object id (if a test has been passed by a user, he doesn't need to repeat it in other contexts. But target objects are usually stored with their reference id if available, otherwise, if they are non-referenced objects (e.g. (survey) questions) they are stored with their object id.

Stefan Meyer 10-08-2004 In addition we store the ref_id of the trigger object to allow the target object to link to the triggered object. But it's not possible to assign two or more linked (same obj_id) triggered objects to a target object

Examples:

Learning module 5 may only be accessed, if test 6 has been passed: trigger_obj_type "tst" trigger_id 6 (object id) trigger_ref_id 117 operator "passed" value target_obj_type "lm" target_id 5 (reference id)

Survey question 10 should only be presented, if survey question 8 is answered with a value greater than 4. trigger_obj_type "qst" trigger_id 8 (question (instance) object id) trigger_ref_id 117 operator ">" value "4" target_obj_type "lm" target_id 10 (question (instance) object id)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilConditionHandler.php 44362 2013-08-22 08:36:03Z jluetzen

Definition at line 66 of file class.ilConditionHandler.php.

Member Function Documentation

static ilConditionHandler::_adjustMovedObjectConditions (   $a_ref_id)
static

In the moment it is not allowed to create preconditions on objects that are located outside of a course.

Therefore, after moving an object: check for parent type 'crs'. if that fails delete preconditions

public

Parameters
intreference id of moved object

Definition at line 137 of file class.ilConditionHandler.php.

References $conditions, _deleteTargetConditionsByRefId(), and _getDistinctTargetRefIds().

Referenced by ilSoapObjectAdministration\moveObject(), ilContainerGUI\pasteObject(), and ilContainerGUI\performPasteIntoMultipleObjectsObject().

{
global $tree;
if($tree->checkForParentType($a_ref_id,'crs'))
{
// Nothing to do
return true;
}
// Need another implementation that has better performance
$childs = $tree->getSubTree($tree->getNodeData($a_ref_id),false);
foreach(array_intersect($conditions,$childs) as $target_ref)
{
if(!$tree->checkForParentType($target_ref,'crs'))
{
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilConditionHandler::_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

Definition at line 856 of file class.ilConditionHandler.php.

References $conditions, $ilBench, $ilUser, _checkCondition(), _getConditionsOfTarget(), calculateRequiredTriggers(), ilMemberViewSettings\getInstance(), and getOptionalConditionsOfTarget().

Referenced by ilCourseObjectivePresentationGUI\__showLearningMaterials(), ilCourseObjectivePresentationGUI\__showOtherResources(), ilCourseObjectivePresentationGUI\__showTests(), ilObjContentObject\_checkPreconditionsOfPage(), ilAccessHandler\doConditionCheck(), ilRepositoryExplorerGUI\getChildsOfNode(), ilObjCourseListGUI\initItem(), ilObjCourseReferenceListGUI\initItem(), ilShopRepositoryExplorer\isClickable(), ilRepositoryExplorer\isClickable(), ilRepositoryExplorerGUI\isNodeClickable(), ilShopRepositoryExplorer\showChilds(), ilRepositoryExplorer\showChilds(), ilCourseContentGUI\showStartObjects(), and ilObjCourseGUI\showStartObjects().

{
global $ilBench,$ilUser,$tree;
$a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
$conditions = ilConditionHandler::_getConditionsOfTarget($a_target_ref_id,$a_target_id, $a_target_type);
if(!count($conditions))
{
return true;
}
// @todo check this
include_once './Services/Container/classes/class.ilMemberViewSettings.php';
{
return true;
}
// First check obligatory conditions
$optional = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type);
$num_required = self::calculateRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type);
$passed = 0;
foreach($conditions as $condition)
{
if($tree->isDeleted($condition['trigger_ref_id']))
{
continue;
}
$check = ilConditionHandler::_checkCondition($condition['id'],$a_usr_id);
if($check)
{
++$passed;
if($passed >= $num_required)
{
return true;
}
}
else
{
if(!count($optional))
{
return false;
}
}
}
// not all optional conditions passed
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilConditionHandler::_checkCondition (   $a_id,
  $a_usr_id = 0 
)

checks wether a single condition is fulfilled every trigger object type must implement a static method _checkCondition($a_operator, $a_value)

Definition at line 730 of file class.ilConditionHandler.php.

References $ilUser, _getCondition(), and ilLPStatus\_hasUserCompleted().

Referenced by _checkAllConditionsOfTarget(), ilObjContentObject\_getMissingPreconditionsOfPage(), ilObjContentObject\_getMissingPreconditionsTopChapter(), and ilObjectListGUI\parseConditions().

{
global $ilUser;
$a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
$condition = ilConditionHandler::_getCondition($a_id);
switch($condition['trigger_type'])
{
case "tst":
include_once './Modules/Test/classes/class.ilObjTestAccess.php';
return ilObjTestAccess::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value'],$a_usr_id);
case "crs":
include_once './Modules/Course/classes/class.ilObjCourse.php';
return ilObjCourse::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value'],$a_usr_id);
case 'exc':
include_once './Modules/Exercise/classes/class.ilObjExercise.php';
return ilObjExercise::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value'],$a_usr_id);
case 'crsg':
include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value'],$a_usr_id);
case 'sahs':
include_once './Services/Tracking/classes/class.ilLPStatus.php';
return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id);
case 'svy':
include_once './Modules/Survey/classes/class.ilObjSurvey.php';
return ilObjSurvey::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value'],$a_usr_id);
default:
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilConditionHandler::_deleteTargetConditionsByRefId (   $a_target_ref_id)
static

Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on e.g chapters are not handled.

public

Parameters
intref id of target

Definition at line 191 of file class.ilConditionHandler.php.

References $query, and $res.

Referenced by _adjustMovedObjectConditions(), and ilRBACTest\testConditions().

{
global $ilDB;
$query = "DELETE FROM conditions ".
"WHERE target_ref_id = ".$ilDB->quote($a_target_ref_id,'integer')." ".
"AND target_type != 'st' ";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

ilConditionHandler::_getCondition (   $a_id)

Definition at line 696 of file class.ilConditionHandler.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by _checkCondition(), ilConditionHandlerInterface\askDelete(), ilConditionHandlerInterface\edit(), ilConditionHandlerInterface\initFormCondition(), ilRBACTest\testConditions(), and ilConditionHandlerInterface\updateCondition().

{
global $ilDB;
$query = "SELECT * FROM conditions ".
"WHERE condition_id = ".$ilDB->quote($a_id,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_array['id'] = $row->condition_id;
$tmp_array['target_ref_id'] = $row->target_ref_id;
$tmp_array['target_obj_id'] = $row->target_obj_id;
$tmp_array['target_type'] = $row->target_type;
$tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
$tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
$tmp_array['trigger_type'] = $row->trigger_type;
$tmp_array['operator'] = $row->operator;
$tmp_array['value'] = $row->value;
$tmp_array['ref_handling'] = $row->ref_handling;
$tmp_array['obligatory'] = $row->obligatory;
return $tmp_array;
}
return false;
}

+ Here is the caller graph for this function:

static ilConditionHandler::_getConditionsOfTarget (   $a_target_ref_id,
  $a_target_obj_id,
  $a_target_type = "" 
)
static

get all conditions of target object

Parameters
$a_target_ref_idtarget reference id
$a_target_obj_idtarget object id
$a_target_typetarget object type (must be provided only if object is not derived from ilObject and therefore stored in object_data; this is e.g. the case for chapters (type = "st"))

Definition at line 603 of file class.ilConditionHandler.php.

References $conditions, $ilBench, $query, $res, $row, and ilObject\_lookupType().

Referenced by ilConditionHandlerInterface\__getConditionsOfTarget(), _checkAllConditionsOfTarget(), ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), ilObjContentObject\_getMissingPreconditionsOfPage(), ilObjContentObject\_getMissingPreconditionsTopChapter(), calculateRequiredTriggers(), checkCircle(), ilObject\cloneDependencies(), ilAccessHandler\doConditionCheck(), getOptionalConditionsOfTarget(), ilObjectListGUI\insertPreconditions(), ilConditionHandlerInterface\listConditions(), ilConditionHandlerInterface\saveObligatoryList(), ilConditionHandlerInterface\saveObligatorySettings(), ilConditionHandlerInterface\showObligatoryForm(), and ilRBACTest\testConditions().

{
global $ilDB, $ilBench;
// get type if no type given
if ($a_target_type == "")
{
$a_target_type = ilObject::_lookupType($a_target_obj_id);
}
// check conditions for target cache
if (isset(self::$cond_for_target_cache[$a_target_ref_id.":".$a_target_obj_id.":".
$a_target_type]))
{
return self::$cond_for_target_cache[$a_target_ref_id.":".$a_target_obj_id.":".
$a_target_type];
}
// check rows cache
if (isset(self::$cond_target_rows[$a_target_type.":".$a_target_obj_id]))
{
$rows = self::$cond_target_rows[$a_target_type.":".$a_target_obj_id];
}
else
{
// query data from db
$query = "SELECT * FROM conditions ".
"WHERE target_obj_id = ".$ilDB->quote($a_target_obj_id,'integer')." ".
" AND target_type = ".$ilDB->quote($a_target_type,'text');
$res = $ilDB->query($query);
$rows = array();
while ($row = $ilDB->fetchAssoc($res))
{
$rows[] = $row;
}
}
reset($rows);
$conditions = array();
foreach ($rows as $row)
{
if ($row["ref_handling"] == self::UNIQUE_CONDITIONS)
{
if ($row["target_ref_id"] != $a_target_ref_id)
{
continue;
}
}
$row["id"] = $row["condition_id"];
}
// write conditions for target cache
self::$cond_for_target_cache[$a_target_ref_id.":".$a_target_obj_id.":".
$a_target_type] = $conditions;
return $conditions;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilConditionHandler::_getConditionsOfTrigger (   $a_trigger_obj_type,
  $a_trigger_id 
)
static

get all conditions of trigger object

Definition at line 563 of file class.ilConditionHandler.php.

References $conditions, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjCourseGrouping\_checkGroupingDependencies(), ilObjCourseGrouping\_getGroupingCourseIds(), ilObjCourseGrouping\_getGroupingItems(), ilScormLP\checkSCORMPreconditions(), ilObjCourseGrouping\deassign(), ilObjCourseGrouping\getAssignedItems(), and ilRBACTest\testConditions().

{
global $ilDB;
$query = "SELECT * FROM conditions ".
"WHERE trigger_obj_id = ".$ilDB->quote($a_trigger_id,'integer')." ".
" AND trigger_type = ".$ilDB->quote($a_trigger_obj_type,'text');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_array['id'] = $row->condition_id;
$tmp_array['target_ref_id'] = $row->target_ref_id;
$tmp_array['target_obj_id'] = $row->target_obj_id;
$tmp_array['target_type'] = $row->target_type;
$tmp_array['trigger_ref_id'] = $row->trigger_ref_id;
$tmp_array['trigger_obj_id'] = $row->trigger_obj_id;
$tmp_array['trigger_type'] = $row->trigger_type;
$tmp_array['operator'] = $row->operator;
$tmp_array['value'] = $row->value;
$tmp_array['ref_handling'] = $row->ref_handling;
$tmp_array['obligatory'] = $row->obligatory;
$conditions[] = $tmp_array;
unset($tmp_array);
}
return $conditions ? $conditions : array();
}

+ Here is the caller graph for this function:

static ilConditionHandler::_getDistinctTargetRefIds ( )
static

Get all target ref ids.

public

Definition at line 168 of file class.ilConditionHandler.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by _adjustMovedObjectConditions(), and ilRBACTest\testConditions().

{
global $ilDB;
$query = "SELECT DISTINCT target_ref_id ref FROM conditions ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ref_ids[] = $row->ref;
}
return $ref_ids ? $ref_ids : array();
}

+ Here is the caller graph for this function:

static ilConditionHandler::_isReferenceHandlingOptional (   $a_type)
static

is reference handling optional

public

Parameters
stringtarget type ILIAS obj type

Definition at line 115 of file class.ilConditionHandler.php.

Referenced by ilConditionHandlerInterface\initFormCondition().

{
switch($a_type)
{
case 'st':
return true;
default:
return false;
}
}

+ Here is the caller graph for this function:

static ilConditionHandler::calculateRequiredTriggers (   $a_target_ref_id,
  $a_target_obj_id,
  $a_target_obj_type = '',
  $a_force_update = false 
)
static

calculate number of obligatory items

Parameters
int$a_target_ref_id
int$a_target_obj_id
Returns
int

Definition at line 799 of file class.ilConditionHandler.php.

References $result, _getConditionsOfTarget(), getOptionalConditionsOfTarget(), and saveNumberOfRequiredTriggers().

Referenced by _checkAllConditionsOfTarget(), ilObjectListGUI\parseConditions(), ilConditionHandlerInterface\saveObligatoryList(), and ilConditionHandlerInterface\showObligatoryForm().

{
global $ilDB;
// Get all conditions
$all = self::_getConditionsOfTarget($a_target_ref_id,$a_target_obj_id,$a_target_obj_type);
$opt = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id,$a_target_obj_type);
$set_obl = 0;
if(isset($all[0]))
{
$set_obl = $all[0]['num_obligatory'];
}
// existing value is valid
if($set_obl > 0 and
$set_obl < count($all) and
$set_obl > (count($all) - count($opt) + 1))
{
return $set_obl;
}
if(count($opt))
{
$result = count($all) - count($opt) + 1;
}
else
{
$result = count($all);
}
if($a_force_update)
{
self::saveNumberOfRequiredTriggers($a_target_ref_id,$a_target_obj_id,$result);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilConditionHandler::checkCircle (   $a_ref_id,
  $a_obj_id 
)

Definition at line 945 of file class.ilConditionHandler.php.

References _getConditionsOfTarget(), and getOperator().

Referenced by validate().

{
foreach(ilConditionHandler::_getConditionsOfTarget($a_ref_id,$a_obj_id) as $condition)
{
if($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator())
{
$this->circle = true;
break;
}
else
{
$this->checkCircle($condition['trigger_ref_id'],$condition['trigger_obj_id']);
}
}
return $this->circle;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilConditionHandler::checkExists ( )

Definition at line 463 of file class.ilConditionHandler.php.

References $query, $res, getOperator(), getTargetObjId(), getTargetRefId(), getTriggerObjId(), and getTriggerRefId().

{
global $ilDB;
$query = "SELECT * FROM conditions ".
"WHERE target_ref_id = ".$ilDB->quote($this->getTargetRefId(),'integer')." ".
"AND target_obj_id = ".$ilDB->quote($this->getTargetObjId(),'integer')." ".
"AND trigger_ref_id = ".$ilDB->quote($this->getTriggerRefId(),'integer')." ".
"AND trigger_obj_id = ".$ilDB->quote($this->getTriggerObjId(),'integer')." ".
"AND operator = ".$ilDB->quote($this->getOperator(),'text');
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the call graph for this function:

ilConditionHandler::delete (   $a_ref_id)

delete all trigger and target entries This method is called from ilObject::delete() if an object os removed from trash

Definition at line 518 of file class.ilConditionHandler.php.

References $query, and $res.

{
global $ilDB;
$query = "DELETE FROM conditions WHERE ".
"target_ref_id = ".$ilDB->quote($a_ref_id,'integer')." ".
"OR trigger_ref_id = ".$ilDB->quote($a_ref_id,'integer');
$res = $ilDB->manipulate($query);
return true;
}
ilConditionHandler::deleteByObjId (   $a_obj_id)

delete all trigger and target entries This method is called from ilObject::delete() if an object is removed from trash

Definition at line 533 of file class.ilConditionHandler.php.

References $query, and $res.

{
global $ilDB;
$query = "DELETE FROM conditions WHERE ".
"target_obj_id = ".$ilDB->quote($a_obj_id,'integer')." ".
"OR trigger_obj_id = ".$ilDB->quote($a_obj_id,'integer');
$res = $ilDB->manipulate($query);
return true;
}
ilConditionHandler::deleteCondition (   $a_id)

delete condition

Definition at line 548 of file class.ilConditionHandler.php.

References $query, and $res.

Referenced by storeCondition().

{
global $ilDB;
$query = "DELETE FROM conditions ".
"WHERE condition_id = ".$ilDB->quote($a_id,'integer');
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

ilConditionHandler::enableAutomaticValidation (   $a_validate = true)

enable automated validation

Definition at line 385 of file class.ilConditionHandler.php.

{
$this->validation = $a_validate;
}
ilConditionHandler::getErrorMessage ( )

Definition at line 230 of file class.ilConditionHandler.php.

References $error_message.

{
}
ilConditionHandler::getObligatory ( )

Get obligatory status.

Returns
obligatory status

Definition at line 376 of file class.ilConditionHandler.php.

References $obligatory.

Referenced by storeCondition(), and updateCondition().

{
return (bool) $this->obligatory;
}

+ Here is the caller graph for this function:

ilConditionHandler::getOperator ( )

get operator

Definition at line 342 of file class.ilConditionHandler.php.

References $operator.

Referenced by checkCircle(), checkExists(), storeCondition(), and updateCondition().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getOperatorsByTargetType (   $a_type)

Definition at line 401 of file class.ilConditionHandler.php.

{
switch($a_type)
{
case 'crs':
case 'exc':
return array('passed');
case 'tst':
return array('passed','finished','not_finished');
case 'crsg':
return array('not_member');
case 'sahs':
return array('finished');
case 'svy':
return array('finished');
default:
return array();
}
}
static ilConditionHandler::getOptionalConditionsOfTarget (   $a_target_ref_id,
  $a_target_obj_id,
  $a_obj_type = '' 
)
static

Get optional conditions.

Parameters
int$a_target_ref_id
int$a_target_obj_id

Definition at line 776 of file class.ilConditionHandler.php.

References $conditions, and _getConditionsOfTarget().

Referenced by _checkAllConditionsOfTarget(), calculateRequiredTriggers(), ilConditionHandlerInterface\listConditions(), ilObjectListGUI\parseConditions(), ilConditionHandlerInterface\saveObligatorySettings(), and ilConditionHandlerInterface\showObligatoryForm().

{
$conditions = self::_getConditionsOfTarget($a_target_ref_id,$a_target_obj_id);
$opt = array();
foreach($conditions as $con)
{
if($con['obligatory'])
{
continue;
}
$opt[] = $con;
}
return $opt;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilConditionHandler::getReferenceHandlingType ( )

get reference handling type

public

Definition at line 220 of file class.ilConditionHandler.php.

Referenced by storeCondition(), and updateCondition().

{
return (int) $this->condition_reference_type;
}

+ Here is the caller graph for this function:

ilConditionHandler::getTargetObjId ( )

get target obj id

Definition at line 262 of file class.ilConditionHandler.php.

References $target_obj_id.

Referenced by checkExists(), and storeCondition().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getTargetRefId ( )

get target ref id

Definition at line 246 of file class.ilConditionHandler.php.

References $target_ref_id.

Referenced by checkExists(), storeCondition(), updateCondition(), and validate().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getTargetType ( )

get target obj type

Definition at line 278 of file class.ilConditionHandler.php.

References $target_type.

Referenced by storeCondition().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getTriggerObjId ( )

get trigger obj id

Definition at line 310 of file class.ilConditionHandler.php.

References $trigger_obj_id.

Referenced by checkExists(), and storeCondition().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getTriggerRefId ( )

get target ref id

Definition at line 294 of file class.ilConditionHandler.php.

References $trigger_ref_id.

Referenced by checkExists(), storeCondition(), and validate().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getTriggerType ( )

get trigger obj type

Definition at line 326 of file class.ilConditionHandler.php.

References $trigger_type.

Referenced by storeCondition().

{
}

+ Here is the caller graph for this function:

ilConditionHandler::getTriggerTypes ( )

get all possible trigger types NOT STATIC public

Definition at line 395 of file class.ilConditionHandler.php.

{
return array('crs','exc','tst','sahs', 'svy');
}
ilConditionHandler::getValue ( )

get value

Definition at line 358 of file class.ilConditionHandler.php.

References $value.

Referenced by storeCondition(), and updateCondition().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilConditionHandler::ilConditionHandler ( )

constructor public

Definition at line 98 of file class.ilConditionHandler.php.

References $lng.

{
global $ilDB,$lng;
$this->db =& $ilDB;
$this->lng =& $lng;
$this->validation = true;
}
ilConditionHandler::preloadConditionsForTargetRecords (   $a_type,
  $a_obj_ids 
)

Preload conditions for target records.

Parameters
@return

Definition at line 670 of file class.ilConditionHandler.php.

References $res, and $row.

Referenced by ilObjectListGUIPreloader\preload().

{
global $ilDB;
if (is_array($a_obj_ids) && count($a_obj_ids) > 0)
{
$res = $ilDB->query("SELECT * FROM conditions ".
"WHERE ".$ilDB->in("target_obj_id", $a_obj_ids, false, "integer").
" AND target_type = ".$ilDB->quote($a_type,'text'));
$rows = array();
while ($row = $ilDB->fetchAssoc($res))
{
self::$cond_target_rows[$a_type.":".$row["target_obj_id"]][]
= $row;
}
// init obj ids without any record
foreach ($a_obj_ids as $obj_id)
{
if (!is_array(self::$cond_target_rows[$a_type.":".$obj_id]))
{
self::$cond_target_rows[$a_type.":".$obj_id] = array();
}
}
}
}

+ Here is the caller graph for this function:

static ilConditionHandler::saveNumberOfRequiredTriggers (   $a_target_ref_id,
  $a_target_obj_id,
  $a_num 
)
static

Save number of obigatory triggers.

Parameters
int$a_target_ref_id
int$a_target_obj_id

Definition at line 841 of file class.ilConditionHandler.php.

References $query.

Referenced by calculateRequiredTriggers(), and ilConditionHandlerInterface\saveObligatorySettings().

{
global $ilDB;
$query = 'UPDATE conditions '.
'SET num_obligatory = '.$ilDB->quote($a_num,'integer').' '.
'WHERE target_ref_id = '.$ilDB->quote($a_target_ref_id,'integer').' '.
'AND target_obj_id = '.$ilDB->quote($a_target_obj_id,'integer');
$ilDB->manipulate($query);
return;
}

+ Here is the caller graph for this function:

ilConditionHandler::setErrorMessage (   $a_msg)

Definition at line 226 of file class.ilConditionHandler.php.

Referenced by validate().

{
$this->error_message = $a_msg;
}

+ Here is the caller graph for this function:

ilConditionHandler::setObligatory (   $a_obl)

Set obligatory status.

Parameters
bool$a_obl

Definition at line 367 of file class.ilConditionHandler.php.

{
$this->obligatory = $a_obl;
}
ilConditionHandler::setOperator (   $a_operator)

set operator

Definition at line 334 of file class.ilConditionHandler.php.

{
return $this->operator = $a_operator;
}
ilConditionHandler::setReferenceHandlingType (   $a_type)

set reference handling type

Parameters
intpublic

Definition at line 209 of file class.ilConditionHandler.php.

{
return $this->condition_reference_type = $a_type;
}
ilConditionHandler::setTargetObjId (   $a_target_obj_id)

set target object id

Definition at line 254 of file class.ilConditionHandler.php.

{
return $this->target_obj_id = $a_target_obj_id;
}
ilConditionHandler::setTargetRefId (   $a_target_ref_id)

set target ref id

Definition at line 238 of file class.ilConditionHandler.php.

{
return $this->target_ref_id = $a_target_ref_id;
}
ilConditionHandler::setTargetType (   $a_target_type)

set target object type

Definition at line 270 of file class.ilConditionHandler.php.

{
return $this->target_type = $a_target_type;
}
ilConditionHandler::setTriggerObjId (   $a_trigger_obj_id)

set trigger object id

Definition at line 302 of file class.ilConditionHandler.php.

{
return $this->trigger_obj_id = $a_trigger_obj_id;
}
ilConditionHandler::setTriggerRefId (   $a_trigger_ref_id)

set trigger ref id

Definition at line 286 of file class.ilConditionHandler.php.

{
return $this->trigger_ref_id = $a_trigger_ref_id;
}
ilConditionHandler::setTriggerType (   $a_trigger_type)

set trigger object type

Definition at line 318 of file class.ilConditionHandler.php.

{
return $this->trigger_type = $a_trigger_type;
}
ilConditionHandler::setValue (   $a_value)

set value

Definition at line 350 of file class.ilConditionHandler.php.

{
return $this->value = $a_value;
}
ilConditionHandler::storeCondition ( )

store new condition in database NOT STATIC public

Definition at line 431 of file class.ilConditionHandler.php.

References $query, $res, deleteCondition(), getObligatory(), getOperator(), getReferenceHandlingType(), getTargetObjId(), getTargetRefId(), getTargetType(), getTriggerObjId(), getTriggerRefId(), getTriggerType(), getValue(), and validate().

{
global $ilDB;
// first insert, then validate: it's easier to check for circles if the new condition is in the db table
$next_id = $ilDB->nextId('conditions');
$query = 'INSERT INTO conditions (condition_id,target_ref_id,target_obj_id,target_type,'.
'trigger_ref_id,trigger_obj_id,trigger_type,operator,value,ref_handling,obligatory) '.
'VALUES ('.
$ilDB->quote($next_id,'integer').','.
$ilDB->quote($this->getTargetRefId(),'integer').",".
$ilDB->quote($this->getTargetObjId(),'integer').",".
$ilDB->quote($this->getTargetType(),'text').",".
$ilDB->quote($this->getTriggerRefId(),'integer').",".
$ilDB->quote($this->getTriggerObjId(),'integer').",".
$ilDB->quote($this->getTriggerType(),'text').",".
$ilDB->quote($this->getOperator(),'text').",".
$ilDB->quote($this->getValue(),'text').", ".
$ilDB->quote($this->getReferenceHandlingType(),'integer').', '.
$ilDB->quote($this->getObligatory(),'integer').
')';
$res = $ilDB->manipulate($query);
if ($this->validation && !$this->validate())
{
$this->deleteCondition($next_id);
return false;
}
return true;
}

+ Here is the call graph for this function:

ilConditionHandler::updateCondition (   $a_id)

update condition

Definition at line 480 of file class.ilConditionHandler.php.

References $query, $res, getObligatory(), getOperator(), getReferenceHandlingType(), getTargetRefId(), and getValue().

{
global $ilDB;
$query = "UPDATE conditions SET ".
"target_ref_id = ".$ilDB->quote($this->getTargetRefId(),'integer').", ".
"operator = ".$ilDB->quote($this->getOperator(),'text').", ".
"value = ".$ilDB->quote($this->getValue(),'text').", ".
"ref_handling = ".$this->db->quote($this->getReferenceHandlingType(),'integer').", ".
'obligatory = '.$this->db->quote($this->getObligatory(),'integer').' '.
"WHERE condition_id = ".$ilDB->quote($a_id,'integer');
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

static ilConditionHandler::updateObligatory (   $a_id,
  $a_status 
)
static

Toggle condition obligatory status.

Parameters
int$a_id
bool$a_status

Definition at line 502 of file class.ilConditionHandler.php.

References $query, and $res.

Referenced by ilConditionHandlerInterface\saveObligatoryList(), and ilConditionHandlerInterface\saveObligatorySettings().

{
global $ilDB;
$query = "UPDATE conditions SET ".
'obligatory = '.$ilDB->quote($a_status,'integer').' '.
"WHERE condition_id = ".$ilDB->quote($a_id,'integer');
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

ilConditionHandler::validate ( )

Definition at line 909 of file class.ilConditionHandler.php.

References $query, $res, checkCircle(), ilObjectFactory\getInstanceByRefId(), getTargetRefId(), getTriggerRefId(), and setErrorMessage().

Referenced by storeCondition().

{
global $ilDB;
// check if obj_id is already assigned
$query = "SELECT * FROM conditions WHERE ".
"trigger_ref_id = ".$ilDB->quote($trigger_obj->getId(),'integer')." ".
"AND target_ref_id = ".$ilDB->quote($target_obj->getId(),'integer');
$res = $this->db->query($query);
if($res->numRows() > 1)
{
$this->setErrorMessage($this->lng->txt('condition_already_assigned'));
unset($trigger_obj);
unset($target_obj);
return false;
}
// check for circle
$this->target_obj_id = $target_obj->getId();
if($this->checkCircle($this->getTargetRefId(),$target_obj->getId()))
{
$this->setErrorMessage($this->lng->txt('condition_circle_created'));
unset($trigger_obj);
unset($target_obj);
return false;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilConditionHandler::$cond_for_target_cache = array()
static

Definition at line 90 of file class.ilConditionHandler.php.

ilConditionHandler::$cond_target_rows = array()
static

Definition at line 91 of file class.ilConditionHandler.php.

ilConditionHandler::$db

Definition at line 71 of file class.ilConditionHandler.php.

ilConditionHandler::$error_message

Definition at line 75 of file class.ilConditionHandler.php.

Referenced by getErrorMessage().

ilConditionHandler::$lng

Definition at line 72 of file class.ilConditionHandler.php.

Referenced by ilConditionHandler().

ilConditionHandler::$obligatory = true
private

Definition at line 87 of file class.ilConditionHandler.php.

Referenced by getObligatory().

ilConditionHandler::$operator

Definition at line 83 of file class.ilConditionHandler.php.

Referenced by getOperator().

ilConditionHandler::$target_obj_id

Definition at line 77 of file class.ilConditionHandler.php.

Referenced by getTargetObjId().

ilConditionHandler::$target_ref_id

Definition at line 78 of file class.ilConditionHandler.php.

Referenced by getTargetRefId().

ilConditionHandler::$target_type

Definition at line 79 of file class.ilConditionHandler.php.

Referenced by getTargetType().

ilConditionHandler::$trigger_obj_id

Definition at line 80 of file class.ilConditionHandler.php.

Referenced by getTriggerObjId().

ilConditionHandler::$trigger_ref_id

Definition at line 81 of file class.ilConditionHandler.php.

Referenced by getTriggerRefId().

ilConditionHandler::$trigger_type

Definition at line 82 of file class.ilConditionHandler.php.

Referenced by getTriggerType().

ilConditionHandler::$validation

Definition at line 85 of file class.ilConditionHandler.php.

ilConditionHandler::$value

Definition at line 84 of file class.ilConditionHandler.php.

Referenced by getValue().

const ilConditionHandler::SHARED_CONDITIONS = 0

The documentation for this class was generated from the following file: