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