XHTML fixes
[squirrelmail.git] / src / delete_message.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * delete_message.php
5 *
82d304a0 6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
65c3ec94 9 * Deletes a meesage from the IMAP server
35586184 10 *
30967a1e 11 * @version $Id$
8f6f9ba5 12 * @package squirrelmail
35586184 13 */
ef870322 14
30967a1e 15/**
16 * Path for SquirrelMail required files.
17 * @ignore
18 */
86725763 19define('SM_PATH','../');
20
21/* SquirrelMail required files. */
08185f2a 22require_once(SM_PATH . 'include/validate.php');
86725763 23require_once(SM_PATH . 'functions/display_messages.php');
24require_once(SM_PATH . 'functions/imap.php');
d3cdb279 25
f38b7cf0 26/* get globals */
27sqgetGlobalVar('username', $username, SQ_SESSION);
28sqgetGlobalVar('key', $key, SQ_COOKIE);
29sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
30
98a9cc03 31sqgetGlobalVar('message', $message, SQ_FORM);
f38b7cf0 32sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
abafb676 33
98a9cc03 34sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM);
abafb676 35
f38b7cf0 36/* end globals */
0b97a708 37
98a9cc03 38if (sqGetGlobalVar('saved_draft', $tmp, SQ_GET)) {
39 $saved_draft = urlencode($tmp);
0b97a708 40}
98a9cc03 41if (sqGetGlobalVar('mail_sent', $tmp, SQ_GET)) {
42 $mail_sent = urlencode($tmp);
0b97a708 43}
98a9cc03 44if (sqGetGlobalVar('where', $tmp, SQ_FORM)) {
45 $where = urlencode($tmp);
fc266700 46}
98a9cc03 47if (sqGetGlobalVar('what', $tmp, SQ_FORM)) {
48 $what = urlencode($tmp);
fc266700 49}
98a9cc03 50if (sqGetGlobalVar('sort', $tmp, SQ_FORM)) {
51 $sort = (int) $tmp;
0b97a708 52}
98a9cc03 53if (sqGetGlobalVar('startMessage', $tmp, SQ_FORM)) {
54 $startMessage = (int) $tmp;
0b97a708 55}
56
65c3ec94 57$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
58
59sqimap_mailbox_select($imapConnection, $mailbox);
d4467150 60
abafb676 61sqimap_messages_delete($imapConnection, $message, $message, $mailbox,$bypass_trash);
65c3ec94 62if ($auto_expunge) {
63 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
64}
9c3e6cd4 65if (!isset($saved_draft)) {
66 $saved_draft = '';
67}
acaa9842 68
439166c1 69if (!isset($mail_sent)) {
70 $mail_sent = '';
71}
72
65c3ec94 73$location = get_location();
7058a2a9 74
65c3ec94 75if (isset($where) && isset($what)) {
9b761dbd 76 header("Location: $location/search.php?where=" . $where .
77 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
65c3ec94 78} else {
854000c0 79 if (!empty($saved_draft) || !empty($mail_sent)) {
732fd5a4 80 header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
9c3e6cd4 81 }
82 else {
732fd5a4 83 header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
e02775fe 84 urlencode($mailbox));
9c3e6cd4 85 }
65c3ec94 86}
a48fbf9b 87
65c3ec94 88sqimap_logout($imapConnection);
e02775fe 89
5e9e90fd 90?>