ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Notes\NotificationsManager Class Reference
+ Collaboration diagram for ILIAS\Notes\NotificationsManager:

Public Member Functions

 __construct (InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain, \ILIAS\Blog\InternalGUIService $blog_gui)
 
 sendNotifications (Note $note, bool $a_changed=false)
 Sends all comments to a list of accounts configured in the global administration. More...
 
 notifyObserver (array $observer, string $action, Note $note)
 Notify observers on update/create. More...
 

Protected Attributes

ilAccessHandler $access
 
ilSetting $settings
 
InternalDomainService $domain
 
InternalRepoService $repo
 
InternalDataService $data
 
ILIAS Blog InternalGUIService $blog_gui
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 28 of file class.NotificationsManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Notes\NotificationsManager::__construct ( InternalDataService  $data,
InternalRepoService  $repo,
InternalDomainService  $domain,
\ILIAS\Blog\InternalGUIService  $blog_gui 
)

Member Function Documentation

◆ notifyObserver()

ILIAS\Notes\NotificationsManager::notifyObserver ( array  $observer,
string  $action,
Note  $note 
)

Notify observers on update/create.

Definition at line 197 of file class.NotificationsManager.php.

201 : void {
202 foreach ($observer as $item) {
203 $context = $note->getContext();
204 $param[] = $context->getObjId();
205 $param[] = $context->getSubObjId();
206 $param[] = $context->getType();
207 $param[] = $action;
208 $param[] = $note->getId();
209 call_user_func_array($item, $param);
210 }
211 }
$param
Definition: xapitoken.php:44

References $param, ILIAS\Notes\Note\getContext(), and ILIAS\Notes\Note\getId().

+ Here is the call graph for this function:

◆ sendNotifications()

ILIAS\Notes\NotificationsManager::sendNotifications ( Note  $note,
bool  $a_changed = false 
)

Sends all comments to a list of accounts configured in the global administration.

Todo:
: get rid of object type specific code

Definition at line 56 of file class.NotificationsManager.php.

59 : void {
62
63 $obj_title = "";
64 $type_lv = "";
65
66 // no notifications for notes
67 if ($note->getType() === Note::PRIVATE) {
68 return;
69 }
70
71 $recipients = $settings->get("comments_noti_recip", '');
72 $recipients = explode(",", $recipients);
73
74 // blog: blog_id, 0, "blog"
75 // lm: lm_id, page_id, "pg" (ok)
76 // sahs: sahs_id, node_id, node_type
77 // info_screen: obj_id, 0, obj_type (ok)
78 // portfolio: port_id, page_id, "portfolio_page" (ok)
79 // wiki: wiki_id, wiki_page_id, "wpg" (ok)
80
81 $context = $note->getContext();
82 $rep_obj_id = $context->getObjId();
83 $sub_obj_id = $context->getSubObjId();
84 $obj_type = $context->getType();
85
86 // resolve repository references for object-specific notifications
87 $ref_ids = array();
88 $wsp_id = 0;
89 if (
90 ($obj_type === "blp" && $context->getInRepository())
91 || ($sub_obj_id === 0 && $obj_type !== "blp")
92 || in_array($obj_type, array("pg", "wpg"), true)
93 ) {
94 $obj_title = \ilObject::_lookupTitle($rep_obj_id);
95 $type_lv = "obj_" . $obj_type;
96 $ref_ids = \ilObject::_getAllReferences($rep_obj_id);
97 }
98 if ($obj_type === "blp" && !$context->getInRepository()) {
99 $wsp_id = (new \ilWorkspaceTree(0))->lookupNodeId($rep_obj_id);
100 }
101 $wsp_tree = $wsp_id > 0 ? new \ilWorkspaceTree(0) : null;
102 $wsp_access = $wsp_tree === null ? null : new \ilWorkspaceAccessHandler($wsp_tree);
103
104 if ($obj_type === "wpg") {
105 $type_lv = "obj_wiki";
106 }
107 if ($obj_type === "pg") {
108 $type_lv = "obj_lm";
109 }
110 if ($obj_type === "blp") {
111 $obj_title = \ilObject::_lookupTitle($rep_obj_id);
112 $type_lv = "obj_blog";
113 }
114 if ($obj_type === "pfpg") {
115 $obj_title = \ilObject::_lookupTitle($rep_obj_id);
116 $type_lv = "portfolio";
117 }
118 if ($obj_type === "dcl") {
119 $obj_title = \ilObject::_lookupTitle($rep_obj_id);
120 $type_lv = "obj_dcl";
121 }
122
123 foreach ($recipients as $r) {
124 $login = trim($r);
125 if (($user_id = \ilObjUser::_lookupId($login)) > 0) {
126 $link = "";
127 if ($wsp_id > 0 && $wsp_tree !== null && $wsp_access !== null) {
128 if ($wsp_access->checkAccessOfUser($wsp_tree, $user_id, "read", "", $wsp_id)) {
129 $link = $this->blog_gui
130 ->permanentLink(0, $wsp_id)
131 ->getPermanentLink($sub_obj_id);
132 }
133 }
134 foreach ($ref_ids as $ref_id) {
135 if ($access->checkAccessOfUser($user_id, "read", "", $ref_id)) {
136 if ($sub_obj_id === 0 && $obj_type !== "blog") {
137 $link = \ilLink::_getLink($ref_id);
138 } elseif ($obj_type === "wpg") {
139 $title = \ilWikiPage::lookupTitle($sub_obj_id);
141 $ref_id,
142 "wiki",
143 true,
144 "_" . \ilWikiUtil::makeUrlTitle($title)
145 );
146 } elseif ($obj_type === "pg") {
147 $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=pg_" . $sub_obj_id . "_" . $ref_id;
148 } elseif ($obj_type === "blp") {
149 $link = $this->blog_gui
150 ->permanentLink($ref_id)
151 ->getPermanentLink($sub_obj_id);
152 }
153 }
154 }
155 if ($obj_type === "pfpg") {
156 $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=prtf_" . $rep_obj_id;
157 }
158
159 // use language of recipient to compose message
161 $ulng->loadLanguageModule('note');
162
163 if ($a_changed) {
164 $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
165 } else {
166 $subject = sprintf($ulng->txt('note_comment_notification_subject'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
167 }
168 $message = sprintf($ulng->txt('note_comment_notification_salutation'), \ilObjUser::_lookupFullname($user_id)) . "\n\n";
169
170 $message .= sprintf($ulng->txt('note_comment_notification_user_has_written'), \ilUserUtil::getNamePresentation($note->getAuthor())) . "\n\n";
171
172 $message .= $note->getText() . "\n\n";
173
174 if ($link !== "") {
175 $message .= $ulng->txt('note_comment_notification_link') . ": " . $link . "\n\n";
176 }
177
178 $message .= $ulng->txt('note_comment_notification_reason') . "\n\n";
179
180 $mail_obj = new \ilMail(ANONYMOUS_USER_ID);
181 $mail_obj->appendInstallationSignature(true);
182 $mail_obj->enqueue(
184 "",
185 "",
186 $subject,
187 $message,
189 );
190 }
191 }
192 }
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
static _lookupFullname(int $a_user_id)
static _lookupId(string|array $a_user_str)
static _lookupLogin(int $a_user_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
get(string $a_keyword, ?string $a_default_value=null)
get setting
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static lookupTitle(int $a_page_id, string $lang="-")
static makeUrlTitle(string $a_par)
const CLIENT_ID
Definition: constants.php:41
const ANONYMOUS_USER_ID
Definition: constants.php:27
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)

Field Documentation

◆ $access

ilAccessHandler ILIAS\Notes\NotificationsManager::$access
protected

Definition at line 30 of file class.NotificationsManager.php.

◆ $blog_gui

ILIAS Blog InternalGUIService ILIAS\Notes\NotificationsManager::$blog_gui
protected

◆ $data

InternalDataService ILIAS\Notes\NotificationsManager::$data
protected

◆ $domain

InternalDomainService ILIAS\Notes\NotificationsManager::$domain
protected

◆ $repo

InternalRepoService ILIAS\Notes\NotificationsManager::$repo
protected

◆ $settings

ilSetting ILIAS\Notes\NotificationsManager::$settings
protected

Definition at line 31 of file class.NotificationsManager.php.


The documentation for this class was generated from the following file: