function notifications_process_rows in Notifications 6
Same name and namespace in other branches
- 5 notifications.cron.inc \notifications_process_rows()
- 6.2 notifications.cron.inc \notifications_process_rows()
- 6.3 notifications.cron.inc \notifications_process_rows()
Process rows given query conditions
This is used by the immediate sending feature
Parameters
$conditions: Array of query conditions
See also
1 call to notifications_process_rows()
- notifications_exit in ./
notifications.module - Implementation of hook_exit()
1 string reference to 'notifications_process_rows'
- notifications_queue_operations in ./
notifications.admin.inc - List of queue operations
File
- ./
notifications.cron.inc, line 169
Code
function notifications_process_rows($conditions) {
notifications_log('Processing queue rows', $conditions);
$account = NULL;
$subscriptions = $events = $processed = array();
$send_method = $send_interval = NULL;
// Build query and fetch rows from queue
$query = notifications_queue_query($conditions);
$sql = "SELECT * FROM {notifications_queue} ";
$sql .= " WHERE " . implode(' AND ', $query['where']);
$sql .= " ORDER BY uid, send_method, send_interval";
$result = db_query($sql, $query['args']);
// Group rows by user, send_method, send_interval before sending
// This loop has to run a final time after all rows have been fetched
while (($queue = db_fetch_object($result)) || $processed) {
if (!$account || !$queue || $queue->uid != $account->uid || $queue->send_method != $send_method || $queue->send_interval != $send_interval) {
// New user or sending method, send if not the first row and reset
if ($account && $events && $subscriptions) {
notifications_process_send($account, $events, $subscriptions, $send_method, $send_interval);
notifications_update_sent($account->uid, $send_method, $send_interval, time());
}
if ($processed) {
notifications_queue_done(array(
'sqid' => $processed,
));
}
$subscriptions = $events = $processed = array();
if ($queue) {
$account = notifications_load_user($queue->uid);
$send_method = $queue->send_method;
$send_interval = $queue->send_interval;
}
}
if ($queue) {
if ($event = notifications_load_event($queue->eid)) {
notifications_event_tracker('count', $event);
if (notifications_user_allowed('event', $account, $event)) {
$events[$queue->eid] = $event;
$subscriptions[$queue->eid][] = $queue->sid;
}
$processed[] = $queue->sqid;
}
}
}
notifications_event_tracker('update');
}