You are here

function messaging_store_sent in Messaging 5

Same name and namespace in other branches
  1. 6 messaging.store.inc \messaging_store_sent()
  2. 6.2 messaging.store.inc \messaging_store_sent()
  3. 6.3 messaging.store.inc \messaging_store_sent()

Mark messages as sent, either deleting them, or keeping logs

Parameters

$mqid: Single message id or array of message ids

$log: Optional, just move queue messages to log, for messages on which sending failed

2 calls to messaging_store_sent()
messaging_store_pull_pending in ./messaging.store.inc
Get pending messages for method
messaging_store_queue_process_step in ./messaging.store.inc
Retrieve and send queued messages

File

./messaging.store.inc, line 198
Database storage for the messaging framework

Code

function messaging_store_sent($mqid, $log = FALSE) {
  $mqid = is_array($mqid) ? $mqid : array(
    $mqid,
  );
  list($where, $args) = messaging_store_query(array(
    'mqid' => $mqid,
  ));

  // First delete the ones that are not for logging
  if (!$log) {
    db_query("DELETE FROM {messaging_store} WHERE log = 0 AND " . implode(' AND ', $where), $mqid);
  }

  // Now mark the rest as sent
  $args = array_merge(array(
    time(),
  ), $mqid);
  db_query("UPDATE {messaging_store} SET queue = 0, log = 1, sent = %d WHERE " . implode(' AND ', $where), $args);
}