Ignore:
Timestamp:
05/24/11 17:58:15 (13 years ago)
Author:
airton
Message:

Ticket #1925 - Permitir associar um contato com um grupo na tela de criação do contato

File:
1 edited

Legend:

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

    r4477 r4498  
    518518                { 
    519519                        $contact = CreateObject('contactcenter.so_contact', $id_contact); 
    520                         $connections = $contact->get_connections($extra); 
    521                  
     520                        $connections = $contact->get_connections(); 
     521                        $getDummy = false; 
     522                        if ($extra && $extra === 'defaultwdummy') 
     523                        { 
     524                                $getDummy = true; 
     525                                $extra = 'default'; 
     526                        } 
     527                         
    522528                        $count = 1;      
    523529                        foreach($connections as $id => $type) 
     
    552558                         
    553559                        return $return; 
     560                } 
     561 
     562                /* 
     563                 * @function update_contact_groups 
     564                 * @abstract Atualiza os grupos onde o contato está inserido. 
     565                 * @author Luiz Carlos Viana Melo - Prognus 
     566                 * @param (integer) $id_contact O ID do contato. 
     567                 * @param (array) $groups Os grupos onde o contato será inserido/removido. O 
     568                 * formato dos grupos será: 
     569                 * array( 
     570                 *      'added'         => array( 
     571                 *                                              id_group => array ( 
     572                 *                                                                              'id_group' => O ID do grupo. 
     573                 *                                                                              'title' => O título do grupo. 
     574                 *                                                                      ) 
     575                 *                                      ) 
     576                 *      'removed'       => mesmo formato do added. 
     577                 * ) 
     578                 */ 
     579                function update_contact_groups($id_contact, $groups, $old_connections = false) 
     580                { 
     581                        $connections = $this->get_connections($id_contact, 'defaultwdummy'); 
     582                        $default_connection = false; 
     583                        foreach ($connections as $connection) 
     584                        { 
     585                                if (!$default_connection) 
     586                                { 
     587                                        $default_connection = $connection; 
     588                                } 
     589                                if ($connection['id_type'] === 1) 
     590                                { 
     591                                        $default_connection = $connection; 
     592                                } 
     593                                if($default_connection['id_type'] === 1) 
     594                                { 
     595                                        break; 
     596                                } 
     597                                         
     598                        } 
     599                         
     600                        $altered = false; 
     601 
     602                        if ($default_connection) 
     603                        { 
     604                                $bo_group = CreateObject('contactcenter.bo_group'); 
     605                                $old_groups = $groups['previous_selected']; 
     606                                if ($old_connections) 
     607                                        $bo_group->update_contact_groups($default_connection['id_connection'], $old_connections, $old_groups); 
     608                                $added_groups = $groups['added']; 
     609                                $removed_groups = $groups['removed']; 
     610                                         
     611                                foreach ($added_groups as $group) 
     612                                { 
     613                                        $altered = true; 
     614                                        $c = array(); 
     615                                        $c[] = $default_connection['id_connection']; 
     616                                        $bo_group->add_contacts_in_group($group['id_group'], $c); 
     617                                } 
     618                                         
     619                                foreach ($removed_groups as $group) 
     620                                { 
     621                                        $altered = true; 
     622                                        $c = array(); 
     623                                        $c[] = $default_connection['id_connection']; 
     624                                        $bo_group->remove_contacts_from_group($group['id_group'], $c); 
     625                                } 
     626                        } 
     627                         
     628                        if ($altered) 
     629                        { 
     630                                $contact = CreateObject('contactcenter.so_contact', $id_contact); 
     631                                $contact->set_field("last_status", 'U'); 
     632                                $contact->set_field("last_update",time()."000"); 
     633                                return $contact->commit(); 
     634                        } 
    554635                } 
    555636         
Note: See TracChangeset for help on using the changeset viewer.