ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures Class Reference

Class BasicAccessCheckClosures. More...

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

Public Member Functions

 isRepositoryReadable (?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.

References $DIC.

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

Member Function Documentation

◆ checkClosureForBoolReturnValue()

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

Definition at line 105 of file BasicAccessCheckClosures.php.

References Vendor\Package\$e.

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

105  : bool
106  {
107  try {
108  $r = new ReflectionFunction($c);
109  } catch (\Throwable $e) {
110  return false;
111  }
112 
113  if(!$r->hasReturnType() || !$r->getReturnType()->isBuiltin()){
114  throw new \InvalidArgumentException('the additional Closure MUST return a bool dy declaration');
115  }
116  return true;
117  }
$c
Definition: cli.php:37
+ Here is the caller graph for this function:

◆ getClosureWithOptinalClosure()

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

Definition at line 119 of file BasicAccessCheckClosures.php.

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().

119  : Closure
120  {
122  return static function () use ($closure, $additional) : bool {
123  return $additional() && $closure();
124  };
125  }
126 
127  return $closure;
128  }
$additional
Definition: goto.php:52
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

◆ hasAdministrationAccess()

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

Definition at line 89 of file BasicAccessCheckClosures.php.

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

89  : Closure
90  {
91  static $has_admin_access;
92  if (!isset($has_admin_access)) {
93  $has_admin_access = (bool) ($this->dic->rbac()->system()->checkAccess('visible', SYSTEM_FOLDER_ID));
94  }
95  return $this->getClosureWithOptinalClosure(static function () use ($has_admin_access) : bool {
96  return $has_admin_access;
97  }, $additional);
98  }
const SYSTEM_FOLDER_ID
Definition: constants.php:33
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)
$additional
Definition: goto.php:52
+ 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.

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

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  }
const ROOT_FOLDER_ID
Definition: constants.php:30
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)
$additional
Definition: goto.php:52
+ Here is the call graph for this function:

◆ isRepositoryVisible()

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

Definition at line 60 of file BasicAccessCheckClosures.php.

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

60  : Closure
61  {
62  static $repo_visible;
63  if (!isset($repo_visible)) {
64  $is_user_logged_in = $this->isUserLoggedIn()();
65  if (!$is_user_logged_in) {
66  $repo_visible = (bool) $this->dic->settings()->get('pub_section') && $this->dic->access()->checkAccess('visible', '', ROOT_FOLDER_ID);
67  } else {
68  $repo_visible = (bool) $this->dic->access()->checkAccess('visible', '', ROOT_FOLDER_ID);
69  }
70  }
71 
72  return $this->getClosureWithOptinalClosure(static function () use ($repo_visible) : bool {
73  return $repo_visible;
74  }, $additional);
75  }
const ROOT_FOLDER_ID
Definition: constants.php:30
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)
$additional
Definition: goto.php:52
+ Here is the call graph for this function:

◆ isUserLoggedIn()

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

Definition at line 77 of file BasicAccessCheckClosures.php.

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

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

77  : Closure
78  {
79  static $is_anonymous;
80  if (!isset($is_anonymous)) {
81  $is_anonymous = (bool) $this->dic->user()->isAnonymous() || ($this->dic->user()->getId() == 0);
82  }
83 
84  return $this->getClosureWithOptinalClosure(static function () use ($is_anonymous) : bool {
85  return !$is_anonymous;
86  }, $additional);
87  }
getClosureWithOptinalClosure(Closure $closure, ?Closure $additional=null)
$additional
Definition: goto.php:52
+ 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

Definition at line 18 of file BasicAccessCheckClosures.php.


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