function _privatemsg_delete_data

7-1 privatemsg.module _privatemsg_delete_data($account)
7-2 privatemsg.module _privatemsg_delete_data($account)

Delete all message data from a user.

2 calls to _privatemsg_delete_data()
privatemsg_user_cancel in ./privatemsg.module
Implements hook_user_cancel().
privatemsg_user_delete in ./privatemsg.module
Implements hook_user_delete().

File

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

Code

function _privatemsg_delete_data($account) {
  $mids = db_select('pm_message', 'pm')->fields('pm', array('mid'))->condition('author', $account->uid)->execute()->fetchCol();

  if (!empty($mids)) {
    // Delete recipient entries in {pm_index} of the messages the user wrote.
    db_delete('pm_index')->condition('mid', $mids)->execute();
  }

  // Delete messages the user wrote.
  db_delete('pm_message')->condition('author', $account->uid)->execute();

  // Delete recipient entries of that user.
  db_delete('pm_index')->condition('recipient', $account->uid)->condition('type', array('user', 'hidden'))->execute();

  // Delete any disable flag for user.
  privatemsg_del_setting('user', $account->uid, 'disabled');
}