ILIAS  release_8 Revision v8.24
class.ilNewsService.php
Go to the documentation of this file.
1<?php
2
24{
26
27 public function __construct(
30 ilObjUser $user,
31 ilNewsObjectAdapterInterface $obj_adapter = null
32 ) {
33 if (is_null($obj_adapter)) {
34 $obj_adapter = new ilNewsObjectAdapter();
35 }
36 $this->_deps = new ilNewsServiceDependencies($lng, $settings, $user, $obj_adapter);
37 }
38
39 public function data(): ilNewsData
40 {
41 return new ilNewsData($this, $this->_deps);
42 }
43
48 {
49 $news = new ilNewsItem();
50 $news->setContext($context->getObjId(), $context->getObjType(), $context->getSubId(), $context->getSubType());
51 $news->setPriority(NEWS_NOTICE);
52 $news->setUserId($this->_deps->user()->getId());
53 return $news;
54 }
55
59 public function contextForRefId(
60 int $ref_id,
61 int $subid = 0,
62 string $subtype = ""
63 ): ilNewsContext {
64 $obj_id = $this->_deps->obj()->getObjIdForRefId($ref_id);
65 $obj_type = $this->_deps->obj()->getTypeForObjId($obj_id);
66 return new ilNewsContext($obj_id, $obj_type, $subid, $subtype);
67 }
68
69 public function isGloballyActivated(): bool
70 {
71 return (bool) $this->_deps->settings()->get("block_activated_news");
72 }
73
74}
const NEWS_NOTICE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A news item can be created by different sources.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilLanguage $lng, ilSetting $settings, ilObjUser $user, ilNewsObjectAdapterInterface $obj_adapter=null)
ilNewsServiceDependencies $_deps
contextForRefId(int $ref_id, int $subid=0, string $subtype="")
Get context object for news.
item(ilNewsContext $context)
Get a new news item for a context.
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$lng
$context
Definition: webdav.php:29