ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilObjGlossaryAccess.php
Go to the documentation of this file.
1 <?php
2 
20 {
21  protected ilObjUser $user;
22  protected ilLanguage $lng;
25 
26  public function __construct()
27  {
28  global $DIC;
29 
30  $this->user = $DIC->user();
31  $this->lng = $DIC->language();
32  $this->rbacsystem = $DIC->rbac()->system();
33  $this->access = $DIC->access();
34  }
35 
36  public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
37  {
38  $ilUser = $this->user;
39  $lng = $this->lng;
40  $rbacsystem = $this->rbacsystem;
41  $ilAccess = $this->access;
42 
43  if (is_null($user_id)) {
44  $user_id = $ilUser->getId();
45  }
46 
47  switch ($permission) {
48  case "read":
49  if (!self::_lookupOnline($obj_id)
50  && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
51  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
52  return false;
53  }
54  break;
55 
56  case "visible":
57  if (!self::_lookupOnline($obj_id) &&
58  (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))) {
59  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
60  return false;
61  }
62  break;
63  }
64 
65 
66  return true;
67  }
68 
69  public static function _getCommands(): array
70  {
71  $commands = array(
72  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
73  "default" => true),
74  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
75  array("permission" => "edit_content", "cmd" => "edit", "lang_var" => "edit_content"), // #11099
76  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
77  );
78 
79  return $commands;
80  }
81 
82  //
83  // access relevant methods
84  //
85 
86  public static function _lookupOnline(int $a_id): bool
87  {
88  return !self::_isOffline($a_id);
89  }
90 
91  public static function _lookupOnlineStatus(array $a_ids): array
92  {
93  $status = [];
94  foreach ($a_ids as $id) {
95  $status[$id] = !self::_isOffline($id);
96  }
97 
98  return $status;
99  }
100 
101 
102  public static function _checkGoto(string $target): bool
103  {
104  global $DIC;
105 
106  $ilAccess = $DIC->access();
107 
108  $t_arr = explode("_", $target);
109 
110  if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0) {
111  return false;
112  }
113 
114  if ($t_arr[0] == "glo") {
115  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
116  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
117  return true;
118  }
119  }
120 
121  if ($t_arr[0] == "git") {
122  if ((int) ($t_arr[2] ?? 0) > 0) {
123  $ref_ids = array($t_arr[2]);
124  } else {
125  // determine learning object
126  $glo_id = ilGlossaryTerm::_lookGlossaryID((int) $t_arr[1]);
127  $ref_ids = ilObject::_getAllReferences($glo_id);
128  }
129  // check read permissions
130  foreach ($ref_ids as $ref_id) {
131  // Permission check
132  if ($ilAccess->checkAccess("read", "", $ref_id)) {
133  return true;
134  }
135  }
136  }
137 
138  return false;
139  }
140 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupOnlineStatus(array $a_ids)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _checkGoto(string $target)
static _lookGlossaryID(int $term_id)
get glossary id form term id