Changeset 970
- Timestamp:
- 06/10/09 15:32:32 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r877 r970 1650 1650 function messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd) 1651 1651 { 1652 $sort = array(); 1653 if ($offsetBegin > $offsetEnd) {$temp=$offsetEnd; $offsetEnd=$offsetBegin; $offsetBegin=$temp;} 1654 $num_msgs = imap_num_msg($this->mbox); 1655 if ($offsetEnd > $num_msgs) {$offsetEnd = $num_msgs;} 1656 if ($search_box_type == "" && $sort_box_type == "SORTARRIVAL") 1657 { 1658 // If I'm looking for any type of email doesn't need to see all imap box 1652 if ($search_box_type == "" || $search_box_type == "ALL"){ 1653 $imapsort = imap_sort($this->mbox,constant($sort_box_type),$sort_box_reverse,SE_UID,$search_box_type); 1654 foreach($imapsort as $iuid) 1655 $sort[$iuid] = ""; 1656 $slice_array = true; 1657 } 1658 else 1659 { 1660 $sort = array(); 1661 if ($offsetBegin > $offsetEnd) {$temp=$offsetEnd; $offsetEnd=$offsetBegin; $offsetBegin=$temp;} 1662 $num_msgs = imap_num_msg($this->mbox); 1663 if ($offsetEnd > $num_msgs) {$offsetEnd = $num_msgs;} 1664 if ($sort_box_type == "SORTARRIVAL") 1665 { 1666 // If I'm looking for arrival order we doesn't need to see all imap box 1667 if ($sort_box_reverse) 1668 { 1669 $numBegin = $num_msgs - $offsetEnd; 1670 if ($numBegin < 0) $numBegin=0; 1671 $numEnd = $num_msgs - ($offsetBegin-1); 1672 } 1673 else 1674 { 1675 $numBegin = ($offsetBegin-1); 1676 $numEnd = $offsetEnd; 1677 } 1678 $slice_array = false; 1679 } 1680 else 1681 { 1682 // If I'm looking for a specific type of email I have to see entire imap box 1683 $numBegin = 0; 1684 $numEnd = $num_msgs; 1685 $slice_array = true; 1686 } 1687 for ($i=$numBegin+1; $i<=$numEnd; $i++) 1688 { 1689 $iuid = @imap_uid($this->mbox,$i); 1690 $header = $this->get_header($iuid); 1691 // List UNSEEN messages. 1692 if($search_box_type == "UNSEEN" && (!trim($header->Recent) && !trim($header->Unseen))){ 1693 continue; 1694 } 1695 // List SEEN messages. 1696 elseif($search_box_type == "SEEN" && (trim($header->Recent) || trim($header->Unseen))){ 1697 continue; 1698 } 1699 // List ANSWERED messages. 1700 elseif($search_box_type == "ANSWERED" && !trim($header->Answered)){ 1701 continue; 1702 } 1703 // List FLAGGED messages. 1704 elseif($search_box_type == "FLAGGED" && !trim($header->Flagged)){ 1705 continue; 1706 } 1707 1708 if($sort_box_type=='SORTFROM') { 1709 if (($header->from[0]->mailbox . "@" . $header->from[0]->host) == $_SESSION['phpgw_info']['expressomail']['user']['email']) 1710 $from = $header->to; 1711 else 1712 $from = $header->from; 1713 1714 $tmp = imap_mime_header_decode($from[0]->personal); 1715 1716 if ($tmp[0]->text != "") 1717 $sort[$iuid] = $tmp[0]->text; 1718 else 1719 $sort[$iuid] = $from[0]->mailbox . "@" . $from[0]->host; 1720 } 1721 else if($sort_box_type=='SORTSUBJECT') { 1722 $sort[$iuid] = $header->subject; 1723 } 1724 else if($sort_box_type=='SORTSIZE') { 1725 $sort[$iuid] = $header->Size; 1726 } 1727 else { 1728 $sort[$iuid] = $header->udate; 1729 } 1730 1731 } 1732 natcasesort($sort); 1733 1659 1734 if ($sort_box_reverse) 1660 { 1661 $numBegin = $num_msgs - $offsetEnd; 1662 if ($numBegin < 0) $numBegin=0; 1663 $numEnd = $num_msgs - ($offsetBegin-1); 1664 } 1665 else 1666 { 1667 $numBegin = ($offsetBegin-1); 1668 $numEnd = $offsetEnd; 1669 } 1670 $slice_array = false; 1671 } 1672 else 1673 { 1674 // If I'm looking for a specific type of email I have to see entire imap box 1675 $numBegin = 0; 1676 $numEnd = $num_msgs; 1677 $slice_array = true; 1678 } 1679 for ($i=$numBegin+1; $i<=$numEnd; $i++) 1680 { 1681 $iuid = @imap_uid($this->mbox,$i); 1682 $header = $this->get_header($iuid); 1683 // List UNSEEN messages. 1684 if($search_box_type == "UNSEEN" && (!trim($header->Recent) && !trim($header->Unseen))){ 1685 continue; 1686 } 1687 // List SEEN messages. 1688 elseif($search_box_type == "SEEN" && (trim($header->Recent) || trim($header->Unseen))){ 1689 continue; 1690 } 1691 // List ANSWERED messages. 1692 elseif($search_box_type == "ANSWERED" && !trim($header->Answered)){ 1693 continue; 1694 } 1695 // List FLAGGED messages. 1696 elseif($search_box_type == "FLAGGED" && !trim($header->Flagged)){ 1697 continue; 1698 } 1699 1700 if($sort_box_type=='SORTFROM') { 1701 if (($header->from[0]->mailbox . "@" . $header->from[0]->host) == $_SESSION['phpgw_info']['expressomail']['user']['email']) 1702 $from = $header->to; 1703 else 1704 $from = $header->from; 1705 1706 $tmp = imap_mime_header_decode($from[0]->personal); 1707 1708 if ($tmp[0]->text != "") 1709 $sort[$iuid] = $tmp[0]->text; 1710 else 1711 $sort[$iuid] = $from[0]->mailbox . "@" . $from[0]->host; 1712 } 1713 else if($sort_box_type=='SORTSUBJECT') { 1714 $sort[$iuid] = $header->subject; 1715 } 1716 else if($sort_box_type=='SORTSIZE') { 1717 $sort[$iuid] = $header->Size; 1718 } 1719 else { 1720 $sort[$iuid] = $header->udate; 1721 } 1722 1723 } 1724 natcasesort($sort); 1725 1726 if ($sort_box_reverse) 1727 $sort = array_reverse($sort,true); 1735 $sort = array_reverse($sort,true); 1736 } 1728 1737 1729 1738 if ($slice_array) 1730 1739 $sort = array_slice($sort,$offsetBegin-1,$offsetEnd-($offsetBegin-1),true); 1740 1731 1741 return $sort; 1732 1742 1733 1743 } 1734 1744 1745 1735 1746 function move_search_messages($params){ 1736 1747 $params['selected_messages'] = urldecode($params['selected_messages']);
Note: See TracChangeset
for help on using the changeset viewer.