3 namespace Elgg\Notifications;
8 use Elgg\Traits\Loggable;
34 protected Queue $queue,
58 if (!isset($this->events[
$type])) {
59 $this->events[
$type] = [];
106 if (empty($this->events[
$type])) {
107 unset($this->events[
$type]);
141 if (!$this->isRegisteredMethod(
$name)) {
145 unset($this->methods[
$name]);
166 return in_array($method, $this->methods);
179 $object_type =
$object->getType();
180 $object_subtype =
$object->getSubtype();
187 $handlers = $this->getSubscriptionHandlers($object_type, $object_subtype,
$action);
188 if (empty($handlers)) {
197 $registered = (bool) $this->elgg_events->triggerResults(
'enqueue',
'notification',
$params,
true);
202 $this->elgg_events->trigger(
'enqueue',
'notifications',
$object);
222 if (is_a(
$handler, InstantNotificationEventHandler::class,
true)) {
244 InstantNotificationEventHandler::class,
250 if (!is_a(
$handler, InstantNotificationEventHandler::class,
true)) {
259 InstantNotificationEventHandler::class,
277 while (time() < $stopTime) {
281 return $this->queue->dequeue();
295 $this->elgg_events->trigger(
'dequeue',
'notifications',
$object);
297 $handlers = $this->getSubscriptionHandlers(
$object->getType(),
$object->getSubtype(), $event->getAction());
298 if (empty($handlers)) {
302 foreach ($handlers as $handler_class) {
303 $handler =
new $handler_class($event, $this);
308 }
catch (\Throwable $t) {
309 $this->getLogger()->error($t);
355 if (empty($this->methods)) {
365 $handler->setRecipients($recipients);
384 if (empty($this->methods)) {
389 if (empty($handlers)) {
399 foreach ($handlers as $handler_class) {
407 }
catch (\Throwable $t) {
408 $this->getLogger()->error($t);
if(! $user||! $user->canDelete()) $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/clear'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['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', 'controller'=> \Elgg\Diagnostics\DownloadController::class,], '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'=>[],]
A generic class that contains shared code among \ElggExtender, \ElggEntity, and \ElggRelationship.
Exception thrown if an argument is not of the expected type.
Notification Event Handler for instant notifications.
Instant notification event.
Notification Event Handler handles preparation of a notification.
enqueueEvent(string $action, \ElggData $object, ?\ElggEntity $actor=null)
Add a notification event to the queue.
sendInstantNotifications(\ElggEntity $sender, array $recipients=[], array $params=[])
Notify a user via their preferences.
unregisterMethod(string $name)
Unregister a delivery method for notifications.
getEvents()
Return the notification events.
sendInstantNotification(\ElggUser $recipient, string $action, \ElggData $subject, array $params=[], ?\ElggEntity $from=null)
Send an instant notification to a user.
unregisterEvent(string $type, string $subtype, string $action='create', string $handler=NotificationEventHandler::class)
Unregister a notification event.
getSubscriptionHandlers(string $type, string $subtype, string $action)
Get the subscription notification handlers.
processQueue(int $stopTime)
Pull notification events from queue until stop time is reached.
isRegisteredMethod(string $method)
Check if a notification method is registed.
registerMethod(string $name)
Register a delivery method for notifications.
__construct(protected Queue $queue, protected \ElggSession $session, protected EventsService $elgg_events)
Constructor.
getInstantHandlers(string $type, string $subtype, string $action)
Get the instant notification handlers.
registerEvent(string $type, string $subtype, string $action='create', string $handler=NotificationEventHandler::class)
Register a notification event.
getMethods()
Returns registered delivery methods for notifications.
const ELGG_IGNORE_ACCESS
elgg_call() flags
const ELGG_SHOW_DISABLED_ENTITIES
if($email instanceof \Elgg\Email) $object
$subject
HTML body of an email.
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags.
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_get_site_entity()
Get the current site entity.
if(isset($_COOKIE['elggperm'])) $session
if($container instanceof ElggGroup && $container->guid !=elgg_get_page_owner_guid()) $key
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.