Ignore:
Timestamp:
08/16/11 17:06:14 (13 years ago)
Author:
roberto.santosjunior
Message:

Ticket #1820 - Pesquisa de mensagem por data e importante.r4927

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r4908 r4941  
    37233723                                } 
    37243724                                else{ 
    3725                                         $search_criteria = imap_search($mbox_stream, $filter, SE_UID); 
    3726                                         if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) 
    3727                                         { 
    3728                                             if((!strpos($filter,"FLAGGED") === false) || (!strpos($filter,"UNFLAGGED") === false)) 
     3725                                    if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) 
     3726                                    { 
     3727                                        if((!strpos($filter,"FLAGGED") === false) || (!strpos($filter,"UNFLAGGED") === false)) 
     3728                                        { 
     3729                                            $num_msgs = imap_num_msg($mbox_stream); 
     3730                                            $flagged_msgs = array(); 
     3731                                            for ($i=$num_msgs; $i>0; $i--) 
    37293732                                            { 
    3730                                                 $num_msgs = imap_num_msg($mbox_stream); 
    3731                                                 $flagged_msgs = array(); 
    3732                                                 for ($i=$num_msgs; $i>0; $i--) 
    3733                                                 { 
    3734                                                         $iuid = @imap_uid($this->mbox,$i); 
    3735                                                         $header = $this->get_header($iuid); 
    3736                                                         if(trim($header->Flagged)) 
    3737                                                         { 
    3738                                                                 $flagged_msgs[$i] = $iuid; 
    3739                                                         } 
    3740                                                 } 
    3741                                                 if((count($flagged_msgs) >0) && (strpos($filter,"UNFLAGGED") === false)) 
    3742                                                 { 
    3743                                                     $arry_diff = is_array($search_criteria) ? array_diff($flagged_msgs,$search_criteria):$flagged_msgs; 
    3744                                                     foreach($arry_diff as $msg) 
    3745                                                     { 
    3746                                                         $search_criteria[] = $msg; 
    3747                                                     } 
    3748                                                 } 
    3749                                                 else if((count($flagged_msgs) >0) && (is_array($search_criteria)) && (!strpos($filter,"UNFLAGGED") === false)) 
    3750                                                 { 
    3751                                                     $search_criteria = array_diff($search_criteria,$flagged_msgs); 
    3752                                                 } 
     3733                                                $iuid = @imap_uid($this->mbox,$i); 
     3734                                                $header = $this->get_header($iuid); 
     3735                                                if(trim($header->Flagged)) 
     3736                                                { 
     3737                                                        $flagged_msgs[$i] = $iuid; 
     3738                                                } 
    37533739                                            } 
    3754                                         } 
    3755  
    3756                                         if( is_array( $search_criteria) ) 
    3757                                         { 
    3758                                                 foreach($search_criteria as $new_search) 
    3759                                                 { 
    3760                                                         $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream);  
    3761                                                         $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" );  
    3762                                                         $elem['uid'] = $new_search; 
    3763                                                         /* compare dates in ordering */ 
    3764                                                         $elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2); 
    3765                                                         $retorno[] = $elem; 
    3766                                                 } 
    3767                                         } 
     3740 
     3741                                            $new_filter = trim(preg_replace('/UNFLAGGED|FLAGGED/','',$filter)); 
     3742 
     3743                                            $search_without_flagged = imap_search($mbox_stream, $new_filter, SE_UID); 
     3744 
     3745                                            if (strpos($filter,"UNFLAGGED") === false) 
     3746                                            { 
     3747                                                $search_criteria = array_intersect($search_without_flagged, $flagged_msgs); 
     3748                                            } 
     3749                                            else 
     3750                                            { 
     3751                                                $search_criteria = array_diff($search_without_flagged,$flagged_msgs); 
     3752                                            } 
     3753                                        } 
     3754                                        else 
     3755                                        { 
     3756                                            $search_criteria = imap_search($mbox_stream, $filter, SE_UID); 
     3757                                        } 
     3758                                    } 
     3759                                    else 
     3760                                    { 
     3761                                        $search_criteria = imap_search($mbox_stream, $filter, SE_UID); 
     3762                                    } 
     3763 
     3764                                    if( is_array( $search_criteria) ) 
     3765                                    { 
     3766                                        foreach($search_criteria as $new_search) 
     3767                                        { 
     3768                                            $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 
     3769                                            $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ); 
     3770                                            $elem['uid'] = $new_search; 
     3771                                            /* compare dates in ordering */ 
     3772                                            $elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2); 
     3773                                            $retorno[] = $elem; 
     3774                                        } 
     3775                                    } 
    37683776                                } 
    37693777                        } 
Note: See TracChangeset for help on using the changeset viewer.