You are here

function privatemsg_empty_folder_form_submit in Privatemsg 5.3

Same name and namespace in other branches
  1. 5 privatemsg.module \privatemsg_empty_folder_form_submit()

File

./privatemsg.module, line 1346

Code

function privatemsg_empty_folder_form_submit($form_id, $form_values) {
  global $user;
  $fid = intval(arg(2));
  if ($fid == 0 || $form_values['empty'] != 1) {
    drupal_goto('privatemsg/folders');
  }
  if ($fid == 1) {
    db_query("UPDATE {privatemsg} SET author_del = 1 WHERE author = %d", $user->uid);
  }
  else {
    if ($fid > 1 && !db_result(db_query('SELECT fid FROM {privatemsg_folder} WHERE fid = %d AND uid = %d', $fid, $user->uid))) {
      watchdog('privatemsg', t('Attempted use of unauthorized folder'), WATCHDOG_WARNING);
      return drupal_access_denied();
    }
    else {
      db_query("UPDATE {privatemsg} SET recipient_del = 1 WHERE folder = %d AND recipient = %d", $fid, $user->uid);
    }
  }
  drupal_set_message(t('Folder emptied.'));
  drupal_goto('privatemsg/folders');
}