Changeset 285 for trunk/contactcenter/inc/class.ui_data.inc.php
- Timestamp:
- 05/23/08 17:10:39 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/inc/class.ui_data.inc.php
r284 r285 14 14 \***************************************************************************/ 15 15 16 16 17 17 class ui_data 18 18 { … … 20 20 'data_manager' => true, 21 21 ); 22 22 23 23 var $bo; 24 24 var $typeContact; 25 25 26 26 var $page_info = array( 27 27 'n_cards' => 20, … … 34 34 'actual_catalog' => false 35 35 ); 36 36 37 37 /*! 38 38 39 39 @function ui_data 40 40 @abstract The constructor. Sets the initial parameters and loads 41 41 the data saved in the session 42 42 @author Raphael Derosso Pereira 43 43 44 44 */ 45 45 function ui_data() … … 47 47 $temp = $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter'); 48 48 $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 54 50 $this->bo = CreateObject('contactcenter.bo_contactcenter'); 55 51 56 52 if ($temp) 57 53 { … … 63 59 $this->all_entries = $temp2; 64 60 } 65 66 if ($temp3) 67 { 68 $this->last_search_ids = $temp3; 69 } 70 61 71 62 if (!$this->page_info['actual_catalog']) 72 63 { … … 74 65 $this->page_info['actual_catalog'] = $catalogs[0]; 75 66 } 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 79 70 if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') 80 71 $this -> typeContact = 'groups'; … … 84 75 85 76 /*! 86 77 87 78 @function index 88 79 @abstract Builds the Main Page 89 80 @author Raphael Derosso Pereira 90 81 @author Jonas Goes 91 92 */ 82 83 */ 93 84 function index() 94 { 85 { 95 86 if(!@is_object($GLOBALS['phpgw']->js)) 96 87 { … … 101 92 $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); 102 93 $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); 103 94 104 95 // $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); 105 96 $GLOBALS['phpgw']->common->phpgw_header(); 106 97 107 98 $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); 108 99 $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); 109 100 110 101 /* Quick Add */ 111 102 $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); … … 116 107 $GLOBALS['phpgw']->template->set_var('cc_qa_save',lang('Save')); 117 108 $GLOBALS['phpgw']->template->set_var('cc_qa_clear',lang('Clear')); 109 $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close')); 118 110 /* End Quick Add */ 119 111 120 112 $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; 121 113 $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; … … 123 115 $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); 124 116 $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); 125 117 126 118 $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 127 119 128 120 $GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); 129 121 $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 130 122 131 123 $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 132 124 $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); … … 137 129 $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); 138 130 $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); 139 131 140 132 /* Panel */ 141 133 $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); … … 143 135 $GLOBALS['phpgw']->template->set_var('cc_panel_table',lang('Table View')); 144 136 $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 146 140 $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); 147 141 $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); … … 151 145 $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); 152 146 /* End Panel */ 153 147 154 148 /* Messages */ 155 149 $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); … … 166 160 $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); 167 161 /* End Messages */ 168 162 169 163 $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); 170 164 $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')); 171 166 $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); 172 167 $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')); 174 169 $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 175 170 $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); … … 179 174 $GLOBALS['phpgw']->template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 180 175 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 181 226 $GLOBALS['phpgw']->template->parse('out','index'); 182 227 183 228 $api = CreateObject('contactcenter.ui_api'); 184 229 $main = $api->get_full_add(); … … 191 236 } 192 237 193 238 194 239 /*! 195 240 196 241 @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 198 243 parameters 199 244 @author Raphael Derosso Pereira 200 245 201 246 */ 202 247 function data_manager() … … 207 252 case 'set_n_cards': 208 253 return $this->set_n_cards((int)$_GET['ncards']); 209 210 case 'get_cards_data': 211 254 255 case 'get_cards_data': 212 256 $ids = false; 213 257 // To support ldap catalogs using accentuation 214 258 if ($_POST['letter'] == 'search' && isset($_POST['data'])) 215 259 { 216 //$ids = utf8_decode($this->search($_POST['data'])); 217 $ids = $this->search($_POST['data']); 260 $ids = utf8_decode($this->search($_POST['data'])); 218 261 } 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); 224 267 case 'get_cards_data_get': 225 268 return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); … … 229 272 return $this->get_photo($_GET['id']); 230 273 231 274 case 'get_visible_all_ldap': 275 echo $this->get_visible_all_ldap(); 276 return; 277 232 278 /* Catalog Methods */ 233 279 case 'set_catalog': 234 280 return $this->set_catalog($_GET['catalog']); 235 281 236 282 case 'get_catalog_tree': 237 283 echo serialize($this->get_catalog_tree($_GET['level'])); … … 250 296 echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); 251 297 return; 252 298 253 299 /* Full Add Methods */ 254 300 case 'get_full_data': 255 301 return $this->get_full_data($_GET['id']); 256 302 257 303 case 'get_group': 258 304 return $this->get_group_data($_GET['id']); 259 305 260 306 case 'get_contact_full_add_const': 261 307 return $this->get_contact_full_add_const(); … … 269 315 case 'get_states': 270 316 return $this->get_states($_GET['country']); 271 317 272 318 case 'get_cities': 273 319 return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); 274 275 320 321 276 322 /* Other Methods */ 277 case 'quick_add': 323 case 'quick_add': 278 324 return $this->quick_add($_POST['add']); 279 280 case 'add_group': 325 326 case 'add_group': 281 327 return $this->add_group($_POST['add']); 282 328 283 329 case 'remove_entry': 284 330 return $this->remove_entry((int)$_GET['remove']); 285 331 286 332 case 'remove_all_entries': 287 333 return $this->remove_all_entries(); 288 334 289 335 case 'remove_group': 290 291 return $this->remove_group((int)$_GET['remove']); 336 337 return $this->remove_group((int)$_GET['remove']); 292 338 293 339 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); 295 343 296 344 case 'email_win': … … 326 374 327 375 /*! 328 376 329 377 @function set_n_cards 330 378 @abstract Informs the class the number of cards the page can show 331 379 @author Raphael Derosso Pereira 332 380 333 381 @param integer $n_cards The number of cards 334 382 335 383 */ 336 384 function set_n_cards($n_cards) … … 341 389 echo 1; 342 390 } 343 391 344 392 $this->save_session(); 345 393 } 346 394 347 395 /*! 348 396 349 397 @function set_catalog 350 398 @abstract Sets the current catalog selected by the user 351 399 @author Raphael Derosso Pereira 352 400 353 401 @param string $id_catalog The sequence of IDs to reach the catalog 354 402 separated by commas 355 403 356 404 */ 357 405 function set_catalog($id_catalog) … … 359 407 $id_catalog = str_replace('\\"', '"', $id_catalog); 360 408 $temp =& $this->bo->set_catalog($id_catalog); 361 409 362 410 if ($temp) 363 411 { … … 366 414 $this->page_info['actual_catalog'] =& $temp; 367 415 $this->save_session(); 368 416 369 417 $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 370 418 371 419 if ($catalog_info['class'] === 'bo_global_ldap_catalog' || 372 420 $catalog_info['class'] === 'bo_catalog_group_catalog') … … 378 426 $perms = 15; 379 427 } 380 428 381 429 echo serialize(array( 382 430 'status' => 'ok', … … 386 434 return; 387 435 } 388 436 389 437 echo serialize(array( 390 438 'status' => 'ok', … … 392 440 )); 393 441 } 394 395 442 443 396 444 /*! 397 445 398 446 @function get_catalog_tree 399 447 @abstract Returns the JS serialized array to used as the tree 400 448 level 401 449 @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 406 454 */ 407 455 function get_catalog_tree($level) … … 412 460 413 461 $parent = '0'; 414 462 415 463 if (!($tree = $this->bo->get_catalog_tree($level))) 416 464 { … … 426 474 $parent = substr($level, 0, $last_dot); 427 475 $child = substr($level, $last_dot+1, strlen($level)); 428 476 429 477 if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 430 478 { … … 445 493 } 446 494 } 447 495 448 496 $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 449 497 $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 450 498 451 499 // Deals with error messages from the server and returns them to the browser 452 500 if ($tree['msg']) … … 474 522 'status' => 'error' 475 523 ); 476 477 524 } 478 525 } 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 518 527 /*! 519 528 520 529 @function get_actual_catalog 521 530 @abstract Returns the actual selected Catalog … … 524 533 */ 525 534 function get_actual_catalog() 526 { 535 { 527 536 $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); 528 537 529 538 if ($level) 530 539 { … … 540 549 ); 541 550 } 542 551 543 552 /*! 544 553 545 554 @function get_cards_data 546 555 @abstract Returns the information that is placed on the cards 547 556 @author Raphael Derosso Pereira 548 557 549 558 @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 551 560 @param (str) $ids The ids to be taken in case of search 552 561 … … 556 565 function get_cards_data($letter, $page, $ids) 557 566 { 567 if( $ids ) 568 $_SESSION['ids'] = $ids; 558 569 559 570 // It's an external catalog? 560 571 $external = $this->bo->is_external($this->page_info['actual_catalog']); 561 562 572 //echo $page."\n"; 563 573 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 565 575 $this->page_info['changed'])) 566 576 { 567 577 unset($ids); 568 578 $this->page_info['changed'] = false; 569 579 570 580 switch ($this->page_info['actual_catalog']['class']) 571 581 { … … 654 664 ); 655 665 } 656 666 657 667 $find_field[0] = array('contact.id_contact','contact.names_ordered'); 658 668 659 669 $find_other[0] = array( 660 670 //'offset' => (($page-1)*$this->page_info['n_cards']), … … 662 672 'order' => 'contact.names_ordered' 663 673 ); 664 674 665 675 break; 666 667 //case 'bo_external_ldap_catalog': 668 669 // break; 670 676 671 677 case 'bo_global_ldap_catalog': 678 672 679 $field_name = 'id_contact'; 673 680 … … 718 725 'value' => 'u' 719 726 ), 720 /*1 => array( 721 'field' => 'contact.account_type', 722 'type' => '=', 723 'value' => 'g' 724 ),*/ 725 2 => array( 727 1 => array( 726 728 'field' => 'contact.account_type', 727 729 'type' => '=', … … 834 836 'value' => 'g' 835 837 ),*/ 836 2=> array(838 1 => array( 837 839 'field' => 'contact.account_type', 838 840 'type' => '=', … … 842 844 ); 843 845 } 844 845 846 } 846 847 … … 858 859 $find_field[0] = array('contact.id_contact','contact.names_ordered'); 859 860 } 860 861 861 862 $find_other[0] = array( 862 863 //'offset' => (($page-1)*$this->page_info['n_cards']), … … 864 865 'order' => 'contact.names_ordered' 865 866 ); 866 867 867 868 break; 868 869 869 870 case 'bo_company_manager': 870 871 $field_name = 'id_company'; 871 872 872 873 $find_field[0] = array('company.id_company','company.company_name'); 873 874 874 875 $find_other[0] = array( 875 876 //'offset' => (($page-1)*$this->page_info['n_cards']), … … 877 878 'order' => 'company.company_name' 878 879 ); 879 880 880 881 $find_restric[0] = array( 881 882 0 => array( … … 885 886 ) 886 887 ); 887 888 888 889 break; 889 890 890 891 case 'bo_group_manager': 891 892 892 893 $field_name = 'id_group'; 893 894 894 895 if ($letter !== 'number') { 895 896 896 897 $find_restric[0] = array( 897 898 0 => array( … … 903 904 } 904 905 else { 905 906 906 907 $find_restric[0] = array( 907 908 0 => array( 908 909 'field' => 'group.title', 909 910 'type' => 'LIKE', 910 'value' => '0%' 911 'value' => '0%' 911 912 ) 912 ); 913 ); 913 914 } 914 915 915 916 array_push($find_restric[0], array( 916 917 'field' => 'group.owner', 917 918 'type' => '=', 918 'value' => $GLOBALS['phpgw_info']['user']['account_id'] 919 'value' => $GLOBALS['phpgw_info']['user']['account_id'] 919 920 ) 920 921 ); 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'); 923 924 $find_other[0] = array( 924 925 'order' => 'group.title' 925 926 ); 926 927 927 928 break; 928 929 929 930 case 'bo_catalog_group_catalog': 930 931 $this->page_info['actual_entries'] = false; 931 932 932 933 $this->page_info['actual_letter'] = $letter; 933 934 $this->page_info['actual_page'] = 0; 934 935 935 936 $this->save_session(); 936 937 $final[0] = 0; 937 $final[1] = $this ->typeContact;938 echo serialize($final); 938 $final[1] = $this->typeContact; 939 echo serialize($final); 939 940 return; 940 941 941 942 } 942 943 943 944 $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 944 945 $n_entries = count($result); 945 946 946 947 if ($n_entries) 947 948 { … … 957 958 { 958 959 $this->page_info['actual_entries'] = false; 959 960 960 961 $this->page_info['actual_letter'] = $letter; 961 962 $this->page_info['actual_page'] = 0; 962 963 $this->save_session(); 963 964 $this->save_session(); 964 965 $final[0] = 0; 965 $final[1] = $this ->typeContact;966 echo serialize($final); 966 $final[1] = $this->typeContact; 967 echo serialize($final); 967 968 return; 968 969 } … … 973 974 { 974 975 $this->page_info['actual_entries'][] = $value[$field_name]; 975 } 976 }977 }978 //************************************************************************* 976 } 977 //print_r($this->page_info['actual_entries']); 978 } 979 } 979 980 else if ($letter === 'search') 980 981 { 981 982 //if (!$ids and $this->page_info['actual_letter'] !== 'search') 982 if (!$ids && !$this->last_search_ids)983 if (!$ids) 983 984 { 984 985 error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); 985 986 $this->page_info['actual_entries'] = false; 986 987 987 988 $this->page_info['actual_letter'] = $letter; 988 989 $this->page_info['actual_page'] = 0; 989 990 990 991 $this->save_session(); 991 992 $final[0] = 0; 992 993 $final[1] = $this -> typeContact; 993 echo serialize($final); 994 echo serialize($final); 994 995 return; 995 996 } … … 1007 1008 return; 1008 1009 } 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 { 1024 1012 $this->page_info['actual_letter'] = $letter; 1025 1013 $this->page_info['actual_entries'] = $ids; … … 1038 1026 $page = $this->page_info['n_pages']; 1039 1027 } 1040 1028 1041 1029 $final = array( 1042 1030 0 => (int)$this->page_info['n_pages'], … … 1050 1038 5 => 'cc_alias', 1051 1039 6 => 'cc_id', 1052 7 => 'cc_forwarding_address', 1053 8 => 'cc_empNumber', 1054 9 => 'cc_department' 1040 7 => 'cc_forwarding_address' 1055 1041 ) 1056 1042 ); 1057 1043 1058 1044 //echo 'Page: '.$page.'<br>'; 1059 1045 $id_i = (($page-1)*$this->page_info['n_cards']); 1060 1046 $id_f = $id_i + $this->page_info['n_cards']; 1061 1047 $n_entries = count($this->page_info['actual_entries']); 1062 1048 1063 1049 //echo 'ID_I: '.$id_i.'<br>'; 1064 1050 //echo 'ID_F: '.$id_f.'<br>'; 1065 ///---------------- Corre ᅵᅵo Temporï¿œria PHP5 -----------------------///1051 ///---------------- Correção Temporária PHP5 -----------------------/// 1066 1052 $ids = array(); 1067 $array_temp = array(); 1068 1053 $array_temp = array(); 1054 1069 1055 foreach($this->page_info['actual_entries'] as $key=>$tmp){ 1070 $array_temp[] = $tmp; 1071 } 1072 1056 $array_temp[] = $tmp; 1057 } 1058 1073 1059 for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 1074 1060 { 1075 1061 $ids[] = $array_temp[$i]; 1076 1062 } 1077 1063 1078 1064 /// Original 1079 1065 //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) … … 1082 1068 //} 1083 1069 /// 1084 1070 1085 1071 $fields = $this->bo->catalog->get_fields(false); 1086 1072 1087 if( $this ->typeContact == 'groups') {1073 if( $this->typeContact == 'groups') { 1088 1074 $final = array( 1089 1075 0 => (int)$this->page_info['n_pages'], … … 1094 1080 2 => 'cc_id', 1095 1081 3 => 'cc_contacts' 1096 ) 1097 ); 1098 1082 ) 1083 ); 1084 1099 1085 $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 1100 1086 1101 1087 $i = 0; 1102 1088 // contatos do grupo 1103 $boGroups = CreateObject('contactcenter.bo_group'); 1089 $boGroups = CreateObject('contactcenter.bo_group'); 1104 1090 $contacts = array(); 1105 1091 foreach($groups as $group) { 1106 1092 1107 1093 $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'; 1109 1095 $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; 1110 1096 $contacts = $boGroups -> get_contacts_by_group($group['id_group']); 1111 1097 $final[3][$i][3] = $contacts; 1112 $i++; 1098 $i++; 1113 1099 } 1114 1100 1115 1101 $this->page_info['actual_letter'] = $letter; 1116 $this->page_info['actual_page'] = $page; 1117 1118 1102 $this->page_info['actual_page'] = $page; 1103 1104 1119 1105 $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 1120 1106 1121 1107 $final[5] = '<span class="link" onclick="'.$lnk_compose; 1122 $final[10] = 'groups'; 1123 $this->save_session(); 1108 $final[10] = 'groups'; 1109 $this->save_session(); 1124 1110 echo serialize($final); 1125 return; 1126 } 1127 1111 return; 1112 } 1113 1128 1114 $fields['photo'] = true; 1129 1115 $fields['names_ordered'] = true; … … 1132 1118 $fields['companies'] = 'default'; 1133 1119 $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 1138 1124 if (!is_array($contacts) or !count($contacts)) 1139 1125 { … … 1143 1129 return; 1144 1130 } 1145 1131 1146 1132 $i = 0; 1147 1133 foreach($contacts as $index => $contact) 1148 1134 { 1149 1135 /* 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. 1152 1138 */ 1153 1139 if ($index !== 'error'){ … … 1156 1142 $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 1157 1143 1158 //Para exibir a matricula do empregado1159 $final[3][$i][8] = $contact['companies']['company1']['empNumber']?$contact['companies']['company1']['empNumber']:'none';1160 //Para exibir o setor/lotaᅵᅵo do empregado1161 $final[3][$i][9] = $contact['companies']['company1']['department']?$contact['companies']['company1']['department']:'none';1162 1163 1144 /* Select the correct Email and Telephone to be shown */ 1164 1145 $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 1146 1165 1147 if (!is_array($preferences)) 1166 1148 { … … 1188 1170 $default_phone_found = true; 1189 1171 } 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){ 1192 1173 $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 } 1195 1175 $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 1196 1176 } 1197 1177 } 1198 1178 } 1199 1179 1200 1180 if (!$final[3][$i][3]) 1201 1181 { … … 1217 1197 $final[4][$i] = $contact['photo'] ? 1 : 0; 1218 1198 $i++; 1219 1220 1199 } 1221 1200 else … … 1230 1209 $this->page_info['actual_letter'] = $letter; 1231 1210 $this->page_info['actual_page'] = $page; 1232 1233 $this->save_session(); 1234 1211 1212 $this->save_session(); 1235 1213 echo serialize($final); 1236 1214 return; 1237 1215 } 1238 1216 1239 1217 $this->page_info['actual_letter'] = $letter; 1240 1218 $this->page_info['actual_page'] = $page; 1241 1219 1242 1220 $this->save_session(); 1243 1221 1244 1222 $final[0] = 0; 1245 1223 $final[1] = $this -> typeContact; 1246 1224 echo serialize($final); 1247 1225 } 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 1249 1235 /*! 1250 1236 1251 1237 @function get_group_data 1252 1238 @abstract Returns all the information of a given Group 1253 1239 @author Nilton Emilio Buhrer Neto 1254 1240 1255 1241 @param (integer) $id The id to get information 1256 1257 */ 1242 1243 */ 1258 1244 function get_group_data($id) 1259 1245 { … … 1261 1247 $fields = $this->bo->catalog->get_fields(true); 1262 1248 $data = $this->bo->catalog->get_single_entry($id,$fields); 1263 1264 if($id) { 1249 1250 if($id) { 1265 1251 // 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 1269 1255 $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 1277 1270 /*! 1278 1271 1279 1272 @function get_full_data 1280 1273 @abstract Returns all the information of a given Entry 1281 1274 @author Raphael Derosso Pereira 1282 1275 1283 1276 @param (integer) $id The id to get information 1284 1277 1285 1278 */ 1286 1279 function get_full_data($id) 1287 1280 { 1288 1281 $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'); 1290 1283 $fields = $this->bo->catalog->get_fields(true); 1291 1284 $fields['photo'] = false; … … 1320 1313 } 1321 1314 $datecount = 0; 1322 1315 1323 1316 $data['result'] = 'ok'; 1324 1317 $data['cc_full_add_contact_id'] = $id; … … 1362 1355 1363 1356 /* Relations */ 1364 1357 1365 1358 echo serialize($data); 1366 1359 } … … 1399 1392 return; 1400 1393 } 1401 1394 1402 1395 echo 0; 1403 1396 } 1404 1397 1405 1398 /*! 1406 1399 1407 1400 @function quick_add 1408 1401 @abstract Adds a new Contact using the Quick Add interface 1409 1402 @author Raphael Derosso Pereira 1410 1403 1411 1404 @param string $sdata Serialized data 1412 1405 */ 1413 1406 function quick_add($sdata) 1414 1407 { 1415 1408 1416 1409 $sdata = str_replace('\\"', '"', $sdata); 1417 1410 $new_array = unserialize($sdata); 1418 1411 $tdata = array(); 1419 1412 1420 1413 foreach($new_array as $tmp) 1421 1414 $tdata[] = $tmp; 1422 1415 1423 1416 if (!$tdata) 1424 1417 { … … 1427 1420 'status' => 'abort' 1428 1421 )); 1429 1422 1430 1423 return; 1431 1424 } 1432 1433 // verifica se email j ï¿œexiste!1425 1426 // verifica se email já existe! 1434 1427 $boGroup = CreateObject('contactcenter.bo_group'); 1435 1428 $contact = $boGroup->verify_contact($tdata[4]); 1436 1429 1437 1430 if($contact) 1438 { 1431 { 1439 1432 $str_contact = "\r\n - ".implode("\r\n - ",$contact); 1440 1433 1441 1434 echo serialize(array( 1442 1435 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), 1443 1436 'status' => 'alreadyExists' 1444 1437 )); 1445 1446 return; 1438 1439 return; 1447 1440 } 1448 1441 … … 1460 1453 1461 1454 if ($boPeople ->quick_add($data)) 1462 { 1455 { 1463 1456 $this->page_info['changed'] = true; 1464 1457 1465 1458 echo serialize(array( 1466 1459 'msg' => lang('Entry added with success!'), … … 1476 1469 } 1477 1470 1478 $this->save_session(); 1479 1471 $this->save_session(); 1472 1480 1473 } 1481 1474 1482 1475 /*! 1483 1476 1484 1477 @function add_group 1485 1478 @abstract Adds a new Group using the Add Group interface 1486 1479 @author Nilton Emilio Buhrer Neto 1487 1480 1488 1481 @param string $sdata Serialized data 1489 1482 */ … … 1493 1486 $tdata = unserialize($sdata); 1494 1487 $new_tdata = array(); 1495 1488 1496 1489 if (!$tdata) 1497 1490 { … … 1500 1493 'status' => 'abort' 1501 1494 )); 1502 1495 1503 1496 return; 1504 1497 } 1505 1498 1506 1499 foreach($tdata as $tmp) 1507 1500 $new_tdata[] = $tmp; 1508 1509 $data['title'] = $new_tdata[0]; 1501 1502 $data['title'] = $new_tdata[0]; 1510 1503 $data['contact_in_list'] = $new_tdata[1]; 1511 1504 $data['id_group'] = $new_tdata[2]; 1512 1505 1513 1506 $boGroup = CreateObject('contactcenter.bo_group_manager'); 1514 1507 $id = $boGroup -> add_group($data); 1515 1508 1516 1509 if ($id) 1517 1510 { 1518 1511 $this->page_info['changed'] = true; 1519 1512 1520 1513 echo serialize(array( 1521 1514 'msg' => lang('Entry added with success!'), … … 1535 1528 1536 1529 /*! 1537 1530 1538 1531 @function remove_group 1539 1532 @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 1541 1534 @param (integer) $id The id to be removed 1542 1535 1543 1536 */ 1544 1537 function remove_group($id) 1545 { 1546 $soGroup = CreateObject('contactcenter.so_group'); 1538 { 1539 $soGroup = CreateObject('contactcenter.so_group'); 1547 1540 $data = array ('id_group' => $id); 1548 1541 if($soGroup -> delete($data)) { … … 1550 1543 'msg' => lang('Removed Entry ID '.$id.'!'), 1551 1544 'status' => 'ok' 1552 )); 1545 )); 1553 1546 } 1554 1547 else { … … 1559 1552 } 1560 1553 1561 $this->save_session(); 1554 $this->save_session(); 1562 1555 } 1563 1556 1564 1557 1565 1558 function remove_all_entries (){ 1566 1559 1567 1560 $error = false; 1568 1561 $this->all_entries = $this->bo->catalog->get_all_entries_ids(); … … 1572 1565 if(!$result) { 1573 1566 $error = true; 1574 break; 1567 break; 1575 1568 } 1576 1569 } … … 1581 1574 'status' => 'ok' 1582 1575 )); 1583 } 1576 } 1584 1577 else { 1585 1578 echo serialize(array( … … 1593 1586 1594 1587 /*! 1595 1588 1596 1589 @function remove_entry 1597 1590 @abstract Removes an entry if the user has the right to do it 1598 1591 @author Raphael Derosso Pereira 1599 1592 1600 1593 @param (integer) $id The id to be removed 1601 1594 1602 1595 */ 1603 1596 function remove_entry ($id) … … 1608 1601 return; 1609 1602 } 1610 1603 1611 1604 $this->page_info['changed'] = true; 1612 1605 $result = $this->bo->catalog->remove_single_entry($id); 1613 1606 1614 1607 if ($result) 1615 1608 { … … 1618 1611 unset($this->page_info['actual_entries'][$pos]); 1619 1612 } 1620 1613 1621 1614 $temp = false; 1622 1615 reset($this->page_info['actual_entries']); … … 1625 1618 $temp[] = $t; 1626 1619 } 1627 1620 1628 1621 $this->page_info['actual_entries'] = $temp; 1629 1622 … … 1640 1633 )); 1641 1634 } 1642 1635 1643 1636 $this->save_session(); 1644 1637 } 1645 1638 1646 1639 1647 1640 /*! 1648 1641 1649 1642 @function post_full_add 1650 1643 @abstract Saves all the information altered/entered in the Full Add … … 1655 1648 function post_full_add() 1656 1649 { 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)); 1658 1654 $this -> bo -> catalog = CreateObject('contactcenter.bo_people_catalog'); 1659 1660 // echo str_replace('\\"', '"', $_POST['data']);1661 1655 1662 1656 if (!is_array($data)) … … 1682 1676 'status' => 'fatal' 1683 1677 )); 1684 1678 1685 1679 return; 1686 1680 } … … 1696 1690 $id_photo = '_new_'; 1697 1691 } 1698 1699 /* 1700 * Process Photo, if available 1692 1693 /* 1694 * Process Photo, if available 1701 1695 */ 1702 1696 $sleep_count = 0; … … 1715 1709 } 1716 1710 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 1717 1711 1718 1712 if (isset($this->page_info['photos'][$id_photo])) 1719 1713 { … … 1732 1726 $this->save_session(); 1733 1727 } 1734 1728 1735 1729 /* 1736 1730 * Arrange Date so it gets inserted correctly 1737 1731 */ 1738 1732 1739 1733 $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 1740 1734 1741 1735 $j = 0; 1742 1736 for ($i = 0; $i < 5; $i+=2) … … 1771 1765 continue; 1772 1766 } 1773 1767 1774 1768 switch($field) 1775 1769 { … … 1783 1777 /* Do Nothing. This is just to make sure no invalid field is passed */ 1784 1778 break; 1785 1779 1786 1780 case 'id_status': 1787 1781 case 'id_prefix': … … 1792 1786 } 1793 1787 break; 1794 1788 1795 1789 case 'birthdate_0': 1796 1790 case 'birthdate_1': 1797 1791 case 'birthdate_2': 1798 1792 1799 1793 switch($date[$datecount]['digit']) 1800 1794 { … … 1818 1812 break; 1819 1813 } 1820 1814 1821 1815 if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 1822 1816 { … … 1827 1821 return; 1828 1822 } 1829 1823 1830 1824 $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 1831 1825 break; … … 1850 1844 { 1851 1845 $index = 'address'.$type; 1852 1846 1853 1847 $id_state = $this->bo->catalog->add_state($state_info); 1854 1848 $data['addresses'][$index]['id_state'] = $id_state; … … 1868 1862 { 1869 1863 $index = 'address'.$type; 1870 1864 1871 1865 $id_city = $this->bo->catalog->add_city($city_info); 1872 1866 $data['addresses'][$index]['id_city'] = $id_city; … … 1909 1903 ); 1910 1904 } 1911 1905 1912 1906 eval($code); 1913 1907 … … 1925 1919 1926 1920 /*! 1927 1921 1928 1922 @function post_photo 1929 1923 @abstract Wrapper to post a photo without reload a page. … … 1935 1929 //print_r($_FILES); 1936 1930 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); 1937 1931 1938 1932 if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) 1939 1933 { 1940 1934 $this->page_info['photos'][$id]['status'] = 'no_upload'; 1941 1935 $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); 1942 1936 1943 1937 $this->save_session(); 1944 1938 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); … … 1950 1944 $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; 1951 1945 $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 1953 1947 $this->save_session(); 1954 1948 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); … … 1976 1970 return; 1977 1971 } 1978 1972 1979 1973 switch($_FILES['cc_pd_photo']['type']) 1980 1974 { … … 2006 2000 2007 2001 default: 2008 2002 2009 2003 $this->page_info['photos'][$id]['status'] = 'invalid_image'; 2010 2004 $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); … … 2019 2013 $this->page_info['photos'][$id]['status'] = 'invalid_file'; 2020 2014 $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 2022 2016 $this->save_session(); 2023 2017 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 2024 2018 return; 2025 2019 } 2026 2020 2027 2021 $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); 2028 2022 $dst_img = imagecreatetruecolor(60, 80); 2029 2023 2030 2024 if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) 2031 2025 { 2032 2026 $this->page_info['photos'][$id]['status'] = 'invalid_file'; 2033 2027 $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 2035 2029 $this->save_session(); 2036 2030 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 2037 2031 return; 2038 2032 } 2039 2033 2040 2034 ob_start(); 2041 2035 imagepng($dst_img); … … 2047 2041 2048 2042 $this->save_session(); 2049 2043 2050 2044 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 2051 2045 … … 2068 2062 $fields = $this->bo->catalog->get_fields(false); 2069 2063 $fields['photo'] = true; 2070 2064 2071 2065 $contact = $this->bo->catalog->get_single_entry($id, $fields); 2072 2066 … … 2077 2071 return; 2078 2072 } 2079 2073 2080 2074 header('Content-type: image/jpeg'); 2081 2075 $photo = imagecreatefromstring ($contact['photo']); … … 2089 2083 return; 2090 2084 } 2091 2085 2092 2086 /*! 2093 2087 2094 2088 @function get_states 2095 2089 @abstract Echos a serialized array containing all the states for the given country … … 2113 2107 return; 2114 2108 } 2115 2109 2116 2110 $result = array( 2117 2111 'msg' => lang('States Successfully retrieved!'), 2118 2112 'status' => 'ok' 2119 2113 ); 2120 2114 2121 2115 foreach ($states as $state_info) 2122 2116 { … … 2157 2151 return; 2158 2152 } 2159 2153 2160 2154 $result = array( 2161 2155 'msg' => lang('Cities Successfully retrieved!'), 2162 2156 'status' => 'ok' 2163 2157 ); 2164 2158 2165 2159 foreach ($cities as $city_info) 2166 2160 { 2167 2161 $result['data'][$city_info['id_city']] = $city_info['name']; 2168 2162 } 2169 2163 2170 2164 echo serialize($result); 2171 2165 } … … 2173 2167 2174 2168 /*! 2175 2169 2176 2170 @function search 2177 2171 @abstract Echos a serialized array containing the IDs 2178 2172 of the entries that matches the search argument 2179 2173 @author Raphael Derosso Pereira 2180 @author M ï¿œrio Cï¿œsar Kolling (external catalogs)2174 @author Mário César Kolling (external catalogs) 2181 2175 2182 2176 @param string $str_data A serialized array with two informations: … … 2187 2181 2188 2182 */ 2183 // SERPRO 2189 2184 function search($str_data) 2190 2185 { … … 2192 2187 // It's an external catalog? 2193 2188 $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 2205 2201 /* 2206 2202 * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly … … 2213 2209 $data['search_for'] = utf8_encode($data['search_for']); 2214 2210 } 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 } 2241 2237 2242 2238 if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && … … 2271 2267 ); 2272 2268 } 2273 2274 2275 2276 2277 2278 2279 2280 2281 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 } 2286 2282 2287 2283 if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || … … 2305 2301 } 2306 2302 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 { 2314 2305 $this->last_search_ids = null; 2315 2306 $this->save_session(); 2316 2307 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 2331 2319 return $ids_f; 2332 2333 //echo serialize(array(2334 // 'data' => $ids_f,2335 // 'msg' => lang('Found %1 Entries', count($ids)),2336 // 'status' => 'ok'2337 //));2338 2320 } 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 }*/ 2340 2418 /*! 2341 2419 … … 2345 2423 @author Raphael Derosso Pereira 2346 2424 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 2348 2426 to be taken, the fields to be taken and the rules to be used on the 2349 2427 retrieval: … … 2358 2436 { 2359 2437 $data = unserialize($str_data); 2360 2438 2361 2439 if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) 2362 2440 { … … 2368 2446 2369 2447 $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); 2370 2448 2371 2449 if (!is_array($entries) or !count($entries)) 2372 2450 { … … 2387 2465 2388 2466 @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 2390 2468 in the default CC UI format 2391 2469 @author Raphael Derosso Pereira 2392 2470 2393 @params array str_data A serialized array containing the fields to 2471 @params array str_data A serialized array containing the fields to 2394 2472 be grabbed, the maximum number of entries to be returned and a 2395 2473 boolean specifying if the calls refers to a new grab or to an … … 2400 2478 { 2401 2479 $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 2406 2484 !$data['maxlength'] or 2407 2485 (!$data['new'] and !$data['offset'])) … … 2429 2507 $data['offset'] = 0; 2430 2508 } 2431 2509 2432 2510 if ($data['maxlength'] != -1) 2433 2511 { … … 2440 2518 2441 2519 $prefs = ExecMethod('contactcenter.ui_preferences.get_preferences'); 2442 2520 2443 2521 $jsCode = array(); 2444 2522 $count = 0; … … 2450 2528 } 2451 2529 2452 if($this-> typeContact == 'groups') { 2453 2530 if($this-> typeContact == 'groups') { 2531 2454 2532 foreach ($each as $field => $value) { 2455 2533 2456 2534 if ($field === 'title') { 2457 2535 $optionName = '\\"'.$value.'\\"'; 2458 2536 2459 2537 } 2460 2538 else if ($field === 'short_name') { 2461 2539 2462 2540 $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; 2463 $count++; 2464 } 2541 $count++; 2542 } 2465 2543 } 2466 2544 } 2467 2468 else { 2545 2546 else { 2469 2547 foreach ($each as $field => $value) { 2470 2548 if ($field === 'names_ordered') { … … 2474 2552 } 2475 2553 else if ($field === 'connections') { 2476 2554 2477 2555 foreach ($value as $connection) { 2478 2556 if ($connection['id_type'] == $prefs['personCardEmail']) { … … 2487 2565 2488 2566 $jsCodeFinal = implode("\n", $jsCode); 2489 2567 2490 2568 $nEntries = count($result); 2491 2569 2492 2570 if (!$nEntries) 2493 2571 { … … 2507 2585 ); 2508 2586 } 2509 2587 2510 2588 /*********************************************************************\ 2511 2589 * Auxiliar Methods * … … 2513 2591 2514 2592 /*! 2515 2593 2516 2594 @function save_session 2517 2595 @abstract Saves the data on the session 2518 2596 @author Raphael Derosso Pereira 2519 2597 2520 2598 */ 2521 2599 function save_session() … … 2523 2601 $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter',$this->page_info); 2524 2602 $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);2526 2603 } 2527 2604 2528 2605 /*! 2529 2606 2530 2607 @function convert_tree 2531 2608 @abstract Converts the tree array in the BO format to a JS tree array compatible 2532 2609 with the one available in eGW 2533 2610 @author Raphael Derosso Pereira 2534 2611 2535 2612 @param (array) $tree The tree in the BO format 2536 2613 @param (string) $name The tree name … … 2566 2643 'caption' => $value['name'] 2567 2644 ); 2568 2645 2569 2646 switch($value['type']) 2570 2647 { … … 2589 2666 $this->bo->catalog->src_info = $ldap->srcs[1]; 2590 2667 } 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); 2593 2670 $dn=$this->bo->catalog->src_info['dn']; 2594 2671 $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); 2597 2674 for($z = 0; $z < 5; $z++) { 2598 $participant = $info[0][$justThese[$z]]; 2675 $participant = $info[0][$justThese[$z]]; 2599 2676 array_push($array_participants, $participant); 2600 2677 } … … 2602 2679 ldap_close($ds); 2603 2680 echo serialize($array_participants); 2604 } 2605 2606 function get_catalog_participants_list($id) 2681 } 2682 2683 function get_catalog_participants_list($id) 2607 2684 { 2608 2609 $fields = $this->bo->catalog->get_fields(false); 2685 2686 $fields = $this->bo->catalog->get_fields(false); 2610 2687 $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 2614 2691 $array_participants = array(); 2615 2692 $array_emails = array(); 2616 2693 2617 2694 $filter = null; 2618 for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 2695 for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 2619 2696 if(strstr($contact['mail_forwarding_address'][$z],'@')) { 2620 2697 $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; 2621 2698 $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; 2622 } 2623 else 2699 } 2700 else 2624 2701 $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; 2625 } 2626 2702 } 2703 2627 2704 if($filter) { 2628 $filter = "(|".$filter.")"; 2705 $filter = "(|".$filter.")"; 2629 2706 if(!$this->bo->catalog->src_info) { 2630 2707 $ldap = CreateObject('contactcenter.bo_ldap_manager'); 2631 2708 $this->bo->catalog->src_info = $ldap->srcs[1]; 2632 2709 } 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); 2634 2711 $dn=$this->bo->catalog->src_info['dn']; 2635 2712 $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); 2638 2715 for($z = 0; $z < $info['count']; $z++) { 2639 2716 $participant = '<font color=\'DARKBLUE\'> "'.$info[$z]['cn'][0].'" <'.$info[$z]['mail'][0].'></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 2644 2721 foreach($array_emails as $index => $email) 2645 if($email) 2646 array_push($array_participants, " ".$email."<br>"); 2647 2722 if($email) 2723 array_push($array_participants, " ".$email."<br>"); 2724 2648 2725 ldap_close($ds); 2649 2726 } 2650 2727 sort($array_participants); 2651 $innerHTML = ''; 2728 $innerHTML = ''; 2652 2729 foreach($array_participants as $index => $participant){ 2653 2730 $innerHTML .= $participant; 2654 2731 } 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); 2656 2733 echo serialize($return); 2657 } 2658 2734 } 2735 2659 2736 function export_contacts($typeExport){ 2660 2737 … … 2667 2744 2668 2745 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. 2670 2747 // em outra com apenas 1 elemento pra cada contato 2671 2748 $i=0; … … 2678 2755 $all_contacts[$i]['phone']=$object['connection_value']; 2679 2756 } 2680 2757 2681 2758 switch($typeExport) { 2682 2759 2683 2760 case 'outlook_en': 2684 2761 $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"; 2686 2763 foreach($all_contacts as $index => $object){ 2687 2764 $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 2688 2765 } 2689 2766 break; 2690 2767 2691 2768 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"; 2698 2775 foreach($all_contacts as $index => $object){ 2699 2776 $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 2700 2777 } 2701 2778 break; 2702 2779 2703 2780 case 'outlook2000_pt-BR': 2704 2781 $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\",". 2710 2787 "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 2711 2788 "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 2712 2789 "\"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\",". 2721 2798 "\"Sexo\"\r\n"; 2722 2799 foreach($all_contacts as $index => $object){ … … 2724 2801 } 2725 2802 break; 2726 2803 2727 2804 case 'outlook2000_en': 2728 2805 $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". … … 2740 2817 } 2741 2818 break; 2742 2819 2743 2820 case 'thunderbird': 2744 $streamBuffer = "\n"; 2821 $streamBuffer = "\n"; 2745 2822 foreach($all_contacts as $index => $object){ 2746 2823 $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 2747 2824 } 2748 2825 break; 2749 2750 default:2826 2827 case 'expresso': 2751 2828 $streamBuffer = "Nome,Email,Telefone\r\n"; 2752 2829 foreach($all_contacts as $index => $object){ … … 2754 2831 } 2755 2832 break; 2756 2833 2757 2834 } 2758 2835 … … 2762 2839 if(!$f) 2763 2840 echo null; 2764 2841 2765 2842 fputs($f,$streamBuffer); 2766 2843 fclose($f); … … 2769 2846 } 2770 2847 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 } 2771 2878 2772 2879 function import_contacts($typeImport){ 2773 2880 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']); 2778 2883 $len = filesize($file); 2779 2884 $count = 0; 2780 2885 $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); 2781 2886 $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 2782 2900 $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); 2783 2901 if(count($header) < 2 || count($header) > 100) { … … 2787 2905 return; 2788 2906 } 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'); 2793 2913 switch($typeImport){ 2794 2914 case 'outlook2000': … … 2807 2927 $phone_pos=7; 2808 2928 break; 2809 default:2929 case 'expresso': 2810 2930 $name_pos=0; 2811 2931 $email_pos=1; 2812 2932 $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 2814 2962 2815 2963 while (($data = fgetcsv($handle, $len, $delim))) { 2816 2817 2964 foreach ($header as $key=>$heading) 2818 2965 $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 2819 2966 2820 2967 $sdata = array(); 2821 2968 $full_name = trim($row[$header[$name_pos]]); … … 2831 2978 $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 2832 2979 $sdata['connections']['default_phone']['connection_value'] = $phone; 2833 2834 // verifica se email j ï¿œexiste!2980 2981 // verifica se email já existe! 2835 2982 $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']; 2837 2990 if($contact){ 2838 2991 $return['_existing']++; 2839 } 2992 } 2840 2993 else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 2841 2994 $return['_failure']++; 2995 $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 2842 2996 } 2843 2997 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>"; 2845 3000 } 2846 3001 else 2847 3002 $return['_new']++; 2848 } 3003 } 2849 3004 fclose($handle); 2850 3005 unlink($file); … … 2860 3015 $new = null; 2861 3016 $code = null; 2862 3017 2863 3018 if ($parent === '0') 2864 3019 { … … 2866 3021 $code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n"; 2867 3022 } 2868 3023 2869 3024 foreach ($tree as $id => $value) 2870 3025 { … … 2872 3027 2873 3028 switch ($value['type']) 2874 { 3029 { 2875 3030 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"; 2877 3032 break; 2878 3033 2879 3034 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"; 2881 3036 $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 2882 3037 break; … … 2887 3042 $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 2888 3043 break; 2889 3044 2890 3045 case 'catalog': 2891 3046 $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 2896 3051 return $code; 2897 3052 }
Note: See TracChangeset
for help on using the changeset viewer.