Elgg  Version master
notification.php
Go to the documentation of this file.
1 <?php
52 
73 function elgg_register_notification_event(string $object_type, string $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(string $object_type, string $object_subtype, array $actions = []): void {
89  _elgg_services()->notifications->unregisterEvent($object_type, $object_subtype, $actions);
90 }
91 
106  _elgg_services()->notifications->registerMethod($name);
107 }
108 
121 function elgg_get_notification_methods(): array {
122  return _elgg_services()->notifications->getMethods();
123 }
124 
135  _elgg_services()->notifications->unregisterMethod($name);
136 }
137 
153 function elgg_get_notification_events(): array {
154  return _elgg_services()->notifications->getEvents();
155 }
156 
172  $methods = _elgg_services()->notifications->getMethods();
173 
174  return _elgg_services()->subscriptions->getSubscriptionsForContainer($container_guid, $methods);
175 }
176 
201 function notify_user(int|array $to, int $from = 0, string $subject = '', string $message = '', array $params = [], $methods_override = null): array {
202 
203  $params['subject'] = $subject;
204  $params['body'] = $message;
205  $params['methods_override'] = $methods_override;
206 
207  if (!empty($from)) {
208  $sender = get_entity($from);
209  } else {
210  $sender = elgg_get_site_entity();
211  }
212 
213  if (!$sender instanceof \ElggEntity) {
214  return [];
215  }
216 
217  $recipients = [];
218  $to = (array) $to;
219  foreach ($to as $guid) {
220  $recipient = get_entity($guid);
221  if (!$recipient instanceof \ElggEntity) {
222  continue;
223  }
224 
225  $recipients[] = $recipient;
226  }
227 
228  return _elgg_services()->notifications->sendInstantNotifications($sender, $recipients, $params);
229 }
230 
239 function elgg_send_email(\Elgg\Email $email): bool {
240  return _elgg_services()->emails->send($email);
241 }
242 
257  _elgg_services()->notifications->enqueueEvent($action, $object, $actor);
258 }
$params
Saves global plugin settings.
Definition: save.php:13
if(($owner instanceof\ElggGroup||$owner instanceof\ElggUser)&&!in_array($owner->guid, $mute_guids)) $actor
Definition: mute.php:78
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_enqueue_notification_event(string $action,\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
elgg_unregister_notification_method(string $name)
Unregister a delivery method for notifications.
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.
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:70
elgg_register_notification_event(string $object_type, string $object_subtype, array $actions=[], string $handler=NotificationEventHandler::class)
Register a notification event.
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:101
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_register_notification_method(string $name)
Register a delivery method for notifications.
notify_user(int|array $to, int $from=0, string $subject= '', string $message= '', array $params=[], $methods_override=null)
Notify a user via their preferences.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:351
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(string $object_type, string $object_subtype, array $actions=[])
Unregister a notification event.
$methods
Definition: subscribe.php:8
$recipient
Definition: mute.php:8
$subject
Definition: useradd.php:54
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
elgg_get_notification_events()
Get the registered notification events in the format.