You are here

function notifications_process_compose in Notifications 6.3

Same name and namespace in other branches
  1. 6.2 notifications.cron.inc \notifications_process_compose()

Message composition.

Processes everything, included templating and digestion and sends message/s.

Adds some more information into $message['notifications'] that may be used by other modules

Parameters

$account: User account to send the notification to

$events: Array of loaded event objects to be processed

$subscriptions: Array of arrays of subscription ids (sids) for each event(eid)

Return value

array() Array of messages ready for sending out

1 call to notifications_process_compose()
NotificationsTemplatesTests::testNotificationsTemplates in tests/notifications_templates.test
Play with creating, retrieving, deleting a pair subscriptions

File

./notifications.cron.inc, line 472

Code

function notifications_process_compose($params) {
  notifications_log('Process compose', array(
    'params' => $params,
  ));

  // Digest if send_interval > 0 (not immediate sending)
  $build_method = notifications_build_method($params->send_interval);
  $build_function = $build_method['build callback'];

  // Add sender option parameter if not set
  if (!isset($params->sender_option)) {
    $params->sender_option = variable_get('notifications_sender', 0);
  }

  // If it is a digest build method, build all at once
  if (!empty($build_method['digest'])) {
    $params->digest = $build_method['type'];

    // It can be digested in more than one message by some other digest plug-in
    $messages = $build_function($params);
  }
  else {

    // Build messages array, the function will advance the event
    $messages = array();
    while ($event = current($params->events)) {
      $messages[] = $build_function($event, $params);
      next($params->events);
    }
  }

  // Reset the parameters and return messages
  reset($params->events);
  return $messages;
}