ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilObjBookingPoolAccess.php
Go to the documentation of this file.
1 <?php
2 
23 {
24  protected ilLanguage $lng;
26  protected ilObjUser $user;
28 
29  public function __construct()
30  {
31  global $DIC;
32 
33  $this->user = $DIC->user();
34  $this->rbacsystem = $DIC->rbac()->system();
35  $this->access = $DIC->access();
36  $this->lng = $DIC->language();
37  }
38 
39  public static function _getCommands(): array
40  {
41  $commands = array();
42  $commands[] = array("permission" => "read", "cmd" => "render", "lang_var" => "show", "default" => true);
43  $commands[] = array("permission" => "write", "cmd" => "render", "lang_var" => "edit_content");
44  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
45 
46  return $commands;
47  }
48 
49  public static function _checkGoto(string $target): bool
50  {
51  global $DIC;
52 
53  $ilAccess = $DIC->access();
54 
55  $t_arr = explode("_", $target);
56 
57  if ($t_arr[0] !== "book" || ((int) $t_arr[1]) <= 0) {
58  return false;
59  }
60 
61  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
62  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
63  return true;
64  }
65  return false;
66  }
67 
68  public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
69  {
70  $ilUser = $this->user;
71  $rbacsystem = $this->rbacsystem;
72 
73  if ($user_id === null) {
74  $user_id = $ilUser->getId();
75  }
76 
77  // add no access info item and return false if access is not granted
78  // $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $text, $data = "");
79  //
80  // for all RBAC checks use checkAccessOfUser instead the normal checkAccess-method:
81  // $rbacsystem->checkAccessOfUser($user_id, $permission, $ref_id)
82 
83  //TODO refactor this: first check if the object is online and then the permissions.
84  #22653
85  if (($permission === "visible" || $permission === "read") && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
86  if (self::_isOffline($obj_id)) {
87  $this->access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("offline"));
88  return false;
89  }
90  }
91 
92  return true;
93  }
94 
99  public static function _lookupOnlineStatus(array $a_ids): array
100  {
101  global $DIC;
102 
103  $ilDB = $DIC->database();
104 
105  $q = "SELECT booking_pool_id, pool_offline FROM booking_settings WHERE " .
106  $ilDB->in("booking_pool_id", $a_ids, false, "integer");
107  $lm_set = $ilDB->query($q);
108  $status = [];
109  while ($r = $ilDB->fetchAssoc($lm_set)) {
110  $status[$r["booking_pool_id"]] = !$r["pool_offline"];
111  }
112  return $status;
113  }
114 
115  public function canBeDelivered(ilWACPath $ilWACPath): bool
116  {
117  // we return always false, since the files in the file/ and post/ directoies
118  // are server by php (they could/should be moved to the data dir outside of the web doc root)
119  return false;
120  }
121 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
global $DIC
Definition: shib_login.php:22
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
$lm_set
$q
Definition: shib_logout.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$r
static _lookupOnlineStatus(array $a_ids)
Check whether booking pool is online (legacy version)