38 protected \ILIAS\Notes\Service
$notes;
39 protected \ILIAS\MediaCast\InternalDomainService
$domain;
58 bool $a_call_by_reference =
true 62 $this->db = $DIC->database();
63 $this->
user = $DIC->user();
67 $this->
setOrder(self::ORDER_CREATION_DATE_DESC);
68 $this->mob_tracking = $DIC->mediaObjects()->internal()
71 $this->notes = $DIC->notes();
72 $this->domain = $DIC->mediaCast()->internal()->domain();
78 $this->online = $a_online;
98 $this->publicfiles = $a_publicfiles;
108 $this->view_mode = $a_val;
118 $this->itemsarray = $a_itemsarray;
128 $this->autoplay_mode = $a_val;
138 $this->nr_initial_videos = $a_val;
151 $this->new_items_in_lp = $a_val;
179 foreach (array_keys($med_items) as $idx) {
180 if (array_key_exists($idx, $order)) {
181 $med_items[$idx][
"order"] = ($order[$idx] + 1) * 10;
185 $med_items[$idx][
"order"] = (++$pos) * 10;
197 $this->downloadable = $a_downloadable;
212 $this->defaultAccess = ($value === 0) ? 0 : 1;
217 $this->order = $a_value;
230 $id = parent::create();
232 $query =
"INSERT INTO il_media_cast_data (" .
241 ", nr_initial_videos" .
242 ", new_items_in_lp" .
255 $ilDB->manipulate($query);
263 if (!parent::update()) {
268 $query =
"UPDATE il_media_cast_data SET " .
269 " is_online = " .
$ilDB->quote((
int) $this->
getOnline(),
"integer") .
273 ", sortmode = " .
$ilDB->quote($this->
getOrder(),
"integer") .
278 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
280 $ilDB->manipulate($query);
282 $this->notes->domain()->activateComments($this->
getId(), $this->
getComments());
294 $query =
"SELECT * FROM il_media_cast_data WHERE id = " .
296 $set =
$ilDB->query($query);
297 $rec =
$ilDB->fetchAssoc($set);
299 $this->
setOnline((
bool) $rec[
"is_online"]);
303 $this->
setOrder((
int) $rec[
"sortmode"]);
313 public function delete():
bool 318 if (!parent::delete()) {
324 foreach ($med_items as $item) {
326 $news_item->delete();
332 $query =
"DELETE FROM il_media_cast_data" .
333 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
334 $ilDB->manipulate($query);
339 public function readItems(
bool $a_oldest_first =
false): array
343 $it->setContextObjId($this->
getId());
344 $it->setContextObjType($this->
getType());
345 $this->itemsarray = $it->queryNewsForContext(
false, 0,
"",
false, $a_oldest_first);
354 if (!$this->
getId()) {
358 $sql =
"DELETE FROM il_media_cast_data_ord" .
359 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
360 $ilDB->manipulate($sql);
367 if (!$this->
getId()) {
372 $sql =
"SELECT item_id FROM il_media_cast_data_ord" .
373 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer") .
377 $all[] = $row[
"item_id"];
386 if (!$this->
getId()) {
392 foreach ($a_items as $item_id) {
395 $sql =
"INSERT INTO il_media_cast_data_ord (obj_id,item_id,pos)" .
396 " VALUES (" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
397 $ilDB->quote($item_id,
"integer") .
"," .
398 $ilDB->quote($pos,
"integer") .
")";
399 $ilDB->manipulate($sql);
409 if (!array_key_exists($i, $mapping)) {
412 $items[] = $mapping[$i];
417 public function cloneObject(
int $a_target_id,
int $a_copy_id = 0,
bool $a_omit_tree =
false): ?
ilObject 420 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
425 if (!$cp_options->isRootNode($this->getRefId())) {
432 $new_obj->setOrder($this->
getOrder());
451 $obj_settings->cloneSettings($new_obj->getId());
452 unset($obj_settings);
457 $collection = $olp->getCollectionInstance();
459 $collection->cloneCollection($new_obj->getRefId(), $cp_options->getCopyId());
470 foreach ($this->
readItems(
true) as $item) {
472 $mob_id = $item[
"mob_id"];
474 $new_mob = $mob->duplicate();
479 $mc_item->setMobId($new_mob->getId());
481 $mc_item->setContextObjId($a_new_obj->
getId());
482 $mc_item->setContextObjType($a_new_obj->
getType());
483 $mc_item->setUserId($ilUser->getId());
484 $mc_item->setPlaytime($item[
"playtime"] ??
"");
485 $mc_item->setTitle($item[
"title"] ??
"");
486 $mc_item->setContent($item[
"content"] ??
"");
487 $mc_item->setVisibility($item[
"visibility"] ??
"users");
489 $this->mob_mapping[$mob_id] = $new_mob->getId();
490 $item_mapping[$item[
"id"]] = $mc_item->getId();
492 return $item_mapping;
499 $this->mob_tracking->saveCompletion(
513 bool $extract =
false 518 $mob->getExternalMetadata();
523 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
527 $mc_item->setMobId($mob->getId());
529 $mc_item->setContextObjId($this->
getId());
530 $mc_item->setContextObjType($this->
getType());
531 $mc_item->setUserId($user_id);
532 $med_item = $mob->getMediaItem(
"Standard");
534 $mc_item->setTitle($mob->getTitle());
535 $mc_item->setContent($mob->getLongDescription());
539 $mc_item->setLimitation(
false);
540 $mc_item->setVisibility($this->
getDefaultAccess() == 0 ?
"users" :
"public");
543 $lp = $this->domain->learningProgress($this);
544 $lp->addItemToLP($mob_id);
546 return $mc_item->getId();
554 $hours = floor($seconds / 3600);
555 $minutes = floor(($seconds % 3600) / 60);
556 $seconds = $seconds % 60;
557 $duration = str_pad($hours, 2,
"0", STR_PAD_LEFT) .
":" .
558 str_pad($minutes, 2,
"0", STR_PAD_LEFT) .
":" .
559 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.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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)