You are here

function notifications_event in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications.module \notifications_event()
  2. 6 notifications.module \notifications_event()
  3. 6.2 notifications.module \notifications_event()
  4. 6.3 notifications.module \notifications_event()
  5. 7 notifications.module \notifications_event()

Process subscriptions events

4 calls to notifications_event()
notifications_content_comment in notifications_content/notifications_content.module
Implementation of hook_comment()
notifications_content_nodeapi in notifications_content/notifications_content.module
Implementation of hook_nodeapi()
notifications_feed_feedapi_after_refresh in notifications_feed/notifications_feed.module
Implementation of hook_feedapi_after_refresh()
notifications_lite_add_to_queue in notifications_lite/notifications_lite.module
Put simple notification into queue

File

./notifications.module, line 229
Notifications module

Code

function notifications_event($event) {
  global $user;

  // Fill in event with default values, that can be changed by modules implementing hook_notifications('event trigger', ..)
  // Such modules can mark the event to be discarded changing the 'save' and 'queue' options
  $event += array(
    'uid' => $user->uid,
    'load_args' => '',
    'created' => time(),
    'module' => 'notifications',
    // Module that triggered the event
    'type' => '',
    // Object/event type
    'action' => '',
    // Action that happened to the object
    'params' => array(),
  );

  // Check whether we have to save and queue this event, defaults to yes if not set
  $info = variable_get('notifications_events', array());
  if (isset($info[$event['type']][$event['action']]) && !$info[$event['type']][$event['action']]) {

    // Do not store nor queue this event, can be changed by plug-in modules
    $event += array(
      'save' => FALSE,
      'queue' => FALSE,
    );
  }
  else {
    $event += array(
      'save' => TRUE,
      'queue' => TRUE,
    );
  }
  $event = (object) $event;

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

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

  // Send event to queue for subscriptions, unless marked not to
  if ($event->queue) {
    notifications_queue($event);
  }
  return $event;
}