ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once './Modules/Forum/interfaces/interface.ilForumNotificationMailData.php';
5include_once './Modules/Forum/classes/class.ilForumProperties.php';
6require_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 public $deleted_by = '';
142
146 protected static $authorInformationCache = array();
147
151 public function __construct($row)
152 {
153 $this->obj_id = $row['obj_id'];
154 $this->ref_id = $row['ref_id'];
155
156 $this->thread_id = $row['thread_id'];
157 $this->thread_title = $row['thr_subject'];
158
159 $this->forum_id = $row['pos_top_fk'];
160 $this->forum_title = $row['top_name'];
161
162 $this->post_id = $row['pos_pk'];
163 $this->post_title = $row['pos_subject'];
164 $this->post_message = $row['pos_message'];
165 $this->post_date = $row['pos_date'];
166 $this->post_update = $row['pos_update'];
167 $this->post_update_user_id = $row['update_user'];
168
169 $this->post_censored = $row['pos_cens'];
170 $this->post_censored_date = $row['pos_cens_date'];
171 $this->post_censored_comment = $row['pos_cens_com'];
172
173 $this->pos_usr_alias = $row['pos_usr_alias'];
174 $this->pos_display_user_id = $row['pos_display_user_id'];
175 $this->pos_author_id = $row['pos_author_id'];
176
177 $this->import_name = strlen($row['import_name']) ? $row['import_name'] : '';
178
179 if (isset($row['deleted_by'])) {
180 //cron context
181 $this->deleted_by = $row['deleted_by'];
182 } else {
183 // fallback
184 global $DIC;
185 $this->deleted_by = $DIC->user()->getLogin();
186 }
187
188 $this->read();
189 }
190
194 protected function read()
195 {
196 $this->readAttachments();
197 }
198
202 private function readAttachments()
203 {
205 // get attachments
206 include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
207 $fileDataForum = new ilFileDataForum($this->getObjId(), $this->getPostId());
208 $filesOfPost = $fileDataForum->getFilesOfPost();
209
210 foreach ($filesOfPost as $attachment) {
211 $this->attachments[] = $attachment['name'];
212 }
213 }
214 }
215
219 public function addRecipient($user_id)
220 {
221 $this->cron_recipients[] = (int) $user_id;
222 }
223
227 public function getCronRecipients()
228 {
230 }
231
235 public function getRefId()
236 {
237 return $this->ref_id;
238 }
239
243 public function getObjId()
244 {
245 return $this->obj_id;
246 }
247
251 public function getForumId()
252 {
253 return $this->forum_id;
254 }
255
259 public function getForumTitle()
260 {
261 return $this->forum_title;
262 }
263
267 public function getThreadId()
268 {
269 return $this->thread_id;
270 }
271
275 public function getThreadTitle()
276 {
277 return $this->thread_title;
278 }
279
283 public function getPostId()
284 {
285 return $this->post_id;
286 }
287
291 public function getPostTitle()
292 {
293 return $this->post_title;
294 }
295
299 public function getPostMessage()
300 {
301 return $this->post_message;
302 }
303
307 public function getPostDate()
308 {
309 return $this->post_date;
310 }
311
315 public function getPostUpdate()
316 {
317 return $this->post_update;
318 }
319
323 public function getPostCensored()
324 {
326 }
327
331 public function getPostCensoredDate()
332 {
334 }
335
339 public function getCensorshipComment()
340 {
342 }
343
347 public function getAttachments()
348 {
349 return $this->attachments;
350 }
351
356 {
357 $this->notification_type = $notification_type;
358 }
359
363 public function getPosDisplayUserId()
364 {
366 }
367
368
372 public function getPosUserAlias()
373 {
375 }
376
380 public function getPostUpdateUserId()
381 {
383 }
384
389 {
390 $this->post_update_user_id = $post_update_user_id;
391 }
392
394 {
395 $this->pos_author_id = $pos_author_id;
396 }
397 public function getPosAuthorId()
398 {
400 }
401
405 public function isAnonymized()
406 {
408 }
409
413 public function getDeletedBy()
414 {
415 return $this->deleted_by;
416 }
417
421 public function setDeletedBy($deleted_by)
422 {
423 $this->deleted_by = $deleted_by;
424 }
425
429 public function getImportName()
430 {
431 return $this->import_name;
432 }
433
442 private function getAuthorInformation(\ilLanguage $lng, $authorUsrId, $displayUserId, $usrAlias, $importName)
443 {
444 $cacheKey = md5(implode('|', array(
445 $lng->getLangKey(),
446 (int) $authorUsrId,
447 (int) $displayUserId,
448 (string) $usrAlias,
449 (string) $importName
450 )));
451
452 if (!array_key_exists($cacheKey, self::$authorInformationCache)) {
453 $authorInformation = new ilForumAuthorInformation(
454 $authorUsrId,
455 $displayUserId,
456 $usrAlias,
457 $importName,
458 array(),
459 $lng
460 );
461
462 self::$authorInformationCache[$cacheKey] = $authorInformation;
463 }
464
465 return self::$authorInformationCache[$cacheKey];
466 }
467
471 public function getPostUserName(\ilLanguage $user_lang)
472 {
473 if (null === $this->post_user_name) {
474 $this->post_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
475 $user_lang,
476 $this->getPosAuthorId(),
477 $this->getPosDisplayUserId(),
478 $this->getPosUserAlias(),
479 $this->getImportName()
480 ));
481 }
482
483 return (string) $this->post_user_name;
484 }
485
489 public function getPostUpdateUserName(\ilLanguage $user_lang)
490 {
491 if ($this->update_user_name === null) {
492 $this->update_user_name = $this->getPublicUserInformation(self::getAuthorInformation(
493 $user_lang,
494 $this->getPosAuthorId(),
495 $this->getPostUpdateUserId(),
496 $this->getPosUserAlias(),
497 $this->getImportName()
498 ));
499
500 // Possible Fix for #25432
501 if (
502 $this->getPosUserAlias() && $this->getPosDisplayUserId() == 0 &&
503 $this->getPosAuthorId() == $this->getPostUpdateUserId()
504 ) {
505 $this->update_user_name = (string) $this->getPosUserAlias();
506 }
507 }
508
509 return (string) $this->update_user_name;
510 }
511
517 {
518 if ($authorinfo->hasSuffix()) {
519 $public_name = $authorinfo->getAuthorName();
520 } else {
521 $public_name = $authorinfo->getAuthorShortName();
522
523 if ($authorinfo->getAuthorName() && !$this->isAnonymized()) {
524 $public_name = $authorinfo->getAuthorName();
525 }
526 }
527
528 return $public_name;
529 }
530}
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)
getPublicUserInformation(ilForumAuthorInformation $authorinfo)
getAuthorInformation(\ilLanguage $lng, $authorUsrId, $displayUserId, $usrAlias, $importName)
language handling
Interface ilForumNotificationMailData.
global $lng
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7