ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5include_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 {
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 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
151 return true;
152 }
153 return false;
154 }
155
161 public static function _lookupOnline($a_id)
162 {
163 global $DIC;
164
165 $ilDB = $DIC->database();
166
167 $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
168 $mc_set = $ilDB->query($q);
169 $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
170
171 return $mc_rec["is_online"];
172 }
173
179 public static function _lookupPublicFiles($a_id)
180 {
181 global $DIC;
182
183 $ilDB = $DIC->database();
184
185 $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
186 $mc_set = $ilDB->query($q);
187 $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
188
189 return $mc_rec["public_files"];
190 }
191
197 public static function _lookupDiskUsage($a_id)
198 {
199 require_once('Modules/MediaCast/classes/class.ilObjMediaCast.php');
200 require_once("./Services/News/classes/class.ilNewsItem.php");
201 require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
202 $obj = new ilObjMediaCast($a_id, false);
203 $obj->read();
204 $items = $obj->getItemsArray();
205 $size = 0;
206 foreach ($items as $item) {
207 $news_item = new ilNewsItem($item["id"]);
208 $news_item->read();
209 $mobId = $news_item->getMobId();
211 }
212 return $size;
213 }
214}
user()
Definition: user.php:4
$size
Definition: RandomTest.php:84
An exception for terminatinating execution or to throw for unit testing.
const IL_STATUS_MESSAGE
const IL_NO_OBJECT_ACCESS
Class ilObjMediaCastAccess.
static _getCommands()
get commands
static _lookupOnline($a_id)
Check wether media cast is online.
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id.
static _checkGoto($a_target)
check whether goto script will succeed
static _lookupPublicFiles($a_id)
Check wether files should be public.
_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...
Class ilObjMediaCast.
static _getDirectory($a_mob_id)
Get absolute directory.
Class ilObjectAccess.
static dirsize($directory)
get size of a directory or a file.
global $ilDB
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46