ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileBasedLMAccess.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 {
49  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
50  {
51  global $ilUser, $lng, $rbacsystem, $ilAccess;
52 
53  if ($a_user_id == "")
54  {
55  $a_user_id = $ilUser->getId();
56  }
57 
58  switch ($a_permission)
59  {
60  case "visible":
61  if (!ilObjFileBasedLMAccess::_lookupOnline($a_obj_id) &&
62  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
63  {
64  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
65  return false;
66  }
67  break;
68 
69  case "read":
70 
72  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id)) ||
74  {
75  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
76  return false;
77  }
78  break;
79  }
80 
81 
82  return true;
83  }
84 
97  function _getCommands()
98  {
99  $commands = array
100  (
101  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
102  "default" => true),
103  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
104  );
105 
106  return $commands;
107  }
108 
109  //
110  // access relevant methods
111  //
112 
116  function _lookupOnline($a_id)
117  {
118  global $ilDB;
119 
120  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
121  $set = $ilDB->query($q);
122  $rec = $ilDB->fetchAssoc($set);
123 
124  return ilUtil::yn2tf($rec["is_online"]);
125  }
126 
130  function _determineStartUrl($a_id)
131  {
132  global $ilDB;
133 
134  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
135  $set = $ilDB->query($q);
136  $rec = $ilDB->fetchAssoc($set);
137  $start_file = $rec["startfile"];
138  $dir = ilUtil::getWebspaceDir()."/lm_data/lm_".$a_id;
139 
140  if (($start_file != "") &&
141  (@is_file($dir."/".$start_file)))
142  {
143  return "./".$dir."/".$start_file;
144  }
145  else if (@is_file($dir."/index.html"))
146  {
147  return "./".$dir."/index.html";
148  }
149  else if (@is_file($dir."/index.htm"))
150  {
151  return "./".$dir."/index.htm";
152  }
153 
154  return "";
155  }
156 
160  function _checkGoto($a_target)
161  {
162  global $ilAccess;
163 
164  $t_arr = explode("_", $a_target);
165 
166  if ($t_arr[0] != "htlm" || ((int) $t_arr[1]) <= 0)
167  {
168  return false;
169  }
170 
171  if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
172  {
173  return true;
174  }
175  return false;
176  }
177 
183  function _lookupDiskUsage($a_id)
184  {
185  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
186  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
187 
188  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
189 
190  }
191 }
192 
193 ?>