ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27
34class ilAccess implements Access
35{
36 private const MAX_CACHE_SIZE = 1000;
37
39 protected array $obj_tree_cache;
40 protected array $obj_type_cache;
41 protected array $obj_id_cache;
42 protected array $ac_cache;
43
44 protected bool $status;
45 protected bool $path;
46 protected bool $condition;
47 protected bool $tree;
48 protected bool $rbac;
49 protected bool $cache;
50
51 private bool $prevent_caching_last_result = false;
52
54 protected ?ilAccessInfo $last_info = null;
55 protected array $results = [];
56 protected array $last_result = [];
57 protected array $stored_rbac_access = [];
58 protected array $current_result_element = [];
59
60 protected ?ilLanguage $language = null;
61
62 public function __construct(
63 private UserIdProviderProxy $user,
64 private ilDBInterface $db,
65 private ilRbacSystem $rbacsystem,
66 private RepositoryTreeAccessProxy $repositoryTree,
67 private ObjectDefinitionAccessProxy $objDefinition,
68 private LoggerInterface $ac_logger
69 ) {
70 $this->results = [];
71 $this->current_info = new ilAccessInfo();
72
73 // use function enable to switch on/off tests (only cache is used so far)
74 $this->cache = true;
75 $this->rbac = true;
76 $this->tree = true;
77 $this->condition = true;
78 $this->path = true;
79 $this->status = true;
80 $this->obj_id_cache = [];
81 $this->obj_type_cache = [];
82 $this->obj_tree_cache = [];
83 $this->ac_cache = [];
84 }
85
86 private function getLanguage(): ilLanguage
87 {
88 if ($this->language === null) {
89 global $DIC;
90 $this->language = $DIC['lng'];
91 }
92
93 return $this->language;
94 }
95
99 public function storeAccessResult(
100 string $a_permission,
101 string $a_cmd,
102 int $a_ref_id,
103 bool $a_access_granted,
104 ?int $a_user_id = null,
105 ?ilAccessInfo $a_info = null
106 ): void {
107 if ($a_user_id === null) {
108 $a_user_id = $this->user->getId();
109 }
110 if ($a_info === null) {
111 $a_info = $this->current_info;
112 }
113 if ($this->cache) {
114 $this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id] = [
115 "granted" => $a_access_granted,
116 "info" => $a_info,
117 "prevent_db_cache" => $this->getPreventCachingLastResult()
118 ];
119 $this->current_result_element = [$a_access_granted, $a_ref_id, $a_permission, $a_cmd, $a_user_id];
120 $this->last_result = $this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id];
121 $this->last_info = $a_info;
122 }
123 // get new info object
124 $this->current_info = new ilAccessInfo();
125 }
126
130 public function setPreventCachingLastResult(bool $a_val): void
131 {
132 $this->prevent_caching_last_result = $a_val;
133 }
134
138 public function getPreventCachingLastResult(): bool
139 {
140 return $this->prevent_caching_last_result;
141 }
142
146 public function getStoredAccessResult(
147 string $a_permission,
148 string $a_cmd,
149 int $a_ref_id,
150 ?int $a_user_id = null
151 ): array {
152 if ($a_user_id === null) {
153 $a_user_id = $this->user->getId();
154 }
155 if (isset($this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id])) {
156 return $this->results[$a_ref_id][$a_permission][$a_cmd][$a_user_id];
157 }
158 return [];
159 }
160
164 public function getResults(): array
165 {
166 return $this->results;
167 }
168
172 public function setResults(array $a_results): void
173 {
174 $this->results = $a_results;
175 }
176
180 public function addInfoItem(string $a_type, string $a_text, string $a_data = ""): void
181 {
182 $this->current_info->addInfoItem($a_type, $a_text, $a_data);
183 }
184
188 public function checkAccess(
189 string $a_permission,
190 string $a_cmd,
191 int $a_ref_id,
192 string $a_type = "",
193 ?int $a_obj_id = null,
194 ?int $a_tree_id = null
195 ): bool {
196 return $this->checkAccessOfUser(
197 $this->user->getId(),
198 $a_permission,
199 $a_cmd,
200 $a_ref_id,
201 $a_type,
202 $a_obj_id,
203 $a_tree_id
204 );
205 }
206
210 public function checkAccessOfUser(
211 int $a_user_id,
212 string $a_permission,
213 string $a_cmd,
214 int $a_ref_id,
215 string $a_type = "",
216 ?int $a_obj_id = 0,
217 ?int $a_tree_id = 0
218 ): bool {
219 global $DIC;
220
221 $ilBench = $DIC['ilBench'];
222
223 $this->setPreventCachingLastResult(false); // for external db based caches
224
225 $ilBench->start("AccessControl", "0400_clear_info");
226 $this->current_info->clear();
227 $ilBench->stop("AccessControl", "0400_clear_info");
228
229 // get stored result (internal memory based cache)
230 $cached = $this->doCacheCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id);
231 if ($cached["hit"]) {
232 // Store access result
233 if (!$cached["granted"]) {
234 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt("status_no_permission"));
235 }
236 if ($cached["prevent_db_cache"]) {
237 $this->setPreventCachingLastResult(true); // should have been saved in previous call already
238 }
239 return $cached["granted"];
240 }
241
242 $ilBench->start("AccessControl", "0500_lookup_id_and_type");
243 // get object id if not provided
244 if ($a_obj_id == 0) {
245 if (isset($this->obj_id_cache[$a_ref_id]) && $this->obj_id_cache[$a_ref_id] > 0) {
246 $a_obj_id = $this->obj_id_cache[$a_ref_id];
247 } else {
248 $a_obj_id = ilObject::_lookupObjId($a_ref_id);
249 $this->obj_id_cache[$a_ref_id] = $a_obj_id;
250 }
251 }
252 if ($a_type == "") {
253 if (isset($this->obj_type_cache[$a_ref_id]) && $this->obj_type_cache[$a_ref_id] != "") {
254 $a_type = $this->obj_type_cache[$a_ref_id];
255 } else {
256 $a_type = ilObject::_lookupType($a_ref_id, true);
257 $this->obj_type_cache[$a_ref_id] = $a_type;
258 }
259 }
260
261 $ilBench->stop("AccessControl", "0500_lookup_id_and_type");
262
263 // if supplied tree id is not = 1 (= repository main tree),
264 // check if object is in tree and not deleted
265 if ($a_tree_id != 1 &&
266 !$this->doTreeCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id)) {
267 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt("status_no_permission"));
268 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
269 return false;
270 }
271
272 // As of FR: https://docu.ilias.de/go/wiki/wpage_8648_1357#ilPageTocA248
273 // the ilObjSystemFolderGUI is always readable.
274 if ($a_ref_id === SYSTEM_FOLDER_ID && 'read' === $a_permission) {
275 return true;
276 }
277 // rbac check for current object
278 if (!$this->doRBACCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_type)) {
279 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt("status_no_permission"));
280 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
281 return false;
282 }
283
284 // Check object activation
285 $act_check = $this->doActivationCheck(
286 $a_permission,
287 $a_cmd,
288 $a_ref_id,
289 $a_user_id,
290 $a_obj_id,
291 $a_type
292 );
293
294 if (!$act_check) {
295 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt('status_no_permission'));
296 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
297 return false;
298 }
299
300 // check read permission for all parents
301 $par_check = $this->doPathCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id);
302 if (!$par_check) {
303 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt("status_no_permission"));
304 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
305 return false;
306 }
307
308 // condition check (currently only implemented for read permission)
309 if (!$this->doConditionCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type)) {
310 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt("status_no_permission"));
311 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
312 $this->setPreventCachingLastResult(true); // do not store this in db, since condition updates are not monitored
313 return false;
314 }
315
316 // object type specific check
317 if (!$this->doStatusCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type)) {
318 $this->current_info->addInfoItem(ilAccessInfo::IL_NO_PERMISSION, $this->getLanguage()->txt("status_no_permission"));
319 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
320 $this->setPreventCachingLastResult(true); // do not store this in db, since status updates are not monitored
321 return false;
322 }
323
324 // all checks passed
325 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, true, $a_user_id);
326 return true;
327 }
328
332 public function getInfo(): array
333 {
334 return is_object($this->last_info) ? $this->last_info->getInfoItems() : [];
335 }
336
340 public function getResultLast(): array
341 {
342 return $this->last_result;
343 }
344
348 public function getResultAll(int $a_ref_id = 0): array
349 {
350 if ($a_ref_id == "") {
351 return $this->results;
352 }
353
354 return $this->results[$a_ref_id];
355 }
356
360 public function doCacheCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id): array
361 {
362 $stored_access = $this->getStoredAccessResult($a_permission, $a_cmd, $a_ref_id, $a_user_id);
363
364 //var_dump($stored_access);
365 if ($stored_access !== []) {
366 if (isset($stored_access['info']) && $stored_access['info'] instanceof ilAccessInfo) {
367 $this->current_info = $stored_access["info"];
368 }
369 //var_dump("cache-treffer:");
370 return [
371 "hit" => true,
372 "granted" => $stored_access["granted"],
373 "prevent_db_cache" => $stored_access["prevent_db_cache"]
374 ];
375 }
376
377 // not in cache
378 return [
379 "hit" => false,
380 "granted" => false,
381 "prevent_db_cache" => false
382 ];
383 }
384
388 public function doTreeCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id): bool
389 {
390 // Get stored result
391 $tree_cache_key = $a_user_id . ':' . $a_ref_id;
392 if (array_key_exists($tree_cache_key, $this->obj_tree_cache)) {
393 // Store access result
394 if (!$this->obj_tree_cache[$tree_cache_key]) {
395 $this->current_info->addInfoItem(
397 $this->getLanguage()->txt("status_no_permission")
398 );
399 }
400 $this->storeAccessResult(
401 $a_permission,
402 $a_cmd,
403 $a_ref_id,
404 $this->obj_tree_cache[$tree_cache_key],
405 $a_user_id
406 );
407
408 return $this->obj_tree_cache[$tree_cache_key];
409 }
410
411 if (!$this->repositoryTree->isInTree($a_ref_id) || $this->repositoryTree->isDeleted($a_ref_id)) {
412 // Store negative access results
413 // Store in tree cache
414 // Note, we only store up to 1000 results to avoid memory overflow.
415 if (count($this->obj_tree_cache) < self::MAX_CACHE_SIZE) {
416 $this->obj_tree_cache[$tree_cache_key] = false;
417 }
418
419 // Store in result cache
420 $this->current_info->addInfoItem(ilAccessInfo::IL_DELETED, $this->getLanguage()->txt("object_deleted"));
421 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
422 return false;
423 }
424
425 // Store positive access result.
426 // Store in tree cache
427 // Note, we only store up to 1000 results to avoid memory overflow.
428 if (count($this->obj_tree_cache) < self::MAX_CACHE_SIZE) {
429 $this->obj_tree_cache[$tree_cache_key] = true;
430 }
431 // Store in result cache
432 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, true, $a_user_id);
433 return true;
434 }
435
439 public function doRBACCheck(
440 string $a_permission,
441 string $a_cmd,
442 int $a_ref_id,
443 int $a_user_id,
444 string $a_type
445 ): bool {
446 if ($a_permission == "") {
447 $message = sprintf(
448 '%s::doRBACCheck(): No operations given! $a_ref_id: %s',
449 get_class($this),
450 $a_ref_id
451 );
452 $this->ac_logger->error($message);
454 }
455
456 if (isset($this->stored_rbac_access[$a_user_id . "-" . $a_permission . "-" . $a_ref_id])) {
457 $access = $this->stored_rbac_access[$a_user_id . "-" . $a_permission . "-" . $a_ref_id];
458 } else {
459 $access = $this->rbacsystem->checkAccessOfUser($a_user_id, $a_permission, $a_ref_id, $a_type);
460 if (!is_array($this->stored_rbac_access) || count($this->stored_rbac_access) < self::MAX_CACHE_SIZE) {
461 if ($a_permission != "create") {
462 $this->stored_rbac_access[$a_user_id . "-" . $a_permission . "-" . $a_ref_id] = $access;
463 }
464 }
465 }
466 // Store in result cache
467 if (!$access) {
468 $this->current_info->addInfoItem(
470 $this->getLanguage()->txt("status_no_permission")
471 );
472 }
473 if ($a_permission != "create") {
474 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, true, $a_user_id);
475 }
476 return $access;
477 }
478
482 public function doPathCheck(
483 string $a_permission,
484 string $a_cmd,
485 int $a_ref_id,
486 int $a_user_id,
487 bool $a_all = false
488 ): bool {
489 $path = $this->repositoryTree->getPathId($a_ref_id);
490 foreach ($path as $id) {
491 if ($a_ref_id === $id) {
492 continue;
493 }
494 $access = $this->checkAccessOfUser($a_user_id, "read", "info", $id);
495 if ($access == false) {
496 $this->current_info->addInfoItem(
498 $this->getLanguage()->txt("no_parent_access"),
499 (string) $id
500 );
501 if ($a_all == false) {
502 return false;
503 }
504 }
505 }
506 return true;
507 }
508
512 public function doActivationCheck(
513 string $a_permission,
514 string $a_cmd,
515 int $a_ref_id,
516 int $a_user_id,
517 int $a_obj_id,
518 string $a_type
519 ): bool {
520 $cache_perm = ($a_permission === "visible" || $a_permission === 'leave')
521 ? "visible"
522 : "other";
523
524 if (isset($this->ac_cache[$cache_perm][$a_ref_id][$a_user_id])) {
525 return $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id];
526 }
527
528 // nothings needs to be done if current permission is write permission
529 if ($a_permission === 'write') {
530 return true;
531 }
532
533 // #10852 - member view check
534 if ($a_user_id === $this->user->getId()) {
535 // #10905 - activate parent container ONLY
537 if ($memview->isActiveForRefId($a_ref_id) &&
538 $memview->getContainer() == $a_ref_id) {
539 return true;
540 }
541 }
542
543 // in any case, if user has write permission return true.
544 // you may specify further exceptions in ilObj[TYPE]Access::getBypassActivationCheckForPermissions;
545 $class = $this->objDefinition->getClassName($a_type);
546 $full_class = "ilObj" . $class . "Access";
547
548 $bypass = method_exists($full_class, 'getBypassActivationCheckForPermissions') ?
549 $full_class::getBypassActivationCheckForPermissions() : ['write'];
550
551 foreach ($bypass as $permission) {
552 if ($this->checkAccessOfUser($a_user_id, $permission, "", $a_ref_id)) {
553 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true;
554 return true;
555 }
556 }
557
558 // no write access/bypass => check centralized offline status
559 if (
560 $this->objDefinition->supportsOfflineHandling($a_type) &&
562 ) {
563 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = false;
564 return false;
565 }
566 $item_data = ilObjectActivation::getItem($a_ref_id);
567 // if activation isn't enabled
568 if ($item_data === null || (is_array($item_data) && count($item_data) == 0) ||
569 $item_data['timing_type'] != ilObjectActivation::TIMINGS_ACTIVATION) {
570 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true;
571 return true;
572 }
573 // if within activation time
574 if (($item_data['timing_start'] == 0 || time() >= $item_data['timing_start']) and
575 ($item_data['timing_end'] == 0 || time() <= $item_data['timing_end'])) {
576 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true;
577 return true;
578 }
579
580 // if user has write permission
581 if ($this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id)) {
582 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true;
583 return true;
584 }
585
586 // if current permission is visible or leave and visible is set in activation
587 if (($a_permission === 'visible' || $a_permission === 'leave')
588 && $item_data['visible']) {
589 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true;
590 return true;
591 }
592
593 // learning progress must be readable, regardless of the activation
594 if ($a_permission == 'read_learning_progress') {
595 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true;
596 return true;
597 }
598 // no access
599 $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = false;
600 return false;
601 }
602
606 public function doConditionCheck(
607 string $a_permission,
608 string $a_cmd,
609 int $a_ref_id,
610 int $a_user_id,
611 int $a_obj_id,
612 string $a_type
613 ): bool {
614 if (
615 ($a_permission == 'visible') &&
616 !$this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id, $a_type, $a_obj_id)
617 ) {
619 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id, $a_type, $a_user_id)) {
620 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_ref_id, $a_obj_id, $a_type);
621 foreach ($conditions as $condition) {
622 $this->current_info->addInfoItem(
624 $this->getLanguage()->txt("missing_precondition") . ": " .
625 ilObject::_lookupTitle($condition["trigger_obj_id"]) . " " .
626 $this->getLanguage()->txt("condition_" . $condition["operator"]) . " " .
627 $condition["value"],
628 serialize($condition)
629 );
630 }
631 return false;
632 }
633 }
634 }
635
636 if (($a_permission == "read" or $a_permission == 'join') &&
637 !$this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id, $a_type, $a_obj_id)) {
638 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id, $a_type, $a_user_id)) {
639 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($a_ref_id, $a_obj_id, $a_type);
640 foreach ($conditions as $condition) {
641 $this->current_info->addInfoItem(
643 $this->getLanguage()->txt("missing_precondition") . ": " .
644 ilObject::_lookupTitle($condition["trigger_obj_id"]) . " " .
645 $this->getLanguage()->txt("condition_" . $condition["operator"]) . " " .
646 $condition["value"],
647 serialize($condition)
648 );
649 }
650 return false;
651 }
652 }
653 return true;
654 }
655
659 public function doStatusCheck(
660 string $a_permission,
661 string $a_cmd,
662 int $a_ref_id,
663 int $a_user_id,
664 int $a_obj_id,
665 string $a_type
666 ): bool {
667 // check for a deactivated plugin
668 if ($this->objDefinition->isPluginTypeName($a_type) && !$this->objDefinition->isPlugin($a_type)) {
669 return false;
670 }
671 if (!$a_type) {
672 return false;
673 }
674
675 $class = $this->objDefinition->getClassName($a_type);
676 $location = $this->objDefinition->getLocation($a_type);
677 $full_class = "ilObj" . $class . "Access";
678
679 if ($class == "") {
680 $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.");
681 return false;
682 }
683
684 $full_class = new $full_class();
685
686 $obj_access = call_user_func(
687 [$full_class, "_checkAccess"],
688 $a_cmd,
689 $a_permission,
690 $a_ref_id,
691 $a_obj_id,
692 $a_user_id
693 );
694 if ($obj_access !== true) {
695 //Note: We must not add an info item here, because one is going
696 // to be added by the user function we just called a few
697 // lines above.
698 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, false, $a_user_id);
699 return false;
700 }
701 $this->storeAccessResult($a_permission, $a_cmd, $a_ref_id, true, $a_user_id);
702 return true;
703 }
704
708 public function clear(): void
709 {
710 $this->results = [];
711 $this->last_result = [];
712 $this->current_info = new ilAccessInfo();
713 $this->stored_rbac_access = [];
714 }
715
720 public function enable(string $a_str, bool $a_bool): void
721 {
722 $this->$a_str = $a_bool;
723 }
724
725
726
727 //
728 // OrgUnit Positions
729 //
730
732 {
734 }
735
739 public function filterUserIdsForCurrentUsersPositionsAndPermission(array $user_ids, string $permission): array
740 {
741 return $this->positionAccess()->filterUserIdsForCurrentUsersPositionsAndPermission(
742 $user_ids,
743 $permission
744 );
745 }
746
750 public function filterUserIdsForUsersPositionsAndPermission(array $user_ids, int $for_user_id, string $permission): array
751 {
752 return $this->positionAccess()->filterUserIdsForUsersPositionsAndPermission(
753 $user_ids,
754 $for_user_id,
755 $permission
756 );
757 }
758
762 public function isCurrentUserBasedOnPositionsAllowedTo(string $permission, array $on_user_ids): bool
763 {
764 return $this->positionAccess()->isCurrentUserBasedOnPositionsAllowedTo($permission, $on_user_ids);
765 }
766
770 public function isUserBasedOnPositionsAllowedTo(int $which_user_id, string $permission, array $on_user_ids): bool
771 {
772 return $this->positionAccess()->isUserBasedOnPositionsAllowedTo(
773 $which_user_id,
774 $permission,
775 $on_user_ids
776 );
777 }
778
782 public function checkPositionAccess(string $pos_perm, int $ref_id): bool
783 {
784 return $this->positionAccess()->checkPositionAccess($pos_perm, $ref_id);
785 }
786
790 public function checkRbacOrPositionPermissionAccess(string $rbac_perm, string $pos_perm, int $ref_id): bool
791 {
792 return $this->positionAccess()->checkRbacOrPositionPermissionAccess($rbac_perm, $pos_perm, $ref_id);
793 }
794
798 public function filterUserIdsByPositionOfCurrentUser(string $pos_perm, int $ref_id, array $user_ids): array
799 {
800 return $this->positionAccess()->filterUserIdsByPositionOfCurrentUser($pos_perm, $ref_id, $user_ids);
801 }
802
806 public function filterUserIdsByPositionOfUser(int $user_id, string $pos_perm, int $ref_id, array $user_ids): array
807 {
808 return $this->positionAccess()->filterUserIdsByPositionOfUser($user_id, $pos_perm, $ref_id, $user_ids);
809 }
810
814 public function filterUserIdsByRbacOrPositionOfCurrentUser(string $rbac_perm, string $pos_perm, int $ref_id, array $user_ids): array
815 {
816 return $this->positionAccess()->filterUserIdsByRbacOrPositionOfCurrentUser(
817 $rbac_perm,
818 $pos_perm,
819 $ref_id,
820 $user_ids
821 );
822 }
823
827 public function hasCurrentUserAnyPositionAccess(int $ref_id): bool
828 {
829 return $this->positionAccess()->hasCurrentUserAnyPositionAccess($ref_id);
830 }
831
835 public function hasUserRBACorAnyPositionAccess(string $rbac_perm, int $ref_id): bool
836 {
837 return $this->positionAccess()->hasUserRBACorAnyPositionAccess($rbac_perm, $ref_id);
838 }
839}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$location
Definition: buildRTE.php:22
class ilAccessInfo
const IL_MISSING_PRECONDITION
Checks access for ILIAS objects.
array $obj_type_cache
enable(string $a_str, bool $a_bool)
@deprected
array $stored_rbac_access
hasUserRBACorAnyPositionAccess(string $rbac_perm, int $ref_id)
isCurrentUserBasedOnPositionsAllowedTo(string $permission, array $on_user_ids)
bool getAvailablePositionRelatedPermissions for available permissions
array $ac_cache
addInfoItem(string $a_type, string $a_text, string $a_data="")
add an info item to current info object
ilAccessInfo $last_info
checkRbacOrPositionPermissionAccess(string $rbac_perm, string $pos_perm, int $ref_id)
bool
filterUserIdsByPositionOfUser(int $user_id, string $pos_perm, int $ref_id, array $user_ids)
int[] getAvailablePositionRelatedPermissions for available permissions
doPathCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, bool $a_all=false)
check read permission for all parents
filterUserIdsByPositionOfCurrentUser(string $pos_perm, int $ref_id, array $user_ids)
int[] getAvailablePositionRelatedPermissions for available permissions
storeAccessResult(string $a_permission, string $a_cmd, int $a_ref_id, bool $a_access_granted, ?int $a_user_id=null, ?ilAccessInfo $a_info=null)
store access result
doConditionCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, int $a_obj_id, string $a_type)
condition check (currently only implemented for read permission)
array $obj_tree_cache
filterUserIdsByRbacOrPositionOfCurrentUser(string $rbac_perm, string $pos_perm, int $ref_id, array $user_ids)
int[]
array $results
doRBACCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, string $a_type)
rbac check for current object -> type is used for create permission
getResultLast()
get last info object
checkPositionAccess(string $pos_perm, int $ref_id)
bool getAvailablePositionRelatedPermissions for available permissions
__construct(private UserIdProviderProxy $user, private ilDBInterface $db, private ilRbacSystem $rbacsystem, private RepositoryTreeAccessProxy $repositoryTree, private ObjectDefinitionAccessProxy $objDefinition, private LoggerInterface $ac_logger)
ilLanguage $language
array $current_result_element
array $obj_id_cache
getPreventCachingLastResult()
Get prevent caching last result.
bool $prevent_caching_last_result
ilAccessInfo $current_info
doCacheCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id)
look if result for current query is already in cachearray<{hit: bool, granted: bool,...
const MAX_CACHE_SIZE
doActivationCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, int $a_obj_id, string $a_type)
check for activation and centralized offline status.
getResultAll(int $a_ref_id=0)
filterUserIdsForCurrentUsersPositionsAndPermission(array $user_ids, string $permission)
int[] Filtered List of ILIAS-User-IDs ilOrgUnitAccessException when a unknown permission is used....
doStatusCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, int $a_obj_id, string $a_type)
object type specific check
hasCurrentUserAnyPositionAccess(int $ref_id)
bool
setResults(array $a_results)
array $last_result
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=0, ?int $a_tree_id=0)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
isUserBasedOnPositionsAllowedTo(int $which_user_id, string $permission, array $on_user_ids)
bool getAvailablePositionRelatedPermissions for available permissions
ilOrgUnitPositionAccess $ilOrgUnitPositionAccess
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
filterUserIdsForUsersPositionsAndPermission(array $user_ids, int $for_user_id, string $permission)
int[] Filtered List of ILIAS-User-IDs ilOrgUnitAccessException when a unknown permission is used....
bool $condition
getInfo()
get last info objectilAccessInfo::getInfoItems()
doTreeCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id)
check if object is in tree and not deleted
setPreventCachingLastResult(bool $a_val)
Set prevent caching last result.
getStoredAccessResult(string $a_permission, string $a_cmd, int $a_ref_id, ?int $a_user_id=null)
get stored access resultarray<{granted: bool, info: ?ilAccessInfo, prevent_db_cache: bool}>
static lookupEffectiveHiddenStatusByTarget(int $a_target_ref_id)
Lookup hidden status (also take container control into account)
static _checkAllConditionsOfTarget(int $a_target_ref_id, int $a_target_id, string $a_target_type="", int $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
language handling
static getItem(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
const SYSTEM_FOLDER_ID
Definition: constants.php:35
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Public access-handling service of the AccessControl component.
Definition: Access.php:31
Interface ilDBInterface.
$results
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
getLanguage()