74 $action_list = array_unique(array_merge($action_list,
$actions));
75 } elseif (!in_array(
'create', $action_list)) {
76 $action_list[] =
'create';
90 unset($this->
events[$type][$subtype]);
115 if (isset($this->methods[
$name])) {
116 unset($this->methods[$name]);
140 $object_type =
$object->getType();
141 $object_subtype =
$object->getSubtype();
144 if (isset($this->
events[$object_type])
145 && isset($this->
events[$object_type][$object_subtype])
146 && in_array(
$action, $this->
events[$object_type][$object_subtype])) {
155 $registered = $this->hooks->trigger(
'enqueue',
'notification',
$params, $registered);
179 $ia = $this->session->setIgnoreAccess(
true);
181 while (time() < $stopTime) {
183 $event = $this->queue->dequeue();
197 if ($this->hooks->trigger(
'send:before',
'notifications',
$params,
true)) {
200 $this->hooks->trigger(
'send:after',
'notifications',
$params);
206 $this->session->setIgnoreAccess(
$ia);
221 if (!$this->methods) {
228 if (in_array($method, $this->methods)) {
250 if (!$recipient || $recipient->isBanned()) {
255 if ($recipient->getGUID() == $event->getActorGUID()) {
259 $actor = $event->getActor();
273 'recipient' => $recipient,
282 $type =
'notification:' . $event->getDescription();
283 if ($this->hooks->hasHandler(
'prepare', $type)) {
284 $notification = $this->hooks->trigger(
'prepare', $type,
$params, $notification);
290 if ($this->hooks->hasHandler(
'send',
"notification:$method")) {
293 'notification' => $notification,
296 return $this->hooks->trigger(
'send',
"notification:$method",
$params,
false);
299 $userGuid = $notification->getRecipientGUID();
300 $senderGuid = $notification->getSenderGUID();
301 $subject = $notification->subject;
302 $body = $notification->body;
303 $params = $notification->params;
326 if (isset($this->deprHandlers[
$method])) {
327 return $this->deprHandlers[
$method];
341 foreach ($this->methods as
$method) {
359 'to_entity' => $notification->getRecipient(),
368 $notification->body =
$body;
371 return $notification;
390 if (!isset($this->deprSubjects[
$type])) {
391 $this->deprSubjects[
$type] = array();
412 if (!isset($this->deprSubjects[
$type])) {
416 if (!isset($this->deprSubjects[$type][
$subtype])) {
435 'event' => $event->getAction(),
436 'object_type' =>
$entity->getType(),
439 $hookresult = $this->hooks->trigger(
'object:notifications',
$entity->getType(),
$params,
false);
440 if ($hookresult ===
true) {
441 elgg_deprecated_notice(
"Using the plugin hook 'object:notifications' has been deprecated by the hook 'send:before', 'notifications'", 1.9);
getDeprecatedNotificationBody(\Elgg\Notifications\Notification $notification,\Elgg\Notifications\Event $event, $method)
Get the notification body using a pre-Elgg 1.9 plugin hook.
sendNotification(\Elgg\Notifications\Event $event, $guid, $method)
Send a notification to a subscriber.
if($guid==elgg_get_logged_in_user_guid()) $name
existsDeprecatedNotificationOverride(\Elgg\Notifications\Event $event)
Is someone using the deprecated override.
sendNotifications($event, $subscriptions)
Sends the notifications based on subscriptions.
$guid
Removes an admin notice.
getMethodsAsDeprecatedGlobal()
Provides a way to incrementally wean Elgg's notifications code from the global $NOTIFICATION_HANDLERS...
getDeprecatedHandler($method)
Get a deprecated notification handler callback.
setDeprecatedNotificationSubject($type, $subtype, $subject)
Set message subject for deprecated notification code.
events($event="", $object_type="", $function="", $priority=500, $call=false, $object=null)
Deprecated events core function.
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
get_user($guid)
Get a user object from a GUID.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
enqueueEvent($action, $type, $object)
Add a notification event to the queue.
getDeprecatedNotificationSubject($type, $subtype)
Get the deprecated subject.
__construct(\Elgg\Notifications\SubscriptionsService $subscriptions,\Elgg\Queue\Queue $queue,\Elgg\PluginHooksService $hooks,\ElggSession $session)
Constructor.
has_access_to_entity($entity, $user=null)
Can a user access an entity.
unregisterEvent($type, $subtype)
$language
$vars['language']
registerEvent($type, $subtype, array $actions=array())
registerDeprecatedHandler($method, $handler)
Register a deprecated notification handler.
processQueue($stopTime)
Pull notification events from queue until stop time is reached.
_elgg_notify_user($to, $from, $subject, $message, array $params=null, $methods_override="")
Notify a user via their preferences.