function Notifications_Queue::queue_event in Notifications 6.4
Queue events for notifications adding query conditions from plug-ins
This is an example of the resulting query
INSERT INTO {notifications_queue} (uid, sid, module, eid, send_interval, send_method, cron, created, conditions) SELECT DISTINCT s.uid, s.sid, s.module, 34, s.send_interval, s.send_method, s.cron, 1230578161, s.conditions FROM notifications s INNER JOIN notifications_fields f ON s.sid = f.sid WHERE s.status = 1 AND s.event_type = 'node' AND s.send_interval >= 0 AND ((f.field = 'nid' AND f.value = '2') OR (f.field = 'type' AND f.value = 'story') OR (f.field = 'author' AND f.value = '1')) GROUP BY s.uid, s.sid, s.module, s.send_interval, s.send_method, s.cron, s.conditions HAVING s.conditions = count(f.sid)
Parameters
$event: Event object
Return value
int Number of queued rows
File
- includes/
notifications_queue.class.inc, line 779
Class
- Notifications_Queue
- Queue management and processing
Code
function queue_event($event) {
notifications_include('object.inc');
notifications_include('query.inc');
$query = array();
// Build big insert query using the query builder. The fields for this event type will be added by the plug-ins.
// If no arguments retrieved, skip this step
if ($query_args = module_invoke_all('notifications_event', 'query', $event)) {
// Build a query skeleton and add parameters for each module separately
$query = notifications_query_event_queue($event);
foreach ($query_args as $query_params) {
$query = notifications_query_build($query_params, $query);
}
// Give a chance to other modules to alter the query or empty it so we don't throw it
drupal_alter('notifications_query', $query, $event);
// Finally we build the SELECT part of the query and glue it to the INSERT
if ($query) {
list($sql, $args) = notifications_query_sql($query);
db_query($sql, $args);
}
}
// Return number of queued rows
return db_result(db_query('SELECT COUNT(*) FROM {notifications_queue} WHERE eid = %d', $event->eid));
}