ILIAS  release_8 Revision v8.23
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 503 of file class.ilForumAppEventListener.php.

References ilLogger\debug(), ilForumNotificationDataProvider\getForumNotificationRecipients(), ilForumNotificationDataProvider\getPostActivationRecipients(), ilForumNotificationDataProvider\getThreadNotificationRecipients(), ilForumMailNotification\TYPE_POST_ACTIVATION, and ilForumMailNotification\TYPE_POST_ANSWERED.

507  : void {
508  switch ($notification_type) {
510  self::sendNotification(
511  $provider,
512  $logger,
513  $notification_type,
514  $provider->getPostActivationRecipients()
515  );
516  break;
517 
519  self::sendNotification($provider, $logger, $notification_type, $provider->getPostAnsweredRecipients());
520  break;
521 
522  default:
523  // get recipients who want to get forum notifications
524  $logger->debug('Determining subscribers for global forum notifications ...');
525  $frm_recipients = $provider->getForumNotificationRecipients($notification_type);
526 
527  // get recipients who want to get thread notifications
528  $logger->debug('Determining subscribers for thread notifications ...');
529  $thread_recipients = $provider->getThreadNotificationRecipients($notification_type);
530 
531  $recipients = array_unique(array_merge($frm_recipients, $thread_recipients));
532  self::sendNotification($provider, $logger, $notification_type, $recipients);
533 
534  break;
535  }
536  }
debug(string $a_message, array $a_context=array())
+ Here is the call graph for this function:

◆ getCachedReferences()

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

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

References ilObject\_getAllReferences().

494  : array
495  {
496  if (!array_key_exists($obj_id, self::$ref_ids)) {
497  self::$ref_ids[$obj_id] = ilObject::_getAllReferences($obj_id);
498  }
499 
500  return self::$ref_ids[$obj_id];
501  }
static _getAllReferences(int $id)
get all reference ids for object ID
+ Here is the call graph for this function:

◆ sendNotification()

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

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

References ANONYMOUS_USER_ID, and ilLogger\debug().

549  : void {
550  if (count($recipients)) {
551  $logger->debug(sprintf(
552  'Will send %s notification(s) to: %s',
553  count($recipients),
554  implode(', ', $recipients)
555  ));
556 
557  if (defined('ANONYMOUS_USER_ID')) {
558  $recipients = array_filter(
559  $recipients,
560  static fn (int $recipient): bool => $recipient !== ANONYMOUS_USER_ID
561  );
562  }
563 
564  $mailNotification = new ilForumMailEventNotificationSender($provider, $logger);
565  $mailNotification->setType($notificationTypes);
566  $mailNotification->setRecipients($recipients);
567  $mailNotification->send();
568  } else {
569  $logger->debug('No recipients found, skipped notification delivery.');
570  }
571  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
debug(string $a_message, array $a_context=array())
+ Here is the call 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: