92 $this->results = array();
99 $this->condition =
true;
101 $this->status =
true;
102 $this->obj_id_cache = array();
103 $this->obj_type_cache = array();
104 $this->obj_tree_cache = array();
115 public function storeAccessResult($a_permission, $a_cmd, $a_ref_id, $a_access_granted, $a_user_id =
"", $a_info =
"")
121 if ($a_user_id ==
"") {
132 $this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id] =
133 array(
"granted" => $a_access_granted,
"info" => $a_info,
136 $this->current_result_element = array($a_access_granted,$a_ref_id,$a_permission,$a_cmd,$a_user_id);
137 $this->last_result = $this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id];
138 $this->last_info = $a_info;
150 $this->prevent_caching_last_result = $a_val;
158 return $this->prevent_caching_last_result;
170 if ($a_user_id ==
"") {
179 if (isset($this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id])) {
180 return $this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id];
191 $ilDB = $DIC[
'ilDB'];
194 $query =
"DELETE FROM acc_cache WHERE user_id = " .
$ilDB->quote(
$ilUser->getId(),
'integer');
197 $ilDB->insert(
'acc_cache', array(
198 'user_id' => array(
'integer',
$ilUser->getId()),
199 'time' => array(
'integer',time()),
200 'result' => array(
'clob',serialize($this->results))
211 $ilDB = $DIC[
'ilDB'];
214 $query =
"SELECT * FROM acc_cache WHERE user_id = " .
218 if ((time() - $rec[
"time"]) < $a_secs) {
219 $this->results = unserialize($rec[
"result"]);
238 $this->results = $a_results;
246 $this->current_info->addInfoItem(
$a_type, $a_text, $a_data);
252 public function checkAccess($a_permission, $a_cmd, $a_ref_id,
$a_type =
"", $a_obj_id =
"", $a_tree_id =
"")
273 $ilBench->start(
"AccessControl",
"0400_clear_info");
274 $this->current_info->clear();
275 $ilBench->stop(
"AccessControl",
"0400_clear_info");
279 $cached = $this->
doCacheCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id);
280 if ($cached[
"hit"]) {
282 if (!$cached[
"granted"]) {
285 if ($cached[
"prevent_db_cache"]) {
288 return $cached[
"granted"];
291 $ilBench->start(
"AccessControl",
"0500_lookup_id_and_type");
293 if ($a_obj_id ==
"") {
294 if (isset($this->obj_id_cache[$a_ref_id]) && $this->obj_id_cache[$a_ref_id] > 0) {
295 $a_obj_id = $this->obj_id_cache[$a_ref_id];
298 $this->obj_id_cache[$a_ref_id] = $a_obj_id;
302 if (isset($this->obj_type_cache[$a_ref_id]) && $this->obj_type_cache[$a_ref_id] !=
"") {
303 $a_type = $this->obj_type_cache[$a_ref_id];
306 $this->obj_type_cache[$a_ref_id] =
$a_type;
310 $ilBench->stop(
"AccessControl",
"0500_lookup_id_and_type");
314 if ($a_tree_id != 1 &&
315 !$this->
doTreeCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id)) {
345 $par_check = $this->
doPathCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id);
381 return is_object($this->last_info) ? $this->last_info->getInfoItems() : array();
389 return $this->last_result;
396 if ($a_ref_id ==
"") {
400 return $this->results[$a_ref_id];
406 public function doCacheCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id)
413 $ilBench->start(
"AccessControl",
"1000_checkAccess_get_cache_result");
416 if (is_array($stored_access)) {
417 $this->current_info = $stored_access[
"info"];
419 $ilBench->stop(
"AccessControl",
"1000_checkAccess_get_cache_result");
420 return array(
"hit" =>
true,
"granted" => $stored_access[
"granted"],
421 "prevent_db_cache" => $stored_access[
"prevent_db_cache"]);
425 $ilBench->stop(
"AccessControl",
"1000_checkAccess_get_cache_result");
426 return array(
"hit" =>
false,
"granted" =>
false,
427 "prevent_db_cache" =>
false);
433 public function doTreeCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id)
437 $tree = $DIC[
'tree'];
443 $tree_cache_key = $a_user_id .
':' . $a_ref_id;
444 if (array_key_exists($tree_cache_key, $this->obj_tree_cache)) {
446 if (!$this->obj_tree_cache[$tree_cache_key]) {
449 $this->
storeAccessResult($a_permission, $a_cmd, $a_ref_id, $this->obj_tree_cache[$tree_cache_key], $a_user_id);
451 return $this->obj_tree_cache[$tree_cache_key];
454 $ilBench->start(
"AccessControl",
"2000_checkAccess_in_tree");
456 if (!
$tree->isInTree($a_ref_id)
or $tree->isDeleted($a_ref_id)) {
461 if (count($this->obj_tree_cache) < 1000) {
462 $this->obj_tree_cache[$tree_cache_key] =
false;
466 $this->current_info->addInfoItem(
IL_DELETED,
$lng->txt(
"object_deleted"));
469 $ilBench->stop(
"AccessControl",
"2000_checkAccess_in_tree");
478 if (count($this->obj_tree_cache) < 1000) {
479 $this->obj_tree_cache[$tree_cache_key] =
true;
485 $ilBench->stop(
"AccessControl",
"2000_checkAccess_in_tree");
501 $ilBench->start(
"AccessControl",
"2500_checkAccess_rbac_check");
503 if ($a_permission ==
"") {
505 '%s::doRBACCheck(): No operations given! $a_ref_id: %s',
513 if (isset($this->stored_rbac_access[$a_user_id .
"-" . $a_permission .
"-" . $a_ref_id])) {
514 $access = $this->stored_rbac_access[$a_user_id .
"-" . $a_permission .
"-" . $a_ref_id];
516 $access = $this->rbacsystem->checkAccessOfUser($a_user_id, $a_permission, $a_ref_id,
$a_type);
517 if (!is_array($this->stored_rbac_access) || count($this->stored_rbac_access) < 1000) {
518 if ($a_permission !=
"create") {
519 $this->stored_rbac_access[$a_user_id .
"-" . $a_permission .
"-" . $a_ref_id] = $access;
528 if ($a_permission !=
"create") {
531 $ilBench->stop(
"AccessControl",
"2500_checkAccess_rbac_check");
539 public function doPathCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_all =
false)
543 $tree = $DIC[
'tree'];
546 $ilObjDataCache = $DIC[
'ilObjDataCache'];
549 $ilBench->start(
"AccessControl",
"3100_checkAccess_check_parents_get_path");
560 $ilBench->stop(
"AccessControl",
"3100_checkAccess_check_parents_get_path");
563 if ($a_ref_id == $id) {
569 if ($access ==
false) {
574 if ($a_all ==
false) {
594 $objDefinition = $DIC[
'objDefinition'];
597 $cache_perm = ($a_permission ==
"visible")
602 if (isset($this->ac_cache[$cache_perm][$a_ref_id][$a_user_id])) {
603 return $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id];
607 if ($a_permission ==
'write') {
612 if ($a_user_id ==
$ilUser->getId()) {
614 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
616 if ($memview->isActiveForRefId($a_ref_id) &&
617 $memview->getContainer() == $a_ref_id) {
624 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
true;
630 $objDefinition->supportsOfflineHandling(
$a_type) &&
633 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
false;
637 include_once
'Services/Object/classes/class.ilObjectActivation.php';
641 if ($item_data === null ||
643 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
true;
648 if (($item_data[
'timing_start'] == 0 || time() >= $item_data[
'timing_start'])
and 649 ($item_data[
'timing_end'] == 0 || time() <= $item_data[
'timing_end'])) {
650 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
true;
656 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
true;
657 $ilBench->stop(
"AccessControl",
"3150_checkAccess_check_course_activation");
662 if ($a_permission ==
'visible' and $item_data[
'visible']) {
663 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
true;
668 if ($a_permission ==
'read_learning_progress') {
669 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
true;
670 $ilBench->stop(
"AccessControl",
"3150_checkAccess_check_course_activation");
675 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] =
false;
691 ($a_permission ==
'visible')
and 694 if (ilConditionHandler::lookupEffectiveHiddenStatusByTarget($a_ref_id)) {
696 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_ref_id, $a_obj_id,
$a_type);
698 $this->current_info->addInfoItem(
700 $lng->txt(
"missing_precondition") .
": " .
702 $lng->txt(
"condition_" . $condition[
"operator"]) .
" " .
709 $ilBench->stop(
"AccessControl",
"4000_checkAccess_condition_check");
714 if (($a_permission ==
"read" or $a_permission ==
'join') &&
716 $ilBench->start(
"AccessControl",
"4000_checkAccess_condition_check");
718 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_ref_id, $a_obj_id,
$a_type);
720 $this->current_info->addInfoItem(
722 $lng->txt(
"missing_precondition") .
": " .
724 $lng->txt(
"condition_" . $condition[
"operator"]) .
" " .
729 $ilBench->stop(
"AccessControl",
"4000_checkAccess_condition_check");
732 $ilBench->stop(
"AccessControl",
"4000_checkAccess_condition_check");
745 $objDefinition = $DIC[
'objDefinition'];
747 $ilPluginAdmin = $DIC[
'ilPluginAdmin'];
749 $ilBench->start(
"AccessControl",
"5000_checkAccess_object_check");
752 if ($objDefinition->isPluginTypeName(
$a_type) && !$objDefinition->isPlugin(
$a_type)) {
759 $class = $objDefinition->getClassName(
$a_type);
761 $full_class =
"ilObj" . $class .
"Access";
764 $this->ac_logger->error(
"Cannot find class for object type $a_type, obj id $a_obj_id, ref id $a_ref_id. Abort status check.");
768 include_once(
$location .
"/class." . $full_class .
".php");
771 $full_class =
new $full_class();
773 $obj_access = call_user_func(
774 array($full_class,
"_checkAccess"),
781 if (!($obj_access ===
true)) {
788 $ilBench->stop(
"AccessControl",
"5000_checkAccess_object_check");
793 $ilBench->stop(
"AccessControl",
"5000_checkAccess_object_check");
802 $this->results = array();
803 $this->last_result =
"";
805 $this->stored_rbac_access = [];
812 $this->$a_str = $a_bool;
getResultLast()
get last info object
hasCurrentUserAnyPositionAccess($ref_id)
bool
isCurrentUserBasedOnPositionsAllowedTo($permission, array $on_user_ids)
$on_user_ids List of ILIAS-User-IDsgetAvailablePositionRelatedPermissions for available permissionsbo...
filterUserIdsByPositionOfCurrentUser($pos_perm, $ref_id, array $user_ids)
$user_idsgetAvailablePositionRelatedPermissions for available permissionsint[]
filterUserIdsForUsersPositionsAndPermission(array $user_ids, $for_user_id, $permission)
$user_ids List of ILIAS-User-IDs which shall be filtered getAvailablePositionRelatedPermissions for a...
doActivationCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type)
check for activation and centralized offline status.
filterUserIdsForCurrentUsersPositionsAndPermission(array $user_ids, $permission)
$user_ids List of ILIAS-User-IDs which shall be filteredgetAvailablePositionRelatedPermissions for av...
checkPositionAccess($pos_perm, $ref_id)
Reference-ID of the desired Object in the treegetAvailablePositionRelatedPermissions for available pe...
checkRbacOrPositionPermissionAccess($rbac_perm, $pos_perm, $ref_id)
See the list of available permissions in interface ilOrgUnitPositionAccessHandler Reference-ID of the...
isCurrentUserBasedOnPositionsAllowedTo($permission, array $on_user_ids)
$on_user_ids List of ILIAS-User-IDsgetAvailablePositionRelatedPermissions for available permissionsbo...
filterUserIdsForUsersPositionsAndPermission(array $user_ids, $for_user_id, $permission)
$user_ids List of ILIAS-User-IDs which shall be filtered getAvailablePositionRelatedPermissions for a...
checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_ref_id, $a_type="", $a_obj_id="", $a_tree_id="")
check access for an object (provide $a_type and $a_obj_id if available for better performance)(option...
static getItem($a_ref_id)
Get item data.
if(!array_key_exists('StateId', $_REQUEST)) $id
setPreventCachingLastResult($a_val)
Set prevent caching last result.true if last result should not be cached
filterUserIdsByRbacOrPositionOfCurrentUser($rbac_perm, $pos_perm, $ref_id, array $user_ids)
See the list of available permissions in interface ilOrgUnitPositionAccessHandler Reference-ID of the...
const IL_NO_PARENT_ACCESS
doStatusCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type)
object type specific checkbool
Class ilOrgUnitPositionAccess.
static _lookupTitle($a_id)
lookup object title
addInfoItem($a_type, $a_text, $a_data="")
add an info item to current info object
getStoredAccessResult($a_permission, $a_cmd, $a_ref_id, $a_user_id="")
get stored access resultprivatepermission command string reference id user id (if no id passed...
getResultAll($a_ref_id="")
hasUserRBACorAnyPositionAccess($rbac_perm, $ref_id)
bool
Interface ilAccessHandler.
checkPositionAccess($pos_perm, $ref_id)
Reference-ID of the desired Object in the treegetAvailablePositionRelatedPermissions for available pe...
hasUserRBACorAnyPositionAccess($rbac_perm, $ref_id)
bool
hasCurrentUserAnyPositionAccess($ref_id)
bool
doConditionCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type)
condition check (currently only implemented for read permission)bool
catch(Exception $e) $message
getPreventCachingLastResult()
Get prevent caching last result.boolean true if last result should not be cached
filterUserIdsByPositionOfCurrentUser($pos_perm, $ref_id, array $user_ids)
$user_idsgetAvailablePositionRelatedPermissions for available permissionsint[]
foreach($_POST as $key=> $value) $res
checkAccess($a_permission, $a_cmd, $a_ref_id, $a_type="", $a_obj_id="", $a_tree_id="")
check access for an object (provide $a_type and $a_obj_id if available for better performance)(option...
doCacheCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id)
look if result for current query is already in cachebool
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
static _lookupObjId($a_id)
doPathCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_all=false)
check read permission for all parentsbool
filterUserIdsByRbacOrPositionOfCurrentUser($rbac_perm, $pos_perm, $ref_id, array $user_ids)
See the list of available permissions in interface ilOrgUnitPositionAccessHandler Reference-ID of the...
getInfo()
get last info object
isUserBasedOnPositionsAllowedTo($which_user_id, $permission, array $on_user_ids)
Permission check for this ILIAS-User-ID $on_user_ids List of ILIAS-User-IDsgetAvailablePositionRelate...
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
doRBACCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_type)
rbac check for current object -> type should be used for create permissionbool
static _lookupType($a_id, $a_reference=false)
lookup object type
checkRbacOrPositionPermissionAccess($rbac_perm, $pos_perm, $ref_id)
See the list of available permissions in interface ilOrgUnitPositionAccessHandler Reference-ID of the...
filterUserIdsByPositionOfUser($user_id, $pos_perm, $ref_id, array $user_ids)
$user_idsgetAvailablePositionRelatedPermissions for available permissionsint[]
const IL_MISSING_PRECONDITION
static getInstance()
Get instance.
isUserBasedOnPositionsAllowedTo($which_user_id, $permission, array $on_user_ids)
Permission check for this ILIAS-User-ID $on_user_ids List of ILIAS-User-IDsgetAvailablePositionRelate...
static getLogger($a_component_id)
Get component logger.
doTreeCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id)
check if object is in tree and not deletedbool
filterUserIdsForCurrentUsersPositionsAndPermission(array $user_ids, $permission)
$user_ids List of ILIAS-User-IDs which shall be filteredgetAvailablePositionRelatedPermissions for av...
storeAccessResult($a_permission, $a_cmd, $a_ref_id, $a_access_granted, $a_user_id="", $a_info="")
store access resultprivatepermission command string reference id true if access is granted user id (i...
filterUserIdsByPositionOfUser($user_id, $pos_perm, $ref_id, array $user_ids)
$user_idsgetAvailablePositionRelatedPermissions for available permissionsint[]