ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjMediaCastAccess.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" => "listItems", "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 "listItems":
86 
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":
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 (!ilObjMediaCastAccess::_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] != "mcst" || ((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_media_cast_data WHERE id = ".$ilDB->quote($a_id);
155  $mc_set = $ilDB->query($q);
156  $mc_rec = $mc_set->fetchRow(DB_FETCHMODE_ASSOC);
157 
158  return $mc_rec["online"];
159  }
160 
166  function _lookupPublicFiles($a_id)
167  {
168  global $ilDB;
169 
170  $q = "SELECT * FROM il_media_cast_data WHERE id = ".$ilDB->quote($a_id);
171  $mc_set = $ilDB->query($q);
172  $mc_rec = $mc_set->fetchRow(DB_FETCHMODE_ASSOC);
173 
174  return $mc_rec["public_files"];
175  }
176 
177  //BEGIN DiskQuota: Get used disk space..
183  function _getDiskSpaceUsed($a_id)
184  {
185  require_once('Modules/MediaCast/classes/class.ilObjMediaCast.php');
186  require_once("./Services/News/classes/class.ilNewsItem.php");
187  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
188  $obj = new ilObjMediaCast($a_id, false);
189  $obj->read();
190  $items = $obj->getItemsArray();
191  $size = 0;
192  foreach ($items as $item)
193  {
194  $news_item = new ilNewsItem($item["id"]);
195  $news_item->read();
196  $mobId = $news_item->getMobId();
198  }
199  return $size;
200  }
206  function _getDiskSpaceUsedBy($user_id, $as_string = false)
207  {
208  global $ilDB, $lng;
209 
210  $q = "SELECT obj_id FROM object_data WHERE type = 'mcst' AND owner = $user_id";
211  $us_set = $ilDB->query($q);
212  $size = 0;
213  $count = 0;
214  while($us_rec = $us_set->fetchRow(DB_FETCHMODE_ASSOC))
215  {
216  $size += ilObjMediaCastAccess::_getDiskSpaceUsed($us_rec["obj_id"]);
217  $count++;
218  }
219 
220  require_once("./Modules/File/classes/class.ilObjFileAccess.php");
221  return ($as_string) ? $count.' '.$lng->txt('obj_mcst').', '.ilObjFileAccess::_sizeToString($size) : $size;
222  }
223  //END DiskQuota: Get used disk space..
224 }
225 
226 ?>