59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * folders_subscribe.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Subscribe and unsubcribe form folders. |
10 | * Called from folders.php |
11 | * |
12 | * $Id$ |
13 | */ |
ef870322 |
14 | |
35586184 |
15 | require_once('../src/validate.php'); |
16 | require_once('../functions/imap.php'); |
17 | require_once('../functions/display_messages.php'); |
11353192 |
18 | |
32f4e318 |
19 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
11353192 |
20 | |
32f4e318 |
21 | $location = get_location(); |
52ed2f88 |
22 | |
23 | if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == "") { |
24 | header("Location: $location/folders.php"); |
25 | sqimap_logout($imapConnection); |
26 | exit(0); |
27 | } |
28 | |
32f4e318 |
29 | if ($method == 'sub') { |
52ed2f88 |
30 | if($no_list_for_subscribe && $imap_server_type == 'cyrus') { |
31 | /* Cyrus, atleast, does not typically allow subscription to |
32 | * nonexistent folders (this is an optional part of IMAP), |
33 | * lets catch it here and report back cleanly. */ |
34 | if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) { |
35 | header("Location: $location/folders.php?success=subscribe-doesnotexist"); |
36 | sqimap_logout($imapConnection); |
37 | exit(0); |
38 | } |
39 | } |
40 | |
32f4e318 |
41 | for ($i=0; $i < count($mailbox); $i++) { |
42 | $mailbox[$i] = trim($mailbox[$i]); |
43 | sqimap_subscribe ($imapConnection, $mailbox[$i]); |
44 | header("Location: $location/folders.php?success=subscribe"); |
45 | } |
46 | } else { |
47 | for ($i=0; $i < count($mailbox); $i++) { |
48 | $mailbox[$i] = trim($mailbox[$i]); |
49 | sqimap_unsubscribe ($imapConnection, $mailbox[$i]); |
50 | header("Location: $location/folders.php?success=unsubscribe"); |
51 | } |
52 | } |
32f4e318 |
53 | sqimap_logout($imapConnection); |
11353192 |
54 | |
32f4e318 |
55 | /* |
56 | displayPageHeader($color, 'None'); |
57 | echo "<BR><BR><BR><CENTER><B>"; |
58 | if ($method == "sub") { |
59 | echo _("Subscribed Successfully!"); |
60 | echo "</B><BR><BR>"; |
61 | echo _("You have been successfully subscribed."); |
62 | } else { |
63 | echo _("Unsubscribed Successfully!"); |
64 | echo "</B><BR><BR>"; |
65 | echo _("You have been successfully unsubscribed."); |
66 | } |
67 | echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>"; |
68 | echo _("Click here"); |
69 | echo "</A> "; |
70 | echo _("to continue."); |
71 | echo "</CENTER>"; |
72 | echo "</BODY></HTML>"; |
73 | */ |
f1177e37 |
74 | ?> |