fixed warning when attachments aren't set
[squirrelmail.git] / functions / imap_mailbox.php
index 0cae70822d952b131522e978cc4b2f8cb5550e50..8553beca3fbf101956e0a3e2ce64920470027f64 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * imap_mailbox.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This impliments all functions that manipulate mailboxes
@@ -107,27 +107,28 @@ function readMailboxParent($haystack, $needle) {
 
 
 function isBoxBelow( $box2, $box1 ) {
-    global $delimiter, $folder_prefix, $imap_server_type;
-
-    if ( $imap_server_type == 'uw' ) {
-        $boxs = $box2;
-        $i = strpos( $box1, $delimiter, strlen( $folder_prefix ) );
-        if ( $i === false ) {
-            $i = strlen( $box2 );
-        }
-    } else {
-        $boxs = $box2 . $delimiter;
-        /* Skip next second delimiter */
-        $i = strpos( $box1, $delimiter );
-        $i = strpos( $box1, $delimiter, $i + 1  );
-        if ( $i === false ) {
-            $i = strlen( $box2 );
-        } else {
-            $i++;
-        }
-    }
-
-    return ( substr( $box1, 0, $i ) == substr( $boxs, 0, $i ) );
+global $delimiter, $folder_prefix, $imap_server_type;
+       if ( $imap_server_type == 'uw' ) {
+               $boxs = $box2;
+               $i = strpos( $box1, $delimiter, strlen( $folder_prefix ) );
+               if ( $i === false ) {
+                       $i = strlen( $box2 );
+               }
+       } else {
+               if (substr($box2,0,strlen($box1)) == $box1) {
+                       return true;
+               }
+               $boxs = $box2 . $delimiter;
+               /* Skip next second delimiter */
+               $i = strpos( $box1, $delimiter );
+               $i = strpos( $box1, $delimiter, $i + 1  );
+               if ( $i === false ) {
+                       $i = strlen( $box2 );
+               } else {
+                       $i++;
+               }
+       }
+       return ( substr( $box1, 0, $i ) == substr( $boxs, 0, $i ) );
 }
 
 /* Defines special mailboxes */
@@ -136,14 +137,13 @@ function isSpecialMailbox( $box ) {
            $move_to_trash, $move_to_sent, $save_as_draft;
 
     $ret = ( (strtolower($box) == 'inbox') ||
-             ( $move_to_trash && isBoxBelow( $box, $trash_folder ) ) ||
-             ( $move_to_sent && isBoxBelow( $box, $sent_folder )) ||
+             ( $move_to_trash && $trash_folder && isBoxBelow( $box, $trash_folder )) ||
+             ( $move_to_sent  && $sent_folder  && isBoxBelow( $box, $sent_folder  )) ||
              ($save_as_draft && $box == $draft_folder ) );
 
     if ( !$ret ) {
         $ret = do_hook_function( 'special_mailbox', $box );
     }
-
     return $ret;
 }
 
@@ -936,4 +936,5 @@ function sqimap_fill_mailbox_tree($mbx_ary, $mbxs=false) {
 
     return $mailboxes;
 }
+
 ?>