ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjGlossaryAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $user;
16 
20  protected $lng;
21 
25  protected $rbacsystem;
26 
30  protected $access;
31 
32 
36  public function __construct()
37  {
38  global $DIC;
39 
40  $this->user = $DIC->user();
41  $this->lng = $DIC->language();
42  $this->rbacsystem = $DIC->rbac()->system();
43  $this->access = $DIC->access();
44  }
45 
59  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
60  {
62  $lng = $this->lng;
64  $ilAccess = $this->access;
65 
66  if ($a_user_id == "") {
67  $a_user_id = $ilUser->getId();
68  }
69 
70  switch ($a_permission) {
71  case "read":
73  && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
74  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
75  return false;
76  }
77  break;
78 
79  case "visible":
80  if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
81  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
82  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
83  return false;
84  }
85  break;
86  }
87 
88 
89  return true;
90  }
91 
104  public static function _getCommands()
105  {
106  $commands = array(
107  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
108  "default" => true),
109  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
110  array("permission" => "edit_content", "cmd" => "edit", "lang_var" => "edit_content"), // #11099
111  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
112  );
113 
114  return $commands;
115  }
116 
117  //
118  // access relevant methods
119  //
120 
124  public static function _lookupOnline($a_id)
125  {
126  global $DIC;
127 
128  $ilDB = $DIC->database();
129 
130  $q = "SELECT * FROM glossary WHERE id = " .
131  $ilDB->quote($a_id, "integer");
132  $lm_set = $ilDB->query($q);
133  $lm_rec = $ilDB->fetchAssoc($lm_set);
134 
135  return ilUtil::yn2tf($lm_rec["is_online"]);
136  }
137 
143  public static function _lookupOnlineStatus($a_ids)
144  {
145  global $DIC;
146 
147  $ilDB = $DIC->database();
148 
149  $q = "SELECT id, is_online FROM glossary WHERE " .
150  $ilDB->in("id", $a_ids, false, "integer");
151  $lm_set = $ilDB->query($q);
152  $status = [];
153  while ($r = $ilDB->fetchAssoc($lm_set)) {
154  $status[$r["id"]] = ilUtil::yn2tf($r["is_online"]);
155  }
156 
157  return $status;
158  }
159 
160 
164  public static function _checkGoto($a_target)
165  {
166  global $DIC;
167 
168  $ilAccess = $DIC->access();
169 
170  $t_arr = explode("_", $a_target);
171 
172  if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0) {
173  return false;
174  }
175 
176  if ($t_arr[0] == "glo") {
177  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
178  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
179  return true;
180  }
181  }
182 
183  if ($t_arr[0] == "git") {
184  if ($t_arr[2] > 0) {
185  $ref_ids = array($t_arr[2]);
186  } else {
187  // determine learning object
188  $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
189  $ref_ids = ilObject::_getAllReferences($glo_id);
190  }
191  // check read permissions
192  foreach ($ref_ids as $ref_id) {
193  // Permission check
194  if ($ilAccess->checkAccess("read", "", $ref_id)) {
195  return true;
196  }
197  }
198  }
199 
200  return false;
201  }
202 }
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
const IL_NO_OBJECT_ACCESS
static _lookupOnline($a_id)
check wether learning module is online
static _lookupOnlineStatus($a_ids)
Check wether learning module is online (legacy version)
static _getCommands()
get commands
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
static _checkGoto($a_target)
check whether goto script will succeed
Class ilObjGlossaryAccess.
$ilUser
Definition: imgupload.php:18
static _lookGlossaryID($term_id)
get glossary id form term id
$lm_set
global $ilDB
$DIC
Definition: xapitoken.php:46
static yn2tf($a_yn)
convert "y"/"n" to true/false