ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSAHSLearningModuleAccess.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 {
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_cmd)
59  {
60  case "view":
61 
63  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
64  {
65  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
66  return false;
67  }
68  break;
69  }
70 
71  switch ($a_permission)
72  {
73  case "visible":
75  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
76  {
77  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
78  return false;
79  }
80  break;
81  }
82 
83 
84  return true;
85  }
86 
99  function _getCommands()
100  {
101  $commands = array
102  (
103  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
104  "default" => true),
105  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
106  );
107 
108  return $commands;
109  }
110 
111  //
112  // access relevant methods
113  //
114 
118  function _lookupOnline($a_id)
119  {
120  global $ilDB;
121 
122  $q = "SELECT * FROM sahs_lm WHERE id = ".$ilDB->quote($a_id);
123  $set = $ilDB->query($q);
124  $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
125 
126  return ilUtil::yn2tf($rec["online"]);
127  }
128 
132  function _checkGoto($a_target)
133  {
134  global $ilAccess;
135 
136  $t_arr = explode("_", $a_target);
137 
138  if ($t_arr[0] != "sahs" || ((int) $t_arr[1]) <= 0)
139  {
140  return false;
141  }
142 
143  if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
144  {
145  return true;
146  }
147  return false;
148  }
149 
150  //BEGIN DiskQuota: Get used disk space
156  function _getDiskSpaceUsed($a_id)
157  {
158  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
159  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
160 
161  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
162 
163  }
169  function _getDiskSpaceUsedBy($user_id, $as_string = false)
170  {
171  // XXX - This method is extremely slow. We should
172  // use a cache to speed it up, for example, we should
173  // store the disk space used in a table of the sahs object.
174  global $ilDB, $lng;
175 
176 
177  $q = "SELECT obj_id ".
178  "FROM object_data ".
179  "WHERE type = 'sahs' ".
180  "AND owner = ".$ilDB->quote($user_id);
181  $us_set = $ilDB->query($q);
182  $size = 0;
183  $count = 0;
184  while($us_rec = $us_set->fetchRow(DB_FETCHMODE_ASSOC))
185  {
187  $count++;
188  }
189  include_once("Modules/File/classes/class.ilObjFileAccess.php");
190  return ($as_string) ?
191  $count.' '.$lng->txt('sahs').', '.ilObjFileAccess::_sizeToString($size) :
192  $size;
193  }
194  //END DiskQuota: Get used disk space
195 
196 }
197 
198 ?>