Elgg  Version 4.3
notification.php
Go to the documentation of this file.
1 <?php
52 
73 function elgg_register_notification_event($object_type, $object_subtype, array $actions = [], string $handler = NotificationEventHandler::class): void {
74  _elgg_services()->notifications->registerEvent($object_type, $object_subtype, $actions, $handler);
75 }
76 
88 function elgg_unregister_notification_event($object_type, $object_subtype, array $actions = []): bool {
89  return _elgg_services()->notifications->unregisterEvent($object_type, $object_subtype, $actions);
90 }
91 
105  _elgg_services()->notifications->registerMethod($name);
106 }
107 
120 function elgg_get_notification_methods(): array {
121  return _elgg_services()->notifications->getMethods();
122 }
123 
133  return _elgg_services()->notifications->unregisterMethod($name);
134 }
135 
151 function elgg_get_notification_events(): array {
152  return _elgg_services()->notifications->getEvents();
153 }
154 
170  $methods = _elgg_services()->notifications->getMethods();
171 
172  return _elgg_services()->subscriptions->getSubscriptionsForContainer($container_guid, $methods);
173 }
174 
199 function notify_user($to, $from = 0, $subject = '', $message = '', array $params = [], $methods_override = null): array {
200 
201  $params['subject'] = $subject;
202  $params['body'] = $message;
203  $params['methods_override'] = $methods_override;
204 
205  if ($from) {
206  $sender = get_entity($from);
207  } else {
208  $sender = elgg_get_site_entity();
209  }
210  if (!$sender) {
211  return [];
212  }
213 
214  $recipients = [];
215  $to = (array) $to;
216  foreach ($to as $guid) {
217  $recipient = get_entity($guid);
218  if (!$recipient) {
219  continue;
220  }
221  $recipients[] = $recipient;
222  }
223 
224  return _elgg_services()->notifications->sendInstantNotifications($sender, $recipients, $params);
225 }
226 
234 function elgg_send_email(\Elgg\Email $email): bool {
235  return _elgg_services()->emails->send($email);
236 }
237 
249 function elgg_set_email_transport(\Laminas\Mail\Transport\TransportInterface $mailer): void {
250  _elgg_services()->set('mailer', $mailer);
251 }
252 
268  _elgg_services()->notifications->enqueueEvent($action, $type, $object, $actor);
269 }
elgg_set_email_transport(\Laminas\Mail\Transport\TransportInterface $mailer)
Replace default email transport.
elgg_register_notification_method($name)
Register a delivery method for notifications.
$params
Saves global plugin settings.
Definition: save.php:13
elgg_register_notification_event($object_type, $object_subtype, array $actions=[], string $handler=NotificationEventHandler::class)
Register a notification event.
if(($owner instanceof\ElggGroup||$owner instanceof\ElggUser)&&!in_array($owner->guid, $mute_guids)) $actor
Definition: mute.php:86
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_enqueue_notification_event(string $action, string $type,\ElggData $object,\ElggEntity $actor=null)
Enqueue a notification event for delivery.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
$email
Definition: change_email.php:7
$type
Definition: delete.php:21
notify_user($to, $from=0, $subject= '', $message= '', array $params=[], $methods_override=null)
Notify a user via their preferences.
Notifications This file contains classes and functions which allow plugins to register and send notif...
elgg_get_subscriptions_for_container(int $container_guid)
Get the subscriptions for the content created inside this container.
elgg_unregister_notification_method($name)
Unregister a delivery method for notifications.
if(!$menu instanceof\Elgg\Menu\PreparedMenu) $actions
Definition: user_hover.php:16
elgg_send_email(\Elgg\Email $email)
Send an email to any email address.
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:99
A generic class that contains shared code among , , and .
Definition: ElggData.php:10
$action
Definition: subscribe.php:11
if($email instanceof\Elgg\Email) $object
Definition: body.php:24
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
elgg_get_notification_methods()
Returns registered delivery methods for notifications [ &#39;email&#39; => &#39;email&#39;, &#39;sms&#39; => &#39;sms&#39;...
$container_guid
$handler
Definition: add.php:7
elgg_unregister_notification_event($object_type, $object_subtype, array $actions=[])
Unregister a notification event.
$methods
Definition: subscribe.php:8
$recipient
Definition: mute.php:8
$subject
Definition: useradd.php:58
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69
elgg_get_notification_events()
Get the registered notification events in the format.