Changeset 7261 for sandbox


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.

Location:
sandbox/2.5.0-expresso1
Files:
3 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        } 
  • sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js

    r7248 r7261  
    13911391//ONLINE messages_proxy.prototype.messages_list = function(folder,msg_range_begin,emails_per_page,sort_box_type,search_box_type,sort_box_reverse,preview_msg_subject,preview_msg_tip,call_back,tree_name) { 
    13921392//sys call = proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort,search,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box); 
    1393 MailArchiver.prototype.listMessages = function(){ 
     1393MailArchiver.prototype.listMessages = function(folderId){ 
    13941394    try{ 
    13951395        connector.showProgressBar(); 
    13961396        var getcurrent = get_current_folder();        
    13971397        //tree_folders.getNodeById(get_current_folder())._select(); 
    1398         var folderid = this.currentfolder; //getcurrent.substr(6,getcurrent.length); 
     1398        var folderid; 
     1399        if(typeof(folderId) != "undefined"){ 
     1400            folderid = folderId; 
     1401        } else { 
     1402            folderid = this.currentfolder;     
     1403        } 
    13991404        var objfolder = new Object(); 
    14001405        objfolder.folder = folderid;         
  • sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js

    r7220 r7261  
    566566 
    567567                    var name_box = $(this).parents("li:first").attr("id"); 
     568 
     569 
    568570                    var name_folder = name_box.split(cyrus_delimiter)[name_box.split(cyrus_delimiter).length-1]; 
    569571 
     
    571573                        if(!data){ 
    572574                            write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')) 
    573                         }else if(data["empty_folder"]){ 
     575                        }else if(data["empty_folder"] || data == "empty_folder"){ 
    574576                            write_msg(get_lang("The selected folder is empty.")); 
    575577                        }else 
    576578                          download_attachments(null, null, data, null,null, name_folder +'.zip'); 
    577579                    } 
    578                     cExecute("$this.exporteml.export_all",hand_export,"folder="+name_box);   
     580                    if($(this).parents("li:first").find("input[type=hidden]:first").val() == "localFolder"){                         
     581                          expresso_mail_archive.listMessages(name_box.split("_")[2]); 
     582                          var msgsArchive = expresso_mail_archive.messageslisted; 
     583                         
     584                          var array = new Array(); 
     585 
     586                          for(var i =0; i < msgsArchive.length; i++){ 
     587                            eachMsg = { 
     588                                    'ContentType' : msgsArchive[i].ContentType, 
     589                                    'from' : { 'email' : msgsArchive[i].from.email, 'full' : msgsArchive[i].from.full, 'name' : msgsArchive[i].from.name}, 
     590                                    'msg_sample' : msgsArchive[i].msg_sample, 
     591                                    'subject' : msgsArchive[i].subject, 
     592                                    'to' : { 'email' : msgsArchive[i].to.email, 'full' : msgsArchive[i].to.full, 'name' : msgsArchive[i].to.name}, 
     593                                    'toaddress2' : msgsArchive[i].toaddress2, 
     594                                    'msg_number' : msgsArchive[i].msg_number, 
     595                                    'date' : new Date(msgsArchive[i].timestamp).toString()   
     596                            }; 
     597                            array.push(eachMsg); 
     598 
     599                          } 
     600 
     601                            $.ajax({ 
     602                              type: "POST", 
     603                              url: "controller.php?action=$this.exporteml.export_all_byLocalFolder", 
     604                              data: { folder: name_box, type: "msg_local", messages : array} 
     605                              }).done(function(msg) { 
     606                                hand_export(msg.split('"')[1]); 
     607                              }); 
     608                    } else { 
     609                        alert(1); 
     610                          cExecute("$this.exporteml.export_all",hand_export,"folder="+name_box);   
     611                    } 
    579612                    write_msg(get_lang('You must wait while the messages will be exported...'));         
    580613                }); 
Note: See TracChangeset for help on using the changeset viewer.