6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Deletes a meesage from the IMAP server
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 include_once(SM_PATH
. 'functions/display_messages.php');
24 require_once(SM_PATH
. 'functions/imap.php');
27 sqgetGlobalVar('username', $username, SQ_SESSION
);
28 sqgetGlobalVar('key', $key, SQ_COOKIE
);
29 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
31 sqgetGlobalVar('message', $message, SQ_FORM
);
32 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
34 sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM
);
39 /* get $compose_new_win */
40 $compose_new_win=getPref($data_dir,$username,'compose_new_win',0);
43 * Script is used when draft is saved again or sent.
44 * browser should be redirected to compose.php (compose_new_win=1)
46 * Problem: drafts folder listing is not refreshed when
49 if (sqGetGlobalVar('saved_draft', $tmp, SQ_GET
)) {
50 $saved_draft = urlencode($tmp);
52 if (sqGetGlobalVar('mail_sent', $tmp, SQ_GET
)) {
53 $mail_sent = urlencode($tmp);
56 * Script is used in search page.
57 * browser should be redirected to search.php
58 * Is it really used in search page?
60 if (sqGetGlobalVar('where', $tmp, SQ_FORM
)) {
61 $where = urlencode($tmp);
63 if (sqGetGlobalVar('what', $tmp, SQ_FORM
)) {
64 $what = urlencode($tmp);
67 * FIXME: which part of code uses it?
69 if (sqGetGlobalVar('sort', $tmp, SQ_FORM
)) {
72 if (sqGetGlobalVar('startMessage', $tmp, SQ_FORM
)) {
73 $startMessage = (int) $tmp;
76 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
78 // FIXME: unchecked use of variables.
79 sqimap_mailbox_select($imapConnection, $mailbox);
81 // FIXME: unchecked use of variables.
82 sqimap_messages_delete($imapConnection, $message, $message, $mailbox,$bypass_trash);
84 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
87 $location = get_location();
90 * FIXME: rg=on problems with $saved_drafts, $sent_mail, $where and $what
91 * FIXME: current version of squirrelmail contains only two
92 * delete_message.php calls. with saved_draft=yes (compose.php
93 * around line 360) and with mail_sent=yes (compose.php around line 434)
95 if (isset($saved_draft)) {
96 // process resumed and again saved draft
97 if ($compose_new_win == '1') {
98 header("Location: $location/compose.php?saved_draft=yes");
100 $draft_message = _("Draft Saved");
101 header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) .
102 "&startMessage=1¬e=".urlencode($draft_message));
104 } elseif (isset($mail_sent)) {
105 // process resumed and then sent draft
106 if ($compose_new_win == '1') {
107 header("Location: $location/compose.php?mail_sent=yes");
109 $draft_message = _("Your Message has been sent.");
110 header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) .
111 "&startMessage=1¬e=".urlencode($draft_message));
113 } elseif (isset($where) && isset($what)) {
114 // FIXME: I suspect that part of code is obsolete
115 header("Location: $location/search.php?where=" . $where .
116 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
118 header("Location: $location/right_main.php?startMessage=$startMessage&mailbox=" .
119 urlencode($mailbox));
121 sqimap_logout($imapConnection);