ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ilForumAppEventListener Class Reference

Forum listener. More...

+ Inheritance diagram for ilForumAppEventListener:
+ Collaboration diagram for ilForumAppEventListener:

Static Public Member Functions

static sendNotification (ilForumNotificationDataProvider $provider, ilLogger $logger, int $notificationTypes, array $recipients)
 
- Static Public Member Functions inherited from ilAppEventListener
static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle an event in a listener. More...
 

Static Protected Attributes

static array $ref_ids = []
 

Static Private Member Functions

static getCachedReferences (int $obj_id)
 
static delegateNotification (ilForumNotificationDataProvider $provider, int $notification_type, ilLogger $logger)
 

Detailed Description

Forum listener.

Listens to events of other components.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e \

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

Member Function Documentation

◆ delegateNotification()

static ilForumAppEventListener::delegateNotification ( ilForumNotificationDataProvider  $provider,
int  $notification_type,
ilLogger  $logger 
)
staticprivate

Definition at line 491 of file class.ilForumAppEventListener.php.

495 : void {
496 switch ($notification_type) {
499 $provider,
500 $logger,
501 $notification_type,
502 $provider->getPostActivationRecipients()
503 );
504 break;
505
507 self::sendNotification($provider, $logger, $notification_type, $provider->getPostAnsweredRecipients());
508 break;
509
510 default:
511 // get recipients who want to get forum notifications
512 $logger->debug('Determining subscribers for global forum notifications ...');
513 $frm_recipients = $provider->getForumNotificationRecipients($notification_type);
514
515 // get recipients who want to get thread notifications
516 $logger->debug('Determining subscribers for thread notifications ...');
517 $thread_recipients = $provider->getThreadNotificationRecipients($notification_type);
518
519 $recipients = array_unique(array_merge($frm_recipients, $thread_recipients));
520 self::sendNotification($provider, $logger, $notification_type, $recipients);
521
522 break;
523 }
524 }
static sendNotification(ilForumNotificationDataProvider $provider, ilLogger $logger, int $notificationTypes, array $recipients)
debug(string $message, array $context=[])
$provider
Definition: ltitoken.php:80

References $provider, ilLogger\debug(), sendNotification(), ilForumMailNotification\TYPE_POST_ACTIVATION, and ilForumMailNotification\TYPE_POST_ANSWERED.

+ Here is the call graph for this function:

◆ getCachedReferences()

static ilForumAppEventListener::getCachedReferences ( int  $obj_id)
staticprivate
Returns
int[]

Definition at line 482 of file class.ilForumAppEventListener.php.

482 : array
483 {
484 if (!array_key_exists($obj_id, self::$ref_ids)) {
485 self::$ref_ids[$obj_id] = ilObject::_getAllReferences($obj_id);
486 }
487
488 return self::$ref_ids[$obj_id];
489 }
static _getAllReferences(int $id)
get all reference ids for object ID

References ilObject\_getAllReferences().

+ Here is the call graph for this function:

◆ sendNotification()

static ilForumAppEventListener::sendNotification ( ilForumNotificationDataProvider  $provider,
ilLogger  $logger,
int  $notificationTypes,
array  $recipients 
)
static
Parameters
int[]$recipients

Definition at line 529 of file class.ilForumAppEventListener.php.

534 : void {
535 if ($recipients !== []) {
536 $logger->debug(sprintf(
537 'Will send %s notification(s) to: %s',
538 count($recipients),
539 implode(', ', $recipients)
540 ));
541
542 if (defined('ANONYMOUS_USER_ID')) {
543 $recipients = array_filter(
544 $recipients,
545 static fn(int $recipient): bool => $recipient !== ANONYMOUS_USER_ID
546 );
547 }
548
549 $mailNotification = new ilForumMailEventNotificationSender($provider, $logger);
550 $mailNotification->setType($notificationTypes);
551 $mailNotification->setRecipients($recipients);
552 $mailNotification->send();
553 } else {
554 $logger->debug('No recipients found, skipped notification delivery.');
555 }
556 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

References $provider, ANONYMOUS_USER_ID, and ilLogger\debug().

Referenced by delegateNotification().

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

Field Documentation

◆ $ref_ids

array ilForumAppEventListener::$ref_ids = []
staticprotected

Definition at line 29 of file class.ilForumAppEventListener.php.


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