* Support for LIST-SUBSCRIBED capability.
[squirrelmail.git] / functions / imap_mailbox.php
index 128b27a1f2fa4c5d474a053e658f1af6e89c4e70..a5e50c7f0402f5e115cd7cbd67259461a8c7437e 100755 (executable)
@@ -744,7 +744,7 @@ function sqimap_mailbox_list($imap_stream, $force=false) {
            * 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);
@@ -764,7 +764,9 @@ function sqimap_mailbox_list($imap_stream, $force=false) {
                 $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
@@ -1105,6 +1107,7 @@ function sqimap_fill_mailbox_tree($mbx_ary, $mbxs=false,$imap_stream) {
  * @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
@@ -1112,7 +1115,7 @@ function sqimap_utf7_decode_mbx_tree(&$mbx_tree) {
    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]);
       }
    }
 }
@@ -1210,4 +1213,46 @@ function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
     }
 }
 
-?>
\ 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;
+}
+
+?>