making script work correctly when draft is resumed. Tagging some parts that
[squirrelmail.git] / src / delete_message.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * delete_message.php
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 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');
acb177ab 23include_once(SM_PATH . 'functions/display_messages.php');
86725763 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
acb177ab 36global $data_dir;
f38b7cf0 37/* end globals */
0b97a708 38
acb177ab 39/* get $compose_new_win */
40$compose_new_win=getPref($data_dir,$username,'compose_new_win',0);
41
42/**
43 * Script is used when draft is saved again or sent.
44 * browser should be redirected to compose.php (compose_new_win=1)
45 * or right_main.php
46 * Problem: drafts folder listing is not refreshed when
47 * compose_new_win=1.
48 */
98a9cc03 49if (sqGetGlobalVar('saved_draft', $tmp, SQ_GET)) {
50 $saved_draft = urlencode($tmp);
0b97a708 51}
98a9cc03 52if (sqGetGlobalVar('mail_sent', $tmp, SQ_GET)) {
53 $mail_sent = urlencode($tmp);
0b97a708 54}
acb177ab 55/**
56 * Script is used in search page.
57 * browser should be redirected to search.php
58 * Is it really used in search page?
59 */
98a9cc03 60if (sqGetGlobalVar('where', $tmp, SQ_FORM)) {
61 $where = urlencode($tmp);
fc266700 62}
98a9cc03 63if (sqGetGlobalVar('what', $tmp, SQ_FORM)) {
64 $what = urlencode($tmp);
fc266700 65}
acb177ab 66/**
67 * FIXME: which part of code uses it?
68 */
98a9cc03 69if (sqGetGlobalVar('sort', $tmp, SQ_FORM)) {
134e4174 70 $sort = (int) $tmp;
0b97a708 71}
98a9cc03 72if (sqGetGlobalVar('startMessage', $tmp, SQ_FORM)) {
134e4174 73 $startMessage = (int) $tmp;
0b97a708 74}
75
65c3ec94 76$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
77
acb177ab 78// FIXME: unchecked use of variables.
65c3ec94 79sqimap_mailbox_select($imapConnection, $mailbox);
d4467150 80
acb177ab 81// FIXME: unchecked use of variables.
abafb676 82sqimap_messages_delete($imapConnection, $message, $message, $mailbox,$bypass_trash);
65c3ec94 83if ($auto_expunge) {
84 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
85}
439166c1 86
65c3ec94 87$location = get_location();
7058a2a9 88
acb177ab 89/**
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)
94 */
95if (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");
99 } else {
100 $draft_message = _("Draft Saved");
101 header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) .
102 "&startMessage=1&note=".urlencode($draft_message));
103 }
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");
108 } else {
109 $draft_message = _("Your Message has been sent.");
110 header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) .
111 "&startMessage=1&note=".urlencode($draft_message));
112 }
113} elseif (isset($where) && isset($what)) {
114 // FIXME: I suspect that part of code is obsolete
9b761dbd 115 header("Location: $location/search.php?where=" . $where .
116 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
acb177ab 117} else {
118 header("Location: $location/right_main.php?startMessage=$startMessage&mailbox=" .
119 urlencode($mailbox));
65c3ec94 120}
65c3ec94 121sqimap_logout($imapConnection);
acb177ab 122?>