Changeset 6457


Ignore:
Timestamp:
06/11/12 15:47:53 (12 years ago)
Author:
cristiano
Message:

Ticket #2778 - Permitir inserir imagens no corpo de e-mail via area de transferencia

Location:
trunk
Files:
2 edited

Legend:

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

    r6442 r6457  
    30343034            //////////////////////////////////////////////////////////////////////////////////////////////////// 
    30353035 
     3036            $this->rfc2397ToEmbeddedAttachment($mailService , $body);  
     3037 
    30363038            if ($isHTML) 
    30373039                $mailService->setBodyHtml($body); 
     
    51985200        * @param      <Array> <$proc> <ações do filtro> 
    51995201        * @return     <Regras do usuário em Array> 
    5200         * @access     <public> 
     5202        * @access public 
    52015203        */ 
    52025204        function apliSieveFilter($msgs , $proc) 
     
    52395241                return $ret; 
    52405242        } 
     5243 
     5244   /** 
     5245    * Método que convert imagens no formato rfc2397 para Embedded Attachment 
     5246    * 
     5247    * @license    http://www.gnu.org/copyleft/gpl.html GPL 
     5248    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 
     5249    * @sponsor     Caixa Econômica Federal 
     5250    * @author     Cristiano Corrêa Schmidt 
     5251    * @param      <MailService> <$mailService> <Referencia objeto MailService> 
     5252    * @param      <String> <$body> <Referencia Corpo do email> 
     5253    * @return     <void> 
     5254    * @access     public 
     5255    */ 
     5256   function rfc2397ToEmbeddedAttachment( &$mailService , &$body ) 
     5257   {  
     5258       $matches = array(); 
     5259       preg_match_all("/src=[\'|\"]+data:([^,]*);base64,([a-zA-Z0-9\+\/\=]+)[\'|\"]+/i", $body, $matches,  PREG_SET_ORDER); //Resgata imagens em rfc2397        
     5260        
     5261       foreach ($matches as $i => &$v) 
     5262       { 
     5263            $ext = explode(';', $v[1]); //quebra todos os parametros em um array.  
     5264            $mailService->addStringImage(base64_decode($v[2]), $ext[0] , 'EmbeddedImage'.$i.'.'.$this->mimeToExtension($v[1]));  
     5265            $body = str_replace($v[0], 'src="EmbeddedImage'.$i.'.'.$this->mimeToExtension($ext[0]).'"' , $body);  
     5266       } 
     5267   } 
     5268 
     5269   /** 
     5270    * Método que retorna a extensão do arquivo atraves do mime type 
     5271    * 
     5272    * @license    http://www.gnu.org/copyleft/gpl.html GPL 
     5273    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 
     5274    * @sponsor     Caixa Econômica Federal 
     5275    * @author     Cristiano Corrêa Schmidt 
     5276    * @param      <String> <$mimeType> <Mime Type do arquivo> 
     5277    * @return     <String> <extensão> 
     5278    * @access     public 
     5279    */ 
     5280   function mimeToExtension($mimeType) 
     5281   { 
     5282       switch ( $mimeType )  
     5283       {    
     5284           case 'image/bmp' :  
     5285           return 'bmp'; 
     5286           case 'image/cgm' : 
     5287               return 'cgm'; 
     5288           case 'image/vnd.djvu' :  
     5289               return 'djv'; 
     5290           case 'image/gif' : 
     5291               return 'gif'; 
     5292           case 'image/x-icon' : 
     5293               return 'ico'; 
     5294           case 'image/ief' : 
     5295               return 'ief'; 
     5296           case 'image/jpeg' : 
     5297               return 'jpg'; 
     5298           case 'image/x-macpaint' : 
     5299               return 'mac'; 
     5300           case 'image/pict' : 
     5301               return 'pct'; 
     5302           case 'image/png' : 
     5303               return 'png'; 
     5304           case 'image/x-quicktime' : 
     5305               return 'qti'; 
     5306           case 'image/x-rgb' : 
     5307               return 'rgb'; 
     5308           case 'image/tiff' : 
     5309               return 'tif'; 
     5310           default: 
     5311               return ''; 
     5312       } 
     5313        
     5314   } 
    52415315} 
    52425316?> 
  • trunk/prototype/services/ImapServiceAdapter.php

    r6389 r6457  
    607607                                        $mailService->addHeaderField('Disposition-Notification-To', Config::me('mail')); 
    608608 
     609                                $this->rfc2397ToEmbeddedAttachment($mailService , $body); 
     610 
    609611                                $isHTML = ( isset($data['type']) && $data['type'] == 'html' )?  true : false; 
    610612 
Note: See TracChangeset for help on using the changeset viewer.