ILIAS  release_7 Revision v7.30-3-g800a261c036
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
32 private $closest_container = null;
33
37 protected $forum_title = '';
38
42 protected $thread_id = 0;
43
47 protected $thread_title = '';
48
52 protected $post_id = 0;
56 protected $post_title = '';
60 protected $post_message = '';
64 protected $post_date = null;
68 protected $post_update = null;
69
73 protected $post_censored = false;
77 protected $post_censored_date = null;
81 protected $post_censored_comment = '';
82
86 protected $pos_usr_alias = '';
90 protected $pos_display_user_id = 0;
91
95 protected $is_anonymized = false;
96
100 protected $import_name = '';
101
105 protected $attachments = array();
106
110 protected $cron_recipients = array();
111
116
120 public $pos_author_id = 0;
121
125 public $deleted_by = '';
126
130 protected static $authorInformationCache = array();
131
132
134 private $post_user_name = null;
135
137 private $update_user_name = null;
138
141
147 {
148 $this->obj_id = $row['obj_id'];
149 $this->ref_id = $row['ref_id'];
150
151 $this->closest_container = $row['closest_container'];
152
153 $this->thread_id = $row['thread_id'];
154 $this->thread_title = $row['thr_subject'];
155
156 $this->forum_id = $row['pos_top_fk'];
157 $this->forum_title = $row['top_name'];
158
159 $this->post_id = $row['pos_pk'];
160 $this->post_title = $row['pos_subject'];
161 $this->post_message = $row['pos_message'];
162 $this->post_date = $row['pos_date'];
163 $this->post_update = $row['pos_update'];
164 $this->post_update_user_id = $row['update_user'];
165
166 $this->post_censored = $row['pos_cens'];
167 $this->post_censored_date = $row['pos_cens_date'];
168 $this->post_censored_comment = $row['pos_cens_com'];
169
170 $this->pos_usr_alias = $row['pos_usr_alias'];
171 $this->pos_display_user_id = $row['pos_display_user_id'];
172 $this->pos_author_id = $row['pos_author_id'];
173
174 $this->import_name = strlen($row['import_name']) ? $row['import_name'] : '';
175
176 if ($notificationCache === null) {
178 }
179 $this->notificationCache = $notificationCache;
180
181 if (isset($row['deleted_by'])) {
182 //cron context
183 $this->deleted_by = $row['deleted_by'];
184 } else {
185 // fallback
186 global $DIC;
187 $this->deleted_by = $DIC->user()->getLogin();
188 }
189
190 $this->read();
191 }
192
196 protected function read()
197 {
198 $this->readAttachments();
199 }
200
204 private function readAttachments()
205 {
207 // get attachments
208 $fileDataForum = new ilFileDataForum($this->getObjId(), $this->getPostId());
209 $filesOfPost = $fileDataForum->getFilesOfPost();
210
211 foreach ($filesOfPost as $attachment) {
212 $this->attachments[] = $attachment['name'];
213 }
214 }
215 }
216
220 public function addRecipient($user_id)
221 {
222 $this->cron_recipients[] = (int) $user_id;
223 }
224
228 public function getCronRecipients()
229 {
231 }
232
236 public function getRefId()
237 {
238 return $this->ref_id;
239 }
240
244 public function getObjId()
245 {
246 return $this->obj_id;
247 }
248
252 public function getForumId()
253 {
254 return $this->forum_id;
255 }
256
257 public function closestContainer() : ?ilObject
258 {
260 }
261
262 public function providesClosestContainer() : bool
263 {
264 return $this->closest_container !== null;
265 }
266
270 public function getForumTitle()
271 {
272 return $this->forum_title;
273 }
274
278 public function getThreadId()
279 {
280 return $this->thread_id;
281 }
282
286 public function getThreadTitle()
287 {
288 return $this->thread_title;
289 }
290
294 public function getPostId()
295 {
296 return $this->post_id;
297 }
298
302 public function getPostTitle()
303 {
304 return $this->post_title;
305 }
306
310 public function getPostMessage()
311 {
312 return $this->post_message;
313 }
314
318 public function getPostDate()
319 {
320 return $this->post_date;
321 }
322
326 public function getPostUpdate()
327 {
328 return $this->post_update;
329 }
330
334 public function getPostCensored()
335 {
337 }
338
342 public function getPostCensoredDate()
343 {
345 }
346
350 public function getCensorshipComment()
351 {
353 }
354
358 public function getAttachments()
359 {
360 return $this->attachments;
361 }
362
367 {
368 $this->notification_type = $notification_type;
369 }
370
374 public function getPosDisplayUserId()
375 {
377 }
378
379
383 public function getPosUserAlias()
384 {
386 }
387
391 public function getPostUpdateUserId()
392 {
394 }
395
400 {
401 $this->post_update_user_id = $post_update_user_id;
402 }
403
405 {
406 $this->pos_author_id = $pos_author_id;
407 }
408 public function getPosAuthorId()
409 {
411 }
412
416 public function isAnonymized()
417 {
419 }
420
424 public function getDeletedBy()
425 {
426 return $this->deleted_by;
427 }
428
432 public function getImportName()
433 {
434 return $this->import_name;
435 }
436
440 public function getPostUserName(\ilLanguage $user_lang)
441 {
442 if ($this->post_user_name === null) {
443 $this->post_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
444 $user_lang,
445 (int) $this->getPosAuthorId(),
446 (int) $this->getPosDisplayUserId(),
447 (string) $this->getPosUserAlias(),
448 (string) $this->getImportName()
449 ));
450 }
451
453 }
454
458 public function getPostUpdateUserName(\ilLanguage $user_lang)
459 {
460 if ($this->update_user_name === null) {
461 $this->update_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
462 $user_lang,
463 (int) $this->getPosAuthorId(),
464 (int) $this->getPostUpdateUserId(),
465 (string) $this->getPosUserAlias(),
466 (string) $this->getImportName()
467 ));
468 }
469
470 // Fix for #25432
471 if ($this->getPosUserAlias() && $this->getPosDisplayUserId() == 0
472 && $this->getPosAuthorId() == $this->getPostUpdateUserId()) {
473 return (string) $this->getPosUserAlias();
474 }
475
476 return (string) $this->update_user_name;
477 }
478
484 {
485 $publicName = $authorinfo->getAuthorShortName();
486
487 if ($authorinfo->hasSuffix()) {
488 $publicName = $authorinfo->getAuthorName();
489 } elseif ($authorinfo->getAuthorName() && !$this->isAnonymized()) {
490 $publicName = $authorinfo->getAuthorName();
491 }
492
493 return $publicName;
494 }
495
504 private function getAuthorInformation(
506 int $authorUsrId,
507 int $displayUserId,
508 string $usrAlias,
509 string $importName
510 ) {
511 $cacheKey = $this->notificationCache->createKeyByValues(array(
512 $lng->getLangKey(),
513 (int) $authorUsrId,
514 (int) $displayUserId,
515 (string) $usrAlias,
516 (string) $importName
517 ));
518
519 if (false === $this->notificationCache->exists($cacheKey)) {
520 $authorInformation = new ilForumAuthorInformation(
521 $authorUsrId,
522 $displayUserId,
523 $usrAlias,
524 $importName,
525 array(),
526 $lng
527 );
528
529 $this->notificationCache->store($cacheKey, $authorInformation);
530 }
531
532 return $this->notificationCache->fetch($cacheKey);
533 }
534}
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
Class ilObject Basic functions for all objects.
global $DIC
Definition: goto.php:24
Interface ilForumNotificationMailData.
$lng