ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjWikiAccess.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObjectAccess.php");
5 
16 {
17 
30  function _getCommands()
31  {
32  $commands = array
33  (
34  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
35  "default" => true),
36  array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings")
37  );
38 
39  return $commands;
40  }
41 
54  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
55  {
56  global $ilUser, $lng, $rbacsystem, $ilAccess;
57 
58  if ($a_user_id == "")
59  {
60  $a_user_id = $ilUser->getId();
61  }
62 
63  switch ($a_cmd)
64  {
65  case "view":
66 
67  if(!ilObjWikiAccess::_lookupOnline($a_obj_id)
68  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
69  {
70  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
71  return false;
72  }
73  break;
74 
75  // for permission query feature
76  case "infoScreen":
77  if(!ilObjWikiAccess::_lookupOnline($a_obj_id))
78  {
79  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
80  }
81  else
82  {
83  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
84  }
85  break;
86 
87  }
88  switch ($a_permission)
89  {
90  case "read":
91  case "visible":
92  if (!ilObjWikiAccess::_lookupOnline($a_obj_id) &&
93  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)))
94  {
95  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
96  return false;
97  }
98  break;
99  }
100 
101  return true;
102  }
103 
107  function _checkGoto($a_target)
108  {
109  global $ilAccess;
110 
111  $t_arr = explode("_", $a_target);
112 
113  if ($t_arr[0] != "wiki" || ((int) $t_arr[1]) <= 0)
114  {
115  return false;
116  }
117 
118  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
119  {
120  return true;
121  }
122  return false;
123  }
124 
130  function _lookupOnline($a_id)
131  {
132  global $ilDB;
133 
134  $q = "SELECT * FROM il_wiki_data WHERE id = ".
135  $ilDB->quote($a_id, "integer");
136  $wk_set = $ilDB->query($q);
137  $wk_rec = $ilDB->fetchAssoc($wk_set);
138 
139  return $wk_rec["is_online"];
140  }
141 
147  function _lookupPublicFiles($a_id)
148  {
149  global $ilDB;
150 
151  $q = "SELECT * FROM il_wiki_data WHERE id = ".
152  $ilDB->quote($a_id, "integer");
153  $wk_set = $ilDB->query($q);
154  $wk_rec = $ilDB->fetchAssoc($wk_set);
155 
156  return $wk_rec["public_files"];
157  }
158 
159 }
160 
161 ?>