You are here

function notifications_load_event in Notifications 6.3

Same name and namespace in other branches
  1. 5 notifications.cron.inc \notifications_load_event()
  2. 6 notifications.cron.inc \notifications_load_event()
  3. 6.2 notifications.cron.inc \notifications_load_event()

Get events with static caching. Handle event deletion if not available anymore

1 call to notifications_load_event()
notifications_process_rows in ./notifications.cron.inc
Process rows given query conditions

File

./notifications.cron.inc, line 631

Code

function notifications_load_event($id) {
  $cache =& messaging_static(__FUNCTION__);
  if (!$cache || !array_key_exists($id, $cache)) {
    $event = db_fetch_object(db_query("SELECT * FROM {notifications_event} WHERE eid = %d", $id));
    $event->params = unserialize($event->params);

    // Load aditional objects for the event
    $event->objects = array();
    notifications_module_invoke('event load', $event);

    // Check event status, it may need deletion if objects are not available
    if (!empty($event->delete)) {
      notifications_event_tracker('delete', $event);
      $event = NULL;
    }
    $cache[$id] = $event;
  }
  return $cache[$id];
}