Ignore:
Timestamp:
09/20/12 17:13:44 (12 years ago)
Author:
thiago
Message:

Ticket #3088 - Uma parte da exportação de mensagem foi concluida.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.5.0-expresso1/expressoMail1_2/inc/class.exporteml.inc.php

    r7157 r7261  
    5656        // Rommel Cysne (rommel.cysne@serpro.gov.br) 
    5757        // em 17/12/2008. 
     58 
     59    function createFileEml_by_localFolder($sEMLData, $tempDir, $file){  
     60 
     61        $file = "{$file}.eml"; 
     62 
     63        $f = fopen($tempDir.'/'.$file,"w"); 
     64        if(!$f) 
     65            return False; 
     66 
     67        fputs($f,$sEMLData); 
     68        fclose($f); 
     69         
     70        return $file; 
     71    } 
     72 
    5873        function createFileEml($sEMLData, $tempDir, $id, $subject=false, $i=false) 
    5974    { 
     
    6782  
    6883                        //$subject = preg_replace('/\//', '\'', $subject); 
    69                         $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 
     84                        $from = "áàâãÀéÚêëíìîïóòÎõöúùûÌç?\"!@#$%š&*()-=+ÂŽ`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 
    7085                        $to =   "aaaaaeeeeiiiiooooouuuuc______________________________________________AAAAAEEEEIIIIOOOOOUUUUC"; 
    7186                        $subject = strtr($subject,$from,$to); 
     
    7893 
    7994                        if($subject && $i){ 
    80                                 $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 
     95                                $from = "áàâãÀéÚêëíìîïóòÎõöúùûÌç?\"!@#$%š&*()-=+ÂŽ`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 
    8196                                $to =   "aaaaaeeeeiiiiooooouuuuc______________________________________________AAAAAEEEEIIIIOOOOOUUUUC"; 
    8297                                $subject = strtr($subject,$from,$to); 
     
    8499                                $subject = preg_replace('/[^a-zA-Z0-9_]/i', '_', $subject);  
    85100 
    86                                 // é necessário que a sessão faça parte do nome do arquivo para que o mesmo não venha vazio o.O  
     101                                // é necessário que a sessão faça parte do nome do arquivo para que o mesmo não venha vazio o.O  
    87102                                $file = $subject."_".$i."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".eml";   
    88103                        } else{ 
     
    101116    }  
    102117 
    103         function createFileZip($files, $tempDir){                
     118        function createFileZip($files, $tempDir){        
     119 
    104120                $tmp_zip_filename = "email_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".zip"; 
    105                  
    106121                if (!empty($files)) 
    107122                { 
     
    119134                    } 
    120135                } 
    121                  
    122                 $command = "cd " . escapeshellarg($tempDir) . " && nice zip -m9 " . escapeshellarg($tmp_zip_filename) . " " .  $files; 
     136 
     137 
     138$command = "cd " . escapeshellarg($tempDir) . " && nice zip -m9 " . escapeshellarg($tmp_zip_filename) . " " .  $files; 
     139 
     140 
    123141                if(!exec($command)) { 
    124142                        $command = "cd " .  escapeshellarg($tempDir) . " && rm ".$files." ". escapeshellarg($tmp_zip_filename); 
     
    126144                        return null; 
    127145                } 
    128                  
     146 
    129147                return $tmp_zip_filename; 
    130148                                 
    131149        } 
    132150 
    133         function export_all($params){ 
    134                  
     151function export_all_byLocalFolder($params){ 
     152        $error = false; 
     153 
     154        if(empty($params['messages'])){ 
     155            $file["empty_folder"] = true; 
     156        } else { 
     157            foreach($params['messages'] as $eachMsg){ 
     158               $header = ""; 
     159               $body = ""; 
     160               $tempDir = $this->tempDir; 
     161 
     162               $this->get_header_byLocalFolder($eachMsg, $header); 
     163               $this->get_body_byLocalFolder($eachMsg, $body); 
     164               $sEMLData    = $this->parseEml($header, $body); 
     165               $fileName   = $this->createFileEml_by_localFolder($sEMLData, $tempDir,$eachMsg['msg_number']); 
     166 
     167               if(!$fileName){ 
     168                   $error = true; 
     169                   break; 
     170               } else  
     171                   $fileNames .= "\"".$fileName."\" "; 
     172            } 
     173 
     174            $nameFileZip = 'False';          
     175            if($fileNames && !$error) {          
     176                $nameFileZip = $this->createFileZip($fileNames, $tempDir); 
     177                ($nameFileZip) ? ($file = $tempDir.'/'.$nameFileZip) : ($file = false); 
     178            } else  
     179                $file = false; 
     180        } 
     181        
     182       return $file; 
     183 
     184} 
     185 
     186function get_header_byLocalFolder($eachMsg, &$header){ 
     187    $header = <<<header 
     188        MIME-Version: 1.0 
     189        Content-Type: text/html; charset=ISO-8859-1 
     190        Content-Transfer-Encoding: quoted-printable 
     191        From: "{$eachMsg['from']['name']}" <{$eachMsg['from']['email']}> 
     192        To: {$eachMsg['to']['email']} 
     193        Subject: {$eachMsg['subject']} 
     194        Message-Id: {$eachMsg['msg_number']} 
     195        Date: {$eachMsg['date']} 
     196header; 
     197} 
     198 
     199function get_body_byLocalFolder($eachMsg, &$body){ 
     200    $body = $eachMsg['msg_sample']['body']; 
     201} 
     202 
     203function export_all($params){ 
     204 
    135205                $this->folder = $params['folder']; 
    136206                $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 
     
    140210                 
    141211                $msgs = imap_search($this->mbox_stream,"ALL",SE_UID); 
     212 
    142213                if($msgs){ 
    143214                        foreach($msgs as $nMsgs){ 
    144                                 $header         = $this-> getHeader($nMsgs);                                                                     
    145                                 $body           = $this-> getBody($nMsgs);                       
     215 
     216                                $header         = $this-> getHeader($nMsgs);                                                              
     217                                $body           = $this-> getBody($nMsgs);               
     218 
    146219                                $sEMLData       = $this -> parseEml($header, $body); 
    147220                                $fileName       = $this -> CreateFileEml($sEMLData, $tempDir,$nMsgs); 
     
    182255        // Funcao alterada para que, quando houver   
    183256        // apenas um arquivo a ser exportado,  
    184         // não seja criado em zip  
     257        // não seja criado em zip  
    185258        // 
    186259        // Funcao altarada para exportar uma ou 
     
    481554         
    482555        /* Airton 
    483          * Fazendo o port de um método necessário para o funcionamento do arquivamento local 
     556         * Fazendo o port de um método necessário para o funcionamento do arquivamento local 
    484557         */ 
    485558        //MAILARCHIVER  
     
    509582        }  
    510583        /*Airton  
    511          * Fim do método portado 
     584         * Fim do método portado 
    512585         */  
    513586         
     
    553626        function remove_accents($string) { 
    554627                /* 
    555                         $array1 = array("á", "à", "â", "ã", "ä", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ó", "ò", "ô", "õ", "ö", "ú", "ù", "û", "ü", "ç" , "?", "\"", "!", "@", "#", "$", "%", "š", "&", "*", "(", ")", "-", "=", "+", "Ž", "`", "[", "]", "{", "}", "~", "^", ",", "<", ">", ";", ":", "/", "?", "\\", "|", "¹", "²", "³", "£", "¢", "¬", "§", "ª", "º", "°", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç"); 
     628                        $array1 = array("á", "à", "â", "ã", "À", "é", "Ú", "ê", "ë", "í", "ì", "î", "ï", "ó", "ò", "ÃŽ", "õ", "ö", "ú", "ù", "û", "ÃŒ", "ç" , "?", "\"", "!", "@", "#", "$", "%", "š", "&", "*", "(", ")", "-", "=", "+", "ÂŽ", "`", "[", "]", "{", "}", "~", "^", ",", "<", ">", ";", ":", "/", "?", "\\", "|", "¹", "²", "³", "£", "¢", "¬", "§", "ª", "º", "°", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç"); 
    556629                        $array2 = array("a", "a", "a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "u", "u", "u", "u", "c" , "" , ""  , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" ,  "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "I", "I", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C"); 
    557630                        return str_replace( $array1, $array2, $string ); 
    558631                */ 
    559632                return strtr($string, 
    560                         "áàâãäéèêëíìîïóòôõöúùûüç?\"'!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº°ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ", 
     633                        "áàâãÀéÚêëíìîïóòÎõöúùûÌç?\"'!@#$%š&*()-=+ÂŽ`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº°ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ", 
    561634                        "aaaaaeeeeiiiiooooouuuuc___________________________________________AAAAAEEEEIIIIOOOOOUUUUC"); 
    562635        } 
Note: See TracChangeset for help on using the changeset viewer.