You are here

function privatemsg_message_change_delete in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg.module \privatemsg_message_change_delete()
  2. 6 privatemsg.module \privatemsg_message_change_delete()
  3. 7 privatemsg.module \privatemsg_message_change_delete()

Delete or restore a message.

Parameters

$pmid: Message id, pm.mid field.

$delete: Either deletes or restores the thread (1 => delete, 0 => restore)

$account: User account for which the delete action should be carried out. Set to NULL to delete for all users.

Related topics

2 calls to privatemsg_message_change_delete()
PrivatemsgTestCase::testPrivatemsgFlush in ./privatemsg.test
Tests for the flush feature
privatemsg_delete_submit in ./privatemsg.pages.inc

File

./privatemsg.module, line 1631
Allows users to send private messages to other users.

Code

function privatemsg_message_change_delete($pmid, $delete, $account = NULL) {
  $delete_value = 0;
  if ($delete == TRUE) {
    $delete_value = REQUEST_TIME;
  }
  $update = db_update('pm_index')
    ->fields(array(
    'deleted' => $delete_value,
  ))
    ->condition('mid', $pmid);
  if ($account) {
    $update
      ->condition('recipient', $account->uid)
      ->condition('type', array(
      'user',
      'hidden',
    ));
  }
  $update
    ->execute();

  // Allow modules to respond to the deleted changes.
  module_invoke_all('privatemsg_message_status_deleted', $pmid, $delete, $account);
}