Changeset 12871

Show
Ignore:
Timestamp:
06/11/09 00:20:53 (1 year ago)
Author:
asha
Message:

#6020: Filesize,fielname was missing for a document created as a result of mail qualify of a mail having attachment and utf-8 characters were not handled in filename - DJ

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • vtigercrm/branches/5.1/modules/Webmails/Save.php

    r12842 r12871  
    102102function add_attachment_to_contact($cid,$email,$emailid) { 
    103103        // add vtiger_attachments to contact 
    104         global $adb,$current_user
     104        global $adb,$current_user,$default_charset
    105105        for($j=0;$j<2;$j++) { 
    106106            if($j==0) 
     
    116116         
    117117                        $filename = ereg_replace("[ ()-]+", "_",$attachments[$i]["filename"]); 
     118                        preg_match_all('/=\?([^\?]+)\?([^\?]+)\?([^\?]+)\?=/', $filename, $matches); 
     119                        $totalmatches = count($matches[0]); 
     120                         
     121                        for($index = 0; $index < $totalmatches; ++$index) { 
     122                                $charset = $matches[1][$index]; 
     123                                $encoding= strtoupper($matches[2][$index]); 
     124                                $data    = $matches[3][$index]; 
     125                                 
     126                                if($encoding == 'B') { 
     127                                        $filename = base64_decode($data); 
     128                                } else if($encoding == 'Q') { 
     129                                        $filename = quoted_printable_decode($data); 
     130                                } 
     131                                $filename = iconv(str_replace('_','-',$charset),$default_charset,$filename); 
     132                        } 
     133                         
    118134                        $saveasfile = $upload_filepath.'/'.$current_id.'_'.$filename; 
    119135                $filetype = MailAttachmentMIME::detect($saveasfile); 
     
    134150                                        $document->column_fields['notes_title']      = $filename; 
    135151                                        $document->column_fields['filename']         = $filename; 
     152                                        $document->column_fields['filesize']             = $filesize; 
     153                                        $document->column_fields['filetype']             = $filetype; 
    136154                                        $document->column_fields['filestatus']       = 1; 
    137155                                        $document->column_fields['filelocationtype'] = 'I';