ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjGlossaryAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once("./Services/Object/classes/class.ilObjectAccess.php");
7 
18 {
22  protected $user;
23 
27  protected $lng;
28 
32  protected $rbacsystem;
33 
37  protected $access;
38 
39 
43  public function __construct()
44  {
45  global $DIC;
46 
47  $this->user = $DIC->user();
48  $this->lng = $DIC->language();
49  $this->rbacsystem = $DIC->rbac()->system();
50  $this->access = $DIC->access();
51  }
52 
66  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
67  {
69  $lng = $this->lng;
71  $ilAccess = $this->access;
72 
73  if ($a_user_id == "") {
74  $a_user_id = $ilUser->getId();
75  }
76 
77  switch ($a_permission) {
78  case "read":
80  && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
81  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
82  return false;
83  }
84  break;
85 
86  case "visible":
87  if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
88  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
89  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
90  return false;
91  }
92  break;
93  }
94 
95 
96  return true;
97  }
98 
111  public static function _getCommands()
112  {
113  $commands = array(
114  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
115  "default" => true),
116  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
117  array("permission" => "edit_content", "cmd" => "edit", "lang_var" => "edit_content"), // #11099
118  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
119  );
120 
121  return $commands;
122  }
123 
124  //
125  // access relevant methods
126  //
127 
131  public static function _lookupOnline($a_id)
132  {
133  global $DIC;
134 
135  $ilDB = $DIC->database();
136 
137  $q = "SELECT * FROM glossary WHERE id = " .
138  $ilDB->quote($a_id, "integer");
139  $lm_set = $ilDB->query($q);
140  $lm_rec = $ilDB->fetchAssoc($lm_set);
141 
142  return ilUtil::yn2tf($lm_rec["is_online"]);
143  }
144 
148  public static function _checkGoto($a_target)
149  {
150  global $DIC;
151 
152  $ilAccess = $DIC->access();
153 
154  $t_arr = explode("_", $a_target);
155 
156  if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0) {
157  return false;
158  }
159 
160  if ($t_arr[0] == "glo") {
161  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
162  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
163  return true;
164  }
165  }
166 
167  if ($t_arr[0] == "git") {
168  if ($t_arr[2] > 0) {
169  $ref_ids = array($t_arr[2]);
170  } else {
171  // determine learning object
172  require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
173  $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
174  $ref_ids = ilObject::_getAllReferences($glo_id);
175  }
176  // check read permissions
177  foreach ($ref_ids as $ref_id) {
178  // Permission check
179  if ($ilAccess->checkAccess("read", "", $ref_id)) {
180  return true;
181  }
182  }
183  }
184 
185  return false;
186  }
187 }
global $DIC
Definition: saml.php:7
_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 _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
Create styles array
The data for the language used.
static _lookGlossaryID($term_id)
get glossary id form term id
$lm_set
Class ilObjectAccess.
global $ilDB
static yn2tf($a_yn)
convert "y"/"n" to true/false