4 * folders_subscribe.php
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Subscribe and unsubcribe from folders.
10 * Called from folders.php
13 * @package squirrelmail
17 * Path for SquirrelMail required files.
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'include/validate.php');
24 require_once(SM_PATH
. 'functions/global.php');
25 require_once(SM_PATH
. 'functions/imap.php');
26 require_once(SM_PATH
. 'functions/display_messages.php');
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
);
36 $location = get_location();
38 if (!isset($mailbox) ||
!isset($mailbox[0]) ||
$mailbox[0] == '') {
39 header("Location: $location/folders.php");
44 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
46 if ($method == 'sub') {
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);
57 for ($i=0; $i < count($mailbox); $i++
) {
58 $mailbox[$i] = trim($mailbox[$i]);
59 sqimap_subscribe ($imapConnection, $mailbox[$i]);
61 $success = 'subscribe';
63 for ($i=0; $i < count($mailbox); $i++
) {
64 $mailbox[$i] = trim($mailbox[$i]);
65 sqimap_unsubscribe ($imapConnection, $mailbox[$i]);
67 $success = 'unsubscribe';
70 sqimap_logout($imapConnection);
71 header("Location: $location/folders.php?success=$success");