You are here

function privatemsg_attachments_privatemsg_message_flush in Privatemsg 6.2

Implements hook_privatemsg_message_flush().

File

privatemsg_attachments/privatemsg_attachments.module, line 333
Allows users to add attachments to messages

Code

function privatemsg_attachments_privatemsg_message_flush($message) {
  if (!isset($message['files'])) {
    return;
  }
  foreach ($message['files'] as $fid => $file) {

    // Delete all files associated with the node
    db_query('DELETE FROM {files} WHERE fid = %d', $fid);
    file_delete($file->filepath);
  }

  // Delete all file revision information associated with the node
  db_query('DELETE FROM {pm_attachments} WHERE mid = %d', $message['mid']);
}