You are here

function notifications_lite_queue_event in Notifications 6.4

Same name and namespace in other branches
  1. 5 notifications_lite/notifications_lite.module \notifications_lite_queue_event()
  2. 6 notifications_lite/notifications_lite.module \notifications_lite_queue_event()
  3. 6.2 notifications_lite/notifications_lite.module \notifications_lite_queue_event()

Insert lite notification into queue if we have a valid destination

This just insert a row into notifications_queue table for this event, so it will be processed on cron The message information (subject, body) will be in the event itself, as serialized parameters

1 call to notifications_lite_queue_event()
notifications_lite_add_to_queue in notifications_lite/notifications_lite.module
Put simple notification into queue

File

notifications_lite/notifications_lite.module, line 140
Simple notifications API

Code

function notifications_lite_queue_event($event) {
  $uid = $event->params['for-uid'];
  $account = notifications_load_user($uid);
  $send_method = messaging_method_default($account);
  if ($destination = messaging_account_build_destination($account, $send_method)) {
    $event
      ->save();
    $queue = array(
      'mdid' => $destination->mdid,
      'uid' => $uid,
      'sid' => 0,
      'module' => 'notifications',
      'eid' => $event->eid,
      'send_interval' => notifications_user_setting('send_interval', $account, 0),
      'send_method' => $send_method,
      'destination' => $destination->address,
      'cron' => 1,
      'created' => time(),
      'conditions' => 0,
    );
    notifications_queue()
      ->queue_item($queue);

    // Run hooks and store for immediate sending
    module_invoke_all('notifications_event', 'queued', $event);
    Notifications_Event::send_immediate($event);
  }
}