Ignore:
Timestamp:
06/16/09 18:29:16 (15 years ago)
Author:
rafaelraymundo
Message:

Ticket #550 - Unificação de funcionalidade do SERPRO referentes ao arquivamento local.

File:
1 edited

Legend:

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

    r711 r1000  
    4444         
    4545        // create EML File. 
    46     function createFileEml($sEMLData, $tempDir, $id)   
     46        // Funcao alterada para tratar a exportacao 
     47        // de mensagens arquivadas localmente. 
     48        // Rommel Cysne (rommel.cysne@serpro.gov.br) 
     49        // em 17/12/2008. 
     50        function createFileEml($sEMLData, $tempDir, $id, $subject=false, $i) 
    4751    { 
    4852        if($id) 
     
    5458                $subject = substr($subject, 0, 59); 
    5559  
    56             $subject = ereg_replace('/', '\'', $subject);             
     60                        //$subject = ereg_replace('/', '\'', $subject); 
     61                        $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº°ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 
     62                        $to =   "aaaaaeeeeiiiiooooouuuuc__________________________________________AAAAAEEEEIIIIOOOOOUUUUC"; 
     63                        $subject = strtr($subject,$from,$to); 
    5764            $file =    $subject."_".$id.".eml"; 
     65                } else{ 
     66                        // Se mensagem for arquivada localmente, $subject (assunto da mensagem) 
     67                        // sera passado para compor o nome do arquivo .eml; 
     68 
     69                        if($subject){ 
     70                                $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº°ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 
     71                                $to =   "aaaaaeeeeiiiiooooouuuuc__________________________________________AAAAAEEEEIIIIOOOOOUUUUC"; 
     72                                $subject = strtr($subject,$from,$to); 
     73                                //$subject = ereg_replace(':', '_', $subject); 
     74                                //$subject = ereg_replace('/', '_', $subject); 
     75                                $file = $subject."_".$i.".eml"; 
     76                        } else{ 
     77                                $file = "email_".md5(microtime()).".eml"; 
    5878        }     
    59         else{ 
    60             $file =    "email_".md5(microtime()).".eml"; 
    6179        } 
    6280         
     
    124142        } 
    125143 
     144        // Funcao alterada para tratar a exportacao 
     145        // de mensagens arquivadas localmente. 
     146        // Rommel Cysne (rommel.cysne@serpro.gov.br) 
     147        // em 17/12/2008. 
    126148        function makeAll($params) { 
    127                  
    128                 $this-> folder = $params['folder']; 
    129                 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 
    130                 $array_ids = explode(',', $params['msgs_to_export']);    
    131                 $error = False;          
    132                 $fileNames = ""; 
    133                 $tempDir = ini_get("session.save_path"); 
    134                 $this->connectImap(); 
    135                                  
    136                 for($i = 0; $i < count($array_ids); $i++) { 
    137                                  
     149                // Exportacao de mensagens arquivadas localmente 
     150                if($params['l_msg'] == "t"){ 
     151                // Recebe todos os subjects e bodies das mensagens locais selecionadas para exportacao 
     152                // e gera arrays com os conteudos separados; 
     153                $array_mesgs = explode('@@',$params['mesgs']); 
     154                $array_subjects = explode('@@',$params['subjects']); 
     155            $array_ids = explode(',', $params['msgs_to_export']); 
     156            $tempDir = ini_get("session.save_path"); 
     157                        // Para cada mensagem selecionada sera gerado um arquivo .eml cujo titulo sera o assunto (subject) da mesma; 
     158                        include_once("class.imap_functions.inc.php"); 
     159                        $imapf = new imap_functions(); 
     160                foreach($array_ids as $i=>$id) { 
     161                                $sEMLData=$imapf->treat_base64_from_post($array_mesgs[$i]); 
     162                                $fileName=$this->CreateFileEml($sEMLData, $tempDir,'',$array_subjects[$i],$i); 
     163                                if(!$fileName){ 
     164                                        $error = True; 
     165                                        break; 
     166                                } else{ 
     167                                        $fileNames .= "\"".$fileName."\" "; 
     168                                } 
     169                        } 
     170                        $nameFileZip = 'False'; 
     171                        if($fileNames && !$error) { 
     172                                $nameFileZip = $this -> createFileZip($fileNames, $tempDir); 
     173                                if($nameFileZip){ 
     174                                        $file = $tempDir.'/'.$nameFileZip; 
     175                                } else{ 
     176                                        $file = false; 
     177                                } 
     178 
     179                        } else{ 
     180                                $file = false; 
     181                        } 
     182 
     183            return $file; 
     184 
     185                // Exportacao de mensagens da caixa de entrada (imap) - processo original do Expresso 
     186                } else{ 
     187            $this-> folder = $params['folder']; 
     188            $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 
     189            $array_ids = explode(',', $params['msgs_to_export']); 
     190            $error = False; 
     191            $fileNames = ""; 
     192            $tempDir = ini_get("session.save_path"); 
     193            $this->connectImap(); 
     194                        for($i = 0; $i < count($array_ids); $i++) { 
    138195                        $header         = $this-> getHeader($array_ids[$i]);                                                                                     
    139196                        $body           = $this-> getBody($array_ids[$i]);                       
     
    165222                         
    166223                return $file; 
    167         } 
     224        } 
     225    } 
    168226 
    169227        function export_msg($params) { 
     
    209267                imap_close($this->mbox_stream); 
    210268                return $urlPath; 
    211         } 
     269        } 
    212270 
    213271        function remove_accents($string) { 
     
    241299                $imap_attachment = new imap_attachment(); 
    242300                $attachments = $imap_attachment->download_attachment($this->mbox_stream, $id_number); 
    243                  
    244  
    245                  
    246301                foreach($attachments as $i => $attachment){ 
    247302                        if($i && $i == 'names') 
     
    280335                imap_close($this->mbox_stream); 
    281336                return $return_attachments; 
    282         } 
     337        } 
    283338         
    284339        private function getFileType($nameFile) { 
Note: See TracChangeset for help on using the changeset viewer.