Changeset 615 for trunk


Ignore:
Timestamp:
01/16/09 15:40:26 (15 years ago)
Author:
eduardoalex
Message:

Ticket #402

Location:
trunk/expressoMail1_2
Files:
2 added
2 edited

Legend:

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

    r614 r615  
    1010                'get_range_msgs'                                => True, 
    1111                'get_info_msg'                                  => True, 
    12                 'get_folders_list'                              => True 
     12                'get_folders_list'                              => True, 
     13                'import_msgs'                                   => True 
    1314        ); 
    1415 
     
    176177                else 
    177178                        return $this->htmlspecialchars_encode($string); 
     179        } 
     180        /** 
     181        * Função que importa arquivos .eml exportados pelo expresso para a caixa do usuário. Testado apenas 
     182        * com .emls gerados pelo expresso, e o arquivo pode ser um zip contendo vários emls ou um .eml. 
     183        */ 
     184        function import_msgs() { 
     185                 
     186                if(!$this->mbox) 
     187                        $this->mbox = $this->open_mbox($params["folder"]); 
     188                $errors = array(); 
     189                $invalid_format = false; 
     190                $filename = $_FILES['arquivo']['name']; 
     191                if(substr($filename,strlen($filename)-4)==".zip") { 
     192                        $zip = zip_open($_FILES['arquivo']['tmp_name']); 
     193 
     194                        if ($zip) { 
     195                                while ($zip_entry = zip_read($zip)) { 
     196                                         
     197                                        if (zip_entry_open($zip, $zip_entry, "r")) { 
     198                                                $email = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); 
     199                                                $status = @imap_append($this->mbox, 
     200                                                                "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"."INBOX", 
     201                                                                        $email 
     202                                                                        ); 
     203                                                if(!$status) 
     204                                                        array_push($errors,zip_entry_name($zip_entry)); 
     205                                                zip_entry_close($zip_entry); 
     206                                        } 
     207                                } 
     208 
     209                        } 
     210 
     211                        zip_close($zip); 
     212                } 
     213                else if(substr($filename,strlen($filename)-4)==".eml") { 
     214                        $email = implode("",file($_FILES['arquivo']['tmp_name'])); 
     215                        $status = @imap_append($this->mbox, 
     216                                                                "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"."INBOX", 
     217                                                                        $email 
     218                                                                        ); 
     219                        if(!$status) 
     220                                array_push($errors,zip_entry_name($zip_entry)); 
     221                        zip_entry_close($zip_entry); 
     222                } 
     223                else  
     224                { 
     225                        echo "<script>alert(\"".lang("wrong file format")."\")</script>"; 
     226                        $invalid_format = true; 
     227                } 
     228                 
     229                if(!$invalid_format) { 
     230                        if(count($errors)>0) { 
     231                                $message = lang("fail in import:")."\n"; 
     232                                foreach($errors as $arquivo) { 
     233                                        $message.=$arquivo."\n"; 
     234                                } 
     235                                echo "<script>alert(\"$message\")</script>"; 
     236                        } 
     237                        else 
     238                                echo "<script>alert(\"".lang("messages imported successfully")."\")</script>"; 
     239                } 
     240                echo "<script>location.href='/expressoMail1_2/index.php'</script>"; 
    178241        } 
    179242         
  • trunk/expressoMail1_2/js/draw_api.js

    r614 r615  
    23372337                '<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span> | '+ 
    23382338                '<span title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span> | '+ 
    2339                 '<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span>'; 
     2339                '<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span> | ' +  
     2340                '<span title="'+get_lang("Import")+'" class="message_options" onclick="location.href=\'/expressoMail1_2/import.php\'">'+get_lang("Import")+'</span>'; 
    23402341         
    23412342        if (use_spam_filter) { 
Note: See TracChangeset for help on using the changeset viewer.