ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGlossaryAccess.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("classes/class.ilObjectAccess.php");
25 
36 {
50  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
51  {
52  global $ilUser, $lng, $rbacsystem, $ilAccess;
53 
54  if ($a_user_id == "")
55  {
56  $a_user_id = $ilUser->getId();
57  }
58 
59  switch ($a_permission)
60  {
61  case "read":
63  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
64  {
65  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
66  return false;
67  }
68  break;
69 
70  case "visible":
71  if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
72  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
73  {
74  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
75  return false;
76  }
77  break;
78  }
79 
80 
81  return true;
82  }
83 
96  function _getCommands()
97  {
98  $commands = array
99  (
100  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
101  "default" => true),
102  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
103  );
104 
105  return $commands;
106  }
107 
108  //
109  // access relevant methods
110  //
111 
115  function _lookupOnline($a_id)
116  {
117  global $ilDB;
118 
119  $q = "SELECT * FROM glossary WHERE id = ".
120  $ilDB->quote($a_id, "integer");
121  $lm_set = $ilDB->query($q);
122  $lm_rec = $ilDB->fetchAssoc($lm_set);
123 
124  return ilUtil::yn2tf($lm_rec["is_online"]);
125  }
126 
130  function _checkGoto($a_target)
131  {
132  global $ilAccess;
133 
134  $t_arr = explode("_", $a_target);
135 
136  if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0)
137  {
138  return false;
139  }
140 
141  if ($t_arr[0] == "glo")
142  {
143  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
144  $ilAccess->checkAccess("visible", "", $t_arr[1]))
145  {
146  return true;
147  }
148  }
149 
150  if ($t_arr[0] == "git")
151  {
152  if ($t_arr[2] > 0)
153  {
154  $ref_ids = array($t_arr[2]);
155  }
156  else
157  {
158  // determine learning object
159  require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
160  $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
161  $ref_ids = ilObject::_getAllReferences($glo_id);
162  }
163  // check read permissions
164  foreach ($ref_ids as $ref_id)
165  {
166  // Permission check
167  if ($ilAccess->checkAccess("read", "", $ref_id))
168  {
169  return true;
170  }
171  }
172  }
173 
174  return false;
175  }
176 
177 
178 }
179 
180 ?>