ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures Class Reference

Class BasicAccessCheckClosures. More...

+ Collaboration diagram for ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures:

Public Member Functions

 __construct (?Container $dic=null)
 BasicAccessCheckClosuresSingleton constructor. More...
 
 isRepositoryReadable (?Closure $additional=null)
 
 isRepositoryVisible (?Closure $additional=null)
 
 isUserLoggedIn (?Closure $additional=null)
 
 hasAdministrationAccess (?Closure $additional=null)
 

Private Member Functions

 checkClosureForBoolReturnValue (Closure $c)
 
 getClosureWithOptinalClosure (Closure $closure, ?Closure $additional=null)
 

Private Attributes

Container $dic
 @readonly More...
 
array $access_cache = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::__construct ( ?Container  $dic = null)

BasicAccessCheckClosuresSingleton constructor.

Definition at line 45 of file BasicAccessCheckClosures.php.

46 {
47 global $DIC;
48 $this->dic = $dic ?? $DIC;
49 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\$dic.

Member Function Documentation

◆ checkClosureForBoolReturnValue()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::checkClosureForBoolReturnValue ( Closure  $c)
private

Definition at line 125 of file BasicAccessCheckClosures.php.

125 : bool
126 {
127 try {
128 $r = new ReflectionFunction($c);
129 } catch (Throwable) {
130 return false;
131 }
132
133 if (!$r->hasReturnType() || !$r->getReturnType()->isBuiltin()) {
134 throw new InvalidArgumentException('the additional Closure MUST return a bool dy declaration');
135 }
136 return true;
137 }
$c
Definition: deliver.php:25

References $c.

Referenced by ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure().

+ Here is the caller graph for this function:

◆ getClosureWithOptinalClosure()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::getClosureWithOptinalClosure ( Closure  $closure,
?Closure  $additional = null 
)
private

Definition at line 139 of file BasicAccessCheckClosures.php.

139 : Closure
140 {
141 if ($additional instanceof Closure && $this->checkClosureForBoolReturnValue($additional)) {
142 return static fn(): bool => $additional() && $closure();
143 }
144
145 return $closure;
146 }

References ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\checkClosureForBoolReturnValue().

Referenced by ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\hasAdministrationAccess(), ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isRepositoryReadable(), ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isRepositoryVisible(), and ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isUserLoggedIn().

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

◆ hasAdministrationAccess()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::hasAdministrationAccess ( ?Closure  $additional = null)

Definition at line 109 of file BasicAccessCheckClosures.php.

109 : Closure
110 {
111 if (!isset($this->access_cache['has_admin_access'])) {
112 $this->access_cache['has_admin_access'] = ($this->dic->rbac()->system()->checkAccess(
113 'visible',
115 ));
116 }
117 return $this->getClosureWithOptinalClosure(fn(): bool => $this->access_cache['has_admin_access'], $additional);
118 }
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)
const SYSTEM_FOLDER_ID
Definition: constants.php:35

References ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure(), and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ isRepositoryReadable()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::isRepositoryReadable ( ?Closure  $additional = null)

Definition at line 51 of file BasicAccessCheckClosures.php.

51 : Closure
52 {
53 if (!isset($this->access_cache['repo_read'])) {
54 $is_user_logged_in = $this->isUserLoggedIn()();
55 if ($is_user_logged_in) {
56 $this->access_cache['repo_read'] = $this->dic->access()->checkAccess(
57 'read',
58 '',
60 );
61 } else {
62 $this->access_cache['repo_read'] = $this->dic->settings()->get('pub_section') && $this->dic->access(
63 )->checkAccessOfUser(
64 $this->dic->user()->getId() ?: ANONYMOUS_USER_ID,
65 'read',
66 '',
68 );
69 }
70 }
71
72 return $this->getClosureWithOptinalClosure(fn(): bool => $this->access_cache['repo_read'], $additional);
73 }
const ANONYMOUS_USER_ID
Definition: constants.php:27
const ROOT_FOLDER_ID
Definition: constants.php:32

References ANONYMOUS_USER_ID, ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure(), ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isUserLoggedIn(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ isRepositoryVisible()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::isRepositoryVisible ( ?Closure  $additional = null)

Definition at line 75 of file BasicAccessCheckClosures.php.

75 : Closure
76 {
77 if (!isset($this->access_cache['repo_visible'])) {
78 $is_user_logged_in = $this->isUserLoggedIn()();
79 if ($is_user_logged_in) {
80 $this->access_cache['repo_visible'] = $this->dic->access()->checkAccess(
81 'visible',
82 '',
84 );
85 } else {
86 $this->access_cache['repo_visible'] = $this->dic->settings()->get('pub_section') && $this->dic->access(
87 )->checkAccessOfUser(
88 $this->dic->user()->getId() ?: ANONYMOUS_USER_ID,
89 'visible',
90 '',
92 );
93 }
94 }
95
96 return $this->getClosureWithOptinalClosure(fn(): bool => $this->access_cache['repo_visible'], $additional);
97 }

References ANONYMOUS_USER_ID, ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure(), ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isUserLoggedIn(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ isUserLoggedIn()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::isUserLoggedIn ( ?Closure  $additional = null)

Definition at line 99 of file BasicAccessCheckClosures.php.

99 : Closure
100 {
101 if (!isset($this->access_cache['is_anonymous'])) {
102 $this->access_cache['is_anonymous'] = ($this->dic->user()->isAnonymous() || $this->dic->user()->getId(
103 ) === 0);
104 }
105
106 return $this->getClosureWithOptinalClosure(fn(): bool => !$this->access_cache['is_anonymous'], $additional);
107 }

References ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure().

Referenced by ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isRepositoryReadable(), and ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isRepositoryVisible().

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

Field Documentation

◆ $access_cache

array ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::$access_cache = []
private

Definition at line 40 of file BasicAccessCheckClosures.php.

◆ $dic

Container ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::$dic
private

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