ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjPollAccess.php
Go to the documentation of this file.
1 <?php
2 
3 declare(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  {
49  $ilUser = $this->user;
50  $lng = $this->lng;
51  $rbacsystem = $this->rbacsystem;
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 
71  public static function _getCommands(): array
72  {
73  return [
74  ["permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true],
75  ["permission" => "write", "cmd" => "render", "lang_var" => "edit"]
76  ];
77  }
78 
82  public static function _checkGoto(string $target): bool
83  {
84  global $DIC;
85 
86  $ilAccess = $DIC->access();
87 
88  $t_arr = explode("_", $target);
89 
90  if ($t_arr[0] !== "poll" || ((int) $t_arr[1]) <= 0) {
91  return false;
92  }
93 
94  if ($ilAccess->checkAccess("read", "", (int) $t_arr[1])) {
95  return true;
96  }
97 
98  return false;
99  }
100 
101 
105  public function canBeDelivered(ilWACPath $ilWACPath): bool
106  {
107  $ilAccess = $this->access;
108  preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
109 
110  foreach (ilObject2::_getAllReferences((int) $results[1]) as $ref_id) {
111  if ($ilAccess->checkAccess('read', '', $ref_id)) {
112  return true;
113  }
114  }
115 
116  return false;
117  }
118 }
static _getAllReferences(int $id)
get all reference ids for object ID
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
ilAccessHandler $access
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$results
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
canBeDelivered(ilWACPath $ilWACPath)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _checkGoto(string $target)