37 protected \ILIAS\MediaCast\InternalDomainService
$domain;
56 bool $a_call_by_reference =
true 60 $this->db = $DIC->database();
61 $this->
user = $DIC->user();
65 $this->
setOrder(self::ORDER_CREATION_DATE_DESC);
66 $this->mob_tracking = $DIC->mediaObjects()->internal()
69 $this->domain = $DIC->mediaCast()->internal()->domain();
75 $this->online = $a_online;
85 $this->publicfiles = $a_publicfiles;
95 $this->view_mode = $a_val;
105 $this->itemsarray = $a_itemsarray;
115 $this->autoplay_mode = $a_val;
125 $this->nr_initial_videos = $a_val;
138 $this->new_items_in_lp = $a_val;
167 foreach (array_keys($med_items) as $idx) {
168 if (array_key_exists($idx, $order)) {
169 $med_items[$idx][
"order"] = ($order[$idx] + 1) * 10;
173 $med_items[$idx][
"order"] = (++$pos) * 10;
185 $this->downloadable = $a_downloadable;
200 $this->defaultAccess = ($value === 0) ? 0 : 1;
205 $this->order = $a_value;
218 $id = parent::create();
220 $query =
"INSERT INTO il_media_cast_data (" .
229 ", nr_initial_videos" .
230 ", new_items_in_lp" .
251 if (!parent::update()) {
256 $query =
"UPDATE il_media_cast_data SET " .
257 " is_online = " .
$ilDB->quote((
int) $this->
getOnline(),
"integer") .
261 ", sortmode = " .
$ilDB->quote($this->
getOrder(),
"integer") .
266 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
280 $query =
"SELECT * FROM il_media_cast_data WHERE id = " .
283 $rec =
$ilDB->fetchAssoc($set);
285 $this->
setOnline((
bool) $rec[
"is_online"]);
289 $this->
setOrder((
int) $rec[
"sortmode"]);
297 public function delete():
bool 302 if (!parent::delete()) {
308 foreach ($med_items as $item) {
310 $news_item->delete();
316 $query =
"DELETE FROM il_media_cast_data" .
317 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
323 public function readItems(
bool $a_oldest_first =
false): array
327 $it->setContextObjId($this->
getId());
328 $it->setContextObjType($this->
getType());
329 $this->itemsarray = $it->queryNewsForContext(
false, 0,
"",
false, $a_oldest_first);
338 if (!$this->
getId()) {
342 $sql =
"DELETE FROM il_media_cast_data_ord" .
343 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
344 $ilDB->manipulate($sql);
351 if (!$this->
getId()) {
356 $sql =
"SELECT item_id FROM il_media_cast_data_ord" .
357 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer") .
361 $all[] = $row[
"item_id"];
370 if (!$this->
getId()) {
376 foreach ($a_items as $item_id) {
379 $sql =
"INSERT INTO il_media_cast_data_ord (obj_id,item_id,pos)" .
380 " VALUES (" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
381 $ilDB->quote($item_id,
"integer") .
"," .
382 $ilDB->quote($pos,
"integer") .
")";
383 $ilDB->manipulate($sql);
393 if (!array_key_exists($i, $mapping)) {
396 $items[] = $mapping[
$i];
401 public function cloneObject(
int $a_target_id,
int $a_copy_id = 0,
bool $a_omit_tree =
false): ?
ilObject 404 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
409 if (!$cp_options->isRootNode($this->getRefId())) {
416 $new_obj->setOrder($this->
getOrder());
435 $obj_settings->cloneSettings($new_obj->getId());
436 unset($obj_settings);
441 $collection = $olp->getCollectionInstance();
443 $collection->cloneCollection($new_obj->getRefId(), $cp_options->getCopyId());
454 foreach ($this->
readItems(
true) as $item) {
456 $mob_id = $item[
"mob_id"];
458 $new_mob = $mob->duplicate();
463 $mc_item->setMobId($new_mob->getId());
465 $mc_item->setContextObjId($a_new_obj->
getId());
466 $mc_item->setContextObjType($a_new_obj->
getType());
467 $mc_item->setUserId(
$ilUser->getId());
468 $mc_item->setPlaytime($item[
"playtime"] ??
"");
469 $mc_item->setTitle($item[
"title"] ??
"");
470 $mc_item->setContent($item[
"content"] ??
"");
471 $mc_item->setVisibility($item[
"visibility"] ??
"users");
473 $this->mob_mapping[$mob_id] = $new_mob->getId();
474 $item_mapping[$item[
"id"]] = $mc_item->getId();
476 return $item_mapping;
483 $this->mob_tracking->saveCompletion(
497 bool $extract =
false 502 $mob->getExternalMetadata();
507 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
511 $mc_item->setMobId($mob->getId());
513 $mc_item->setContextObjId($this->
getId());
514 $mc_item->setContextObjType($this->
getType());
515 $mc_item->setUserId($user_id);
516 $med_item = $mob->getMediaItem(
"Standard");
518 $mc_item->setTitle($mob->getTitle());
519 $mc_item->setContent($mob->getLongDescription());
523 $mc_item->setLimitation(
false);
524 $mc_item->setVisibility($this->
getDefaultAccess() == 0 ?
"users" :
"public");
527 $lp = $this->domain->learningProgress($this);
528 $lp->addItemToLP($mob_id);
530 return $mc_item->getId();
538 $hours = floor($seconds / 3600);
539 $minutes = floor(($seconds % 3600) / 60);
540 $seconds = $seconds % 60;
541 $duration = str_pad($hours, 2,
"0", STR_PAD_LEFT) .
":" .
542 str_pad($minutes, 2,
"0", STR_PAD_LEFT) .
":" .
543 str_pad($seconds, 2,
"0", STR_PAD_LEFT);
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
A news item can be created by different sources.
__construct(Container $dic, ilPlugin $plugin)
static _getInstance(int $a_copy_id)
static getInstance(int $obj_id)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)