6 use Elgg\Traits\Loggable;
49 final public function send(): array {
62 $params[
'deliveries'] = $deliveries;
77 'event' => $this->event,
78 'methods' => $this->getMethods(),
79 'methods_override' => (array)
elgg_extract(
'methods_override', $this->params, []),
102 return _elgg_services()->subscriptions->getNotificationEventSubscriptions($this->event, $this->getMethods(), $this->getNotificationSubsciptionExclusionGUIDs());
111 $object = $this->event->getObject();
117 if ($this->excludeOwnerSubscribers()) {
118 $exclude[] =
$object->owner_guid;
121 if ($this->excludeContainerSubscribers()) {
122 $exclude[] =
$object->container_guid;
125 if ($this->excludeEntitySubscribers()) {
168 return $this->service->getMethods();
191 if (empty($this->getMethods())) {
196 $current_language = $translator->getCurrentLanguage();
202 $translator->setCurrentLanguage(
$recipient->getLanguage());
209 if ($this->service->isRegisteredMethod($method)) {
213 }
catch (\Throwable $t) {
214 $translator->setCurrentLanguage($current_language);
218 $translator->setCurrentLanguage($current_language);
221 $this->
getLogger()->info(
"Results for the notification event {$this->event->getDescription()}: " . print_r(
$result,
true));
235 if (!
_elgg_services()->events->hasHandler(
'send',
"notification:{$method}")) {
240 $actor = $this->
event->getActor();
241 $object = $this->
event->getObject();
278 $params[
'event'] = $this->event;
284 $params[
'action'] = $this->
event->getAction();
304 'event' => $this->event,
309 if ($this->getLogger()->isLoggable(LogLevel::INFO)) {
310 $logger_data = print_r((array)
$notification->toObject(),
true);
312 $this->getLogger()->info(
'Notification sent: ' . $logger_data);
314 $this->getLogger()->info(
'Notification was not sent: ' . $logger_data);
334 throw new RuntimeException(
"'prepare','notification' event must return an instance of " . Notification::class);
337 $type =
'notification:' . $this->
event->getDescription();
340 throw new RuntimeException(
"'prepare','{$type}' event must return an instance of " . Notification::class);
350 throw new RuntimeException(
"'format','notification:{$params['method']}' event must return an instance of " . Notification::class);
368 $actor = $this->event->getActor() ?: null;
369 $object = $this->
event->getObject();
372 $subject_key =
"notification:{$this->event->getDescription()}:subject";
373 if (
_elgg_services()->translator->languageKeyExists($subject_key)) {
375 $actor?->getDisplayName(),
381 return _elgg_services()->translator->translate(
'notification:subject', [
$actor?->getDisplayName()]);
407 $actor = $this->event->getActor() ?: null;
408 $object = $this->
event->getObject() ?:
null;
411 $body_key =
"notification:{$this->event->getDescription()}:body";
414 $container_name =
'';
417 $container_name =
$object->getContainerEntity()?->getDisplayName();
421 $actor?->getDisplayName(),
454 $object = $this->event->getObject() ?: null;
456 return (
string)
$object?->getURL();
466 $actor = $this->event->getActor();
478 $object = $this->event->getObject();
504 return static::isConfigurableForUser(
$entity);
506 return static::isConfigurableForGroup(
$entity);
getLogger()
Returns logger.
$guid
Reset an ElggUpgrade.
if(! $new_container instanceof \ElggEntity) if(! $new_container->canWriteToContainer(0, $entity->type, $entity->subtype)) $display_name
$params
Saves global plugin settings.
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
if(! $owner instanceof ElggEntity) $summary
Exception thrown if an error which can only be found on runtime occurs.
Instant notification event.
Notification Event Handler handles preparation of a notification.
deliverNotification(Notification $notification, string $method)
Deliver a notification.
sendNotification(int $guid, string $method, array $params=[])
Send a notification to a subscriber.
addMuteLink()
Add a mute link in the email notification.
getMethods()
Returns methods to be used for this notification.
getNotificationSummary(\ElggUser $recipient, string $method)
Return the summary for a notification.
__construct(NotificationEvent $event, NotificationsService $service, array $params=[])
Constructor.
filterMutedSubscriptions()
Should muted subscribers be filtered.
getEventActor()
Get the acting user from the notification event.
static isConfigurableByUser()
Is this event configurable by the user on the notification settings page.
excludeOwnerSubscribers()
Exclude the NotificationEvent object owner_guid when fetching the subscription records for this notif...
getEventEntity()
Get the entity from the notification event.
static isConfigurableForUser(\ElggUser $user)
Can this event be configured for a specific user.
static isConfigurableForGroup(\ElggGroup $group)
Can this event be configured for a specific group.
prepareNotification(array $params)
Prepares a notification for delivery.
prepareSubscriptions()
Returns subscriptions.
sendNotifications(array $subscriptions, array $params=[])
Sends the notifications based on subscriptions.
getNotificationSubject(\ElggUser $recipient, string $method)
Get subject for the notification.
getNotificationSubsciptionExclusionGUIDs()
Get an array of GUIDs to not get the subscription records for.
static isConfigurableForEntity(\ElggEntity $entity)
Can this event be configured for a specific entity.
getNotificationBody(\ElggUser $recipient, string $method)
Get body for the notification.
excludeEntitySubscribers()
Exclude the NotificationEvent object guid when fetching the subscription records for this notificatio...
excludeContainerSubscribers()
Exclude the NotificationEvent object container_guid when fetching the subscription records for this n...
getSubscriptions()
Returns subscriptions for the event.
getNotificationURL(\ElggUser $recipient, string $method)
Returns the url related to this notification.
if($email instanceof \Elgg\Email) $object
if($item instanceof \ElggEntity) elseif($item instanceof \ElggRiverItem) elseif($item instanceof \ElggRelationship) elseif(is_callable([ $item, 'getType']))
_elgg_services()
Get the global service provider.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Notification event interface.
elgg_view_exists(string $view, string $viewtype='', bool $recurse=true)
Returns whether the specified view exists.
_elgg_view_under_viewtype(string $view, array $vars, string $viewtype)
Render a view while the global viewtype is temporarily changed.
if(!elgg_get_config('trash_enabled')) $group
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
if(empty($methods)) $subscriptions