- /**
- * Just in case they're not subscribed to their inbox,
- * we'll get it for them anyway
- */
- if ($inbox_subscribed == false || $inbox_in_list == false) {
- $inbox_ary = sqimap_run_command ($imap_stream, "LIST \"\" \"INBOX\"",
- TRUE, $response, $message);
- /* Another workaround for EIMS */
- if (isset($inbox_ary[1]) &&
- ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
- $inbox_ary[0], $regs)) {
- $inbox_ary[0] = $regs[1] . '"' . addslashes(trim($inbox_ary[1])) .
- '"' . $regs[2];
- }
-
- $sorted_list_ary[] = $inbox_ary[0];
- $sorted_lsub_ary[] = find_mailbox_name($inbox_ary[0]);
+ /*
+ * Section about removing the last element was removed
+ * We don't return "* OK" anymore from sqimap_read_data
+ */
+
+ $sorted_lsub_ary = array();
+ $cnt = count($lsub_ary);
+ for ($i = 0; $i < $cnt; $i++) {
+ $mbx = find_mailbox_name($lsub_ary[$i]);
+
+ // only do the noselect test if !uw, is checked later. FIX ME see conf.pl setting
+ if ($imap_server_type != "uw") {
+ $noselect = check_is_noselect($lsub_ary[$i]);
+ $noinferiors = check_is_noinferiors($lsub_ary[$i]);
+ }
+ if (substr($mbx, -1) == $delimiter) {
+ $mbx = substr($mbx, 0, strlen($mbx) - 1);
+ }
+ $sorted_lsub_ary[] = array ('mbx' => $mbx, 'noselect' => $noselect, 'noinferiors' => $noinferiors);
+ }
+ // FIX ME this requires a config setting inside conf.pl instead of checking on server type
+ if ($imap_server_type == "uw") {
+ $aQuery = array();
+ $aTag = array();
+ // prepare an array with queries
+ foreach ($sorted_lsub_ary as $aMbx) {
+ $mbx = stripslashes($aMbx['mbx']);
+ sqimap_prepare_pipelined_query('LIST "" ' . sqimap_encode_mailbox_name($mbx), $tag, $aQuery, false);
+ $aTag[$tag] = $mbx;
+ }
+ $sorted_lsub_ary = array();
+ // execute all the queries at once
+ $aResponse = sqimap_run_pipelined_command ($imap_stream, $aQuery, false, $aServerResponse, $aServerMessage);
+ foreach($aTag as $tag => $mbx) {
+ if ($aServerResponse[$tag] == 'OK') {
+ $sResponse = implode('', $aResponse[$tag]);
+ $noselect = check_is_noselect($sResponse);
+ $noinferiors = check_is_noinferiors($sResponse);
+ $sorted_lsub_ary[] = array ('mbx' => $mbx, 'noselect' => $noselect, 'noinferiors' => $noinferiors);
+ }
+ }
+ $cnt = count($sorted_lsub_ary);
+ }
+ $sorted_lsub_ary = array_values($sorted_lsub_ary);
+ array_multisort($sorted_lsub_ary, SORT_ASC, SORT_REGULAR);
+ $boxesnew = sqimap_fill_mailbox_tree($sorted_lsub_ary,false,$imap_stream);
+ return $boxesnew;