ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilObjAdministrativeNotificationAccess.php
Go to the documentation of this file.
1<?php
2
23{
25
26 protected ?int $ref_id;
27
31 public function __construct()
32 {
33 global $DIC;
34 $this->rbacsystem = $DIC->rbac()->system();
35 $this->ref_id = $DIC->http()->wrapper()->query()->has('ref_id')
36 ? $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int())
37 : null;
38 }
39
43 public function checkAccessAndThrowException(string $permission): void
44 {
45 if (!$this->hasUserPermissionTo($permission)) {
46 throw new ilException('Permission denied');
47 }
48 }
49
50 public function hasUserPermissionTo(string $permissions_string): bool
51 {
52 $permissions = explode(',', $permissions_string);
53 foreach ($permissions as $permission) {
54 if ($this->rbacsystem->checkAccess($permission, $this->ref_id)) {
55 return true;
56 }
57 }
58 return false;
59 }
60}
Base class for ILIAS Exception handling.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct()
ilObjAdministrativeNotificationAccess constructor.
Class ilObjectAccess.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
global $DIC
Definition: shib_login.php:26