ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
112  public $objPost = null;
113 
118 
122  public $pos_author_id = 0;
123 
127  public $deleted_by = '';
128 
132  protected static $authorInformationCache = array();
133 
134 
136  private $post_user_name = null;
137 
139  private $update_user_name = null;
140 
143 
149  {
150  $this->obj_id = $row['obj_id'];
151  $this->ref_id = $row['ref_id'];
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  {
230  return $this->cron_recipients;
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 
260  public function getForumTitle()
261  {
262  return $this->forum_title;
263  }
264 
268  public function getThreadId()
269  {
270  return $this->thread_id;
271  }
272 
276  public function getThreadTitle()
277  {
278  return $this->thread_title;
279  }
280 
284  public function getPostId()
285  {
286  return $this->post_id;
287  }
288 
292  public function getPostTitle()
293  {
294  return $this->post_title;
295  }
296 
300  public function getPostMessage()
301  {
302  return $this->post_message;
303  }
304 
308  public function getPostDate()
309  {
310  return $this->post_date;
311  }
312 
316  public function getPostUpdate()
317  {
318  return $this->post_update;
319  }
320 
324  public function getPostCensored()
325  {
326  return $this->post_censored;
327  }
328 
332  public function getPostCensoredDate()
333  {
335  }
336 
340  public function getCensorshipComment()
341  {
343  }
344 
348  public function getAttachments()
349  {
350  return $this->attachments;
351  }
352 
357  {
358  $this->notification_type = $notification_type;
359  }
360 
364  public function getPosDisplayUserId()
365  {
367  }
368 
369 
373  public function getPosUserAlias()
374  {
375  return $this->pos_usr_alias;
376  }
377 
381  public function getPostUpdateUserId()
382  {
384  }
385 
390  {
391  $this->post_update_user_id = $post_update_user_id;
392  }
393 
395  {
396  $this->pos_author_id = $pos_author_id;
397  }
398  public function getPosAuthorId()
399  {
400  return $this->pos_author_id;
401  }
402 
406  public function isAnonymized()
407  {
408  return $this->is_anonymized;
409  }
410 
414  public function getDeletedBy()
415  {
416  return $this->deleted_by;
417  }
418 
422  public function getImportName()
423  {
424  return $this->import_name;
425  }
426 
430  public function getPostUserName(\ilLanguage $user_lang)
431  {
432  if ($this->post_user_name === null) {
433  $this->post_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
434  $user_lang,
435  (int) $this->getPosAuthorId(),
436  (int) $this->getPosDisplayUserId(),
437  (string) $this->getPosUserAlias(),
438  (string) $this->getImportName()
439  ));
440  }
441 
442  return $this->post_user_name;
443  }
444 
448  public function getPostUpdateUserName(\ilLanguage $user_lang)
449  {
450  if ($this->update_user_name === null) {
451  $this->update_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
452  $user_lang,
453  (int) $this->getPosAuthorId(),
454  (int) $this->getPostUpdateUserId(),
455  (string) $this->getPosUserAlias(),
456  (string) $this->getImportName()
457  ));
458  }
459 
460  // Possible Fix for #25432
461  if (
462  $this->getPosUserAlias() && $this->getPosDisplayUserId() == 0 &&
463  $this->getPosAuthorId() == $this->getPostUpdateUserId()
464  ) {
465  return (string) $this->getPosUserAlias();
466  }
467 
468  return (string) $this->update_user_name;
469  }
470 
476  {
477  $publicName = $authorinfo->getAuthorShortName();
478 
479  if ($authorinfo->hasSuffix()) {
480  $publicName = $authorinfo->getAuthorName();
481  } elseif ($authorinfo->getAuthorName() && !$this->isAnonymized()) {
482  $publicName = $authorinfo->getAuthorName();
483  }
484 
485  return $publicName;
486  }
487 
496  private function getAuthorInformation(
497  \ilLanguage $lng,
498  int $authorUsrId,
499  int $displayUserId,
500  string $usrAlias,
501  string $importName
502  ) {
503  $cacheKey = $this->notificationCache->createKeyByValues(array(
504  $lng->getLangKey(),
505  (int) $authorUsrId,
506  (int) $displayUserId,
507  (string) $usrAlias,
508  (string) $importName
509  ));
510 
511  if (false === $this->notificationCache->exists($cacheKey)) {
512  $authorInformation = new ilForumAuthorInformation(
513  $authorUsrId,
514  $displayUserId,
515  $usrAlias,
516  $importName,
517  array(),
518  $lng
519  );
520 
521  $this->notificationCache->store($cacheKey, $authorInformation);
522  }
523 
524  return $this->notificationCache->fetch($cacheKey);
525  }
526 }
getPublicUserInformation(ilForumAuthorInformation $authorinfo)
global $DIC
Definition: saml.php:7
Class ilForumCronNotificationDataProvider.
getAuthorName($without_short_name=false)
$lng
Class ilForumNotificationCache.
__construct($row, ilForumNotificationCache $notificationCache=null)
Interface ilForumNotificationMailData.
$row
This class handles all operations on files for the forum object.
language handling
getAuthorInformation(\ilLanguage $lng, int $authorUsrId, int $displayUserId, string $usrAlias, string $importName)