ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 {
53 $ilUser = $this->user;
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
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 switch ($permission) {
82 case "read":
83 case "visible":
84 if (self::_isOffline($obj_id) &&
86 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
87 return false;
88 }
89 break;
90 }
91
92 return true;
93 }
94
95 public static function _checkGoto(string $target): bool
96 {
97 global $DIC;
98
99 $ilAccess = $DIC->access();
100
101 $t_arr = explode("_", $target);
102
103 if ($t_arr[0] != "mcst" || ((int) $t_arr[1]) <= 0) {
104 return false;
105 }
106
107 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
108 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
109 return true;
110 }
111 return false;
112 }
113
114 public static function _lookupOnline(int $a_id): bool
115 {
116 global $DIC;
117
118 $ilDB = $DIC->database();
119
120 $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
121 $mc_set = $ilDB->query($q);
122 $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
123
124 return (bool) ($mc_rec["is_online"] ?? false);
125 }
126
127 public static function _lookupPublicFiles(int $a_id): bool
128 {
129 global $DIC;
130
131 $ilDB = $DIC->database();
132
133 $q = "SELECT * FROM il_media_cast_data WHERE id = " . $ilDB->quote($a_id);
134 $mc_set = $ilDB->query($q);
135 $mc_rec = $mc_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
136
137 return (bool) $mc_rec["public_files"];
138 }
139
144 public static function _lookupDiskUsage(int $a_id): int
145 {
146 $obj = new ilObjMediaCast($a_id, false);
147 $obj->read();
148 $items = $obj->getItemsArray();
149 $size = 0;
150 foreach ($items as $item) {
151 $news_item = new ilNewsItem($item["id"]);
152 $news_item->read();
153 $mobId = $news_item->getMobId();
155 }
156 return $size;
157 }
158}
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.
Class ilObjectAccess.
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="")
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23