59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * folders_subscribe.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 | * |
b7f83b61 |
9 | * Subscribe and unsubcribe from folders. |
35586184 |
10 | * Called from folders.php |
11 | * |
12 | * $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
35586184 |
14 | */ |
ef870322 |
15 | |
8f6f9ba5 |
16 | /** Path for SquirrelMail required files. */ |
86725763 |
17 | define('SM_PATH','../'); |
18 | |
19 | /* SquirrelMail required files. */ |
08185f2a |
20 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
21 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
22 | require_once(SM_PATH . 'functions/imap.php'); |
23 | require_once(SM_PATH . 'functions/display_messages.php'); |
11353192 |
24 | |
a32985a5 |
25 | /* globals */ |
1e12d1ff |
26 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
27 | sqgetGlobalVar('username', $username, SQ_SESSION); |
28 | sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); |
29 | sqgetGlobalVar('method', $method, SQ_GET); |
30 | sqgetGlobalVar('mailbox', $mailbox, SQ_POST); |
a32985a5 |
31 | /* end globals */ |
32 | |
32f4e318 |
33 | $location = get_location(); |
52ed2f88 |
34 | |
b7f83b61 |
35 | if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == '') { |
52ed2f88 |
36 | header("Location: $location/folders.php"); |
b7f83b61 |
37 | |
52ed2f88 |
38 | exit(0); |
39 | } |
40 | |
b7f83b61 |
41 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
42 | |
32f4e318 |
43 | if ($method == 'sub') { |
52ed2f88 |
44 | if($no_list_for_subscribe && $imap_server_type == 'cyrus') { |
45 | /* Cyrus, atleast, does not typically allow subscription to |
46 | * nonexistent folders (this is an optional part of IMAP), |
47 | * lets catch it here and report back cleanly. */ |
48 | if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) { |
49 | header("Location: $location/folders.php?success=subscribe-doesnotexist"); |
50 | sqimap_logout($imapConnection); |
51 | exit(0); |
52 | } |
53 | } |
32f4e318 |
54 | for ($i=0; $i < count($mailbox); $i++) { |
55 | $mailbox[$i] = trim($mailbox[$i]); |
56 | sqimap_subscribe ($imapConnection, $mailbox[$i]); |
32f4e318 |
57 | } |
b7f83b61 |
58 | $success = 'subscribe'; |
32f4e318 |
59 | } else { |
60 | for ($i=0; $i < count($mailbox); $i++) { |
61 | $mailbox[$i] = trim($mailbox[$i]); |
62 | sqimap_unsubscribe ($imapConnection, $mailbox[$i]); |
32f4e318 |
63 | } |
b7f83b61 |
64 | $success = 'unsubscribe'; |
32f4e318 |
65 | } |
b7f83b61 |
66 | |
32f4e318 |
67 | sqimap_logout($imapConnection); |
b7f83b61 |
68 | header("Location: $location/folders.php?success=$success"); |
11353192 |
69 | |
f1177e37 |
70 | ?> |