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