ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjWikiAccess.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 {
37 
50  function _getCommands()
51  {
52  $commands = array
53  (
54  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
55  "default" => true),
56  array("permission" => "write", "cmd" => "editSettings", "lang_var" => "edit")
57  );
58 
59  return $commands;
60  }
61 
74  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
75  {
76  global $ilUser, $lng, $rbacsystem, $ilAccess;
77 
78  if ($a_user_id == "")
79  {
80  $a_user_id = $ilUser->getId();
81  }
82 
83  switch ($a_cmd)
84  {
85  case "view":
86 
87  if(!ilObjWikiAccess::_lookupOnline($a_obj_id)
88  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
89  {
90  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
91  return false;
92  }
93  break;
94 
95  // for permission query feature
96  case "infoScreen":
97  if(!ilObjWikiAccess::_lookupOnline($a_obj_id))
98  {
99  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
100  }
101  else
102  {
103  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
104  }
105  break;
106 
107  }
108  switch ($a_permission)
109  {
110  case "read":
111  case "visible":
112  if (!ilObjWikiAccess::_lookupOnline($a_obj_id) &&
113  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)))
114  {
115  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
116  return false;
117  }
118  break;
119  }
120 
121  return true;
122  }
123 
127  function _checkGoto($a_target)
128  {
129  global $ilAccess;
130 
131  $t_arr = explode("_", $a_target);
132 
133  if ($t_arr[0] != "wiki" || ((int) $t_arr[1]) <= 0)
134  {
135  return false;
136  }
137 
138  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
139  {
140  return true;
141  }
142  return false;
143  }
144 
150  function _lookupOnline($a_id)
151  {
152  global $ilDB;
153 
154  $q = "SELECT * FROM il_wiki_data WHERE id = ".$ilDB->quote($a_id);
155  $wk_set = $ilDB->query($q);
156  $wk_rec = $wk_set->fetchRow(DB_FETCHMODE_ASSOC);
157 
158  return $wk_rec["online"];
159  }
160 
166  function _lookupPublicFiles($a_id)
167  {
168  global $ilDB;
169 
170  $q = "SELECT * FROM il_wiki_data WHERE id = ".$ilDB->quote($a_id);
171  $wk_set = $ilDB->query($q);
172  $wk_rec = $wk_set->fetchRow(DB_FETCHMODE_ASSOC);
173 
174  return $wk_rec["public_files"];
175  }
176 
177 }
178 
179 ?>