/**
* imap_mailbox.php
*
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* This implements all functions that manipulate mailboxes
*
+ * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
* @subpackage imap
function sqimap_mailbox_delete ($imap_stream, $mailbox) {
global $data_dir, $username;
sqimap_unsubscribe ($imap_stream, $mailbox);
- $read_ary = sqimap_run_command($imap_stream, 'DELETE ' .
- sqimap_encode_mailbox_name($mailbox),
- true, $response, $message);
- if ($response !== 'OK') {
- // subscribe again
- sqimap_subscribe ($imap_stream, $mailbox);
- } else {
- do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
- removePref($data_dir, $username, "thread_$mailbox");
- removePref($data_dir, $username, "collapse_folder_$mailbox");
+
+ if (sqimap_mailbox_exists($imap_stream, $mailbox)) {
+
+ $read_ary = sqimap_run_command($imap_stream, 'DELETE ' .
+ sqimap_encode_mailbox_name($mailbox),
+ true, $response, $message);
+ if ($response !== 'OK') {
+ // subscribe again
+ sqimap_subscribe ($imap_stream, $mailbox);
+ } else {
+ do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
+ removePref($data_dir, $username, "thread_$mailbox");
+ removePref($data_dir, $username, "collapse_folder_$mailbox");
+ }
}
}
$folder_prefix, $delimiter, $trash_folder, $move_to_trash,
$imap_server_type, $show_only_subscribed_folders;
+ // TODO: implement mailbox tree caching. maybe store object in session?
+
$noselect = false;
$noinferiors = false;
$has_inbox = false;
for ($i = 0, $cnt = count($lsub_ary); $i < $cnt; $i++) {
- if (preg_match("/^\*\s+$lsub_cmd.*\s\"?INBOX\"?[^(\/\.)].*$/i",$lsub_ary[$i])) {
+ if (preg_match("/^\*\s+$lsub_cmd.*\s\"?INBOX\"?\s*$/i",$lsub_ary[$i])) {
$lsub_ary[$i] = strtoupper($lsub_ary[$i]);
// in case of an unsubscribed inbox an imap server can
// return the inbox in the lsub results with a \NoSelect