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