ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjPollAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected ilObjUser $user;
29 protected ilLanguage $lng;
32
33 public function __construct()
34 {
35 global $DIC;
36
37 $this->user = $DIC->user();
38 $this->lng = $DIC->language();
39 $this->rbacsystem = $DIC->rbac()->system();
40 $this->access = $DIC->access();
41 }
42
46 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
47 {
48 $ilUser = $this->user;
51 $ilAccess = $this->access;
52
53 if (!$user_id) {
54 $a_user_id = $ilUser->getId();
55 }
56
57 if (
58 $cmd === 'preview' &&
59 $permission === 'read'
60 ) {
61 return false;
62 }
63
64 return true;
65 }
66
70 public static function _getCommands(): array
71 {
72 return [
73 ["permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true],
74 ["permission" => "write", "cmd" => "render", "lang_var" => "edit"]
75 ];
76 }
77
81 public static function _checkGoto(string $target): bool
82 {
83 global $DIC;
84
85 $ilAccess = $DIC->access();
86
87 $t_arr = explode("_", $target);
88
89 if ($t_arr[0] !== "poll" || ((int) $t_arr[1]) <= 0) {
90 return false;
91 }
92
93 if ($ilAccess->checkAccess("read", "", (int) $t_arr[1])) {
94 return true;
95 }
96
97 return false;
98 }
99
100
104 public function canBeDelivered(ilWACPath $ilWACPath): bool
105 {
106 $ilAccess = $this->access;
107 preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
108
109 foreach (ilObject2::_getAllReferences((int) $results[1]) as $ref_id) {
110 if ($ilAccess->checkAccess('read', '', $ref_id)) {
111 return true;
112 }
113 }
114
115 return false;
116 }
117}
language handling
Class ilObjPollAccess.
_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...
static _checkGoto(string $target)
check whether goto script will succeed
static _getCommands()
get commandsthis method returns an array of all possible commands/permission combinationsexample: $co...
ilAccessHandler $access
canBeDelivered(ilWACPath $ilWACPath)
User class.
Class ilObjectAccess.
static _getAllReferences(int $id)
get all reference ids for object ID
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
$results
global $DIC
Definition: shib_login.php:26