ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjMainMenuAccess Class Reference

Class ilObjMainMenuAccess. More...

+ Inheritance diagram for ilObjMainMenuAccess:
+ Collaboration diagram for ilObjMainMenuAccess:

Public Member Functions

 __construct ()
 ilObjMainMenuAccess constructor. More...
 
 checkAccessAndThrowException (string $permission)
 
 hasUserPermissionTo (string $permission)
 
 getGlobalRoles ()
 
 isCurrentUserAllowedToSeeCustomItem (ilMMCustomItemStorage $item)
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
Parameters
ilWACPath$ilWACPath
Returns
bool
More...
 

Private Attributes

 $http
 
 $user
 
 $rbacsystem
 
 $rbacreview
 

Additional Inherited Members

- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjMainMenuAccess::__construct ( )

ilObjMainMenuAccess constructor.

Definition at line 30 of file class.ilObjMainMenuAccess.php.

References $DIC, ILIAS\FileDelivery\http(), and user().

31  {
32  global $DIC;
33  $this->rbacreview = $DIC->rbac()->review();
34  $this->rbacsystem = $DIC->rbac()->system();
35  $this->user = $DIC->user();
36  $this->http = $DIC->http();
37  }
user()
Definition: user.php:4
static http()
Fetches the global http state from ILIAS.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ checkAccessAndThrowException()

ilObjMainMenuAccess::checkAccessAndThrowException ( string  $permission)
Parameters
string$permission
Exceptions
ilException

Definition at line 43 of file class.ilObjMainMenuAccess.php.

References hasUserPermissionTo().

43  : void
44  {
45  if (!$this->hasUserPermissionTo($permission)) {
46  throw new ilException('Permission denied');
47  }
48  }
hasUserPermissionTo(string $permission)
+ Here is the call graph for this function:

◆ getGlobalRoles()

ilObjMainMenuAccess::getGlobalRoles ( )
Returns
array

Definition at line 63 of file class.ilObjMainMenuAccess.php.

63  : array {
64  $global_roles = $this->rbacreview->getRolesForIDs(
65  $this->rbacreview->getGlobalRoles(),false
66  );
67 
68  $roles = [];
69  foreach ($global_roles as $global_role) {
70  $roles[$global_role['rol_id']] = $global_role['title'];
71  }
72 
73  return $roles;
74  }

◆ hasUserPermissionTo()

ilObjMainMenuAccess::hasUserPermissionTo ( string  $permission)
Parameters
string$permission
Returns
bool

Definition at line 54 of file class.ilObjMainMenuAccess.php.

References ILIAS\FileDelivery\http().

Referenced by checkAccessAndThrowException().

54  : bool
55  {
56  return (bool) $this->rbacsystem->checkAccess($permission, $this->http->request()->getQueryParams()['ref_id']);
57  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCurrentUserAllowedToSeeCustomItem()

ilObjMainMenuAccess::isCurrentUserAllowedToSeeCustomItem ( ilMMCustomItemStorage  $item)
Parameters
ilMMCustomItemStorage$item
Returns
Closure

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

References ilMMCustomItemStorage\getGlobalRoleIDs(), ilMMCustomItemStorage\hasRoleBasedVisibility(), and user().

80  : Closure
81  {
82  return function () use ($item): bool {
83  $roles_of_current_user = $this->rbacreview->assignedGlobalRoles($this->user->getId());
84  if (!$item->hasRoleBasedVisibility()) {
85  return true;
86  }
87  if ($item->hasRoleBasedVisibility() && !empty($item->getGlobalRoleIDs())) {
88  foreach ($roles_of_current_user as $role_of_current_user) {
89  if (in_array($role_of_current_user, $item->getGlobalRoleIDs())) {
90  return true;
91  }
92  }
93  }
94  return false;
95  };
96  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

Field Documentation

◆ $http

ilObjMainMenuAccess::$http
private

Definition at line 13 of file class.ilObjMainMenuAccess.php.

◆ $rbacreview

ilObjMainMenuAccess::$rbacreview
private

Definition at line 25 of file class.ilObjMainMenuAccess.php.

◆ $rbacsystem

ilObjMainMenuAccess::$rbacsystem
private

Definition at line 21 of file class.ilObjMainMenuAccess.php.

◆ $user

ilObjMainMenuAccess::$user
private

Definition at line 17 of file class.ilObjMainMenuAccess.php.


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