Changeset 286 in subversion
- Timestamp:
- Jul 31, 2006 3:08:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcube_imap.inc
r285 r286 37 37 * @package RoundCube Webmail 38 38 * @author Thomas Bruederli <roundcube@gmail.com> 39 * @version 1. 2639 * @version 1.30 40 40 * @link http://ilohamail.org 41 41 */ … … 519 519 else 520 520 { 521 $sorter = new rcube_header_sorter(); 522 521 523 // retrieve headers from IMAP 522 524 if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 523 525 { 526 $sorter->set_sequence_numbers($msg_index); 527 524 528 $msgs = $msg_index[$begin]; 525 529 for ($i=$begin+1; $i < $end; $i++) … … 561 565 // if not already sorted 562 566 if (!$headers_sorted) 563 $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);564 565 566 if (!$headers_sorted &&$this->sort_order == 'DESC')567 $a_msg_headers = array_reverse($a_msg_headers);568 567 { 568 $sorter->sort_headers($a_msg_headers); 569 570 if ($this->sort_order == 'DESC') 571 $a_msg_headers = array_reverse($a_msg_headers); 572 } 569 573 570 574 return array_values($a_msg_headers); 571 575 } 572 576 577 578 579 580 581 function gethdrids($hdr) 582 { 583 return $hdr->uid . ',' . $hdr->id; 584 } 585 586 587 573 588 574 589 /** … … 2047 2062 2048 2063 2049 2050 2051 function quoted_printable_encode($input="", $line_max=76, $space_conv=false) 2064 /** 2065 * rcube_header_sorter 2066 * 2067 * Class for sorting an array of iilBasicHeader objects in a predetermined order. 2068 * 2069 * @author Eric Stadtherr 2070 */ 2071 class rcube_header_sorter 2072 { 2073 var $sequence_numbers = array(); 2074 2075 /** 2076 * set the predetermined sort order. 2077 * 2078 * @param array $seqnums numerically indexed array of IMAP message sequence numbers 2079 */ 2080 function set_sequence_numbers($seqnums) 2081 { 2082 $this->sequence_numbers = $seqnums; 2083 } 2084 2085 /** 2086 * sort the array of header objects 2087 * 2088 * @param array $headers array of iilBasicHeader objects indexed by UID 2089 */ 2090 function sort_headers(&$headers) 2091 { 2092 /* 2093 * uksort would work if the keys were the sequence number, but unfortunately 2094 * the keys are the UIDs. We'll use uasort instead and dereference the value 2095 * to get the sequence number (in the "id" field). 2096 * 2097 * uksort($headers, array($this, "compare_seqnums")); 2098 */ 2099 uasort($headers, array($this, "compare_seqnums")); 2100 } 2101 2102 /** 2103 * get the position of a message sequence number in my sequence_numbers array 2104 * 2105 * @param integer $seqnum message sequence number contained in sequence_numbers 2106 */ 2107 function position_of($seqnum) 2108 { 2109 $c = count($this->sequence_numbers); 2110 for ($pos = 0; $pos <= $c; $pos++) 2111 { 2112 if ($this->sequence_numbers[$pos] == $seqnum) 2113 return $pos; 2114 } 2115 return -1; 2116 } 2117 2118 /** 2119 * Sort method called by uasort() 2120 */ 2121 function compare_seqnums($a, $b) 2122 { 2123 // First get the sequence number from the header object (the 'id' field). 2124 $seqa = $a->id; 2125 $seqb = $b->id; 2126 2127 // then find each sequence number in my ordered list 2128 $posa = $this->position_of($seqa); 2129 $posb = $this->position_of($seqb); 2130 2131 // return the relative position as the comparison value 2132 $ret = $posa - $posb; 2133 return $ret; 2134 } 2135 } 2136 2137 2138 /** 2139 * Add quoted-printable encoding to a given string 2140 * 2141 * @param string $input string to encode 2142 * @param int $line_max add new line after this number of characters 2143 * @param boolena $space_conf true if spaces should be converted into =20 2144 * @return encoded string 2145 */ 2146 function quoted_printable_encode($input, $line_max=76, $space_conv=false) 2052 2147 { 2053 2148 $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
Note: See TracChangeset
for help on using the changeset viewer.
