Ignore:
Timestamp:
05/23/08 17:10:39 (16 years ago)
Author:
brunocosta
Message:

Correção dos problemas gerados no commit anterior, a funcionalidade citada no ticket #199 foram temporariamente desativadas.

File:
1 edited

Legend:

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

    r284 r285  
    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  
    50                         //TODO: Achar um modo de descarregar este array da sessï¿œo quando o usuï¿œrio sair da tela do contactcenter. 
    51                         //TODO: Descarregar este array da memï¿œria toda vez que uma nova consulta por letras ou mudanï¿œa de catï¿œlogo for feita. 
    52                         $temp3 = $GLOBALS['phpgw']->session->appsession('ui_data.last_search_ids','contactcenter'); 
    53  
     49                         
    5450                        $this->bo = CreateObject('contactcenter.bo_contactcenter'); 
    55  
     51                         
    5652                        if ($temp) 
    5753                        { 
     
    6359                                $this->all_entries = $temp2; 
    6460                        } 
    65  
    66                         if ($temp3) 
    67                         { 
    68                                 $this->last_search_ids = $temp3; 
    69                         } 
    70  
     61                         
    7162                        if (!$this->page_info['actual_catalog']) 
    7263                        { 
     
    7465                                $this->page_info['actual_catalog'] = $catalogs[0]; 
    7566                        } 
    76  
    77                         $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); 
    78  
     67                         
     68                        $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']);                        
     69                         
    7970                        if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') 
    8071                                $this -> typeContact = 'groups'; 
     
    8475 
    8576                /*! 
    86  
     77                 
    8778                        @function index 
    8879                        @abstract Builds the Main Page 
    8980                        @author Raphael Derosso Pereira 
    9081                        @author Jonas Goes 
    91  
    92                 */ 
     82                         
     83                */               
    9384                function index() 
    94                 { 
     85                {        
    9586                        if(!@is_object($GLOBALS['phpgw']->js)) 
    9687                        { 
     
    10192                        $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); 
    10293                        $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); 
    103  
     94                         
    10495//                      $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); 
    10596                        $GLOBALS['phpgw']->common->phpgw_header(); 
    106  
     97                         
    10798                        $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); 
    10899                        $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); 
    109  
     100                         
    110101                        /* Quick Add */ 
    111102                        $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); 
     
    116107                        $GLOBALS['phpgw']->template->set_var('cc_qa_save',lang('Save')); 
    117108                        $GLOBALS['phpgw']->template->set_var('cc_qa_clear',lang('Clear')); 
     109                        $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close')); 
    118110                        /* End Quick Add */ 
    119  
     111                         
    120112                        $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; 
    121113                        $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; 
     
    123115                        $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); 
    124116                        $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); 
    125  
     117                         
    126118                        $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 
    127  
     119                         
    128120                        $GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); 
    129121                        $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 
    130  
     122                         
    131123                        $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 
    132124                        $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); 
     
    137129                        $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); 
    138130                        $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); 
    139  
     131                         
    140132                        /* Panel */ 
    141133                        $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); 
     
    143135                        $GLOBALS['phpgw']->template->set_var('cc_panel_table',lang('Table View')); 
    144136                        $GLOBALS['phpgw']->template->set_var('cc_panel_cards',lang('Cards View')); 
    145  
     137                        $GLOBALS['phpgw']->template->set_var('cc_btn_import_export', lang('Import/Export')); 
     138                        $GLOBALS['phpgw']->template->set_var('cc_btn_new', lang("New...")); 
     139                         
    146140                        $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); 
    147141                        $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); 
     
    151145                        $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); 
    152146                        /* End Panel */ 
    153  
     147                         
    154148                        /* Messages */ 
    155149                        $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); 
     
    166160                        $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); 
    167161                        /* End Messages */ 
    168  
     162                         
    169163                        $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); 
    170164                        $GLOBALS['phpgw']->template->set_var('cc_is_my',lang('Is My')); 
     165                        $GLOBALS['phpgw']->template->set_var('cc_ie_personal',lang('Import/Export pesonal contacts')); 
    171166                        $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); 
    172167                        $GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation')); 
    173                         $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); 
     168                        $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));                       
    174169                        $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 
    175170                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); 
     
    179174                        $GLOBALS['phpgw']->template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    180175 
     176                        $GLOBALS['phpgw']->template->set_var('cc_msg_import_contacts', lang('Import Contacts')); 
     177                        $GLOBALS['phpgw']->template->set_var('cc_msg_export_contacts', lang('Export Contacts')); 
     178                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_info_csv', lang('The Expresso supports the contacts importation in the CSV file format.')); 
     179                        $GLOBALS['phpgw']->template->set_var('cc_msg_choose_file_type', lang('Select the file type')); 
     180                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express', lang('Outlook Express')); 
     181                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook2k', lang('Outlook 2000')); 
     182                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default', lang('Expresso (default)')); 
     183                        $GLOBALS['phpgw']->template->set_var('cc_msg_choose_contacts_file', lang('Select the file that contains the contacts to be imported:')); 
     184                        $GLOBALS['phpgw']->template->set_var('cc_msg_close_win', lang('Close')); 
     185                        $GLOBALS['phpgw']->template->set_var('cc_msg_close', lang('Close')); 
     186                        $GLOBALS['phpgw']->template->set_var('cc_msg_ie_personal', lang('Import / Export personal Contacts')); 
     187                        $GLOBALS['phpgw']->template->set_var('cc_msg_import_fail', lang('The importation has failed. Verify the file format.')); 
     188                        $GLOBALS['phpgw']->template->set_var('cc_msg_importing_contacts', lang('Importing Contacts...')); 
     189                        $GLOBALS['phpgw']->template->set_var('cc_msg_import_finished', lang('The importation has finished.')); 
     190                        $GLOBALS['phpgw']->template->set_var('cc_msg_new', lang(' new')); 
     191                        $GLOBALS['phpgw']->template->set_var('cc_msg_failure', lang(' failed')); 
     192                        $GLOBALS['phpgw']->template->set_var('cc_msg_exists', lang(' were existent')); 
     193                        $GLOBALS['phpgw']->template->set_var('cc_msg_show_more_info', lang('show more info')); 
     194                        $GLOBALS['phpgw']->template->set_var('cc_msg_clean', lang('Clean')); 
     195                        $GLOBALS['phpgw']->template->set_var('cc_msg_invalid_csv', lang('Select a valid CSV file to import your contacts')); 
     196                        $GLOBALS['phpgw']->template->set_var('cc_msg_export_csv', lang('Select the format type that you want to export your contacts')); 
     197                        $GLOBALS['phpgw']->template->set_var('cc_msg_automatic', lang('Automatic')); 
     198                        $GLOBALS['phpgw']->template->set_var('cc_msg_export_error', lang('An error has occurred while the exportation.')); 
     199                        $GLOBALS['phpgw']->template->set_var('cc_msg_new_email', lang('New Email')); 
     200                        $GLOBALS['phpgw']->template->set_var('cc_msg_main', lang('Main')); 
     201                        $GLOBALS['phpgw']->template->set_var('cc_msg_alternative', lang('Alternative')); 
     202                        $GLOBALS['phpgw']->template->set_var('cc_msg_select_email', lang('Select E-Mail')); 
     203                        $GLOBALS['phpgw']->template->set_var('cc_msg_new_phone', lang('New Telephone')); 
     204                        $GLOBALS['phpgw']->template->set_var('cc_msg_home', lang('Home')); 
     205                        $GLOBALS['phpgw']->template->set_var('cc_msg_cellphone', lang('Cellphone')); 
     206                        $GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work')); 
     207                        $GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax')); 
     208                        $GLOBALS['phpgw']->template->set_var('cc_msg_pager', lang('Pager')); 
     209                        $GLOBALS['phpgw']->template->set_var('cc_msg_choose_phone', lang('Select the telephone')); 
     210                        $GLOBALS['phpgw']->template->set_var('cc_msg_warn_firefox', lang('Warning: Too old version of Firefox')); 
     211                        $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half1', lang('For this application work correctly</u>')); 
     212                        $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half2', lang('it\'s necessary to update your Firefox Browser for a new version (version > 1.5) Install now clicking in the link bellow, or if you want to update it later')); 
     213                        $GLOBALS['phpgw']->template->set_var('cc_msg_click_close', lang('click Close')); 
     214                        $GLOBALS['phpgw']->template->set_var('cc_msg_install_now', lang('Install Now')); 
     215                        $GLOBALS['phpgw']->template->set_var('cc_msg_install_new_firefox', lang('Install a new Firefox version')); 
     216                        $GLOBALS['phpgw']->template->set_var('cc_msg_moz_thunderbird', lang('Export as Mozilla Thunderbird CSV.')); 
     217                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_pt', lang('Export as Outlook Express (Portuguese) CSV.')); 
     218                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_en', lang('Export as Outlook Express (English) CSV.')); 
     219                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.')); 
     220                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.')); 
     221                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 
     222                        $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 
     223                        $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
     224                        $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
     225                         
    181226                        $GLOBALS['phpgw']->template->parse('out','index'); 
    182  
     227                         
    183228                        $api = CreateObject('contactcenter.ui_api'); 
    184229                        $main = $api->get_full_add(); 
     
    191236                } 
    192237 
    193  
     238                 
    194239                /*! 
    195  
     240                 
    196241                        @function data_manager 
    197                         @abstract Calls the right method and passes to it the right 
     242                        @abstract Calls the right method and passes to it the right  
    198243                                parameters 
    199244                        @author Raphael Derosso Pereira 
    200  
     245                 
    201246                */ 
    202247                function data_manager() 
     
    207252                                case 'set_n_cards': 
    208253                                        return $this->set_n_cards((int)$_GET['ncards']); 
    209  
    210                                 case 'get_cards_data': 
    211  
     254                                         
     255                                case 'get_cards_data':                                   
    212256                                        $ids = false; 
    213257                                        // To support ldap catalogs using accentuation 
    214258                                        if ($_POST['letter'] == 'search' && isset($_POST['data'])) 
    215259                                        { 
    216                                                 //$ids = utf8_decode($this->search($_POST['data'])); 
    217                                                 $ids = $this->search($_POST['data']); 
     260                                                $ids = utf8_decode($this->search($_POST['data'])); 
    218261                                        } 
    219  
    220                                         //return $this->get_cards_data($_POST['letter'], $_POST['page'], unserialize(str_replace('\\"','"',$ids))); 
    221                                         return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids); 
    222                                         //return $this->get_cards_data($_POST['letter'], $_POST['page'], unserialize(str_replace('\\"','"',$_POST['ids']))); 
    223  
     262                                         
     263                                        if(isset($_SESSION['ids'])) 
     264                                                $ids = $_SESSION['ids']; 
     265                                         
     266                                        return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids);                                            
    224267                                case 'get_cards_data_get': 
    225268                                        return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); 
     
    229272                                        return $this->get_photo($_GET['id']); 
    230273 
    231  
     274                                case 'get_visible_all_ldap': 
     275                                        echo $this->get_visible_all_ldap(); 
     276                                        return; 
     277                                         
    232278                                /* Catalog Methods */ 
    233279                                case 'set_catalog': 
    234280                                        return $this->set_catalog($_GET['catalog']); 
    235  
     281                                         
    236282                                case 'get_catalog_tree': 
    237283                                        echo serialize($this->get_catalog_tree($_GET['level'])); 
     
    250296                                        echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); 
    251297                                        return; 
    252  
     298                                         
    253299                                /* Full Add Methods */ 
    254300                                case 'get_full_data': 
    255301                                        return $this->get_full_data($_GET['id']); 
    256  
     302                                 
    257303                                case 'get_group': 
    258304                                        return $this->get_group_data($_GET['id']); 
    259  
     305                                         
    260306                                case 'get_contact_full_add_const': 
    261307                                        return $this->get_contact_full_add_const(); 
     
    269315                                case 'get_states': 
    270316                                        return $this->get_states($_GET['country']); 
    271  
     317                                         
    272318                                case 'get_cities': 
    273319                                        return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); 
    274  
    275  
     320                                         
     321                                         
    276322                                /* Other Methods */ 
    277                                 case 'quick_add': 
     323                                case 'quick_add':                                                                                                                        
    278324                                        return $this->quick_add($_POST['add']); 
    279  
    280                                 case 'add_group': 
     325                                 
     326                                case 'add_group':                                                                                                                        
    281327                                        return $this->add_group($_POST['add']); 
    282  
     328                                                                         
    283329                                case 'remove_entry': 
    284330                                        return $this->remove_entry((int)$_GET['remove']); 
    285  
     331                                 
    286332                                case 'remove_all_entries': 
    287333                                        return $this->remove_all_entries(); 
    288334 
    289335                                case 'remove_group': 
    290  
    291                                         return $this->remove_group((int)$_GET['remove']); 
     336                                                                                 
     337                                        return $this->remove_group((int)$_GET['remove']);                                        
    292338 
    293339                                case 'search': 
    294                                         return $this->search(str_replace('\\"', '"', $_GET['data'])); 
     340                                        $ids = false; 
     341                                        $ids = $this->search($_GET['data']); 
     342                                        return $this->get_cards_data('search', '1', $ids); 
    295343 
    296344                                case 'email_win': 
     
    326374 
    327375                /*! 
    328  
     376                 
    329377                        @function set_n_cards 
    330378                        @abstract Informs the class the number of cards the page can show 
    331379                        @author Raphael Derosso Pereira 
    332  
     380                         
    333381                        @param integer $n_cards The number of cards 
    334  
     382                         
    335383                */ 
    336384                function set_n_cards($n_cards) 
     
    341389                                echo 1; 
    342390                        } 
    343  
     391                         
    344392                        $this->save_session(); 
    345393                } 
    346  
     394                                 
    347395                /*! 
    348  
     396                 
    349397                        @function set_catalog 
    350398                        @abstract Sets the current catalog selected by the user 
    351399                        @author Raphael Derosso Pereira 
    352  
     400                         
    353401                        @param string $id_catalog The sequence of IDs to reach the catalog 
    354402                                separated by commas 
    355  
     403                 
    356404                */ 
    357405                function set_catalog($id_catalog) 
     
    359407                        $id_catalog = str_replace('\\"', '"', $id_catalog); 
    360408                        $temp =& $this->bo->set_catalog($id_catalog); 
    361  
     409                         
    362410                        if ($temp) 
    363411                        { 
     
    366414                                $this->page_info['actual_catalog'] =& $temp; 
    367415                                $this->save_session(); 
    368  
     416                                 
    369417                                $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
    370  
     418                                 
    371419                                if ($catalog_info['class'] === 'bo_global_ldap_catalog' || 
    372420                                    $catalog_info['class'] === 'bo_catalog_group_catalog') 
     
    378426                                        $perms = 15; 
    379427                                } 
    380  
     428                                 
    381429                                echo serialize(array( 
    382430                                        'status' => 'ok', 
     
    386434                                return; 
    387435                        } 
    388  
     436                         
    389437                        echo serialize(array( 
    390438                                'status' => 'ok', 
     
    392440                        )); 
    393441                } 
    394  
    395  
     442                 
     443                 
    396444                /*! 
    397  
     445                 
    398446                        @function get_catalog_tree 
    399447                        @abstract Returns the JS serialized array to used as the tree 
    400448                                level 
    401449                        @author Raphael Derosso Pereira 
    402                         @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout) 
    403  
    404                         @param (string) $level The level to be taken 
    405  
     450            @author Mário César Kolling (error messages and timeout) 
     451                         
     452                        @param (string) $level The level to be taken  
     453                 
    406454                */ 
    407455                function get_catalog_tree($level) 
     
    412460 
    413461                                $parent = '0'; 
    414  
     462                                 
    415463                                if (!($tree = $this->bo->get_catalog_tree($level))) 
    416464                                { 
     
    426474                                $parent = substr($level, 0, $last_dot); 
    427475                                $child = substr($level, $last_dot+1, strlen($level)); 
    428  
     476                         
    429477                                if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 
    430478                                { 
     
    445493                                } 
    446494                        } 
    447  
     495                         
    448496                        $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    449497                        $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    450  
     498                         
    451499                        // Deals with error messages from the server and returns them to the browser 
    452500                        if ($tree['msg']) 
     
    474522                                        'status' => 'error' 
    475523                                ); 
    476  
    477524                        } 
    478525                } 
    479  
    480 /*              function get_catalog_tree($level, $name = 'tree') 
    481                 { 
    482                         if ($level === '0') 
    483                         { 
    484                                 $folderImageDir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/dftree/images/'; 
    485                                 $tree_js =  $name." = new dFTree({'name': '".$name."'});\n"; 
    486  
    487                                 $parent = '0'; 
    488                                 $child  = '0'; 
    489  
    490                                 if (!($tree = $this->bo->get_catalog_tree($level))) 
    491                                 { 
    492                                         return '0'; 
    493                                 } 
    494                         } 
    495                         else 
    496                         { 
    497                                 $last_dot = strrpos($level,'.'); 
    498                                 $parent = substr($level, 0, $last_dot); 
    499                                 $child = substr($level, $last_dot+1, strlen($level)); 
    500  
    501                                 $tree_js = ''; 
    502  
    503                                 if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 
    504                                 { 
    505                                         return '0'; 
    506                                 } 
    507                         } 
    508  
    509                         $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    510                         $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    511  
    512                         $tree_js .= $this->convert_tree($tree, $name, $folderImageDir, $parent); 
    513  
    514                         return $tree_js; 
    515                 } 
    516 */ 
    517  
     526                 
    518527                /*! 
    519  
     528                 
    520529                        @function get_actual_catalog 
    521530                        @abstract Returns the actual selected Catalog 
     
    524533                */ 
    525534                function get_actual_catalog() 
    526                 { 
     535                {                        
    527536                        $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); 
    528  
     537                         
    529538                        if ($level) 
    530539                        { 
     
    540549                        ); 
    541550                } 
    542  
     551                 
    543552                /*! 
    544  
     553                 
    545554                        @function get_cards_data 
    546555                        @abstract Returns the information that is placed on the cards 
    547556                        @author Raphael Derosso Pereira 
    548  
     557                         
    549558                        @param string $letter The first letter to be searched 
    550                         @param (int)  $page The page to be taken 
     559                        @param (int)  $page The page to be taken  
    551560                        @param (str)  $ids The ids to be taken in case of search 
    552561 
     
    556565                function get_cards_data($letter, $page, $ids) 
    557566                { 
     567                        if( $ids ) 
     568                                $_SESSION['ids'] = $ids;                    
    558569 
    559570                        // It's an external catalog? 
    560571                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
    561  
    562572                        //echo $page."\n"; 
    563573                        if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or 
    564                             ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 
     574                            ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or  
    565575                            $this->page_info['changed'])) 
    566576                        { 
    567577                                unset($ids); 
    568578                                $this->page_info['changed'] = false; 
    569  
     579                                  
    570580                                switch ($this->page_info['actual_catalog']['class']) 
    571581                                { 
     
    654664                                                        ); 
    655665                                                } 
    656  
     666                                                 
    657667                                                $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    658  
     668                                                 
    659669                                                $find_other[0] = array( 
    660670                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    662672                                                        'order'  => 'contact.names_ordered' 
    663673                                                ); 
    664  
     674                                                 
    665675                                                break; 
    666  
    667                                         //case 'bo_external_ldap_catalog': 
    668  
    669                                         //      break; 
    670  
     676                                         
    671677                                        case 'bo_global_ldap_catalog': 
     678                                         
    672679                                                $field_name = 'id_contact'; 
    673680 
     
    718725                                                                                        'value' => 'u' 
    719726                                                                                        ), 
    720                                                                                         /*1 => array( 
    721                                                                                         'field' => 'contact.account_type', 
    722                                                                                         'type'  => '=', 
    723                                                                                         'value' => 'g' 
    724                                                                                         ),*/ 
    725                                                                                         2 => array( 
     727                                                                                        1 => array( 
    726728                                                                                        'field' => 'contact.account_type', 
    727729                                                                                        'type'  => '=', 
     
    834836                                                                                'value' => 'g' 
    835837                                                                                ),*/ 
    836                                                                                 2 => array( 
     838                                                                                1 => array( 
    837839                                                                                'field' => 'contact.account_type', 
    838840                                                                                'type'  => '=', 
     
    842844                                                                ); 
    843845                                                        } 
    844  
    845846                                                } 
    846847 
     
    858859                                                        $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    859860                                                } 
    860  
     861                                                 
    861862                                                $find_other[0] = array( 
    862863                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    864865                                                        'order'  => 'contact.names_ordered' 
    865866                                                ); 
    866  
     867                                                 
    867868                                                break; 
    868  
     869                                         
    869870                                        case 'bo_company_manager': 
    870871                                                $field_name = 'id_company'; 
    871  
     872         
    872873                                                $find_field[0] = array('company.id_company','company.company_name'); 
    873  
     874                                                 
    874875                                                $find_other[0] = array( 
    875876                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    877878                                                        'order'  => 'company.company_name' 
    878879                                                ); 
    879  
     880         
    880881                                                $find_restric[0] = array( 
    881882                                                        0 => array( 
     
    885886                                                        ) 
    886887                                                ); 
    887  
     888                                                         
    888889                                                break; 
    889890 
    890891                                        case 'bo_group_manager': 
    891  
     892                                         
    892893                                                $field_name = 'id_group'; 
    893  
     894                                                 
    894895                                                if ($letter !== 'number')       { 
    895  
     896                                                         
    896897                                                        $find_restric[0] = array( 
    897898                                                                0 => array( 
     
    903904                                                } 
    904905                                                 else { 
    905  
     906                                                         
    906907                                                        $find_restric[0] = array( 
    907908                                                                0 => array( 
    908909                                                                                        'field' => 'group.title', 
    909910                                                                                        'type'  => 'LIKE', 
    910                                                                                         'value' => '0%' 
     911                                                                                        'value' => '0%'                                                                          
    911912                                                                ) 
    912                                                         ); 
     913                                                        );                                               
    913914                                                } 
    914  
     915                                                 
    915916                                                array_push($find_restric[0],  array( 
    916917                                                                                        'field' => 'group.owner', 
    917918                                                                                        'type'  => '=', 
    918                                                                                         'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
     919                                                                                        'value' => $GLOBALS['phpgw_info']['user']['account_id']                                                                          
    919920                                                                ) 
    920921                                                ); 
    921  
    922                                                 $find_field[0] = array('group.id_group','group.title','group.short_name'); 
     922                                                 
     923                                                $find_field[0] = array('group.id_group','group.title','group.short_name');                                               
    923924                                                $find_other[0] = array( 
    924925                                                        'order'  => 'group.title' 
    925926                                                ); 
    926  
     927                                                 
    927928                                                break; 
    928  
     929                                                 
    929930                                        case 'bo_catalog_group_catalog': 
    930931                                                $this->page_info['actual_entries'] = false; 
    931  
     932                                                 
    932933                                                $this->page_info['actual_letter'] = $letter; 
    933934                                                $this->page_info['actual_page'] = 0; 
    934  
     935                                                 
    935936                                                $this->save_session(); 
    936937                                                $final[0] = 0; 
    937                                                 $final[1] = $this -> typeContact; 
    938                                                 echo serialize($final); 
     938                                                $final[1] = $this->typeContact; 
     939                                                echo serialize($final);                                          
    939940                                                return; 
    940941 
    941942                                } 
    942  
     943                                 
    943944                                $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 
    944945                                $n_entries = count($result); 
    945  
     946                                 
    946947                                if ($n_entries) 
    947948                                { 
     
    957958                                { 
    958959                                        $this->page_info['actual_entries'] = false; 
    959  
     960                                         
    960961                                        $this->page_info['actual_letter'] = $letter; 
    961962                                        $this->page_info['actual_page'] = 0; 
    962  
    963                                         $this->save_session(); 
     963                                         
     964                                        $this->save_session();                           
    964965                                        $final[0] = 0; 
    965                                         $final[1] = $this -> typeContact; 
    966                                         echo serialize($final); 
     966                                        $final[1] = $this->typeContact; 
     967                                        echo serialize($final);                                                                                  
    967968                                        return; 
    968969                                } 
     
    973974                                        { 
    974975                                                $this->page_info['actual_entries'][] = $value[$field_name]; 
    975                                         } 
    976                                 } 
    977                         } 
    978 //************************************************************************* 
     976                                        }  
     977                                        //print_r($this->page_info['actual_entries']); 
     978                                } 
     979                        } 
    979980                        else if ($letter === 'search') 
    980981                        { 
    981982                                //if (!$ids and $this->page_info['actual_letter'] !== 'search') 
    982                                 if (!$ids && !$this->last_search_ids) 
     983                                if (!$ids) 
    983984                                { 
    984985                                        error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); 
    985986                                        $this->page_info['actual_entries'] = false; 
    986  
     987                                         
    987988                                        $this->page_info['actual_letter'] = $letter; 
    988989                                        $this->page_info['actual_page'] = 0; 
    989  
     990                                         
    990991                                        $this->save_session(); 
    991992                                        $final[0] = 0; 
    992993                                        $final[1] = $this -> typeContact; 
    993                                         echo serialize($final); 
     994                                        echo serialize($final);                                  
    994995                                        return; 
    995996                                } 
     
    10071008                                        return; 
    10081009                                } 
    1009                                 else if ($ids || $this->last_search_ids) 
    1010                                 { 
    1011  
    1012                                         if ($ids) 
    1013                                         { 
    1014  
    1015                                                 $this->last_search_ids = $ids; 
    1016  
    1017                                         } 
    1018                                         else { 
    1019  
    1020                                                 $ids = $this->last_search_ids; 
    1021  
    1022                                         } 
    1023  
     1010                                else if ($ids) 
     1011                                {                                
    10241012                                        $this->page_info['actual_letter']  = $letter; 
    10251013                                        $this->page_info['actual_entries'] = $ids; 
     
    10381026                                        $page = $this->page_info['n_pages']; 
    10391027                                } 
    1040  
     1028                                 
    10411029                                $final = array( 
    10421030                                        0 => (int)$this->page_info['n_pages'], 
     
    10501038                                                5 => 'cc_alias', 
    10511039                                                6 => 'cc_id', 
    1052                                                 7 => 'cc_forwarding_address', 
    1053                                                 8 => 'cc_empNumber', 
    1054                                                 9 => 'cc_department' 
     1040                                                7 => 'cc_forwarding_address' 
    10551041                                        ) 
    10561042                                ); 
    1057  
     1043                                 
    10581044                                //echo 'Page: '.$page.'<br>'; 
    10591045                                $id_i = (($page-1)*$this->page_info['n_cards']); 
    10601046                                $id_f = $id_i + $this->page_info['n_cards']; 
    10611047                                $n_entries = count($this->page_info['actual_entries']); 
    1062  
     1048                                 
    10631049                                //echo 'ID_I: '.$id_i.'<br>'; 
    10641050                                //echo 'ID_F: '.$id_f.'<br>'; 
    1065                                 ///---------------- Correᅵᅵo Temporï¿œria PHP5 -----------------------/// 
     1051                                ///---------------- Correção Temporária PHP5 -----------------------/// 
    10661052                                $ids = array(); 
    1067                                 $array_temp = array(); 
    1068  
     1053                                $array_temp = array();                   
     1054                                                                 
    10691055                                foreach($this->page_info['actual_entries'] as $key=>$tmp){ 
    1070                                         $array_temp[] = $tmp; 
    1071                                 } 
    1072  
     1056                                        $array_temp[] = $tmp;                            
     1057                                }        
     1058                                 
    10731059                                for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
    10741060                                { 
    10751061                                        $ids[] = $array_temp[$i]; 
    10761062                                } 
    1077  
     1063                                 
    10781064                                /// Original 
    10791065                                //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
     
    10821068                                //} 
    10831069                                /// 
    1084  
     1070                                 
    10851071                                $fields = $this->bo->catalog->get_fields(false); 
    10861072 
    1087                                 if( $this -> typeContact == 'groups') { 
     1073                                if( $this->typeContact == 'groups') { 
    10881074                                        $final = array( 
    10891075                                                0 => (int)$this->page_info['n_pages'], 
     
    10941080                                                        2 => 'cc_id', 
    10951081                                                        3 => 'cc_contacts' 
    1096                                                 ) 
    1097                                         ); 
    1098  
     1082                                                )                                                
     1083                                        );                                       
     1084                                         
    10991085                                        $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    1100  
     1086                                         
    11011087                                        $i = 0; 
    11021088                                        // contatos do grupo 
    1103                                         $boGroups = CreateObject('contactcenter.bo_group'); 
     1089                                        $boGroups = CreateObject('contactcenter.bo_group');                                      
    11041090                                        $contacts = array(); 
    11051091                                        foreach($groups as $group)              { 
    1106  
     1092                                                                                 
    11071093                                                $final[3][$i][0] = $group['title'] ? $group['title'] : 'none'; 
    1108                                                 $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; 
     1094                                                $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none';                                                 
    11091095                                                $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; 
    11101096                                                $contacts = $boGroups -> get_contacts_by_group($group['id_group']); 
    11111097                                                $final[3][$i][3] = $contacts; 
    1112                                                 $i++; 
     1098                                                $i++;                                                    
    11131099                                        } 
    1114  
     1100                                         
    11151101                                        $this->page_info['actual_letter'] = $letter; 
    1116                                         $this->page_info['actual_page'] = $page; 
    1117  
    1118  
     1102                                        $this->page_info['actual_page'] = $page;                                         
     1103                                         
     1104                                         
    11191105                                        $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
    1120  
     1106                                         
    11211107                                        $final[5] = '<span class="link"  onclick="'.$lnk_compose; 
    1122                                         $final[10] = 'groups'; 
    1123                                         $this->save_session(); 
     1108                                        $final[10] = 'groups';                                                                                                                                                                                                                           
     1109                                        $this->save_session();                                   
    11241110                                        echo serialize($final); 
    1125                                         return; 
    1126                                 } 
    1127  
     1111                                        return;                                  
     1112                                } 
     1113                                 
    11281114                                $fields['photo'] = true; 
    11291115                                $fields['names_ordered'] = true; 
     
    11321118                                $fields['companies'] = 'default'; 
    11331119                                $fields['connections'] = 'default'; 
    1134  
    1135                                 // ?aqui alterar a chamada desse mï¿œtodo para receber o base dn? 
    1136                                 $contacts =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    1137  
     1120                                // ?aqui alterar a chamada desse método para receber o base dn? 
     1121                                $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 
     1122                                 
     1123                                 
    11381124                                if (!is_array($contacts) or !count($contacts)) 
    11391125                                { 
     
    11431129                                        return; 
    11441130                                } 
    1145  
     1131                                 
    11461132                                $i = 0; 
    11471133                                foreach($contacts as $index => $contact) 
    11481134                                { 
    11491135                                        /* 
    1150                                          * TODO: Os timeouts de conexï¿œo foram retirados, ver se serï¿œ necessï¿œrio retornar essa funcionalidade, e, 
    1151                                          * neste caso, terminar a implementaᅵᅵo das mensagens de retorno. 
     1136                                         * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e, 
     1137                                         * neste caso, terminar a implementação das mensagens de retorno. 
    11521138                                         */ 
    11531139                                        if ($index !== 'error'){ 
     
    11561142                                                $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 
    11571143 
    1158                                                 //Para exibir a matricula do empregado 
    1159                                                 $final[3][$i][8] = $contact['companies']['company1']['empNumber']?$contact['companies']['company1']['empNumber']:'none'; 
    1160                                                 //Para exibir o setor/lotaᅵᅵo do empregado 
    1161                                                 $final[3][$i][9] = $contact['companies']['company1']['department']?$contact['companies']['company1']['department']:'none'; 
    1162  
    11631144                                                /* Select the correct Email and Telephone to be shown */ 
    11641145                                                $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
     1146                                                 
    11651147                                                if (!is_array($preferences)) 
    11661148                                                { 
     
    11881170                                                                                $default_phone_found = true; 
    11891171                                                                        } 
    1190                                                                          
    1191                                                                         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) { 
     1172                                                                        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){ 
    11921173                                                                                $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>"; 
    1193                                                                 } 
    1194                                                                          
     1174                                                                        } 
    11951175                                                                        $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
    11961176                                                                } 
    11971177                                                        } 
    11981178                                                } 
    1199  
     1179                                                 
    12001180                                                if (!$final[3][$i][3]) 
    12011181                                                { 
     
    12171197                                                $final[4][$i] = $contact['photo'] ? 1  : 0; 
    12181198                                                $i++; 
    1219  
    12201199                                        } 
    12211200                                        else 
     
    12301209                                $this->page_info['actual_letter'] = $letter; 
    12311210                                $this->page_info['actual_page'] = $page; 
    1232  
    1233                                 $this->save_session(); 
    1234  
     1211                                 
     1212                                $this->save_session();                           
    12351213                                echo serialize($final); 
    12361214                                return; 
    12371215                        } 
    1238  
     1216                         
    12391217                        $this->page_info['actual_letter'] = $letter; 
    12401218                        $this->page_info['actual_page'] = $page; 
    1241  
     1219                         
    12421220                        $this->save_session(); 
    1243  
     1221                         
    12441222                        $final[0] = 0; 
    12451223                        $final[1] = $this -> typeContact; 
    12461224                        echo serialize($final); 
    12471225                } 
    1248  
     1226                 
     1227                function get_visible_all_ldap() 
     1228                { 
     1229                        $bo = CreateObject('contactcenter.bo_ldap_manager'); 
     1230                        $ldap_query = $bo->srcs; 
     1231                        return $ldap_query[1]['visible'];        
     1232                } 
     1233 
     1234  
    12491235                /*! 
    1250  
     1236                 
    12511237                        @function get_group_data 
    12521238                        @abstract Returns all the information of a given Group 
    12531239                        @author Nilton Emilio Buhrer Neto 
    1254  
     1240                         
    12551241                        @param (integer) $id The id to get information 
    1256  
    1257                 */ 
     1242                 
     1243                */               
    12581244                function get_group_data($id) 
    12591245                { 
     
    12611247                        $fields = $this->bo->catalog->get_fields(true); 
    12621248                        $data = $this->bo->catalog->get_single_entry($id,$fields); 
    1263  
    1264                         if($id) { 
     1249                         
     1250                        if($id) {                        
    12651251                                // get All Contacts by group. 
    1266                                 $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id); 
    1267                         } 
    1268  
     1252                                $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id);                                                               
     1253                        } 
     1254                         
    12691255                        $boGroup = CreateObject('contactcenter.bo_group'); 
    1270  
    1271                         $data['contact_list'] = $boGroup->get_all_contacts(); 
    1272  
    1273                         $data['result'] = 'ok'; 
    1274                         echo serialize($data); 
    1275                 } 
    1276  
     1256                                                 
     1257                        $all_contacts = $boGroup->get_all_contacts(); 
     1258                         
     1259                        $contact_options = ""; 
     1260                        if(count($all_contacts)) {                                       
     1261                                foreach($all_contacts as $idx => $contact) {                             
     1262                                        $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; 
     1263                                } 
     1264                        } 
     1265                        $data['contact_list'] = $contact_options; 
     1266                        $data['result'] = 'ok';                                                          
     1267                        echo serialize($data);                   
     1268                }                
     1269                 
    12771270                /*! 
    1278  
     1271                 
    12791272                        @function get_full_data 
    12801273                        @abstract Returns all the information of a given Entry 
    12811274                        @author Raphael Derosso Pereira 
    1282  
     1275                         
    12831276                        @param (integer) $id The id to get information 
    1284  
     1277                 
    12851278                */ 
    12861279                function get_full_data($id) 
    12871280                { 
    12881281                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1289                         $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); 
     1282                        $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog');            
    12901283                        $fields = $this->bo->catalog->get_fields(true); 
    12911284                        $fields['photo'] = false; 
     
    13201313                        } 
    13211314                        $datecount = 0; 
    1322  
     1315                         
    13231316                        $data['result'] = 'ok'; 
    13241317                        $data['cc_full_add_contact_id'] = $id; 
     
    13621355 
    13631356                        /* Relations */ 
    1364  
     1357                         
    13651358                        echo serialize($data); 
    13661359                } 
     
    13991392                                return; 
    14001393                        } 
    1401  
     1394                         
    14021395                        echo 0; 
    14031396                } 
    1404  
     1397                 
    14051398                /*! 
    1406  
     1399                 
    14071400                        @function quick_add 
    14081401                        @abstract Adds a new Contact using the Quick Add interface 
    14091402                        @author Raphael Derosso Pereira 
    1410  
     1403                         
    14111404                        @param string $sdata Serialized data 
    14121405                */ 
    14131406                function quick_add($sdata) 
    14141407                { 
    1415  
     1408                         
    14161409                        $sdata = str_replace('\\"', '"', $sdata); 
    14171410                        $new_array = unserialize($sdata); 
    14181411                        $tdata = array(); 
    1419  
     1412                         
    14201413                        foreach($new_array as $tmp) 
    14211414                                $tdata[] = $tmp; 
    1422  
     1415                         
    14231416                        if (!$tdata) 
    14241417                        { 
     
    14271420                                        'status' => 'abort' 
    14281421                                )); 
    1429  
     1422                                 
    14301423                                return; 
    14311424                        } 
    1432  
    1433                         // verifica se email jï¿œ existe! 
     1425                         
     1426                        // verifica se email já existe! 
    14341427                        $boGroup = CreateObject('contactcenter.bo_group'); 
    14351428                        $contact = $boGroup->verify_contact($tdata[4]); 
    1436  
     1429                                                                                                 
    14371430                        if($contact) 
    1438                         { 
     1431                        {                                                        
    14391432                                $str_contact = "\r\n - ".implode("\r\n - ",$contact); 
    1440  
     1433                                 
    14411434                                echo serialize(array( 
    14421435                                        'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), 
    14431436                                        'status' => 'alreadyExists' 
    14441437                                )); 
    1445  
    1446                                 return; 
     1438                                 
     1439                                return;                  
    14471440                        } 
    14481441 
     
    14601453 
    14611454                        if ($boPeople ->quick_add($data)) 
    1462                         { 
     1455                        {                                
    14631456                                $this->page_info['changed'] = true; 
    1464  
     1457                                 
    14651458                                echo serialize(array( 
    14661459                                        'msg'    => lang('Entry added with success!'), 
     
    14761469                        } 
    14771470 
    1478                         $this->save_session(); 
    1479  
     1471                        $this->save_session();   
     1472                         
    14801473                } 
    14811474 
    14821475                /*! 
    1483  
     1476                 
    14841477                        @function add_group 
    14851478                        @abstract Adds a new Group using the Add Group interface 
    14861479                        @author Nilton Emilio Buhrer Neto 
    1487  
     1480                         
    14881481                        @param string $sdata Serialized data 
    14891482                */ 
     
    14931486                        $tdata = unserialize($sdata); 
    14941487                        $new_tdata = array(); 
    1495  
     1488                         
    14961489                        if (!$tdata) 
    14971490                        { 
     
    15001493                                        'status' => 'abort' 
    15011494                                )); 
    1502  
     1495                                 
    15031496                                return; 
    15041497                        } 
    1505  
     1498                         
    15061499                        foreach($tdata as $tmp) 
    15071500                                $new_tdata[] = $tmp; 
    1508  
    1509                         $data['title'] = $new_tdata[0]; 
     1501                         
     1502                        $data['title'] = $new_tdata[0];                  
    15101503                        $data['contact_in_list'] = $new_tdata[1]; 
    15111504                        $data['id_group'] = $new_tdata[2]; 
    1512  
     1505                                                 
    15131506                        $boGroup = CreateObject('contactcenter.bo_group_manager'); 
    15141507                        $id = $boGroup -> add_group($data); 
    1515  
     1508                         
    15161509                        if ($id) 
    15171510                        { 
    15181511                                $this->page_info['changed'] = true; 
    1519  
     1512                                 
    15201513                                echo serialize(array( 
    15211514                                        'msg'    => lang('Entry added with success!'), 
     
    15351528 
    15361529                /*! 
    1537  
     1530                 
    15381531                        @function remove_group 
    15391532                        @abstract Removes a group if the user has the right to do it 
    1540                         @author Nilton Emilio Buhrer Neto 
     1533                        @author Nilton Emilio Buhrer Neto                        
    15411534                        @param (integer) $id The id to be removed 
    1542  
     1535                                 
    15431536                */ 
    15441537                function remove_group($id) 
    1545                 { 
    1546                                 $soGroup = CreateObject('contactcenter.so_group'); 
     1538                {                                
     1539                                $soGroup = CreateObject('contactcenter.so_group');                               
    15471540                                $data = array ('id_group' => $id); 
    15481541                                if($soGroup -> delete($data)) { 
     
    15501543                                                'msg'    => lang('Removed Entry ID '.$id.'!'), 
    15511544                                                'status' => 'ok' 
    1552                                         )); 
     1545                                        ));                                                      
    15531546                                } 
    15541547                                else { 
     
    15591552                                } 
    15601553 
    1561                         $this->save_session(); 
     1554                        $this->save_session();                           
    15621555                } 
    15631556 
    15641557 
    15651558                function remove_all_entries (){ 
    1566  
     1559                 
    15671560                        $error = false; 
    15681561                        $this->all_entries = $this->bo->catalog->get_all_entries_ids(); 
     
    15721565                                if(!$result) { 
    15731566                                        $error = true; 
    1574                                         break; 
     1567                                        break;           
    15751568                                } 
    15761569                        } 
     
    15811574                                        'status' => 'ok' 
    15821575                                )); 
    1583                         } 
     1576                        }  
    15841577                        else { 
    15851578                                echo serialize(array( 
     
    15931586 
    15941587                /*! 
    1595  
     1588                 
    15961589                        @function remove_entry 
    15971590                        @abstract Removes an entry if the user has the right to do it 
    15981591                        @author Raphael Derosso Pereira 
    1599  
     1592                         
    16001593                        @param (integer) $id The id to be removed 
    1601  
     1594                                 
    16021595                */ 
    16031596                function remove_entry ($id) 
     
    16081601                                return; 
    16091602                        } 
    1610  
     1603                         
    16111604                        $this->page_info['changed'] = true; 
    16121605                        $result = $this->bo->catalog->remove_single_entry($id); 
    1613  
     1606                         
    16141607                        if ($result) 
    16151608                        { 
     
    16181611                                        unset($this->page_info['actual_entries'][$pos]); 
    16191612                                } 
    1620  
     1613                                 
    16211614                                $temp = false; 
    16221615                                reset($this->page_info['actual_entries']); 
     
    16251618                                        $temp[] = $t; 
    16261619                                } 
    1627  
     1620                                 
    16281621                                $this->page_info['actual_entries'] = $temp; 
    16291622 
     
    16401633                                )); 
    16411634                        } 
    1642  
     1635                         
    16431636                        $this->save_session(); 
    16441637                } 
    16451638 
    1646  
     1639                 
    16471640                /*! 
    1648  
     1641                 
    16491642                        @function post_full_add 
    16501643                        @abstract Saves all the information altered/entered in the Full Add 
     
    16551648                function post_full_add() 
    16561649                { 
    1657                         $data = unserialize(str_replace('\\"', '"', $_POST['data'])); 
     1650                        $data =  $_POST['data']; 
     1651                        // Exceptions!!! utf8 special chars.  
     1652                        $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 
     1653                        $data = unserialize(str_replace('\\"', '"', $data)); 
    16581654                        $this -> bo -> catalog = CreateObject('contactcenter.bo_people_catalog'); 
    1659  
    1660 //                      echo str_replace('\\"', '"', $_POST['data']); 
    16611655 
    16621656                        if (!is_array($data)) 
     
    16821676                                        'status' => 'fatal' 
    16831677                                )); 
    1684  
     1678                                 
    16851679                                return; 
    16861680                        } 
     
    16961690                                $id_photo = '_new_'; 
    16971691                        } 
    1698  
    1699                         /* 
    1700                          * Process Photo, if available 
     1692                         
     1693                        /*  
     1694                         * Process Photo, if available  
    17011695                         */ 
    17021696                        $sleep_count = 0; 
     
    17151709                        } 
    17161710                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 
    1717  
     1711                         
    17181712                        if (isset($this->page_info['photos'][$id_photo])) 
    17191713                        { 
     
    17321726                                $this->save_session(); 
    17331727                        } 
    1734  
     1728                         
    17351729                        /* 
    17361730                         * Arrange Date so it gets inserted correctly 
    17371731                         */ 
    1738  
     1732                          
    17391733                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1740  
     1734                 
    17411735                        $j = 0; 
    17421736                        for ($i = 0; $i < 5; $i+=2) 
     
    17711765                                        continue; 
    17721766                                } 
    1773  
     1767                                 
    17741768                                switch($field) 
    17751769                                { 
     
    17831777                                                /* Do Nothing. This is just to make sure no invalid field is passed */ 
    17841778                                                break; 
    1785  
     1779                                         
    17861780                                        case 'id_status': 
    17871781                                        case 'id_prefix': 
     
    17921786                                                } 
    17931787                                                break; 
    1794  
     1788                                         
    17951789                                        case 'birthdate_0': 
    17961790                                        case 'birthdate_1': 
    17971791                                        case 'birthdate_2': 
    1798  
     1792                                         
    17991793                                                switch($date[$datecount]['digit']) 
    18001794                                                { 
     
    18181812                                                        break; 
    18191813                                                } 
    1820  
     1814                                                 
    18211815                                                if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 
    18221816                                                { 
     
    18271821                                                        return; 
    18281822                                                } 
    1829  
     1823                                                 
    18301824                                                $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 
    18311825                                                break; 
     
    18501844                                                        { 
    18511845                                                                $index = 'address'.$type; 
    1852  
     1846                                                                 
    18531847                                                                $id_state = $this->bo->catalog->add_state($state_info); 
    18541848                                                                $data['addresses'][$index]['id_state'] = $id_state; 
     
    18681862                                                        { 
    18691863                                                                $index = 'address'.$type; 
    1870  
     1864                                                                 
    18711865                                                                $id_city = $this->bo->catalog->add_city($city_info); 
    18721866                                                                $data['addresses'][$index]['id_city'] = $id_city; 
     
    19091903                                ); 
    19101904                        } 
    1911  
     1905                         
    19121906                        eval($code); 
    19131907 
     
    19251919 
    19261920                /*! 
    1927  
     1921                 
    19281922                        @function post_photo 
    19291923                        @abstract Wrapper to post a photo without reload a page. 
     
    19351929                        //print_r($_FILES); 
    19361930                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); 
    1937  
     1931                         
    19381932                        if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) 
    19391933                        { 
    19401934                                $this->page_info['photos'][$id]['status'] = 'no_upload'; 
    19411935                                $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); 
    1942  
     1936                                 
    19431937                                $this->save_session(); 
    19441938                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    19501944                                $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; 
    19511945                                $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.'); 
    1952  
     1946                                 
    19531947                                $this->save_session(); 
    19541948                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    19761970                                return; 
    19771971                        } 
    1978  
     1972                         
    19791973                        switch($_FILES['cc_pd_photo']['type']) 
    19801974                        { 
     
    20062000 
    20072001                                default: 
    2008  
     2002                                         
    20092003                                        $this->page_info['photos'][$id]['status'] = 'invalid_image'; 
    20102004                                        $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); 
     
    20192013                                        $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    20202014                                        $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    2021  
     2015                                         
    20222016                                        $this->save_session(); 
    20232017                                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    20242018                                        return; 
    20252019                        } 
    2026  
     2020                         
    20272021                        $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); 
    20282022                        $dst_img = imagecreatetruecolor(60, 80); 
    2029  
     2023                         
    20302024                        if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) 
    20312025                        { 
    20322026                                $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    20332027                                $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    2034  
     2028                                 
    20352029                                $this->save_session(); 
    20362030                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    20372031                                return; 
    20382032                        } 
    2039  
     2033                         
    20402034                        ob_start(); 
    20412035                        imagepng($dst_img); 
     
    20472041 
    20482042                        $this->save_session(); 
    2049  
     2043                 
    20502044                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    20512045 
     
    20682062                        $fields = $this->bo->catalog->get_fields(false); 
    20692063                        $fields['photo'] = true; 
    2070  
     2064                         
    20712065                        $contact = $this->bo->catalog->get_single_entry($id, $fields); 
    20722066 
     
    20772071                                return; 
    20782072                        } 
    2079  
     2073                         
    20802074                        header('Content-type: image/jpeg'); 
    20812075                        $photo = imagecreatefromstring ($contact['photo']); 
     
    20892083                        return; 
    20902084                } 
    2091  
     2085                 
    20922086                /*! 
    2093  
     2087                 
    20942088                        @function get_states 
    20952089                        @abstract Echos a serialized array containing all the states for the given country 
     
    21132107                                return; 
    21142108                        } 
    2115  
     2109                         
    21162110                        $result = array( 
    21172111                                'msg'    => lang('States Successfully retrieved!'), 
    21182112                                'status' => 'ok' 
    21192113                        ); 
    2120  
     2114                         
    21212115                        foreach ($states as $state_info) 
    21222116                        { 
     
    21572151                                return; 
    21582152                        } 
    2159  
     2153                         
    21602154                        $result = array( 
    21612155                                'msg'    => lang('Cities Successfully retrieved!'), 
    21622156                                'status' => 'ok' 
    21632157                        ); 
    2164  
     2158                         
    21652159                        foreach ($cities as $city_info) 
    21662160                        { 
    21672161                                $result['data'][$city_info['id_city']] = $city_info['name']; 
    21682162                        } 
    2169  
     2163                         
    21702164                        echo serialize($result); 
    21712165                } 
     
    21732167 
    21742168                /*! 
    2175  
     2169                 
    21762170                        @function search 
    21772171                        @abstract Echos a serialized array containing the IDs 
    21782172                                of the entries that matches the search argument 
    21792173                        @author Raphael Derosso Pereira 
    2180                         @author Mï¿œrio Cï¿œsar Kolling (external catalogs) 
     2174                        @author Mário César Kolling (external catalogs) 
    21812175 
    21822176                        @param string $str_data A serialized array with two informations: 
     
    21872181 
    21882182                */ 
     2183                // SERPRO 
    21892184                function search($str_data) 
    21902185                { 
     
    21922187                        // It's an external catalog? 
    21932188                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
    2194  
    2195                         if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
    2196                         { 
    2197                                 //echo serialize(array( 
    2198                                 //      'msg'    => lang('Invalid parameters'), 
    2199                                 //      'status' => 'abort' 
    2200                                 //)); 
    2201  
    2202                                 return array('error' => lang('Invalid parameters')); 
    2203                         } 
    2204  
     2189                         
     2190            if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
     2191            { 
     2192                echo serialize(array(                                                                                                    
     2193                   'msg'    => lang('Invalid parameters'),                                                                              
     2194                    'status' => 'abort' 
     2195                )); 
     2196             
     2197                return array('error' => lang('Invalid parameters'));                                                                                                                  
     2198            }    
     2199 
     2200             
    22052201                        /* 
    22062202                         * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly 
     
    22132209                                $data['search_for'] = utf8_encode($data['search_for']); 
    22142210                        } 
    2215  
    2216                         $rules  = array(); 
    2217  
    2218                         if ($data['search_for'] === '*') 
    2219                         { 
    2220                                 $rules = array( 
    2221                                         0 => array( 
    2222                                                 'field' => $data['fields']['search'], 
    2223                                                 'type'  => 'LIKE', 
    2224                                                 'value' => '%' 
    2225                                         ) 
    2226                                 ); 
    2227                         } 
    2228                         else 
    2229                         { 
    2230                                 $names = explode(' ', $data['search_for']); 
    2231  
    2232                                 if (!is_array($names)) 
    2233                                 { 
    2234                                         //echo serialize(array( 
    2235                                         //      'msg'    => lang('Invalid Search Parameter'), 
    2236                                         //      'status' => 'abort' 
    2237                                         //)); 
    2238  
    2239                                         return array('error' => lang('Invalid Search Parameter')); 
    2240                                 } 
     2211             
     2212            $rules  = array();                                                                                                           
     2213             
     2214             
     2215            if ($data['search_for'] === '*')                                                                                             
     2216            { 
     2217                $rules = array(                                                                                                          
     2218                    0 => array(                                                                                                          
     2219                        'field' => $data['fields']['search'],                                                                            
     2220                        'type'  => 'LIKE', 
     2221                        'value' => '%' 
     2222                    )    
     2223                );   
     2224            }    
     2225            else                                                                                                                         
     2226            { 
     2227                $names = explode(' ', $data['search_for']);                                                                              
     2228                 
     2229                if (!is_array($names))                                                                                                   
     2230                { 
     2231                    echo serialize(array(                                                                                                
     2232                        'msg'    => lang('Invalid Search Parameter'),                                                                    
     2233                        'status' => 'abort' 
     2234                    )); 
     2235  
     2236                } 
    22412237 
    22422238                                if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     
    22712267                                        ); 
    22722268                                } 
    2273  
    2274                                 foreach ($names as $name) 
    2275                                 { 
    2276                                         if ($name != '') 
    2277                                         { 
    2278                                                 array_push($rules, array( 
    2279                                                         'field' => $data['fields']['search'], 
    2280                                                         'type'  => 'iLIKE', 
    2281                                                         'value' => '%'.$name.'%' 
    2282                                                 )); 
    2283                                         } 
    2284                                 } 
    2285                         } 
     2269                 
     2270                foreach ($names as $name) 
     2271                { 
     2272                    if ($name != '') 
     2273                    { 
     2274                        array_push($rules, array( 
     2275                            'field' => $data['fields']['search'], 
     2276                            'type'  => 'iLIKE', 
     2277                            'value' => '%'.$name.'%' 
     2278                        )); 
     2279                    } 
     2280                } 
     2281            } 
    22862282 
    22872283                        if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || 
     
    23052301                        } 
    23062302 
    2307                         if (!is_array($ids) || !count($ids)) 
    2308                         { 
    2309                                 //echo serialize(array( 
    2310                                 //      'msg'    => lang('No Entries Found!'), 
    2311                                 //      'status' => 'empty' 
    2312                                 //)); 
    2313  
     2303            if (!is_array($ids) || !count($ids)) 
     2304            { 
    23142305                                $this->last_search_ids = null; 
    23152306                                $this->save_session(); 
    23162307                                return null; 
    2317                         } 
    2318  
    2319                         $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
    2320  
    2321                         $ids_f = array(); 
    2322                         foreach ($ids as $e_info) 
    2323                         { 
    2324                                 //$ids_f[] = "base64::" . base64_encode($e_info[$id_field]); 
    2325                                 $ids_f[] = $e_info[$id_field]; 
    2326                         } 
    2327  
    2328                         //error_log("ids_f serializados: " . serialize($ids_f) . "\n", 3, '/var/www/teste.log'); 
    2329  
    2330                         //return serialize($ids_f); 
     2308            } 
     2309 
     2310            $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
     2311                         
     2312            $ids_f = array(); 
     2313 
     2314            foreach ($ids as $e_info) 
     2315            { 
     2316                $ids_f[] = $e_info[$id_field]; 
     2317            } 
     2318 
    23312319                        return $ids_f; 
    2332  
    2333                         //echo serialize(array( 
    2334                         //      'data'   => $ids_f, 
    2335                         //      'msg'    => lang('Found %1 Entries', count($ids)), 
    2336                         //      'status' => 'ok' 
    2337                         //)); 
    23382320                } 
    2339  
     2321                 
     2322                // CELEPAR 
     2323                /* 
     2324        function search($str_data) 
     2325        { 
     2326            $data = unserialize($str_data); 
     2327 
     2328            if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
     2329            { 
     2330                echo serialize(array( 
     2331                    'msg'    => lang('Invalid parameters'), 
     2332                    'status' => 'abort' 
     2333                )); 
     2334 
     2335                return; 
     2336            } 
     2337 
     2338            $rules  = array(); 
     2339 
     2340            if ($data['search_for'] === '*') 
     2341            { 
     2342                $rules = array( 
     2343                    0 => array( 
     2344                        'field' => $data['fields']['search'], 
     2345                        'type'  => 'LIKE', 
     2346                        'value' => '%' 
     2347                    ) 
     2348                ); 
     2349            } 
     2350            else 
     2351            { 
     2352                $names = explode(' ', $data['search_for']); 
     2353 
     2354                if (!is_array($names)) 
     2355                { 
     2356                    echo serialize(array( 
     2357                        'msg'    => lang('Invalid Search Parameter'), 
     2358                        'status' => 'abort' 
     2359                    )); 
     2360                     
     2361                    return; 
     2362                } 
     2363                 
     2364                foreach ($names as $name) 
     2365                { 
     2366                    if ($name != '') 
     2367                    { 
     2368                        array_push($rules, array( 
     2369                            'field' => $data['fields']['search'], 
     2370                            'type'  => 'iLIKE', 
     2371                            'value' => '%'.$name.'%' 
     2372                        )); 
     2373                    } 
     2374                } 
     2375            } 
     2376 
     2377             
     2378             
     2379            //$catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
     2380             
     2381            //if ($catalog['class'] === 'bo_people_catalog') 
     2382            //{ 
     2383            //    array_push($rules, array( 
     2384            //        'field' => 'contact.id_owner', 
     2385            //        'type'  => '=', 
     2386            //        'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
     2387            //    )); 
     2388            //} 
     2389             
     2390             
     2391            $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
     2392 
     2393            if (!is_array($ids) || !count($ids)) 
     2394            { 
     2395                echo serialize(array( 
     2396                    'msg'    => lang('No Entries Found!'), 
     2397                    'status' => 'empty' 
     2398                )); 
     2399 
     2400                return; 
     2401            } 
     2402            $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
     2403 
     2404            $ids_f = array(); 
     2405            foreach ($ids as $e_info) 
     2406            { 
     2407                $ids_f[] = $e_info[$id_field]; 
     2408            } 
     2409 
     2410            echo serialize(array( 
     2411                'data'   => $ids_f, 
     2412                'msg'    => lang('Found %1 Entries', count($ids)), 
     2413                'status' => 'ok' 
     2414            )); 
     2415                         
     2416                        return; 
     2417        }*/ 
    23402418                /*! 
    23412419 
     
    23452423                        @author Raphael Derosso Pereira 
    23462424 
    2347                         @param array str_data A serialized array containing the ID's of the entries 
     2425                        @param array str_data A serialized array containing the ID's of the entries  
    23482426                                to be taken, the fields to be taken and the rules to be used on the 
    23492427                                retrieval: 
     
    23582436                { 
    23592437                        $data = unserialize($str_data); 
    2360  
     2438                         
    23612439                        if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) 
    23622440                        { 
     
    23682446 
    23692447                        $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); 
    2370  
     2448                         
    23712449                        if (!is_array($entries) or !count($entries)) 
    23722450                        { 
     
    23872465 
    23882466                        @function get_all_entries 
    2389                         @abstract Returns the specified fields for all catalog's entries 
     2467                        @abstract Returns the specified fields for all catalog's entries  
    23902468                                in the default CC UI format 
    23912469                        @author Raphael Derosso Pereira 
    23922470 
    2393                         @params array str_data A serialized array containing the fields to 
     2471                        @params array str_data A serialized array containing the fields to  
    23942472                                be grabbed, the maximum number of entries to be returned and a 
    23952473                                boolean specifying if the calls refers to a new grab or to an 
     
    24002478                { 
    24012479                        $data = unserialize($str_data); 
    2402  
    2403                         if (!is_array($data) or 
    2404                             !count($data) or 
    2405                                 !count($data['fields']) or 
     2480                         
     2481                        if (!is_array($data) or  
     2482                            !count($data) or  
     2483                                !count($data['fields']) or  
    24062484                                !$data['maxlength'] or 
    24072485                                (!$data['new'] and !$data['offset'])) 
     
    24292507                                $data['offset'] = 0; 
    24302508                        } 
    2431  
     2509                         
    24322510                        if ($data['maxlength'] != -1) 
    24332511                        { 
     
    24402518 
    24412519                        $prefs = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    2442  
     2520                         
    24432521                        $jsCode = array(); 
    24442522                        $count = 0; 
     
    24502528                                } 
    24512529 
    2452                                 if($this-> typeContact == 'groups') { 
    2453  
     2530                                if($this-> typeContact == 'groups') {                            
     2531                                         
    24542532                                        foreach ($each as $field => $value)     { 
    2455  
     2533                                                                                 
    24562534                                                if ($field === 'title') { 
    24572535                                                        $optionName = '\\"'.$value.'\\"'; 
    2458  
     2536                                                          
    24592537                                                } 
    24602538                                                else if ($field === 'short_name')       { 
    2461  
     2539                                                         
    24622540                                                        $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; 
    2463                                                         $count++; 
    2464                                                 } 
     2541                                                        $count++;                                                                                                                                                                        
     2542                                                }                                        
    24652543                                        } 
    24662544                                } 
    2467  
    2468                                 else  { 
     2545                                 
     2546                                else  {  
    24692547                                        foreach ($each as $field => $value)     { 
    24702548                                                if ($field === 'names_ordered') { 
     
    24742552                                                } 
    24752553                                                else if ($field === 'connections')      { 
    2476  
     2554                                                         
    24772555                                                        foreach ($value as $connection)         { 
    24782556                                                                if ($connection['id_type'] == $prefs['personCardEmail'])        { 
     
    24872565 
    24882566                        $jsCodeFinal = implode("\n", $jsCode); 
    2489  
     2567                         
    24902568                        $nEntries = count($result); 
    2491  
     2569                         
    24922570                        if (!$nEntries) 
    24932571                        { 
     
    25072585                        ); 
    25082586                } 
    2509  
     2587                 
    25102588                /*********************************************************************\ 
    25112589                 *                      Auxiliar Methods                             * 
     
    25132591 
    25142592                /*! 
    2515  
     2593                 
    25162594                        @function save_session 
    25172595                        @abstract Saves the data on the session 
    25182596                        @author Raphael Derosso Pereira 
    2519  
     2597                 
    25202598                */ 
    25212599                function save_session() 
     
    25232601                        $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter',$this->page_info); 
    25242602                        $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter',$this->all_entries); 
    2525                         $GLOBALS['phpgw']->session->appsession('ui_data.last_search_ids','contactcenter',$this->last_search_ids); 
    25262603                } 
    25272604 
    25282605                /*! 
    2529  
     2606                 
    25302607                        @function convert_tree 
    25312608                        @abstract Converts the tree array in the BO format to a JS tree array compatible 
    25322609                                with the one available in eGW 
    25332610                        @author Raphael Derosso Pereira 
    2534  
     2611                 
    25352612                        @param (array)  $tree    The tree in the BO format 
    25362613                        @param (string) $name    The tree name 
     
    25662643                                        'caption' => $value['name'] 
    25672644                                ); 
    2568  
     2645                                 
    25692646                                switch($value['type']) 
    25702647                                { 
     
    25892666                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
    25902667                        } 
    2591  
    2592                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
     2668                         
     2669                        $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
    25932670                        $dn=$this->bo->catalog->src_info['dn']; 
    25942671                        $justThese = array("givenname","givenname","sn","telephonenumber","mail"); 
    2595                         $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 
    2596                         $info = ldap_get_entries($ds, $sr); 
     2672                        $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
     2673                        $info = ldap_get_entries($ds, $sr);                                                      
    25972674                        for($z = 0; $z < 5; $z++) { 
    2598                                 $participant = $info[0][$justThese[$z]]; 
     2675                                $participant = $info[0][$justThese[$z]];                                                                                                         
    25992676                                array_push($array_participants, $participant); 
    26002677                        } 
     
    26022679                        ldap_close($ds); 
    26032680                        echo serialize($array_participants); 
    2604                 } 
    2605  
    2606                 function get_catalog_participants_list($id) 
     2681                }        
     2682                 
     2683                function get_catalog_participants_list($id)  
    26072684                { 
    2608  
    2609                         $fields = $this->bo->catalog->get_fields(false); 
     2685                         
     2686                        $fields = $this->bo->catalog->get_fields(false);                         
    26102687                        $fields['names_ordered'] = true; 
    2611                         $fields['mail_forwarding_address'] = true; 
    2612                         $contact = $this->bo->catalog->get_single_entry($id,$fields); 
    2613  
     2688                        $fields['mail_forwarding_address'] = true;                       
     2689                        $contact = $this->bo->catalog->get_single_entry($id,$fields);                    
     2690                         
    26142691                        $array_participants = array(); 
    26152692                        $array_emails = array(); 
    2616  
     2693                         
    26172694                        $filter = null; 
    2618                         for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 
     2695                        for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) {                   
    26192696                                        if(strstr($contact['mail_forwarding_address'][$z],'@')) { 
    26202697                                                $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; 
    26212698                                                $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; 
    2622                                         } 
    2623                                         else 
     2699                                        }                                                                                                                                
     2700                                        else  
    26242701                                                $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; 
    2625                         } 
    2626  
     2702                        }                                        
     2703                         
    26272704                        if($filter) { 
    2628                                 $filter = "(|".$filter.")"; 
     2705                                $filter = "(|".$filter.")";                                                      
    26292706                                if(!$this->bo->catalog->src_info) { 
    26302707                                        $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    26312708                                        $this->bo->catalog->src_info = $ldap->srcs[1]; 
    26322709                                } 
    2633                                 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
     2710                                $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
    26342711                                $dn=$this->bo->catalog->src_info['dn']; 
    26352712                                $justThese = array("cn","mail"); 
    2636                                 $sr = ldap_search($ds,$dn, $filter,$justThese); 
    2637                                 $info = ldap_get_entries($ds, $sr); 
     2713                                $sr = ldap_search($ds,$dn, $filter,$justThese);                                                          
     2714                                $info = ldap_get_entries($ds, $sr);                                                      
    26382715                                for($z = 0; $z < $info['count']; $z++) { 
    26392716                                        $participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>'; 
    2640                                         $array_emails[$info[$z]['mail'][0]] = null; 
    2641                                         array_push($array_participants, $participant); 
    2642                                 } 
    2643  
     2717                                        $array_emails[$info[$z]['mail'][0]] = null;                                                              
     2718                                        array_push($array_participants, $participant);                                   
     2719                                } 
     2720                                 
    26442721                                foreach($array_emails as $index => $email) 
    2645                                         if($email) 
    2646                                                 array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>"); 
    2647  
     2722                                        if($email)  
     2723                                                array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>");                           
     2724                                                                                                 
    26482725                                ldap_close($ds); 
    26492726                        } 
    26502727                        sort($array_participants); 
    2651                         $innerHTML = ''; 
     2728                        $innerHTML = '';                         
    26522729                        foreach($array_participants as $index => $participant){ 
    26532730                                $innerHTML .= $participant; 
    26542731                        } 
    2655                         $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 
     2732                        $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);                   
    26562733                        echo serialize($return); 
    2657                 } 
    2658  
     2734                }        
     2735                 
    26592736                function export_contacts($typeExport){ 
    26602737 
     
    26672744 
    26682745 
    2669                         // Essa iteraᅵᅵo transforma uma esturuta com contatos redundantes e separados por email ou tel. 
     2746                        // Essa iteração transforma uma esturuta com contatos redundantes e separados por email ou tel. 
    26702747                        // em outra com apenas 1 elemento pra cada contato 
    26712748                        $i=0; 
     
    26782755                                        $all_contacts[$i]['phone']=$object['connection_value']; 
    26792756                        } 
    2680  
     2757                         
    26812758                        switch($typeExport) { 
    26822759 
    26832760                                case 'outlook_en': 
    26842761                                        $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". 
    2685                                                         "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 
     2762                                                        "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";                                                         
    26862763                                        foreach($all_contacts as $index => $object){ 
    26872764                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 
    26882765                                        } 
    26892766                                break; 
    2690  
     2767                                 
    26912768                                case 'outlook_pt-BR': 
    2692                                         $streamBuffer = "Nome;End. de email;Endereï¿œo residencial;". 
    2693                                         "Cidade do endereï¿œo residencial;CEP do endereï¿œo residencial;". 
    2694                                         "Estado;Paï¿œs/regiï¿œo do endereï¿œo residencial;Telefone residencial;". 
    2695                                         "Rua do endereï¿œo comercial;Cidade do endereï¿œo comercial;". 
    2696                                         "CEP do endereï¿œo comercial;Estado do endereï¿œo comercial;". 
    2697                                         "Paï¿œs/regiï¿œo do endereï¿œo comercial;Telefone comercial;Empresa;Cargo\r\n"; 
     2769                                        $streamBuffer = "Nome;End. de email;Endereço residencial;". 
     2770                                        "Cidade do endereço residencial;CEP do endereço residencial;". 
     2771                                        "Estado;País/região do endereço residencial;Telefone residencial;". 
     2772                                        "Rua do endereço comercial;Cidade do endereço comercial;". 
     2773                                        "CEP do endereço comercial;Estado do endereço comercial;". 
     2774                                        "País/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";                                                        
    26982775                                        foreach($all_contacts as $index => $object){ 
    26992776                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
    27002777                                        } 
    27012778                                break; 
    2702  
     2779                                 
    27032780                                case 'outlook2000_pt-BR': 
    27042781                                        $streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". 
    2705                                         "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereï¿œo comercial\",\"Rua do endereï¿œo comercial 2\",". 
    2706                                         "\"Rua do endereï¿œo comercial 3\",\"Cidade do endereï¿œo comercial\",\"Estado do endereï¿œo comercial\",". 
    2707                                         "\"CEP do endereï¿œo comercial\",\"Paï¿œs do endereï¿œo comercial\",\"Endereï¿œo residencial\",\"Rua residencial 2\",". 
    2708                                         "\"Rua residencial 3\",\"Cidade do endereï¿œo residencial\",\"Estado\",\"CEP do endereï¿œo residencial\",\"Paï¿œs do endereï¿œo residencial\",". 
    2709                                         "\"Outro endereï¿œo\",\"Outro endereï¿œo 2\",\"Outro endereï¿œo 3\",\"Cidade\",\"Estado\",\"CEP\",\"Paï¿œs\",". 
     2782                                        "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereço comercial\",\"Rua do endereço comercial 2\",". 
     2783                                        "\"Rua do endereço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",". 
     2784                                        "\"CEP do endereço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",". 
     2785                                        "\"Rua residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",". 
     2786                                        "\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",". 
    27102787                                        "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 
    27112788                                        "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 
    27122789                                        "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". 
    2713                                         "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversï¿œrio\",\"Anotaᅵᅵes\",\"Caixa postal\",\"Categorias\",". 
    2714                                         "\"Cï¿œdigo da empresa\",\"Cï¿œdigo do governo\",\"Cï¿œnjuge\",\"Conta\",\"Endereï¿œo de correio eletrï¿œnico\",". 
    2715                                         "\"Nome de exibiᅵᅵo do correio eletr.\",\"Endereï¿œo de correio eletrï¿œnico 2\",". 
    2716                                         "\"Nome de exibiᅵᅵo do correio eletr.2\",\"Endereï¿œo de correio eletrï¿œnico 3\",". 
    2717                                         "\"Nome de exibiᅵᅵo do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
    2718                                         "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicaᅵᅵo\",\"Informaᅵᅵes para cobranï¿œa\",\"Iniciais\",\"Local\",". 
    2719                                         "\"Nome do assistente\",\"Nome do gerenciador\",\"Pï¿œgina da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
    2720                                         "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissï¿œo\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretï¿œrio\",". 
     2790                                        "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversário\",\"Anotações\",\"Caixa postal\",\"Categorias\",". 
     2791                                        "\"Código da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",". 
     2792                                        "\"Nome de exibição do correio eletr.\",\"Endereço de correio eletrônico 2\",". 
     2793                                        "\"Nome de exibição do correio eletr.2\",\"Endereço de correio eletrônico 3\",". 
     2794                                        "\"Nome de exibição do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
     2795                                        "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",". 
     2796                                        "\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
     2797                                        "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",". 
    27212798                                        "\"Sexo\"\r\n"; 
    27222799                                        foreach($all_contacts as $index => $object){ 
     
    27242801                                        } 
    27252802                                break; 
    2726  
     2803                                 
    27272804                                case 'outlook2000_en': 
    27282805                                        $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". 
     
    27402817                                        } 
    27412818                                break; 
    2742  
     2819                                         
    27432820                                case 'thunderbird': 
    2744                                         $streamBuffer = "\n"; 
     2821                                        $streamBuffer = "\n";                                                    
    27452822                                        foreach($all_contacts as $index => $object){ 
    27462823                                                $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    27472824                                        } 
    27482825                                break; 
    2749  
    2750                                 default: 
     2826                                 
     2827                                case 'expresso': 
    27512828                                        $streamBuffer = "Nome,Email,Telefone\r\n"; 
    27522829                                        foreach($all_contacts as $index => $object){ 
     
    27542831                                        } 
    27552832                                break; 
    2756  
     2833                                 
    27572834                        } 
    27582835 
     
    27622839                        if(!$f) 
    27632840                                echo null; 
    2764  
     2841                 
    27652842                        fputs($f,$streamBuffer); 
    27662843                        fclose($f); 
     
    27692846                } 
    27702847 
     2848                // Get the csv field and put into array, from php.net 
     2849                function parse_line($input_text, $delimiter = ',', $text_qualifier = '"') { 
     2850                        $text = trim($input_text); 
     2851                          if(is_string($delimiter) && is_string($text_qualifier)) { 
     2852                         $re_d = '\x' . dechex(ord($delimiter));            //format for regexp 
     2853                        $re_tq = '\x' . dechex(ord($text_qualifier));    //format for regexp 
     2854                         
     2855                        $fields = array(); 
     2856                        $field_num = 0; 
     2857                        while(strlen($text) > 0) { 
     2858                        if($text{0} == $text_qualifier) { 
     2859                                preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches); 
     2860                                
     2861                                $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]); 
     2862                                $text = trim($matches[2]); 
     2863                
     2864                                $fields[$field_num++] = $value; 
     2865                        } else { 
     2866                                preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches); 
     2867                                
     2868                                $value = $matches[1]; 
     2869                                $text = trim($matches[2]); 
     2870                
     2871                                $fields[$field_num++] = $value; 
     2872                } 
     2873                } 
     2874                        return $fields; 
     2875                    } else 
     2876                        return false; 
     2877                } 
    27712878 
    27722879                function import_contacts($typeImport){ 
    27732880 
    2774                         $delim          = ($typeImport == 'outlook' ? ';' : ','); 
    2775  
    2776                         if($file = $_SESSION['contactcenter']['importCSV']) { 
    2777                                 unset($_SESSION['contactcenter']['importCSV']); 
     2881                        if($file = $_SESSION['contactcenter']['importCSV']) {                            
     2882                                unset($_SESSION['contactcenter']['importCSV']);                          
    27782883                                $len = filesize($file); 
    27792884                                $count = 0; 
    27802885                                $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); 
    27812886                                $handle = @fopen($file, "r") or die(serialize($return['error'] = true)); 
     2887                                 
     2888                                $input_header = fgets($handle); 
     2889                                if ($typeImport == 'outlook') 
     2890                                        $delim = ';'; 
     2891                                else if ($typeImport == 'auto') 
     2892                                $delim = strstr($input_header,',') ? ',' : ';'; 
     2893                                else   
     2894                                        $delim = ','; 
     2895                                $csv_header = $this->parse_line($input_header,$delim); 
     2896                                $firstContact = fgets($handle); 
     2897                                preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv 
     2898                                rewind($handle);                                 
     2899 
    27822900                                $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); 
    27832901                                if(count($header)  < 2 || count($header) > 100) { 
     
    27872905                                        return; 
    27882906                                } 
    2789  
    2790                                 $boGroup = CreateObject('contactcenter.bo_group'); 
    2791                                 $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
    2792  
     2907                                 
     2908                                if ($matches[0][strlen($matches[0])-1] == ';') 
     2909                                        $delim = ';'; 
     2910                                 
     2911                        $boGroup = CreateObject('contactcenter.bo_group'); 
     2912                        $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
    27932913                                switch($typeImport){ 
    27942914                                        case 'outlook2000': 
     
    28072927                                                $phone_pos=7; 
    28082928                                                break; 
    2809                                         default: 
     2929                                        case 'expresso': 
    28102930                                                $name_pos=0; 
    28112931                                                $email_pos=1; 
    28122932                                                $phone_pos=2; 
    2813                                 } 
     2933                                                break; 
     2934                                        default: 
     2935                                                foreach($csv_header as $index => $fieldName) 
     2936                                                { 
     2937                                                        switch($fieldName){ 
     2938                                                        case 'Name': 
     2939                                                        case 'Nome': 
     2940                                                        case 'First Name': 
     2941                                                                $name_pos = $index; 
     2942                                                                break; 
     2943                                                        case 'E-mail': 
     2944                                                        case 'Email': 
     2945                                                        case 'E-mail Address': 
     2946                                                        case 'Endereço de correio eletrônico': 
     2947                                                        case 'End. de email': 
     2948                                                                $email_pos = $index; 
     2949                                                                break; 
     2950                                                        case 'Home Phone': 
     2951                                                        case 'Phone': 
     2952                                                        case 'Telefone': 
     2953                                                        case 'Telefone principal': 
     2954                                                        case 'Telefone comercial': 
     2955                                                                $phone_pos = $index; 
     2956                                                                break; 
     2957                                                        } 
     2958                                                }        
     2959                                                break; 
     2960                                } 
     2961                                 
    28142962 
    28152963                                while (($data = fgetcsv($handle, $len, $delim))) { 
    2816  
    28172964                                foreach ($header as $key=>$heading) 
    28182965                                $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 
    2819  
     2966                                 
    28202967                                        $sdata = array(); 
    28212968                                        $full_name  = trim($row[$header[$name_pos]]); 
     
    28312978                                        $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 
    28322979                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    2833  
    2834                                         //      verifica se email jï¿œ existe! 
     2980                                         
     2981                                        //      verifica se email já existe! 
    28352982                                        $contact = $boGroup->verify_contact($email); 
    2836  
     2983                                                                                 
     2984                                        if(!$sdata['given_names'] && $email){ 
     2985                                                        $a_email = explode("@",$email); 
     2986                                                        $sdata['given_names'] = $a_email[0]; 
     2987                                        } 
     2988 
     2989                                        $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];  
    28372990                                        if($contact){ 
    28382991                                                $return['_existing']++; 
    2839                                         } 
     2992                                        }                                                                                                                
    28402993                                        else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
    28412994                                                $return['_failure']++; 
     2995                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
    28422996                                        } 
    28432997                                        else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){ 
    2844                                                 $return['_failure']++; 
     2998                                                $return['_failure']++;                                                   
     2999                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 
    28453000                                        } 
    28463001                                        else 
    28473002                                                $return['_new']++; 
    2848                         } 
     3003                        }                                
    28493004                                fclose($handle); 
    28503005                                unlink($file); 
     
    28603015                        $new = null; 
    28613016                        $code = null; 
    2862  
     3017                         
    28633018                        if ($parent === '0') 
    28643019                        { 
     
    28663021                                $code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n"; 
    28673022                        } 
    2868  
     3023                         
    28693024                        foreach ($tree as $id => $value) 
    28703025                        { 
     
    28723027 
    28733028                                switch ($value['type']) 
    2874                                 { 
     3029                                {                                        
    28753030                                        case 'unknown': 
    2876                                                 $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"; 
     3031                                                $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";  
    28773032                                                break; 
    2878  
     3033                                         
    28793034                                        case 'catalog_group': 
    2880                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n"; 
     3035                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n";  
    28813036                                                $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    28823037                                                break; 
     
    28873042                                                $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    28883043                                                break; 
    2889  
     3044                                         
    28903045                                        case 'catalog': 
    28913046                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n"; 
    2892  
    2893                                 } 
    2894                         } 
    2895  
     3047                                                 
     3048                                } 
     3049                        } 
     3050                         
    28963051                        return $code; 
    28973052                } 
Note: See TracChangeset for help on using the changeset viewer.