You are here

function privatemsg_delete in Privatemsg 5

Same name and namespace in other branches
  1. 5.3 privatemsg.module \privatemsg_delete()
  2. 6.2 privatemsg.pages.inc \privatemsg_delete()
  3. 6 privatemsg.module \privatemsg_delete()
  4. 7.2 privatemsg.pages.inc \privatemsg_delete()
  5. 7 privatemsg.pages.inc \privatemsg_delete()
1 string reference to 'privatemsg_delete'
privatemsg_menu in ./privatemsg.module
Implementation of hook_menu().

File

./privatemsg.module, line 2005

Code

function privatemsg_delete() {
  global $user;

  // Display the confirmation form for folks without JS.
  if (arg(2) == 'confirm' && ($mid = intval(arg(3))) > 0) {
    $test = db_result(db_query("SELECT id FROM {privatemsg} WHERE (recipient = %d OR author = %d) AND id = %d", $user->uid, $user->uid, $mid));
    if (empty($test)) {
      drupal_goto('privatemsg');
    }
    return drupal_get_form('privatemsg_delete_form', $mid);
  }
  if (arg(2) == 'multiple') {
    if (empty($_SESSION['privatemsg']) || !is_array($_SESSION['privatemsg'])) {
      drupal_goto('priatemsg');
    }
    return drupal_get_form('privatemsg_delete_multiple_form');
  }
  if (($folder = _privatemsg_delete(arg(2))) !== FALSE) {
    drupal_set_message(t('Message deleted.'));
  }
  drupal_goto($folder ? 'privatemsg/list/' . $folder : 'privatemsg');
}