You are here

function Notifications_Event::trigger in Notifications 6.4

Same name and namespace in other branches
  1. 7 notifications.event.inc \Notifications_Event::trigger()

Trigger event. Save, run queue query, etc...

Replaces notifications_event_trigger($event)

File

includes/notifications_event.class.inc, line 263
Drupal Notifications Framework - Default class file

Class

Notifications_Event
Message destination class

Code

function trigger() {

  // Notify other modules we are about to trigger some subscriptions event
  // Modules can do cleanup operations or modify event properties
  module_invoke_all('notifications_event', 'trigger', $this);

  // Store event, unles marked not to be saved
  if ($this->save) {
    $this
      ->save();

    // Send event to queue for subscriptions, unless marked not to
    if ($this->queue) {
      $this->queued = TRUE;
      $this->counter = notifications_queue()
        ->queue_event($this);

      // Modules can do cleanup operations or modify the queue or the event counter
      module_invoke_all('notifications_event', 'queued', $this);
      $count = $this->counter;

      // Now update event counter with rows in notifications_queue or delete if no rows
      if ($count) {
        $this
          ->update_counter($count);

        // If immediate sending enabled, store it for sending on page exit.
        if (variable_get('notifications_send_immediate', 0)) {
          self::send_immediate($this);
        }
      }
      else {
        $this
          ->delete();
      }
    }
  }
}