ILIAS  release_8 Revision v8.24
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
 
array $access_cache = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

BasicAccessCheckClosuresSingleton constructor.

Definition at line 42 of file BasicAccessCheckClosures.php.

43 {
44 global $DIC;
45 $this->dic = $dic ?? $DIC;
46 }
global $DIC
Definition: feed.php:28

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

Member Function Documentation

◆ checkClosureForBoolReturnValue()

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

Definition at line 130 of file BasicAccessCheckClosures.php.

130 : bool
131 {
132 try {
133 $r = new ReflectionFunction($c);
134 } catch (Throwable $e) {
135 return false;
136 }
137
138 if (!$r->hasReturnType() || !$r->getReturnType()->isBuiltin()) {
139 throw new InvalidArgumentException('the additional Closure MUST return a bool dy declaration');
140 }
141 return true;
142 }
$c
Definition: cli.php:38

References $c, and Vendor\Package\$e.

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 144 of file BasicAccessCheckClosures.php.

144 : Closure
145 {
146 if ($additional instanceof Closure && $this->checkClosureForBoolReturnValue($additional)) {
147 return static function () use ($closure, $additional): bool {
148 return $additional() && $closure();
149 };
150 }
151
152 return $closure;
153 }
$additional
Definition: goto.php:53

References $additional, and 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 112 of file BasicAccessCheckClosures.php.

112 : Closure
113 {
114 if (!isset($this->access_cache['has_admin_access'])) {
115 $this->access_cache['has_admin_access'] = ($this->dic->rbac()->system()->checkAccess(
116 'visible',
118 ));
119 }
120 return $this->getClosureWithOptinalClosure(function (): bool {
121 return $this->access_cache['has_admin_access'];
122 }, $additional);
123 }
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)
const SYSTEM_FOLDER_ID
Definition: constants.php:35

References $additional, 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 48 of file BasicAccessCheckClosures.php.

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

References $additional, 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 74 of file BasicAccessCheckClosures.php.

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

References $additional, 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 100 of file BasicAccessCheckClosures.php.

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

References $additional, and 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 37 of file BasicAccessCheckClosures.php.

◆ $dic

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

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