Ignore:
Timestamp:
09/11/08 16:42:44 (16 years ago)
Author:
rafaelraymundo
Message:

Melhoria implementada, relativo a ocorrencia #314 da comunidade.
Contatos dinamicos no envio de emails de forma configuravel.

File:
1 edited

Legend:

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

    r205 r413  
    33define('PHPGW_API_INC','../phpgwapi/inc');       
    44include_once(PHPGW_API_INC.'/class.db.inc.php'); 
    5          
     5include_once('class.dynamic_contacts.inc.php'); 
     6 
    67class db_functions 
    78{        
     
    142143        } 
    143144 
    144         function get_dropdown_contacts(){ 
     145        function get_dropdown_contacts() 
     146        { 
     147                $dynamic_contact = new dynamic_contacts(); 
    145148                 
    146149                $contacts = $this -> get_cc_contacts(); 
    147150                $groups = $this -> get_cc_groups(); 
     151                $dynamic = $dynamic_contact->dynamic_contact_toString(); 
    148152                 
    149153                if(($contacts) && ($groups)) 
     
    155159                elseif ((!$contacts) && ($groups)) 
    156160                        $stringDropDownContacts = $groups; 
    157                                          
     161                if (($dynamic) && (($groups) || ($contacts))) 
     162                        $stringDropDownContacts .= ',' . $dynamic; 
     163                else  
     164                        if ($dynamic) 
     165                                $stringDropDownContacts = $dynamic; 
     166                                 
    158167                return $stringDropDownContacts;  
    159168        } 
     
    257266                return $result; 
    258267        } 
     268         
     269        function get_dynamic_contacts() 
     270        {                                
     271                // Pesquisa os emails e ultima inserção nos contatos dinamicos. 
     272                if(!$this->db->select('phpgw_expressomail_contacts','data', 
     273                                                  'id_owner ='.$this -> user_id, 
     274                                                  __LINE__,__FILE__)) 
     275                { 
     276                return $this->db->Error; 
     277        } 
     278                while($this->db->next_record()) 
     279                { 
     280                        $result[] = $this->db->row(); 
     281                } 
     282                foreach($result as $item)  
     283                { 
     284                        $contacts = unserialize($item['data']); 
     285                } 
     286                if (count($contacts) == 0) 
     287                {                        
     288                        return null; 
     289                }        
     290                return $contacts; 
     291        } 
     292         
     293        function update_contacts($contacts=array()) 
     294        {                        
     295                // Atualiza um email nos contatos dinamicos. 
     296                if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($contacts).'\'', 
     297                                                          'id_owner ='.$this -> user_id, 
     298                                                          __LINE__,__FILE__)) 
     299                { 
     300                        return $this->db->Error; 
     301                } 
     302        return $contacts; 
     303        }        
     304         
     305        function insert_contact($contact)        
     306        { 
     307                $contacts[] = array( 'timestamp'        => time(), 
     308                                                                'email'         => $contact ); 
     309 
     310                // Insere um email nos contatos dinamicos.       
     311                $query = 'INSERT INTO phpgw_expressomail_contacts (data, id_owner)  ' . 
     312                                        'values ( \''.serialize($contacts).'\', '.$this->user_id.')'; 
     313                 
     314                if(!$this->db->query($query,__LINE__,__FILE__)) 
     315                return $this->db->Error; 
     316        return $contacts; 
     317        } 
     318         
     319        function remove_dynamic_contact($user_id,$line,$file) 
     320        { 
     321                $where = $user_id.' = id_owner'; 
     322                $this->db->delete('phpgw_expressomail_contacts',$where,$line,$file);     
     323        } 
    259324} 
    260325?> 
Note: See TracChangeset for help on using the changeset viewer.