Ignore:
Timestamp:
08/04/11 10:38:25 (13 years ago)
Author:
roberto.santosjunior
Message:

Ticket #2031 - Contato Dinâmico, trat. dos contatos antigos e espaços entre nomes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/expressoMail1_2/inc/class.dynamic_contacts.inc.php

    r4634 r4901  
    7979                        { 
    8080                                foreach($this->contacts as $item => $valor) 
    81                                         $contact .= str_replace("#",";",$this->contacts[$item]['email']) . ','; 
     81                                        // 
     82                                        if (strstr($this->contacts[$item]['email'], '#')){ 
     83                                                $contact .= str_replace("#",";",$this->contacts[$item]['email']) . ','; 
     84                                        }else{ 
     85                                                $contact .= ';'.$this->contacts[$item]['email'] . ','; 
     86                                        }        
     87                                         
    8288                                //Retira ultima virgula. 
    8389                                $contact = substr($contact,0,(strlen($contact) - 1)); 
     
    106112                { 
    107113                        // Trim all whitespaces and duplicated commas from full_email_address 
    108                         $full_email_address = preg_replace('{(,)\1+}',',',ereg_replace( ' +', '', $full_email_address)); 
     114                        //$full_email_address = preg_replace('{(,)\1+}',',',ereg_replace( ' +', '', $full_email_address)); 
    109115                        $parse_address = imap_rfc822_parse_adrlist($full_email_address, ""); 
    110116                        $new_contacts = array(); 
     
    118124                                if(!$this->contacts) // Used one time to insert the first contact in database 
    119125                                { 
    120                                         $this->db->insert_contact($val->personal."#".$val->mailbox."@".$val->host); 
     126                                        $this->db->insert_contact(ltrim(rtrim($val->personal))."#".$val->mailbox."@".$val->host); 
    121127                                        // Just new contact added. 
    122                                         $new_contacts[] = $val->personal.";".$val->mailbox."@".$val->host; 
     128                                        $new_contacts[] = ltrim(rtrim($val->personal)).";".$val->mailbox."@".$val->host; 
    123129                                        $this->contacts = $this->db->get_dynamic_contacts(); 
    124130                                } 
     
    129135                                        foreach($this->contacts as $item => $valor) 
    130136                                        { 
    131                                                 if($this->contacts[$item]['email'] == $val->personal."#".$val->mailbox."@".$val->host) // check if email already exists 
     137                                                if($this->contacts[$item]['email'] == ltrim(rtrim($val->personal))."#".$val->mailbox."@".$val->host) // check if email already exists 
    132138                                                {        
    133139                                                        $this->contacts[$item]['timestamp'] = time(); //update timestamp of email 
     
    143149                                        { 
    144150                                                // Just new contact added. 
    145                                                 $new_contacts[] = $val->personal.";".$val->mailbox."@".$val->host; 
     151                                                $new_contacts[] = ltrim(rtrim($val->personal)).";".$val->mailbox."@".$val->host; 
    146152                                                if($this->number_of_contacts > count($this->contacts)) 
    147153                                                { 
    148154                                                        $this->contacts[] = array( 'timestamp'  => time(), 
    149                                                                                                                 'email'         => $val->personal."#".$val->mailbox."@".$val->host); 
     155                                                                                                                'email'         => ltrim(rtrim($val->personal))."#".$val->mailbox."@".$val->host); 
    150156                                                } 
    151157                                                if($this->number_of_contacts <= count($this->contacts)) 
    152158                                                { 
    153159                                                        $this->contacts[$older_contact] = array( 'timestamp'    => time(), 
    154                                                                                                                                                 'email'         => $val->personal."#".$val->mailbox."@".$val->host); 
     160                                                                                                                                                'email'         => ltrim(rtrim($val->personal))."#".$val->mailbox."@".$val->host); 
    155161                                                } 
    156162                                        } 
Note: See TracChangeset for help on using the changeset viewer.