ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
trait.ilObjFileNews.php
Go to the documentation of this file.
1<?php
2
24{
25 protected bool $just_notified = false;
26 protected bool $notify = false;
27
28 public function notifyCreation(int $obj_id, ?string $additional_message = null): void
29 {
30 $this->addNewsNotification($obj_id, 'file_created', $additional_message);
31 $this->just_notified = true;
32 }
33
34 public function enableNotification(): void
35 {
36 $this->notify = true;
37 }
38
39 public function notifyUpdate(
40 int $obj_id,
41 ?string $additional_message = null
42 ): void {
43 if (!$this->notify) {
44 return;
45 }
46 if (!$this->just_notified) {
47 $this->addNewsNotification($obj_id, 'file_updated', $additional_message);
48 $this->just_notified = true;
49 }
50 }
51
52 protected function addNewsNotification(int $obj_id, string $a_lang_var, ?string $description = null): void
53 {
54 global $DIC;
55
56 // ilHistory::_createEntry($this->getId(), "create", $this->getFileName() . ",1" . ",1");
57
58 // Add Notification to news
59 $news_item = new ilNewsItem();
60 $news_item->setContext($obj_id, 'file');
61 $news_item->setPriority(NEWS_NOTICE);
62 $news_item->setTitle($a_lang_var);
63 $news_item->setContentIsLangVar(true);
64 if ($description && $description !== '') {
65 $news_item->setContent("<p>" . $description . "</p>");
66 }
67 $news_item->setUserId($DIC->user()->getId());
68 $news_item->setVisibility(NEWS_USERS);
69 $news_item->create();
70 }
71}
const NEWS_USERS
const NEWS_NOTICE
A news item can be created by different sources.
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
bool $notify
addNewsNotification(int $obj_id, string $a_lang_var, ?string $description=null)
trait ilObjFileNews
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
enableNotification()
notifyCreation(int $obj_id, ?string $additional_message=null)
notifyUpdate(int $obj_id, ?string $additional_message=null)