Changeset 6256 for sandbox/webservice


Ignore:
Timestamp:
05/21/12 16:05:22 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Implementadas as devidas validações para evitar retorno nulo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/adapters/MailAdapter.php

    r6228 r6256  
    106106                //$msg['msgDate']        =  $info_msg['fulldate']; 
    107107                $msg['msgDate']  =  $info_msg['msg_day']." ".$info_msg['msg_hour']; 
    108  
    109                 $msg['msgFrom']['fullName']     = $info_msg['from']['name']; 
    110                 $msg['msgFrom']['mailAddress']  = $info_msg['from']['email'];            
    111                 $msg['msgSender']['fullName']   = $info_msg['sender']['name']; 
    112                 $msg['msgSender']['mailAddress']= $info_msg['sender']['email']; 
    113                  
    114                 $toaddresses = explode(",",$info_msg['toaddress2']); 
    115                 if(count($toaddresses) > 1) {                            
    116                         foreach ($toaddresses as $i => $toaddress){ 
    117                                 $msg['msgTo'][$i] = $this->formatMailObject($toaddress);                         
     108                if($info_msg['from']) { 
     109                        $msg['msgFrom']['fullName']     = $info_msg['from']['name']; 
     110                        $msg['msgFrom']['mailAddress']  = $info_msg['from']['email']; 
     111                } 
     112                if($info_msg['sender'] != null){ 
     113                        $msg['msgSender']['fullName']   = $info_msg['sender']['name']; 
     114                        $msg['msgSender']['mailAddress']= $info_msg['sender']['email']; 
     115                }                
     116                if($info_msg['toaddress2'] != null){ 
     117                        $toaddresses = explode(",",$info_msg['toaddress2']); 
     118                        if(count($toaddresses) > 1) { 
     119                                foreach ($toaddresses as $i => $toaddress){ 
     120                                        $msg['msgTo'][$i] = $this->formatMailObject($toaddress); 
     121                                } 
     122                        } 
     123                        else{ 
     124                                $msg['msgTo'][0] = $this->formatMailObject($info_msg['toaddress2']); 
    118125                        } 
    119126                } 
    120                 else{ 
    121                         $msg['msgTo'][0] = $this->formatMailObject($info_msg['toaddress2']); 
    122                 } 
    123                          
    124                 $ccaddresses = explode(",",$info_msg['cc']); 
    125                 if(count($ccaddresses) > 1) {            
    126                         foreach ($ccaddresses as $i => $ccaddress){ 
    127                                 $msg['msgCC'][$i] = $this->formatMailObject($ccaddress); 
     127                if($info_msg['cc'] != null) { 
     128                        $ccaddresses = explode(",",$info_msg['cc']); 
     129                        if(count($ccaddresses) > 1) { 
     130                                foreach ($ccaddresses as $i => $ccaddress){ 
     131                                        $msg['msgCC'][$i] = $this->formatMailObject($ccaddress); 
     132                                } 
    128133                        } 
    129                 } 
    130                 else{ 
    131                         $msg['msgCC'][0] = $this->formatMailObject($info_msg['cc']); 
    132                 } 
    133                  
    134  
    135                 $msg['msgReplyTo'][0] = $this->formatMailObject($info_msg['reply_toaddress']);                                           
    136                 $msg['msgSubject']  = mb_convert_encoding($info_msg['subject'],"UTF8", "ISO_8859-1");            
     134                        else{ 
     135                                $msg['msgCC'][0] = $this->formatMailObject($info_msg['cc']); 
     136                        } 
     137                }                
     138                if($info_msg['reply_toaddress'] != null) { 
     139                        $msg['msgReplyTo'][0] = $this->formatMailObject($info_msg['reply_toaddress']); 
     140                }                                                
     141                $msg['msgSubject']  = ($info_msg['subject'] ? mb_convert_encoding($info_msg['subject'],"UTF8", "ISO_8859-1") : "");              
    137142                $msg['msgHasAttachments'] = $info_msg['attachments'] ? "1" : "0";                
    138143                $msg['msgAttachments'] = $info_msg['attachments'];               
     
    143148                $msg['msgSeen']         = $info_msg['Unseen'] == "U" ? "0" : "1";                                
    144149                $msg['msgSize']         = $info_msg['Size']; 
    145                 $msg['msgBody']         = mb_convert_encoding($info_msg['body'],"UTF8", "ISO_8859-1");           
     150                $msg['msgBody']         = ($info_msg['body'] ? mb_convert_encoding($info_msg['body'],"UTF8", "ISO_8859-1") : "");                
    146151                 
    147152                return $msg;             
Note: See TracChangeset for help on using the changeset viewer.