You are here

function _notifications_scheduler_batch_send in Notifications 7

Batch send event to list of sids

1 string reference to '_notifications_scheduler_batch_send'
_notifications_scheduler_create_batch in notifications_scheduler/notifications_scheduler.admin.inc
Send to a list of subscriptions @todo Create batch

File

notifications_scheduler/notifications_scheduler.admin.inc, line 208

Code

function _notifications_scheduler_batch_send($event, $sids, &$context) {

  // Only the first time we set the event so the same object is updated (and keeps track of sent notifications).
  if (!isset($context['results']['event'])) {
    $context['results'] = array(
      'event' => $event,
      'processed' => array(),
      'sent' => array(),
      'skip' => array(),
    );
  }
  else {
    $event = $context['results']['event'];
  }
  $context['message'] = t('Sending event @event to @count subscriptions.', array(
    '@event' => $event
      ->get_title(),
    '@count' => count($sids),
  ));
  $results = $event
    ->send_list($sids);
  $results += array(
    'processed' => $sids,
  );
  foreach (array(
    'processed',
    'sent',
    'skip',
  ) as $key) {
    $context['results'][$key] = array_merge($context['results'][$key], $results[$key]);
  }
}