ILIAS  Release_4_4_x_branch Revision 61816
 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) && $t_arr[1] != "wpage")
114  {
115  return false;
116  }
117 
118  if ($t_arr[1] == "wpage")
119  {
120  $wpg_id = (int) $t_arr[2];
121  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
122  $w_id = ilWikiPage::lookupWikiId($wpg_id);
123  $refs = ilObject::_getAllReferences($w_id);
124  foreach ($refs as $r)
125  {
126  if ($ilAccess->checkAccess("read", "", $r))
127  {
128  return true;
129  }
130  }
131  }
132  else if ($ilAccess->checkAccess("read", "", $t_arr[1]))
133  {
134  return true;
135  }
136  return false;
137  }
138 
144  function _lookupOnline($a_id)
145  {
146  global $ilDB;
147 
148  $q = "SELECT * FROM il_wiki_data WHERE id = ".
149  $ilDB->quote($a_id, "integer");
150  $wk_set = $ilDB->query($q);
151  $wk_rec = $ilDB->fetchAssoc($wk_set);
152 
153  return $wk_rec["is_online"];
154  }
155 
161  function _lookupPublicFiles($a_id)
162  {
163  global $ilDB;
164 
165  $q = "SELECT * FROM il_wiki_data WHERE id = ".
166  $ilDB->quote($a_id, "integer");
167  $wk_set = $ilDB->query($q);
168  $wk_rec = $ilDB->fetchAssoc($wk_set);
169 
170  return $wk_rec["public_files"];
171  }
172 
173 }
174 
175 ?>