ILIAS  release_8 Revision v8.24
class.ilObjPollAccess.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
28{
29 protected ilObjUser $user;
30 protected ilLanguage $lng;
33
34 public function __construct()
35 {
36 global $DIC;
37
38 $this->user = $DIC->user();
39 $this->lng = $DIC->language();
40 $this->rbacsystem = $DIC->rbac()->system();
41 $this->access = $DIC->access();
42 }
43
47 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
48 {
52 $ilAccess = $this->access;
53
54 if (!$user_id) {
55 $a_user_id = $ilUser->getId();
56 }
57
58 if (
59 $cmd === 'preview' &&
60 $permission === 'read'
61 ) {
62 return false;
63 }
64
65 return true;
66 }
67
68 public static function _isActivated(int $a_ref_id): bool
69 {
70 $item = ilObjectActivation::getItem($a_ref_id);
71 switch ($item['timing_type']) {
73 if (time() < $item['timing_start'] or
74 time() > $item['timing_end']) {
75 return false;
76 }
77 // fallthrough
78
79 // no break
80 default:
81 return true;
82 }
83 }
84
88 public static function _getCommands(): array
89 {
90 return [
91 ["permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true],
92 ["permission" => "write", "cmd" => "render", "lang_var" => "edit"]
93 ];
94 }
95
99 public static function _checkGoto(string $target): bool
100 {
101 global $DIC;
102
103 $ilAccess = $DIC->access();
104
105 $t_arr = explode("_", $target);
106
107 if ($t_arr[0] !== "poll" || ((int) $t_arr[1]) <= 0) {
108 return false;
109 }
110
111 if ($ilAccess->checkAccess("read", "", (int) $t_arr[1])) {
112 return true;
113 }
114
115 return false;
116 }
117
118
122 public function canBeDelivered(ilWACPath $ilWACPath): bool
123 {
124 $ilAccess = $this->access;
125 preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
126
127 foreach (ilObject2::_getAllReferences((int) $results[1]) as $ref_id) {
128 if ($ilAccess->checkAccess('read', '', $ref_id)) {
129 return true;
130 }
131 }
132
133 return false;
134 }
135}
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
_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
static _isActivated(int $a_ref_id)
canBeDelivered(ilWACPath $ilWACPath)
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getItem(int $ref_id)
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...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
$results