ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilForumCronNotificationDataProvider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
10{
14 public $notification_type = null;
15
19 protected $ref_id = 0;
20
24 protected $obj_id = 0;
25
29 protected $forum_id = 0;
30
34 protected $forum_title = '';
35
39 protected $thread_id = 0;
40
44 protected $thread_title = '';
45
49 protected $post_id = 0;
53 protected $post_title = '';
57 protected $post_message = '';
61 protected $post_date = null;
65 protected $post_update = null;
66
70 protected $post_censored = false;
74 protected $post_censored_date = null;
78 protected $post_censored_comment = '';
79
83 protected $pos_usr_alias = '';
87 protected $pos_display_user_id = 0;
88
92 protected $is_anonymized = false;
93
97 protected $import_name = '';
98
102 protected $attachments = array();
103
107 protected $cron_recipients = array();
108
113
117 public $pos_author_id = 0;
118
122 public $deleted_by = '';
123
127 protected static $authorInformationCache = array();
128
129
131 private $post_user_name = null;
132
134 private $update_user_name = null;
135
138
144 {
145 $this->obj_id = $row['obj_id'];
146 $this->ref_id = $row['ref_id'];
147
148 $this->thread_id = $row['thread_id'];
149 $this->thread_title = $row['thr_subject'];
150
151 $this->forum_id = $row['pos_top_fk'];
152 $this->forum_title = $row['top_name'];
153
154 $this->post_id = $row['pos_pk'];
155 $this->post_title = $row['pos_subject'];
156 $this->post_message = $row['pos_message'];
157 $this->post_date = $row['pos_date'];
158 $this->post_update = $row['pos_update'];
159 $this->post_update_user_id = $row['update_user'];
160
161 $this->post_censored = $row['pos_cens'];
162 $this->post_censored_date = $row['pos_cens_date'];
163 $this->post_censored_comment = $row['pos_cens_com'];
164
165 $this->pos_usr_alias = $row['pos_usr_alias'];
166 $this->pos_display_user_id = $row['pos_display_user_id'];
167 $this->pos_author_id = $row['pos_author_id'];
168
169 $this->import_name = strlen($row['import_name']) ? $row['import_name'] : '';
170
171 if ($notificationCache === null) {
173 }
174 $this->notificationCache = $notificationCache;
175
176 if (isset($row['deleted_by'])) {
177 //cron context
178 $this->deleted_by = $row['deleted_by'];
179 } else {
180 // fallback
181 global $DIC;
182 $this->deleted_by = $DIC->user()->getLogin();
183 }
184
185 $this->read();
186 }
187
191 protected function read()
192 {
193 $this->readAttachments();
194 }
195
199 private function readAttachments()
200 {
202 // get attachments
203 $fileDataForum = new ilFileDataForum($this->getObjId(), $this->getPostId());
204 $filesOfPost = $fileDataForum->getFilesOfPost();
205
206 foreach ($filesOfPost as $attachment) {
207 $this->attachments[] = $attachment['name'];
208 }
209 }
210 }
211
215 public function addRecipient($user_id)
216 {
217 $this->cron_recipients[] = (int) $user_id;
218 }
219
223 public function getCronRecipients()
224 {
226 }
227
231 public function getRefId()
232 {
233 return $this->ref_id;
234 }
235
239 public function getObjId()
240 {
241 return $this->obj_id;
242 }
243
247 public function getForumId()
248 {
249 return $this->forum_id;
250 }
251
255 public function getForumTitle()
256 {
257 return $this->forum_title;
258 }
259
263 public function getThreadId()
264 {
265 return $this->thread_id;
266 }
267
271 public function getThreadTitle()
272 {
273 return $this->thread_title;
274 }
275
279 public function getPostId()
280 {
281 return $this->post_id;
282 }
283
287 public function getPostTitle()
288 {
289 return $this->post_title;
290 }
291
295 public function getPostMessage()
296 {
297 return $this->post_message;
298 }
299
303 public function getPostDate()
304 {
305 return $this->post_date;
306 }
307
311 public function getPostUpdate()
312 {
313 return $this->post_update;
314 }
315
319 public function getPostCensored()
320 {
322 }
323
327 public function getPostCensoredDate()
328 {
330 }
331
335 public function getCensorshipComment()
336 {
338 }
339
343 public function getAttachments()
344 {
345 return $this->attachments;
346 }
347
352 {
353 $this->notification_type = $notification_type;
354 }
355
359 public function getPosDisplayUserId()
360 {
362 }
363
364
368 public function getPosUserAlias()
369 {
371 }
372
376 public function getPostUpdateUserId()
377 {
379 }
380
385 {
386 $this->post_update_user_id = $post_update_user_id;
387 }
388
390 {
391 $this->pos_author_id = $pos_author_id;
392 }
393 public function getPosAuthorId()
394 {
396 }
397
401 public function isAnonymized()
402 {
404 }
405
409 public function getDeletedBy()
410 {
411 return $this->deleted_by;
412 }
413
417 public function getImportName()
418 {
419 return $this->import_name;
420 }
421
425 public function getPostUserName(\ilLanguage $user_lang)
426 {
427 if ($this->post_user_name === null) {
428 $this->post_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
429 $user_lang,
430 (int) $this->getPosAuthorId(),
431 (int) $this->getPosDisplayUserId(),
432 (string) $this->getPosUserAlias(),
433 (string) $this->getImportName()
434 ));
435 }
436
438 }
439
443 public function getPostUpdateUserName(\ilLanguage $user_lang)
444 {
445 if ($this->update_user_name === null) {
446 $this->update_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
447 $user_lang,
448 (int) $this->getPosAuthorId(),
449 (int) $this->getPostUpdateUserId(),
450 (string) $this->getPosUserAlias(),
451 (string) $this->getImportName()
452 ));
453 }
454
455 // Fix for #25432
456 if ($this->getPosUserAlias() && $this->getPosDisplayUserId() == 0
457 && $this->getPosAuthorId() == $this->getPostUpdateUserId()) {
458 return (string) $this->getPosUserAlias();
459 }
460
461 return (string) $this->update_user_name;
462 }
463
469 {
470 $publicName = $authorinfo->getAuthorShortName();
471
472 if ($authorinfo->hasSuffix()) {
473 $publicName = $authorinfo->getAuthorName();
474 } elseif ($authorinfo->getAuthorName() && !$this->isAnonymized()) {
475 $publicName = $authorinfo->getAuthorName();
476 }
477
478 return $publicName;
479 }
480
489 private function getAuthorInformation(
491 int $authorUsrId,
492 int $displayUserId,
493 string $usrAlias,
494 string $importName
495 ) {
496 $cacheKey = $this->notificationCache->createKeyByValues(array(
497 $lng->getLangKey(),
498 (int) $authorUsrId,
499 (int) $displayUserId,
500 (string) $usrAlias,
501 (string) $importName
502 ));
503
504 if (false === $this->notificationCache->exists($cacheKey)) {
505 $authorInformation = new ilForumAuthorInformation(
506 $authorUsrId,
507 $displayUserId,
508 $usrAlias,
509 $importName,
510 array(),
511 $lng
512 );
513
514 $this->notificationCache->store($cacheKey, $authorInformation);
515 }
516
517 return $this->notificationCache->fetch($cacheKey);
518 }
519}
An exception for terminatinating execution or to throw for unit testing.
This class handles all operations on files for the forum object.
getAuthorName($without_short_name=false)
__construct($row, ilForumNotificationCache $notificationCache=null)
getPublicUserInformation(ilForumAuthorInformation $authorinfo)
getAuthorInformation(\ilLanguage $lng, int $authorUsrId, int $displayUserId, string $usrAlias, string $importName)
Class ilForumNotificationCache.
language handling
Interface ilForumNotificationMailData.
$lng
$DIC
Definition: xapitoken.php:46