Ignore:
Timestamp:
11/03/11 11:17:35 (12 years ago)
Author:
wmerlotto
Message:

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus, do modulo contactcenter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/inc/class.ui_data.inc.php

    r4838 r5131  
    1919                var $public_functions = array( 
    2020                        'data_manager' => true, 
     21                        'advanced_searh_fields' => true  
    2122                ); 
    2223 
     
    6869                        } 
    6970 
    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']); 
    7172 
    7273 
     
    257258                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.')); 
    258259                        $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.')); 
    259261                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 
    260262                        $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 
    261263                        $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
    262264                        $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.")); 
    263266 
    264267                        $select_groups = ''; 
     
    282285                                $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'default'); 
    283286                        } 
     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                         
    284336                        $GLOBALS['phpgw']->template->parse('out','index'); 
    285337 
     
    289341                        $main .= $api->get_quick_add_plugin(); 
    290342                        $main .= $api->get_add_group(); 
     343                        $main .= $api->get_contact_details(); 
    291344                        $main .= $GLOBALS['phpgw']->template->get_var('out'); 
    292345 
     
    358411                                case 'get_catalog_add_contact': 
    359412                                        // 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'])); 
    361414                                        return; 
    362415 
     
    450503                                        echo $this->get_list_owners_perms_add(); 
    451504                                        return; 
    452  
     505                                case 'get_contact_details': 
     506                                        return $this->get_contact_details($_GET['id']); 
    453507                        } 
    454508                } 
     
    487541                { 
    488542                        $id_catalog = str_replace('\\"', '"', $id_catalog); 
    489                         $temp =& $this->bo->set_catalog($id_catalog); 
     543                        $temp = $this->bo->set_catalog($id_catalog); 
    490544 
    491545                        if(!$this->bo->catalog->src_info) { 
     
    505559                                $this->page_info['changed'] = true; 
    506560                                $this->page_info['actual_entries'] = false; 
    507                                 $this->page_info['actual_catalog'] =& $temp; 
     561                                $this->page_info['actual_catalog'] = $temp; 
    508562                                $this->save_session(); 
    509563 
     
    13301384                                ); 
    13311385 
     1386                                //verifica se esta habilitado a opcao de exibir os detalhes extras 
     1387                                $objconfig = CreateObject('phpgwapi.config', 'contactcenter'); 
     1388                                $config = $objconfig->read_repository(); 
     1389                                 
    13321390                                //echo 'Page: '.$page.'<br>'; 
    13331391                                $n_entries = count($this->page_info['actual_entries']); 
     
    13891447                                        for($z = 0; $z < $info['count']; $z++) { 
    13901448                                                $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                                                } 
    13911469                                        } 
    13921470                                } 
     
    14181496                                        ); 
    14191497 
    1420                                         $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
     1498                                        $groups = $this->bo->catalog->get_multiple_entries($ids,$fields); 
    14211499 
    14221500                                        $i = 0; 
     
    14731551                                if($external) 
    14741552                                { 
    1475                                         $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields,false,true); 
     1553                                        $contacts = $this->bo->catalog->get_multiple_entries($ids,$fields,false,true); 
    14761554                                } else{ 
    1477                                         $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 
    1478                                 } 
    1479  
     1555                                        $contacts = $this->bo->catalog->get_multiple_entries($ids,$fields); 
     1556                                } 
    14801557/*******/ 
    1481  
    1482  
    14831558                                if (!is_array($contacts) or !count($contacts)) 
    14841559                                { 
     
    15171592/********/ 
    15181593 
    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'; 
    15201595 
    15211596                                                //Para exibir a matricula do empregado 
     
    15511626                                                                                $default_phone_found = true; 
    15521627                                                                        } 
    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                                                                        } 
    15541632/**rev 104**/ 
    15551633                                                                        //if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external){ 
     
    15631641                                                                        $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
    15641642                                                                } 
     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                                                                } 
    15651648                                                        } 
    15661649                                                } 
     
    15711654                                                } 
    15721655 
    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                                                                 
    15761660                                                } 
    15771661 
    15781662                                                $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]); 
    15801664 
    15811665/**rev 104**/ 
     
    15931677                                                        $final[3][$i][12] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; 
    15941678                                                } 
    1595 /******/ 
    15961679 
    15971680                                                $final[4][$i] = $contact['photo'] ? 1  : 0; 
     1681                                                 
     1682 
     1683 
    15981684                                                $i++; 
    15991685                                        } 
     
    16101696                                $final[9] = $count; 
    16111697                                $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="" '; 
    16141700                                $this->page_info['actual_letter'] = $letter; 
    16151701                                $this->page_info['actual_page'] = $page; 
     
    16561742                                } 
    16571743                                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                                        } 
    16581759                        } 
    16591760                        echo serialize ($owner_names);   
     
    16901791                        $boGroup = CreateObject('contactcenter.bo_group'); 
    16911792 
    1692                         $all_contacts = $boGroup->get_all_contacts('only_email',$shared_from); 
     1793                        $all_contacts = $boGroup->get_all_contacts(false,$shared_from); 
    16931794                         
    16941795                        $contact_options = ""; 
    16951796                        if(count($all_contacts)) {                                       
    16961797                                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>"; 
    16981803                                } 
    16991804                        } 
     
    18051910 
    18061911                        /* 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                        } 
    18071938 
    18081939                        echo serialize($data); 
     
    18241955                        $predata[] = $boPeopleCatalog -> get_all_countries(); 
    18251956                        $predata[] = $boPeopleCatalog -> get_all_connections_types(); 
     1957                        $boGroup = CreateObject('contactcenter.bo_group');  
     1958            //$predata[] = $boGroup->get_groups_by_user(); 
    18261959                        //$predata[] = $this->bo->catalog->get_all_relations_types(); 
    18271960 
     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                         
    18281973                        $i = 0; 
    18291974                        foreach($predata as $data_) 
     
    18832028                                } 
    18842029                        } 
    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                             else 
    1904                                 { 
    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  
    19132030                        $data['alias'] = addslashes($tdata[0]); 
    19142031                        $data['given_names'] = addslashes($tdata[1]); 
     
    23052422                                        $email = $dataConn['connection'.$i]['connection_value']; 
    23062423                                    } 
    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; 
    23192424                                } 
    23202425 
     
    24482553                                                /* Does nothing... */ 
    24492554                                                break; 
    2450  
     2555                                        case 'groups': 
     2556                                                $groups = $data['groups']; 
     2557                                                unset($data['groups']); 
     2558                                                break; 
    24512559                                        default: 
    24522560                                                echo serialize(array( 
     
    24822590                                        'status' => 'fail' 
    24832591                                ); 
     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); 
    24842599                        } 
    24852600 
     
    26172732                                        $email = $dataConn['connection'.$i]['connection_value']; 
    26182733                                    } 
    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; 
    26312734                                } 
    26322735 
     
    27652868                        } 
    27662869 
    2767                         $code = '$id = $this->bo->catalog->'; 
     2870                        //$code = '$id = $this->bo->catalog->'; 
    27682871 
    27692872                        if (!is_null($id) and $id !== '') 
    27702873                        { 
    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){ 
    27722877                                $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!'), 
    27742886                                        'status' => 'ok' 
    27752887                                ); 
    27762888                        } 
     2889                        } 
    27772890                        else 
    27782891                        { 
    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){ 
    27902895                                $result = array( 
    27912896                                        'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'. 
     
    27942899                                ); 
    27952900                        } 
    2796  
     2901                                else{ 
     2902                                        $result = array( 
     2903                                                'msg' => lang('Entry Added Successfully!'), 
     2904                                                'status' => 'ok' 
     2905                                        ); 
     2906                                } 
     2907                        } 
    27972908                        echo serialize($result); 
    2798 } 
     2909                } 
    27992910                /*! 
    28002911 
     
    30963207                        if (!is_array($data) || (!$data['search_for'] && !$full_search) || !is_array($data['fields'])) 
    30973208                        { 
    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                                ); 
    31043222                        } 
    31053223 
     
    31183236                        { 
    31193237 
    3120                                 $data['search_for'] = utf8_encode($data['search_for']); 
     3238                                $data['search_for'] = $data['search_for']; 
    31213239                        } 
    31223240 
     
    32453363                                // Get only this attributes: dn, cn for external catalogs, 
    32463364                                // 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);   } 
    32493366                        else 
    32503367                        { 
     
    32593376                                        'contact.connection.mail', 
    32603377                                        '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 ); } 
    32633379 
    32643380                        if (!is_array($ids) || !count($ids)) 
     
    36413757                        for($z = 0; $z < 5; $z++) { 
    36423758                                $participant = $info[0][$justThese[$z]]; 
     3759                                $participant[0] = utf8_decode($participant[0]); 
    36433760                                array_push($array_participants, $participant); 
    36443761                        } 
     
    37553872                        $contacts = $boGroup->get_all_contacts(); 
    37563873                        $streamBuffer = ''; 
     3874                        $stramArray = Array(); 
    37573875 
    37583876                        if(!count($contacts)) 
     
    37803898 
    37813899                                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;" 
    37833901                                                                        ."Cidade do endereço residencial;CEP do endereço residencial;Estado;País/região do endereço residencial;" 
    37843902                                                                        ."Telefone residencial;Fax residencial;Telefone celular;Página pessoal da Web;Rua do endereço comercial;" 
     
    37893907                                        foreach($contacts as $index => $object){ 
    37903908                                                $streamBuffer.= "\"".$object[ 'names_ordered'] . "\";" 
    3791                                                         .";;;" 
    37923909                                                        . "\"".$object[ 'alias' ] . "\";" 
    37933910                                                        . "\"".$object[ 'main-mail' ] . "\";" 
     
    38133930                                                        . "\"".$object[ 'job_title' ] . "\";" 
    38143931                                                        . "\"".$object[ 'department' ] . "\";" 
    3815                                                         .";" 
     3932                                                        ."\"\";" 
    38163933                                                        . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"\r\n"; 
    38173934                                        } 
     
    39584075                                                ."Home Address 2,Home City,Home State,Home ZipCode,Home Country,Work Address,Work Address 2," 
    39594076                                                ."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"; 
    39614078 
    39624079                                        foreach($contacts as $index => $object){ 
    39634080                                                $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); 
    39984131                                        } 
    39994132                                break; 
     
    40074140 
    40084141                            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); 
    40434187                            } 
    40444188                        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; 
    40454306 
    40464307                        } 
    40474308 
    40484309                        $file = "contacts_".md5(microtime()).".swp"; 
    4049                         $tempDir = ini_get("session.save_path"); 
     4310                        $tempDir = $GLOBALS['phpgw_info']['server']['temp_dir']; 
    40504311                        $f = fopen($tempDir.'/'.$file,"w"); 
    40514312                        if(!$f) 
     
    40954356                //sobrenome, notas e e-mail; 
    40964357                //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                { 
    40984360                        $this->so_group = CreateObject('contactcenter.so_group'); 
    4099                         if($file = $_SESSION['contactcenter']['importCSV']) { 
     4361                        if($file = $_SESSION['contactcenter']['importCSV'])  
     4362                        { 
    41004363                                unset($_SESSION['contactcenter']['importCSV']); 
    41014364                                $len = filesize($file); 
     
    41074370                                if ($typeImport == 'outlook') 
    41084371                                        $delim = ';'; 
    4109                                 else if ($typeImport == 'auto') 
     4372                                else if ($typeImport == 'auto' || $typeImport== 'thunderbird') 
    41104373                                $delim = strstr($input_header,',') ? ',' : ';'; 
    41114374                                else 
     
    41494412                                                        break; 
    41504413                                                case 'outlook': 
    4151                                                         $name_pos=3; 
    4152                                                         $email_pos=4; 
    4153                                                         $phone_pos=7; 
    4154                                                         $home_phone_pos=10; 
    4155                                                         $personal_cell_pos=12; 
    4156                                                         $corporate_street_pos=13; 
    4157                                                         $cep_pos=15; 
    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; 
    41594422                                                        $fax_pos=19; 
    41604423                                                        $pager_pos=20; 
     
    41634426                                                case 'thunderbird': 
    41644427                                                        $name_pos=2; 
     4428                                                        $alias_pos=3; 
     4429                                                        //MAILS 
    41654430                                                        $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; 
    41674497                                                        break; 
    41684498                                                case 'expresso': 
     
    42764606                                } 
    42774607 
    4278                                 while (($data = fgetcsv($handle, $len, $delim))) { 
     4608 
     4609                 
     4610                                while (($data = fgetcsv($handle, $len, $delim)))  
     4611                                { 
    42794612                                        foreach ($header as $key=>$heading) 
    42804613                                $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 
    42814614 
    42824615                                                $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]])); 
    42974631                                                 
    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; 
    43034632                                        $array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name)))); 
    43044633                                        $sdata['given_names'] = addslashes($array_name[0]); 
     
    43864715                                                $sdata['addresses']['address_personal']['id_city'] =  trim($row[$header[$city_pos]]); 
    43874716 
    4388                                         if(trim($birth)) { 
     4717                                        if(trim($birth))  
     4718                                        { 
    43894719                                                $array_birth = explode("/",trim($birth)); 
    43904720                                                $sdata['birthdate'] = date('Y-m-d', mktime(0,0,0,$array_birth[1],$array_birth[0],$array_birth[2])); 
     
    43944724                                        //$sdata['is_quick_add'] = true; 
    43954725                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    4396  
     4726                                        if(!$phone){ 
     4727 
     4728                                        } 
    43974729                                        //      verifica se email já existe! 
    43984730                                        $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                                        { 
    44024735                                                        $a_email = explode("@",$email); 
    44034736                                                        $sdata['given_names'] = addslashes($a_email[0]); 
     
    44064739                                        $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new']; 
    44074740 
    4408                                         if($contact){ 
     4741                                        if($contact[0] != null) 
     4742                                        { 
    44094743                                                $return['_existing']++; 
    44104744                                        } 
    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) { 
    44124746                                                $return['_failure']++; 
    44134747                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
     
    44324766                        echo serialize($return); 
    44334767                } 
     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                 
    44344830        } 
    44354831 
Note: See TracChangeset for help on using the changeset viewer.