ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMediaCastDataSet.php
Go to the documentation of this file.
1<?php
2
25{
27 protected array $order = array();
28
29 public function getSupportedVersions(): array
30 {
31 return array("8.0", "5.0.0", "4.1.0");
32 }
33
34 public function getXmlNamespace(string $a_entity, string $a_schema_version): string
35 {
36 return "https://www.ilias.de/xml/Modules/MediaCast/" . $a_entity;
37 }
38
39 protected function getTypes(string $a_entity, string $a_version): array
40 {
41 if ($a_entity == "mcst") {
42 switch ($a_version) {
43 case "4.1.0":
44 return array(
45 "Id" => "integer",
46 "Title" => "text",
47 "Description" => "text",
48 "PublicFiles" => "integer",
49 "Downloadable" => "integer",
50 "DefaultAccess" => "integer");
51
52 case "5.0.0":
53 return array(
54 "Id" => "integer",
55 "Title" => "text",
56 "Description" => "text",
57 "PublicFiles" => "integer",
58 "Downloadable" => "integer",
59 "DefaultAccess" => "integer",
60 "Sortmode" => "integer",
61 "Viewmode" => "text",
62 "PublicFeed" => "integer",
63 "KeepRssMin" => "integer",
64 "Order" => "text"
65 );
66
67 case "8.0":
68 return array(
69 "Id" => "integer",
70 "Title" => "text",
71 "Description" => "text",
72 "PublicFiles" => "integer",
73 "Downloadable" => "integer",
74 "DefaultAccess" => "integer",
75 "Sortmode" => "integer",
76 "Viewmode" => "text",
77 "PublicFeed" => "integer",
78 "KeepRssMin" => "integer",
79 "Order" => "text",
80 "Autoplaymode" => "integer",
81 "NrInitialVideos" => "integer",
82 "NewItemsInLp" => "integer"
83 );
84 }
85 }
86 return [];
87 }
88
89 public function readData(
90 string $a_entity,
91 string $a_version,
92 array $a_ids
93 ): void {
94 $ilDB = $this->db;
95
96
97 if ($a_entity == "mcst") {
98 switch ($a_version) {
99 case "4.1.0":
100 $this->getDirectDataFromQuery("SELECT id, title, description, " .
101 " public_files, downloadable, def_access default_access" .
102 " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
103 "WHERE " .
104 $ilDB->in("id", $a_ids, false, "integer"));
105 break;
106
107 case "5.0.0":
108 $this->getDirectDataFromQuery("SELECT id, title, description, " .
109 " public_files, downloadable, def_access default_access, sortmode, viewmode" .
110 " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
111 "WHERE " .
112 $ilDB->in("id", $a_ids, false, "integer"));
113
114 // #17174 - manual order?
115 $order = array();
116 $set = $ilDB->query("SELECT * FROM il_media_cast_data_ord" .
117 " WHERE " . $ilDB->in("obj_id", $a_ids, false, "integer") .
118 " ORDER BY pos");
119 while ($row = $ilDB->fetchAssoc($set)) {
120 $order[$row["obj_id"]][] = $row["item_id"];
121 }
122
123 foreach ($this->data as $k => $v) {
124 $this->data[$k]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $v["Id"]);
125 $this->data[$k]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $v["Id"]);
126
127 // manual order?
128 if ($this->data[$k]["Sortmode"] == 4 &&
129 array_key_exists($v["Id"], $order)) {
130 $this->data[$k]["Order"] = implode(";", $order[$v["Id"]]);
131 }
132 }
133 break;
134
135 case "8.0":
136 $this->getDirectDataFromQuery("SELECT id, title, description, " .
137 " public_files, downloadable, def_access default_access, sortmode, viewmode," .
138 " autoplaymode,nr_initial_videos,new_items_in_lp" .
139 " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
140 "WHERE " .
141 $ilDB->in("id", $a_ids, false, "integer"));
142
143 // #17174 - manual order?
144 $order = array();
145 $set = $ilDB->query("SELECT * FROM il_media_cast_data_ord" .
146 " WHERE " . $ilDB->in("obj_id", $a_ids, false, "integer") .
147 " ORDER BY pos");
148 while ($row = $ilDB->fetchAssoc($set)) {
149 $order[$row["obj_id"]][] = $row["item_id"];
150 }
151
152 foreach ($this->data as $k => $v) {
153 $this->data[$k]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $v["Id"]);
154 $this->data[$k]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $v["Id"]);
155
156 // manual order?
157 if ($this->data[$k]["Sortmode"] == 4 &&
158 array_key_exists($v["Id"], $order)) {
159 $this->data[$k]["Order"] = implode(";", $order[$v["Id"]]);
160 }
161 }
162 break;
163 }
164 }
165 }
166
167 protected function getDependencies(
168 string $a_entity,
169 string $a_version,
170 ?array $a_rec = null,
171 ?array $a_ids = null
172 ): array {
173 return [];
174 }
175
176 public function importRecord(
177 string $a_entity,
178 array $a_types,
179 array $a_rec,
180 ilImportMapping $a_mapping,
181 string $a_schema_version
182 ): void {
183 $a_rec = $this->stripTags($a_rec);
184 switch ($a_entity) {
185 case "mcst":
186
187 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['Id'])) {
188 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
189 } else {
190 $newObj = new ilObjMediaCast();
191 $newObj->setType("mcst");
192 $newObj->create();
193 }
194
195 $newObj->setTitle($a_rec["Title"] ?? "");
196 $newObj->setDescription($a_rec["Description"] ?? "");
197 $newObj->setDefaultAccess((int) ($a_rec["DefaultAccess"] ?? 0));
198 $newObj->setDownloadable((bool) (int) ($a_rec["Downloadable"] ?? false));
199 $newObj->setPublicFiles((bool) (int) ($a_rec["PublicFiles"] ?? false));
200
201 $a_mapping->addMapping("components/ILIAS/ILIASObject", "obj", $a_rec["Id"], $newObj->getId());
202
203 if (in_array($a_schema_version, ["5.0.0", "8.0"])) {
204 $newObj->setOrder((int) ($a_rec["Sortmode"] ?? 0));
205 $newObj->setViewMode((string) ($a_rec["Viewmode"] ?? ""));
206
207 if ($a_rec["Order"] ?? false) {
208 $this->order[$newObj->getId()] = explode(";", $a_rec["Order"]);
209 }
210
212 "news",
213 "public_feed",
214 $a_rec["PublicFeed"],
215 0,
216 $newObj->getId()
217 );
218
220 "news",
221 "keep_rss_min",
222 $a_rec["KeepRssMin"],
223 0,
224 $newObj->getId()
225 );
226 }
227 if (in_array($a_schema_version, ["8.0"])) {
228 $newObj->setAutoplayMode((int) ($a_rec["Autoplaymode"] ?? 0));
229 $newObj->setNumberInitialVideos((int) ($a_rec["NrInitialVideos"] ?? 0));
230 $newObj->setNewItemsInLearningProgress((bool) (int) ($a_rec["NewItemsInLp"] ?? false));
231 }
232
233 $newObj->update();
234 $this->current_obj = $newObj;
235 $a_mapping->addMapping("components/ILIAS/MediaCast", "mcst", $a_rec["Id"], $newObj->getId());
236 $a_mapping->addMapping(
237 "components/ILIAS/News",
238 "news_context",
239 $a_rec["Id"] . ":mcst:0:",
240 $newObj->getId() . ":mcst:0:"
241 );
242 $a_mapping->addMapping(
243 "components/ILIAS/MetaData",
244 "md",
245 $a_rec["Id"] . ":0:mcst",
246 $newObj->getId() . ":0:mcst"
247 );
248 break;
249 }
250 }
251
252 public function getOrder(): array
253 {
254 return $this->order;
255 }
256}
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
getXmlNamespace(string $a_entity, string $a_schema_version)
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...