Changeset 613


Ignore:
Timestamp:
01/15/09 10:58:13 (15 years ago)
Author:
eduardoalex
Message:

Ticket #400

Location:
trunk/expressoMail1_2
Files:
4 edited

Legend:

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

    r605 r613  
    162162        } 
    163163         
     164        /* 
     165                Remove os anexos de uma mensagem. A estratégia para isso é criar uma mensagem nova sem os anexos, mantendo apenas 
     166                a primeira parte do e-mail, que é o texto, sem anexos. 
     167                O método considera que o email é multpart. 
     168        */ 
     169        function remove_attachments($params) { 
     170                include_once("class.message_components.inc.php"); 
     171                if(!$this->mbox || !is_resource($this->mbox)) 
     172                        $this->mbox = $this->open_mbox($params["folder"]); 
     173                $return["status"] = true; 
     174                $return["msg_num"] = $params["msg_num"]; 
     175                $header = ""; 
     176                 
     177                $headertemp = explode("\n",imap_fetchheader($this->mbox, imap_msgno($this->mbox, $params["msg_num"]))); 
     178                foreach($headertemp as $head) {//Se eu colocar todo o header do email dá pau no append, então procuro apenas o que interessa. 
     179                        $head1 = explode(":",$head); 
     180                        if ( (strtoupper($head1[0]) == strtoupper("to")) ||  
     181                                        (strtoupper($head1[0]) == strtoupper("from")) ||  
     182                                        (strtoupper($head1[0]) == strtoupper("subject")) || 
     183                                        (strtoupper($head1[0]) == strtoupper("date")) ) 
     184                                $header .= $head."\r\n"; 
     185                } 
     186                                 
     187                $msg = &new message_components($this->mbox); 
     188                $msg->fetch_structure($params["msg_num"]);/* O fetchbody tava trazendo o email com problemas na acentuação.  
     189                                                             Então uso essa classe para verificar a codificação e o charset,  
     190                                                             para que o método decodeBody do expresso possa trazer tudo certinho*/ 
     191                 
     192                $status = @imap_append($this->mbox, 
     193                                "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"], 
     194                                        $header. 
     195                                        "\r\n". 
     196                                        str_replace("\n","\r\n",$this->decodeBody( 
     197                                                        imap_fetchbody($this->mbox,imap_msgno($this->mbox, $params["msg_num"]),"1"), 
     198                                                        $msg->encoding[$params["msg_num"]][0], $msg->charset[$params["msg_num"]][0] 
     199                                                        )                                        
     200                                        )); //Append do novo email, só com header e conteúdo sem anexos. 
     201                 
     202                if(!$status) { 
     203                        $return["status"] = false; 
     204                        $return["msg"] = lang("error appending mail on delete attachments"); 
     205                } 
     206                 
     207                @imap_delete($this->mbox, imap_msgno($this->mbox, $params["msg_num"])); //Insere o novo e-mail sem anexos. 
     208                @imap_expunge($this->mbox); //Deleta o e-mail com anexos 
     209                 
     210                return $return; 
     211                 
     212        } 
     213 
    164214        function get_info_msg($params) 
    165215        { 
  • trunk/expressoMail1_2/js/draw_api.js

    r607 r613  
    12871287                attachments.align='left'; 
    12881288                var zipped_attachments = ''; 
    1289                 if(info_msg.attachments.length > 1){ 
     1289                if(info_msg.attachments.length >= 1){ 
    12901290                        var zipped_attachments  = document.createElement("TABLE"); 
    12911291                        zipped_attachments.style.marginBottom = "4px"; 
     
    12941294                        var tr = document.createElement("TR"); 
    12951295                        var td = document.createElement("TD");                   
    1296                         var link_attachment     = document.createElement("A"); 
    1297                         link_attachment.setAttribute("href", "javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')"); 
    1298                         link_attachment.innerHTML = " "+info_msg.attachments.length+' '+get_lang('files')+' :: '+get_lang('Download all atachments'); 
    1299                         link_attachment.innerHTML += '<BR>'; 
    1300                         td.appendChild(link_attachment); 
     1296                        if(info_msg.attachments.length != 1) { 
     1297                                var link_attachment     = document.createElement("A"); 
     1298                                link_attachment.setAttribute("href", "javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')"); 
     1299                                link_attachment.innerHTML = " "+info_msg.attachments.length+' '+get_lang('files')+' :: '+get_lang('Download all atachments'); 
     1300                                link_attachment.innerHTML += '<BR>'; 
     1301                                td.appendChild(link_attachment); 
     1302                        } 
     1303                        var del_attachments = document.createElement("A"); 
     1304                        del_attachments.setAttribute("href", "javascript:remove_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");                  
     1305                        del_attachments.innerHTML = get_lang('remove all attachments'); 
     1306                 
     1307                        td.appendChild(del_attachments); 
    13011308                        tr.appendChild(td); 
    13021309                        zipped_attachments.appendChild(tr); 
  • trunk/expressoMail1_2/js/main.js

    r605 r613  
    4141        setTimeout('auto_refresh()', time_refresh); 
    4242} 
    43  
     43/* 
     44        função que remove todos os anexos... 
     45*/ 
     46function remove_all_attachments(folder,msg_num) { 
     47         
     48        var call_back = function(data) { 
     49                                        if(!data.status) { //Em caso de erros, o status vem como false e o texto do erro vem em msg. 
     50                                                alert(data.msg); 
     51                                        } 
     52                                        else { 
     53                                                mail_msg = Element("tbody_box"); 
     54                                                msg_to_delete = Element(data.msg_num); 
     55                                                if (msg_to_delete) { 
     56                                                        if ( (msg_to_delete.style.backgroundColor != '') && (preferences.use_shortcuts == '1') ) 
     57                                                                select_msg('null', 'down'); 
     58                                                        mail_msg.removeChild(msg_to_delete);                                                                                             
     59                                                }//Remove o email com anexos da lista de emails. 
     60                                                write_msg(get_lang("Attachments removed"));//indica que os anexos foram removidos 
     61                                                refresh(); //dá um refresh na lista de emails, para que apareça o novo email sem anexos 
     62                                                delete_border(data.msg_num+'_r','false');//fecha a tela do email já removido. 
     63                                        } 
     64                                }; 
     65        if (confirm(get_lang("delete all attachments confirmation"))) 
     66                cExecute ("$this.imap_functions.remove_attachments&folder="+folder+"&msg_num="+msg_num, call_back); //chamada em ajax para a função de remover anexos. 
     67} 
    4468function watch_changes_in_msg(border_id) 
    4569{ 
Note: See TracChangeset for help on using the changeset viewer.