Ignore:
Timestamp:
05/20/11 17:03:00 (13 years ago)
Author:
airton
Message:

Ticket #1912 - Permitir a criação de contatos sem email

File:
1 edited

Legend:

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

    r3826 r4477  
    524524                        { 
    525525                                $connection = CreateObject('contactcenter.so_connection', $id); 
    526  
    527                                 if ($extra === 'default' and $connection->is_default()) 
    528                                 { 
    529                                         $connection_type = CreateObject('contactcenter.so_contact_connection_type', $type); 
    530                                         $return['connection'.$count]['id_connection'] = $id; 
    531                                         $return['connection'.$count]['id_type'] = $type; 
    532                                         $return['connection'.$count]['type'] = $connection_type->get_type_name();  
    533                                         $return['connection'.$count]['connection_name'] = $connection->get_name(); 
    534                                         $return['connection'.$count]['connection_value'] = $connection->get_value(); 
    535                                         $return['connection'.$count]['connection_is_default'] = $connection->is_default(); 
    536                                         $count++; 
    537                                 } 
    538                                 else if ($extra !== 'default') 
    539                                 { 
    540                                         $connection_type = CreateObject('contactcenter.so_contact_connection_type', $type); 
    541                                         $return['connection'.$count]['id_connection'] = $id; 
    542                                         $return['connection'.$count]['id_type'] = $type; 
    543                                         $return['connection'.$count]['type'] = $connection_type->get_type_name();  
    544                                         $return['connection'.$count]['connection_name'] = $connection->get_name(); 
    545                                         $return['connection'.$count]['connection_value'] = $connection->get_value(); 
    546                                         $return['connection'.$count]['connection_is_default'] = $connection->is_default(); 
    547                                         $count++; 
     526                                if ($getDummy || $connection->get_name() !== 'no_conns') 
     527                                { 
     528                                        if ($extra === 'default' and $connection->is_default()) 
     529                                        { 
     530                                                $connection_type = CreateObject('contactcenter.so_contact_connection_type', $type); 
     531                                                $return['connection'.$count]['id_connection'] = $id; 
     532                                                $return['connection'.$count]['id_type'] = $type; 
     533                                                $return['connection'.$count]['type'] = $connection_type->get_type_name(); 
     534                                                $return['connection'.$count]['connection_name'] = $connection->get_name(); 
     535                                                $return['connection'.$count]['connection_value'] = $connection->get_value(); 
     536                                                $return['connection'.$count]['connection_is_default'] = $connection->is_default(); 
     537                                                $count++; 
     538                                        } 
     539                                        else if ($extra !== 'default') 
     540                                        { 
     541                                                $connection_type = CreateObject('contactcenter.so_contact_connection_type', $type); 
     542                                                $return['connection'.$count]['id_connection'] = $id; 
     543                                                $return['connection'.$count]['id_type'] = $type; 
     544                                                $return['connection'.$count]['type'] = $connection_type->get_type_name(); 
     545                                                $return['connection'.$count]['connection_name'] = $connection->get_name(); 
     546                                                $return['connection'.$count]['connection_value'] = $connection->get_value(); 
     547                                                $return['connection'.$count]['connection_is_default'] = $connection->is_default(); 
     548                                                $count++; 
     549                                        } 
    548550                                } 
    549551                        } 
     
    902904                        $permissions = $this->security->get_permissions(); 
    903905                         
     906                        $exist_connections = false; 
     907                         
    904908                        if (!$permissions['create']) 
    905909                        { 
     
    913917                        foreach($data as $field => $value) 
    914918                        { 
    915                                 if ($value === false) 
     919                                if ($value === false && $field != 'connections') 
    916920                                { 
    917921                                        continue; 
     
    10011005                                                foreach($value as $connection_name => $connection_fields) 
    10021006                                                { 
     1007                                                        $exist_connections = true; 
    10031008                                                        $connection = CreateObject('contactcenter.so_connection'); 
    10041009                                                        $connection->reset_values(); 
     
    10261031                        { 
    10271032                                $contact->set_field('id_owner',$GLOBALS['phpgw_info']['user']['account_id']); 
     1033                                //insert a dummy connection if the contact dont have an email and telephone 
     1034                                if (!$exist_connections)  
     1035                                { 
     1036                                        $this->add_dummy($contact); 
     1037                                } 
    10281038                                return $contact->commit(); 
    10291039                        } 
     
    15191529                                         
    15201530                                        case 'connections': 
     1531                                                //alteracao para permitir a exibicao de contatos sem email ou telefone 
     1532                                                $all_removed = true; 
     1533                                                $added_connection = false; 
    15211534                                                foreach($value as $connection_name => $connection_fields) 
    15221535                                                { 
     
    15371550                                                        } 
    15381551                                                         
     1552                                                        $all_removed = false; 
     1553                                                        // removes the dummy if there is at least one connection 
     1554                                                        if (!$added_connection) 
     1555                                                        { 
     1556                                                                $this->remove_dummy($contact); //remove the dummy 
     1557                                                        } 
     1558                                                        $added_connection = true; 
    15391559                                                        $id_connection = $connection_fields['id_connection']; 
    15401560                                                        if ($id_connection === '_NEW_' or 
     
    15641584                                                        $contact->set_connection($id_connection, $connection_fields['id_typeof_connection']); 
    15651585                                                } 
     1586                                                // add the dummy if there is no other connection 
     1587                                                if ($all_removed) 
     1588                                                        $this->add_dummy($contact); 
    15661589                                                break; 
    15671590                                                 
     
    15831606         
    15841607                /*! 
     1608                        @function remove_dummy 
     1609                        @abstract Remove the dummy connection entry. 
     1610                        @author Luiz Carlos Viana Melo - Prognus 
     1611                 */ 
     1612                function remove_dummy($so_contact) 
     1613                { 
     1614                        //$so_contact = CreateObject('contactcenter.so_contact', $id_contact); 
     1615                        $connections = $so_contact->get_connections(); 
     1616                        foreach ($connections as $id_connection => $type_connection) 
     1617                        { 
     1618                                $so_connection = CreateObject('contactcenter.so_connection', $id_connection); 
     1619                                if ($so_connection->get_field('connection_name') === 'no_conns') //if connection is the dummy one 
     1620                                { 
     1621                                        if (!$so_connection->remove()) 
     1622                                        { 
     1623                                                return false; 
     1624                                        } 
     1625                                        $so_contact->remove_connection($id_connection); 
     1626                                        //$so_connection->commit(); 
     1627                                        break; 
     1628                                } 
     1629                        } 
     1630                 
     1631                } 
     1632                 
     1633                /*! 
     1634                        @function add_dummy 
     1635                        @abstract Add a dummy connection entry on a contact. This is necessary for 
     1636                                possibility on adding a contact that dont have an email or telephone. 
     1637                        @return The dummy's connection ID. 
     1638                        @author Luiz Carlos Viana Melo - Prognus 
     1639                 */ 
     1640                function add_dummy($so_contact) 
     1641                { 
     1642                        $so_connection = CreateObject('contactcenter.so_connection'); 
     1643                        $so_connection->reset_values(); 
     1644                         
     1645                        $so_connection->set_field('connection_name', 'no_conns'); //defined code for the dummy connection 
     1646                        $so_connection->set_field('connection_value', ''); 
     1647                        $so_connection->set_field('connection_is_default', true); 
     1648                         
     1649                        if (!$so_connection->commit()) 
     1650                        { 
     1651                                return false; 
     1652                        } 
     1653                        $id_connection = $so_connection->get_id(); 
     1654                        $so_contact->set_connection($id_connection, 2); 
     1655                        return $id_connection; 
     1656                } 
     1657                                         
     1658                /*! 
    15851659                 
    15861660                        @function update_prefix 
Note: See TracChangeset for help on using the changeset viewer.