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
16 /** Path for SquirrelMail required files. */
17 define('SM_PATH','../');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'include/validate.php');
21 require_once(SM_PATH
. 'functions/global.php');
22 require_once(SM_PATH
. 'functions/imap.php');
23 require_once(SM_PATH
. 'functions/display_messages.php');
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
);
33 $location = get_location();
35 if (!isset($mailbox) ||
!isset($mailbox[0]) ||
$mailbox[0] == '') {
36 header("Location: $location/folders.php");
41 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
43 if ($method == 'sub') {
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);
54 for ($i=0; $i < count($mailbox); $i++
) {
55 $mailbox[$i] = trim($mailbox[$i]);
56 sqimap_subscribe ($imapConnection, $mailbox[$i]);
58 $success = 'subscribe';
60 for ($i=0; $i < count($mailbox); $i++
) {
61 $mailbox[$i] = trim($mailbox[$i]);
62 sqimap_unsubscribe ($imapConnection, $mailbox[$i]);
64 $success = 'unsubscribe';
67 sqimap_logout($imapConnection);
68 header("Location: $location/folders.php?success=$success");