ILIAS  release_7 Revision v7.30-3-g800a261c036
trait.ilObjFileNews.php
Go to the documentation of this file.
1<?php
2
8{
12 protected $just_notified = false;
13
14 public function notifyCreation(int $obj_id, string $additional_message = null) : void
15 {
16 $this->addNewsNotification($obj_id, 'file_created', $additional_message);
17 $this->just_notified = true;
18 }
19
20 public function notifyUpdate(int $obj_id, string $additional_message = null) : void
21 {
22 if (!$this->just_notified) {
23 $this->addNewsNotification($obj_id, 'file_updated', $additional_message);
24 $this->just_notified = true;
25 }
26 }
27
28 protected function addNewsNotification(int $obj_id, string $a_lang_var, string $description = null) : void
29 {
30 global $DIC;
31
32 // ilHistory::_createEntry($this->getId(), "create", $this->getFileName() . ",1" . ",1");
33
34 // Add Notification to news
35 $news_item = new ilNewsItem();
36 $news_item->setContext($obj_id, 'file');
37 $news_item->setPriority(NEWS_NOTICE);
38 $news_item->setTitle($a_lang_var);
39 $news_item->setContentIsLangVar(true);
40 if ($description && $description !== '') {
41 $news_item->setContent("<p>" . $description . "</p>");
42 }
43 $news_item->setUserId($DIC->user()->getId());
44 $news_item->setVisibility(NEWS_USERS);
45 $news_item->create();
46 }
47}
An exception for terminatinating execution or to throw for unit testing.
const NEWS_USERS
const NEWS_NOTICE
global $DIC
Definition: goto.php:24
addNewsNotification(int $obj_id, string $a_lang_var, string $description=null)
trait ilObjFileNews
Trait ilObjFileNews.
notifyCreation(int $obj_id, string $additional_message=null)
notifyUpdate(int $obj_id, string $additional_message=null)