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