Changeset 4413


Ignore:
Timestamp:
05/13/11 18:21:58 (13 years ago)
Author:
adriano
Message:

Ticket #1888 - Problemas ao anexar um arquivo na composicao de um email

Location:
sandbox/2.2.0.2/expressoMail1_2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r4291 r4413  
    27392739                $msg_uid = $params['msg_id']; 
    27402740                $body = $params['body']; 
    2741                 $body = str_replace("%nbsp;"," ",$params['body']); 
     2741                $body = str_replace("%nbsp;"," ", $body); 
    27422742                $body = preg_replace("/\n/"," ",$body); 
    27432743                $body = preg_replace("/\r/","",$body); 
  • sandbox/2.2.0.2/expressoMail1_2/js/common_functions.js

    r4062 r4413  
    336336                var countDivFiles = 1; 
    337337 
    338         divFile = document.createElement('DIV'); 
    339  
    340  
    341         divFile.innerHTML = "<input type='file' id_border='"+id_border+"' size='50' maxLength='255' onchange=\"function () {validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));};\" id='"+"inputFile_"+id_border+"_"+countDivFiles+"' name='file_"+countDivFiles+"'>"; 
    342  
    343  
    344         var linkFile = document.createElement("A"); 
    345         linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; 
    346         linkFile.href='javascript:void(0)'; 
    347         linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; 
    348         linkFile.innerHTML=get_lang("Remove"); 
    349         //divFile.innerHTML += "&nbsp;&nbsp;"; 
     338        divFile = document.createElement('div');  
     339 
     340        var inputFile = document.createElement("input");  
     341        inputFile.id        = "inputFile_"+id_border+"_"+countDivFiles;  
     342        inputFile.name      = "file_"+countDivFiles;  
     343        inputFile.type      = "file";  
     344        inputFile.size      = 50;  
     345        inputFile.maxlength = 255;  
     346        inputFile.onchange  = function () {  
     347                validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));  
     348                openTab.autosave_timer[id_border] = setTimeout("save_msg("+id_border+")", autosave_time);  
     349        };  
     350         
     351        inputFile.onfocus = function () {        
     352                if (openTab.autosave_timer[id_border])  
     353                        clearTimeout(openTab.autosave_timer[id_border]);  
     354        };  
     355         
     356        divFile.appendChild(inputFile);  
     357 
     358        var linkFile = document.createElement("a");  
     359        linkFile.id        = "linkFile_"+id_border+"_"+countDivFiles;  
     360        linkFile.href      = 'javascript:void(0)';  
     361        linkFile.onclick   = function () {removeFile("divFile_"+id_border+"_"+countDivFiles); return false;};  
     362        linkFile.innerHTML = get_lang("Remove"); 
     363         
    350364        divFile.appendChild(linkFile); 
    351365        divFile.id = "divFile_"+id_border+"_"+countDivFiles; 
    352366        divFiles.appendChild(divFile); 
    353367 
    354  
    355  
    356         return document.getElementById("inputFile_"+id_border+"_"+countDivFiles); 
     368        return inputFile; 
    357369} 
    358370//      Remove Input File Dynamically. 
  • sandbox/2.2.0.2/expressoMail1_2/js/draw_api.js

    r4365 r4413  
    31893189        } 
    31903190 
     3191        /**  
     3192        * event to enable autosave_draft on file attachment  
     3193        */  
     3194        function save_onchange_attachment_handler () { 
     3195                away = false;  
     3196                var save_link = Element("save_message_options_"+border_id);  
     3197                save_link.onclick = function onclick(event) {  
     3198                openTab.toPreserve[border_id] = true;   
     3199                        save_msg(border_id);  
     3200                };  
     3201                save_link.className = 'message_options';  
     3202        };  
     3203         
    31913204        var add_files = document.createElement("A"); 
    31923205        add_files.setAttribute("href", "javascript:void(0)"); 
    3193         add_files.onclick = function () { addFile(ID); return false;}; 
     3206        add_files.onclick = function () { 
     3207                var obj = addFile(ID);  
     3208                if (preferences.auto_save_draft == 1 && obj) { 
     3209                        if ( obj.addEventListener )  
     3210                        obj.addEventListener('click', save_onchange_attachment_handler, false);  
     3211                }  
     3212                return false;  
     3213        };  
    31943214        add_files.innerHTML =  get_lang("Attachments: add+"); 
    31953215        add_files.setAttribute("tabIndex","-1"); 
  • sandbox/2.2.0.2/expressoMail1_2/js/main.js

    r4364 r4413  
    33// tempo do auto save (em milisegundos) 
    44// 20000 = 20 segundos 
    5 var autosave_time = 20000; 
     5var autosave_time = 5000; 
    66 
    77var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>';  
     
    17451745        } 
    17461746        else 
     1747        { 
    17471748                cExecuteForm("$this.imap_functions.send_mail", form, handler_send_message, ID); 
     1749        } 
    17481750} 
    17491751function change_tr_properties(tr_element, newUid, newSubject){ 
     
    17651767} 
    17661768 
    1767 function return_save(data,border_id,folder_name,folder_id,message_id) 
    1768 { 
     1769function return_save(data,border_id,folder_name,folder_id,message_id){ 
    17691770        Element("send_button_"+border_id).style.visibility="visible"; 
    1770         var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); }; 
    1771  
    1772         if (data.append != true || !data) 
     1771        var handler_delete_msg = function(data){refresh(preferences.alert_new_msg);}; 
     1772 
     1773        if (data == null || data.append != true ) 
    17731774        { 
    1774                 RichTextEditor.saveFlag = -1; 
     1775 
     1776                RichTextEditor.saveFlag = -1; 
    17751777                if (! data.append) 
    1776                         if(data == 'Post-Content-Length') 
    1777                                 write_msg(get_lang('The size of this message has exceeded  the limit (%1B).', preferences.max_attachment_size ? preferences.max_attachment_size : Element('upload_max_filesize').value)); 
    1778                         else 
    1779                                 write_msg(get_lang('ERROR saving your message.')); 
     1778                        write_msg('ERROR saving your message.'); 
    17801779                else 
    17811780                { 
     
    17981797                openTab.imapUid[border_id] = data.msg_no; 
    17991798                openTab.imapBox[border_id] = data.folder_id; 
    1800  
     1799                 
    18011800                var newTitle = document.getElementById('subject_'+border_id).value; 
    1802                 if (newTitle == '') 
     1801                if (newTitle.length > 18) 
     1802                        newTitle = newTitle.substr(18) + '...'; 
     1803                else if (newTitle == '') 
    18031804                        newTitle = get_lang("No subject"); 
    1804                 set_border_caption('border_id_'+border_id, newTitle); 
    1805  
     1805                document.getElementById('font_border_id_'+border_id).innerHTML = newTitle; 
     1806                 
    18061807                // Replace the embedded images for new uids 
    1807                 var mainField = document.getElementById('body_'+border_id).contentWindow; 
    1808                 var content_body =  mainField.document.getElementsByTagName('body').item(0).innerHTML; 
    1809                 var body_images = content_body.match(/msg_num=\d*/g); 
    1810                 var images_part = content_body.match(/msg_part=\d*/g); 
    1811                 if (body_images) 
     1808                var mainField     = document.getElementById('body_'+border_id).contentWindow; 
     1809                var content_body  = mainField.document.getElementsByTagName('body').item(0).innerHTML; 
     1810                var body_images   = content_body.match(/msg_num=\d*/g); 
     1811                var folder_images = content_body.match(/msg_folder=[^&]*&/g);            
     1812                 
     1813                if (body_images != null) 
    18121814                { 
    1813                         for (var i=0; i<body_images.length; i++){ 
    1814                                 content_body =  content_body.replace(body_images[i],"msg_num="+openTab.imapUid[border_id]); 
    1815                         } 
    1816                         var allImgs = new Array (images_part.length); 
    1817                                 var j=-1; 
    1818                                 for (var i in images_part){ 
    1819  
    1820                                         if (is_ie) 
    1821                                                 if (i == 0) 
    1822                                                         var image_number = parseInt(images_part[i].substr(9)); 
    1823                                                 else 
    1824                                                         image_number = "null"; 
    1825                                         else 
    1826                                                 var image_number = parseInt(images_part[i].substr(9)); 
    1827  
    1828                                 if (! isNaN(image_number)) 
    1829                                         { 
    1830                                                 if (! allImgs[image_number]) 
    1831                                                 { 
    1832                                                         allImgs[image_number] = true; 
    1833                                                         j--; 
    1834                                                 } 
    1835                                         content_body = content_body.replace(images_part[i],'msg_part='+j); 
    1836                                         } 
    1837                                 } 
    1838                         content_body = content_body.replace(/msg_part=-/g,'msg_part='); 
    1839  
    1840                         mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body; 
    1841                 } 
    1842  
     1815                    for (var i=0; i<body_images.length; i++) 
     1816                    { 
     1817                        if( folder_images != null) 
     1818                           content_body = content_body.replace(folder_images[i], "msg_folder=INBOX" + cyrus_delimiter + draftsfolder +"&"); 
     1819 
     1820                        content_body = content_body.replace(body_images[i],"msg_num="+openTab.imapUid[border_id]); 
     1821                    } 
     1822 
     1823                    var images_part   = content_body.match(/msg_part=[0-9.]*/g); 
     1824 
     1825                    if(images_part != null) 
     1826                    { 
     1827                        for (var x = 0; x < images_part.length; x++) 
     1828                        { 
     1829                            var position = images_part[x].substr(9,images_part[x].length); 
     1830                            content_body = content_body.replace(images_part[x],'msg_part(||.|||.||)='+data.imagesParts[position]); 
     1831                        } 
     1832 
     1833                    } 
     1834                    content_body = content_body.replace(/msg_part\(\|\|\.\|\|\|\.\|\|\)=/g,'msg_part='); 
     1835 
     1836                    mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body; 
     1837                 }        
     1838                 
     1839 
     1840         
    18431841                //Replace all files to new files 
    18441842                var divFiles = Element("divFiles_"+border_id); 
    1845                 elFiles = divFiles.getElementsByTagName("input"); 
    1846                 var countCheck =0; 
    1847                 for (var i=0; i<elFiles.length; i++) { 
    1848                         if(elFiles[i].value !=""){ 
    1849                                 if (elFiles[i].type == "checkbox") { 
    1850                                         countCheck++; 
    1851                                 } 
    1852                                 else { 
    1853                                         elFiles[i].value =""; 
    1854                                         parantNodeFile = elFiles[i].parentNode.parentNode; 
    1855                                         parantNodeFile.removeChild(elFiles[i].parentNode); 
    1856                                         i--; 
    1857                                 } 
    1858  
    1859                         } 
    1860                 }; 
    1861  
     1843                divFiles.innerHTML = ''; 
     1844                 
    18621845                var attach_files = connector.unserialize(data.files); 
    18631846                if (attach_files != null) { 
    18641847                        openTab.countFile[border_id] = attach_files.length; 
    1865                         att_index = countCheck; 
    1866                 for (att_index; att_index < attach_files.length; att_index++){ 
    1867  
    1868                         var link_attachment = document.createElement("A"); 
    1869                         var fileName = attach_files[att_index].substr(0,attach_files[att_index].indexOf('_SIZE_')); 
    1870                         var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].indexOf('_SIZE_')+6))/1024 
    1871                         link_attachment.innerHTML = fileName + " ("+borkb((parseInt(fileSize)*1024))+")"; 
    1872  
    1873                         var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','"+(att_index+2)+"','base64'"; 
    1874  
    1875                         link_attachment.setAttribute("href", "javascript:download_attachments("+href+")"); 
    1876  
    1877                         var a_tmp = href.split(','); 
    1878                         a_tmp[2] = fileName; 
    1879                         s_tmp = escape(connector.serialize(a_tmp)); 
    1880  
    1881                         var check_attachment = document.createElement("INPUT"); 
    1882                         check_attachment.type = 'CHECKBOX'; 
    1883                         check_attachment.name = 'forwarding_attachments[]'; 
    1884                         check_attachment.value = trim(s_tmp); 
    1885  
    1886                         if (!divFiles.childNodes[0]) 
    1887                         { 
    1888                             divFiles.appendChild(document.createElement("BR")); 
    1889                         } 
    1890                         else 
    1891                             { 
    1892                                 divFiles.insertBefore(document.createElement("BR"),divFiles.childNodes[0]); 
    1893                             } 
    1894  
    1895                         divFiles.insertBefore(link_attachment,divFiles.childNodes[0]); 
    1896                         divFiles.insertBefore(check_attachment,divFiles.childNodes[0]); 
    1897  
    1898                         check_attachment.checked = true; 
    1899                 } 
    1900         } 
     1848                        for (att_index = 0; att_index < attach_files.length; att_index++){ 
     1849                 
     1850                                var link_attachment = document.createElement("a"); 
     1851                                var fileName = attach_files[att_index].substr(0, attach_files[att_index].lastIndexOf('_SIZE_')); 
     1852                                var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].lastIndexOf('_SIZE_')+6))/1024 
     1853                                link_attachment.innerHTML = fileName + " ("+parseInt(fileSize)+" kb)"; 
     1854 
     1855                                var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','0."+(att_index+1)+"','base64'"; 
     1856 
     1857                                link_attachment.setAttribute("href", "javascript:download_attachments("+href+")"); 
     1858 
     1859                                var a_tmp = href.split(','); 
     1860                                a_tmp[2] = fileName; 
     1861                                s_tmp = escape(connector.serialize(a_tmp)); 
     1862                                                 
     1863                                var check_attachment = document.createElement("input"); 
     1864                                check_attachment.type = 'checkbox'; 
     1865                                check_attachment.name = 'forwarding_attachments[]'; 
     1866                                check_attachment.value = s_tmp; 
     1867                                 
     1868                                check_attachment.checked = true; 
     1869                                check_attachment.setAttribute("checked", "checked"); 
     1870                                 
     1871                                divFiles.appendChild(check_attachment); 
     1872                                divFiles.appendChild(link_attachment); 
     1873                                divFiles.appendChild(document.createElement("br")); 
     1874                        }                        
     1875                } 
     1876                 
     1877                 
    19011878                if (message_id) 
    19021879                { 
    19031880                        cExecute ("$this.imap_functions.delete_msgs&folder="+openTab.imapBox[border_id]+"&msgs_number="+message_id,handler_delete_msg); 
    1904                         if (openTab.imapBox[0] == "INBOX/"+draftsfolder) 
     1881                        if (openTab.imapBox[0] == "INBOX" + cyrus_delimiter + draftsfolder) 
    19051882                        { 
    19061883                                //Update mailbox 
    1907                                                 var tr_msg = document.getElementById(message_id); 
     1884                                var tr_msg = document.getElementById(message_id); 
    19081885                                change_tr_properties(tr_msg, data.msg_no, data.subject); 
    19091886                        } 
    1910                 } else { 
    1911                         refresh(); 
    1912                 } 
    1913  
     1887                 
     1888                } 
    19141889                var save_link = Element("save_message_options_"+border_id); 
    19151890                save_link.onclick = ''; 
     
    19171892                watch_changes_in_msg(border_id); 
    19181893                write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name))); 
    1919         } 
     1894        }                
    19201895} 
    19211896 
Note: See TracChangeset for help on using the changeset viewer.