ILIAS  Release_3_10_x_branch Revision 61812
 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-2006 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_cmd)
60  {
61  case "view":
62 
64  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
65  {
66  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
67  return false;
68  }
69  break;
70  }
71 
72  switch ($a_permission)
73  {
74  case "visible":
75  if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
76  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
77  {
78  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
79  return false;
80  }
81  break;
82  }
83 
84 
85  return true;
86  }
87 
100  function _getCommands()
101  {
102  $commands = array
103  (
104  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
105  "default" => true),
106  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
107  );
108 
109  return $commands;
110  }
111 
112  //
113  // access relevant methods
114  //
115 
119  function _lookupOnline($a_id)
120  {
121  global $ilDB;
122 
123  $q = "SELECT * FROM glossary WHERE id = ".$ilDB->quote($a_id);
124  $lm_set = $ilDB->query($q);
125  $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
126 
127  return ilUtil::yn2tf($lm_rec["online"]);
128  }
129 
133  function _checkGoto($a_target)
134  {
135  global $ilAccess;
136 
137  $t_arr = explode("_", $a_target);
138 
139  if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0)
140  {
141  return false;
142  }
143 
144  if ($t_arr[0] == "glo")
145  {
146  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
147  $ilAccess->checkAccess("visible", "", $t_arr[1]))
148  {
149  return true;
150  }
151  }
152 
153  if ($t_arr[0] == "git")
154  {
155  if ($t_arr[2] > 0)
156  {
157  $ref_ids = array($t_arr[2]);
158  }
159  else
160  {
161  // determine learning object
162  require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
163  $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
164  $ref_ids = ilObject::_getAllReferences($glo_id);
165  }
166  // check read permissions
167  foreach ($ref_ids as $ref_id)
168  {
169  // Permission check
170  if ($ilAccess->checkAccess("read", "", $ref_id))
171  {
172  return true;
173  }
174  }
175  }
176 
177  return false;
178  }
179 
180 
181 }
182 
183 ?>