You are here

public static function Messaging_Store::message_sent in Messaging 6.4

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

Parameters

$mqid: Single message id or array of message ids

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

1 call to Messaging_Store::message_sent()
Messaging_Store::queue_process_step in includes/messaging_store.class.inc
Retrieve and send queued messages

File

includes/messaging_store.class.inc, line 348
Database storage for the messaging framework

Class

Messaging_Store
Default storage and queueing system for Messaging

Code

public static function message_sent($mqid, $error = FALSE) {
  $mqid = is_array($mqid) ? $mqid : array(
    $mqid,
  );
  $where = self::query_fields(array(
    'mqid' => $mqid,
  ));
  if ($error) {

    // Error, log them all, sent = 0
    $sent = 0;
  }
  else {

    // First delete the ones that are not for logging, then mark as sent
    db_query("DELETE FROM {messaging_store} WHERE log = 0 AND " . implode(' AND ', $where['where']), $where['args']);
    $sent = time();
  }

  // Now unmark the rest for queue processing, as logs
  $args = array_merge(array(
    $sent,
  ), $where['args']);
  db_query("UPDATE {messaging_store} SET queue = 0, cron = 0, log = 1, sent = %d WHERE " . implode(' AND ', $where['where']), $args);
}