phpdoc updates
[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_FORM);
29 sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
30
31 sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM);
32
33 /* end globals */
34
35 if (sqGetGlobalVar('saved_draft', $tmp, SQ_GET)) {
36 $saved_draft = urlencode($tmp);
37 }
38 if (sqGetGlobalVar('mail_sent', $tmp, SQ_GET)) {
39 $mail_sent = urlencode($tmp);
40 }
41 if (sqGetGlobalVar('where', $tmp, SQ_FORM)) {
42 $where = urlencode($tmp);
43 }
44 if (sqGetGlobalVar('what', $tmp, SQ_FORM)) {
45 $what = urlencode($tmp);
46 }
47 if (sqGetGlobalVar('sort', $tmp, SQ_FORM)) {
48 $sort = (int) $tmp;
49 }
50 if (sqGetGlobalVar('startMessage', $tmp, SQ_FORM)) {
51 $startMessage = (int) $tmp;
52 }
53
54 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
55
56 sqimap_mailbox_select($imapConnection, $mailbox);
57
58 sqimap_messages_delete($imapConnection, $message, $message, $mailbox,$bypass_trash);
59 if ($auto_expunge) {
60 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
61 }
62 if (!isset($saved_draft)) {
63 $saved_draft = '';
64 }
65
66 if (!isset($mail_sent)) {
67 $mail_sent = '';
68 }
69
70 $location = get_location();
71
72 if (isset($where) && isset($what)) {
73 header("Location: $location/search.php?where=" . $where .
74 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
75 } else {
76 if (!empty($saved_draft) || !empty($mail_sent)) {
77 header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
78 }
79 else {
80 header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
81 urlencode($mailbox));
82 }
83 }
84
85 sqimap_logout($imapConnection);
86
87 ?>