You are here

function privatemsg_message_change_delete in Privatemsg 7

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.2 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

3 calls to privatemsg_message_change_delete()
PrivatemsgTestCase::testPrivatemsgFlush in ./privatemsg.test
Tests for the flush feature
privatemsg_delete_submit in ./privatemsg.pages.inc
privatemsg_thread_change_delete in ./privatemsg.module
Delete or restore one or multiple threads.

File

./privatemsg.module, line 1571
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();
}