removed old rcptaddress
[squirrelmail.git] / src / folders_subscribe.php
1 <?php
2
3 /**
4 * folders_subscribe.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
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 */
14
15 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/display_messages.php');
18
19 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
20
21 $location = get_location();
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
29 if ($method == 'sub') {
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
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 }
53 sqimap_logout($imapConnection);
54
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 */
74 ?>