ILIAS  release_8 Revision v8.24
class.ilObjMediaCastAccess.php
Go to the documentation of this file.
1<?php
2
23{
24 protected ilObjUser $user;
25 protected ilLanguage $lng;
28
29 public function __construct()
30 {
31 global $DIC;
32
33 $this->user = $DIC->user();
34 $this->lng = $DIC->language();
35 $this->rbacsystem = $DIC->rbac()->system();
36 $this->access = $DIC->access();
37 }
38
39 public static function _getCommands(): array
40 {
41 $commands = array(
42 array("permission" => "read", "cmd" => "showContent", "lang_var" => "show",
43 "default" => true),
44 array("permission" => "write", "cmd" => "listItems", "lang_var" => "edit_content"),
45 array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings")
46 );
47
48 return $commands;
49 }
50
51 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
52 {
56 $ilAccess = $this->access;
57
58 if (is_null($user_id)) {
59 $user_id = $ilUser->getId();
60 }
61
62 switch ($cmd) {
63 case "listItems":
64
66 && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
67 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
68 return false;
69 }
70 break;
71
72 // for permission query feature
73 case "infoScreen":
75 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
76 } else {
77 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_MESSAGE, $lng->txt("online"));
78 }
79 break;
80
81 }
82 switch ($permission) {
83 case "read":
84 case "visible":
86 (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))) {
87 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
88 return false;
89 }
90 break;
91 }
92
93 return true;
94 }
95
96 public static function _checkGoto(string $target): bool
97 {
98 global $DIC;
99
100 $ilAccess = $DIC->access();
101
102 $t_arr = explode("_", $target);
103
104 if ($t_arr[0] != "mcst" || ((int) $t_arr[1]) <= 0) {
105 return false;
106 }
107
108 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
109 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
110 return true;
111 }
112 return false;
113 }
114
115 public static function _lookupOnline(int $a_id): bool
116 {
117 global $DIC;
118
119 $ilDB = $DIC->database();
120
121 $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
122 $mc_set = $ilDB->query($q);
123 $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
124
125 return (bool) ($mc_rec["is_online"] ?? false);
126 }
127
128 public static function _lookupPublicFiles(int $a_id): bool
129 {
130 global $DIC;
131
132 $ilDB = $DIC->database();
133
134 $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
135 $mc_set = $ilDB->query($q);
136 $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
137
138 return (bool) $mc_rec["public_files"];
139 }
140
145 public static function _lookupDiskUsage(int $a_id): int
146 {
147 $obj = new ilObjMediaCast($a_id, false);
148 $obj->read();
149 $items = $obj->getItemsArray();
150 $size = 0;
151 foreach ($items as $item) {
152 $news_item = new ilNewsItem($item["id"]);
153 $news_item->read();
154 $mobId = $news_item->getMobId();
156 }
157 return $size;
158 }
159}
static dirsize(string $directory)
get size of a directory or a file.
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
A news item can be created by different sources.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getCommands()
get commands
static _checkGoto(string $target)
check whether goto script will succeed
static _lookupDiskUsage(int $a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id.
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getDirectory(int $a_mob_id)
Get absolute directory.
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67