ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjMainMenuAccess Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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, Closure $current)
 
- 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...
 
 canBeDelivered (ilWACPath $ilWACPath)
 

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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilObjMainMenuAccess

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

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

Constructor & Destructor Documentation

◆ __construct()

ilObjMainMenuAccess::__construct ( )

ilObjMainMenuAccess constructor.

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

47 {
48 global $DIC;
49 $this->rbacreview = $DIC->rbac()->review();
50 $this->rbacsystem = $DIC->rbac()->system();
51 $this->user = $DIC->user();
52 $this->http = $DIC->http();
53 }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
static http()
Fetches the global http state from ILIAS.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkAccessAndThrowException()

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

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

59 : void
60 {
61 if (!$this->hasUserPermissionTo($permission)) {
62 throw new ilException('Permission denied');
63 }
64 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
hasUserPermissionTo(string $permission)

References hasUserPermissionTo().

+ Here is the call graph for this function:

◆ getGlobalRoles()

ilObjMainMenuAccess::getGlobalRoles ( )
Returns
array

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

79 : array
80 {
81 $global_roles = $this->rbacreview->getRolesForIDs(
82 $this->rbacreview->getGlobalRoles(),
83 false
84 );
85
86 $roles = [];
87 foreach ($global_roles as $global_role) {
88 $roles[$global_role['rol_id']] = $global_role['title'];
89 }
90
91 return $roles;
92 }

◆ hasUserPermissionTo()

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

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

70 : bool
71 {
72 return (bool) $this->rbacsystem->checkAccess($permission, $this->http->request()->getQueryParams()['ref_id']);
73 }

References ILIAS\FileDelivery\http().

Referenced by checkAccessAndThrowException().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCurrentUserAllowedToSeeCustomItem()

ilObjMainMenuAccess::isCurrentUserAllowedToSeeCustomItem ( ilMMCustomItemStorage  $item,
Closure  $current 
)

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

94 : Closure
95 {
96 return function () use ($item, $current) : bool {
97 $roles_of_current_user = $this->rbacreview->assignedGlobalRoles($this->user->getId());
98 if (!$item->hasRoleBasedVisibility()) {
99 return $current();
100 }
101 if ($item->hasRoleBasedVisibility() && !empty($item->getGlobalRoleIDs())) {
102 foreach ($roles_of_current_user as $role_of_current_user) {
103 if (in_array((int) $role_of_current_user, $item->getGlobalRoleIDs(), true)) {
104 return $current();
105 }
106 }
107 }
108 return false;
109 };
110 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $http

ilObjMainMenuAccess::$http
private

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

◆ $rbacreview

ilObjMainMenuAccess::$rbacreview
private

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

◆ $rbacsystem

ilObjMainMenuAccess::$rbacsystem
private

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

◆ $user

ilObjMainMenuAccess::$user
private

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


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