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())) {
410 $new_obj->setOnline($this->getOnline());
413 $new_obj->setPublicFiles($this->getPublicFiles());
414 $new_obj->setDownloadable($this->getDownloadable());
415 $new_obj->setDefaultAccess($this->getDefaultAccess());
416 $new_obj->setOrder($this->getOrder());
417 $new_obj->setViewMode($this->getViewMode());
418 $new_obj->setAutoplayMode($this->getAutoplayMode());
419 $new_obj->setNumberInitialVideos($this->getNumberInitialVideos());
420 $new_obj->setNewItemsInLearningProgress($this->getNewItemsInLearningProgress());
430 $mapping = $this->copyItems($new_obj);
431 $this->copyOrder($new_obj, $mapping);
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(
496 string $long_desc =
"",
497 bool $extract =
false
503 }
catch (Exception
$e) {
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");
517 $mc_item->setPlaytime($this->getPlaytimeForSeconds($med_item->getDuration()));
518 $mc_item->setTitle($mob->getTitle());
519 $mc_item->setContent($mob->getLongDescription());
520 if ($long_desc !=
"") {
521 $mc_item->setContent($long_desc);
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 sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
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.
static _getInstance(int $a_copy_id)
A news item can be created by different sources.
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc