Ignore:
Timestamp:
07/11/12 11:45:10 (12 years ago)
Author:
niltonneto
Message:

Ticket #0000 - Copiadas as alterações do Trunk. Versão final da 2.4.1.

Location:
branches/2.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4

  • branches/2.4/expressoMail1_2/inc/class.db_functions.inc.php

    r6331 r6754  
    2424        include_once(PHPGW_API_INC.'/class.db.inc.php');  
    2525}  
    26 include_once('class.dynamic_contacts.inc.php'); 
    2726         
    2827class db_functions 
     
    248247        } 
    249248 
    250         //Gera lista de contatos para ser gravado e acessado pelo expresso offline. 
    251         function get_dropdown_contacts_to_cache() { 
    252                 return $this->get_dropdown_contacts(); 
    253         } 
    254          
    255         function get_dropdown_contacts(){ 
    256                 $contacts = $this->get_cc_contacts(); 
    257                 $groups = $this->get_cc_groups(); 
    258                  
    259                 if(($contacts) && ($groups)) 
    260                         $stringDropDownContacts = $contacts . ',' . $groups; 
    261                 elseif ((!$contacts) && (!$groups)) 
    262                         $stringDropDownContacts = ''; 
    263                 elseif (($contacts) && (!$groups)) 
    264                         $stringDropDownContacts = $contacts; 
    265                 elseif ((!$contacts) && ($groups)) 
    266                         $stringDropDownContacts = $groups; 
    267                                          
    268                 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 
    269                         // Free others requests  
    270                         session_write_close();  
    271                         $dynamic_contact = new dynamic_contacts(); 
    272                         $dynamic = $dynamic_contact->dynamic_contact_toString(); 
    273                         if ($dynamic) 
    274                                 $stringDropDownContacts .= ($stringDropDownContacts ? ',' : '') . $dynamic; 
    275                 } 
    276                 return $stringDropDownContacts;  
    277         } 
    278249        function getUserByEmail($params){        
    279250                // Follow the referral 
     
    309280        } 
    310281         
    311         function get_dynamic_contacts() 
    312         {                                
    313                 // Pesquisa os emails e ultima inserção nos contatos dinamicos. 
    314                 if(!$this->db->select('phpgw_expressomail_contacts','data','id_owner ='.$this->user_id,__LINE__,__FILE__)) 
    315                 { 
    316                 return $this->db->Error; 
    317 } 
    318                 while($this->db->next_record()) 
    319                 { 
    320                         $result[] = $this->db->row(); 
    321                 } 
    322                 if($result) foreach($result as $item)  
    323                 { 
    324                         $contacts = unserialize($item['data']); 
    325                 } 
    326                 if (count($contacts) == 0) 
    327                 {                        
    328                         return null; 
    329                 }        
    330                 //Sort by email 
    331                 function cmp($a, $b) { return strcmp($a["email"], $b["email"]);}  
    332                 usort($contacts,"cmp"); 
    333                 return $contacts; 
    334         } 
    335         function update_contacts($contacts=array()) 
    336         {                        
    337                  
    338          
    339                 if(!$this->db->select('phpgw_expressomail_contacts','data','id_owner ='.$this->user_id,__LINE__,__FILE__)) 
    340         { 
    341             $result['dberr1'] = $this->db->Error; 
    342         } 
    343                 $regs = array(); 
    344                 while($this->db->next_record()) 
    345         { 
    346             $regs[] = $this->db->row(); 
    347         } 
    348                 $old_contatacts = array(); 
    349                 foreach($regs as $old){ 
    350                         $old_contatacts = unserialize($old['data']); 
    351                 } 
    352                   
    353                 foreach($old_contatacts as $i => $v) 
    354                         foreach($contacts as $ii => $vv) 
    355                                 if(trim($v['email']) == trim($vv['email'])) 
    356                                         unset($old_contatacts[$i]); 
    357                  
    358                   
    359                  $old_contatacts = array_merge( $old_contatacts , $contacts);            
    360                 // Atualiza um email nos contatos dinamicos. 
    361                 if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($old_contatacts).'\'','id_owner ='.$this->user_id,__LINE__,__FILE__)) 
    362                 { 
    363                         return $this->db->Error; 
    364                 } 
    365                 return $contacts; 
    366         }        
    367282        function update_preferences($params){ 
    368283                $string_serial = urldecode($params['prefe_string']);                             
     
    375290                else 
    376291                        return array("success" => true); 
    377         } 
    378          
    379         function insert_contact($contact)        
    380         { 
    381                 $contacts[] = array( 'timestamp'        => time(), 
    382                                                                 'email'         => $contact ); 
    383  
    384                 // Insere um email nos contatos dinamicos.       
    385                 $query = 'INSERT INTO phpgw_expressomail_contacts (data, id_owner)  ' . 
    386                                         'values ( \''.serialize($contacts).'\', '.$this->user_id.')'; 
    387                  
    388                 if(!$this->db->query($query,__LINE__,__FILE__)) 
    389                 return $this->db->Error; 
    390         return $contacts; 
    391         } 
    392          
    393         function remove_dynamic_contact($user_id,$line,$file) 
    394         { 
    395                 $where = $user_id.' = id_owner'; 
    396                 $this->db->delete('phpgw_expressomail_contacts',$where,$line,$file);     
    397292        } 
    398293         
Note: See TracChangeset for help on using the changeset viewer.