- Timestamp:
- 05/20/11 17:03:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.2.0.2/contactcenter/inc/class.bo_people_catalog.inc.php
r3826 r4477 524 524 { 525 525 $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 } 548 550 } 549 551 } … … 902 904 $permissions = $this->security->get_permissions(); 903 905 906 $exist_connections = false; 907 904 908 if (!$permissions['create']) 905 909 { … … 913 917 foreach($data as $field => $value) 914 918 { 915 if ($value === false )919 if ($value === false && $field != 'connections') 916 920 { 917 921 continue; … … 1001 1005 foreach($value as $connection_name => $connection_fields) 1002 1006 { 1007 $exist_connections = true; 1003 1008 $connection = CreateObject('contactcenter.so_connection'); 1004 1009 $connection->reset_values(); … … 1026 1031 { 1027 1032 $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 } 1028 1038 return $contact->commit(); 1029 1039 } … … 1519 1529 1520 1530 case 'connections': 1531 //alteracao para permitir a exibicao de contatos sem email ou telefone 1532 $all_removed = true; 1533 $added_connection = false; 1521 1534 foreach($value as $connection_name => $connection_fields) 1522 1535 { … … 1537 1550 } 1538 1551 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; 1539 1559 $id_connection = $connection_fields['id_connection']; 1540 1560 if ($id_connection === '_NEW_' or … … 1564 1584 $contact->set_connection($id_connection, $connection_fields['id_typeof_connection']); 1565 1585 } 1586 // add the dummy if there is no other connection 1587 if ($all_removed) 1588 $this->add_dummy($contact); 1566 1589 break; 1567 1590 … … 1583 1606 1584 1607 /*! 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 /*! 1585 1659 1586 1660 @function update_prefix
Note: See TracChangeset
for help on using the changeset viewer.