Changeset 4502 for sandbox


Ignore:
Timestamp:
05/25/11 12:08:00 (13 years ago)
Author:
airton
Message:

Ticket #1928 - Falhas na associação de um contato com um grupo de contato

Location:
sandbox/2.2.0.2/contactcenter
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/contactcenter/inc/class.bo_group.inc.php

    r4498 r4502  
    127127                        return $this->so->deleteContactsByGroup($id_group, $contacts_conns); 
    128128                } 
     129 
     130                function update_contact_groups($id_defaultconnection, $connections, $groups) 
     131                { 
     132                        return $this->so->updateContactGroups($id_defaultconnection, $connections, $groups); 
     133                } 
    129134                 
    130135        } 
  • sandbox/2.2.0.2/contactcenter/inc/class.bo_people_catalog.inc.php

    r4498 r4502  
    18901890                                 
    18911891                        } 
    1892  
     1892                        $groups = CreateObject('contactcenter.so_group'); 
     1893                         
    18931894                        foreach ($connections as $id => $type) 
    18941895                        { 
     
    18971898                                        return false; 
    18981899                                } 
    1899                                  
     1900                                $groups->deleteContactFromGroups($id); 
    19001901                                if (!($connection->remove())) 
    19011902                                { 
  • sandbox/2.2.0.2/contactcenter/inc/class.so_group.inc.php

    r4498 r4502  
    569569                }                
    570570                 
     571                function updateContactGroups($id_defaultconnection, $connections, $groups) 
     572                { 
     573                        if (is_array($groups) && count($groups) > 0) 
     574                        { 
     575                                $query = "UPDATE phpgw_cc_contact_grps SET id_connection = " . $id_defaultconnection . " WHERE ("; 
     576                                $more = false; 
     577                                foreach ($connections as $connection) 
     578                                { 
     579                                        if ($more) 
     580                                        $query .= " OR "; 
     581                                        $query .= "id_connection = " . $connection['id_connection']; 
     582                                        $more = true; 
     583                                } 
     584                                $query .= ") AND ("; 
     585                                $more = false; 
     586                                foreach ($groups as $group) 
     587                                { 
     588                                        if ($more) 
     589                                        $query .= " OR "; 
     590                                        $query .= "id_group = " . $group['id_group']; 
     591                                        $more = true; 
     592                                } 
     593                                $query .= ");"; 
     594                                if (!$this->db->query($query))                   
     595                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);                              
     596                                                                         
     597                                return true; 
     598                        } 
     599                } 
     600                 
    571601                function deleteContactsByGroup($id_group, $contacts = null) 
    572602                { 
  • sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php

    r4500 r4502  
    20292029                        $data['contact_in_list'] = $new_tdata[1]; 
    20302030                        $data['id_group'] = $new_tdata[2]; 
     2031                        $data['old_contacts_in_list'] = $new_tdata[3]; 
    20312032                         
    2032                         $contactWOemail = false;  
    2033                                   
    2034                         foreach ($data['contact_in_list'] as $id_connection)  
    2035                         {  
    2036                                 $boConn = CreateObject('contactcenter.bo_connection');  
    2037                                 $type = $boConn->get_connection_type_by_conn_id($id_connection);  
    2038                                 if ($type != 1)  
    2039                                 {  
    2040                                         $contactWOemail = true;  
    2041                                         break;  
    2042                                 }  
    2043                         } 
    2044  
    2045  
     2033                        foreach ($data['old_contacts_in_list'] as $id_connection) 
     2034                        { 
     2035                                $boConn = CreateObject('contactcenter.bo_connection'); 
     2036 
     2037                                $id_contact = $boConn->get_contact_id_by_connection($id_connection); 
     2038                                $contact = CreateObject('contactcenter.so_contact', $id_contact); 
     2039                                $contact->set_field("last_status", 'U'); 
     2040                                $contact->set_field("last_update",time()."000"); 
     2041                                $contact->commit(); 
     2042                        } 
     2043                                                 
     2044                        $contactWOemail = false; 
     2045 
     2046                        foreach ($data['contact_in_list'] as $id_connection) 
     2047                        { 
     2048                                $boConn = CreateObject('contactcenter.bo_connection'); 
     2049                                 
     2050                                $id_contact = $boConn->get_contact_id_by_connection($id_connection); 
     2051                                $contact = CreateObject('contactcenter.so_contact', $id_contact); 
     2052                                $contact->set_field("last_status", 'U'); 
     2053                                $contact->set_field("last_update",time()."000"); 
     2054                                $contact->commit(); 
     2055                                 
     2056                                if (!$contactWOemail) 
     2057                                { 
     2058                                        $type = $boConn->get_connection_type_by_conn_id($id_connection); 
     2059                                        if ($type != 1) 
     2060                                        { 
     2061                                                $contactWOemail = true; 
     2062                                        } 
     2063                                } 
     2064                        } 
     2065 
     2066  
    20462067                        $acumulatedErrors = ''; 
    20472068 
     
    24972518                        if (!is_null($id) and $id !== '') 
    24982519                        { 
    2499                                 $id = $this->bo->catalog->update_single_info($id, $data);  
     2520                                $old_connections = $this->bo->catalog->get_connections($id); 
     2521                                $id = $this->bo->catalog->update_single_info($id, $data); 
    25002522                                $result = array( 
    25012523                                        'msg' => lang('Updated Successfully!'), 
     
    25222544                        else 
    25232545                        { 
    2524                                 $this->bo->catalog->update_contact_groups($id, $groups); 
     2546                                if (isset($old_connections)) 
     2547                                        $this->bo->catalog->update_contact_groups($id, $groups, $old_connections); 
     2548                                else 
     2549                                        $this->bo->catalog->update_contact_groups($id, $groups); 
    25252550                        } 
    25262551 
  • sandbox/2.2.0.2/contactcenter/js/cc.js

    r4500 r4502  
    592592                } 
    593593                ccAddGroup.setSelectedSourceLevel(ccTree.actualLevel); 
    594                 ccAddGroup.window.open(); 
     594                ccAddGroup.openEditWindow(); 
    595595        }; 
    596596                 
     
    888888 * Função que retorna os grupos que foram anteriormente selecionados, adicionados ou removidos pelo 
    889889 * usuário. O formato retornado é um array contendo: 
     890 * ['previous_selected'] { 
     891 *      [id_group] { 
     892 *              'id_group'              => o ID do grupo 
     893 *              'title'                 => o título do grupo 
     894 *      } 
    890895 * ['added'] { 
    891896 *      [id_group] { 
     
    908913        var removed_groups = diffContactIDArray(CC_initial_selected_grps, selected_groups); 
    909914        var groups = new Array(); 
     915        groups['previous_selected'] = CC_initial_selected_grps; 
    910916        groups['added'] = added_groups; 
    911917        groups['removed'] = removed_groups; 
  • sandbox/2.2.0.2/contactcenter/js/ccAddGroup.js

    r4477 r4502  
    3737                this.group_id = Element('group_id'); 
    3838                                 
     39                this.old_contacts_in_list = new Array(); 
     40                 
    3941                ccAGWinHeight = 'ccAGWinHeightMO'; 
    4042 
     
    154156                 
    155157                sdata[0] = this.title.value; 
    156                 var contacts = new Array();                              
     158                var contacts = new Array(); 
     159                var old_contacts = new Array(); 
    157160                 
    158161                for (j =0; j < this.contact_in_list.length; j++) 
    159                         contacts[j] = this.contact_in_list.options[j].value;                     
     162                        contacts[j] = this.contact_in_list.options[j].value; 
     163                for (i = 0; i < this.old_contacts_in_list.length; i++) 
     164                        old_contacts[i] = this.old_contacts_in_list[i]; 
    160165                 
    161166                if(!this.title.value) { 
     
    171176 
    172177                sdata[1] = contacts;             
    173                 sdata[2] = this.group_id.value == 'undefined' ?         sdata[2] = 0 : sdata[2]  = this.group_id.value;                                                  
     178                sdata[2] = this.group_id.value == 'undefined' ?         sdata[2] = 0 : sdata[2]  = this.group_id.value;          
     179                sdata[3] = old_contacts; 
    174180                var sdata = 'add='+escape(serialize(sdata)); 
    175181                Connector.newRequest('cAddGroup.Send', CC_url+'add_group', 'POST', handler, sdata); 
     
    200206                this.title.value = '';                           
    201207        } 
     208         
     209        cAddGroup.prototype.openEditWindow = function() 
     210        { 
     211                var list_old_contacts = Element('contact_in_list'); 
     212                for (var i = 0; i < list_old_contacts.length; i++) 
     213                { 
     214                        this.old_contacts_in_list[i] = list_old_contacts.options[i].value; 
     215                } 
     216                this.window.open(); 
     217        }; 
    202218         
    203219        /* Função para remover contato da lista */       
Note: See TracChangeset for help on using the changeset viewer.