52 : void {
54
55 if ($a_wiki_ref_id === 0) {
56 return;
57 }
58
61 }
62
64 $log->
debug(
"start... vvvvvvvvvvvvvvvvvvvvvvvvvvv");
65
66 $ilUser = $this->domain->user();
67 $ilAccess = $this->domain->access();
68
69 $wiki = $this->domain->wiki()->object($a_wiki_ref_id);
70 $wiki_id = $wiki->getId();
73 $pgui = $this->gui->page()->getWikiPageGUI(
74 $a_wiki_ref_id,
75 $a_page_id,
76 0,
78 );
79 $page = $pgui->getPageObject();
80
81
82 $ignore_threshold = ($a_action === "comment");
83
84
85 if ($a_action === "new") {
86 return;
87 }
88
93 $users = array_merge($users, $wiki_users);
94 if (!count($users)) {
95 $log->
debug(
"no notifications... ^^^^^^^^^^^^^^^^^^");
96 return;
97 }
99 } else {
101 if (!count($users)) {
102 $log->
debug(
"no notifications... ^^^^^^^^^^^^^^^^^^");
103 return;
104 }
105 }
106
108
109
110 if ($a_page_id) {
111
112 $link = \ilLink::_getLink(null, "wiki", [], "wpage_" . $a_page_id . "_" . $a_wiki_ref_id);
113 } else {
114 $link = \ilLink::_getLink($a_wiki_ref_id);
115 }
116
118 $pgui->setRawPageContent(true);
119 $pgui->setAbstractOnly(true);
120 $pgui->setFileDownloadLink(".");
121 $pgui->setFullscreenLink(".");
122 $pgui->setSourcecodeDownloadScript(".");
123 $snippet = $pgui->showPage();
125
126
127 $snippet = str_replace(['<br/>', '<br />', '</p>', '</div>'], "\n", $snippet);
128
129 $snippet = trim(strip_tags($snippet));
130
131
132 $hist = $page->getHistoryEntries();
133 $current_version = array_shift($hist);
134 $current_version = $current_version["nr"] ?? 0;
135 if (!$current_version && $a_action !== "comment") {
137 $a_action = "new";
138 }
139
141 $mails = [];
142 foreach (array_unique($users) as $idx =>
$user_id) {
143 if (
$user_id !== $ilUser->getId() &&
144 $ilAccess->checkAccessOfUser(
$user_id,
'read',
'', $a_wiki_ref_id)) {
145
147 $ulng->loadLanguageModule('wiki');
148
149 if ($a_action === "comment") {
150 $subject = sprintf($ulng->txt('wiki_notification_comment_subject'), $wiki->getTitle(), $page->getTitle());
152
153 $message .= $ulng->txt(
'wiki_notification_' . $a_action) .
":\n\n";
154 $message .= $ulng->txt(
'wiki') .
": " . $wiki->getTitle() .
"\n";
155 $message .= $ulng->txt(
'page') .
": " . $page->getTitle() .
"\n";
157
158
159 if ($a_comment) {
160 $message .=
"\n" . $ulng->txt(
'comment') .
":\n\"" . trim($a_comment) .
"\"\n";
161 }
162
163 $message .=
"\n" . $ulng->txt(
'wiki_change_notification_page_link') .
": " . $link;
164 } else {
165 $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
167
169
170 $message .= $ulng->txt(
'wiki_change_notification_page_body_' . $a_action) .
":\n\n";
171 $message .= $ulng->txt(
'wiki') .
": " . $wiki->getTitle() .
"\n";
172 $message .= $ulng->txt(
'page') .
": " . $page->getTitle() .
"\n";
174
175 if ($snippet) {
176 $message .=
"\n" . $ulng->txt(
'content') .
"\n" .
177 "----------------------------------------\n" .
178 $snippet . "\n" .
179 "----------------------------------------\n";
180 }
181
182
183 if ($a_comment) {
184 $message .=
"\n" . $ulng->txt(
'comment') .
":\n\"" . trim($a_comment) .
"\"\n";
185 }
186
187 $message .=
"\n" . $ulng->txt(
'wiki_change_notification_page_link') .
": " . $link;
188 } else {
189
190 $message .= $ulng->txt(
'wiki_change_notification_body_' . $a_action) .
":\n\n";
191 $message .= $ulng->txt(
'wiki') .
": " . $wiki->getTitle() .
"\n";
192 $message .= $ulng->txt(
'page') .
": " . $page->getTitle() .
"\n";
194
195 if ($snippet) {
196 $message .= $ulng->txt(
'content') .
"\n" .
197 "----------------------------------------\n" .
198 $snippet . "\n" .
199 "----------------------------------------\n\n";
200 }
201
202 $message .= $ulng->txt(
'wiki_change_notification_link') .
": " . $link;
203 }
204 }
205
207 $mail_obj->appendInstallationSignature(true);
208 $log->
debug(
"before enqueue ($user_id)");
209
210
211
212
213
214
215
216
217
219 $mails[] = new \ilMailValueObject(
220 '',
222 '',
223 '',
224 $subject,
226 [],
227 false,
228 false
229 );
231 } else {
232 unset($users[$idx]);
233 }
234 }
235 if (count($mails) > 0) {
236 $processor = new \ilMassMailTaskProcessor();
237 $processor->run(
238 $mails,
240 "",
241 []
242 );
243 }
244 $log->
debug(
"end... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
245 }
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
debug(string $message, array $context=[])
static _getInstallationSignature()
static updateNotificationTime(int $type, int $id, array $user_ids, ?int $page_id=null, bool $activate_new_entries=true)
Update the last mail timestamp for given object and users.
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object.
static _lookupFullname(int $a_user_id)
static _lookupLogin(int $a_user_id)
static truncateHTML(string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
Truncate (html) string.
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: