Ignore:
Timestamp:
11/06/09 09:58:04 (14 years ago)
Author:
rafaelraymundo
Message:

Ticket #719 - Adicionados campos para importacao de contatos no Outlook Express

File:
1 edited

Legend:

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

    r1517 r1599  
    1414  \***************************************************************************/ 
    1515 
    16          
     16 
    1717        class ui_data 
    1818        { 
     
    2020                        'data_manager' => true, 
    2121                ); 
    22                  
     22 
    2323                var $bo; 
    2424                var $typeContact; 
    25                  
     25 
    2626                var $page_info = array( 
    2727                        'n_cards'          => 20, 
     
    3434                        'actual_catalog'   => false 
    3535                ); 
    36                  
     36 
    3737                /*! 
    38                  
     38 
    3939                        @function ui_data 
    4040                        @abstract The constructor. Sets the initial parameters and loads 
    4141                                the data saved in the session 
    4242                        @author Raphael Derosso Pereira 
    43                          
     43 
    4444                */ 
    4545                function ui_data() 
     
    4747                        $temp = $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter'); 
    4848                        $temp2 = $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter'); 
    49                          
     49 
    5050                        $this->bo = CreateObject('contactcenter.bo_contactcenter'); 
    51                          
     51 
    5252                        if ($temp) 
    5353                        { 
     
    5959                                $this->all_entries = $temp2; 
    6060                        } 
    61                          
     61 
    6262                        if (!$this->page_info['actual_catalog']) 
    6363                        { 
     
    6565                                $this->page_info['actual_catalog'] = $catalogs[0]; 
    6666                        } 
    67                          
    68                         $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']);                        
    69                          
     67 
     68                        $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); 
     69 
     70 
    7071                        if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') 
    7172                                $this -> typeContact = 'groups'; 
     73/**rev 104**/ 
    7274                        else if($this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager') 
    7375                                $this -> typeContact = 'shared_groups'; 
    7476                        else if($this->page_info['actual_catalog']['class'] == 'bo_shared_people_manager') 
    7577                                $this -> typeContact = 'shared_contacts'; 
     78/******/ 
    7679                        else 
    7780                                $this -> typeContact = 'contacts'; 
     
    7982 
    8083                /*! 
    81                  
     84 
    8285                        @function index 
    8386                        @abstract Builds the Main Page 
    8487                        @author Raphael Derosso Pereira 
    8588                        @author Jonas Goes 
    86                          
    87                 */               
     89 
     90                */ 
    8891                function index() 
    89                 {        
     92                { 
    9093                        if(!@is_object($GLOBALS['phpgw']->js)) 
    9194                        { 
     
    9699                        $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); 
    97100                        $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); 
    98                          
     101 
    99102//                      $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); 
    100103                        $GLOBALS['phpgw']->common->phpgw_header(); 
    101                          
     104 
    102105                        $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); 
    103106                        $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); 
    104                          
     107 
    105108                        /* Quick Add */ 
    106109                        $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); 
     
    113116                        $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close')); 
    114117                        /* End Quick Add */ 
    115                          
     118 
    116119                        $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; 
    117120                        $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; 
     
    119122                        $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); 
    120123                        $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); 
    121                          
     124 
    122125                        $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 
    123                          
     126 
     127/***rev 104***/ 
     128                        //$GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); 
    124129                        $GLOBALS['phpgw']->template->set_var('cc_full_add_button',lang('Full Add')); 
    125                         $GLOBALS['phpgw']->template->set_var('cc_full_add_button_sh',lang('Full Add Shared')); 
     130/******/ 
     131                        $GLOBALS['phpgw']->template->set_var('cc_full_add_button_sh',lang('Full Add Shared')); 
    126132                        $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 
    127                          
     133 
    128134                        $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 
    129135                        $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); 
     
    134140                        $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); 
    135141                        $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); 
    136                          
     142 
    137143                        /* Panel */ 
    138144                        $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); 
     
    142148                        $GLOBALS['phpgw']->template->set_var('cc_btn_import_export', lang('Import/Export')); 
    143149                        $GLOBALS['phpgw']->template->set_var('cc_btn_new', lang("New...")); 
    144                          
     150 
    145151                        $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); 
    146152                        $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); 
     
    150156                        $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); 
    151157                        /* End Panel */ 
    152                          
     158 
    153159                        /* Messages */ 
     160/**rev 104**/ 
    154161                        $GLOBALS['phpgw']->template->set_var('cc_msg_not_allowed',lang('Not Allowed')); 
    155                         $GLOBALS['phpgw']->template->set_var('cc_msg_unavailable',lang('Unavailable function'));                         
     162                        $GLOBALS['phpgw']->template->set_var('cc_msg_unavailable',lang('Unavailable function')); 
     163/*****/ 
    156164                        $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); 
    157165                        $GLOBALS['phpgw']->template->set_var('cc_msg_err_no_room',lang('No Room for Cards! Increase your browser area.')); 
     
    167175                        $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); 
    168176                        /* End Messages */ 
    169                          
     177 
    170178                        $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); 
    171179                        $GLOBALS['phpgw']->template->set_var('cc_is_my',lang('Is My')); 
     
    173181                        $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); 
    174182                        $GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation')); 
    175                         $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));                       
     183                        $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); 
    176184                        $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 
    177185                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); 
     
    214222                        $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_cellphone', lang('Corporative Cellphone')); 
    215223                        $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_fax', lang('Corporative Fax')); 
    216                         $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_pager', lang('Corporative Pager'));                     
     224                        $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_pager', lang('Corporative Pager')); 
    217225                        $GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work')); 
    218226                        $GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax')); 
     
    234242                        $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
    235243                        $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
    236                          
     244 
    237245                        if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){ 
    238246                                $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'advanced'); 
     
    241249                        } 
    242250                        $GLOBALS['phpgw']->template->parse('out','index'); 
    243                          
     251 
    244252                        $api = CreateObject('contactcenter.ui_api'); 
    245253                        $main = $api->get_full_add(); 
     
    252260                } 
    253261 
    254                  
     262 
    255263                /*! 
    256                  
     264 
    257265                        @function data_manager 
    258                         @abstract Calls the right method and passes to it the right  
     266                        @abstract Calls the right method and passes to it the right 
    259267                                parameters 
    260268                        @author Raphael Derosso Pereira 
    261                  
     269 
    262270                */ 
    263271                function data_manager() 
     
    268276                                case 'set_n_cards': 
    269277                                        return $this->set_n_cards((int)$_GET['ncards']); 
    270                                          
    271                                 case 'get_cards_data':                                   
     278 
     279                                case 'get_cards_data': 
    272280                                        $ids = false; 
    273281                                        // To support ldap catalogs using accentuation 
     
    276284                                                $ids = utf8_decode($this->search($_POST['data'])); 
    277285                                        } 
    278                                          
     286 
    279287                                        if(isset($_SESSION['ids'])) 
    280288                                                $ids = $_SESSION['ids']; 
    281                                          
    282                                         return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids);                                            
     289 
     290                                        return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids); 
     291 
    283292                                case 'get_cards_data_get': 
    284293                                        return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); 
     
    291300                                        echo $this->get_visible_all_ldap(); 
    292301                                        return; 
    293                                          
     302 
    294303                                /* Catalog Methods */ 
    295304                                case 'set_catalog': 
    296305                                        return $this->set_catalog($_GET['catalog']); 
    297                                          
     306 
    298307                                case 'get_catalog_tree': 
    299308                                        echo serialize($this->get_catalog_tree($_GET['level'])); 
     
    307316                                        echo serialize($this->get_catalog_participants_list($_POST['id'])); 
    308317                                        return; 
    309                                  
     318/**rev 104**/ 
    310319                                case 'get_catalog_participants_group': 
    311320                                        echo serialize($this->get_catalog_participants_group($_POST['id'])); 
    312321                                        return; 
    313  
     322/***/ 
    314323                                case 'get_catalog_add_contact': 
    315324                                        // To support ldap catalogs with accentuation 
    316325                                        echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); 
    317326                                        return; 
    318                                          
     327 
    319328                                /* Full Add Methods */ 
    320329                                case 'get_full_data': 
     330                                        //return $this->get_full_data($_GET['id']); 
     331/**rev 104**/ 
    321332                                        return $this->get_full_data($_GET['id'],$_GET['catalog']); 
    322                                  
     333/****/ 
     334 
    323335                                case 'get_group': 
    324336                                        return $this->get_group_data($_GET['id'],isset($_GET['shared_from'])?$_GET['shared_from']:null); 
    325                                          
     337 
    326338                                case 'get_contact_full_add_const': 
    327339                                        return $this->get_contact_full_add_const(); 
     
    338350                                case 'get_states': 
    339351                                        return $this->get_states($_GET['country']); 
    340                                          
     352 
    341353                                case 'get_cities': 
    342354                                        return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); 
    343                                          
    344                                          
     355 
     356 
    345357                                /* Other Methods */ 
    346                                 case 'quick_add':                                                                                                                        
     358                                case 'quick_add': 
    347359                                        return $this->quick_add($_POST['add']); 
    348                                  
    349                                 case 'add_group':                                                                                                                        
     360 
     361                                case 'add_group': 
    350362                                        return $this->add_group($_POST['add']); 
    351                                                                          
     363 
    352364                                case 'remove_entry': 
    353365                                        return $this->remove_entry((int)$_GET['remove']); 
    354                                  
     366 
    355367                                case 'remove_all_entries': 
    356368                                        return $this->remove_all_entries(); 
    357369 
    358370                                case 'remove_group': 
    359                                                                                  
    360                                         return $this->remove_group((int)$_GET['remove']);                                        
     371 
     372                                        return $this->remove_group((int)$_GET['remove']); 
    361373 
    362374                                case 'search': 
     
    397409 
    398410                /*! 
    399                  
     411 
    400412                        @function set_n_cards 
    401413                        @abstract Informs the class the number of cards the page can show 
    402414                        @author Raphael Derosso Pereira 
    403                          
     415 
    404416                        @param integer $n_cards The number of cards 
    405                          
     417 
    406418                */ 
    407419                function set_n_cards($n_cards) 
     
    412424                                echo 1; 
    413425                        } 
    414                          
     426 
    415427                        $this->save_session(); 
    416428                } 
    417                                  
     429 
    418430                /*! 
    419                  
     431 
    420432                        @function set_catalog 
    421433                        @abstract Sets the current catalog selected by the user 
    422434                        @author Raphael Derosso Pereira 
    423                          
     435 
    424436                        @param string $id_catalog The sequence of IDs to reach the catalog 
    425437                                separated by commas 
    426                  
     438 
    427439                */ 
    428440                function set_catalog($id_catalog) 
     
    430442                        $id_catalog = str_replace('\\"', '"', $id_catalog); 
    431443                        $temp =& $this->bo->set_catalog($id_catalog); 
    432                          
     444 
    433445                        if ($temp) 
    434446                        { 
     
    437449                                $this->page_info['actual_catalog'] =& $temp; 
    438450                                $this->save_session(); 
    439                                  
     451 
    440452                                $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
    441                                  
     453 
    442454                                if ($catalog_info['class'] === 'bo_global_ldap_catalog' || 
    443455                                    $catalog_info['class'] === 'bo_catalog_group_catalog') 
     
    449461                                        $perms = 15; 
    450462                                } 
    451                                  
     463 
    452464                                echo serialize(array( 
    453465                                        'status' => 'ok', 
     
    457469                                return; 
    458470                        } 
    459                          
     471 
    460472                        echo serialize(array( 
    461473                                'status' => 'ok', 
     
    463475                        )); 
    464476                } 
    465                  
    466                  
     477 
     478 
    467479                /*! 
    468                  
     480 
    469481                        @function get_catalog_tree 
    470482                        @abstract Returns the JS serialized array to used as the tree 
    471483                                level 
    472484                        @author Raphael Derosso Pereira 
    473             @author Mário César Kolling (error messages and timeout) 
    474                          
    475                         @param (string) $level The level to be taken  
    476                  
     485            @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout) 
     486 
     487                        @param (string) $level The level to be taken 
     488 
    477489                */ 
    478490                function get_catalog_tree($level) 
     
    483495 
    484496                                $parent = '0'; 
    485                                  
     497 
    486498                                if (!($tree = $this->bo->get_catalog_tree($level))) 
    487499                                { 
     
    515527                                } 
    516528                        } 
    517                          
     529 
    518530                        $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    519531                        $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    520                          
     532 
    521533                        // Deals with error messages from the server and returns them to the browser 
    522534                        if ($tree['msg']) 
     
    546558                        } 
    547559                } 
    548                  
     560 
    549561                /*! 
    550                  
     562 
    551563                        @function get_actual_catalog 
    552564                        @abstract Returns the actual selected Catalog 
     
    555567                */ 
    556568                function get_actual_catalog() 
    557                 {                        
     569                { 
    558570                        $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); 
    559                          
     571 
    560572                        if ($level) 
    561573                        { 
     
    571583                        ); 
    572584                } 
    573                  
     585 
    574586                /*! 
    575                  
     587 
    576588                        @function get_cards_data 
    577589                        @abstract Returns the information that is placed on the cards 
    578590                        @author Raphael Derosso Pereira 
    579                          
     591 
    580592                        @param string $letter The first letter to be searched 
    581                         @param (int)  $page The page to be taken  
     593                        @param (int)  $page The page to be taken 
    582594                        @param (str)  $ids The ids to be taken in case of search 
    583595 
     
    588600                { 
    589601                        if( $ids ) 
    590                                 $_SESSION['ids'] = $ids;                    
     602                                $_SESSION['ids'] = $ids; 
    591603 
    592604                        // It's an external catalog? 
     
    594606                        //echo $page."\n"; 
    595607                        if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or 
    596                             ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or  
     608                            ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 
    597609                            $this->page_info['changed'])) 
    598610                        { 
    599611                                unset($ids); 
    600612                                $this->page_info['changed'] = false; 
     613 
    601614                                switch ($this->page_info['actual_catalog']['class']) 
    602615                                { 
     616/**rev 104**/ 
    603617                                        case 'bo_shared_people_manager': 
     618/****/ 
    604619                                        case 'bo_people_catalog': 
    605620                                                $field_name = 'id_contact'; 
     621 
    606622                                                if ($letter !== 'number') 
    607623                                                { 
     
    611627                                                                        'type'  => 'iLIKE', 
    612628                                                                        'value' => $letter !== 'all' ? $letter.'%' : '%' 
    613                                                                 )                                                                
     629/**rev 104**/ 
     630        /*                                                      ), 
     631                                                                1 => array( 
     632                                                                        'field' => 'contact.id_owner', 
     633                                                                        'type'  => '=', 
     634                                                                        'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
     635        */ 
     636                                                                ) 
    614637                                                        ); 
    615638 
     
    617640                                                        $so_contact = CreateObject('contactcenter.so_contact',  $GLOBALS['phpgw_info']['user']['account_id']); 
    618641                                                        $relacionados = $so_contact->get_relations(); 
    619                                                          
    620                                                         $perms_relacao = array();                                
     642 
     643                                                        $perms_relacao = array(); 
    621644 
    622645                                                        foreach($relacionados as $uid_relacionado => $tipo_relacionamento) { 
     
    650673                                                                $n=$this->bo->catalog->src_info['dn']; 
    651674                                                                $apenasThese = array("cn","uidnumber","uid"); 
    652                                                                 $r = ldap_search($s,$n, $filtro,$apenasThese);                                         
     675                                                                $r = ldap_search($s,$n, $filtro,$apenasThese); 
    653676                                                                $infos = ldap_get_entries($s, $r); 
    654                                                                 ldap_close($s);                                                                        
     677                                                                ldap_close($s); 
    655678                                                                for($z = 0; $z < $infos['count']; $z++) { 
    656679                                                                        $prop_names[$infos[$z]['uidnumber'][0]] = array("cn" => $infos[$z]['cn'][0], "uid" => $infos[$z]['uid'][0]); 
     
    666689                                                                ); 
    667690                                                        } 
     691/****/ 
     692 
    668693                                                } 
    669694                                                else 
     
    725750                                                                                ), 
    726751                                                                        ), 
     752/**rev 104**/ 
     753/*                                                              ), 
     754                                                                1 => array( 
     755                                                                        'field' => 'contact.id_owner', 
     756                                                                        'type'  => '=', 
     757                                                                        'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
     758                                                                ), 
     759*/ 
    727760                                                                ) 
    728761                                                        ); 
     
    736769                                                        ); 
    737770                                                } 
    738                                                  
    739                                                  
     771/*****/ 
     772 
    740773                                                $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    741                                                  
     774 
    742775                                                $find_other[0] = array( 
     776/**rev 104**/ 
     777                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     778                                                        //'limit'  => $this->page_info['n_cards'], 
     779/*****/ 
    743780                                                        'order'  => 'contact.names_ordered' 
    744781                                                ); 
    745                                                  
     782 
    746783                                                break; 
    747                                          
     784 
    748785                                        case 'bo_global_ldap_catalog': 
    749                                          
     786 
    750787                                                $field_name = 'id_contact'; 
    751788 
     
    760797                                                                /* 
    761798                                                                 * Restrict the returned contacts in a "first letter" search 
     799/**rev 104 
    762800                                                                 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, 
    763801                                                                 * phpgwAccountVisible != -1 
     
    767805                                                                        'type'  => '=', 
    768806                                                                        'value' => 'phpgwAccount' 
     807/**rev 104**/ 
     808                                                                //),/* 
    769809                                                                ), 
     810/****/ 
    770811                                                                2 => array( 
    771812                                                                        'field' => 'contact.account_status', 
    772813                                                                        'type'  => 'iLIKE', 
    773814                                                                        'value' => '%' 
     815/**rev 104**/ 
     816                                                                //),*/ 
     817                                                                //2 => array( 
    774818                                                                ), 
    775819                                                                3 => array( 
     820/*****/ 
    776821                                                                        'field' => 'contact.account_visible', 
    777822                                                                        'type'  => '!=', 
    778823                                                                        'value' => '-1' 
     824/**rev 104**/ 
     825        /*                                                      ), 
     826                                                                3 => array( 
     827                                                                        'field' => 'contact.object_class', 
     828                                                                        'type'  => '=', 
     829                                                                        'value' => 'inetOrgPerson' 
     830                                                                ), 
     831        */ 
    779832                                                                ) 
     833/*****/ 
     834 
    780835                                                        ); 
    781836                                                        // If not external catalog get only phpgwAccountType = u ou l 
     
    795850                                                                                        'type'  => '=', 
    796851                                                                                        'value' => 'i' 
     852/**rev 104**/ 
    797853                                                                                        ), 
    798854                                                                                        2 => array( 
    799855                                                                                        'field' => 'contact.account_type', 
    800856                                                                                        'type'  => '=', 
     857/****/ 
    801858                                                                                        'value' => 'l' 
     859/**rev 104**/ 
    802860                                                                                        ), 
    803861                                                                                        3 => array( 
     
    805863                                                                                        'type'  => '=', 
    806864                                                                                        'value' => 'g' 
     865/***/ 
    807866                                                                                        ) 
    808867                                                                                ) 
     
    815874                                                                /* 
    816875                                                                 * Restrict the returned contacts in a "first number" search 
     876/**rev 104 
    817877                                                                 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, 
    818878                                                                 * phpgwAccountVisible != -1 
     
    822882                                                                        'type'  => '=', 
    823883                                                                        'value' => 'phpgwAccount' 
     884/**rev 104**/ 
     885                                                                //),/* 
    824886                                                                ), 
     887/****/ 
    825888                                                                1 => array( 
    826889                                                                        'field' => 'contact.account_status', 
    827890                                                                        'type'  => 'iLIKE', 
    828891                                                                        'value' => '%' 
     892/**rev 104**/ 
     893                                                                //),*/ 
     894                                                                //1 => array( 
    829895                                                                ), 
    830896                                                                2 => array( 
     897/*****/ 
    831898                                                                        'field' => 'contact.account_visible', 
    832899                                                                        'type'  => '!=', 
    833900                                                                        'value' => '-1' 
    834901                                                                ), 
     902/**rev 104**/ 
     903        /*                                                      2 => array( 
     904                                                                        'field' => 'contact.object_class', 
     905                                                                        'type'  => '=', 
     906                                                                        'value' => 'inetOrgPerson' 
     907                                                                ), 
     908        */ 
     909/****/ 
    835910                                                                3 => array( 
    836911                                                                        'type'  => 'branch', 
     
    905980                                                                                'field' => 'contact.account_type', 
    906981                                                                                'type'  => '=', 
     982/**rev 104**/ 
     983                                                                                //'value' => 'g' 
     984                                                                                //); 
     985                                                                                //1 => array( 
    907986                                                                                'value' => 'i' 
    908987                                                                                ), 
    909988                                                                                2 => array( 
     989/****/ 
    910990                                                                                'field' => 'contact.account_type', 
    911991                                                                                'type'  => '=', 
    912992                                                                                'value' => 'l' 
     993/**rev 104**/ 
    913994                                                                                ), 
    914995                                                                                3 => array( 
     
    917998                                                                                'value' => 'g' 
    918999                                                                                ) 
    919                                                                                  
     1000/****/ 
    9201001                                                                        ) 
    9211002                                                                ); 
     
    9281009                                                        // for non-external catalogs, used to restrict the attributes used in filters 
    9291010                                                        $find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type', 
    930                                                                 'contact.object_class',/*'contact.account_status',*/'contact.account_visible'); 
     1011                                                                'contact.object_class','contact.account_visible'); 
    9311012                                                } 
    9321013                                                else 
     
    9361017                                                        $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    9371018                                                } 
    938                                                  
     1019 
    9391020                                                $find_other[0] = array( 
    9401021                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    9421023                                                        'order'  => 'contact.names_ordered' 
    9431024                                                ); 
    944                                                  
     1025 
    9451026                                                break; 
    946                                          
     1027 
    9471028                                        case 'bo_company_manager': 
    9481029                                                $field_name = 'id_company'; 
    949          
     1030 
    9501031                                                $find_field[0] = array('company.id_company','company.company_name'); 
    951                                                  
     1032 
    9521033                                                $find_other[0] = array( 
    9531034                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    9551036                                                        'order'  => 'company.company_name' 
    9561037                                                ); 
    957          
     1038 
    9581039                                                $find_restric[0] = array( 
    9591040                                                        0 => array( 
     
    9631044                                                        ) 
    9641045                                                ); 
    965                                                          
     1046 
    9661047                                                break; 
    9671048 
    9681049                                        case 'bo_group_manager': 
     1050/**rev 104**/ 
    9691051                                        case 'bo_shared_group_manager': 
    970                                                                                                  
     1052/****/ 
     1053 
    9711054                                                $field_name = 'id_group'; 
    972                                                  
     1055 
    9731056                                                if ($letter !== 'number')       { 
    974                                                          
     1057 
    9751058                                                        $find_restric[0] = array( 
    9761059                                                                0 => array( 
     
    9821065                                                } 
    9831066                                                 else { 
    984                                                          
     1067 
    9851068                                                        $find_restric[0] = array( 
    9861069                                                                0 => array( 
    9871070                                                                                        'field' => 'group.title', 
    9881071                                                                                        'type'  => 'LIKE', 
    989                                                                                         'value' => '0%'                                                                          
     1072                                                                                        'value' => '0%' 
    9901073                                                                ) 
    991                                                         );                                               
     1074                                                        ); 
    9921075                                                } 
    993                                                  
     1076/**rev 104**/ 
    9941077                                                if($this->page_info['actual_catalog']['class'] == 'bo_group_manager'){ 
     1078/****/ 
    9951079                                                        array_push($find_restric[0],  array( 
    9961080                                                                                        'field' => 'group.owner', 
    9971081                                                                                        'type'  => '=', 
    998                                                                                         'value' => $GLOBALS['phpgw_info']['user']['account_id']                                                                          
     1082                                                                                        'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
    9991083                                                                        ) 
    10001084                                                        ); 
    10011085                                                } 
    1002                                                  
    1003                                                 $find_field[0] = array('group.id_group','group.title','group.short_name');                                               
     1086 
     1087                                                $find_field[0] = array('group.id_group','group.title','group.short_name'); 
    10041088                                                $find_other[0] = array( 
    10051089                                                        'order'  => 'group.title' 
    1006                                                 );                                               
     1090                                                ); 
    10071091                                                break; 
    1008                                          
     1092 
    10091093                                        case 'bo_catalog_group_catalog': 
    10101094                                                $this->page_info['actual_entries'] = false; 
    1011                                                  
     1095 
    10121096                                                $this->page_info['actual_letter'] = $letter; 
    10131097                                                $this->page_info['actual_page'] = 0; 
    1014                                                  
     1098 
    10151099                                                $this->save_session(); 
    10161100                                                $final[0] = 0; 
    10171101                                                $final[1] = $this->typeContact; 
    1018                                                 echo serialize($final);                                          
     1102                                                echo serialize($final); 
    10191103                                                return; 
    10201104 
     
    10231107                                $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 
    10241108                                $n_entries = count($result); 
    1025                                  
     1109 
    10261110                                if ($n_entries) 
    10271111                                { 
     
    10361120                                if (!$result) 
    10371121                                { 
    1038                                          
    10391122                                        $this->page_info['actual_entries'] = false; 
    1040                                          
     1123 
    10411124                                        $this->page_info['actual_letter'] = $letter; 
    10421125                                        $this->page_info['actual_page'] = 0; 
    1043                                          
    1044                                         $this->save_session();                           
     1126 
     1127                                        $this->save_session(); 
    10451128                                        $final[0] = 0; 
    10461129                                        $final[1] = $this->typeContact; 
    1047                                         echo serialize($final);                                                                                  
     1130                                        echo serialize($final); 
    10481131                                        return; 
    10491132                                } 
     
    10531136                                        foreach ($result as $id => $value) 
    10541137                                        { 
     1138/**rev 104**/ 
     1139                                        //      $this->page_info['actual_entries'][] = $value[$field_name]; 
     1140                                        //} 
    10551141                                                if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') 
    10561142                                                        $this->page_info['actual_entries'][] = $value[$field_name]; 
    10571143                                                else 
    10581144                                                        $this->page_info['actual_entries'][] = array(0=>$value[$field_name],1=>$value['perms'],2=>$value['owner']); 
    1059                                         }  
     1145                                        } 
     1146/****/ 
    10601147                                        //print_r($this->page_info['actual_entries']); 
    10611148                                } 
     
    10661153                                if (!$ids) 
    10671154                                { 
     1155/**rev 104**/ 
    10681156                                        //error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); 
     1157/*****/ 
    10691158                                        $this->page_info['actual_entries'] = false; 
    1070                                          
     1159 
    10711160                                        $this->page_info['actual_letter'] = $letter; 
    10721161                                        $this->page_info['actual_page'] = 0; 
    1073                                          
     1162 
    10741163                                        $this->save_session(); 
    10751164                                        $final[0] = 0; 
    10761165                                        $final[1] = $this -> typeContact; 
    1077                                         echo serialize($final);                                  
     1166                                        echo serialize($final); 
    10781167                                        return; 
    10791168                                } 
     
    10921181                                } 
    10931182                                else if ($ids) 
    1094                                 {                                
     1183                                { 
    10951184                                        $this->page_info['actual_letter']  = $letter; 
    10961185                                        $this->page_info['actual_entries'] = $ids; 
     
    11091198                                        $page = $this->page_info['n_pages']; 
    11101199                                } 
    1111                                  
     1200 
    11121201                                $final = array( 
    11131202                                        0 => (int)$this->page_info['n_pages'], 
     
    11211210                                                5 => 'cc_alias', 
    11221211                                                6 => 'cc_id', 
    1123                                                 7 => 'cc_forwarding_address'                                             
     1212                                                7 => 'cc_forwarding_address', 
     1213                                                8 => 'cc_empNumber', 
     1214                                                9 => 'cc_department', 
     1215                                                10 => 'cc_mobile' 
    11241216                                        ) 
    11251217                                ); 
    1126                                  
     1218 
    11271219                                //echo 'Page: '.$page.'<br>'; 
    11281220                                $id_i = (($page-1)*$this->page_info['n_cards']); 
    11291221                                $id_f = $id_i + $this->page_info['n_cards']; 
    11301222                                $n_entries = count($this->page_info['actual_entries']); 
    1131                                  
     1223 
    11321224                                //echo 'ID_I: '.$id_i.'<br>'; 
    11331225                                //echo 'ID_F: '.$id_f.'<br>'; 
    1134                                  
     1226                                ///---------------- Correᅵᅵo Temporï¿œria PHP5 -----------------------/// 
     1227 
    11351228                                $ids = array(); 
     1229/**rev 104**/ 
    11361230                                $perms = array(); 
    11371231                                $owners = array(); 
    1138                                 $array_temp = array();                   
    1139                                  
     1232/****/ 
     1233                                $array_temp = array(); 
     1234 
    11401235                                foreach($this->page_info['actual_entries'] as $key=>$tmp){ 
    1141                                                 $array_temp[] = $tmp;                            
    1142                                 } 
    1143                          
     1236                                        $array_temp[] = $tmp; 
     1237                                } 
     1238 
    11441239                                for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
    11451240                                { 
     1241/**rev 104**/ 
    11461242                                        if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') 
     1243                                        { 
     1244/****/ 
    11471245                                                $ids[] = $array_temp[$i]; 
    1148                                         else { 
     1246/**rev 104**/ 
     1247                                        }else { 
    11491248                                                $ids[] = $array_temp[$i][0]; 
    11501249                                                $perms[] = $array_temp[$i][1]; 
    11511250                                                $owners[] = $array_temp[$i][2]; 
     1251/****/ 
    11521252                                        } 
    1153                                         //$perms[] = $array_temp[$i]; 
    1154                                 } 
    1155                                  
     1253                                } 
     1254 
     1255/**rev 104**/ 
    11561256                                // Carrega o nome completo dos donos dos objetos (contatos e grupos); 
    11571257                                $owner_names = array(); 
    1158                                                          
     1258 
    11591259                                if($owners) { 
    11601260                                        $filter = "(|"; 
     
    11681268                                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
    11691269                                        } 
    1170                                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);                              
     1270                                        $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); 
    11711271                                        $dn=$this->bo->catalog->src_info['dn']; 
    11721272                                        $justThese = array("cn","uidnumber","uid"); 
    1173                                         $sr = ldap_search($ds,$dn, $filter,$justThese);                                                          
     1273                                        $sr = ldap_search($ds,$dn, $filter,$justThese); 
    11741274                                        $info = ldap_get_entries($ds, $sr); 
    1175                                         ldap_close($ds);                                                                                         
     1275                                        ldap_close($ds); 
    11761276                                        for($z = 0; $z < $info['count']; $z++) { 
    11771277                                                $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]); 
    1178                                         }                                
    1179                                 } 
     1278                                        } 
     1279                                } 
     1280 
     1281/*****/ 
     1282 
     1283 
    11801284                                /// Original 
    11811285                                //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
     
    11841288                                //} 
    11851289                                /// 
     1290 
    11861291                                $fields = $this->bo->catalog->get_fields(false); 
     1292/**rev 104**/ 
     1293                                //if( $this->typeContact == 'groups') { 
    11871294                                if( $this->typeContact == 'groups' || $this->typeContact == 'shared_groups') { 
     1295/****/ 
    11881296                                        $final = array( 
    11891297                                                0 => (int)$this->page_info['n_pages'], 
     
    11941302                                                        2 => 'cc_id', 
    11951303                                                        3 => 'cc_contacts' 
    1196                                                 )                                                
    1197                                         );                                       
     1304                                                ) 
     1305                                        ); 
     1306 
    11981307                                        $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    1199                                                                                                                          
     1308 
    12001309                                        $i = 0; 
    12011310                                        // contatos do grupo 
    1202                                         $boGroups = CreateObject('contactcenter.bo_group');                                      
     1311                                        $boGroups = CreateObject('contactcenter.bo_group'); 
    12031312                                        $contacts = array(); 
    1204                                          
    1205                                         foreach($groups as $group)              {        
     1313                                        foreach($groups as $group)              { 
     1314 
    12061315                                                $final[3][$i][0] = $group['title'] ? $group['title'] : 'none'; 
    1207                                                 $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none';                                                 
     1316                                                $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; 
    12081317                                                $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; 
    12091318                                                $contacts = $boGroups -> get_contacts_by_group($group['id_group']); 
     
    12171326                                                $i++;                                                    
    12181327                                        } 
    1219                                          
     1328 
    12201329                                        $this->page_info['actual_letter'] = $letter; 
    1221                                         $this->page_info['actual_page'] = $page;                                         
    1222                                          
    1223                                          
     1330                                        $this->page_info['actual_page'] = $page; 
     1331 
     1332 
    12241333                                        $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
    1225                                          
    1226                                         $final[5] = '<span class="link"  onclick="'.$lnk_compose;                                        
    1227                                         $final[10] = $this->typeContact;                                                                                                                                                                                                                 
    1228                                         $this->save_session();                                   
     1334 
     1335                                        $final[5] = '<span class="link"  onclick="'.$lnk_compose; 
     1336/**rev 104**/ 
     1337                                        //$final[10] = 'groups'; 
     1338                                        $final[10] = $this->typeContact; 
     1339/******/ 
     1340                                        $this->save_session(); 
    12291341                                        echo serialize($final); 
    1230                                         return;                                  
    1231                                 } 
     1342                                        return; 
     1343                                } 
     1344/**rev 104**/ 
    12321345                                $final[10] = $this -> typeContact; 
    1233                                  
     1346/*****/ 
     1347 
    12341348                                $fields['photo'] = true; 
    12351349                                $fields['names_ordered'] = true; 
     
    12381352                                $fields['companies'] = 'default'; 
    12391353                                $fields['connections'] = 'default'; 
     1354 
     1355/**rev 104**/ 
     1356                                // ?aqui alterar a chamada desse mï¿œtodo para receber o base dn? 
     1357                                //$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 
     1358 
    12401359                                // ?aqui alterar a chamada desse método para receber o base dn? 
    12411360                                if($external) 
     1361                                { 
    12421362                                        $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields,false,true); 
    1243                                 else 
     1363                                } else{ 
    12441364                                        $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 
    1245                                  
    1246                                  
     1365                                } 
     1366 
     1367/*******/ 
     1368 
     1369 
    12471370                                if (!is_array($contacts) or !count($contacts)) 
    12481371                                { 
     
    12521375                                        return; 
    12531376                                } 
    1254                                  
     1377 
    12551378                                $i = 0; 
    12561379                                foreach($contacts as $index => $contact) 
    12571380                                { 
    12581381                                        /* 
    1259                                          * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e, 
    1260                                          * neste caso, terminar a implementação das mensagens de retorno. 
     1382                                         * TODO: Os timeouts de conexï¿œo foram retirados, ver se serï¿œ necessï¿œrio retornar essa funcionalidade, e, 
     1383                                         * neste caso, terminar a implementaᅵᅵo das mensagens de retorno. 
    12611384                                         */ 
    12621385                                        if ($index !== 'error'){ 
    12631386                                                $final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none'; 
     1387 
     1388/**rev 104**/ 
     1389                                                //$final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; 
     1390 
    12641391                                                if($this->page_info['actual_catalog']['class']!='bo_global_ldap_catalog'){ 
    12651392                                                        $final[3][$i][1] = $contact['names_ordered'] ? urldecode($contact['names_ordered'])  : 'none'; 
     
    12691396                                                        $final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered']  : 'none'; 
    12701397                                                } 
     1398 
     1399/********/ 
     1400 
    12711401                                                $final[3][$i][2] = $contact['companies']['company1']['title']? urldecode( $contact['companies']['company1']['title'] ) :'none'; 
     1402 
     1403                                                //Para exibir a matricula do empregado 
     1404                                                $final[3][$i][8] = $contact['companies']['company1']['empNumber']?$contact['companies']['company1']['empNumber']:'none'; 
     1405                                                //Para exibir o setor/lotacao do empregado 
     1406                                                $final[3][$i][9] = $contact['companies']['company1']['department']?$contact['companies']['company1']['department']:'none'; 
     1407                                                //Para exibir o celular empresarial do empregado 
     1408                                                $final[3][$i][10] = $contact['companies']['company1']['celPhone']?$contact['companies']['company1']['celPhone']:'none'; 
     1409 
     1410                                                //Para exibir o celular empresarial do empregado 
     1411                                                if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external && $final[3][$i][10] != 'none') 
     1412                                                            $final[3][$i][10] = "<a title=\"".lang("Call Mobile")."\" href=\"#\" onclick=\"connectVoip('".$final[3][$i][10]."', 'mob')\">".$final[3][$i][10]."</a>"; 
    12721413 
    12731414                                                /* Select the correct Email and Telephone to be shown */ 
    12741415                                                $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    1275                                                  
     1416 
    12761417                                                if (!is_array($preferences)) 
    12771418                                                { 
     
    12991440                                                                                $default_phone_found = true; 
    13001441                                                                        } 
     1442 
     1443/**rev 104**/ 
     1444                                                                        //if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external){ 
     1445                                                                        //      $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'ramal')\">".$conn_info['connection_value']."</a>"; 
     1446 
    13011447                                                                        if (!($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['telephone_number'] == $conn_info['connection_value']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && $conn_info['connection_value'] && preg_match('/^\([0-9]{2}\)[0-9]{4}\-[0-9]{4}$/',$conn_info['connection_value'])==1 && !$external){ 
    13021448                                                                                $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>"; 
     1449                                                                         
     1450/*****/ 
    13031451                                                                        } 
    13041452                                                                        $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
     
    13061454                                                        } 
    13071455                                                } 
    1308                                                  
     1456 
    13091457                                                if (!$final[3][$i][3]) 
    13101458                                                { 
     
    13201468                                                $final[3][$i][6] = $ids[$i]; 
    13211469 
    1322                                         //      If contact is a public list or a group, then load the forwarding addresses. 
     1470/**rev 104**/ 
     1471        /*                              //      If contact is a public list, then load the forwarding addresses. 
     1472                                                if($contact['account_type'][0] == 'l') 
     1473                                                        $final[3][$i][7] = array(); 
     1474        */ 
     1475 
     1476                                                //If contact is a public list or a group, then load the forwarding addresses. 
    13231477                                                if($contact['account_type'][0] == 'l' || $contact['account_type'][0] == 'g') 
    13241478                                                        $final[3][$i][7] = ($contact['account_type'][0] == 'l' ? 'list' : 'group'); 
    13251479                                                         
    13261480                                                if($this->page_info['actual_catalog']['class']=='bo_shared_people_manager') { 
    1327                                                         $final[3][$i][8] = $perms[$i]; 
    1328                                                         $final[3][$i][9] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; 
     1481                                                        $final[3][$i][11] = $perms[$i]; 
     1482                                                        $final[3][$i][12] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; 
    13291483                                                } 
     1484/******/ 
    13301485 
    13311486                                                $final[4][$i] = $contact['photo'] ? 1  : 0; 
    1332                                         //      print_r($final[3][$i]); 
    1333                                         //      exit; 
    13341487                                                $i++; 
    13351488                                        } 
     
    13381491                                                // coloca mensagem de erro no vetor que retorna para o browser 
    13391492                                        } 
    1340                                          
    13411493                                } 
    13421494                                $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
     
    13471499                                $final[9] = $count; 
    13481500 
     1501 
    13491502                                $this->page_info['actual_letter'] = $letter; 
    13501503                                $this->page_info['actual_page'] = $page; 
    1351                                  
    1352                                 $this->save_session();                           
     1504 
     1505                                $this->save_session(); 
    13531506                                echo serialize($final); 
    13541507                                return; 
    13551508                        } 
    1356                          
     1509 
    13571510                        $this->page_info['actual_letter'] = $letter; 
    13581511                        $this->page_info['actual_page'] = $page; 
    1359                          
     1512 
    13601513                        $this->save_session(); 
    1361                          
     1514 
    13621515                        $final[0] = 0; 
    13631516                        $final[1] = $this -> typeContact; 
    13641517                        echo serialize($final); 
    13651518                } 
    1366                  
     1519 
    13671520                function get_visible_all_ldap() 
    13681521                { 
    13691522                        $bo = CreateObject('contactcenter.bo_ldap_manager'); 
    13701523                        $ldap_query = $bo->srcs; 
    1371                         return $ldap_query[1]['visible'];        
     1524                        return $ldap_query[1]['visible']; 
    13721525                } 
    13731526 
    1374   
     1527 
    13751528                /*! 
    1376                  
     1529 
    13771530                        @function get_group_data 
    13781531                        @abstract Returns all the information of a given Group 
    13791532                        @author Nilton Emilio Buhrer Neto 
    1380                          
     1533 
    13811534                        @param (integer) $id The id to get information 
    1382                  
    1383                 */               
     1535 
     1536                */ 
    13841537                function get_group_data($id,$shared_from=null) 
    13851538                { 
     
    13941547                         
    13951548                        $boGroup = CreateObject('contactcenter.bo_group'); 
    1396                                                  
     1549 
    13971550                        $all_contacts = $boGroup->get_all_contacts('only_email',$shared_from); 
    13981551                         
     
    14031556                                } 
    14041557                        } 
    1405                         $data['contact_list'] = $contact_options;                        
    1406                         $data['result'] = 'ok'; 
    1407                                                                                          
     1558                        $data['contact_list'] = $contact_options; 
     1559                        $data['result'] = 'ok';                                                          
    14081560                        echo serialize($data);                   
    14091561                }                
    14101562                 
    14111563                /*! 
    1412                  
     1564 
    14131565                        @function get_full_data 
    14141566                        @abstract Returns all the information of a given Entry 
    14151567                        @author Raphael Derosso Pereira 
    1416                          
     1568 
    14171569                        @param (integer) $id The id to get information 
    1418                  
     1570 
    14191571                */ 
     1572/**rev 104**/ 
     1573                //function get_full_data($id) 
    14201574                function get_full_data($id,$catalog='bo_people_catalog') 
    14211575                { 
    14221576                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1423                         $this->bo->catalog = CreateObject('contactcenter.'.$catalog);            
     1577/**rev 104**/ 
     1578                        //$this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); 
     1579                        $this->bo->catalog = CreateObject('contactcenter.'.$catalog); 
     1580/****/ 
    14241581                        $fields = $this->bo->catalog->get_fields(true); 
    14251582                        $fields['photo'] = false; 
     
    14541611                        } 
    14551612                        $datecount = 0; 
    1456                          
     1613 
    14571614                        $data['result'] = 'ok'; 
    14581615                        $data['cc_full_add_contact_id'] = $id; 
     
    14931650                                } 
    14941651                        } 
    1495                          
     1652//                      print_r($data); 
     1653//OBSERVAR cc_department 
    14961654                        /*Corporative*/ 
    14971655                        $data['personal']['cc_name_corporate'] = $entry['corporate_name']; 
     
    15001658                        $data['personal']['cc_name_corporate'] = $entry['corporate_name']; 
    15011659                        $data['personal']['cc_web_page'] = $entry['web_page']; 
    1502                          
    1503                          
     1660 
     1661 
    15041662                        /* Relations */ 
    1505                          
     1663 
    15061664                        echo serialize($data); 
    15071665                } 
     
    15401698                                return; 
    15411699                        } 
    1542                          
     1700 
    15431701                        echo 0; 
    15441702                } 
    1545                  
     1703 
    15461704                /*! 
    1547                  
     1705 
    15481706                        @function quick_add 
    15491707                        @abstract Adds a new Contact using the Quick Add interface 
    15501708                        @author Raphael Derosso Pereira 
    1551                          
     1709 
    15521710                        @param string $sdata Serialized data 
    15531711                */ 
    15541712                function quick_add($sdata) 
    15551713                { 
    1556                          
     1714 
    15571715                        $sdata = str_replace('\\"', '"', $sdata); 
    15581716                        $new_array = unserialize($sdata); 
    15591717                        $tdata = array(); 
    1560                          
     1718 
    15611719                        foreach($new_array as $tmp) 
    15621720                                $tdata[] = $tmp; 
    1563                          
     1721 
    15641722                        if (!$tdata) 
    15651723                        { 
     
    15681726                                        'status' => 'abort' 
    15691727                                )); 
    1570                                  
     1728 
    15711729                                return; 
    15721730                        } 
    1573                          
    1574                         // verifica se email já existe! 
     1731 
     1732                        // verifica se email jï¿œ existe! 
    15751733                        $boGroup = CreateObject('contactcenter.bo_group'); 
    15761734                        $contact = $boGroup->verify_contact($tdata[4]); 
    1577                                                                                                  
     1735 
    15781736                        if($contact) 
    1579                         {                                                        
     1737                        { 
    15801738                                $str_contact = "\r\n - ".implode("\r\n - ",$contact); 
    1581                                  
     1739 
    15821740                                echo serialize(array( 
    15831741                                        'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), 
    15841742                                        'status' => 'alreadyExists' 
    15851743                                )); 
    1586                                  
    1587                                 return;                  
     1744 
     1745                                return; 
    15881746                        } 
    15891747 
     
    16001758 
    16011759                        if ($boPeople ->quick_add($data)) 
    1602                         {                                
     1760                        { 
    16031761                                $this->page_info['changed'] = true; 
    1604                                  
     1762 
    16051763                                echo serialize(array( 
    16061764                                        'msg'    => lang('Entry added with success!'), 
     
    16161774                        } 
    16171775 
    1618                         $this->save_session();   
    1619                          
     1776                        $this->save_session(); 
     1777 
    16201778                } 
    16211779 
    16221780                /*! 
    1623                  
     1781 
    16241782                        @function add_group 
    16251783                        @abstract Adds a new Group using the Add Group interface 
    16261784                        @author Nilton Emilio Buhrer Neto 
    1627                          
     1785 
    16281786                        @param string $sdata Serialized data 
    16291787                */ 
     
    16331791                        $tdata = unserialize($sdata); 
    16341792                        $new_tdata = array(); 
    1635                          
     1793 
    16361794                        if (!$tdata) 
    16371795                        { 
     
    16401798                                        'status' => 'abort' 
    16411799                                )); 
    1642                                  
     1800 
    16431801                                return; 
    16441802                        } 
    1645                          
     1803 
    16461804                        foreach($tdata as $tmp) 
    16471805                                $new_tdata[] = $tmp; 
    1648                          
    1649                         $data['title'] = $new_tdata[0];                  
     1806 
     1807                        $data['title'] = $new_tdata[0]; 
    16501808                        $data['contact_in_list'] = $new_tdata[1]; 
    16511809                        $data['id_group'] = $new_tdata[2]; 
    1652                                                  
     1810 
    16531811                        $boGroup = CreateObject('contactcenter.bo_group_manager'); 
    16541812                        $id = $boGroup -> add_group($data); 
    1655                          
     1813 
    16561814                        if ($id) 
    16571815                        { 
    16581816                                $this->page_info['changed'] = true; 
    1659                                  
     1817 
    16601818                                echo serialize(array( 
    16611819                                        'msg'    => lang('Entry added with success!'), 
     
    16751833 
    16761834                /*! 
    1677                  
     1835 
    16781836                        @function remove_group 
    16791837                        @abstract Removes a group if the user has the right to do it 
    1680                         @author Nilton Emilio Buhrer Neto                        
     1838                        @author Nilton Emilio Buhrer Neto 
    16811839                        @param (integer) $id The id to be removed 
    1682                                  
     1840 
    16831841                */ 
    16841842                function remove_group($id) 
    1685                 {                                
    1686                                 $soGroup = CreateObject('contactcenter.so_group');                               
     1843                { 
     1844                                $soGroup = CreateObject('contactcenter.so_group'); 
    16871845                                $data = array ('id_group' => $id); 
    16881846                                if($soGroup -> delete($data)) { 
     
    16901848                                                'msg'    => lang('Removed Entry ID '.$id.'!'), 
    16911849                                                'status' => 'ok' 
    1692                                         ));                                                      
     1850                                        )); 
    16931851                                } 
    16941852                                else { 
     
    16991857                                } 
    17001858 
    1701                         $this->save_session();                           
     1859                        $this->save_session(); 
    17021860                } 
    17031861 
    17041862 
    17051863                function remove_all_entries (){ 
    1706                  
     1864 
    17071865                        $error = false; 
    17081866                        $this->all_entries = $this->bo->catalog->get_all_entries_ids(); 
     
    17121870                                if(!$result) { 
    17131871                                        $error = true; 
    1714                                         break;           
     1872                                        break; 
    17151873                                } 
    17161874                        } 
     
    17211879                                        'status' => 'ok' 
    17221880                                )); 
    1723                         }  
     1881                        } 
    17241882                        else { 
    17251883                                echo serialize(array( 
     
    17331891 
    17341892                /*! 
    1735                  
     1893 
    17361894                        @function remove_entry 
    17371895                        @abstract Removes an entry if the user has the right to do it 
    17381896                        @author Raphael Derosso Pereira 
    1739                          
     1897 
    17401898                        @param (integer) $id The id to be removed 
    1741                                  
     1899 
    17421900                */ 
    17431901                function remove_entry ($id) 
     
    17481906                                return; 
    17491907                        } 
    1750                          
     1908 
    17511909                        $this->page_info['changed'] = true; 
    17521910                        $result = $this->bo->catalog->remove_single_entry($id); 
    1753                          
     1911 
    17541912                        if ($result) 
    17551913                        { 
     
    17581916                                        unset($this->page_info['actual_entries'][$pos]); 
    17591917                                } 
    1760                                  
     1918 
    17611919                                $temp = false; 
    17621920                                reset($this->page_info['actual_entries']); 
     
    17651923                                        $temp[] = $t; 
    17661924                                } 
    1767                                  
     1925 
    17681926                                $this->page_info['actual_entries'] = $temp; 
    17691927 
     
    17801938                                )); 
    17811939                        } 
    1782                          
     1940 
    17831941                        $this->save_session(); 
    17841942                } 
    17851943 
    1786                  
     1944 
    17871945                /*! 
    1788                  
     1946 
    17891947                        @function post_full_add 
    17901948                        @abstract Saves all the information altered/entered in the Full Add 
     
    17961954                { 
    17971955                        $data =  $_POST['data']; 
    1798                         // Exceptions!!! utf8 special chars.  
     1956                        // Exceptions!!! utf8 special chars. 
    17991957                        $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 
    18001958                        $data = unserialize(str_replace('\\"', '"', $data)); 
     
    18231981                                        'status' => 'fatal' 
    18241982                                )); 
    1825                                  
     1983 
    18261984                                return; 
    18271985                        } 
     
    18371995                                $id_photo = '_new_'; 
    18381996                        } 
    1839                          
    1840                         /*  
    1841                          * Process Photo, if available  
     1997 
     1998                        /* 
     1999                         * Process Photo, if available 
    18422000                         */ 
    18432001                        $sleep_count = 0; 
     
    18562014                        } 
    18572015                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 
    1858                          
     2016 
    18592017                        if (isset($this->page_info['photos'][$id_photo])) 
    18602018                        { 
     
    18732031                                $this->save_session(); 
    18742032                        } 
    1875                          
     2033 
    18762034                        /* 
    18772035                         * Arrange Date so it gets inserted correctly 
    18782036                         */ 
    1879                           
     2037 
    18802038                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1881                  
     2039 
    18822040                        $j = 0; 
    18832041                        for ($i = 0; $i < 5; $i+=2) 
     
    19122070                                        continue; 
    19132071                                } 
    1914                                  
     2072 
    19152073                                switch($field) 
    19162074                                { 
     
    19292087                                                /* Do Nothing. This is just to make sure no invalid field is passed */ 
    19302088                                                break; 
    1931                                          
     2089 
    19322090                                        case 'id_status': 
    19332091                                        case 'id_prefix': 
     
    19382096                                                } 
    19392097                                                break; 
    1940                                          
     2098 
    19412099                                        case 'birthdate_0': 
    19422100                                        case 'birthdate_1': 
    19432101                                        case 'birthdate_2': 
    1944                                          
     2102 
    19452103                                                switch($date[$datecount]['digit']) 
    19462104                                                { 
     
    19642122                                                        break; 
    19652123                                                } 
    1966                                                  
     2124 
    19672125                                                if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 
    19682126                                                { 
     
    19732131                                                        return; 
    19742132                                                } 
    1975                                                  
     2133 
    19762134                                                $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 
    19772135                                                break; 
     
    19962154                                                        { 
    19972155                                                                $index = 'address'.$type; 
    1998                                                                  
     2156 
    19992157                                                                $id_state = $this->bo->catalog->add_state($state_info); 
    20002158                                                                $data['addresses'][$index]['id_state'] = $id_state; 
     
    20142172                                                        { 
    20152173                                                                $index = 'address'.$type; 
    2016                                                                  
     2174 
    20172175                                                                $id_city = $this->bo->catalog->add_city($city_info); 
    20182176                                                                $data['addresses'][$index]['id_city'] = $id_city; 
     
    20552213                                ); 
    20562214                        } 
    2057                          
     2215 
    20582216                        eval($code); 
    20592217 
     
    20742232                { 
    20752233                        $data =  $_POST['data']; 
    2076                         // Exceptions!!! utf8 special chars.  
     2234                        // Exceptions!!! utf8 special chars. 
    20772235                        $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 
    20782236                        $data = unserialize(str_replace('\\"', '"', $data)); 
     
    21012259                                        'status' => 'fatal' 
    21022260                                )); 
    2103                                  
     2261 
    21042262                                return; 
    21052263                        } 
     
    21212279                                unset($data['owner']); 
    21222280                        } 
    2123                         /*  
    2124                          * Process Photo, if available  
     2281                        /* 
     2282                         * Process Photo, if available 
    21252283                         */ 
    21262284                        $sleep_count = 0; 
     
    21392297                        } 
    21402298                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 
    2141                          
     2299 
    21422300                        if (isset($this->page_info['photos'][$id_photo])) 
    21432301                        { 
     
    21562314                                $this->save_session(); 
    21572315                        } 
    2158                          
     2316 
    21592317                        /* 
    21602318                         * Arrange Date so it gets inserted correctly 
    21612319                         */ 
    2162                           
     2320 
    21632321                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    2164                  
     2322 
    21652323                        $j = 0; 
    21662324                        for ($i = 0; $i < 5; $i+=2) 
     
    21952353                                        continue; 
    21962354                                } 
    2197                                  
     2355 
    21982356                                switch($field) 
    21992357                                { 
     
    22082366                                                /* Do Nothing. This is just to make sure no invalid field is passed */ 
    22092367                                                break; 
    2210                                          
     2368 
    22112369                                        case 'id_status': 
    22122370                                        case 'id_prefix': 
     
    22172375                                                } 
    22182376                                                break; 
    2219                                          
     2377 
    22202378                                        case 'birthdate_0': 
    22212379                                        case 'birthdate_1': 
    22222380                                        case 'birthdate_2': 
    2223                                          
     2381 
    22242382                                                switch($date[$datecount]['digit']) 
    22252383                                                { 
     
    22432401                                                        break; 
    22442402                                                } 
    2245                                                  
     2403 
    22462404                                                if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 
    22472405                                                { 
     
    22522410                                                        return; 
    22532411                                                } 
    2254                                                  
     2412 
    22552413                                                $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 
    22562414                                                break; 
     
    22752433                                                        { 
    22762434                                                                $index = 'address'.$type; 
    2277                                                                  
     2435 
    22782436                                                                $id_state = $this->bo->catalog->add_state($state_info); 
    22792437                                                                $data['addresses'][$index]['id_state'] = $id_state; 
     
    22932451                                                        { 
    22942452                                                                $index = 'address'.$type; 
    2295                                                                  
     2453 
    22962454                                                                $id_city = $this->bo->catalog->add_city($city_info); 
    22972455                                                                $data['addresses'][$index]['id_city'] = $id_city; 
     
    23342492                                ); 
    23352493                        } 
    2336                          
     2494 
    23372495                        eval($code); 
    23382496 
     
    23492507} 
    23502508                /*! 
    2351                  
     2509 
    23522510                        @function post_photo 
    23532511                        @abstract Wrapper to post a photo without reload a page. 
     
    23592517                        //print_r($_FILES); 
    23602518                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); 
    2361                          
     2519 
    23622520                        if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) 
    23632521                        { 
    23642522                                $this->page_info['photos'][$id]['status'] = 'no_upload'; 
    23652523                                $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); 
    2366                                  
     2524 
    23672525                                $this->save_session(); 
    23682526                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    23742532                                $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; 
    23752533                                $this->page_info['photos'][$id]['msg'] = lang('Cannot manipulate Image. No Image added. Please, if you want to use images, ask the Administrator to install GD library.'); 
    2376                                  
     2534 
    23772535                                $this->save_session(); 
    23782536                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    24002558                                return; 
    24012559                        } 
    2402                          
     2560 
    24032561                        switch($_FILES['cc_pd_photo']['type']) 
    24042562                        { 
     
    24302588 
    24312589                                default: 
    2432                                          
     2590 
    24332591                                        $this->page_info['photos'][$id]['status'] = 'invalid_image'; 
    24342592                                        $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); 
     
    24432601                                        $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    24442602                                        $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    2445                                          
     2603 
    24462604                                        $this->save_session(); 
    24472605                                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    24482606                                        return; 
    24492607                        } 
    2450                          
     2608 
    24512609                        $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); 
    24522610                        $dst_img = imagecreatetruecolor(60, 80); 
    2453                          
     2611 
    24542612                        if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) 
    24552613                        { 
    24562614                                $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    24572615                                $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    2458                                  
     2616 
    24592617                                $this->save_session(); 
    24602618                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    24612619                                return; 
    24622620                        } 
    2463                          
     2621 
    24642622                        ob_start(); 
    24652623                        imagepng($dst_img); 
     
    24712629 
    24722630                        $this->save_session(); 
    2473                  
     2631 
    24742632                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    24752633 
     
    24922650                        $fields = $this->bo->catalog->get_fields(false); 
    24932651                        $fields['photo'] = true; 
    2494                          
     2652 
    24952653                        $contact = $this->bo->catalog->get_single_entry($id, $fields); 
    24962654 
     
    25012659                                return; 
    25022660                        } 
    2503                          
     2661 
    25042662                        header('Content-type: image/jpeg'); 
    25052663                        $photo = imagecreatefromstring ($contact['photo']); 
     
    25132671                        return; 
    25142672                } 
    2515                  
     2673 
    25162674                /*! 
    2517                  
     2675 
    25182676                        @function get_states 
    25192677                        @abstract Echos a serialized array containing all the states for the given country 
     
    25372695                                return; 
    25382696                        } 
    2539                          
     2697 
    25402698                        $result = array( 
    25412699                                'msg'    => lang('States Successfully retrieved!'), 
    25422700                                'status' => 'ok' 
    25432701                        ); 
    2544                          
     2702 
    25452703                        foreach ($states as $state_info) 
    25462704                        { 
     
    25812739                                return; 
    25822740                        } 
    2583                          
     2741 
    25842742                        $result = array( 
    25852743                                'msg'    => lang('Cities Successfully retrieved!'), 
    25862744                                'status' => 'ok' 
    25872745                        ); 
    2588                          
     2746 
    25892747                        foreach ($cities as $city_info) 
    25902748                        { 
    25912749                                $result['data'][$city_info['id_city']] = $city_info['name']; 
    25922750                        } 
    2593                          
     2751 
    25942752                        echo serialize($result); 
    25952753                } 
     
    25972755 
    25982756                /*! 
    2599                  
     2757 
    26002758                        @function search 
    26012759                        @abstract Echos a serialized array containing the IDs 
    26022760                                of the entries that matches the search argument 
    26032761                        @author Raphael Derosso Pereira 
    2604                         @author Mário César Kolling (external catalogs) 
     2762                        @author Mï¿œrio Cï¿œsar Kolling (external catalogs) 
    26052763 
    26062764                        @param string $str_data A serialized array with two informations: 
     
    26172775                        // It's an external catalog? 
    26182776                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
    2619                          
    2620             if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
    2621             { 
    2622                 echo serialize(array(                                                                                                    
    2623                    'msg'    => lang('Invalid parameters'),                                                                              
    2624                     'status' => 'abort' 
    2625                 )); 
    2626              
    2627                 return array('error' => lang('Invalid parameters'));                                                                                                                  
    2628             }    
    2629  
    2630              
     2777 
     2778                        if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
     2779                        { 
     2780                                echo serialize(array( 
     2781                                        'msg'    => lang('Invalid parameters'), 
     2782                                        'status' => 'abort' 
     2783                                )); 
     2784 
     2785                                return array('error' => lang('Invalid parameters')); 
     2786                        } 
     2787 
     2788 
    26312789                        /* 
    26322790                         * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly 
     
    26342792                        // Support search parameters with accentuation 
    26352793                        if ($this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     2794/**rev 104**/ 
     2795                                //$this->page_info['actual_catalog']['class'] != 'bo_group_manager') 
    26362796                                $this->page_info['actual_catalog']['class'] != 'bo_group_manager' && 
    26372797                                $this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && 
    26382798                                $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') 
     2799/****/ 
    26392800                        { 
    26402801 
    26412802                                $data['search_for'] = utf8_encode($data['search_for']); 
    26422803                        } 
    2643              
    2644             $rules  = array();                                                                                                           
    2645              
    2646              
    2647             if ($data['search_for'] === '*')                                                                                             
    2648             { 
    2649                 $rules = array(                                                                                                          
    2650                     0 => array(                                                                                                          
    2651                         'field' => $data['fields']['search'],                                                                            
    2652                         'type'  => 'LIKE', 
    2653                         'value' => '%' 
    2654                     )    
    2655                 );   
    2656             }    
    2657             else                                                                                                                         
    2658             { 
    2659                 $names = explode(' ', $data['search_for']);                                                                              
    2660                  
    2661                 if (!is_array($names))                                                                                                   
    2662                 { 
    2663                     echo serialize(array(                                                                                                
    2664                         'msg'    => lang('Invalid Search Parameter'),                                                                    
    2665                         'status' => 'abort' 
    2666                     )); 
    2667   
    2668                 } 
     2804 
     2805                        $rules  = array(); 
     2806 
     2807                        if ($data['search_for'] === '*') 
     2808                        { 
     2809                                $rules = array( 
     2810                                        0 => array( 
     2811                                                'field' => $data['fields']['search'], 
     2812                                                'type'  => 'LIKE', 
     2813                                                'value' => '%' 
     2814                                        ) 
     2815                                ); 
     2816                        } 
     2817                        else 
     2818                        { 
     2819                                $names = explode(' ', $data['search_for']); 
     2820 
     2821                                if (!is_array($names)) 
     2822                                { 
     2823                                        echo serialize(array( 
     2824                                                'msg'    => lang('Invalid Search Parameter'), 
     2825                                                'status' => 'abort' 
     2826                                        )); 
     2827 
     2828                                } 
    26692829 
    26702830                                if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     2831/**rev 104**/ 
     2832                                        //$this->page_info['actual_catalog']['class'] != 'bo_group_manager') 
    26712833                                        $this->page_info['actual_catalog']['class'] != 'bo_group_manager' && 
    2672                                         $this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' &&                                     
     2834                                        $this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && 
    26732835                                        $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager' ) 
     2836/*****/ 
    26742837                                { 
    26752838                                        /* 
     
    26882851                                                        'value' => '%' 
    26892852                                                ), 
     2853/**rev 104**/ 
     2854                                                /// 
     2855                                                //1 => array( 
    26902856                                                2 => array( 
     2857/*****/ 
    26912858                                                        'field' => 'contact.account_visible', 
    26922859                                                        'type'  => '!=', 
    26932860                                                        'value' => '-1' 
     2861/**rev 104**/ 
     2862        /*                                      ), 
     2863                                                2 => array( 
     2864                                                        'field' => 'contact.object_class', 
     2865                                                        'type'  => '=', 
     2866                                                        'value' => 'inetOrgPerson' 
     2867/****/ 
    26942868                                                ), 
    26952869                                        ); 
    26962870                                } 
    2697                  
    2698                 foreach ($names as $name) 
    2699                 { 
    2700                     if ($name != '') 
    2701                     { 
    2702                         array_push($rules, array( 
    2703                             'field' => $data['fields']['search'], 
    2704                             'type'  => 'iLIKE', 
    2705                             'value' => '%'.$name.'%' 
    2706                         )); 
    2707                     } 
    2708                 } 
    2709             } 
     2871 
     2872                                foreach ($names as $name) 
     2873                                { 
     2874                                        if ($name != '') 
     2875                                        { 
     2876                                                array_push($rules, array( 
     2877                                                        'field' => $data['fields']['search'], 
     2878                                                        'type'  => 'iLIKE', 
     2879                                                        'value' => '%'.$name.'%' 
     2880                                                )); 
     2881                                        } 
     2882                                } 
     2883                        } 
    27102884 
    27112885                        if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || 
     2886/**rev 104**/ 
     2887                                //$this->page_info['actual_catalog']['class'] == 'bo_group_manager') 
    27122888                                $this->page_info['actual_catalog']['class'] == 'bo_group_manager' || 
    27132889                                $this->page_info['actual_catalog']['class'] == 'bo_shared_people_manager' || 
    2714                                 $this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager'        ) 
     2890                                $this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager') 
     2891 
     2892 
     2893/***/ 
    27152894                        { 
    27162895                                // Get only this attributes: dn, cn for external catalogs, 
     
    27282907                                        //'contact.account_status', 
    27292908                                        'contact.account_visible' 
    2730                                         ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
    2731                         } 
    2732  
    2733             if (!is_array($ids) || !count($ids)) 
    2734             { 
     2909                                        ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for_area'] ); 
     2910                        } 
     2911 
     2912                        if (!is_array($ids) || !count($ids)) 
     2913                        { 
    27352914                                $this->last_search_ids = null; 
    27362915                                $this->save_session(); 
    27372916                                return null; 
    2738             } 
    2739  
    2740             $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
    2741                          
    2742             $ids_f = array(); 
    2743  
    2744             foreach ($ids as $e_info) 
    2745             { 
     2917                        } 
     2918 
     2919                        $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
     2920 
     2921                        $ids_f = array(); 
     2922 
     2923                        foreach ($ids as $e_info) 
     2924                        { 
     2925/**rev 104**/ 
     2926                                //$ids_f[] = $e_info[$id_field]; 
    27462927                                if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') 
    2747                         $ids_f[] = $e_info[$id_field]; 
    2748                 else 
    2749                         $ids_f[] = array(0=>$e_info[$id_field],1=>$e_info['perms']); 
    2750             } 
     2928                                { 
     2929                                        $ids_f[] = $e_info[$id_field]; 
     2930                                } else{ 
     2931                                        $ids_f[] = array(0=>$e_info[$id_field],1=>$e_info['perms']); 
     2932                                } 
     2933/****/ 
     2934                        } 
    27512935 
    27522936                        return $ids_f; 
    27532937                } 
    2754                  
     2938 
    27552939                // CELEPAR 
    27562940                /* 
     
    27912975                        'status' => 'abort' 
    27922976                    )); 
    2793                      
     2977 
    27942978                    return; 
    27952979                } 
    2796                  
     2980 
    27972981                foreach ($names as $name) 
    27982982                { 
     
    28082992            } 
    28092993 
    2810              
    2811              
     2994 
     2995 
    28122996            //$catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
    2813              
     2997 
    28142998            //if ($catalog['class'] === 'bo_people_catalog') 
    28152999            //{ 
     
    28203004            //    )); 
    28213005            //} 
    2822              
    2823              
     3006 
     3007 
    28243008            $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
    28253009 
     
    28463030                'status' => 'ok' 
    28473031            )); 
    2848                          
     3032 
    28493033                        return; 
    28503034        }*/ 
     
    28563040                        @author Raphael Derosso Pereira 
    28573041 
    2858                         @param array str_data A serialized array containing the ID's of the entries  
     3042                        @param array str_data A serialized array containing the ID's of the entries 
    28593043                                to be taken, the fields to be taken and the rules to be used on the 
    28603044                                retrieval: 
     
    28693053                { 
    28703054                        $data = unserialize($str_data); 
    2871                          
     3055 
    28723056                        if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) 
    28733057                        { 
     
    28793063 
    28803064                        $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); 
    2881                          
     3065 
    28823066                        if (!is_array($entries) or !count($entries)) 
    28833067                        { 
     
    28983082 
    28993083                        @function get_all_entries 
    2900                         @abstract Returns the specified fields for all catalog's entries  
     3084                        @abstract Returns the specified fields for all catalog's entries 
    29013085                                in the default CC UI format 
    29023086                        @author Raphael Derosso Pereira 
    29033087 
    2904                         @params array str_data A serialized array containing the fields to  
     3088                        @params array str_data A serialized array containing the fields to 
    29053089                                be grabbed, the maximum number of entries to be returned and a 
    29063090                                boolean specifying if the calls refers to a new grab or to an 
     
    29113095                { 
    29123096                        $data = unserialize($str_data); 
    2913                          
    2914                         if (!is_array($data) or  
    2915                             !count($data) or  
    2916                                 !count($data['fields']) or  
     3097 
     3098                        if (!is_array($data) or 
     3099                            !count($data) or 
     3100                                !count($data['fields']) or 
    29173101                                !$data['maxlength'] or 
    29183102                                (!$data['new'] and !$data['offset'])) 
     
    29403124                                $data['offset'] = 0; 
    29413125                        } 
    2942                          
     3126 
    29433127                        if ($data['maxlength'] != -1) 
    29443128                        { 
     
    29513135 
    29523136                        $prefs = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    2953                          
     3137 
    29543138                        $jsCode = array(); 
    29553139                        $count = 0; 
     
    29613145                                } 
    29623146 
    2963                                 if($this-> typeContact == 'groups') {                            
    2964                                          
     3147                                if($this-> typeContact == 'groups') { 
     3148 
    29653149                                        foreach ($each as $field => $value)     { 
    2966                                                                                  
     3150 
    29673151                                                if ($field === 'title') { 
    29683152                                                        $optionName = '\\"'.$value.'\\"'; 
    2969                                                           
     3153 
    29703154                                                } 
    29713155                                                else if ($field === 'short_name')       { 
    2972                                                          
     3156 
    29733157                                                        $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; 
    2974                                                         $count++;                                                                                                                                                                        
    2975                                                 }                                        
     3158                                                        $count++; 
     3159                                                } 
    29763160                                        } 
    29773161                                } 
    2978                                  
    2979                                 else  {  
     3162 
     3163                                else  { 
    29803164                                        foreach ($each as $field => $value)     { 
    29813165                                                if ($field === 'names_ordered') { 
     
    29853169                                                } 
    29863170                                                else if ($field === 'connections')      { 
    2987                                                          
     3171 
    29883172                                                        foreach ($value as $connection)         { 
    29893173                                                                if ($connection['id_type'] == $prefs['personCardEmail'])        { 
     
    29983182 
    29993183                        $jsCodeFinal = implode("\n", $jsCode); 
    3000                          
     3184 
    30013185                        $nEntries = count($result); 
    3002                          
     3186 
    30033187                        if (!$nEntries) 
    30043188                        { 
     
    30183202                        ); 
    30193203                } 
    3020                  
     3204 
    30213205                /*********************************************************************\ 
    30223206                 *                      Auxiliar Methods                             * 
     
    30243208 
    30253209                /*! 
    3026                  
     3210 
    30273211                        @function save_session 
    30283212                        @abstract Saves the data on the session 
    30293213                        @author Raphael Derosso Pereira 
    3030                  
     3214 
    30313215                */ 
    30323216                function save_session() 
     
    30373221 
    30383222                /*! 
    3039                  
     3223 
    30403224                        @function convert_tree 
    30413225                        @abstract Converts the tree array in the BO format to a JS tree array compatible 
    30423226                                with the one available in eGW 
    30433227                        @author Raphael Derosso Pereira 
    3044                  
     3228 
    30453229                        @param (array)  $tree    The tree in the BO format 
    30463230                        @param (string) $name    The tree name 
     
    30763260                                        'caption' => $value['name'] 
    30773261                                ); 
    3078                                  
     3262 
    30793263                                switch($value['type']) 
    30803264                                { 
     
    30993283                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
    31003284                        } 
    3101                          
    3102                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
     3285 
     3286                        $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
    31033287                        $dn=$this->bo->catalog->src_info['dn']; 
    31043288                        $justThese = array("givenname","givenname","sn","telephonenumber","mail"); 
    3105                         $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
    3106                         $info = ldap_get_entries($ds, $sr);                                                      
     3289                        $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 
     3290                        $info = ldap_get_entries($ds, $sr); 
    31073291                        for($z = 0; $z < 5; $z++) { 
    3108                                 $participant = $info[0][$justThese[$z]];                                                                                                         
     3292                                $participant = $info[0][$justThese[$z]]; 
    31093293                                array_push($array_participants, $participant); 
    31103294                        } 
     
    31123296                        ldap_close($ds); 
    31133297                        echo serialize($array_participants); 
    3114                 }        
    3115                  
    3116                 function get_catalog_participants_group($id)  
     3298                } 
     3299 
     3300                function get_catalog_participants_group($id) 
    31173301                { 
    31183302                        if(!$this->bo->catalog->src_info) { 
    31193303                                $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    31203304                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
    3121                         }                        
    3122                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                       
    3123                         $justThese = array("description","memberuid");                   
    3124                         $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
     3305                        } 
     3306                        $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
     3307                        $justThese = array("description","memberuid"); 
     3308                        $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 
    31253309                        $info = ldap_get_entries($ds, $sr); 
    31263310                        $member_uids = $info[0]['memberuid']; 
    31273311                        $contact['names_ordered'] = $info[0]['description']; 
    3128                         $filter = "";                    
     3312                        $filter = ""; 
    31293313                        for($z = 0; $z < count($member_uids); $z++) { 
    31303314                                if($member_uids[$z]) 
    3131                                         $filter.="(uid=".$member_uids[$z].")";   
     3315                                        $filter.="(uid=".$member_uids[$z].")"; 
    31323316                        } 
    31333317                        $array_participants = array(); 
     
    31383322                                $dn = implode(',',$valarray); 
    31393323                                $justThese = array("cn","mail"); 
    3140                                 $sr = ldap_search($ds,$dn, $filter,$justThese);                                                          
    3141                                 $info = ldap_get_entries($ds, $sr);                                                      
     3324                                $sr = ldap_search($ds,$dn, $filter,$justThese); 
     3325                                $info = ldap_get_entries($ds, $sr); 
    31423326                                for($z = 0; $z < $info['count']; $z++) { 
    31433327                                        $participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>'; 
    3144                                         $array_emails[$info[$z]['mail'][0]] = null;                                                              
    3145                                         array_push($array_participants, $participant);                                   
     3328                                    $array_emails[$info[$z]['mail'][0]] = null; 
     3329                                        array_push($array_participants, $participant); 
    31463330                                } 
    31473331                                ldap_close($ds); 
    3148                         }                        
     3332                        } 
    31493333                        sort($array_participants); 
    3150                         $innerHTML = '';                         
     3334                        $innerHTML = ''; 
    31513335                        foreach($array_participants as $index => $participant){ 
    31523336                                $innerHTML .= $participant; 
    31533337                        } 
    3154                         $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);                   
     3338                        $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 
    31553339                        echo serialize($return); 
    31563340                } 
    31573341 
    3158                 function get_catalog_participants_list($id)  
     3342                function get_catalog_participants_list($id) 
    31593343                { 
    3160                          
    3161                         $fields = $this->bo->catalog->get_fields(false);                         
     3344 
     3345                        $fields = $this->bo->catalog->get_fields(false); 
    31623346                        $fields['names_ordered'] = true; 
    3163                         $fields['mail_forwarding_address'] = true;                       
    3164                         $contact = $this->bo->catalog->get_single_entry($id,$fields);                    
    3165                          
     3347                        $fields['mail_forwarding_address'] = true; 
     3348                        $contact = $this->bo->catalog->get_single_entry($id,$fields); 
     3349 
    31663350                        $array_participants = array(); 
    31673351                        $array_emails = array(); 
    31683352 
    31693353                        $filter = null; 
    3170                         for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) {                   
     3354                        for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 
    31713355                                        if(strstr($contact['mail_forwarding_address'][$z],'@')) { 
    31723356                                                $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; 
    31733357                                                $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; 
    3174                                         }                                                                                                                                
    3175                                         else  
     3358                                        } 
     3359                                        else 
    31763360                                                $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; 
    3177                         }                                        
    3178                          
     3361                        } 
     3362 
    31793363                        if($filter) { 
    3180                                 $filter = "(|".$filter.")";                                                      
     3364                                $filter = "(|".$filter.")"; 
    31813365                                if(!$this->bo->catalog->src_info) { 
    31823366                                        $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
     
    31843368                                } 
    31853369                                $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
    3186                                  
    31873370                                $dn=$this->bo->catalog->src_info['dn']; 
    31883371                                $justThese = array("cn","mail"); 
    3189                                 $sr = ldap_search($ds,$dn, $filter,$justThese);                                                          
    3190                                 $info = ldap_get_entries($ds, $sr);                                                      
     3372                                $sr = ldap_search($ds,$dn, $filter,$justThese); 
     3373                                $info = ldap_get_entries($ds, $sr); 
    31913374                                for($z = 0; $z < $info['count']; $z++) { 
    31923375                                        $participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>'; 
    3193                                         $array_emails[$info[$z]['mail'][0]] = null;                                                              
    3194                                         array_push($array_participants, $participant);                                   
    3195                                 } 
    3196                                  
     3376                                        $array_emails[$info[$z]['mail'][0]] = null; 
     3377                                        array_push($array_participants, $participant); 
     3378                                } 
     3379 
    31973380                                foreach($array_emails as $index => $email) 
    3198                                         if($email)  
    3199                                                 array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>");                           
    3200                                                                                                  
     3381                                        if($email) 
     3382                                                array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>"); 
     3383 
    32013384                                ldap_close($ds); 
    32023385                        } 
    32033386                        sort($array_participants); 
    3204                         $innerHTML = '';                         
     3387                        $innerHTML = ''; 
    32053388                        foreach($array_participants as $index => $participant){ 
    32063389                                $innerHTML .= $participant; 
    32073390                        } 
    3208                         $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);                   
     3391                        $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 
    32093392                        echo serialize($return); 
    3210                 }        
    3211                  
     3393                } 
     3394 
    32123395                function export_contacts($typeExport){ 
    32133396 
     
    32183401                        if(!count($contacts)) 
    32193402                                echo null; 
    3220                          
     3403 
     3404/**rev 104**/ 
     3405                        // Essa iteraᅵᅵo transforma uma esturuta com contatos redundantes e separados por email ou tel. 
     3406                        // em outra com apenas 1 elemento pra cada contato 
     3407        /*              $i=0; 
     3408                        foreach($contacts as $object){ 
     3409                                $i=($object['id_contact'] - 1); 
     3410                                $all_contacts[$i]['name']=$object['names_ordered']; 
     3411                                if ($object['id_typeof_contact_connection'] == 1) 
     3412                                        $all_contacts[$i]['email']=$object['connection_value']; 
     3413                                else 
     3414                                        $all_contacts[$i]['phone']=$object['connection_value']; 
     3415                        } 
     3416        */ 
     3417/*****/ 
     3418 
    32213419                        switch($typeExport) { 
    32223420 
    32233421                                case 'outlook_en': 
    32243422                                        $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". 
     3423/**rev 104**/ 
     3424        /*                                              "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 
     3425                                        foreach($all_contacts as $index => $object){ 
     3426                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 
     3427                                        } 
     3428        */ 
    32253429                                                        "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";                                                         
    32263430                                        foreach($contacts as $index => $object){ 
    32273431                                                $streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;".$object['phone'].";;;\r\n"; 
    32283432                                        } 
     3433/*****/ 
    32293434                                break; 
    3230                                  
     3435 
    32313436                                case 'outlook_pt-BR': 
    3232                                         $streamBuffer = "Nome;End. de email;Endereço residencial;". 
    3233                                         "Cidade do endereço residencial;CEP do endereço residencial;". 
    3234                                         "Estado;País/região do endereço residencial;Telefone residencial;". 
    3235                                         "Rua do endereço comercial;Cidade do endereço comercial;". 
    3236                                         "CEP do endereço comercial;Estado do endereço comercial;". 
    3237                                         "País/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";                                                        
     3437                                        $streamBuffer = "Nome;End. de email;Endereï¿œo residencial;". 
     3438                                        "Cidade do endereï¿œo residencial;CEP do endereï¿œo residencial;". 
     3439                                        "Estado;Paï¿œs/regiï¿œo do endereï¿œo residencial;Telefone residencial;". 
     3440                                        "Rua do endereï¿œo comercial;Cidade do endereï¿œo comercial;". 
     3441                                        "CEP do endereï¿œo comercial;Estado do endereï¿œo comercial;". 
     3442                                        "Paï¿œs/regiï¿œo do endereï¿œo comercial;Telefone comercial;Empresa;Cargo\r\n"; 
     3443/**rev 104**/ 
     3444                                //      foreach($all_contacts as $index => $object){ 
     3445                                //              $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
    32383446                                        foreach($contacts as $index => $object){ 
    32393447                                                $streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
     3448/******/ 
    32403449                                        } 
    32413450                                break; 
    3242                                  
     3451 
    32433452                                case 'outlook2000_pt-BR': 
    32443453                                        $streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". 
    3245                                         "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereço comercial\",\"Rua do endereço comercial 2\",". 
    3246                                         "\"Rua do endereço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",". 
    3247                                         "\"CEP do endereço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",". 
    3248                                         "\"Rua residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",". 
    3249                                         "\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",". 
     3454                                        "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereï¿œo comercial\",\"Rua do endereï¿œo comercial 2\",". 
     3455                                        "\"Rua do endereï¿œo comercial 3\",\"Cidade do endereï¿œo comercial\",\"Estado do endereï¿œo comercial\",". 
     3456                                        "\"CEP do endereï¿œo comercial\",\"Paï¿œs do endereï¿œo comercial\",\"Endereï¿œo residencial\",\"Rua residencial 2\",". 
     3457                                        "\"Rua residencial 3\",\"Cidade do endereï¿œo residencial\",\"Estado\",\"CEP do endereï¿œo residencial\",\"Paï¿œs do endereï¿œo residencial\",". 
     3458                                        "\"Outro endereï¿œo\",\"Outro endereï¿œo 2\",\"Outro endereï¿œo 3\",\"Cidade\",\"Estado\",\"CEP\",\"Paï¿œs\",". 
    32503459                                        "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 
    32513460                                        "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 
    32523461                                        "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". 
    3253                                         "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversário\",\"Anotações\",\"Caixa postal\",\"Categorias\",". 
    3254                                         "\"Código da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",". 
    3255                                         "\"Nome de exibição do correio eletr.\",\"Endereço de correio eletrônico 2\",". 
    3256                                         "\"Nome de exibição do correio eletr.2\",\"Endereço de correio eletrônico 3\",". 
    3257                                         "\"Nome de exibição do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
    3258                                         "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",". 
    3259                                         "\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
    3260                                         "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",". 
     3462                                        "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversï¿œrio\",\"Anotaᅵᅵes\",\"Caixa postal\",\"Categorias\",". 
     3463                                        "\"Cï¿œdigo da empresa\",\"Cï¿œdigo do governo\",\"Cï¿œnjuge\",\"Conta\",\"Endereï¿œo de correio eletrï¿œnico\",". 
     3464                                        "\"Nome de exibiᅵᅵo do correio eletr.\",\"Endereï¿œo de correio eletrï¿œnico 2\",". 
     3465                                        "\"Nome de exibiᅵᅵo do correio eletr.2\",\"Endereï¿œo de correio eletrï¿œnico 3\",". 
     3466                                        "\"Nome de exibiᅵᅵo do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
     3467                                        "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicaᅵᅵo\",\"Informaᅵᅵes para cobranï¿œa\",\"Iniciais\",\"Local\",". 
     3468                                        "\"Nome do assistente\",\"Nome do gerenciador\",\"Pï¿œgina da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
     3469                                        "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissï¿œo\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretï¿œrio\",". 
    32613470                                        "\"Sexo\"\r\n"; 
     3471 
     3472/**rev 104**/ 
     3473                                        //foreach($all_contacts as $index => $object){ 
     3474                                        //      $streamBuffer.= ",\"".$object['name']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['email']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    32623475                                        foreach($contacts as $index => $object){ 
    32633476                                                $streamBuffer.= ",\"".$object['names_ordered']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['connection_value']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
     3477/******/ 
    32643478                                        } 
    32653479                                break; 
    3266                                  
     3480 
    32673481                                case 'outlook2000_en': 
    32683482                                        $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". 
     
    32763490                                        "Gender,Government ID Number,Hobby,Initials,Internet Free Busy,Keywords,Language,Location,Manager's Name,Mileage,Notes,". 
    32773491                                        "Office Location,Organizational ID Number,PO Box,Priority,Private,Profession,Referred By,Sensitivity,Spouse,User 1,User 2,User 3,User 4,Web Page\r\n"; 
     3492 
     3493/**rev 104**/ 
     3494                                        //foreach($all_contacts as $index => $object){ 
     3495                                        //      $streamBuffer.= ",".$object['name'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['email'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    32783496                                        foreach($contacts as $index => $object){ 
    32793497                                                $streamBuffer.= ",".$object['names_ordered'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['connection_value'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
     3498/*******/ 
    32803499                                        } 
    32813500                                break; 
    3282                                          
     3501 
    32833502                                case 'thunderbird': 
    3284                                         $streamBuffer = "\n";                                                    
     3503                                        $streamBuffer = "\n"; 
     3504 
     3505/**rev 104**/ 
     3506                                        //foreach($all_contacts as $index => $object){ 
     3507                                        //      $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    32853508                                        foreach($contacts as $index => $object){ 
    32863509                                                $streamBuffer.= ",,".$object['names_ordered'].",,".$object['connection_value'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
     3510 
     3511/******/ 
    32873512                                        } 
    32883513                                break; 
    3289                                  
     3514 
    32903515                                case 'expresso': 
    32913516                                        $streamBuffer = "Nome,Email,Telefone\r\n"; 
     3517 
     3518/**rev 104**/ 
     3519                                        //foreach($all_contacts as $index => $object){ 
     3520                                        //      $streamBuffer.= $object['name'].",".$object['email'].",".$object['phone']."\r\n"; 
    32923521                                        foreach($contacts as $index => $object){ 
    32933522                                                $streamBuffer.= $object['names_ordered'].",".$object['connection_value'].",".$object['phone']."\r\n"; 
     3523  
     3524/******/ 
    32943525                                        } 
    32953526                                break; 
    3296                                  
     3527 
    32973528                        } 
    32983529 
     
    33023533                        if(!$f) 
    33033534                                echo null; 
    3304                  
     3535 
    33053536                        fputs($f,$streamBuffer); 
    33063537                        fclose($f); 
     
    33153546                         $re_d = '\x' . dechex(ord($delimiter));            //format for regexp 
    33163547                        $re_tq = '\x' . dechex(ord($text_qualifier));    //format for regexp 
    3317                          
     3548 
    33183549                        $fields = array(); 
    33193550                        $field_num = 0; 
     
    33213552                        if($text{0} == $text_qualifier) { 
    33223553                                preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches); 
    3323                                 
     3554 
    33243555                                $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]); 
    33253556                                $text = trim($matches[2]); 
    3326                 
     3557 
    33273558                                $fields[$field_num++] = $value; 
    33283559                        } else { 
    33293560                                preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches); 
    3330                                 
     3561 
    33313562                                $value = $matches[1]; 
    33323563                                $text = trim($matches[2]); 
    3333                 
     3564 
    33343565                                $fields[$field_num++] = $value; 
    33353566                } 
     
    33403571                } 
    33413572 
     3573                //funcao alterada para importar outros campos alem de nome, telefone e email, de arquivo csv (Outlook 2000) 
     3574                //em 08/04/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); 
     3575                //Foi adicionada uma funcao (escapesheelcmd()) nas variaveis para que caracteres especiais sejam ignorados 
     3576                //durante a importacao dos contatos; o processo estava travando por causa de caracteres em campos como nome, 
     3577                //sobrenome, notas e e-mail; 
     3578                //em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); 
    33423579                function import_contacts($typeImport){ 
    33433580 
    3344                         if($file = $_SESSION['contactcenter']['importCSV']) {                            
    3345                                 unset($_SESSION['contactcenter']['importCSV']);                          
     3581                        if($file = $_SESSION['contactcenter']['importCSV']) { 
     3582                                unset($_SESSION['contactcenter']['importCSV']); 
    33463583                                $len = filesize($file); 
    33473584                                $count = 0; 
    33483585                                $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); 
    33493586                                $handle = @fopen($file, "r") or die(serialize($return['error'] = true)); 
    3350                                  
     3587 
    33513588                                $input_header = fgets($handle); 
    33523589                                if ($typeImport == 'outlook') 
     
    33543591                                else if ($typeImport == 'auto') 
    33553592                                $delim = strstr($input_header,',') ? ',' : ';'; 
    3356                                 else   
     3593                                else 
    33573594                                        $delim = ','; 
    33583595                                $csv_header = $this->parse_line($input_header,$delim); 
    33593596                                $firstContact = fgets($handle); 
    33603597                                preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv 
    3361                                 rewind($handle);                                 
     3598                                rewind($handle); 
    33623599 
    33633600                                $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); 
     
    33683605                                        return; 
    33693606                                } 
    3370                                  
     3607 
    33713608                                if ($matches[0][strlen($matches[0])-1] == ';') 
    33723609                                        $delim = ';'; 
    3373                                  
     3610 
    33743611                        $boGroup = CreateObject('contactcenter.bo_group'); 
    33753612                        $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
     
    33773614                                        case 'outlook2000': 
    33783615                                                $name_pos=1; 
     3616                                                $name2_pos=2; 
     3617                                                $name3_pos=3; 
     3618                                                $addr1_pos=8; 
     3619                                                $cep_pos=13; 
     3620                                                $addr2_pos=22; 
     3621                                                $fax_pos=30; 
     3622                                                $phone_pos=31; 
     3623                                                $resPhone_pos=37; 
     3624                                                $cellPhone_pos=40; 
     3625                                                $pager_pos=43; 
     3626                                                $birth_pos=48; 
     3627                                                $notes_pos=49; 
    33793628                                                $email_pos=56; 
    3380                                                 $phone_pos=44; 
     3629                                                $altEmail_pos=59; 
     3630 
    33813631                                                break; 
    33823632                                        case 'outlook': 
    3383                                                 $name_pos=0; 
    3384                                                 $email_pos=1; 
     3633                                                $name_pos=3; 
     3634                                                $email_pos=4; 
    33853635                                                $phone_pos=7; 
     3636                                                $resPhone_pos=10; 
     3637                                                $cellPhone_pos=12; 
     3638                                                $addr1_pos=13; 
     3639                                                $cep_pos=15; 
     3640                                                $phone_pos=18; 
     3641                                                $fax_pos=19; 
     3642                                                $pager_pos=20; 
     3643                                                $notes_pos=25; 
    33863644                                                break; 
    33873645                                        case 'thunderbird': 
     
    33983656                                                foreach($csv_header as $index => $fieldName) 
    33993657                                                { 
    3400                                                         switch(strtoupper($fieldName)){ 
    3401                                                         case 'NAME': 
    3402                                                         case 'NOME': 
    3403                                                         case 'FIRST NAME': 
     3658                                                        switch($fieldName){ 
     3659                                                        case 'Name': 
     3660                                                        case 'Nome': 
     3661                                                        case 'First Name': 
    34043662                                                                $name_pos = $index; 
    34053663                                                                break; 
    3406                                                         case 'E-MAIL': 
    3407                                                         case 'EMAIL': 
    3408                                                         case 'E-MAIL ADDRESS': 
    3409                                                         case 'ENDEREÇO DE CORREIO ELETRÔNICO': 
    3410                                                         case 'END. DE EMAIL': 
     3664                                                        case 'Second name': 
     3665                                                        case 'Segundo nome': 
     3666                                                                $name2_pos = $index; 
     3667                                                                break; 
     3668                                                        case 'Sobrenome': 
     3669                                                        case 'Surname': 
     3670                                                                $name3_pos = $index; 
     3671                                                                break; 
     3672                                                        case 'Business Street': 
     3673                                                        case 'Rua do endereço comercial': 
     3674                                                                $addr1_pos = $index; 
     3675                                                                break; 
     3676                                                        case 'Rua do endereço comercial 2': 
     3677                                                        case 'Outro endereço': 
     3678                                                                $addr2_pos = $index; 
     3679                                                                break; 
     3680                                                        case 'Business Postal Code': 
     3681                                                        case 'CEP do endereço comercial': 
     3682                                                                $cep_pos = $index; 
     3683                                                                break; 
     3684                                                        case 'Business Fax': 
     3685                                                        case 'Fax comercial': 
     3686                                                        case 'Fax': 
     3687                                                                $fax_pos = $index; 
     3688                                                                break; 
     3689                                                        case 'Home Phone': 
     3690                                                        case 'Telefone residencial': 
     3691                                                                $resPhone_pos = $index; 
     3692                                                                break; 
     3693                                                        case 'Mobile phone': 
     3694                                                        case 'Telefone celular': 
     3695                                                                $cellPhone_pos = $index; 
     3696                                                                break; 
     3697                                                        case 'Pager': 
     3698                                                                $pager_pos = $index; 
     3699                                                                break; 
     3700                                                        case 'Phone': 
     3701                                                        case 'Business Phone': 
     3702                                                        case 'Telefone': 
     3703                                                        case 'Telefone principal': 
     3704                                                        case 'Telefone comercial': 
     3705                                                                $phone_pos = $index; 
     3706                                                                break; 
     3707                                                        case 'Aniversário': 
     3708                                                        case 'Birthdate': 
     3709                                                                $birth_pos = $index; 
     3710                                                        case 'Anotações': 
     3711                                                        case 'Notes': 
     3712                                                                $notes_pos = $index; 
     3713                                                        case 'E-mail': 
     3714                                                        case 'Email': 
     3715                                                        case 'E-mail Address': 
     3716                                                        case 'Endereï¿œo de correio eletrï¿œnico': 
     3717                                                        case 'End. de email': 
    34113718                                                                $email_pos = $index; 
    34123719                                                                break; 
    3413                                                         case 'HOME PHONE': 
    3414                                                         case 'PHONE': 
    3415                                                         case 'TELEFONE': 
    3416                                                         case 'TELEFONE PRINCIPAL': 
    3417                                                         case 'TELEFONE COMERCIAL': 
    3418                                                                 $phone_pos = $index; 
     3720                                                        case 'Endereï¿œo de correio eletrï¿œnico 2': 
     3721                                                                $altEmail_pos = $index; 
    34193722                                                                break; 
    34203723                                                        } 
     
    34223725                                                break; 
    34233726                                } 
    3424                                  
    34253727 
    34263728                                while (($data = fgetcsv($handle, $len, $delim))) { 
    34273729                                foreach ($header as $key=>$heading) 
    34283730                                $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 
    3429                                  
     3731 
    34303732                                        $sdata = array(); 
    3431                                         $full_name  = trim($row[$header[$name_pos]]); 
     3733                                        $full_name      = trim($row[$header[$name_pos]]); 
    34323734                                        $email          = trim($row[$header[$email_pos]]); 
    34333735                                        $phone          = trim($row[$header[$phone_pos]]); 
     3736                                        $name2          = trim($row[$header[$name2_pos]]); 
     3737                                        $name3          = trim($row[$header[$name3_pos]]); 
     3738 
     3739                                        $addr1          = trim($row[$header[$addr1_pos]]); 
     3740                                        $addr2          = trim($row[$header[$addr2_pos]]); 
     3741                                        $cep            = trim($row[$header[$cep_pos]]); 
     3742                                        $fax            = trim($row[$header[$fax_pos]]); 
     3743                                        $resPhone       = trim($row[$header[$resPhone_pos]]); 
     3744                                        $cellPhone      = trim($row[$header[$cellPhone_pos]]); 
     3745                                        $pager          = trim($row[$header[$pager_pos]]); 
     3746                                        $birth          = trim($row[$header[$birth_pos]]); 
     3747                                        $notes          = trim($row[$header[$notes_pos]]); 
     3748                                        $altEmail       = trim($row[$header[$altEmail_pos]]); 
     3749 
     3750                                        $full_name = escapeshellcmd($full_name); 
    34343751                                        $array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name)))); 
    3435                                         $sdata['given_names'] = $array_name[0]; 
     3752                                        $sdata['given_names'] = escapeshellcmd($array_name[0]); 
    34363753                                        $array_name[0] = null; 
    34373754                                        $sdata['family_names'] = trim(implode(' ',$array_name)); 
     3755                                        if($sdata['family_names'] == '') 
     3756                                        { 
     3757                                                $sdata['family_names'] = escapeshellcmd($name2) . " " . escapeshellcmd($name3); 
     3758                                        } 
     3759 
    34383760                                        $sdata['connections']['default_email']['connection_name'] = lang('Main'); 
    3439                                         $sdata['connections']['default_email']['connection_value'] = $email; 
     3761                                        $sdata['connections']['default_email']['connection_value'] = escapeshellcmd($email); 
    34403762 
    34413763                                        $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 
     3764                                        $sdata['connections']['default_phone']['connection_value'] = escapeshellcmd($phone); 
     3765 
     3766                                        $sdata['connections']['fax']['connection_name'] = lang('Fax'); 
     3767                                        $sdata['connections']['fax']['connection_value'] = escapeshellcmd($fax); 
     3768 
     3769                                        $sdata['connections']['residencial_phone']['connection_name'] = lang('Residencial'); 
     3770                                        $sdata['connections']['residencial_phone']['connection_value'] = escapeshellcmd($resPhone); 
     3771 
     3772                                        $sdata['connections']['cellular_phone']['connection_name'] = lang('Cellphone'); 
     3773                                        $sdata['connections']['cellular_phone']['connection_value'] = escapeshellcmd($cellPhone); 
     3774 
     3775                                        $sdata['connections']['pager']['connection_name'] = lang('Pager'); 
     3776                                        $sdata['connections']['pager']['connection_value'] = escapeshellcmd($pager); 
     3777 
     3778                                        $sdata['connections']['alternative_email']['connection_name'] = lang('Alternative'); 
     3779                                        $sdata['connections']['alternative_email']['connection_value'] = escapeshellcmd($altEmail); 
     3780 
     3781                                        $sdata['addresses']['addr1']['address_value'] = escapeshellcmd($addr1); 
     3782                                        $sdata['addresses']['addr2']['address_value'] = escapeshellcmd($addr2); 
     3783                                        $sdata['addresses']['cep']['address_value'] = escapeshellcmd($cep); 
     3784 
     3785                                        $array_birth = explode("/",$birth); 
     3786 
     3787                                        $sdata['birthdate'] = escapeshellcmd(date('Y-m-d', mktime(0,0,0,$array_birth[1],$array_birth[0],$array_birth[2]))); 
     3788 
     3789                                        $sdata['notes'] = escapeshellcmd($notes); 
     3790                                        $sdata['is_quick_add'] = true; 
    34423791                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    3443                                         $sdata['is_quick_add'] = true; 
    3444                                          
     3792 
    34453793                                        //      verifica se email já existe! 
     3794                                        $email = escapeshellcmd($email); 
    34463795                                        $contact = $boGroup->verify_contact($email); 
    3447                                                                                  
     3796 
    34483797                                        if(!$sdata['given_names'] && $email){ 
    34493798                                                        $a_email = explode("@",$email); 
    3450                                                         $sdata['given_names'] = $a_email[0]; 
     3799                                                        $sdata['given_names'] = escapeshellcmd($a_email[0]); 
    34513800                                        } 
    34523801 
    3453                                         $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];  
     3802                                        $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new']; 
     3803 
    34543804                                        if($contact){ 
    34553805                                                $return['_existing']++; 
    3456                                         }                                                                                                                
    3457                                         else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
     3806                                        } 
     3807                                        else if(!eregi("^[/_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
    34583808                                                $return['_failure']++; 
    34593809                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
    34603810                                        } 
    34613811                                        else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){ 
    3462                                                 $return['_failure']++;                                                   
     3812                                                $return['_failure']++; 
    34633813                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 
    34643814                                        } 
    34653815                                        else 
    34663816                                                $return['_new']++; 
    3467                         }                                
     3817                        } 
    34683818                                fclose($handle); 
    34693819                                unlink($file); 
     
    34743824                        echo serialize($return); 
    34753825                } 
    3476 /* 
    3477                 function convert_tree($tree, $name, &$iconDir, $parent='0') 
    3478                 { 
    3479                         $new = null; 
    3480                         $code = null; 
    3481                          
    3482                         if ($parent === '0') 
    3483                         { 
    3484  
    3485                                 $code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n"; 
    3486                         } 
    3487                          
    3488                         foreach ($tree as $id => $value) 
    3489                         { 
    3490                                 $title = $value['name']; 
    3491  
    3492                                 switch ($value['type']) 
    3493                                 {                                        
    3494                                         case 'unknown': 
    3495                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption:'{$value['name']}', onFirstOpen: 'getCatalogTree(\\'{$parent}.{$id}\\');', onClick: 'getCatalogTree(\\'{$parent}.{$id}\\'); waitForTree(\\'{$parent}.{$id}\\', 0)'}),'$parent');\n";  
    3496                                                 break; 
    3497                                          
    3498                                         case 'catalog_group': 
    3499                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n";  
    3500                                                 $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    3501                                                 break; 
    3502  
    3503                                         case 'mixed_catalog_group': 
    3504                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n"; 
    3505  
    3506                                                 $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    3507                                                 break; 
    3508                                          
    3509                                         case 'catalog': 
    3510                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n"; 
    3511                                                  
    3512                                 } 
    3513                         } 
    3514                          
    3515                         return $code; 
    3516                 } 
    3517 */ 
    35183826        } 
    35193827 
Note: See TracChangeset for help on using the changeset viewer.