Changeset 5131 for trunk/contactcenter/inc/class.ui_data.inc.php
- Timestamp:
- 11/03/11 11:17:35 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/inc/class.ui_data.inc.php
r4838 r5131 19 19 var $public_functions = array( 20 20 'data_manager' => true, 21 'advanced_searh_fields' => true 21 22 ); 22 23 … … 68 69 } 69 70 70 $this->page_info['actual_catalog'] = &$this->bo->set_catalog($this->page_info['actual_catalog']);71 $this->page_info['actual_catalog'] = $this->bo->set_catalog($this->page_info['actual_catalog']); 71 72 72 73 … … 257 258 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.')); 258 259 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.')); 260 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2003', lang('Export as Outlook 2003 CSV.')); 259 261 $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 260 262 $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 261 263 $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 262 264 $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 265 $GLOBALS['phpgw']->template->set_var('cc_msg_show_extra_detail', lang("Show extra contact's details.")); 263 266 264 267 $select_groups = ''; … … 282 285 $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'default'); 283 286 } 287 288 /* 289 * Monta Contactcenter Busca Avancada 290 */ 291 $c = CreateObject('phpgwapi.config','contactcenter'); 292 $c->read_repository(); 293 $current_config = $c->config_data; 294 295 $arraySearch = array(); 296 foreach ($current_config as $index => $value) 297 { 298 299 if(substr($index, 0, 24) == 'cc_attribute_searchable_') 300 { 301 if($value == 'true') 302 { 303 $v = substr($index, 24, strlen($index)); 304 $arraySearch[] = $v; 305 } 306 } 307 } 308 $advanceSearchArray = array(); 309 foreach ($arraySearch as $value) 310 { 311 foreach ($current_config as $index => $value2) 312 { 313 if($value == substr($index, 22, strlen($index)) && substr($index, 0, 22) == 'cc_attribute_ldapname_') 314 { 315 foreach ($current_config as $index2 => $value3) 316 { 317 if($value == substr($index2, 18, strlen($index2)) && substr($index2, 0, 18) == 'cc_attribute_name_') 318 $advanceSearchArray[$value2] = $value3; 319 } 320 } 321 322 } 323 } 324 325 $advanceSearch = array(); 326 foreach ($advanceSearchArray as $index => $value) 327 $advanceSearch[] ='"'.$index.'":"'.$value.'"'; 328 329 $advancedFields = "{".implode(',',$advanceSearch)."}"; 330 331 332 $GLOBALS['phpgw']->template->set_var('cc_config_advanced_search', $advancedFields); 333 334 335 284 336 $GLOBALS['phpgw']->template->parse('out','index'); 285 337 … … 289 341 $main .= $api->get_quick_add_plugin(); 290 342 $main .= $api->get_add_group(); 343 $main .= $api->get_contact_details(); 291 344 $main .= $GLOBALS['phpgw']->template->get_var('out'); 292 345 … … 358 411 case 'get_catalog_add_contact': 359 412 // To support ldap catalogs with accentuation 360 echo serialize($this->get_catalog_add_contact( utf8_decode($_POST['id'])));413 echo serialize($this->get_catalog_add_contact($_POST['id'])); 361 414 return; 362 415 … … 450 503 echo $this->get_list_owners_perms_add(); 451 504 return; 452 505 case 'get_contact_details': 506 return $this->get_contact_details($_GET['id']); 453 507 } 454 508 } … … 487 541 { 488 542 $id_catalog = str_replace('\\"', '"', $id_catalog); 489 $temp = &$this->bo->set_catalog($id_catalog);543 $temp = $this->bo->set_catalog($id_catalog); 490 544 491 545 if(!$this->bo->catalog->src_info) { … … 505 559 $this->page_info['changed'] = true; 506 560 $this->page_info['actual_entries'] = false; 507 $this->page_info['actual_catalog'] = &$temp;561 $this->page_info['actual_catalog'] = $temp; 508 562 $this->save_session(); 509 563 … … 1330 1384 ); 1331 1385 1386 //verifica se esta habilitado a opcao de exibir os detalhes extras 1387 $objconfig = CreateObject('phpgwapi.config', 'contactcenter'); 1388 $config = $objconfig->read_repository(); 1389 1332 1390 //echo 'Page: '.$page.'<br>'; 1333 1391 $n_entries = count($this->page_info['actual_entries']); … … 1389 1447 for($z = 0; $z < $info['count']; $z++) { 1390 1448 $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]); 1449 } 1450 1451 //SAMPLE : dc=teste, dc=diretorio, dc=empresa 1452 if(!count($owner_names)){ 1453 $dns = explode(',', $dn); 1454 for($i = count($dns); $i > 0; $i--){ 1455 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); 1456 //verifica se veio a base como parametro, remoção de erros gerados por paramentro null 1457 //if(isset($dns[$i])){ 1458 $sr = ldap_search($ds,$dns[$i], $filter,$justThese); 1459 $info = ldap_get_entries($ds, $sr); 1460 ldap_close($ds); 1461 for($z = 0; $z < $info['count']; $z++) { 1462 $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]); 1463 } 1464 if(count($owner_names)){ 1465 $i = 0; 1466 } 1467 // } 1468 } 1391 1469 } 1392 1470 } … … 1418 1496 ); 1419 1497 1420 $groups = &$this->bo->catalog->get_multiple_entries($ids,$fields);1498 $groups = $this->bo->catalog->get_multiple_entries($ids,$fields); 1421 1499 1422 1500 $i = 0; … … 1473 1551 if($external) 1474 1552 { 1475 $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields,false,true);1553 $contacts = $this->bo->catalog->get_multiple_entries($ids,$fields,false,true); 1476 1554 } else{ 1477 $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 1478 } 1479 1555 $contacts = $this->bo->catalog->get_multiple_entries($ids,$fields); 1556 } 1480 1557 /*******/ 1481 1482 1483 1558 if (!is_array($contacts) or !count($contacts)) 1484 1559 { … … 1517 1592 /********/ 1518 1593 1519 $final[3][$i][2] = $contact['companies']['company1']['title']? urldecode( $contact['companies']['company1']['title'] ):'none';1594 $final[3][$i][2] = $contact['companies']['company1']['title']? $contact['companies']['company1']['title']:'none'; 1520 1595 1521 1596 //Para exibir a matricula do empregado … … 1551 1626 $default_phone_found = true; 1552 1627 } 1553 1628 if($final[3][$i][4] == 'none' or !$final[3][$i][4]){ 1629 $final[3][$i][4] = "Não informado."; 1630 $final[3][$i][13] = $conn_info['id_connection']; 1631 } 1554 1632 /**rev 104**/ 1555 1633 //if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external){ … … 1563 1641 $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 1564 1642 } 1643 if($final[3][$i][4] == 'none' or !$final[3][$i][4]){ 1644 $final[3][$i][4] = 'Não informado'; 1645 $final[3][$i][13] = $conn_info['id_connection']; 1646 1647 } 1565 1648 } 1566 1649 } … … 1571 1654 } 1572 1655 1573 if (!$final[3][$i][4]) 1574 { 1575 $final[3][$i][4] = 'none'; 1656 if($final[3][$i][4] == 'none' or !$final[3][$i][4]){ 1657 $final[3][$i][4] = 'Não informado.'; 1658 $final[3][$i][13] = $conn_info['id_connection']; 1659 1576 1660 } 1577 1661 1578 1662 $final[3][$i][5] = $contact['alias']? urldecode( $contact['alias'] ):'none'; 1579 $final[3][$i][6] = $ids[$i];1663 $final[3][$i][6] = utf8_decode($ids[$i]); 1580 1664 1581 1665 /**rev 104**/ … … 1593 1677 $final[3][$i][12] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; 1594 1678 } 1595 /******/1596 1679 1597 1680 $final[4][$i] = $contact['photo'] ? 1 : 0; 1681 1682 1683 1598 1684 $i++; 1599 1685 } … … 1610 1696 $final[9] = $count; 1611 1697 $final[11] = $this->bo->catalog_level; 1612 1613 1698 $final[12] = isset($config['cc_allow_details'])? $config['cc_allow_details'] : false; 1699 $final[13] = '<span class="" '; 1614 1700 $this->page_info['actual_letter'] = $letter; 1615 1701 $this->page_info['actual_page'] = $page; … … 1656 1742 } 1657 1743 ldap_close($ds); 1744 if(!count($owner_names)){ 1745 $dns = explode(',', $dn); 1746 for($i = count($dns); $i > 0; $i--){ 1747 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); 1748 $sr = ldap_search($ds,$dns[$i], $filter,$justThese); 1749 $info = ldap_get_entries($ds, $sr); 1750 ldap_close($ds); 1751 for($z = 0; $z < $info['count']; $z++) { 1752 $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]); 1753 } 1754 if(count($owner_names)){ 1755 $i = 0; 1756 } 1757 } 1758 } 1658 1759 } 1659 1760 echo serialize ($owner_names); … … 1690 1791 $boGroup = CreateObject('contactcenter.bo_group'); 1691 1792 1692 $all_contacts = $boGroup->get_all_contacts( 'only_email',$shared_from);1793 $all_contacts = $boGroup->get_all_contacts(false,$shared_from); 1693 1794 1694 1795 $contact_options = ""; 1695 1796 if(count($all_contacts)) { 1696 1797 foreach($all_contacts as $idx => $contact) { 1697 $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; 1798 $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']; 1799 if (isset($contact['connection_value'])) 1800 $contact_options .= " (".$contact['connection_value'].")</OPTION>"; 1801 else 1802 $contact_options .= " (". $contact['phone'].")</OPTION>"; 1698 1803 } 1699 1804 } … … 1805 1910 1806 1911 /* Relations */ 1912 /* Groups */ 1913 /* 1914 * Criado uma estrutura no data que conterá os grupos do 1915 * contato. O formato é: 1916 * data['groups'] = array( 1917 * 'id_group' => array( 1918 * 'id_group', 'title', 'short_name' 1919 * ) 1920 * ); 1921 */ 1922 $boGroup = CreateObject('contactcenter.bo_group'); 1923 $groups = $boGroup->get_contact_groups($id); 1924 1925 $i = 0; 1926 $data['groups'] = array(); 1927 if(is_array($groups)) 1928 foreach($groups as $group) 1929 { 1930 $idGroup = $group['id_group']; 1931 $data['groups'][$idGroup] = array( 1932 'title' => $group['title'], 1933 'id_group' => $idGroup, 1934 'short_name' => $group['short_name'] 1935 ); 1936 $i++; 1937 } 1807 1938 1808 1939 echo serialize($data); … … 1824 1955 $predata[] = $boPeopleCatalog -> get_all_countries(); 1825 1956 $predata[] = $boPeopleCatalog -> get_all_connections_types(); 1957 $boGroup = CreateObject('contactcenter.bo_group'); 1958 //$predata[] = $boGroup->get_groups_by_user(); 1826 1959 //$predata[] = $this->bo->catalog->get_all_relations_types(); 1827 1960 1961 if ($this->typeContact == 'shared_contacts') { 1962 $so_contact = CreateObject('contactcenter.so_contact', $GLOBALS['phpgw_info']['user']['account_id']); 1963 $relacionados = $so_contact->get_relations(); 1964 1965 foreach($relacionados as $uid_relacionado => $tipo_relacionamento) { 1966 $predata[] = $boGroup->get_groups_by_user($uid_relacionado); 1967 } 1968 } else { 1969 $predata[] = $boGroup->get_groups_by_user(); 1970 } 1971 1972 1828 1973 $i = 0; 1829 1974 foreach($predata as $data_) … … 1883 2028 } 1884 2029 } 1885 1886 // verifica se email já existe!1887 $boGroup = CreateObject('contactcenter.bo_group');1888 $contact = $boGroup->verify_contact($tdata[4]);1889 1890 if($contact)1891 {1892 $str_contact = "\r\n - ".implode("\r\n - ",$contact);1893 1894 if ($echo)1895 {1896 echo serialize(array(1897 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),1898 'status' => 'alreadyExists'1899 ));1900 1901 return;1902 }1903 else1904 {1905 return serialize(array(1906 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),1907 'status' => 'alreadyExists',1908 'id_connection' => $contact[1]1909 ));1910 }1911 }1912 1913 2030 $data['alias'] = addslashes($tdata[0]); 1914 2031 $data['given_names'] = addslashes($tdata[1]); … … 2305 2422 $email = $dataConn['connection'.$i]['connection_value']; 2306 2423 } 2307 }2308 // verifica se email já existe!2309 $boGroup = CreateObject('contactcenter.bo_group');2310 $contact = $boGroup->verify_contact($email);2311 if($contact)2312 {2313 $str_contact = "\r\n - ".implode("\r\n - ",$contact);2314 echo serialize(array(2315 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),2316 'status' => 'alreadyExists'2317 ));2318 return;2319 2424 } 2320 2425 … … 2448 2553 /* Does nothing... */ 2449 2554 break; 2450 2555 case 'groups': 2556 $groups = $data['groups']; 2557 unset($data['groups']); 2558 break; 2451 2559 default: 2452 2560 echo serialize(array( … … 2482 2590 'status' => 'fail' 2483 2591 ); 2592 } 2593 else 2594 { 2595 if (isset($old_connections)) 2596 $this->bo->catalog->update_contact_groups($id, $groups, $old_connections); 2597 else 2598 $this->bo->catalog->update_contact_groups($id, $groups); 2484 2599 } 2485 2600 … … 2617 2732 $email = $dataConn['connection'.$i]['connection_value']; 2618 2733 } 2619 }2620 // verifica se email já existe!2621 $boGroup = CreateObject('contactcenter.bo_group');2622 $contact = $boGroup->verify_shared_contact($owner,$email);2623 if($contact)2624 {2625 $str_contact = "\r\n - ".implode("\r\n - ",$contact);2626 echo serialize(array(2627 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),2628 'status' => 'alreadyExists'2629 ));2630 return;2631 2734 } 2632 2735 … … 2765 2868 } 2766 2869 2767 $code = '$id = $this->bo->catalog->';2870 //$code = '$id = $this->bo->catalog->'; 2768 2871 2769 2872 if (!is_null($id) and $id !== '') 2770 2873 { 2771 $code .= $code.'update_single_info($id, $data);'; 2874 //$code .= $code.'update_single_info($id, $data);'; 2875 $id = $this->bo->catalog->update_single_info($id, $data); 2876 if(!$id){ 2772 2877 $result = array( 2773 'msg' => lang('Updated Successfully!'), 2878 'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'. 2879 'Report the problem to the Administrator.'), 2880 'status' => 'fail' 2881 ); 2882 } 2883 else{ 2884 $result = array( 2885 'msg' => lang('Updated Successfully!'), 2774 2886 'status' => 'ok' 2775 2887 ); 2776 2888 } 2889 } 2777 2890 else 2778 2891 { 2779 $code .= 'add_single_entry($data,'.$owner.');'; 2780 $result = array( 2781 'msg' => lang('Entry Added Successfully!'), 2782 'status' => 'ok' 2783 ); 2784 } 2785 2786 eval($code); 2787 2788 if (!($id)) 2789 { 2892 //$code .= 'add_single_entry($data,'.$owner.');'; 2893 $id = $this->bo->catalog->add_single_entry($data,$owner); 2894 if(!$id){ 2790 2895 $result = array( 2791 2896 'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'. … … 2794 2899 ); 2795 2900 } 2796 2901 else{ 2902 $result = array( 2903 'msg' => lang('Entry Added Successfully!'), 2904 'status' => 'ok' 2905 ); 2906 } 2907 } 2797 2908 echo serialize($result); 2798 }2909 } 2799 2910 /*! 2800 2911 … … 3096 3207 if (!is_array($data) || (!$data['search_for'] && !$full_search) || !is_array($data['fields'])) 3097 3208 { 3098 echo serialize(array( 3099 'msg' => lang('Invalid parameters'), 3100 'status' => 'abort' 3101 )); 3102 3103 return array('error' => lang('Invalid parameters')); 3209 // echo serialize(array( 3210 // 'msg' => lang('Invalid parameters'), 3211 // 'status' => 'abort' 3212 // )); 3213 3214 // return array('error' => lang('Invalid parameters')); 3215 $rules = array( 3216 0 => array( 3217 'field' => $data['fields']['search'], 3218 'type' => 'LIKE', 3219 'value' => '%' 3220 ) 3221 ); 3104 3222 } 3105 3223 … … 3118 3236 { 3119 3237 3120 $data['search_for'] = utf8_encode($data['search_for']);3238 $data['search_for'] = $data['search_for']; 3121 3239 } 3122 3240 … … 3245 3363 // Get only this attributes: dn, cn for external catalogs, 3246 3364 // used to restrict the attributes used in filters 3247 $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for'] != null); 3248 } 3365 $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC', 'customFilter' => $data['custom_filter'], 'CN' => $data['CN'], 'exact' => $data['exact']), $data['search_for'] != null); } 3249 3366 else 3250 3367 { … … 3259 3376 'contact.connection.mail', 3260 3377 'contact.connection.phone' 3261 ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for_area'], $data['search_for'] != null ); 3262 } 3378 ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC', 'customFilter' => $data['custom_filter'], 'CN' => $data['CN'], 'exact' => $data['exact']), $data['search_for_area'], $data['search_for'] != null ); } 3263 3379 3264 3380 if (!is_array($ids) || !count($ids)) … … 3641 3757 for($z = 0; $z < 5; $z++) { 3642 3758 $participant = $info[0][$justThese[$z]]; 3759 $participant[0] = utf8_decode($participant[0]); 3643 3760 array_push($array_participants, $participant); 3644 3761 } … … 3755 3872 $contacts = $boGroup->get_all_contacts(); 3756 3873 $streamBuffer = ''; 3874 $stramArray = Array(); 3757 3875 3758 3876 if(!count($contacts)) … … 3780 3898 3781 3899 case 'outlook_pt-BR': 3782 $streamBuffer = "Nome; Sobrenome;Segundo nome;Nome;Apelido;End. de email;Endereço residencial;"3900 $streamBuffer = "Nome;Apelido;End. de email;Endereço residencial;" 3783 3901 ."Cidade do endereço residencial;CEP do endereço residencial;Estado;País/região do endereço residencial;" 3784 3902 ."Telefone residencial;Fax residencial;Telefone celular;Página pessoal da Web;Rua do endereço comercial;" … … 3789 3907 foreach($contacts as $index => $object){ 3790 3908 $streamBuffer.= "\"".$object[ 'names_ordered'] . "\";" 3791 .";;;"3792 3909 . "\"".$object[ 'alias' ] . "\";" 3793 3910 . "\"".$object[ 'main-mail' ] . "\";" … … 3813 3930 . "\"".$object[ 'job_title' ] . "\";" 3814 3931 . "\"".$object[ 'department' ] . "\";" 3815 ." ;"3932 ."\"\";" 3816 3933 . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"\r\n"; 3817 3934 } … … 3958 4075 ."Home Address 2,Home City,Home State,Home ZipCode,Home Country,Work Address,Work Address 2," 3959 4076 ."Work City,Work State,Work ZipCode,Work Country,Job Title,Department,Organization,Web Page 1," 3960 ."Web Page 2,Birth Year,Birth Month,Birth Day,Custom 1,Custom 2,Custom 3,Custom 4,Notes,\ n";4077 ."Web Page 2,Birth Year,Birth Month,Birth Day,Custom 1,Custom 2,Custom 3,Custom 4,Notes,\r\n"; 3961 4078 3962 4079 foreach($contacts as $index => $object){ 3963 4080 $array_birth = explode("-",$object[ 'birthdate' ]); 3964 $streamBuffer.= "\"".$object[ 'names_ordered'] . "\"," 3965 .",," 3966 . "\"".$object[ 'alias' ] . "\"," 3967 . "\"".$object[ 'main-mail' ] . "\"," 3968 . "\"".$object[ 'alternative-mail' ] . "\"," 3969 ."," 3970 . "\"".$phone . "\"," 3971 . "\"".$object[ 'home-phone' ] . "\"," 3972 . "\"".$object[ 'business-fax' ] . "\"," 3973 . "\"".$object[ 'business-pager' ] . "\"," 3974 . "\"".$object[ 'mobile' ] . "\"," 3975 . "\"".$object[ 'home-address' ] . "\"," 3976 . "\"".$object[ 'home-address-2' ] . "\"," 3977 . "\"".$object[ 'home-city_name' ] . "\"," 3978 . "\"".$object[ 'home-state_name' ] . "\"," 3979 . "\"".$object[ 'home-postal_code' ] . "\"," 3980 . "\"".$object[ 'home-id_country' ] . "\"," 3981 . "\"".$object[ 'business-address' ] . "\"," 3982 . "\"".$object[ 'business-address-2' ] . "\"," 3983 . "\"".$object[ 'business-city_name' ] . "\"," 3984 . "\"".$object[ 'business-state_name' ] . "\"," 3985 . "\"".$object[ 'business-postal_code' ] . "\"," 3986 . "\"".$object[ 'business-id_country' ] . "\"," 3987 . "\"".$object[ 'job_title' ] . "\"," 3988 . "\"".$object[ 'department' ] . "\"," 3989 . "\"".$object[ 'corporate_name' ] . "\"," 3990 . "\"".$object[ 'web_page' ] . "\"," 3991 . "\"".$object[ 'web_page' ] . "\"," 3992 . "\"".$array_birth[0] . "\"," 3993 . "\"".$array_birth[1] . "\"," 3994 . "\"".$array_birth[2] . "\"," 3995 .",,,," 3996 . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\",\r\n"; 3997 4081 4082 $stramArray[0] = "\"".$object[ 'names_ordered'] . "\""; 4083 $stramArray[1] = ""; 4084 $stramArray[2] = "\"".$object[ 'names_ordered'] . "\""; 4085 $stramArray[3] = "\"".$object[ 'alias' ] . "\""; 4086 $stramArray[4] = "\"".$object[ 'main-mail' ] . "\""; 4087 $stramArray[5] = "\"".$object[ 'alternative-mail' ] . "\""; 4088 $stramArray[6] = ""; 4089 $stramArray[7] = "\"".$object[ 'business-phone' ] . "\""; 4090 $stramArray[8] = "\"".$object[ 'home-phone' ] . "\""; 4091 $stramArray[9] = "\"".$object[ 'business-fax' ] . "\""; 4092 $stramArray[10] = "\"".$object[ 'business-pager' ] . "\""; 4093 $stramArray[11] = "\"".$object[ 'mobile' ] . "\""; 4094 $stramArray[12] = "\"".$object[ 'home-address' ] . "\""; 4095 $stramArray[13] = "\"".$object[ 'home-address-2' ] . "\""; 4096 $stramArray[14] = "\"".$object[ 'home-city_name' ] . "\""; 4097 $stramArray[15] = "\"".$object[ 'home-state_name' ] . "\""; 4098 $stramArray[16] = "\"".$object[ 'home-postal_code' ] . "\""; 4099 $stramArray[17] = "\"".$object[ 'home-id_country' ] . "\""; 4100 $stramArray[18] = "\"".$object[ 'business-address' ] . "\""; 4101 $stramArray[19] = "\"".$object[ 'business-address-2' ] . "\""; 4102 $stramArray[20] = "\"".$object[ 'business-city_name' ] . "\""; 4103 $stramArray[21] = "\"".$object[ 'business-state_name' ] . "\""; 4104 $stramArray[22] = "\"".$object[ 'business-postal_code' ] . "\""; 4105 $stramArray[23] = "\"".$object[ 'business-id_country' ] . "\""; 4106 $stramArray[24] = "\"".$object[ 'job_title' ] . "\""; 4107 $stramArray[25] = "\"".$object[ 'department' ] . "\""; 4108 $stramArray[26] = "\"".$object[ 'corporate_name' ] . "\""; 4109 $stramArray[27] = ""; 4110 $stramArray[28] = ""; 4111 $stramArray[29] = "\"".$array_birth[0] . "\""; 4112 $stramArray[30] = "\"".$array_birth[1] . "\""; 4113 $stramArray[31] = "\"".$array_birth[2] . "\""; 4114 $stramArray[32] = ""; 4115 $stramArray[33] = ""; 4116 $stramArray[34] = ""; 4117 $stramArray[35] = ""; 4118 $stramArray[36] = ""; 4119 $stramArray[37] = "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"\r\n"; 4120 4121 if($object[ 'phone' ]){ 4122 if(!$object[ 'home-phone' ]) 4123 $stramArray[8] = "\"".$object[ 'phone' ]. "\""; 4124 else if(!$object[ 'mobile' ]) 4125 $stramArray[11] = "\"".$object[ 'phone' ]. "\""; 4126 else if(!$object[ 'business-phone' ]) 4127 $stramArray[7] = "\"".$object[ 'phone' ]. "\""; 4128 } 4129 4130 $streamBuffer .= implode("," , $stramArray); 3998 4131 } 3999 4132 break; … … 4007 4140 4008 4141 foreach($contacts as $index => $object){ 4009 $streamBuffer .= "\"".$object[ 'names_ordered'] . "\"," 4010 . "\"".$object[ 'alias' ] . "\"," 4011 . "\"".$object[ 'main-mail' ] . "\"," 4012 . "\"".$object[ 'alternative-mail' ] . "\"," 4013 . "\"".$object[ 'mobile' ] . "\"," 4014 . "\"".$object[ 'business-phone' ] . "\"," 4015 . "\"".$object[ 'business-address' ] . "\"," 4016 . "\"".$object[ 'business-complement' ] . "\"," 4017 . "\"".$object[ 'business-postal_code' ] . "\"," 4018 . "\"".$object[ 'business-city_name' ] . "\"," 4019 . "\"".$object[ 'business-state_name' ] . "\"," 4020 . "\"".$object[ 'business-id_country' ] . "\"," 4021 . "\"".$object[ 'home-phone' ] . "\"," 4022 . "\"".$object[ 'home-address' ] . "\"," 4023 . "\"".$object[ 'home-complement' ] . "\"," 4024 . "\"".$object[ 'home-postal_code' ] . "\"," 4025 . "\"".$object[ 'home-city_name' ] . "\"," 4026 . "\"".$object[ 'home-state_name' ] . "\"," 4027 . "\"".$object[ 'home-id_country' ] . "\"," 4028 . "\"".$object[ 'birthdate' ] . "\"," 4029 . "\"".$object[ 'sex' ] . "\"," 4030 . "\"".$object[ 'pgp_key' ] . "\"," 4031 . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"," 4032 . "\"".$object[ 'web_page' ] . "\"," 4033 . "\"".$object[ 'corporate_name' ] . "\"," 4034 . "\"".$object[ 'job_title' ] . "\"," 4035 . "\"".$object[ 'department' ] . "\"," 4036 . "\"".$object[ 'business-fax' ] . "\"," 4037 . "\"".$object[ 'business-pager' ] . "\"," 4038 . "\"".$object[ 'business-mobile' ] . "\"," 4039 . "\"".$object[ 'home-fax' ] . "\"," 4040 . "\"".$object[ 'home-pager' ] . "\"," 4041 . "\"".$object[ 'business-address-2' ] . "\"," 4042 . "\"".$object[ 'home-address-2' ] . "\"\r\n"; 4142 $stramArray[0] = "\"".$object[ 'names_ordered'] . "\""; 4143 $stramArray[1] = "\"".$object[ 'alias' ] . "\""; 4144 $stramArray[2] = "\"".$object[ 'main-mail' ] . "\""; 4145 $stramArray[3] = "\"".$object[ 'alternative-mail' ] . "\""; 4146 $stramArray[4] = "\"".$object[ 'mobile' ] . "\""; 4147 $stramArray[5] = "\"".$object[ 'business-phone' ] . "\""; 4148 $stramArray[6] = "\"".$object[ 'business-address' ] . "\""; 4149 $stramArray[7] = "\"".$object[ 'business-complement' ] . "\""; 4150 $stramArray[8] = "\"".$object[ 'business-postal_code' ] . "\""; 4151 $stramArray[9] = "\"".$object[ 'business-city_name' ] . "\""; 4152 $stramArray[10] = "\"".$object[ 'business-state_name' ] . "\""; 4153 $stramArray[11] = "\"".$object[ 'business-id_country' ] . "\""; 4154 $stramArray[12] = "\"".$object[ 'home-phone' ] . "\""; 4155 $stramArray[13] = "\"".$object[ 'home-address' ] . "\""; 4156 $stramArray[14] = "\"".$object[ 'home-complement' ] . "\""; 4157 $stramArray[15] = "\"".$object[ 'home-postal_code' ] . "\""; 4158 $stramArray[16] = "\"".$object[ 'home-city_name' ] . "\""; 4159 $stramArray[17] = "\"".$object[ 'home-state_name' ] . "\""; 4160 $stramArray[18] = "\"".$object[ 'home-id_country' ] . "\""; 4161 $stramArray[19] = "\"".$object[ 'birthdate' ] . "\""; 4162 $stramArray[20] = "\"".$object[ 'sex' ] . "\""; 4163 $stramArray[21] = "\"".$object[ 'pgp_key' ] . "\""; 4164 $stramArray[22] = "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\""; 4165 $stramArray[23] = "\"".$object[ 'web_page' ] . "\""; 4166 $stramArray[24] = "\"".$object[ 'corporate_name' ] . "\""; 4167 $stramArray[25] = "\"".$object[ 'job_title' ] . "\""; 4168 $stramArray[26] = "\"".$object[ 'department' ] . "\""; 4169 $stramArray[27] = "\"".$object[ 'business-fax' ] . "\""; 4170 $stramArray[28] = "\"".$object[ 'business-pager' ] . "\""; 4171 $stramArray[29] = "\"".$object[ 'business-mobile' ] . "\""; 4172 $stramArray[30] = "\"".$object[ 'home-fax' ] . "\""; 4173 $stramArray[31] = "\"".$object[ 'home-pager' ] . "\""; 4174 $stramArray[32] = "\"".$object[ 'business-address-2' ] . "\""; 4175 $stramArray[33] = "\"".$object[ 'home-address-2' ] . "\"\r\n"; 4176 4177 if($object[ 'phone' ]){ 4178 if(!$object[ 'home-phone' ]) 4179 $stramArray[12] = "\"".$object[ 'phone' ]. "\""; 4180 else if(!$object[ 'mobile' ]) 4181 $stramArray[4] = "\"".$object[ 'phone' ]. "\""; 4182 else if(!$object[ 'business-phone' ]) 4183 $stramArray[5] = "\"".$object[ 'phone' ]. "\""; 4184 } 4185 4186 $streamBuffer .= implode("," , $stramArray); 4043 4187 } 4044 4188 break; 4189 4190 case 'outlook2003': 4191 $streamBuffer = "\"Tratamento\",\"Primeiro nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". 4192 "\"Empresa\",\"Departamento\",\"Cargo\",\"Business Street\",\"Rua do endereço comercial 2\",". 4193 "\"Rua do endereço comercial 3\",\"Business City\",\"Business State\",". 4194 "\"Business Postal Code\",\"Business Country\",\"Endereço residencial\",\"Endereço residencial 2\",". 4195 "\"Endereço residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",". 4196 "\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",". 4197 "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 4198 "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 4199 "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". 4200 "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Anotações\",\"Birthday\",\"Caixa postal de outro endereço\",\"Caixa postal do endereço comercial\",". 4201 "\"Caixa postal do endereço residencial\",\"Categorias\",\"Código da empresa\",\"Código do governo\",\"Conta\",\"Datas especiais\",\"Disponibilidade da internet\",\"E-mail Address\",". 4202 "\"Tipo de email\",\"Nome para exibição do email\",\"Endereço de email 2\",". 4203 "\"Tipo de email 2\",\"Nome para exibição do email 2\",". 4204 "\"Endereço de email 3\",\"Tipo de email 3\",\"Nome para exibição de email 3\",". 4205 "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",". 4206 "\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 4207 "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",". 4208 "\"Sexo\",\"Spouse\"\r\n"; 4209 foreach($contacts as $index => $object){ 4210 $stramArray[0] = "\"".$object[ 'alias' ] . "\""; 4211 $stramArray[1] = "\"".$object[ 'names_ordered'] . "\""; 4212 $stramArray[2] = ""; 4213 $stramArray[3] = ""; 4214 $stramArray[4] = ""; 4215 $stramArray[5] = "\"".$object[ 'corporate_name' ] . "\""; 4216 $stramArray[6] = "\"".$object[ 'department' ] . "\""; 4217 $stramArray[7] = "\"".$object[ 'job_title' ] . "\""; 4218 $stramArray[8] = "\"".$object[ 'business-address' ] . "\""; 4219 $stramArray[9] = "\"".$object[ 'business-address-2' ] . "\""; 4220 $stramArray[10] = ""; 4221 $stramArray[11] = "\"".$object[ 'business-city_name' ] . "\""; 4222 $stramArray[12] = "\"".$object[ 'business-state_name' ] . "\""; 4223 $stramArray[13] = "\"".$object[ 'business-postal_code' ] . "\""; 4224 $stramArray[14] = "\"".$object[ 'business-id_country' ] . "\""; 4225 $stramArray[15] = "\"".$object[ 'home-address' ] . "\""; 4226 $stramArray[16] = "\"".$object[ 'business-address-2' ] . "\""; 4227 $stramArray[17] = ""; 4228 $stramArray[18] = "\"".$object[ 'home-city_name' ] . "\""; 4229 $stramArray[19] = "\"".$object[ 'home-state_name' ] . "\""; 4230 $stramArray[20] = "\"".$object[ 'home-postal_code' ] . "\""; 4231 $stramArray[21] = "\"".$object[ 'home-id_country' ] . "\""; 4232 $stramArray[22] = ""; 4233 $stramArray[23] = ""; 4234 $stramArray[24] = ""; 4235 $stramArray[25] = "\"".$object[ 'home-city_name' ] . "\""; 4236 $stramArray[26] = "\"".$object[ 'home-state_name' ] . "\""; 4237 $stramArray[27] = "\"".$object[ 'home-postal_code' ] . "\""; 4238 $stramArray[28] = "\"".$object[ 'home-id_country' ] . "\""; 4239 $stramArray[29] = ""; 4240 $stramArray[30] = "\"".$object[ 'business-fax' ] . "\""; 4241 $stramArray[31] = "\"".$object[ 'business-phone' ] . "\""; 4242 $stramArray[32] = "\"".$object[ 'mobile' ] . "\""; 4243 $stramArray[33] = ""; 4244 $stramArray[34] = ""; 4245 $stramArray[35] = ""; 4246 $stramArray[36] = "\"".$object[ 'home-fax' ] . "\""; 4247 $stramArray[37] = "\"".$object[ 'home-phone' ] . "\""; 4248 $stramArray[38] = ""; 4249 $stramArray[39] = ""; 4250 $stramArray[40] = "\"".$object[ 'mobile' ] . "\""; 4251 $stramArray[41] = ""; 4252 $stramArray[42] = ""; 4253 $stramArray[43] = "\"".$object[ 'home-pager' ] . "\""; 4254 $stramArray[44] = "\"".$object[ 'phone' ] . "\""; 4255 $stramArray[45] = ""; 4256 $stramArray[46] = ""; 4257 $stramArray[47] = ""; 4258 $stramArray[48] = "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\""; 4259 $stramArray[49] = "\"".$object[ 'birthdate' ] . "\""; 4260 $stramArray[50] = ""; 4261 $stramArray[51] = ""; 4262 $stramArray[52] = ""; 4263 $stramArray[53] = ""; 4264 $stramArray[54] = ""; 4265 $stramArray[55] = ""; 4266 $stramArray[56] = ""; 4267 $stramArray[57] = ""; 4268 $stramArray[58] = ""; 4269 $stramArray[59] = "\"".$object[ 'main-mail' ] . "\""; 4270 $stramArray[60] = ""; 4271 $stramArray[61] = ""; 4272 $stramArray[62] = "\"".$object[ 'alternative-mail' ] . "\""; 4273 $stramArray[63] = ""; 4274 $stramArray[64] = ""; 4275 $stramArray[65] = ""; 4276 $stramArray[66] = ""; 4277 $stramArray[67] = ""; 4278 $stramArray[68] = ""; 4279 $stramArray[69] = ""; 4280 $stramArray[70] = ""; 4281 $stramArray[71] = ""; 4282 $stramArray[72] = ""; 4283 $stramArray[73] = ""; 4284 $stramArray[74] = ""; 4285 $stramArray[75] = ""; 4286 $stramArray[76] = ""; 4287 $stramArray[77] = "\"".$object[ 'web_page' ] . "\""; 4288 $stramArray[78] = ""; 4289 $stramArray[79] = ""; 4290 $stramArray[80] = ""; 4291 $stramArray[81] = ""; 4292 $stramArray[82] = ""; 4293 $stramArray[83] = ""; 4294 $stramArray[84] = ""; 4295 $stramArray[85] = ""; 4296 $stramArray[86] = ""; 4297 $stramArray[87] = ""; 4298 $stramArray[88] = ""; 4299 $stramArray[89] = ""; 4300 $stramArray[90] = "\"".$object[ 'sex' ] . "\""; 4301 $stramArray[91] = "\r\n"; 4302 4303 $streamBuffer .= implode("," , $stramArray); 4304 } 4305 break; 4045 4306 4046 4307 } 4047 4308 4048 4309 $file = "contacts_".md5(microtime()).".swp"; 4049 $tempDir = ini_get("session.save_path");4310 $tempDir = $GLOBALS['phpgw_info']['server']['temp_dir']; 4050 4311 $f = fopen($tempDir.'/'.$file,"w"); 4051 4312 if(!$f) … … 4095 4356 //sobrenome, notas e e-mail; 4096 4357 //em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); 4097 function import_contacts($typeImport, $id_group=false){ 4358 function import_contacts($typeImport, $id_group=false) 4359 { 4098 4360 $this->so_group = CreateObject('contactcenter.so_group'); 4099 if($file = $_SESSION['contactcenter']['importCSV']) { 4361 if($file = $_SESSION['contactcenter']['importCSV']) 4362 { 4100 4363 unset($_SESSION['contactcenter']['importCSV']); 4101 4364 $len = filesize($file); … … 4107 4370 if ($typeImport == 'outlook') 4108 4371 $delim = ';'; 4109 else if ($typeImport == 'auto' )4372 else if ($typeImport == 'auto' || $typeImport== 'thunderbird') 4110 4373 $delim = strstr($input_header,',') ? ',' : ';'; 4111 4374 else … … 4149 4412 break; 4150 4413 case 'outlook': 4151 $name_pos= 3;4152 $email_pos= 4;4153 $phone_pos= 7;4154 $home_phone_pos= 10;4155 $personal_cell_pos=1 2;4156 $corporate_street_pos=1 3;4157 $cep_pos=1 5;4158 $ phone_pos=18;4414 $name_pos=0; 4415 $email_pos=2; 4416 $phone_pos=8; 4417 $home_phone_pos=9; 4418 $personal_cell_pos=10; 4419 $corporate_street_pos=12; 4420 $cep_pos=14; 4421 $corporate_phone_pos=18; 4159 4422 $fax_pos=19; 4160 4423 $pager_pos=20; … … 4163 4426 case 'thunderbird': 4164 4427 $name_pos=2; 4428 $alias_pos=3; 4429 //MAILS 4165 4430 $email_pos=4; 4166 $phone_pos=7; 4431 $aditionalEmail_pos=5; 4432 4433 //PHONES 4434 $corporate_phone_pos=7; 4435 $main_phone_pos=8; 4436 $home_phone_pos=8; 4437 $fax_pos=9; 4438 $pager_pos=10; 4439 $personal_cell_pos=11; 4440 4441 //ADRESS 4442 $street_pos=12; 4443 $street_2_pos = 13; 4444 $city_pos=14; 4445 $state_pos=15; 4446 $cep_pos=16; 4447 $country_pos=17; 4448 4449 //CORPORATE ADRESS 4450 $corporate_street_pos=18; 4451 $corporate_city_pos=20; 4452 $corporate_state_pos=21; 4453 $corporate_cep_pos=22; 4454 $corporate_country_pos=23; 4455 4456 //CORPORATE DETAILS 4457 $job_title_pos=24; 4458 $department_pos=25; 4459 $corporate_name_pos=26; 4460 4461 $notes_pos=36; 4462 break; 4463 case 'outlook2003': 4464 $alias_pos=0; 4465 $name_pos=1; 4466 //CORPORATE DETAILS 4467 $corporate_name_pos=5; 4468 $department_pos=6; 4469 $job_title_pos=7; 4470 //CORPORATE ADRESS 4471 $corporate_comp_pos=7; 4472 $corporate_street_pos=8; 4473 $street_2_pos = 9; 4474 $corporate_city_pos=11; 4475 $corporate_state_pos=12; 4476 $corporate_cep_pos=13; 4477 $corporate_country_pos=14; 4478 //HOME ADRESS 4479 $street_pos=13; 4480 $comp_pos=14; 4481 $cep_pos=15; 4482 $city_pos=16; 4483 $state_pos=17; 4484 $country_pos=18; 4485 //PHONE's 4486 $corporate_phone_pos=31; 4487 $fax_pos=36; 4488 $home_phone_pos=37; 4489 $pager_pos=43; 4490 $main_phone_pos=44; 4491 //OTHER's 4492 $notes_pos=48; 4493 $birth_pos=49; 4494 //EMAIL's 4495 $email_pos=59; 4496 $aditionalEmail_pos=62; 4167 4497 break; 4168 4498 case 'expresso': … … 4276 4606 } 4277 4607 4278 while (($data = fgetcsv($handle, $len, $delim))) { 4608 4609 4610 while (($data = fgetcsv($handle, $len, $delim))) 4611 { 4279 4612 foreach ($header as $key=>$heading) 4280 4613 $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 4281 4614 4282 4615 $sdata = array(); 4283 $full_name = trim($row[$header[$name_pos]]); 4284 $email = trim($row[$header[$email_pos]]); 4285 $phone = trim($row[$header[$phone_pos]]); 4286 $name2 = trim($row[$header[$name2_pos]]); 4287 $name3 = trim($row[$header[$name3_pos]]); 4288 4289 $birth = trim($row[$header[$birth_pos]]); 4290 $notes = trim($row[$header[$notes_pos]]); 4291 $altEmail = trim($row[$header[$altEmail_pos]]); 4292 $sdata['alias'] = trim($row[$header[$alias_pos]]); 4293 $sdata['corporate_name'] = trim($row[$header[$corporate_name_pos]]); 4294 $sdata['job_title'] = trim($row[$header[$job_title_pos]]); 4295 $sdata['department'] = trim($row[$header[$department_pos]]); 4296 $sdata['web_page'] = trim($row[$header[$web_page_pos]]); 4616 $full_name = addslashes(trim($row[$header[$name_pos]])); 4617 $email = addslashes(trim($row[$header[$email_pos]])); 4618 $phone = addslashes(trim($row[$header[$main_phone_pos]])); 4619 $name2 = addslashes(trim($row[$header[$name2_pos]])); 4620 $name3 = addslashes(trim($row[$header[$name3_pos]])); 4621 $birth = addslashes(trim($row[$header[$birth_pos]])); 4622 $notes = addslashes(trim($row[$header[$notes_pos]])); 4623 $altEmail = addslashes(trim($row[$header[$altEmail_pos]])); 4624 $sdata['alias'] = addslashes(trim($row[$header[$alias_pos]])); 4625 $sdata['corporate_name'] = addslashes(trim($row[$header[$corporate_name_pos]])); 4626 $sdata['job_title'] = addslashes(trim($row[$header[$job_title_pos]])); 4627 $sdata['department'] = addslashes(trim($row[$header[$department_pos]])); 4628 $sdata['web_page'] = addslashes(trim($row[$header[$web_page_pos]])); 4629 $sdata['sex'] = addslashes(trim($row[$header[$sex_pos]])); 4630 $sdata['pgp_key'] = addslashes(trim($row[$header[$pgp_key_pos]])); 4297 4631 4298 $sdata['sex'] = trim($row[$header[$sex_pos]]);4299 $sdata['pgp_key'] = trim($row[$header[$pgp_key_pos]]);4300 4301 4302 $full_name = $full_name;4303 4632 $array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name)))); 4304 4633 $sdata['given_names'] = addslashes($array_name[0]); … … 4386 4715 $sdata['addresses']['address_personal']['id_city'] = trim($row[$header[$city_pos]]); 4387 4716 4388 if(trim($birth)) { 4717 if(trim($birth)) 4718 { 4389 4719 $array_birth = explode("/",trim($birth)); 4390 4720 $sdata['birthdate'] = date('Y-m-d', mktime(0,0,0,$array_birth[1],$array_birth[0],$array_birth[2])); … … 4394 4724 //$sdata['is_quick_add'] = true; 4395 4725 $sdata['connections']['default_phone']['connection_value'] = $phone; 4396 4726 if(!$phone){ 4727 4728 } 4397 4729 // verifica se email já existe! 4398 4730 $email = addslashes($email); 4399 $contact = $boGroup->verify_contact($email); 4400 4401 if(!$sdata['given_names'] && $email){ 4731 $contact = false; 4732 $contact = $boGroup->verify_contact($email, $full_name, $phone); 4733 if(!$sdata['given_names'] && $email) 4734 { 4402 4735 $a_email = explode("@",$email); 4403 4736 $sdata['given_names'] = addslashes($a_email[0]); … … 4406 4739 $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new']; 4407 4740 4408 if($contact){ 4741 if($contact[0] != null) 4742 { 4409 4743 $return['_existing']++; 4410 4744 } 4411 else if((!eregi("^[ /_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) && $email) {4745 else if((!eregi("^[a-zA-Z0-9][_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*$", $email)) && $email) { 4412 4746 $return['_failure']++; 4413 4747 $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; … … 4432 4766 echo serialize($return); 4433 4767 } 4768 4769 function get_contact_details($id) 4770 { 4771 $data = array(); 4772 4773 if(!$this->bo->catalog->src_info) { 4774 $ldap = CreateObject('contactcenter.bo_ldap_manager'); 4775 $this->bo->catalog->src_info = $ldap->srcs[1]; 4776 } 4777 //$id = urlencode($id); 4778 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 4779 $dn=$this->bo->catalog->src_info['dn']; 4780 4781 //buscar os atributos do ldap 4782 $configobj = CreateObject('phpgwapi.config', 'contactcenter'); 4783 $prefs = $configobj->read_repository(); 4784 $attr_names = array(); 4785 $attr_types = array(); 4786 $justThese = array(); 4787 foreach ($prefs as $pref_key => $pref_value) 4788 { 4789 if (stripos($pref_key, "cc_attribute_name_") !== false) 4790 { 4791 $num = substr($pref_key, strlen("cc_attribute_name_")); 4792 $attr_names[] = $prefs["cc_attribute_name_$num"]; 4793 $attr_types[] = $prefs["cc_attribute_type_$num"]; 4794 $justThese[] = strtolower($prefs["cc_attribute_ldapname_$num"]); 4795 } 4796 } 4797 4798 4799 4800 $sr = ldap_read($ds,utf8_encode($id), "objectClass=*",$justThese); 4801 $info = ldap_get_entries($ds, $sr); 4802 if ($info) 4803 { 4804 for ($i = 0; $i < count($justThese); $i++) 4805 { 4806 $attr = array(); 4807 $attr['name'] = $attr_names[$i]; 4808 if ($attr_types[$i] == 'multivalues') 4809 { 4810 $attr['type'] = 'multivalues'; 4811 $attr['value'] = array(); 4812 for ($j = 0; $j < $info[0][$justThese[$i]]['count']; $j++) 4813 $attr['value'][] = utf8_decode($info[0][$justThese[$i]][$j]); 4814 } 4815 else 4816 { 4817 $attr['type'] = 'text'; 4818 $attr['value'] = utf8_decode($info[0][$justThese[$i]][0]); 4819 } 4820 $data[] = $attr; 4821 } 4822 } 4823 else 4824 $data = 'error'; 4825 ldap_close($ds); 4826 4827 echo serialize($data); 4828 } 4829 4434 4830 } 4435 4831
Note: See TracChangeset
for help on using the changeset viewer.