ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures Class Reference

Class BasicAccessCheckClosures. More...

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

Public Member Functions

 isRepositoryReadable (?Closure $additional=null)
 
 isPublicSectionActive (?Closure $additional=null)
 
 isRepositoryVisible (?Closure $additional=null)
 
 isUserLoggedIn (?Closure $additional=null)
 
 hasAdministrationAccess (?Closure $additional=null)
 

Static Public Member Functions

static getInstance ()
 

Protected Member Functions

 __construct ()
 BasicAccessCheckClosures constructor. More...
 

Static Protected Attributes

static $instance
 

Private Member Functions

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

Private Attributes

 $dic
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::__construct ( )
protected

BasicAccessCheckClosures constructor.

Parameters
$dic

Definition at line 25 of file BasicAccessCheckClosures.php.

26 {
27 global $DIC;
28 $this->dic = $DIC;
29 }
$DIC
Definition: xapitoken.php:46

References $DIC.

Member Function Documentation

◆ checkClosureForBoolReturnValue()

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

Definition at line 118 of file BasicAccessCheckClosures.php.

118 : bool
119 {
120 try {
121 $r = new ReflectionFunction($c);
122 } catch (\Throwable $e) {
123 return false;
124 }
125
126 if(!$r->hasReturnType() || !$r->getReturnType()->isBuiltin()){
127 throw new \InvalidArgumentException('the additional Closure MUST return a bool dy declaration');
128 }
129 return true;
130 }

References Vendor\Package\$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

◆ getInstance()

◆ hasAdministrationAccess()

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

Definition at line 102 of file BasicAccessCheckClosures.php.

102 : Closure
103 {
104 static $has_admin_access;
105 if (!isset($has_admin_access)) {
106 $has_admin_access = (bool) ($this->dic->rbac()->system()->checkAccess('visible', SYSTEM_FOLDER_ID));
107 }
108 return $this->getClosureWithOptinalClosure(static function () use ($has_admin_access) : bool {
109 return $has_admin_access;
110 }, $additional);
111 }
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)

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

+ Here is the call graph for this function:

◆ isPublicSectionActive()

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

Definition at line 60 of file BasicAccessCheckClosures.php.

60 : Closure
61 {
62 static $public_section_active;
63 if (!isset($public_section_active)) {
64 $public_section_active = (bool) $this->dic->settings()->get('pub_section') && $this->dic->access()->checkAccess('visible',
65 '', ROOT_FOLDER_ID);
66 }
67
68 return $this->getClosureWithOptinalClosure(function () use ($public_section_active) : bool {
69 return $public_section_active;
70 }, $additional);
71 }

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

+ Here is the call graph for this function:

◆ isRepositoryReadable()

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

Definition at line 43 of file BasicAccessCheckClosures.php.

43 : Closure
44 {
45 static $repo_read;
46 if (!isset($repo_read)) {
47 $is_user_logged_in = $this->isUserLoggedIn()();
48 if (!$is_user_logged_in) {
49 $repo_read = (bool) $this->dic->settings()->get('pub_section') && $this->dic->access()->checkAccess('read', '', ROOT_FOLDER_ID);
50 } else {
51 $repo_read = (bool) $this->dic->access()->checkAccess('read', '', ROOT_FOLDER_ID);
52 }
53 }
54
55 return $this->getClosureWithOptinalClosure(static function () use ($repo_read) : bool {
56 return $repo_read;
57 }, $additional);
58 }

References $additional, ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure(), and ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isUserLoggedIn().

+ Here is the call graph for this function:

◆ isRepositoryVisible()

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

Definition at line 73 of file BasicAccessCheckClosures.php.

73 : Closure
74 {
75 static $repo_visible;
76 if (!isset($repo_visible)) {
77 $is_user_logged_in = $this->isUserLoggedIn()();
78 if (!$is_user_logged_in) {
79 $repo_visible = (bool) $this->dic->settings()->get('pub_section') && $this->dic->access()->checkAccess('visible', '', ROOT_FOLDER_ID);
80 } else {
81 $repo_visible = (bool) $this->dic->access()->checkAccess('visible', '', ROOT_FOLDER_ID);
82 }
83 }
84
85 return $this->getClosureWithOptinalClosure(static function () use ($repo_visible) : bool {
86 return $repo_visible;
87 }, $additional);
88 }

References $additional, ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\getClosureWithOptinalClosure(), and ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures\isUserLoggedIn().

+ Here is the call graph for this function:

◆ isUserLoggedIn()

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

Definition at line 90 of file BasicAccessCheckClosures.php.

90 : Closure
91 {
92 static $is_anonymous;
93 if (!isset($is_anonymous)) {
94 $is_anonymous = (bool) $this->dic->user()->isAnonymous() || ($this->dic->user()->getId() == 0);
95 }
96
97 return $this->getClosureWithOptinalClosure(static function () use ($is_anonymous) : bool {
98 return !$is_anonymous;
99 }, $additional);
100 }

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

◆ $dic

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

Definition at line 19 of file BasicAccessCheckClosures.php.

◆ $instance

ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures::$instance
staticprotected

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