function privatemsg_message_change_delete

1 privatemsg.module privatemsg_message_change_delete($pmid, $delete, $account = NULL)
7-1 privatemsg.module privatemsg_message_change_delete($pmid, $delete, $account = NULL)
7-2 privatemsg.module privatemsg_message_change_delete($pmid, $delete, $account = NULL)
6-2 privatemsg.module privatemsg_message_change_delete($pmid, $delete, $account = NULL)

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()

File

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