ILIAS  release_8 Revision v8.24
class.ilObjBookingPoolAccess.php
Go to the documentation of this file.
1<?php
2
23{
24 protected ilObjUser $user;
26
27 public function __construct()
28 {
29 global $DIC;
30
31 $this->user = $DIC->user();
32 $this->rbacsystem = $DIC->rbac()->system();
33 }
34
35 public static function _getCommands(): array
36 {
37 $commands = array();
38 $commands[] = array("permission" => "read", "cmd" => "render", "lang_var" => "show", "default" => true);
39 $commands[] = array("permission" => "write", "cmd" => "render", "lang_var" => "edit_content");
40 $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
41
42 return $commands;
43 }
44
45 public static function _checkGoto(string $target): bool
46 {
47 global $DIC;
48
49 $ilAccess = $DIC->access();
50
51 $t_arr = explode("_", $target);
52
53 if ($t_arr[0] !== "book" || ((int) $t_arr[1]) <= 0) {
54 return false;
55 }
56
57 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
58 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
59 return true;
60 }
61 return false;
62 }
63
64 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
65 {
68
69 if ($user_id === null) {
70 $user_id = $ilUser->getId();
71 }
72
73 // add no access info item and return false if access is not granted
74 // $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $text, $data = "");
75 //
76 // for all RBAC checks use checkAccessOfUser instead the normal checkAccess-method:
77 // $rbacsystem->checkAccessOfUser($user_id, $permission, $ref_id)
78
79 //TODO refactor this: first check if the object is online and then the permissions.
80 #22653
81 if (($permission === "visible" || $permission === "read") && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
82 $pool = new ilObjBookingPool($ref_id);
83 if ($pool->isOffline()) {
84 return false;
85 }
86 }
87
88 return true;
89 }
90
95 public static function _lookupOnlineStatus(array $a_ids): array
96 {
97 global $DIC;
98
99 $ilDB = $DIC->database();
100
101 $q = "SELECT booking_pool_id, pool_offline FROM booking_settings WHERE " .
102 $ilDB->in("booking_pool_id", $a_ids, false, "integer");
103 $lm_set = $ilDB->query($q);
104 $status = [];
105 while ($r = $ilDB->fetchAssoc($lm_set)) {
106 $status[$r["booking_pool_id"]] = !$r["pool_offline"];
107 }
108 return $status;
109 }
110
111 public function canBeDelivered(ilWACPath $ilWACPath): bool
112 {
113
114 // we return always false, since the files in the file/ and post/ directoies
115 // are server by php (they could/should be moved to the data dir outside of the web doc root)
116 return false;
117 }
118}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupOnlineStatus(array $a_ids)
Check whether booking pool is online (legacy version)
static _checkGoto(string $target)
check whether goto script will succeed
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
$lm_set