/**
* 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");
+ }
}
}
* in other words, we cannot rely on it.
*/
$sorted_list_ary = array();
- // if (!$listsubscribed) {
+ if (!$listsubscribed && $show_only_subscribed_folders) {
for ($i=0; $i < count($sorted_lsub_ary); $i++) {
if (substr($sorted_lsub_ary[$i], -1) == $delimiter) {
$mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
$sorted_list_ary[$i] = '';
}
}
- // }
+ } else {
+ $sorted_list_ary = $sorted_lsub_ary;
+ }
/*
* Just in case they're not subscribed to their inbox,
* we'll get it for them anyway
* @since 1.5.0
*/
function sqimap_utf7_decode_mbx_tree(&$mbx_tree) {
+
if (strtoupper($mbx_tree->mailboxname_full) == 'INBOX')
$mbx_tree->mailboxname_sub = _("INBOX");
else
if ($mbx_tree->mbxs) {
$iCnt = count($mbx_tree->mbxs);
for ($i=0;$i<$iCnt;++$i) {
- $mbxs_tree->mbxs[$i] = sqimap_utf7_decode_mbx_tree($mbx_tree->mbxs[$i]);
+ sqimap_utf7_decode_mbx_tree($mbx_tree->mbxs[$i]);
}
}
}
}
}
-?>
\ No newline at end of file
+/**
+ * Checks if folder is noselect (can't store messages)
+ *
+ * Function does not check if folder subscribed.
+ * @param stream $oImapStream imap connection resource
+ * @param string $sImapFolder imap folder name
+ * @param object $oBoxes mailboxes class object.
+ * @return boolean true, when folder has noselect flag. false in any other case.
+ * @since 1.5.1
+ */
+function sqimap_mailbox_is_noselect($oImapStream,$sImapFolder,&$oBoxes) {
+ // build mailbox object if it is not available
+ if (! is_object($oBoxes)) $oBoxes=sqimap_mailbox_list($oImapStream);
+ foreach($oBoxes as $box) {
+ if ($box['unformatted']==$sImapFolder) {
+ return (bool) check_is_noselect($box['raw']);
+ }
+ }
+ return false;
+}
+
+/**
+ * Checks if folder is noinferiors (can't store other folders)
+ *
+ * Function does not check if folder subscribed.
+ * @param stream $oImapStream imap connection resource
+ * @param string $sImapFolder imap folder name
+ * @param object $oBoxes mailboxes class object.
+ * @return boolean true, when folder has noinferiors flag. false in any other case.
+ * @since 1.5.1
+ */
+function sqimap_mailbox_is_noinferiors($oImapStream,$sImapFolder,&$oBoxes) {
+ // build mailbox object if it is not available
+ if (! is_object($oBoxes)) $oBoxes=sqimap_mailbox_list($oImapStream);
+ foreach($oBoxes as $box) {
+ if ($box['unformatted']==$sImapFolder) {
+ return (bool) check_is_noinferiors($box['raw']);
+ }
+ }
+ return false;
+}
+
+?>