You are here

function nofitications_digest_event_info in Notifications 6.2

Same name and namespace in other branches
  1. 5 notifications.cron.inc \nofitications_digest_event_info()
  2. 6 notifications.cron.inc \nofitications_digest_event_info()
  3. 6.3 notifications_digest/notifications_digest.module \nofitications_digest_event_info()

Get digest information for an event.

From the event definition (notifications('event types')) we find out

  • which event object we'll use for digesting
  • which field of that object to use for indexing

I.e. for event type = 'node', event action = 'update' 'digest' => ('node', 'nid')

2 calls to nofitications_digest_event_info()
NotificationsTemplatesTests::testNotificationsTemplates in tests/notifications_templates.test
Play with creating, retrieving, deleting a pair subscriptions
notifications_process_digest_short in ./notifications.cron.inc
Digest multiple events in a single message, short format.

File

./notifications.cron.inc, line 751

Code

function nofitications_digest_event_info($event, $module = 'notifications') {
  $info = notifications_event_types($event->type, $event->action);
  if (!empty($info['digest'])) {
    $type = $info['digest'][0];
    $field = $info['digest'][1];

    // Check object and values, the object may be the event itself
    if ($type == 'event') {
      $object = $event;
    }
    else {
      $object = !empty($event->objects[$type]) ? $event->objects[$type] : NULL;
    }
  }
  else {

    // No digest info for this event /action so we use event and action itselves.
    $type = $event->type;
    $field = $event->action;
    $object = NULL;
  }
  $value = $object && isset($object->{$field}) ? $object->{$field} : 0;
  return array(
    'type' => $type,
    'field' => $field,
    'value' => $value,
    'object' => $object,
    'module' => $module,
  );
}