Handles conditions for accesses to different ILIAS objects. More...
Public Member Functions | |
| ilConditionHandler () | |
| constructor public | |
| 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 | |
| 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 os removed from trash | |
| deleteCondition ($a_id) | |
| delete condition | |
| _getCondition ($a_id) | |
| _checkCondition ($a_id) | |
| checks wether a single condition is fulfilled every trigger object type must implement a static method _checkCondition($a_operator, $a_value) | |
| _checkAllConditionsOfTarget ($a_target_id, $a_target_type="") | |
| checks wether all conditions of a target object are fulfilled | |
| validate () | |
| checkCircle ($a_obj_id) | |
Static Public Member Functions | |
| _getConditionsOfTrigger ($a_trigger_obj_type, $a_trigger_id) | |
| get all conditions of trigger object | |
| _getConditionsOfTarget ($a_target_obj_id, $a_target_type="") | |
| get all conditions of target object | |
Data Fields | |
| $db | |
| $lng | |
| $error_message | |
| $target_obj_id | |
| $target_ref_id | |
| $target_type | |
| $trigger_obj_id | |
| $trigger_ref_id | |
| $trigger_type | |
| $operator | |
| $value | |
| $validation | |
| $conditions | |
Handles conditions for accesses to different ILIAS objects.
A condition consists of four elements:
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)
Definition at line 86 of file class.ilConditionHandler.php.
| ilConditionHandler::_checkAllConditionsOfTarget | ( | $ | a_target_id, | |
| $ | a_target_type = "" | |||
| ) |
checks wether all conditions of a target object are fulfilled
Definition at line 543 of file class.ilConditionHandler.php.
References $ilBench, _checkCondition(), and _getConditionsOfTarget().
Referenced by ilCourseContentInterface::__showLearningMaterials(), ilCourseContentInterface::__showOtherResources(), ilCourseContentInterface::__showTests(), ilObjContentObject::_checkPreconditionsOfPage(), ilCourseContentInterface::cci_start_objects(), ilCourseContentInterface::cci_view(), ilAccessHandler::doConditionCheck(), ilObjCourseListGUI::initItem(), ilRepositoryExplorer::isClickable(), and ilRepositoryExplorer::showChilds().
{
global $ilBench;
foreach(ilConditionHandler::_getConditionsOfTarget($a_target_id, $a_target_type) as $condition)
{
$ilBench->start("ilConditionHandler", "checkCondition");
$check = ilConditionHandler::_checkCondition($condition['id']);
$ilBench->stop("ilConditionHandler", "checkCondition");
if(!$check)
{
return false;
}
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilConditionHandler::_checkCondition | ( | $ | a_id | ) |
checks wether a single condition is fulfilled every trigger object type must implement a static method _checkCondition($a_operator, $a_value)
Definition at line 510 of file class.ilConditionHandler.php.
References _getCondition().
Referenced by _checkAllConditionsOfTarget(), ilObjContentObject::_getMissingPreconditionsOfPage(), ilObjContentObject::_getMissingPreconditionsTopChapter(), and ilObjectListGUI::insertPreconditions().
{
$condition = ilConditionHandler::_getCondition($a_id);
switch($condition['trigger_type'])
{
case "tst":
include_once './assessment/classes/class.ilObjTestAccess.php';
return ilObjTestAccess::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value']);
case "crs":
include_once './course/classes/class.ilObjCourse.php';
return ilObjCourse::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value']);
case 'exc':
include_once './classes/class.ilObjExercise.php';
return ilObjExercise::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value']);
case 'crsg':
include_once './course/classes/class.ilObjCourseGrouping.php';
return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'],$condition['operator'],$condition['value']);
default:
return false;
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilConditionHandler::_getCondition | ( | $ | a_id | ) |
Definition at line 478 of file class.ilConditionHandler.php.
References $query, $res, and $row.
Referenced by _checkCondition().
{
global $ilDB;
$query = "SELECT * FROM conditions ".
"WHERE id = '".$a_id."'";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_array['id'] = $row->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;
return $tmp_array;
}
return false;
}
Here is the caller graph for this function:| ilConditionHandler::_getConditionsOfTarget | ( | $ | a_target_obj_id, | |
| $ | a_target_type = "" | |||
| ) | [static] |
get all conditions of target object
| $a_target_obj_id | target object id | |
| $a_target_type | target 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 441 of file class.ilConditionHandler.php.
References $conditions, $ilBench, $query, $res, $row, and ilObject::_lookupType().
Referenced by ilCourseRegisterGUI::__checkGroupingDependencies(), ilConditionHandlerInterface::__getConditionsOfTarget(), ilCourseRegisterGUI::__getGroupingCourses(), _checkAllConditionsOfTarget(), ilObjCourseGrouping::_getGroupingCourseIds(), ilObjContentObject::_getMissingPreconditionsOfPage(), ilObjContentObject::_getMissingPreconditionsTopChapter(), ilObjCourseGrouping::_isInGrouping(), checkCircle(), ilAccessHandler::doConditionCheck(), and ilObjectListGUI::insertPreconditions().
{
global $ilDB, $ilBench;
$ilBench->start("ilConditionHandler", "getConditionsOfTarget");
if ($a_target_type == "")
{
$a_target_type = ilObject::_lookupType($a_target_obj_id);
}
$query = "SELECT * FROM conditions ".
"WHERE target_obj_id = '".$a_target_obj_id."'".
" AND target_type = '".$a_target_type."'";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_array['id'] = $row->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;
$conditions[] = $tmp_array;
unset($tmp_array);
}
$ilBench->stop("ilConditionHandler", "getConditionsOfTarget");
return $conditions ? $conditions : array();
}
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 403 of file class.ilConditionHandler.php.
References $conditions, $query, $res, and $row.
Referenced by ilCourseRegisterGUI::__checkGroupingDependencies(), ilCourseRegisterGUI::__getGroupingCourses(), ilObjCourseGrouping::_getGroupingCourseIds(), ilObjCourseGrouping::deassign(), and ilObjCourseGrouping::getAssignedCourses().
{
global $ilDB;
$query = "SELECT * FROM conditions ".
"WHERE trigger_obj_id = '".$a_trigger_id."'".
" AND trigger_type = '".$a_trigger_obj_type."'";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_array['id'] = $row->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;
$conditions[] = $tmp_array;
unset($tmp_array);
}
return $conditions ? $conditions : array();
}
Here is the caller graph for this function:| ilConditionHandler::checkCircle | ( | $ | a_obj_id | ) |
Definition at line 596 of file class.ilConditionHandler.php.
References _getConditionsOfTarget(), and getOperator().
Referenced by validate().
{
// Temporally disabled
return false;
foreach(ilConditionHandler::_getConditionsOfTarget($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_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 326 of file class.ilConditionHandler.php.
{
$query = "SELECT * FROM conditions ".
"WHERE target_ref_id = '".$this->getTargetRefId()."' ".
"AND target_obj_id = '".$this->getTargetObjId()."' ".
"AND trigger_ref_id = '".$this->getTriggerRefId()."' ".
"AND trigger_obj_id = '".$this->getTriggerObjId()."' ".
"AND operator = '".$this->getOperator()."'";
$res = $this->db->query($query);
return $res->numRows() ? true : false;
}
| 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 359 of file class.ilConditionHandler.php.
| ilConditionHandler::deleteByObjId | ( | $ | a_obj_id | ) |
delete all trigger and target entries This method is called from ilObject::delete() if an object os removed from trash
Definition at line 373 of file class.ilConditionHandler.php.
| ilConditionHandler::deleteCondition | ( | $ | a_id | ) |
delete condition
Definition at line 387 of file class.ilConditionHandler.php.
Referenced by storeCondition().
{
global $ilDB;
$query = "DELETE FROM conditions ".
"WHERE id = '".$a_id."'";
$res = $ilDB->query($query);
return true;
}
Here is the caller graph for this function:| ilConditionHandler::enableAutomaticValidation | ( | $ | a_validate = true |
) |
enable automated validation
Definition at line 261 of file class.ilConditionHandler.php.
{
$this->validation = $a_validate;
}
| ilConditionHandler::getErrorMessage | ( | ) |
Definition at line 125 of file class.ilConditionHandler.php.
{
return $this->error_message;
}
| ilConditionHandler::getOperator | ( | ) |
get operator
Definition at line 237 of file class.ilConditionHandler.php.
Referenced by checkCircle(), and storeCondition().
{
return $this->operator;
}
Here is the caller graph for this function:| ilConditionHandler::getOperatorsByTargetType | ( | $ | a_type | ) |
Definition at line 277 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');
default:
return array();
}
}
| ilConditionHandler::getTargetObjId | ( | ) |
get target obj id
Definition at line 157 of file class.ilConditionHandler.php.
Referenced by storeCondition().
{
return $this->target_obj_id;
}
Here is the caller graph for this function:| ilConditionHandler::getTargetRefId | ( | ) |
get target ref id
Definition at line 141 of file class.ilConditionHandler.php.
Referenced by validate().
{
return $this->target_ref_id;
}
Here is the caller graph for this function:| ilConditionHandler::getTargetType | ( | ) |
get target obj type
Definition at line 173 of file class.ilConditionHandler.php.
Referenced by storeCondition().
{
return $this->target_type;
}
Here is the caller graph for this function:| ilConditionHandler::getTriggerObjId | ( | ) |
get trigger obj id
Definition at line 205 of file class.ilConditionHandler.php.
Referenced by storeCondition().
{
return $this->trigger_obj_id;
}
Here is the caller graph for this function:| ilConditionHandler::getTriggerRefId | ( | ) |
get target ref id
Definition at line 189 of file class.ilConditionHandler.php.
Referenced by storeCondition(), and validate().
{
return $this->trigger_ref_id;
}
Here is the caller graph for this function:| ilConditionHandler::getTriggerType | ( | ) |
get trigger obj type
Definition at line 221 of file class.ilConditionHandler.php.
Referenced by storeCondition().
{
return $this->trigger_type;
}
Here is the caller graph for this function:| ilConditionHandler::getTriggerTypes | ( | ) |
get all possible trigger types NOT STATIC public
Definition at line 271 of file class.ilConditionHandler.php.
{
return array('crs','exc','tst');
}
| ilConditionHandler::getValue | ( | ) |
get value
Definition at line 253 of file class.ilConditionHandler.php.
Referenced by storeCondition().
{
return $this->value;
}
Here is the caller graph for this function:| ilConditionHandler::ilConditionHandler | ( | ) |
constructor public
Definition at line 111 of file class.ilConditionHandler.php.
References $lng.
{
global $ilDB,$lng;
$this->db =& $ilDB;
$this->lng =& $lng;
$this->validation = true;
}
| ilConditionHandler::setErrorMessage | ( | $ | a_msg | ) |
Definition at line 121 of file class.ilConditionHandler.php.
Referenced by validate().
{
$this->error_message = $a_msg;
}
Here is the caller graph for this function:| ilConditionHandler::setOperator | ( | $ | a_operator | ) |
set operator
Definition at line 229 of file class.ilConditionHandler.php.
{
return $this->operator = $a_operator;
}
| ilConditionHandler::setTargetObjId | ( | $ | a_target_obj_id | ) |
set target object id
Definition at line 149 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 133 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 165 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 197 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 181 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 213 of file class.ilConditionHandler.php.
{
return $this->trigger_type = $a_trigger_type;
}
| ilConditionHandler::setValue | ( | $ | a_value | ) |
set value
Definition at line 245 of file class.ilConditionHandler.php.
{
return $this->value = $a_value;
}
| ilConditionHandler::storeCondition | ( | ) |
store new condition in database NOT STATIC public
Definition at line 301 of file class.ilConditionHandler.php.
References $query, $res, $row, deleteCondition(), getOperator(), getTargetObjId(), getTargetType(), getTriggerObjId(), getTriggerRefId(), getTriggerType(), getValue(), and validate().
{
// first insert, then validate: it's easier to check for circles if the new condition is in the db table
$query = 'INSERT INTO conditions '.
"VALUES('0','".$this->getTargetRefId()."','".$this->getTargetObjId()."','".$this->getTargetType()."','".
$this->getTriggerRefId()."','".$this->getTriggerObjId()."','".$this->getTriggerType()."','".
$this->getOperator()."','".$this->getValue()."')";
$res = $this->db->query($query);
$query = "SELECT LAST_INSERT_ID() AS last FROM conditions";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$last_id = $row->last;
}
if ($this->validation && !$this->validate())
{
$this->deleteCondition($last_id);
return false;
}
return true;
}
Here is the call graph for this function:| ilConditionHandler::updateCondition | ( | $ | a_id | ) |
| ilConditionHandler::validate | ( | ) |
Definition at line 562 of file class.ilConditionHandler.php.
References $query, $res, checkCircle(), ilObjectFactory::getInstanceByRefId(), getTargetRefId(), getTriggerRefId(), and setErrorMessage().
Referenced by storeCondition().
{
// check if obj_id is already assigned
$trigger_obj =& ilObjectFactory::getInstanceByRefId($this->getTriggerRefId());
$target_obj =& ilObjectFactory::getInstanceByRefId($this->getTargetRefId());
$query = "SELECT * FROM conditions WHERE ".
"trigger_obj_id = '".$trigger_obj->getId()."' ".
"AND target_obj_id = '".$target_obj->getId()."'";
$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($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:| ilConditionHandler::$conditions |
Definition at line 104 of file class.ilConditionHandler.php.
Referenced by _getConditionsOfTarget(), and _getConditionsOfTrigger().
| ilConditionHandler::$db |
Definition at line 88 of file class.ilConditionHandler.php.
| ilConditionHandler::$error_message |
Definition at line 92 of file class.ilConditionHandler.php.
| ilConditionHandler::$lng |
Definition at line 89 of file class.ilConditionHandler.php.
Referenced by ilConditionHandler().
| ilConditionHandler::$operator |
Definition at line 100 of file class.ilConditionHandler.php.
| ilConditionHandler::$target_obj_id |
Definition at line 94 of file class.ilConditionHandler.php.
| ilConditionHandler::$target_ref_id |
Definition at line 95 of file class.ilConditionHandler.php.
| ilConditionHandler::$target_type |
Definition at line 96 of file class.ilConditionHandler.php.
| ilConditionHandler::$trigger_obj_id |
Definition at line 97 of file class.ilConditionHandler.php.
| ilConditionHandler::$trigger_ref_id |
Definition at line 98 of file class.ilConditionHandler.php.
| ilConditionHandler::$trigger_type |
Definition at line 99 of file class.ilConditionHandler.php.
| ilConditionHandler::$validation |
Definition at line 102 of file class.ilConditionHandler.php.
| ilConditionHandler::$value |
Definition at line 101 of file class.ilConditionHandler.php.
1.7.1