Ignore:
Timestamp:
02/22/12 18:04:20 (12 years ago)
Author:
douglasz
Message:

Ticket #1875 - Commit inicial do codigo das funcionalidades de marcadores e sinalizadores

File:
1 edited

Legend:

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

    r5520 r5533  
    157157 
    158158        function get_range_msgs2($params) 
    159         {  
     159        {        
    160160            // Free others requests 
    161161            session_write_close(); 
     
    193193                                    $sample = true; 
    194194                                             
    195                                     $return[$i] = $this->get_info_head_msg( $msg_number , $sample ) ; 
     195                                    $return[$i] = $this->get_info_head_msg( $msg_number , $sample ); 
    196196                                    $i++; 
    197197                            } 
     
    228228                return $return; 
    229229    } 
    230      
     230         
     231         
     232        function getMessages($params) { 
     233                $result = array(); 
     234 
     235                $exporteml = new ExportEml(); 
     236                $unseen_msgs = array(); 
     237                 
     238                foreach($params['messages'] as $folder => $messages) { 
     239                        foreach($messages as $msg_number) { 
     240 
     241                                $this->mbox = $this->open_mbox($folder); 
     242                         
     243                                if (isset($params['details']) && $params['details'] == 'all') { 
     244                                        $message = $this->get_info_msg(array('msg_number' => $msg_number, 'msg_folder' =>urlencode($folder))); 
     245                                } else { 
     246                                        $message['headers'] = $this->get_info_head_msg($msg_number, true); 
     247                                        //$message['attachments'] = $exporteml->get_attachments_in_array(array("num_msg" => $msg_number)); 
     248                                } 
     249 
     250                                imap_close($this->mbox); 
     251                                $this->mbox = false; 
     252 
     253                                if($msg_info['Unseen'] == "U" || $msg_info['Recent'] == "N") { 
     254                                        array_push($unseen_msgs,$msg_number); 
     255                                } 
     256                                 
     257                                $result[$folder][] = $message; 
     258                        } 
     259                        if($unseen_msgs){ 
     260                                $msgs_list = implode(",",$unseen_msgs); 
     261                                $array_msgs = array('folder' => $folder, "msgs_to_set" => $msgs_list, "flag" => "unseen"); 
     262                                $this->set_messages_flag($array_msgs); 
     263                        } 
     264                } 
     265                 
     266                return $result; 
     267        }        
     268 
    231269        /** 
    232270        *  Decodifica uma string no formato mime RFC2047 
     
    731769                        $array_msgs = array('folder' => $new_params["msg_folder"], "msgs_to_set" => $msgs_list, "flag" => "unseen"); 
    732770                        $this->set_messages_flag($array_msgs); 
    733                 } 
     771                }                                        
     772                                         
    734773                return $return; 
    735774        } 
    736         } 
     775} 
    737776 
    738777        /** 
     
    50845123        } 
    50855124         
    5086         function parseCriteriaSearchMail($search) 
    5087         { 
    5088             $criteria = ''; 
    5089             $searchArray = explode(' ', $search); 
    5090  
    5091             foreach ($searchArray as $v) 
    5092                 if(trim($v) !== '' ) 
    5093                     $criteria .= 'TEXT "'.$v.'" ' ; 
    5094             
    5095             return $criteria; 
    5096         } 
     5125        function parseCriteriaSearchMail($search) 
     5126        { 
     5127                $criteria = ''; 
     5128                $searchArray = explode(' ', $search); 
     5129 
     5130                foreach ($searchArray as $v) 
     5131                        if(trim($v) !== '' ) 
     5132                                $criteria .= 'TEXT "'.$v.'" ' ; 
     5133            
     5134                return $criteria; 
     5135        } 
    50975136         
    50985137        function quickSearchMail( $params ) 
    50995138        { 
     5139                include '../prototype/api/controller.php'; 
    51005140                $return = array(); 
    51015141                $return['folder'] = $params['folder']; 
     
    51145154                $count = 0; 
    51155155                 
    5116                 $search = $this->parseCriteriaSearchMail($params['search']); 
    5117                                  
     5156                if (!preg_match('/KEYWORD/i', $params['search'])){ 
     5157                        $search = $this->parseCriteriaSearchMail($params['search']); 
     5158                } else { 
     5159                        $search = $params['search']; 
     5160                } 
     5161         
    51185162                foreach ($params['folder'] as $folder)  
    51195163                { 
     
    51395183                                        $return['msgs'][$i]['subject'] .= mb_convert_encoding($tmp->text, 'UTF-8', 'UTF-8 , ISO-8859-1'); 
    51405184                                 
    5141                                  
     5185                                $filter = array('AND', array('=', 'folderName', $folder), array('=','messageNumber', $v)); 
     5186                                $followupflagged = Controller::find( 
     5187                                        array('concept' => 'followupflagged'), 
     5188                                        false,  
     5189                                        array('filter' => $filter, 'criteria' => array('deepness' => '2')) 
     5190                                ); 
     5191                                foreach ($followupflagged as $i => $v) 
     5192                                        { 
     5193                                                if(isset($v['followupflagId'])) 
     5194                                                { 
     5195                                                        $followupflag = Controller::find( array( 'concept' => 'followupflag' ) , false, array( 'filter' => array('=', 'id'  ,  $v['followupflagId']) ));      
     5196                                                        $followupflagged[$i]['followupflag'] = $followupflag[0]; 
     5197                                                } 
     5198 
     5199                                        } 
     5200                                         
     5201                                $labeleds = Controller::find( 
     5202                                        array('concept' => 'labeled'), 
     5203                                        false,  
     5204                                        array('filter' => $filter, 'criteria' => array('deepness' => '2')) 
     5205                                ); 
     5206                                                 
    51425207                                $return['msgs'][$i]['flag'] = ' '; 
    51435208                                $return['msgs'][$i]['flag'] .= $msg->Unseen ? $msg->Unseen : ''; 
     
    51545219                                $return['msgs'][$i]['boxname'] = $folder; 
    51555220                                $return['msgs'][$i]['uid'] = $v; 
     5221                                $return['msgs'][$i]['followupflagged'] = $followupflagged[0]; 
     5222                                $return['msgs'][$i]['labels'] = $labeleds; 
    51565223                                $i++; 
    51575224                        }        
Note: See TracChangeset for help on using the changeset viewer.