/** * Get the subscriptions for this notification event * * The return array is of the form: * * array( * <user guid> => array('email', 'sms', 'ajax'), * ); * * @param NotificationEvent $event Notification event * @return array */ public function getSubscriptions(NotificationEvent $event) { $subscriptions = array(); if (!$this->methods) { return $subscriptions; } $object = $event->getObject(); if (!$object) { return $subscriptions; } // get subscribers only for \ElggEntity if it isn't private if ($object instanceof \ElggEntity && $object->access_id !== ACCESS_PRIVATE) { $prefixLength = strlen(self::RELATIONSHIP_PREFIX); $records = $this->getSubscriptionRecords($object->getContainerGUID()); foreach ($records as $record) { $deliveryMethods = explode(',', $record->methods); $subscriptions[$record->guid] = substr_replace($deliveryMethods, '', 0, $prefixLength); } } $params = array('event' => $event, 'origin' => Notification::ORIGIN_SUBSCRIPTIONS); return _elgg_services()->hooks->trigger('get', 'subscriptions', $params, $subscriptions); }
/** * Get the notification body using a pre-Elgg 1.9 plugin hook * * @param Notification $notification Notification * @param NotificationEvent $event Event * @param string $method Method * @return Notification */ protected function getDeprecatedNotificationBody(Notification $notification, NotificationEvent $event, $method) { $entity = $event->getObject(); if (!$entity) { return $notification; } $params = array('entity' => $entity, 'to_entity' => $notification->getRecipient(), 'method' => $method); $subject = $this->getDeprecatedNotificationSubject($entity->getType(), $entity->getSubtype()); $string = $subject . ": " . $entity->getURL(); $body = $this->hooks->trigger('notify:entity:message', $entity->getType(), $params, $string); if ($subject) { $notification->subject = $subject; $notification->body = $body; } return $notification; }