ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjForumNotificationDataProvider Class Reference

Class ilObjForumNotificationDataProvider. More...

+ Inheritance diagram for ilObjForumNotificationDataProvider:
+ Collaboration diagram for ilObjForumNotificationDataProvider:

Public Member Functions

 __construct (ilForumPost $objPost, $ref_id)
 
 getRefId ()
 
 getObjId ()
 
 getThreadId ()
 
 getPostId ()
 
 getForumId ()
 
 getForumTitle ()
 
 getThreadTitle ()
 
 getPostTitle ()
 
 getPostMessage ()
 
 getPosDisplayUserId ()
 
 getPostDate ()
 
 getPostUpdate ()
 
 getPostCensored ()
 
 getPostCensoredDate ()
 
 getCensorshipComment ()
 
 getAttachments ()
 
 getPosUserAlias ()
 
 isAnonymized ()
 
 getImportName ()
 
 getPostUpdateUserId ()
 
Returns
int
More...
 
 getPostUserName (\ilLanguage $user_lang)
 
Parameters
\ilLanguage$user_lang
Returns
string
More...
 
 getPostUpdateUserName (\ilLanguage $user_lang)
 
Parameters
\ilLanguage$user_lang
Returns
string
More...
 
 getPublicUserInformation (ilForumAuthorInformation $authorinfo)
 
 getForumNotificationRecipients ()
 
 getThreadNotificationRecipients ()
 
 getPostAnsweredRecipients ()
 
 getPostActivationRecipients ()
 
 setPosAuthorId ($pos_author_id)
 
 getPosAuthorId ()
 
 getDeletedBy ()
 
 getRefId ()
 
 getObjId ()
 
 getForumId ()
 
 getForumTitle ()
 
 getThreadId ()
 
 getThreadTitle ()
 
 getPostId ()
 
 getPostTitle ()
 
 getPostMessage ()
 
 getPosAuthorId ()
 
 getPostUpdateUserId ()
 
 getPosDisplayUserId ()
 
 getPosUserAlias ()
 
 getPostUserName (\ilLanguage $user_lang)
 
 getPostDate ()
 
 getPostUpdate ()
 
 getPostUpdateUserName (\ilLanguage $user_lang)
 
 getPostCensored ()
 
 getPostCensoredDate ()
 
 getCensorshipComment ()
 
 getAttachments ()
 
 getDeletedBy ()
 

Data Fields

 $pos_author_id = 0
 
 $objPost
 

Protected Member Functions

 read ()
 

Protected Attributes

 $ref_id = 0
 
 $obj_id = 0
 
 $post_user_name = null
 
 $update_user_name = null
 
 $forum_id = 0
 
 $forum_title = ''
 
 $thread_title = ''
 
 $attachments = array()
 
 $is_anonymized = false
 

Private Member Functions

 readThreadTitle ()
 
 readForumData ()
 
 readAttachments ()
 
 shouldUsePseudonym ()
 

Private Attributes

 $db
 
 $access
 
 $user
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjForumNotificationDataProvider::__construct ( ilForumPost  $objPost,
  $ref_id 
)
Parameters
ilForumPost$objPost
int$ref_id

Definition at line 75 of file class.ilObjForumNotificationDataProvider.php.

76 {
77 global $DIC;
78 $this->db = $DIC->database();
79 $this->access = $DIC->access();
80 $this->user = $DIC->user();
81
82 $this->objPost = $objPost;
83 $this->ref_id = $ref_id;
84 $this->obj_id = ilObject::_lookupObjId($ref_id);
85 $this->read();
86 }
user()
Definition: user.php:4
static _lookupObjId($a_id)
global $DIC
Definition: saml.php:7

References $DIC, $objPost, $ref_id, ilObject\_lookupObjId(), read(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAttachments()

ilObjForumNotificationDataProvider::getAttachments ( )

◆ getCensorshipComment()

ilObjForumNotificationDataProvider::getCensorshipComment ( )
Returns
string

Implements ilForumNotificationMailData.

Definition at line 199 of file class.ilObjForumNotificationDataProvider.php.

200 {
201 return $this->objPost->getCensorshipComment();
202 }

◆ getDeletedBy()

ilObjForumNotificationDataProvider::getDeletedBy ( )
Returns
string

Implements ilForumNotificationMailData.

Definition at line 485 of file class.ilObjForumNotificationDataProvider.php.

486 {
487 global $DIC;
488
489 if ($this->shouldUsePseudonym()) {
490 return (string) $this->objPost->getUserAlias();
491 }
492 return $DIC->user()->getLogin();
493 }

References $DIC, and shouldUsePseudonym().

+ Here is the call graph for this function:

◆ getForumId()

ilObjForumNotificationDataProvider::getForumId ( )
Returns
int

Implements ilForumNotificationMailData.

Definition at line 123 of file class.ilObjForumNotificationDataProvider.php.

References $forum_id.

Referenced by getForumNotificationRecipients().

+ Here is the caller graph for this function:

◆ getForumNotificationRecipients()

ilObjForumNotificationDataProvider::getForumNotificationRecipients ( )
Returns
array

Definition at line 378 of file class.ilObjForumNotificationDataProvider.php.

379 {
380 $res = $this->db->queryf(
381 '
382 SELECT frm_notification.user_id FROM frm_notification, frm_data
383 WHERE frm_data.top_pk = %s
384 AND frm_notification.frm_id = frm_data.top_frm_fk
385 AND frm_notification.user_id != %s
386 GROUP BY frm_notification.user_id',
387 array('integer', 'integer'),
388 array($this->getForumId(), $this->user->getId())
389 );
390
391 // get all references of obj_id
392 $frm_references = ilObject::_getAllReferences($this->getObjId());
393 $rcps = array();
394 while ($row = $this->db->fetchAssoc($res)) {
395 // do rbac check before sending notification
396 foreach ((array) $frm_references as $ref_id) {
397 if ($this->access->checkAccessOfUser($row['user_id'], 'read', '', $ref_id)) {
398 $rcps[] = $row['user_id'];
399 }
400 }
401 }
402
403
404 return array_unique($rcps);
405 }
static _getAllReferences($a_id)
get all reference ids of object
foreach($_POST as $key=> $value) $res

References $ref_id, $res, $row, ilObject\_getAllReferences(), getForumId(), getObjId(), and user().

+ Here is the call graph for this function:

◆ getForumTitle()

ilObjForumNotificationDataProvider::getForumTitle ( )
Returns
string frm_data.top_name

Implements ilForumNotificationMailData.

Definition at line 131 of file class.ilObjForumNotificationDataProvider.php.

References $forum_title.

◆ getImportName()

ilObjForumNotificationDataProvider::getImportName ( )
Returns
string

Definition at line 230 of file class.ilObjForumNotificationDataProvider.php.

231 {
232 return $this->objPost->getImportName();
233 }

Referenced by getPostUpdateUserName(), and getPostUserName().

+ Here is the caller graph for this function:

◆ getObjId()

ilObjForumNotificationDataProvider::getObjId ( )

◆ getPosAuthorId()

ilObjForumNotificationDataProvider::getPosAuthorId ( )
Returns
int

Implements ilForumNotificationMailData.

Definition at line 477 of file class.ilObjForumNotificationDataProvider.php.

References $pos_author_id.

Referenced by getPostUpdateUserName(), and getPostUserName().

+ Here is the caller graph for this function:

◆ getPosDisplayUserId()

ilObjForumNotificationDataProvider::getPosDisplayUserId ( )
Returns
string frm_posts.pos_display_user_id

Implements ilForumNotificationMailData.

Definition at line 163 of file class.ilObjForumNotificationDataProvider.php.

164 {
165 return $this->objPost->getDisplayUserId();
166 }

Referenced by getPostUserName().

+ Here is the caller graph for this function:

◆ getPostActivationRecipients()

ilObjForumNotificationDataProvider::getPostActivationRecipients ( )
Returns
array

Definition at line 458 of file class.ilObjForumNotificationDataProvider.php.

459 {
460 include_once './Modules/Forum/classes/class.ilForum.php';
461 // get moderators to notify about needed activation
462 $rcps = ilForum::_getModerators($this->getRefId());
463 return (array) $rcps;
464 }
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)

References ilForum\_getModerators(), and getRefId().

+ Here is the call graph for this function:

◆ getPostAnsweredRecipients()

ilObjForumNotificationDataProvider::getPostAnsweredRecipients ( )
Returns
array

Definition at line 444 of file class.ilObjForumNotificationDataProvider.php.

445 {
446 include_once './Modules/Forum/classes/class.ilForumPost.php';
447 $parent_objPost = new ilForumPost($this->objPost->getParentId());
448
449 $rcps = array();
450 $rcps[] = $parent_objPost->getPosAuthorId();
451
452 return $rcps;
453 }

◆ getPostCensored()

ilObjForumNotificationDataProvider::getPostCensored ( )
Returns
bool frm_posts.pos_cens

Implements ilForumNotificationMailData.

Definition at line 186 of file class.ilObjForumNotificationDataProvider.php.

187 {
188 return $this->objPost->isCensored();
189 }

◆ getPostCensoredDate()

ilObjForumNotificationDataProvider::getPostCensoredDate ( )
Returns
string frm_posts.pos_cens_date

Implements ilForumNotificationMailData.

Definition at line 194 of file class.ilObjForumNotificationDataProvider.php.

195 {
196 return $this->objPost->getCensoredDate();
197 }

◆ getPostDate()

ilObjForumNotificationDataProvider::getPostDate ( )
Returns
string frm_posts.pos_date

Implements ilForumNotificationMailData.

Definition at line 171 of file class.ilObjForumNotificationDataProvider.php.

172 {
173 return $this->objPost->getCreateDate();
174 }

◆ getPostId()

ilObjForumNotificationDataProvider::getPostId ( )
Returns
int

Implements ilForumNotificationMailData.

Definition at line 115 of file class.ilObjForumNotificationDataProvider.php.

116 {
117 return $this->objPost->getId();
118 }

◆ getPostMessage()

ilObjForumNotificationDataProvider::getPostMessage ( )
Returns
string frm_posts.pos_message

Implements ilForumNotificationMailData.

Definition at line 155 of file class.ilObjForumNotificationDataProvider.php.

156 {
157 return $this->objPost->getMessage();
158 }

◆ getPostTitle()

ilObjForumNotificationDataProvider::getPostTitle ( )
Returns
string frm_posts.pos_subject

Implements ilForumNotificationMailData.

Definition at line 147 of file class.ilObjForumNotificationDataProvider.php.

148 {
149 return $this->objPost->getSubject();
150 }

◆ getPostUpdate()

ilObjForumNotificationDataProvider::getPostUpdate ( )
Returns
string frm_posts.pos_update

Implements ilForumNotificationMailData.

Definition at line 179 of file class.ilObjForumNotificationDataProvider.php.

180 {
181 return $this->objPost->getChangeDate();
182 }

◆ getPostUpdateUserId()

ilObjForumNotificationDataProvider::getPostUpdateUserId ( )

Returns
int

Implements ilForumNotificationMailData.

Definition at line 238 of file class.ilObjForumNotificationDataProvider.php.

239 {
240 return $this->objPost->getUpdateUserId();
241 }

Referenced by getPostUpdateUserName().

+ Here is the caller graph for this function:

◆ getPostUpdateUserName()

ilObjForumNotificationDataProvider::getPostUpdateUserName ( \ilLanguage  $user_lang)

Parameters
\ilLanguage$user_lang
Returns
string

Implements ilForumNotificationMailData.

Definition at line 266 of file class.ilObjForumNotificationDataProvider.php.

267 {
268 if ($this->update_user_name === null) {
269 $authorinfo = new ilForumAuthorInformation(
270 $this->getPosAuthorId(),
271 $this->getPostUpdateUserId(),
272 $this->getPosUserAlias(),
273 $this->getImportName(),
274 array(),
275 $user_lang
276 );
277 $this->update_user_name = $this->getPublicUserInformation($authorinfo);
278 }
279
280 // Possible Fix for #25432
281 if ($this->objPost->getUserAlias() && $this->objPost->getDisplayUserId() == 0
282 && $this->objPost->getPosAuthorId() == $this->objPost->getUpdateUserId()) {
283 return (string) $this->objPost->getUserAlias();
284 }
285
286 return (string) $this->update_user_name;
287 }
getPublicUserInformation(ilForumAuthorInformation $authorinfo)

References $update_user_name, getImportName(), getPosAuthorId(), getPostUpdateUserId(), getPosUserAlias(), and getPublicUserInformation().

+ Here is the call graph for this function:

◆ getPostUserName()

ilObjForumNotificationDataProvider::getPostUserName ( \ilLanguage  $user_lang)

Parameters
\ilLanguage$user_lang
Returns
string

Implements ilForumNotificationMailData.

Definition at line 246 of file class.ilObjForumNotificationDataProvider.php.

247 {
248 if ($this->post_user_name === null) {
249 $authorinfo = new ilForumAuthorInformation(
250 $this->getPosAuthorId(),
251 $this->getPosDisplayUserId(),
252 $this->getPosUserAlias(),
253 $this->getImportName(),
254 array(),
255 $user_lang
256 );
257 $this->post_user_name = $this->getPublicUserInformation($authorinfo);
258 }
259
260 return (string) $this->post_user_name;
261 }

References $post_user_name, getImportName(), getPosAuthorId(), getPosDisplayUserId(), getPosUserAlias(), and getPublicUserInformation().

+ Here is the call graph for this function:

◆ getPosUserAlias()

ilObjForumNotificationDataProvider::getPosUserAlias ( )
Returns
string frm_posts.pos_usr_alias

Implements ilForumNotificationMailData.

Definition at line 215 of file class.ilObjForumNotificationDataProvider.php.

216 {
217 return $this->objPost->getUserAlias();
218 }

Referenced by getPostUpdateUserName(), and getPostUserName().

+ Here is the caller graph for this function:

◆ getPublicUserInformation()

ilObjForumNotificationDataProvider::getPublicUserInformation ( ilForumAuthorInformation  $authorinfo)
Parameters
ilForumAuthorInformation$authorinfo
Returns
string

Definition at line 293 of file class.ilObjForumNotificationDataProvider.php.

294 {
295 if ($authorinfo->hasSuffix()) {
296 $public_name = $authorinfo->getAuthorName();
297 } else {
298 $public_name = $authorinfo->getAuthorShortName();
299
300 if ($authorinfo->getAuthorName() && !$this->isAnonymized()) {
301 $public_name = $authorinfo->getAuthorName();
302 }
303 }
304
305 return $public_name;
306 }
getAuthorName($without_short_name=false)

References ilForumAuthorInformation\getAuthorName(), ilForumAuthorInformation\getAuthorShortName(), and ilForumAuthorInformation\hasSuffix().

Referenced by getPostUpdateUserName(), and getPostUserName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefId()

ilObjForumNotificationDataProvider::getRefId ( )
Returns
int

Implements ilForumNotificationMailData.

Definition at line 91 of file class.ilObjForumNotificationDataProvider.php.

92 {
93 return $this->ref_id;
94 }

References $ref_id.

Referenced by getPostActivationRecipients().

+ Here is the caller graph for this function:

◆ getThreadId()

ilObjForumNotificationDataProvider::getThreadId ( )
Returns
int

Implements ilForumNotificationMailData.

Definition at line 107 of file class.ilObjForumNotificationDataProvider.php.

108 {
109 return $this->objPost->getThreadId();
110 }

Referenced by getThreadNotificationRecipients().

+ Here is the caller graph for this function:

◆ getThreadNotificationRecipients()

ilObjForumNotificationDataProvider::getThreadNotificationRecipients ( )
Returns
int[]

Definition at line 410 of file class.ilObjForumNotificationDataProvider.php.

411 {
412 if (!$this->getThreadId()) {
413 return [];
414 }
415
416 $res = $this->db->queryf(
417 '
418 SELECT frm_notification.user_id
419 FROM frm_notification
420 INNER JOIN frm_threads ON frm_threads.thr_pk = frm_notification.thread_id
421 WHERE frm_notification.thread_id = %s
422 AND frm_notification.user_id != %s',
423 array('integer', 'integer'),
424 array($this->getThreadId(), $this->user->getId())
425 );
426
427
428 $frm_references = \ilObject::_getAllReferences($this->getObjId());
429 $usrIds = [];
430 while ($row = $this->db->fetchAssoc($res)) {
431 foreach ((array) $frm_references as $ref_id) {
432 if ($this->access->checkAccessOfUser($row['user_id'], 'read', '', $ref_id)) {
433 $usrIds[] = $row['user_id'];
434 }
435 }
436 }
437
438 return array_unique($usrIds);
439 }

References $ref_id, $res, $row, ilObject\_getAllReferences(), getObjId(), getThreadId(), and user().

+ Here is the call graph for this function:

◆ getThreadTitle()

ilObjForumNotificationDataProvider::getThreadTitle ( )
Returns
string frm_threads.thr_subject

Implements ilForumNotificationMailData.

Definition at line 139 of file class.ilObjForumNotificationDataProvider.php.

References $thread_title.

◆ isAnonymized()

ilObjForumNotificationDataProvider::isAnonymized ( )

◆ read()

ilObjForumNotificationDataProvider::read ( )
protected

Definition at line 311 of file class.ilObjForumNotificationDataProvider.php.

References readAttachments(), readForumData(), and readThreadTitle().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readAttachments()

ilObjForumNotificationDataProvider::readAttachments ( )
private

Definition at line 358 of file class.ilObjForumNotificationDataProvider.php.

359 {
361 require_once 'Modules/Forum/classes/class.ilFileDataForum.php';
362 $fileDataForum = new ilFileDataForum($this->getObjId(), $this->objPost->getId());
363 $filesOfPost = $fileDataForum->getFilesOfPost();
364
365 require_once 'Services/Mail/classes/class.ilFileDataMail.php';
366 $fileDataMail = new ilFileDataMail(ANONYMOUS_USER_ID);
367
368 foreach ($filesOfPost as $attachment) {
369 $this->attachments[$attachment['path']] = $attachment['name'];
370 $fileDataMail->copyAttachmentFile($attachment['path'], $attachment['name']);
371 }
372 }
373 }
This class handles all operations on files for the forum object.
This class handles all operations on files (attachments) in directory ilias_data/mail.

References getObjId(), and ilForumProperties\isSendAttachmentsByMailEnabled().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readForumData()

ilObjForumNotificationDataProvider::readForumData ( )
private

Definition at line 338 of file class.ilObjForumNotificationDataProvider.php.

339 {
340 $result = $this->db->queryf(
341 '
342 SELECT top_pk, top_name, frm_settings.anonymized FROM frm_data
343 INNER JOIN frm_settings ON top_frm_fk = frm_settings.obj_id
344 WHERE top_frm_fk = %s',
345 array('integer'),
346 array($this->getObjId())
347 );
348
349 $row = $this->db->fetchAssoc($result);
350 $this->forum_id = $row['top_pk'];
351 $this->forum_title = $row['top_name'];
352 $this->is_anonymized = (bool) $row['anonymized'];
353 }
$result

References $result, $row, and getObjId().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readThreadTitle()

ilObjForumNotificationDataProvider::readThreadTitle ( )
private

Definition at line 321 of file class.ilObjForumNotificationDataProvider.php.

322 {
323 $result = $this->db->queryf(
324 '
325 SELECT thr_subject FROM frm_threads
326 WHERE thr_pk = %s',
327 array('integer'),
328 array($this->objPost->getThreadId())
329 );
330
331 $row = $this->db->fetchAssoc($result);
332 $this->thread_title = $row['thr_subject'];
333 }

References $result, and $row.

Referenced by read().

+ Here is the caller graph for this function:

◆ setPosAuthorId()

ilObjForumNotificationDataProvider::setPosAuthorId (   $pos_author_id)
Parameters
$pos_author_id

Definition at line 469 of file class.ilObjForumNotificationDataProvider.php.

470 {
471 $this->pos_author_id = $pos_author_id;
472 }

References $pos_author_id.

◆ shouldUsePseudonym()

ilObjForumNotificationDataProvider::shouldUsePseudonym ( )
private
Returns
bool

Definition at line 498 of file class.ilObjForumNotificationDataProvider.php.

499 {
500 global $DIC;
501
502 if ($this->objPost->getUserAlias() && $this->objPost->getDisplayUserId() == 0
503 && $this->objPost->getPosAuthorId() == $DIC->user()->getId()) {
504 return true;
505 }
506 return false;
507 }

References $DIC.

Referenced by getDeletedBy().

+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilObjForumNotificationDataProvider::$access
private

Definition at line 63 of file class.ilObjForumNotificationDataProvider.php.

◆ $attachments

array ilObjForumNotificationDataProvider::$attachments = array()
protected

Definition at line 55 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getAttachments().

◆ $db

ilObjForumNotificationDataProvider::$db
private

Definition at line 62 of file class.ilObjForumNotificationDataProvider.php.

◆ $forum_id

ilObjForumNotificationDataProvider::$forum_id = 0
protected

Definition at line 40 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getForumId().

◆ $forum_title

string ilObjForumNotificationDataProvider::$forum_title = ''
protected

Definition at line 45 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getForumTitle().

◆ $is_anonymized

ilObjForumNotificationDataProvider::$is_anonymized = false
protected

Definition at line 69 of file class.ilObjForumNotificationDataProvider.php.

Referenced by isAnonymized().

◆ $obj_id

int ilObjForumNotificationDataProvider::$obj_id = 0
protected

Definition at line 21 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getObjId().

◆ $objPost

ilObjForumNotificationDataProvider::$objPost

Definition at line 60 of file class.ilObjForumNotificationDataProvider.php.

Referenced by __construct().

◆ $pos_author_id

ilObjForumNotificationDataProvider::$pos_author_id = 0

Definition at line 36 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getPosAuthorId(), and setPosAuthorId().

◆ $post_user_name

string null ilObjForumNotificationDataProvider::$post_user_name = null
protected

Definition at line 26 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getPostUserName().

◆ $ref_id

int ilObjForumNotificationDataProvider::$ref_id = 0
protected

◆ $thread_title

string ilObjForumNotificationDataProvider::$thread_title = ''
protected

Definition at line 50 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getThreadTitle().

◆ $update_user_name

string null ilObjForumNotificationDataProvider::$update_user_name = null
protected

Definition at line 31 of file class.ilObjForumNotificationDataProvider.php.

Referenced by getPostUpdateUserName().

◆ $user

ilObjForumNotificationDataProvider::$user
private

Definition at line 64 of file class.ilObjForumNotificationDataProvider.php.


The documentation for this class was generated from the following file: