35 protected \ILIAS\Notes\Service
$notes;
36 protected \ILIAS\MediaCast\InternalDomainService
$domain;
54 bool $a_call_by_reference =
true
58 $this->db =
$DIC->database();
59 $this->
user = $DIC->user();
63 $this->
setOrder(self::ORDER_CREATION_DATE_DESC);
64 $this->mob_tracking =
$DIC->mediaObjects()->internal()
67 $this->notes =
$DIC->notes();
68 $this->domain =
$DIC->mediaCast()->internal()->domain();
74 $this->online = $a_online;
94 $this->publicfiles = $a_publicfiles;
104 $this->view_mode = $a_val;
114 $this->itemsarray = $a_itemsarray;
124 $this->nr_initial_videos = $a_val;
137 $this->new_items_in_lp = $a_val;
165 foreach (array_keys($med_items) as $idx) {
166 if (array_key_exists($idx,
$order)) {
167 $med_items[$idx][
"order"] = (
$order[$idx] + 1) * 10;
171 $med_items[$idx][
"order"] = (++$pos) * 10;
183 $this->downloadable = $a_downloadable;
198 $this->defaultAccess = ($value === 0) ? 0 : 1;
203 $this->order = $a_value;
216 $id = parent::create();
220 $query =
"INSERT INTO il_media_cast_data (" .
229 ", nr_initial_videos" .
230 ", new_items_in_lp" .
239 .
"," .
$ilDB->quote(0,
"integer")
243 $ilDB->manipulate($query);
251 if (!parent::update()) {
258 $query =
"UPDATE il_media_cast_data SET " .
259 " is_online = " .
$ilDB->quote((
int) $this->
getOnline(),
"integer") .
263 ", sortmode = " .
$ilDB->quote($this->
getOrder(),
"integer") .
265 ", autoplaymode = " .
$ilDB->quote(0,
"integer") .
268 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
270 $ilDB->manipulate($query);
272 $this->notes->domain()->activateComments($this->
getId(), $this->
getComments());
284 $query =
"SELECT * FROM il_media_cast_data WHERE id = " .
286 $set =
$ilDB->query($query);
287 $rec =
$ilDB->fetchAssoc($set);
289 $this->
setOnline((
bool) $rec[
"is_online"]);
293 $this->
setOrder((
int) $rec[
"sortmode"]);
298 $this->
setComments($this->notes->domain()->commentsActive($this->getId()));
302 public function delete():
bool
307 if (!parent::delete()) {
315 foreach ($med_items as $item) {
317 $news_item->delete();
323 $query =
"DELETE FROM il_media_cast_data" .
324 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
325 $ilDB->manipulate($query);
330 public function readItems(
bool $a_oldest_first =
false): array
334 $it->setContextObjId($this->
getId());
335 $it->setContextObjType($this->
getType());
336 $this->itemsarray = $it->queryNewsForContext(
false, 0,
"",
false, $a_oldest_first);
345 if (!$this->
getId()) {
349 $sql =
"DELETE FROM il_media_cast_data_ord" .
350 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
351 $ilDB->manipulate($sql);
358 if (!$this->
getId()) {
363 $sql =
"SELECT item_id FROM il_media_cast_data_ord" .
364 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer") .
368 $all[] = $row[
"item_id"];
377 if (!$this->
getId()) {
383 foreach ($a_items as $item_id) {
386 $sql =
"INSERT INTO il_media_cast_data_ord (obj_id,item_id,pos)" .
387 " VALUES (" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
388 $ilDB->quote($item_id,
"integer") .
"," .
389 $ilDB->quote($pos,
"integer") .
")";
390 $ilDB->manipulate($sql);
400 if (!array_key_exists($i, $mapping)) {
403 $items[] = $mapping[$i];
408 public function cloneObject(
int $a_target_id,
int $a_copy_id = 0,
bool $a_omit_tree =
false): ?
ilObject
411 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
416 if (!$cp_options->isRootNode($this->getRefId())) {
417 $new_obj->setOnline($this->getOnline());
420 $new_obj->setPublicFiles($this->getPublicFiles());
421 $new_obj->setDownloadable($this->getDownloadable());
422 $new_obj->setDefaultAccess($this->getDefaultAccess());
423 $new_obj->setOrder($this->
getOrder());
424 $new_obj->setViewMode($this->getViewMode());
425 $new_obj->setNumberInitialVideos($this->getNumberInitialVideos());
426 $new_obj->setNewItemsInLearningProgress($this->getNewItemsInLearningProgress());
436 $mapping = $this->copyItems($new_obj);
438 $this->copyOrder($new_obj, $mapping);
442 $obj_settings->cloneSettings($new_obj->getId());
443 unset($obj_settings);
448 $collection = $olp->getCollectionInstance();
450 $collection->cloneCollection($new_obj->getRefId(), $cp_options->getCopyId(), $this->mob_mapping);
453 $this->cloneMetaData($new_obj);
460 $ilUser = $this->user;
463 foreach ($this->readItems(
true) as $item) {
465 $mob_id = $item[
"mob_id"];
467 $new_mob = $mob->duplicate();
472 $mc_item->setMobId($new_mob->getId());
474 $mc_item->setContextObjId($a_new_obj->
getId());
475 $mc_item->setContextObjType($a_new_obj->
getType());
476 $mc_item->setUserId($ilUser->getId());
477 $mc_item->setPlaytime($item[
"playtime"] ??
"");
478 $mc_item->setTitle($item[
"title"] ??
"");
479 $mc_item->setContent($item[
"content"] ??
"");
480 $mc_item->setVisibility($item[
"visibility"] ??
"users");
482 $this->mob_mapping[$mob_id] = $new_mob->getId();
483 $item_mapping[$item[
"id"]] = $mc_item->getId();
485 return $item_mapping;
492 $this->mob_tracking->saveCompletion(
505 string $long_desc =
"",
506 bool $extract =
false
512 }
catch (Exception
$e) {
516 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
520 $mc_item->setMobId($mob->getId());
522 $mc_item->setContextObjId($this->
getId());
523 $mc_item->setContextObjType($this->getType());
525 $med_item = $mob->getMediaItem(
"Standard");
526 $mc_item->setPlaytime($this->getPlaytimeForSeconds($med_item->getDuration()));
527 $mc_item->setTitle($mob->getTitle());
528 $mc_item->setContent($mob->getLongDescription());
529 if ($long_desc !=
"") {
530 $mc_item->setContent($long_desc);
532 $mc_item->setLimitation(
false);
533 $mc_item->setVisibility($this->getDefaultAccess() == 0 ?
"users" :
"public");
536 $lp = $this->domain->learningProgress($this);
537 $lp->addItemToLP($mob_id);
539 return $mc_item->getId();
547 $hours = floor($seconds / 3600);
548 $minutes = floor(($seconds % 3600) / 60);
549 $seconds = $seconds % 60;
550 $duration = str_pad($hours, 2,
"0", STR_PAD_LEFT) .
":" .
551 str_pad($minutes, 2,
"0", STR_PAD_LEFT) .
":" .
552 str_pad($seconds, 2,
"0", STR_PAD_LEFT);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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)
Class ilObject Basic functions for all objects.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc