You are here

function Notifications_Queue::process_compose in Notifications 6.4

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

$destination: 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

File

includes/notifications_queue.class.inc, line 556

Class

Notifications_Queue
Queue management and processing

Code

function process_compose($send_method, $destination, $events, $subscriptions, $send_interval, $langcode = NULL, $module = 'notifications') {
  notifications_log('Processing for sending', array(
    'method' => $send_method,
    'interval' => $send_interval,
    'module' => $module,
    'events' => count($events),
  ));

  // Build message template that will be used for all produced messages
  $template = $this
    ->message_template(array(
    'language' => $langcode,
    'method' => $send_method,
    'send_interval' => $send_interval,
  ));
  $template
    ->set_destination($destination);

  // Find build method for this interval. Check the function is there in case some module has been disabld
  $build_method = $this
    ->build_method($template, array(
    'events' => $events,
    'subscriptions' => $subscriptions,
    'module' => $module,
  ));
  if ($build_method && !empty($build_method['build callback'])) {
    $build_function = $build_method['build callback'];
    $template->digest = !empty($build_method['digest']);
    $template->build_method = $build_method['type'];
  }
  else {

    // Default building function
    $build_function = array(
      $template,
      'build_simple',
    );
    $template->build_method = 'simple';
  }

  // Invoke building function that will return an array of messages
  $messages = call_user_func($build_function, $template, $events, $subscriptions, $module);
  return $messages;
}