Drop unused file imap_search.php.
[squirrelmail.git] / src / folders_subscribe.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * folders_subscribe.php
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
91e0dccc 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 20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
08185f2a 23require_once(SM_PATH . 'include/validate.php');
8650e9e1 24require_once(SM_PATH . 'functions/global.php');
86725763 25require_once(SM_PATH . 'functions/imap.php');
26require_once(SM_PATH . 'functions/display_messages.php');
11353192 27
a32985a5 28/* globals */
1e12d1ff 29sqgetGlobalVar('key', $key, SQ_COOKIE);
30sqgetGlobalVar('username', $username, SQ_SESSION);
31sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
32sqgetGlobalVar('method', $method, SQ_GET);
33sqgetGlobalVar('mailbox', $mailbox, SQ_POST);
a32985a5 34/* end globals */
35
32f4e318 36$location = get_location();
52ed2f88 37
b7f83b61 38if (!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 46if ($method == 'sub') {
52ed2f88 47 if($no_list_for_subscribe && $imap_server_type == 'cyrus') {
48 /* Cyrus, atleast, does not typically allow subscription to
134e4174 49 * nonexistent folders (this is an optional part of IMAP),
52ed2f88 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 70sqimap_logout($imapConnection);
b7f83b61 71header("Location: $location/folders.php?success=$success");
11353192 72
134e4174 73?>