Ignore:
Timestamp:
10/01/08 16:46:55 (16 years ago)
Author:
niltonneto
Message:

Implementação para trazer os contatos compartilhados.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/inc/class.so_contact.inc.php

    r285 r503  
    256256                                ) 
    257257                        ); 
     258                        $this->relateds = array( 
     259                                        'id_related'    => array( 
     260                                                'name'                  => 'id_related', 
     261                                                'type'                  => array('foreign', 'primary'), 
     262                                                'association'   => array( 
     263                                                        'table'                 => 'phpgw_cc_contact', 
     264                                                        'field'                 => 'id_contact' 
     265                                                ), 
     266                                                'states'                =>      array(), 
     267                                                'values'        => array() 
     268                                        ), 
     269                                        'id_contact'    => array( 
     270                                                'name'                  => 'id_contact', 
     271                                                'type'                  => array('foreign', 'primary'), 
     272                                                'association'   => array( 
     273                                                        'table'                 => 'phpgw_cc_contact', 
     274                                                        'field'                 => 'id_contact' 
     275                                                ), 
     276                                                'states'                =>      array(), 
     277                                                'values'        => array() 
     278                                        ), 
     279                                        'id_typeof_contact_relation'    => array( 
     280                                                'name'                  => 'id_typeof_contact_relation', 
     281                                                'type'                  => array('foreign', 'primary'), 
     282                                                'association'   => array( 
     283                                                        'table'                 => 'phpgw_cc_typeof_ct_rels', 
     284                                                        'field'                 => 'id_typeof_contact_relation' 
     285                                                ), 
     286                                                'states'                =>      array(), 
     287                                                'values'        => array() 
     288                                        ) 
     289                                ); 
    258290                                 
    259291 
     
    320352                                        $this->state = 'new'; 
    321353                                } 
     354                                $temp = $this->db_tables; 
     355                         
     356                                $this->db_tables = array(); //Limpo o array para fazer checkout apenas dos contatos relacionados 
     357                                $this->db_tables['phpgw_cc_contact_rels'] =  array( 
     358                                                'type'          => 'multi', 
     359                                                'keys'          => array( 
     360                                                        'primary' => array( 
     361                                                                &$this->relateds['id_related']), 
     362                                                                &$this->relateds['id_contact'], 
     363                                                        'foreign' => array( 
     364                                                                &$this->relateds['id_related'])), 
     365                                                                &$this->relateds['id_contact'], 
     366                                                'fields'        => & $this->relateds); 
     367                                if (!$this->checkout($id_contact)) 
     368                                { 
     369                                        $this->reset_values(); 
     370                                        $this->state = 'new'; 
     371                                } 
     372                                $this->db_tables = $temp; //Coloco o valor do array antigo. 
    322373                        } 
    323374                        else 
     
    500551                        } 
    501552                         
     553                        return $return; 
     554                } 
     555         
     556                function get_relateds() { 
     557                        $return = array(); 
     558                         
     559                        reset($this->relateds['id_contact']['values']); 
     560                        reset($this->relateds['id_typeof_contact_relation']['values']); 
     561                        while(list(,$id_relation) = each($this->relateds['id_contact']['values']) and 
     562                                list(,$id_relation_type) = each($this->relateds['id_typeof_contact_relation']['values'])) 
     563                        { 
     564                                $return[$id_relation] = $id_relation_type; 
     565                        } 
    502566                        return $return; 
    503567                } 
     
    806870         
    807871                /*! 
     872                        @function set_related 
     873                        @abstract Sets the Contact's related 
     874                        @author Raphael Derosso Pereira 
     875                        @param integer $id_related The new Contact's Relation type ID 
     876                        @param integer $id_type The new Contact's Relation ID  
     877 
     878                */ 
     879                function set_relateds ( $relations , $id_type ) 
     880                { 
     881                        $id = $this->id; 
     882                        $db = $GLOBALS['phpgw']->db; 
     883 
     884                        //Remove todos os contatos relacionados 
     885                        $query = "delete from phpgw_cc_contact_rels where id_related=$id and id_typeof_contact_relation=1"; 
     886                         
     887                        if (!$db->query($query, __LINE__, __FILE__)) { 
     888                                return false; 
     889                        } 
     890                        foreach($relations as $id_relation) { 
     891                                $query = "insert into phpgw_cc_contact_rels (id_contact,id_related,id_typeof_contact_relation) values ($id_relation,$id,$id_type)"; 
     892                                 
     893                                if (!$db->query($query, __LINE__, __FILE__)) { 
     894                                        return false; 
     895                                } 
     896                        } 
     897                        return true; 
     898                } 
     899         
     900                /*! 
    808901                 
    809902                        @function set_address 
     
    831924                        $this->manage_fields($this->addresses['id_address'], 'new', 'new'); 
    832925                        $this->manage_fields($this->addresses['id_contact'], 'new', 'new'); 
     926                         
    833927                } 
    834928         
Note: See TracChangeset for help on using the changeset viewer.