correctly detect \Noselect in LSUB responses, and set $mbx->is_noselect
authorrobsiemb <robsiemb@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 29 Aug 2002 15:43:38 +0000 (15:43 +0000)
committerrobsiemb <robsiemb@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 29 Aug 2002 15:43:38 +0000 (15:43 +0000)
so that the folder tree does not allow you to select a nonexistant
mailbox

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3507 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_mailbox.php

index 9c0605e38b0cf09f7dbe0a950046a30c3dfcec8f..aed2c4328fa4beccbc7e29f0e220fc72ce5a0b5d 100755 (executable)
@@ -75,13 +75,15 @@ function sortSpecialMbx($a, $b) {
     return ($acmp>$bcmp) ? 1: -1;
 }      
 
-
 function find_mailbox_name ($mailbox) {
     if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs))
         return $regs[1];
     ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs);
     return $regs[1];
-    
+}
+
+function check_is_noselect ($lsub_line) {
+    return preg_match("/^\* LSUB \([^\)]*\\Noselect[^\)]*\)/i", $lsub_line);
 }
 
 /**
@@ -740,10 +742,11 @@ function sqimap_mailbox_tree($imap_stream) {
 //             $sorted_lsub_ary[] = array ('mbx' => $mbx, 'flag' => $flag); 
 //         }
            $mbx = find_mailbox_name($lsub_ary[$i]);
+           $noselect = check_is_noselect($lsub_ary[$i]);
            if (substr($mbx, -1) == $delimiter) {
                $mbx = substr($mbx, 0, strlen($mbx) - 1);
            }
-           $sorted_lsub_ary[] = array ('mbx' => $mbx, 'flag' => ''); 
+           $sorted_lsub_ary[] = array ('mbx' => $mbx, 'noselect' => $noselect); 
         }
        array_multisort($sorted_lsub_ary, SORT_ASC, SORT_REGULAR);
 
@@ -861,6 +864,8 @@ function sqimap_fill_mailbox_tree($mbx_ary, $mbxs=false) {
            if (isset($mbx_ary[$i]['nummessages'])) {
                $mbx->total = $mbx_ary[$i]['nummessages'];
            }
+
+           $mbx->is_noselect = $mbx_ary[$i]['noselect'];
            
             $r_del_pos = strrpos($mbx_ary[$i]['mbx'], $delimiter);
            if ($r_del_pos) {