ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_once './Modules/Forum/interfaces/interface.ilForumNotificationMailData.php';
5 include_once './Modules/Forum/classes/class.ilForumProperties.php';
6 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
7 
14 {
18  public $notification_type = NULL;
19 
23  protected $ref_id = 0;
24 
28  protected $obj_id = 0;
29 
33  protected $post_user_name = null;
34 
38  protected $update_user_name = null;
39 
43  protected $forum_id = 0;
44 
48  protected $forum_title = '';
49 
53  protected $thread_id = 0;
54 
58  protected $thread_title = '';
59 
63  protected $post_id = 0;
67  protected $post_title = '';
71  protected $post_message = '';
75  protected $post_date = NULL;
79  protected $post_update = NULL;
80 
84  protected $post_censored = false;
88  protected $post_censored_date = NULL;
92  protected $post_censored_comment = '';
93 
97  protected $pos_usr_alias = '';
101  protected $pos_display_user_id = 0;
102 
106  protected $is_anonymized = false;
107 
111  protected $import_name = '';
112 
116  protected $attachments = array();
117 
121  protected $cron_recipients = array();
122 
126  public $objPost = NULL;
127 
132 
136  public $pos_author_id = 0;
137 
141  protected static $authorInformationCache = array();
142 
146  public function __construct($row)
147  {
148  $this->obj_id = $row['obj_id'];
149  $this->ref_id = $row['ref_id'];
150 
151  $this->thread_id = $row['thread_id'];
152  $this->thread_title = $row['thr_subject'];
153 
154  $this->forum_id = $row['pos_top_fk'];
155  $this->forum_title = $row['top_name'];
156 
157  $this->post_id = $row['pos_pk'];
158  $this->post_title = $row['pos_subject'];
159  $this->post_message = $row['pos_message'];
160  $this->post_date = $row['pos_date'];
161  $this->post_update = $row['pos_update'];
162  $this->post_update_user_id = $row['update_user'];
163 
164  $this->post_censored = $row['pos_cens'];
165  $this->post_censored_date = $row['pos_cens_date'];
166  $this->post_censored_comment = $row['pos_cens_com'];
167 
168  $this->pos_usr_alias = $row['pos_usr_alias'];
169  $this->pos_display_user_id = $row['pos_display_user_id'];
170  $this->pos_author_id = $row['pos_author_id'];
171 
172  $this->import_name = strlen($row['import_name']) ? $row['import_name'] : '';
173 
174  $this->read();
175  }
176 
180  protected function read()
181  {
182  $this->readAttachments();
183  }
184 
188  private function readAttachments()
189  {
190  if(ilForumProperties::isSendAttachmentsByMailEnabled())
191  {
192  // get attachments
193  include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
194  $fileDataForum = new ilFileDataForum($this->getObjId(), $this->getPostId());
195  $filesOfPost = $fileDataForum->getFilesOfPost();
196 
197  foreach($filesOfPost as $attachment)
198  {
199  $this->attachments[] = $attachment['name'];
200  }
201  }
202  }
203 
207  public function addRecipient($user_id)
208  {
209  $this->cron_recipients[] = (int)$user_id;
210  }
211 
215  public function getCronRecipients()
216  {
217  return $this->cron_recipients;
218  }
219 
223  public function getRefId()
224  {
225  return $this->ref_id;
226  }
227 
231  public function getObjId()
232  {
233  return $this->obj_id;
234  }
235 
239  public function getForumId()
240  {
241  return $this->forum_id;
242  }
243 
247  public function getForumTitle()
248  {
249  return $this->forum_title;
250  }
251 
255  public function getThreadId()
256  {
257  return $this->thread_id;
258  }
259 
263  public function getThreadTitle()
264  {
265  return $this->thread_title;
266  }
267 
271  public function getPostId()
272  {
273  return $this->post_id;
274  }
275 
279  public function getPostTitle()
280  {
281  return $this->post_title;
282  }
283 
287  public function getPostMessage()
288  {
289  return $this->post_message;
290  }
291 
295  public function getPostDate()
296  {
297  return $this->post_date;
298  }
299 
303  public function getPostUpdate()
304  {
305  return $this->post_update;
306  }
307 
311  public function getPostCensored()
312  {
313  return $this->post_censored;
314  }
315 
319  public function getPostCensoredDate()
320  {
322  }
323 
327  public function getCensorshipComment()
328  {
330  }
331 
335  public function getAttachments()
336  {
337  return $this->attachments;
338  }
339 
344  {
345  $this->notification_type = $notification_type;
346  }
347 
351  public function getPosDisplayUserId()
352  {
354  }
355 
356 
360  public function getPosUserAlias()
361  {
362  return $this->pos_usr_alias;
363  }
364 
368  public function getPostUpdateUserId()
369  {
371  }
372 
377  {
378  $this->post_update_user_id = $post_update_user_id;
379  }
380 
382  {
383  $this->pos_author_id = $pos_author_id;
384  }
385  public function getPosAuthorId()
386  {
387  return $this->pos_author_id;
388  }
389 
393  public function isAnonymized()
394  {
395  return $this->is_anonymized;
396  }
397 
401  public function getImportName()
402  {
403  return $this->import_name;
404  }
405 
414  private function getAuthorInformation(\ilLanguage $lng, $authorUsrId, $displayUserId, $usrAlias, $importName)
415  {
416  $cacheKey = md5(implode('|', array(
417  $lng->getLangKey(),
418  (int)$authorUsrId,
419  (int)$displayUserId,
420  (string)$usrAlias,
421  (string)$importName
422  )));
423 
424  if (!array_key_exists($cacheKey, self::$authorInformationCache)) {
425  $authorInformation = new ilForumAuthorInformation(
426  $authorUsrId,
427  $displayUserId,
428  $usrAlias,
429  $importName,
430  array(),
431  $lng
432  );
433 
434  self::$authorInformationCache[$cacheKey] = $authorInformation;
435  }
436 
437  return self::$authorInformationCache[$cacheKey];
438  }
439 
443  public function getPostUserName(\ilLanguage $user_lang)
444  {
445  if (null === $this->post_user_name) {
446  $this->post_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
447  $user_lang,
448  $this->getPosAuthorId(),
449  $this->getPosDisplayUserId(),
450  $this->getPosUserAlias(),
451  $this->getImportName()
452  ));
453  }
454 
455  return (string)$this->post_user_name;
456  }
457 
461  public function getPostUpdateUserName(\ilLanguage $user_lang)
462  {
463  if ($this->update_user_name === null) {
464  $this->update_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
465  $user_lang,
466  $this->getPosAuthorId(),
467  $this->getPostUpdateUserId(),
468  $this->getPosUserAlias(),
469  $this->getImportName()
470  ));
471  }
472 
473  return (string)$this->update_user_name;
474  }
475 
481  {
482  if($authorinfo->hasSuffix())
483  {
484  $public_name = $authorinfo->getAuthorName();
485  }
486  else
487  {
488  $public_name = $authorinfo->getAuthorShortName();
489 
490  if($authorinfo->getAuthorName() && !$this->isAnonymized())
491  {
492  $public_name = $authorinfo->getAuthorName();
493  }
494  }
495 
496  return $public_name;
497  }
498 }
getPublicUserInformation(ilForumAuthorInformation $authorinfo)
Add rich text string
The name of the decorator.
getAuthorName($without_short_name=false)
getAuthorInformation(\ilLanguage $lng, $authorUsrId, $displayUserId, $usrAlias, $importName)
Create styles array
The data for the language used.
Interface ilForumNotificationMailData.
global $lng
Definition: privfeed.php:17
This class handles all operations on files for the forum object.
language handling