ILIAS  eassessment Revision 61809
 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-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 {
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["is_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 
182  function _lookupDiskUsage($a_id)
183  {
184  require_once('Modules/MediaCast/classes/class.ilObjMediaCast.php');
185  require_once("./Services/News/classes/class.ilNewsItem.php");
186  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
187  $obj = new ilObjMediaCast($a_id, false);
188  $obj->read();
189  $items = $obj->getItemsArray();
190  $size = 0;
191  foreach ($items as $item)
192  {
193  $news_item = new ilNewsItem($item["id"]);
194  $news_item->read();
195  $mobId = $news_item->getMobId();
197  }
198  return $size;
199  }
200 }
201 
202 ?>