You are here

function Notifications_Scheduler_Event::process in Notifications 7

Process event, send pending notifications. Subscriptions start on $counter (min sid)

Parameters

$limit: Maximum number of subscriptions to process

File

notifications_scheduler/notifications_scheduler.inc, line 94
Drupal Notifications Framework - Default class file

Class

Notifications_Scheduler_Event
Notifications Schedule Event class

Code

function process($limit = 10) {
  while ($limit && ($subscriptions = $this
    ->get_subscriptions($limit))) {
    $limit = $limit - count($subscriptions);

    // New value for the counter if this goes right
    $counter = max(array_keys($subscriptions));

    // Turn subscriptions into batches, groups, etc...
    $groups = $this
      ->prepare_subscriptions($subscriptions);

    // Now process groups one at a time
    foreach ($groups as $group) {
      $results = $this
        ->process_group($groups);
    }

    // Update counter on the event record
    $this
      ->update_counter($counter);
  }
  if (!empty($counter)) {

    // We will do more processing later
    $this
      ->release();
  }
  else {

    // Nothing to process, delete all this
    $this
      ->delete();
  }
}