Minor cleanups
[squirrelmail.git] / functions / imap_mailbox.php
index 13238ee33b998c4141d5a5d3d0548be54fe4edc6..4faef27bd36a3fef123a1ac50f000a1a665ffcae 100755 (executable)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * imap_mailbox.php
  *
@@ -247,80 +248,6 @@ function sqimap_mailbox_expunge ($imap_stream, $mailbox, $handle_errors = true,
     return $cnt;
 }
 
-/**
- * Expunge specified message, updated $msgs and $msort
- *
- * Until Marc and I come up with a better way to maintain
- * these stupid arrays, we'll use this wrapper function to
- * remove the message with the matching UID .. the order
- * won't be changed - the array element for the message
- * will just be removed.
- */
-function sqimap_mailbox_expunge_dmn($message_id, $aMbxResponse, &$server_sort_array)
-{
-    global $msgs, $msort, $sort, $imapConnection,
-           $mailbox, $auto_expunge,
-           $sort, $allow_server_sort, $thread_sort_messages, $allow_thread_sort,
-           $username, $data_dir;
-    $cnt = 0;
-
-    if (!isset($sort) || $sort === false) {
-        sqgetGlobalVar('sort',$sort,SQ_GET);
-    }
-    // Got to grab this out of prefs, since it isn't saved from mailbox_view.php
-    if ($allow_thread_sort) {
-        $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox",0);
-    }
-
-    for ($i = 0; $i < count($msort); $i++) {
-        if ($msgs[$i]['ID'] == $message_id) {
-            break;
-        }
-    }
-
-    if ( isset($msgs) ) {
-        unset($msgs[$i]);
-        $msgs = array_values($msgs);
-        sqsession_register($msgs, 'msgs');
-    }
-
-    if ( isset($msort) ) {
-        unset($msort[$i]);
-        $msort = array_values($msort);
-        sqsession_register($msort, 'msort');
-    }
-
-    if ($auto_expunge) {
-         $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-    } else {
-         return $cnt;
-    }
-
-    // And after all that mucking around, update the sort list!
-    // Remind me why the hell we need those two arrays again?!
-
-    if ( $allow_thread_sort && $thread_sort_messages ) {
-        $server_sort_array = get_thread_sort($imapConnection);
-    } elseif ( $allow_server_sort ) {
-        if (is_array($server_sort_array)) {
-            $key = array_search($message_id,$server_sort_array,true);
-            if ($key !== false) {
-                unset($server_sort_array[$key]);
-                $server_sort_array = array_values($server_sort_array);
-            } else {
-                $server_sort_array = sqimap_get_sort_order($imapConnection,$sort,$aMbxResponse);
-            }
-        } else {
-            $server_sort_array = sqimap_get_sort_order($imapConnection,$sort,$aMbxResponse);
-        }
-    } else {
-        $server_sort_array = sqimap_get_php_sort_order($imapConnection,
-                                                   $sort,$aMbxResponse);
-    }
-    sqsession_register($server_sort_array,'server_sort_array');
-    return $cnt;
-}
-
 /**
  * Checks whether or not the specified mailbox exists
  */
@@ -558,7 +485,7 @@ function sqimap_mailbox_parse ($line, $line_lsub) {
 /**
  * Returns list of options (to be echoed into select statement
  * based on available mailboxes and separators
- * Caller should surround options with <SELECT..> </SELECT> and
+ * Caller should surround options with <select ...> </select> and
  * any formatting.
  *   $imap_stream - $imapConnection to query for mailboxes
  *   $show_selected - array containing list of mailboxes to pre-select (0 if none)
@@ -588,7 +515,8 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk
     }
 
     foreach ($boxes as $boxes_part) {
-        if ($flag == NULL || !in_array($flag, $boxes_part['flags'])) {
+        if ($flag == NULL || (is_array($boxes_part['flags'])
+                      && !in_array($flag, $boxes_part['flags']))) {
             $box = $boxes_part['unformatted'];
 
             if ($folder_skip != 0 && in_array($box, $folder_skip) ) {
@@ -615,9 +543,9 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk
                 }
             }
             if ($show_selected != 0 && in_array($lowerbox, $show_selected) ) {
-                $mbox_options .= '<OPTION VALUE="' . htmlspecialchars($box) .'" SELECTED>'.$box2.'</OPTION>' . "\n";
+                $mbox_options .= '<option value="' . htmlspecialchars($box) .'" selected="selected">'.$box2.'</option>' . "\n";
             } else {
-                $mbox_options .= '<OPTION VALUE="' . htmlspecialchars($box) .'">'.$box2.'</OPTION>' . "\n";
+                $mbox_options .= '<option value="' . htmlspecialchars($box) .'">'.$box2.'</option>' . "\n";
             }
         }
     }
@@ -1127,4 +1055,4 @@ function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
     }
 }
 
-?>
+?>
\ No newline at end of file