ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjMediaCastAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Object/classes/class.ilObjectAccess.php");
6 
17 {
21  protected $user;
22 
26  protected $lng;
27 
31  protected $rbacsystem;
32 
36  protected $access;
37 
38 
42  public function __construct()
43  {
44  global $DIC;
45 
46  $this->user = $DIC->user();
47  $this->lng = $DIC->language();
48  $this->rbacsystem = $DIC->rbac()->system();
49  $this->access = $DIC->access();
50  }
51 
52 
65  public static function _getCommands()
66  {
67  $commands = array(
68  array("permission" => "read", "cmd" => "showContent", "lang_var" => "show",
69  "default" => true),
70  array("permission" => "write", "cmd" => "listItems", "lang_var" => "edit_content"),
71  array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings")
72  );
73 
74  return $commands;
75  }
76 
89  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
90  {
92  $lng = $this->lng;
94  $ilAccess = $this->access;
95 
96  if ($a_user_id == "") {
97  $a_user_id = $ilUser->getId();
98  }
99 
100  switch ($a_cmd) {
101  case "listItems":
102 
104  && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
105  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
106  return false;
107  }
108  break;
109 
110  // for permission query feature
111  case "infoScreen":
112  if (!ilObjMediaCastAccess::_lookupOnline($a_obj_id)) {
113  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
114  } else {
115  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
116  }
117  break;
118 
119  }
120  switch ($a_permission) {
121  case "read":
122  case "visible":
123  if (!ilObjMediaCastAccess::_lookupOnline($a_obj_id) &&
124  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
125  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
126  return false;
127  }
128  break;
129  }
130 
131  return true;
132  }
133 
137  public static function _checkGoto($a_target)
138  {
139  global $DIC;
140 
141  $ilAccess = $DIC->access();
142 
143  $t_arr = explode("_", $a_target);
144 
145  if ($t_arr[0] != "mcst" || ((int) $t_arr[1]) <= 0) {
146  return false;
147  }
148 
149  if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
150  return true;
151  }
152  return false;
153  }
154 
160  public static function _lookupOnline($a_id)
161  {
162  global $DIC;
163 
164  $ilDB = $DIC->database();
165 
166  $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
167  $mc_set = $ilDB->query($q);
168  $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
169 
170  return $mc_rec["is_online"];
171  }
172 
178  public static function _lookupPublicFiles($a_id)
179  {
180  global $DIC;
181 
182  $ilDB = $DIC->database();
183 
184  $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
185  $mc_set = $ilDB->query($q);
186  $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
187 
188  return $mc_rec["public_files"];
189  }
190 
196  public static function _lookupDiskUsage($a_id)
197  {
198  require_once('Modules/MediaCast/classes/class.ilObjMediaCast.php');
199  require_once("./Services/News/classes/class.ilNewsItem.php");
200  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
201  $obj = new ilObjMediaCast($a_id, false);
202  $obj->read();
203  $items = $obj->getItemsArray();
204  $size = 0;
205  foreach ($items as $item) {
206  $news_item = new ilNewsItem($item["id"]);
207  $news_item->read();
208  $mobId = $news_item->getMobId();
210  }
211  return $size;
212  }
213 }
$size
Definition: RandomTest.php:84
global $DIC
Definition: saml.php:7
const IL_NO_OBJECT_ACCESS
Class ilObjMediaCastAccess.
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
user()
Definition: user.php:4
static _getDirectory($a_mob_id)
Get absolute directory.
Class ilObjMediaCast.
const IL_STATUS_MESSAGE
$ilUser
Definition: imgupload.php:18
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id...
static _lookupPublicFiles($a_id)
Check wether files should be public.
static dirsize($directory)
get size of a directory or a file.
Class ilObjectAccess.
global $ilDB
static _lookupOnline($a_id)
Check wether media cast is online.
static _checkGoto($a_target)
check whether goto script will succeed
static _getCommands()
get commands