phpdocumentor preparation and a few corrections to earlier phpdocumentor work
[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);
30/* end globals */
0b97a708 31
32if (isset($_GET['saved_draft'])) {
9b761dbd 33 $saved_draft = urlencode($_GET['saved_draft']);
0b97a708 34}
35if (isset($_GET['mail_sent'])) {
9b761dbd 36 $mail_sent = urlencode($_GET['mail_sent']);
0b97a708 37}
fc266700 38if (isset($_GET['sort'])) {
39 $sort = (int) $_GET['sort'];
40}
41
42if (isset($_GET['startMessage'])) {
43 $startMessage = (int) $_GET['startMessage'];
44}
0b97a708 45
46if(isset($_GET['where'])) {
9b761dbd 47 $where = urlencode($_GET['where']);
0b97a708 48}
49if(isset($_GET['what'])) {
9b761dbd 50 $what = urlencode($_GET['what']);
0b97a708 51}
52
65c3ec94 53$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
54
55sqimap_mailbox_select($imapConnection, $mailbox);
d4467150 56
65c3ec94 57sqimap_messages_delete($imapConnection, $message, $message, $mailbox);
58if ($auto_expunge) {
59 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
60}
9c3e6cd4 61if (!isset($saved_draft)) {
62 $saved_draft = '';
63}
acaa9842 64
439166c1 65if (!isset($mail_sent)) {
66 $mail_sent = '';
67}
68
65c3ec94 69$location = get_location();
7058a2a9 70
65c3ec94 71if (isset($where) && isset($what)) {
9b761dbd 72 header("Location: $location/search.php?where=" . $where .
73 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
65c3ec94 74} else {
854000c0 75 if (!empty($saved_draft) || !empty($mail_sent)) {
732fd5a4 76 header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
9c3e6cd4 77 }
78 else {
732fd5a4 79 header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
e02775fe 80 urlencode($mailbox));
9c3e6cd4 81 }
65c3ec94 82}
a48fbf9b 83
65c3ec94 84sqimap_logout($imapConnection);
e02775fe 85
5e9e90fd 86?>