Changeset 284 for trunk/contactcenter/inc/class.ui_data.inc.php
- Timestamp:
- 05/21/08 16:56:17 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/inc/class.ui_data.inc.php
r276 r284 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 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 50 54 $this->bo = CreateObject('contactcenter.bo_contactcenter'); 51 55 52 56 if ($temp) 53 57 { … … 59 63 $this->all_entries = $temp2; 60 64 } 61 65 66 if ($temp3) 67 { 68 $this->last_search_ids = $temp3; 69 } 70 62 71 if (!$this->page_info['actual_catalog']) 63 72 { … … 65 74 $this->page_info['actual_catalog'] = $catalogs[0]; 66 75 } 67 68 $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); 69 76 77 $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); 78 70 79 if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') 71 80 $this -> typeContact = 'groups'; … … 75 84 76 85 /*! 77 86 78 87 @function index 79 88 @abstract Builds the Main Page 80 89 @author Raphael Derosso Pereira 81 90 @author Jonas Goes 82 83 */ 91 92 */ 84 93 function index() 85 { 94 { 86 95 if(!@is_object($GLOBALS['phpgw']->js)) 87 96 { … … 92 101 $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); 93 102 $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); 94 103 95 104 // $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); 96 105 $GLOBALS['phpgw']->common->phpgw_header(); 97 106 98 107 $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); 99 108 $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); 100 109 101 110 /* Quick Add */ 102 111 $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); … … 107 116 $GLOBALS['phpgw']->template->set_var('cc_qa_save',lang('Save')); 108 117 $GLOBALS['phpgw']->template->set_var('cc_qa_clear',lang('Clear')); 109 $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close'));110 118 /* End Quick Add */ 111 119 112 120 $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; 113 121 $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; … … 115 123 $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); 116 124 $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); 117 125 118 126 $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 119 127 120 128 $GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); 121 129 $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 122 130 123 131 $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 124 132 $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); … … 129 137 $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); 130 138 $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); 131 139 132 140 /* Panel */ 133 141 $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); … … 135 143 $GLOBALS['phpgw']->template->set_var('cc_panel_table',lang('Table View')); 136 144 $GLOBALS['phpgw']->template->set_var('cc_panel_cards',lang('Cards View')); 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 145 140 146 $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); 141 147 $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); … … 145 151 $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); 146 152 /* End Panel */ 147 153 148 154 /* Messages */ 149 155 $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); … … 160 166 $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); 161 167 /* End Messages */ 162 168 163 169 $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); 164 170 $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'));166 171 $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); 167 172 $GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation')); 168 $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); 173 $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); 169 174 $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 170 175 $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); … … 174 179 $GLOBALS['phpgw']->template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 175 180 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_ie_personal', lang('Import / Export personal Contacts'));186 $GLOBALS['phpgw']->template->set_var('cc_msg_import_fail', lang('The importation has failed. Verify the file format.'));187 $GLOBALS['phpgw']->template->set_var('cc_msg_importing_contacts', lang('Importing Contacts...'));188 $GLOBALS['phpgw']->template->set_var('cc_msg_import_finished', lang('The importation has finished.'));189 $GLOBALS['phpgw']->template->set_var('cc_msg_new', lang(' new'));190 $GLOBALS['phpgw']->template->set_var('cc_msg_failure', lang(' failed'));191 $GLOBALS['phpgw']->template->set_var('cc_msg_exists', lang(' were existent'));192 $GLOBALS['phpgw']->template->set_var('cc_msg_show_more_info', lang('show more info'));193 $GLOBALS['phpgw']->template->set_var('cc_msg_clean', lang('Clean'));194 $GLOBALS['phpgw']->template->set_var('cc_msg_invalid_csv', lang('Select a valid CSV file to import your contacts'));195 $GLOBALS['phpgw']->template->set_var('cc_msg_export_csv', lang('Select the format type that you want to export your contacts'));196 $GLOBALS['phpgw']->template->set_var('cc_msg_automatic', lang('Automatic'));197 $GLOBALS['phpgw']->template->set_var('cc_msg_export_error', lang('An error has occurred while the exportation.'));198 $GLOBALS['phpgw']->template->set_var('cc_msg_new_email', lang('New Email'));199 $GLOBALS['phpgw']->template->set_var('cc_msg_main', lang('Main'));200 $GLOBALS['phpgw']->template->set_var('cc_msg_alternative', lang('Alternative'));201 $GLOBALS['phpgw']->template->set_var('cc_msg_select_email', lang('Select E-Mail'));202 $GLOBALS['phpgw']->template->set_var('cc_msg_new_phone', lang('New Telephone'));203 $GLOBALS['phpgw']->template->set_var('cc_msg_home', lang('Home'));204 $GLOBALS['phpgw']->template->set_var('cc_msg_cellphone', lang('Cellphone'));205 $GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work'));206 $GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax'));207 $GLOBALS['phpgw']->template->set_var('cc_msg_pager', lang('Pager'));208 $GLOBALS['phpgw']->template->set_var('cc_msg_choose_phone', lang('Select the telephone'));209 $GLOBALS['phpgw']->template->set_var('cc_msg_warn_firefox', lang('Warning: Too old version of Firefox'));210 $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half1', lang('For this application work correctly</u>'));211 $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'));212 $GLOBALS['phpgw']->template->set_var('cc_msg_click_close', lang('click Close'));213 $GLOBALS['phpgw']->template->set_var('cc_msg_install_now', lang('Install Now'));214 $GLOBALS['phpgw']->template->set_var('cc_msg_install_new_firefox', lang('Install a new Firefox version'));215 $GLOBALS['phpgw']->template->set_var('cc_msg_moz_thunderbird', lang('Export as Mozilla Thunderbird CSV.'));216 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_pt', lang('Export as Outlook Express (Portuguese) CSV.'));217 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_en', lang('Export as Outlook Express (English) CSV.'));218 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.'));219 $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.'));220 $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.'));221 $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.'));222 $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.'));223 $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name'));224 225 181 $GLOBALS['phpgw']->template->parse('out','index'); 226 182 227 183 $api = CreateObject('contactcenter.ui_api'); 228 184 $main = $api->get_full_add(); … … 235 191 } 236 192 237 193 238 194 /*! 239 195 240 196 @function data_manager 241 @abstract Calls the right method and passes to it the right 197 @abstract Calls the right method and passes to it the right 242 198 parameters 243 199 @author Raphael Derosso Pereira 244 200 245 201 */ 246 202 function data_manager() … … 251 207 case 'set_n_cards': 252 208 return $this->set_n_cards((int)$_GET['ncards']); 253 209 254 210 case 'get_cards_data': 255 return $this->get_cards_data($_POST['letter'], $_POST['page'], unserialize(str_replace('\\"','"',$_POST['ids']))); 211 212 $ids = false; 213 // To support ldap catalogs using accentuation 214 if ($_POST['letter'] == 'search' && isset($_POST['data'])) 215 { 216 //$ids = utf8_decode($this->search($_POST['data'])); 217 $ids = $this->search($_POST['data']); 218 } 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 256 224 case 'get_cards_data_get': 257 225 return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); … … 261 229 return $this->get_photo($_GET['id']); 262 230 263 231 264 232 /* Catalog Methods */ 265 233 case 'set_catalog': 266 234 return $this->set_catalog($_GET['catalog']); 267 235 268 236 case 'get_catalog_tree': 269 237 echo serialize($this->get_catalog_tree($_GET['level'])); … … 279 247 280 248 case 'get_catalog_add_contact': 281 echo serialize($this->get_catalog_add_contact($_POST['id'])); 249 // To support ldap catalogs with accentuation 250 echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); 282 251 return; 283 252 284 253 /* Full Add Methods */ 285 254 case 'get_full_data': 286 255 return $this->get_full_data($_GET['id']); 287 256 288 257 case 'get_group': 289 258 return $this->get_group_data($_GET['id']); 290 259 291 260 case 'get_contact_full_add_const': 292 261 return $this->get_contact_full_add_const(); … … 300 269 case 'get_states': 301 270 return $this->get_states($_GET['country']); 302 271 303 272 case 'get_cities': 304 273 return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); 305 306 274 275 307 276 /* Other Methods */ 308 case 'quick_add': 277 case 'quick_add': 309 278 return $this->quick_add($_POST['add']); 310 311 case 'add_group': 279 280 case 'add_group': 312 281 return $this->add_group($_POST['add']); 313 282 314 283 case 'remove_entry': 315 284 return $this->remove_entry((int)$_GET['remove']); 316 285 317 286 case 'remove_all_entries': 318 287 return $this->remove_all_entries(); 319 288 320 289 case 'remove_group': 321 322 return $this->remove_group((int)$_GET['remove']); 290 291 return $this->remove_group((int)$_GET['remove']); 323 292 324 293 case 'search': … … 357 326 358 327 /*! 359 328 360 329 @function set_n_cards 361 330 @abstract Informs the class the number of cards the page can show 362 331 @author Raphael Derosso Pereira 363 332 364 333 @param integer $n_cards The number of cards 365 334 366 335 */ 367 336 function set_n_cards($n_cards) … … 372 341 echo 1; 373 342 } 374 343 375 344 $this->save_session(); 376 345 } 377 346 378 347 /*! 379 348 380 349 @function set_catalog 381 350 @abstract Sets the current catalog selected by the user 382 351 @author Raphael Derosso Pereira 383 352 384 353 @param string $id_catalog The sequence of IDs to reach the catalog 385 354 separated by commas 386 355 387 356 */ 388 357 function set_catalog($id_catalog) … … 390 359 $id_catalog = str_replace('\\"', '"', $id_catalog); 391 360 $temp =& $this->bo->set_catalog($id_catalog); 392 361 393 362 if ($temp) 394 363 { … … 397 366 $this->page_info['actual_catalog'] =& $temp; 398 367 $this->save_session(); 399 368 400 369 $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 401 370 402 371 if ($catalog_info['class'] === 'bo_global_ldap_catalog' || 403 372 $catalog_info['class'] === 'bo_catalog_group_catalog') … … 409 378 $perms = 15; 410 379 } 411 380 412 381 echo serialize(array( 413 382 'status' => 'ok', … … 417 386 return; 418 387 } 419 388 420 389 echo serialize(array( 421 390 'status' => 'ok', … … 423 392 )); 424 393 } 425 426 394 395 427 396 /*! 428 397 429 398 @function get_catalog_tree 430 399 @abstract Returns the JS serialized array to used as the tree 431 400 level 432 401 @author Raphael Derosso Pereira 433 434 @param (string) $level The level to be taken 435 402 @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout) 403 404 @param (string) $level The level to be taken 405 436 406 */ 437 407 function get_catalog_tree($level) … … 442 412 443 413 $parent = '0'; 444 414 445 415 if (!($tree = $this->bo->get_catalog_tree($level))) 446 416 { … … 456 426 $parent = substr($level, 0, $last_dot); 457 427 $child = substr($level, $last_dot+1, strlen($level)); 458 428 459 429 if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 460 430 { … … 464 434 ); 465 435 } 466 } 467 436 // Deals with timeout and returns the generated message to the browser 437 else if (!empty($tree[$child]['timeout']) && !empty($tree[$child]['msg'])) 438 { 439 $tmp = array( 440 'msg' => $tree[$child]['msg'], 441 'status' => 'fatal' 442 ); 443 unset($tree[$child]); 444 return $tmp; 445 } 446 } 447 468 448 $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 469 449 $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 470 450 451 // Deals with error messages from the server and returns them to the browser 452 if ($tree['msg']) 453 { 454 $msg = $tree['msg']; 455 unset($tree['msg']); 456 } 457 471 458 $tree_js = $this->convert_tree($tree, $folderImageDir, $parent); 472 473 return array( 474 'data' => $tree_js, 475 'msg' => lang('Catalog Tree Successfully taken!'), 476 'status' => 'ok' 477 ); 478 } 479 459 460 // Return status = ok, or else return generated message to the browser 461 if (!$msg) 462 { 463 return array( 464 'data' => $tree_js, 465 'msg' => lang('Catalog Tree Successfully taken!'), 466 'status' => 'ok' 467 ); 468 } 469 else 470 { 471 return array( 472 'data' => $tree_js, 473 'msg' => $msg, 474 'status' => 'error' 475 ); 476 477 } 478 } 479 480 480 /* function get_catalog_tree($level, $name = 'tree') 481 481 { … … 487 487 $parent = '0'; 488 488 $child = '0'; 489 489 490 490 if (!($tree = $this->bo->get_catalog_tree($level))) 491 491 { … … 498 498 $parent = substr($level, 0, $last_dot); 499 499 $child = substr($level, $last_dot+1, strlen($level)); 500 500 501 501 $tree_js = ''; 502 502 503 503 if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 504 504 { … … 506 506 } 507 507 } 508 508 509 509 $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 510 510 $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 511 511 512 512 $tree_js .= $this->convert_tree($tree, $name, $folderImageDir, $parent); 513 513 514 514 return $tree_js; 515 515 } 516 */ 517 516 */ 517 518 518 /*! 519 519 520 520 @function get_actual_catalog 521 521 @abstract Returns the actual selected Catalog … … 524 524 */ 525 525 function get_actual_catalog() 526 { 526 { 527 527 $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); 528 528 529 529 if ($level) 530 530 { … … 540 540 ); 541 541 } 542 542 543 543 /*! 544 544 545 545 @function get_cards_data 546 546 @abstract Returns the information that is placed on the cards 547 547 @author Raphael Derosso Pereira 548 548 549 549 @param string $letter The first letter to be searched 550 @param (int) $page The page to be taken 550 @param (int) $page The page to be taken 551 551 @param (str) $ids The ids to be taken in case of search 552 552 … … 556 556 function get_cards_data($letter, $page, $ids) 557 557 { 558 559 // It's an external catalog? 560 $external = $this->bo->is_external($this->page_info['actual_catalog']); 561 558 562 //echo $page."\n"; 559 563 if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or 560 ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 564 ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 561 565 $this->page_info['changed'])) 562 566 { 563 567 unset($ids); 564 568 $this->page_info['changed'] = false; 565 569 566 570 switch ($this->page_info['actual_catalog']['class']) 567 571 { … … 650 654 ); 651 655 } 652 656 653 657 $find_field[0] = array('contact.id_contact','contact.names_ordered'); 654 658 655 659 $find_other[0] = array( 656 660 //'offset' => (($page-1)*$this->page_info['n_cards']), … … 658 662 'order' => 'contact.names_ordered' 659 663 ); 660 664 661 665 break; 662 666 667 //case 'bo_external_ldap_catalog': 668 669 // break; 670 663 671 case 'bo_global_ldap_catalog': 664 672 $field_name = 'id_contact'; … … 671 679 'type' => 'iLIKE', 672 680 'value' => $letter !== 'all' ? $letter.'%' : '%' 673 ) 681 ), 682 /* 683 * Restrict the returned contacts in a "first letter" search 684 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, 685 * phpgwAccountVisible != -1 and objectClass = inetOrgPerson 686 */ 687 1 => array( 688 'field' => 'contact.object_class', 689 'type' => '=', 690 'value' => 'phpgwAccount' 691 ), 692 2 => array( 693 'field' => 'contact.account_status', 694 'type' => 'iLIKE', 695 'value' => '%' 696 ), 697 3 => array( 698 'field' => 'contact.account_visible', 699 'type' => '!=', 700 'value' => '-1' 701 ), 702 4 => array( 703 'field' => 'contact.object_class', 704 'type' => '=', 705 'value' => 'inetOrgPerson' 706 ), 674 707 ); 675 $find_restric[0][1] = array( 676 'type' => 'branch', 677 'value' => 'OR', 678 'sub_branch' => array( 679 0 => array( 680 'field' => 'contact.account_type', 681 'type' => '=', 682 'value' => 'u' 683 ), 684 /*1 => array( 685 'field' => 'contact.account_type', 686 'type' => '=', 687 'value' => 'g' 688 ),*/ 689 2 => array( 690 'field' => 'contact.account_type', 691 'type' => '=', 692 'value' => 'l' 708 // If not external catalog get only phpgwAccountType = u ou l 709 if (!$external) 710 { 711 $find_restric[0][5] = array( 712 'type' => 'branch', 713 'value' => 'OR', 714 'sub_branch' => array( 715 0 => array( 716 'field' => 'contact.account_type', 717 'type' => '=', 718 'value' => 'u' 719 ), 720 /*1 => array( 721 'field' => 'contact.account_type', 722 'type' => '=', 723 'value' => 'g' 724 ),*/ 725 2 => array( 726 'field' => 'contact.account_type', 727 'type' => '=', 728 'value' => 'l' 729 ) 693 730 ) 694 )695 );731 ); 732 } 696 733 } 697 734 else 698 735 { 699 736 $find_restric[0] = array( 737 /* 738 * Restrict the returned contacts in a "first number" search 739 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, 740 * phpgwAccountVisible != -1 and objectClass = inetOrgPerson 741 */ 700 742 0 => array( 743 'field' => 'contact.object_class', 744 'type' => '=', 745 'value' => 'phpgwAccount' 746 ), 747 1 => array( 748 'field' => 'contact.account_status', 749 'type' => 'iLIKE', 750 'value' => '%' 751 ), 752 2 => array( 753 'field' => 'contact.account_visible', 754 'type' => '!=', 755 'value' => '-1' 756 ), 757 3 => array( 758 'field' => 'contact.object_class', 759 'type' => '=', 760 'value' => 'inetOrgPerson' 761 ), 762 4 => array( 701 763 'type' => 'branch', 702 764 'value' => 'OR', … … 755 817 ), 756 818 ); 757 $find_restric[0][1] = array( 758 'type' => 'branch', 759 'value' => 'OR', 760 'sub_branch' => array( 761 0 => array( 762 'field' => 'contact.account_type', 763 'type' => '=', 764 'value' => 'u' 765 ), 766 /*1 => array( 767 'field' => 'contact.account_type', 768 'type' => '=', 769 'value' => 'g' 770 ),*/ 771 2 => array( 772 'field' => 'contact.account_type', 773 'type' => '=', 774 'value' => 'l' 819 // If not external catalog get only phpgwAccountType = u ou l 820 if (!$external) 821 { 822 $find_restric[0][5] = array( 823 'type' => 'branch', 824 'value' => 'OR', 825 'sub_branch' => array( 826 0 => array( 827 'field' => 'contact.account_type', 828 'type' => '=', 829 'value' => 'u' 830 ), 831 /*1 => array( 832 'field' => 'contact.account_type', 833 'type' => '=', 834 'value' => 'g' 835 ),*/ 836 2 => array( 837 'field' => 'contact.account_type', 838 'type' => '=', 839 'value' => 'l' 840 ) 775 841 ) 776 ) 777 ); 842 ); 843 } 844 778 845 } 779 780 $find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type'); 781 846 847 if (!$external) 848 { 849 // Get only this attributes: dn, cn, phpgwAccountType, objectClass, phpgwAccountStatus, phpghAccountVisible 850 // for non-external catalogs, used to restrict the attributes used in filters 851 $find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type', 852 'contact.object_class','contact.account_status','contact.account_visible'); 853 } 854 else 855 { 856 // Get only this attributes: dn, cn for external catalogs, 857 // used to restrict the attributes used in filters 858 $find_field[0] = array('contact.id_contact','contact.names_ordered'); 859 } 860 782 861 $find_other[0] = array( 783 862 //'offset' => (($page-1)*$this->page_info['n_cards']), … … 785 864 'order' => 'contact.names_ordered' 786 865 ); 787 866 788 867 break; 789 868 790 869 case 'bo_company_manager': 791 870 $field_name = 'id_company'; 792 871 793 872 $find_field[0] = array('company.id_company','company.company_name'); 794 873 795 874 $find_other[0] = array( 796 875 //'offset' => (($page-1)*$this->page_info['n_cards']), … … 798 877 'order' => 'company.company_name' 799 878 ); 800 879 801 880 $find_restric[0] = array( 802 881 0 => array( … … 806 885 ) 807 886 ); 808 887 809 888 break; 810 889 811 890 case 'bo_group_manager': 812 891 813 892 $field_name = 'id_group'; 814 893 815 894 if ($letter !== 'number') { 816 895 817 896 $find_restric[0] = array( 818 897 0 => array( … … 824 903 } 825 904 else { 826 905 827 906 $find_restric[0] = array( 828 907 0 => array( 829 908 'field' => 'group.title', 830 909 'type' => 'LIKE', 831 'value' => '0%' 910 'value' => '0%' 832 911 ) 833 ); 912 ); 834 913 } 835 914 836 915 array_push($find_restric[0], array( 837 916 'field' => 'group.owner', 838 917 'type' => '=', 839 'value' => $GLOBALS['phpgw_info']['user']['account_id'] 918 'value' => $GLOBALS['phpgw_info']['user']['account_id'] 840 919 ) 841 920 ); 842 843 $find_field[0] = array('group.id_group','group.title','group.short_name'); 921 922 $find_field[0] = array('group.id_group','group.title','group.short_name'); 844 923 $find_other[0] = array( 845 924 'order' => 'group.title' 846 925 ); 847 926 848 927 break; 849 928 850 929 case 'bo_catalog_group_catalog': 851 930 $this->page_info['actual_entries'] = false; 852 931 853 932 $this->page_info['actual_letter'] = $letter; 854 933 $this->page_info['actual_page'] = 0; 855 934 856 935 $this->save_session(); 857 936 $final[0] = 0; 858 937 $final[1] = $this -> typeContact; 859 echo serialize($final); 938 echo serialize($final); 860 939 return; 861 940 862 941 } 863 942 864 943 $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 865 944 $n_entries = count($result); 866 945 867 946 if ($n_entries) 868 947 { … … 878 957 { 879 958 $this->page_info['actual_entries'] = false; 880 959 881 960 $this->page_info['actual_letter'] = $letter; 882 961 $this->page_info['actual_page'] = 0; 883 884 $this->save_session(); 962 963 $this->save_session(); 885 964 $final[0] = 0; 886 965 $final[1] = $this -> typeContact; 887 echo serialize($final); 966 echo serialize($final); 888 967 return; 889 968 } … … 894 973 { 895 974 $this->page_info['actual_entries'][] = $value[$field_name]; 896 } 897 //print_r($this->page_info['actual_entries']);898 899 } 975 } 976 } 977 } 978 //************************************************************************* 900 979 else if ($letter === 'search') 901 980 { 902 if (!$ids and $this->page_info['actual_letter'] !== 'search') 903 { 981 //if (!$ids and $this->page_info['actual_letter'] !== 'search') 982 if (!$ids && !$this->last_search_ids) 983 { 984 error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); 904 985 $this->page_info['actual_entries'] = false; 905 986 906 987 $this->page_info['actual_letter'] = $letter; 907 988 $this->page_info['actual_page'] = 0; 908 989 909 990 $this->save_session(); 910 991 $final[0] = 0; 911 992 $final[1] = $this -> typeContact; 912 echo serialize($final); 993 echo serialize($final); 913 994 return; 914 995 } 915 else if ($ids) 916 { 996 else if ($ids['error']) 997 { 998 $this->page_info['actual_entries'] = false; 999 $this->page_info['actual_letter'] = $letter; 1000 $this->page_info['actual_page'] = 0; 1001 1002 $this->save_session(); 1003 $final[0] = 0; 1004 $final[1] = $this -> typeContact; 1005 $final['error'] = $ids['error']; 1006 echo serialize($final); 1007 return; 1008 } 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 917 1024 $this->page_info['actual_letter'] = $letter; 918 1025 $this->page_info['actual_entries'] = $ids; … … 931 1038 $page = $this->page_info['n_pages']; 932 1039 } 933 1040 934 1041 $final = array( 935 1042 0 => (int)$this->page_info['n_pages'], … … 943 1050 5 => 'cc_alias', 944 1051 6 => 'cc_id', 945 7 => 'cc_forwarding_address' 1052 7 => 'cc_forwarding_address', 1053 8 => 'cc_empNumber', 1054 9 => 'cc_department' 946 1055 ) 947 1056 ); 948 1057 949 1058 //echo 'Page: '.$page.'<br>'; 950 1059 $id_i = (($page-1)*$this->page_info['n_cards']); 951 1060 $id_f = $id_i + $this->page_info['n_cards']; 952 1061 $n_entries = count($this->page_info['actual_entries']); 953 1062 954 1063 //echo 'ID_I: '.$id_i.'<br>'; 955 1064 //echo 'ID_F: '.$id_f.'<br>'; 956 ///---------------- Corre ção Temporária PHP5 -----------------------///1065 ///---------------- Correᅵᅵo Temporï¿œria PHP5 -----------------------/// 957 1066 $ids = array(); 958 $array_temp = array(); 959 1067 $array_temp = array(); 1068 960 1069 foreach($this->page_info['actual_entries'] as $key=>$tmp){ 961 $array_temp[] = $tmp; 962 } 963 1070 $array_temp[] = $tmp; 1071 } 1072 964 1073 for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 965 1074 { 966 1075 $ids[] = $array_temp[$i]; 967 1076 } 968 1077 969 1078 /// Original 970 1079 //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) … … 973 1082 //} 974 1083 /// 975 1084 976 1085 $fields = $this->bo->catalog->get_fields(false); 977 1086 … … 985 1094 2 => 'cc_id', 986 1095 3 => 'cc_contacts' 987 ) 988 ); 989 1096 ) 1097 ); 1098 990 1099 $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 991 1100 992 1101 $i = 0; 993 1102 // contatos do grupo 994 $boGroups = CreateObject('contactcenter.bo_group'); 1103 $boGroups = CreateObject('contactcenter.bo_group'); 995 1104 $contacts = array(); 996 1105 foreach($groups as $group) { 997 1106 998 1107 $final[3][$i][0] = $group['title'] ? $group['title'] : 'none'; 999 $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; 1108 $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; 1000 1109 $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; 1001 1110 $contacts = $boGroups -> get_contacts_by_group($group['id_group']); 1002 1111 $final[3][$i][3] = $contacts; 1003 $i++; 1112 $i++; 1004 1113 } 1005 1114 1006 1115 $this->page_info['actual_letter'] = $letter; 1007 $this->page_info['actual_page'] = $page; 1008 1009 1116 $this->page_info['actual_page'] = $page; 1117 1118 1010 1119 $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 1011 1120 1012 1121 $final[5] = '<span class="link" onclick="'.$lnk_compose; 1013 $final[10] = 'groups'; 1014 $this->save_session(); 1122 $final[10] = 'groups'; 1123 $this->save_session(); 1015 1124 echo serialize($final); 1016 return; 1017 } 1018 1125 return; 1126 } 1127 1019 1128 $fields['photo'] = true; 1020 1129 $fields['names_ordered'] = true; … … 1023 1132 $fields['companies'] = 'default'; 1024 1133 $fields['connections'] = 'default'; 1134 1135 // ?aqui alterar a chamada desse mï¿œtodo para receber o base dn? 1025 1136 $contacts =& $this->bo->catalog->get_multiple_entries($ids,$fields); 1026 1027 1137 1028 1138 if (!is_array($contacts) or !count($contacts)) 1029 1139 { … … 1033 1143 return; 1034 1144 } 1035 1145 1036 1146 $i = 0; 1037 foreach($contacts as $contact) 1038 { 1039 $final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none'; 1040 $final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; 1041 $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 1042 1043 /* Select the correct Email and Telephone to be shown */ 1044 $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 1045 if (!is_array($preferences)) 1046 { 1047 $preferences['personCardEmail'] = 1; 1048 $preferences['personCardPhone'] = 2; 1049 } 1050 if ($contact['connections']) 1051 { 1052 $default_email_found = false; 1053 $default_phone_found = false; 1054 foreach($contact['connections'] as $conn_info) 1147 foreach($contacts as $index => $contact) 1148 { 1149 /* 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. 1152 */ 1153 if ($index !== 'error'){ 1154 $final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none'; 1155 $final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; 1156 $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 1157 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 1163 /* Select the correct Email and Telephone to be shown */ 1164 $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 1165 if (!is_array($preferences)) 1055 1166 { 1056 if ($conn_info['id_type'] == $preferences['personCardEmail'] and !$default_email_found) 1167 $preferences['personCardEmail'] = 1; 1168 $preferences['personCardPhone'] = 2; 1169 } 1170 if ($contact['connections']) 1171 { 1172 $default_email_found = false; 1173 $default_phone_found = false; 1174 foreach($contact['connections'] as $conn_info) 1057 1175 { 1058 if ($conn_info[' connection_is_default'])1176 if ($conn_info['id_type'] == $preferences['personCardEmail'] and !$default_email_found) 1059 1177 { 1060 $default_email_found = true; 1178 if ($conn_info['connection_is_default']) 1179 { 1180 $default_email_found = true; 1181 } 1182 $final[3][$i][4] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 1061 1183 } 1062 $final[3][$i][4] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 1063 } 1064 else if ($conn_info['id_type'] == $preferences['personCardPhone'] and !$default_phone_found) 1065 { 1066 if ($conn_info['connection_is_default']) 1184 else if ($conn_info['id_type'] == $preferences['personCardPhone'] and !$default_phone_found) 1067 1185 { 1068 $default_phone_found = true; 1186 if ($conn_info['connection_is_default']) 1187 { 1188 $default_phone_found = true; 1189 } 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) { 1192 $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>"; 1069 1193 } 1070 $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 1194 1195 $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 1196 } 1071 1197 } 1072 1198 } 1199 1200 if (!$final[3][$i][3]) 1201 { 1202 $final[3][$i][3] = 'none'; 1203 } 1204 1205 if (!$final[3][$i][4]) 1206 { 1207 $final[3][$i][4] = 'none'; 1208 } 1209 1210 $final[3][$i][5] = $contact['alias']?$contact['alias']:'none'; 1211 $final[3][$i][6] = $ids[$i]; 1212 1213 // If contact is a public list, then load the forwarding addresses. 1214 if($contact['account_type'][0] == 'l') 1215 $final[3][$i][7] = array(); 1216 1217 $final[4][$i] = $contact['photo'] ? 1 : 0; 1218 $i++; 1219 1073 1220 } 1074 1075 if (!$final[3][$i][3]) 1221 else 1076 1222 { 1077 $final[3][$i][3] = 'none';1223 // coloca mensagem de erro no vetor que retorna para o browser 1078 1224 } 1079 1080 if (!$final[3][$i][4]) 1081 { 1082 $final[3][$i][4] = 'none'; 1083 } 1084 1085 $final[3][$i][5] = $contact['alias']?$contact['alias']:'none'; 1086 $final[3][$i][6] = $ids[$i]; 1087 1088 // If contact is a public list, then load the forwarding addresses. 1089 if($contact['account_type'][0] == 'l') 1090 $final[3][$i][7] = array(); 1091 1092 $final[4][$i] = $contact['photo'] ? 1 : 0; 1093 $i++; 1094 } 1095 $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 1225 } 1226 $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 1096 1227 $final[5] = '<span class="link" onclick="'.$lnk_compose; 1097 1098 1228 1229 1099 1230 $this->page_info['actual_letter'] = $letter; 1100 1231 $this->page_info['actual_page'] = $page; 1101 1102 $this->save_session(); 1232 1233 $this->save_session(); 1234 1103 1235 echo serialize($final); 1104 1236 return; 1105 1237 } 1106 1238 1107 1239 $this->page_info['actual_letter'] = $letter; 1108 1240 $this->page_info['actual_page'] = $page; 1109 1241 1110 1242 $this->save_session(); 1111 1243 1112 1244 $final[0] = 0; 1113 1245 $final[1] = $this -> typeContact; 1114 1246 echo serialize($final); 1115 1247 } 1116 1248 1117 1249 /*! 1118 1250 1119 1251 @function get_group_data 1120 1252 @abstract Returns all the information of a given Group 1121 1253 @author Nilton Emilio Buhrer Neto 1122 1254 1123 1255 @param (integer) $id The id to get information 1124 1125 */ 1256 1257 */ 1126 1258 function get_group_data($id) 1127 1259 { … … 1129 1261 $fields = $this->bo->catalog->get_fields(true); 1130 1262 $data = $this->bo->catalog->get_single_entry($id,$fields); 1131 1132 if($id) { 1263 1264 if($id) { 1133 1265 // get All Contacts by group. 1134 $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id); 1135 } 1136 1266 $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id); 1267 } 1268 1137 1269 $boGroup = CreateObject('contactcenter.bo_group'); 1138 1139 $all_contacts = $boGroup->get_all_contacts(); 1140 1141 $contact_options = ""; 1142 if(count($all_contacts)) { 1143 foreach($all_contacts as $idx => $contact) { 1144 $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; 1145 } 1146 } 1147 $data['contact_list'] = $contact_options; 1148 $data['result'] = 'ok'; 1149 echo serialize($data); 1150 } 1151 1270 1271 $data['contact_list'] = $boGroup->get_all_contacts(); 1272 1273 $data['result'] = 'ok'; 1274 echo serialize($data); 1275 } 1276 1152 1277 /*! 1153 1278 1154 1279 @function get_full_data 1155 1280 @abstract Returns all the information of a given Entry 1156 1281 @author Raphael Derosso Pereira 1157 1282 1158 1283 @param (integer) $id The id to get information 1159 1284 1160 1285 */ 1161 1286 function get_full_data($id) 1162 1287 { 1163 1288 $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 1164 $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); 1289 $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); 1165 1290 $fields = $this->bo->catalog->get_fields(true); 1166 1291 $fields['photo'] = false; … … 1195 1320 } 1196 1321 $datecount = 0; 1197 1322 1198 1323 $data['result'] = 'ok'; 1199 1324 $data['cc_full_add_contact_id'] = $id; … … 1237 1362 1238 1363 /* Relations */ 1239 1364 1240 1365 echo serialize($data); 1241 1366 } … … 1274 1399 return; 1275 1400 } 1276 1401 1277 1402 echo 0; 1278 1403 } 1279 1404 1280 1405 /*! 1281 1406 1282 1407 @function quick_add 1283 1408 @abstract Adds a new Contact using the Quick Add interface 1284 1409 @author Raphael Derosso Pereira 1285 1410 1286 1411 @param string $sdata Serialized data 1287 1412 */ 1288 1413 function quick_add($sdata) 1289 1414 { 1290 1415 1291 1416 $sdata = str_replace('\\"', '"', $sdata); 1292 1417 $new_array = unserialize($sdata); 1293 1418 $tdata = array(); 1294 1419 1295 1420 foreach($new_array as $tmp) 1296 1421 $tdata[] = $tmp; 1297 1422 1298 1423 if (!$tdata) 1299 1424 { … … 1302 1427 'status' => 'abort' 1303 1428 )); 1304 1429 1305 1430 return; 1306 1431 } 1307 1308 // verifica se email j áexiste!1432 1433 // verifica se email jï¿œ existe! 1309 1434 $boGroup = CreateObject('contactcenter.bo_group'); 1310 1435 $contact = $boGroup->verify_contact($tdata[4]); 1311 1436 1312 1437 if($contact) 1313 { 1438 { 1314 1439 $str_contact = "\r\n - ".implode("\r\n - ",$contact); 1315 1440 1316 1441 echo serialize(array( 1317 1442 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), 1318 1443 'status' => 'alreadyExists' 1319 1444 )); 1320 1321 return; 1445 1446 return; 1322 1447 } 1323 1448 … … 1335 1460 1336 1461 if ($boPeople ->quick_add($data)) 1337 { 1462 { 1338 1463 $this->page_info['changed'] = true; 1339 1464 1340 1465 echo serialize(array( 1341 1466 'msg' => lang('Entry added with success!'), … … 1351 1476 } 1352 1477 1353 $this->save_session(); 1354 1478 $this->save_session(); 1479 1355 1480 } 1356 1481 1357 1482 /*! 1358 1483 1359 1484 @function add_group 1360 1485 @abstract Adds a new Group using the Add Group interface 1361 1486 @author Nilton Emilio Buhrer Neto 1362 1487 1363 1488 @param string $sdata Serialized data 1364 1489 */ … … 1368 1493 $tdata = unserialize($sdata); 1369 1494 $new_tdata = array(); 1370 1495 1371 1496 if (!$tdata) 1372 1497 { … … 1375 1500 'status' => 'abort' 1376 1501 )); 1377 1502 1378 1503 return; 1379 1504 } 1380 1505 1381 1506 foreach($tdata as $tmp) 1382 1507 $new_tdata[] = $tmp; 1383 1384 $data['title'] = $new_tdata[0]; 1508 1509 $data['title'] = $new_tdata[0]; 1385 1510 $data['contact_in_list'] = $new_tdata[1]; 1386 1511 $data['id_group'] = $new_tdata[2]; 1387 1512 1388 1513 $boGroup = CreateObject('contactcenter.bo_group_manager'); 1389 1514 $id = $boGroup -> add_group($data); 1390 1515 1391 1516 if ($id) 1392 1517 { 1393 1518 $this->page_info['changed'] = true; 1394 1519 1395 1520 echo serialize(array( 1396 1521 'msg' => lang('Entry added with success!'), … … 1410 1535 1411 1536 /*! 1412 1537 1413 1538 @function remove_group 1414 1539 @abstract Removes a group if the user has the right to do it 1415 @author Nilton Emilio Buhrer Neto 1540 @author Nilton Emilio Buhrer Neto 1416 1541 @param (integer) $id The id to be removed 1417 1542 1418 1543 */ 1419 1544 function remove_group($id) 1420 { 1421 $soGroup = CreateObject('contactcenter.so_group'); 1545 { 1546 $soGroup = CreateObject('contactcenter.so_group'); 1422 1547 $data = array ('id_group' => $id); 1423 1548 if($soGroup -> delete($data)) { … … 1425 1550 'msg' => lang('Removed Entry ID '.$id.'!'), 1426 1551 'status' => 'ok' 1427 )); 1552 )); 1428 1553 } 1429 1554 else { … … 1434 1559 } 1435 1560 1436 $this->save_session(); 1561 $this->save_session(); 1437 1562 } 1438 1563 1439 1564 1440 1565 function remove_all_entries (){ 1441 1566 1442 1567 $error = false; 1443 1568 $this->all_entries = $this->bo->catalog->get_all_entries_ids(); … … 1447 1572 if(!$result) { 1448 1573 $error = true; 1449 break; 1574 break; 1450 1575 } 1451 1576 } … … 1456 1581 'status' => 'ok' 1457 1582 )); 1458 } 1583 } 1459 1584 else { 1460 1585 echo serialize(array( … … 1468 1593 1469 1594 /*! 1470 1595 1471 1596 @function remove_entry 1472 1597 @abstract Removes an entry if the user has the right to do it 1473 1598 @author Raphael Derosso Pereira 1474 1599 1475 1600 @param (integer) $id The id to be removed 1476 1601 1477 1602 */ 1478 1603 function remove_entry ($id) … … 1483 1608 return; 1484 1609 } 1485 1610 1486 1611 $this->page_info['changed'] = true; 1487 1612 $result = $this->bo->catalog->remove_single_entry($id); 1488 1613 1489 1614 if ($result) 1490 1615 { … … 1493 1618 unset($this->page_info['actual_entries'][$pos]); 1494 1619 } 1495 1620 1496 1621 $temp = false; 1497 1622 reset($this->page_info['actual_entries']); … … 1500 1625 $temp[] = $t; 1501 1626 } 1502 1627 1503 1628 $this->page_info['actual_entries'] = $temp; 1504 1629 … … 1515 1640 )); 1516 1641 } 1517 1642 1518 1643 $this->save_session(); 1519 1644 } 1520 1645 1521 1646 1522 1647 /*! 1523 1648 1524 1649 @function post_full_add 1525 1650 @abstract Saves all the information altered/entered in the Full Add … … 1530 1655 function post_full_add() 1531 1656 { 1532 $data = $_POST['data']; 1533 // Exceptions!!! utf8 special chars. 1534 $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 1535 $data = unserialize(str_replace('\\"', '"', $data)); 1657 $data = unserialize(str_replace('\\"', '"', $_POST['data'])); 1536 1658 $this -> bo -> catalog = CreateObject('contactcenter.bo_people_catalog'); 1659 1660 // echo str_replace('\\"', '"', $_POST['data']); 1537 1661 1538 1662 if (!is_array($data)) … … 1558 1682 'status' => 'fatal' 1559 1683 )); 1560 1684 1561 1685 return; 1562 1686 } … … 1572 1696 $id_photo = '_new_'; 1573 1697 } 1574 1575 /* 1576 * Process Photo, if available 1698 1699 /* 1700 * Process Photo, if available 1577 1701 */ 1578 1702 $sleep_count = 0; … … 1591 1715 } 1592 1716 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 1593 1717 1594 1718 if (isset($this->page_info['photos'][$id_photo])) 1595 1719 { … … 1608 1732 $this->save_session(); 1609 1733 } 1610 1734 1611 1735 /* 1612 1736 * Arrange Date so it gets inserted correctly 1613 1737 */ 1614 1738 1615 1739 $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 1616 1740 1617 1741 $j = 0; 1618 1742 for ($i = 0; $i < 5; $i+=2) … … 1647 1771 continue; 1648 1772 } 1649 1773 1650 1774 switch($field) 1651 1775 { … … 1659 1783 /* Do Nothing. This is just to make sure no invalid field is passed */ 1660 1784 break; 1661 1785 1662 1786 case 'id_status': 1663 1787 case 'id_prefix': … … 1668 1792 } 1669 1793 break; 1670 1794 1671 1795 case 'birthdate_0': 1672 1796 case 'birthdate_1': 1673 1797 case 'birthdate_2': 1674 1798 1675 1799 switch($date[$datecount]['digit']) 1676 1800 { … … 1694 1818 break; 1695 1819 } 1696 1820 1697 1821 if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 1698 1822 { … … 1703 1827 return; 1704 1828 } 1705 1829 1706 1830 $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 1707 1831 break; … … 1726 1850 { 1727 1851 $index = 'address'.$type; 1728 1852 1729 1853 $id_state = $this->bo->catalog->add_state($state_info); 1730 1854 $data['addresses'][$index]['id_state'] = $id_state; … … 1744 1868 { 1745 1869 $index = 'address'.$type; 1746 1870 1747 1871 $id_city = $this->bo->catalog->add_city($city_info); 1748 1872 $data['addresses'][$index]['id_city'] = $id_city; … … 1785 1909 ); 1786 1910 } 1787 1911 1788 1912 eval($code); 1789 1913 … … 1801 1925 1802 1926 /*! 1803 1927 1804 1928 @function post_photo 1805 1929 @abstract Wrapper to post a photo without reload a page. … … 1811 1935 //print_r($_FILES); 1812 1936 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); 1813 1937 1814 1938 if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) 1815 1939 { 1816 1940 $this->page_info['photos'][$id]['status'] = 'no_upload'; 1817 1941 $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); 1818 1942 1819 1943 $this->save_session(); 1820 1944 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); … … 1826 1950 $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; 1827 1951 $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.'); 1828 1952 1829 1953 $this->save_session(); 1830 1954 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); … … 1852 1976 return; 1853 1977 } 1854 1978 1855 1979 switch($_FILES['cc_pd_photo']['type']) 1856 1980 { … … 1882 2006 1883 2007 default: 1884 2008 1885 2009 $this->page_info['photos'][$id]['status'] = 'invalid_image'; 1886 2010 $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); … … 1895 2019 $this->page_info['photos'][$id]['status'] = 'invalid_file'; 1896 2020 $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 1897 2021 1898 2022 $this->save_session(); 1899 2023 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 1900 2024 return; 1901 2025 } 1902 2026 1903 2027 $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); 1904 2028 $dst_img = imagecreatetruecolor(60, 80); 1905 2029 1906 2030 if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) 1907 2031 { 1908 2032 $this->page_info['photos'][$id]['status'] = 'invalid_file'; 1909 2033 $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 1910 2034 1911 2035 $this->save_session(); 1912 2036 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 1913 2037 return; 1914 2038 } 1915 2039 1916 2040 ob_start(); 1917 2041 imagepng($dst_img); … … 1923 2047 1924 2048 $this->save_session(); 1925 2049 1926 2050 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 1927 2051 … … 1944 2068 $fields = $this->bo->catalog->get_fields(false); 1945 2069 $fields['photo'] = true; 1946 2070 1947 2071 $contact = $this->bo->catalog->get_single_entry($id, $fields); 1948 2072 … … 1953 2077 return; 1954 2078 } 1955 2079 1956 2080 header('Content-type: image/jpeg'); 1957 2081 $photo = imagecreatefromstring ($contact['photo']); … … 1965 2089 return; 1966 2090 } 1967 2091 1968 2092 /*! 1969 2093 1970 2094 @function get_states 1971 2095 @abstract Echos a serialized array containing all the states for the given country … … 1989 2113 return; 1990 2114 } 1991 2115 1992 2116 $result = array( 1993 2117 'msg' => lang('States Successfully retrieved!'), 1994 2118 'status' => 'ok' 1995 2119 ); 1996 2120 1997 2121 foreach ($states as $state_info) 1998 2122 { … … 2033 2157 return; 2034 2158 } 2035 2159 2036 2160 $result = array( 2037 2161 'msg' => lang('Cities Successfully retrieved!'), 2038 2162 'status' => 'ok' 2039 2163 ); 2040 2164 2041 2165 foreach ($cities as $city_info) 2042 2166 { 2043 2167 $result['data'][$city_info['id_city']] = $city_info['name']; 2044 2168 } 2045 2169 2046 2170 echo serialize($result); 2047 2171 } … … 2049 2173 2050 2174 /*! 2051 2175 2052 2176 @function search 2053 2177 @abstract Echos a serialized array containing the IDs 2054 2178 of the entries that matches the search argument 2055 2179 @author Raphael Derosso Pereira 2180 @author Mï¿œrio Cï¿œsar Kolling (external catalogs) 2056 2181 2057 2182 @param string $str_data A serialized array with two informations: … … 2065 2190 { 2066 2191 $data = unserialize($str_data); 2192 // It's an external catalog? 2193 $external = $this->bo->is_external($this->page_info['actual_catalog']); 2067 2194 2068 2195 if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 2069 2196 { 2070 echo serialize(array( 2071 'msg' => lang('Invalid parameters'), 2072 'status' => 'abort' 2073 )); 2074 2075 return; 2197 //echo serialize(array( 2198 // 'msg' => lang('Invalid parameters'), 2199 // 'status' => 'abort' 2200 //)); 2201 2202 return array('error' => lang('Invalid parameters')); 2203 } 2204 2205 /* 2206 * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly 2207 */ 2208 // Support search parameters with accentuation 2209 if ($this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 2210 $this->page_info['actual_catalog']['class'] != 'bo_group_manager') 2211 { 2212 2213 $data['search_for'] = utf8_encode($data['search_for']); 2076 2214 } 2077 2215 … … 2094 2232 if (!is_array($names)) 2095 2233 { 2096 echo serialize(array( 2097 'msg' => lang('Invalid Search Parameter'), 2098 'status' => 'abort' 2099 )); 2100 2101 return; 2102 } 2103 2234 //echo serialize(array( 2235 // 'msg' => lang('Invalid Search Parameter'), 2236 // 'status' => 'abort' 2237 //)); 2238 2239 return array('error' => lang('Invalid Search Parameter')); 2240 } 2241 2242 if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 2243 $this->page_info['actual_catalog']['class'] != 'bo_group_manager') 2244 { 2245 /* 2246 * Restrict the returned contacts search to objectClass = phpgwAccount, 2247 * must have attibute phpgwAccountStatus, phpgwAccountVisible != -1 and 2248 * objectClass = inetOrgPerson 2249 */ 2250 $rules = array( 2251 0 => array( 2252 'field' => 'contact.object_class', 2253 'type' => '=', 2254 'value' => 'phpgwAccount' 2255 ), 2256 1 => array( 2257 'field' => 'contact.account_status', 2258 'type' => 'iLIKE', 2259 'value' => '%' 2260 ), 2261 2 => array( 2262 'field' => 'contact.account_visible', 2263 'type' => '!=', 2264 'value' => '-1' 2265 ), 2266 3 => array( 2267 'field' => 'contact.object_class', 2268 'type' => '=', 2269 'value' => 'inetOrgPerson' 2270 ) 2271 ); 2272 } 2273 2104 2274 foreach ($names as $name) 2105 2275 { … … 2114 2284 } 2115 2285 } 2116 2117 /* 2118 $catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 2119 2120 if ($catalog['class'] === 'bo_people_catalog') 2121 { 2122 array_push($rules, array( 2123 'field' => 'contact.id_owner', 2124 'type' => '=', 2125 'value' => $GLOBALS['phpgw_info']['user']['account_id'] 2126 )); 2127 } 2128 */ 2129 2130 $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 2286 2287 if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || 2288 $this->page_info['actual_catalog']['class'] == 'bo_group_manager') 2289 { 2290 // Get only this attributes: dn, cn for external catalogs, 2291 // used to restrict the attributes used in filters 2292 $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 2293 } 2294 else 2295 { 2296 // Get only this attributes: dn, cn, phpgwAccountType, objectClass, phpgwAccountStatus, phpghAccountVisible 2297 // for non-external catalogs, used to restrict the attributes used in filters 2298 $ids = $this->bo->find(array( 2299 $data['fields']['id'], 2300 $data['fields']['search'], 2301 'contact.object_class', 2302 'contact.account_status', 2303 'contact.account_visible' 2304 ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 2305 } 2131 2306 2132 2307 if (!is_array($ids) || !count($ids)) 2133 2308 { 2134 echo serialize(array( 2135 'msg' => lang('No Entries Found!'), 2136 'status' => 'empty' 2137 )); 2138 2139 return; 2309 //echo serialize(array( 2310 // 'msg' => lang('No Entries Found!'), 2311 // 'status' => 'empty' 2312 //)); 2313 2314 $this->last_search_ids = null; 2315 $this->save_session(); 2316 return null; 2140 2317 } 2141 2318 … … 2145 2322 foreach ($ids as $e_info) 2146 2323 { 2324 //$ids_f[] = "base64::" . base64_encode($e_info[$id_field]); 2147 2325 $ids_f[] = $e_info[$id_field]; 2148 2326 } 2149 2150 echo serialize(array( 2151 'data' => $ids_f, 2152 'msg' => lang('Found %1 Entries', count($ids)), 2153 'status' => 'ok' 2154 )); 2327 2328 //error_log("ids_f serializados: " . serialize($ids_f) . "\n", 3, '/var/www/teste.log'); 2329 2330 //return serialize($ids_f); 2331 return $ids_f; 2332 2333 //echo serialize(array( 2334 // 'data' => $ids_f, 2335 // 'msg' => lang('Found %1 Entries', count($ids)), 2336 // 'status' => 'ok' 2337 //)); 2155 2338 } 2156 2339 … … 2162 2345 @author Raphael Derosso Pereira 2163 2346 2164 @param array str_data A serialized array containing the ID's of the entries 2347 @param array str_data A serialized array containing the ID's of the entries 2165 2348 to be taken, the fields to be taken and the rules to be used on the 2166 2349 retrieval: … … 2175 2358 { 2176 2359 $data = unserialize($str_data); 2177 2360 2178 2361 if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) 2179 2362 { … … 2185 2368 2186 2369 $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); 2187 2370 2188 2371 if (!is_array($entries) or !count($entries)) 2189 2372 { … … 2204 2387 2205 2388 @function get_all_entries 2206 @abstract Returns the specified fields for all catalog's entries 2389 @abstract Returns the specified fields for all catalog's entries 2207 2390 in the default CC UI format 2208 2391 @author Raphael Derosso Pereira 2209 2392 2210 @params array str_data A serialized array containing the fields to 2393 @params array str_data A serialized array containing the fields to 2211 2394 be grabbed, the maximum number of entries to be returned and a 2212 2395 boolean specifying if the calls refers to a new grab or to an … … 2217 2400 { 2218 2401 $data = unserialize($str_data); 2219 2220 if (!is_array($data) or 2221 !count($data) or 2222 !count($data['fields']) or 2402 2403 if (!is_array($data) or 2404 !count($data) or 2405 !count($data['fields']) or 2223 2406 !$data['maxlength'] or 2224 2407 (!$data['new'] and !$data['offset'])) … … 2246 2429 $data['offset'] = 0; 2247 2430 } 2248 2431 2249 2432 if ($data['maxlength'] != -1) 2250 2433 { … … 2257 2440 2258 2441 $prefs = ExecMethod('contactcenter.ui_preferences.get_preferences'); 2259 2442 2260 2443 $jsCode = array(); 2261 2444 $count = 0; … … 2267 2450 } 2268 2451 2269 if($this-> typeContact == 'groups') { 2270 2452 if($this-> typeContact == 'groups') { 2453 2271 2454 foreach ($each as $field => $value) { 2272 2455 2273 2456 if ($field === 'title') { 2274 2457 $optionName = '\\"'.$value.'\\"'; 2275 2458 2276 2459 } 2277 2460 else if ($field === 'short_name') { 2278 2461 2279 2462 $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; 2280 $count++; 2281 } 2463 $count++; 2464 } 2282 2465 } 2283 2466 } 2284 2285 else { 2467 2468 else { 2286 2469 foreach ($each as $field => $value) { 2287 2470 if ($field === 'names_ordered') { … … 2291 2474 } 2292 2475 else if ($field === 'connections') { 2293 2476 2294 2477 foreach ($value as $connection) { 2295 2478 if ($connection['id_type'] == $prefs['personCardEmail']) { … … 2304 2487 2305 2488 $jsCodeFinal = implode("\n", $jsCode); 2306 2489 2307 2490 $nEntries = count($result); 2308 2491 2309 2492 if (!$nEntries) 2310 2493 { … … 2324 2507 ); 2325 2508 } 2326 2509 2327 2510 /*********************************************************************\ 2328 2511 * Auxiliar Methods * … … 2330 2513 2331 2514 /*! 2332 2515 2333 2516 @function save_session 2334 2517 @abstract Saves the data on the session 2335 2518 @author Raphael Derosso Pereira 2336 2519 2337 2520 */ 2338 2521 function save_session() … … 2340 2523 $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter',$this->page_info); 2341 2524 $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); 2342 2526 } 2343 2527 2344 2528 /*! 2345 2529 2346 2530 @function convert_tree 2347 2531 @abstract Converts the tree array in the BO format to a JS tree array compatible 2348 2532 with the one available in eGW 2349 2533 @author Raphael Derosso Pereira 2350 2534 2351 2535 @param (array) $tree The tree in the BO format 2352 2536 @param (string) $name The tree name … … 2382 2566 'caption' => $value['name'] 2383 2567 ); 2384 2568 2385 2569 switch($value['type']) 2386 2570 { … … 2405 2589 $this->bo->catalog->src_info = $ldap->srcs[1]; 2406 2590 } 2407 2408 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 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); 2409 2593 $dn=$this->bo->catalog->src_info['dn']; 2410 2594 $justThese = array("givenname","givenname","sn","telephonenumber","mail"); 2411 $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 2412 $info = ldap_get_entries($ds, $sr); 2595 $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 2596 $info = ldap_get_entries($ds, $sr); 2413 2597 for($z = 0; $z < 5; $z++) { 2414 $participant = $info[0][$justThese[$z]]; 2598 $participant = $info[0][$justThese[$z]]; 2415 2599 array_push($array_participants, $participant); 2416 2600 } … … 2418 2602 ldap_close($ds); 2419 2603 echo serialize($array_participants); 2420 } 2421 2422 function get_catalog_participants_list($id) 2604 } 2605 2606 function get_catalog_participants_list($id) 2423 2607 { 2424 2425 $fields = $this->bo->catalog->get_fields(false); 2608 2609 $fields = $this->bo->catalog->get_fields(false); 2426 2610 $fields['names_ordered'] = true; 2427 $fields['mail_forwarding_address'] = true; 2428 $contact = $this->bo->catalog->get_single_entry($id,$fields); 2429 2611 $fields['mail_forwarding_address'] = true; 2612 $contact = $this->bo->catalog->get_single_entry($id,$fields); 2613 2430 2614 $array_participants = array(); 2431 2615 $array_emails = array(); 2432 2616 2433 2617 $filter = null; 2434 for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 2618 for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 2435 2619 if(strstr($contact['mail_forwarding_address'][$z],'@')) { 2436 2620 $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; 2437 2621 $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; 2438 } 2439 else 2622 } 2623 else 2440 2624 $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; 2441 } 2442 2625 } 2626 2443 2627 if($filter) { 2444 $filter = "(|".$filter.")"; 2628 $filter = "(|".$filter.")"; 2445 2629 if(!$this->bo->catalog->src_info) { 2446 2630 $ldap = CreateObject('contactcenter.bo_ldap_manager'); 2447 2631 $this->bo->catalog->src_info = $ldap->srcs[1]; 2448 2632 } 2449 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 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); 2450 2634 $dn=$this->bo->catalog->src_info['dn']; 2451 2635 $justThese = array("cn","mail"); 2452 $sr = ldap_search($ds,$dn, $filter,$justThese); 2453 $info = ldap_get_entries($ds, $sr); 2636 $sr = ldap_search($ds,$dn, $filter,$justThese); 2637 $info = ldap_get_entries($ds, $sr); 2454 2638 for($z = 0; $z < $info['count']; $z++) { 2455 2639 $participant = '<font color=\'DARKBLUE\'> "'.$info[$z]['cn'][0].'" <'.$info[$z]['mail'][0].'></font><br>'; 2456 $array_emails[$info[$z]['mail'][0]] = null; 2457 array_push($array_participants, $participant); 2458 } 2459 2640 $array_emails[$info[$z]['mail'][0]] = null; 2641 array_push($array_participants, $participant); 2642 } 2643 2460 2644 foreach($array_emails as $index => $email) 2461 if($email) 2462 array_push($array_participants, " ".$email."<br>"); 2463 2645 if($email) 2646 array_push($array_participants, " ".$email."<br>"); 2647 2464 2648 ldap_close($ds); 2465 2649 } 2466 2650 sort($array_participants); 2467 $innerHTML = ''; 2651 $innerHTML = ''; 2468 2652 foreach($array_participants as $index => $participant){ 2469 2653 $innerHTML .= $participant; 2470 2654 } 2471 $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 2655 $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 2472 2656 echo serialize($return); 2473 } 2474 2657 } 2658 2475 2659 function export_contacts($typeExport){ 2476 2660 … … 2483 2667 2484 2668 2485 // Essa itera ção transforma uma esturuta com contatos redundantes e separados por email ou tel.2669 // Essa iteraᅵᅵo transforma uma esturuta com contatos redundantes e separados por email ou tel. 2486 2670 // em outra com apenas 1 elemento pra cada contato 2487 2671 $i=0; … … 2494 2678 $all_contacts[$i]['phone']=$object['connection_value']; 2495 2679 } 2496 2680 2497 2681 switch($typeExport) { 2498 2682 2499 2683 case 'outlook_en': 2500 2684 $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". 2501 "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 2685 "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 2502 2686 foreach($all_contacts as $index => $object){ 2503 2687 $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 2504 2688 } 2505 2689 break; 2506 2690 2507 2691 case 'outlook_pt-BR': 2508 $streamBuffer = "Nome;End. de email;Endere ço residencial;".2509 "Cidade do endere ço residencial;CEP do endereço residencial;".2510 "Estado;Pa ís/região do endereço residencial;Telefone residencial;".2511 "Rua do endere ço comercial;Cidade do endereço comercial;".2512 "CEP do endere ço comercial;Estado do endereço comercial;".2513 "Pa ís/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";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"; 2514 2698 foreach($all_contacts as $index => $object){ 2515 2699 $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 2516 2700 } 2517 2701 break; 2518 2702 2519 2703 case 'outlook2000_pt-BR': 2520 2704 $streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". 2521 "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endere ço comercial\",\"Rua do endereço comercial 2\",".2522 "\"Rua do endere ço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",".2523 "\"CEP do endere ço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",".2524 "\"Rua residencial 3\",\"Cidade do endere ço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",".2525 "\"Outro endere ço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",".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\",". 2526 2710 "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 2527 2711 "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 2528 2712 "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". 2529 "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Anivers ário\",\"Anotações\",\"Caixa postal\",\"Categorias\",".2530 "\"C ódigo da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",".2531 "\"Nome de exibi ção do correio eletr.\",\"Endereço de correio eletrônico 2\",".2532 "\"Nome de exibi ção do correio eletr.2\",\"Endereço de correio eletrônico 3\",".2533 "\"Nome de exibi ção do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",".2534 "\"Filhos\",\"Hobby\",\"Idioma\",\"Indica ção\",\"Informações para cobrança\",\"Iniciais\",\"Local\",".2535 "\"Nome do assistente\",\"Nome do gerenciador\",\"P ágina da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",".2536 "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profiss ão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",".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\",". 2537 2721 "\"Sexo\"\r\n"; 2538 2722 foreach($all_contacts as $index => $object){ … … 2540 2724 } 2541 2725 break; 2542 2726 2543 2727 case 'outlook2000_en': 2544 2728 $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". … … 2556 2740 } 2557 2741 break; 2558 2742 2559 2743 case 'thunderbird': 2560 $streamBuffer = "\n"; 2744 $streamBuffer = "\n"; 2561 2745 foreach($all_contacts as $index => $object){ 2562 2746 $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 2563 2747 } 2564 2748 break; 2565 2566 case 'expresso':2749 2750 default: 2567 2751 $streamBuffer = "Nome,Email,Telefone\r\n"; 2568 2752 foreach($all_contacts as $index => $object){ … … 2570 2754 } 2571 2755 break; 2572 2756 2573 2757 } 2574 2758 … … 2578 2762 if(!$f) 2579 2763 echo null; 2580 2764 2581 2765 fputs($f,$streamBuffer); 2582 2766 fclose($f); … … 2585 2769 } 2586 2770 2587 // Get the csv field and put into array, from php.net2588 function parse_line($input_text, $delimiter = ',', $text_qualifier = '"') {2589 $text = trim($input_text);2590 if(is_string($delimiter) && is_string($text_qualifier)) {2591 $re_d = '\x' . dechex(ord($delimiter)); //format for regexp2592 $re_tq = '\x' . dechex(ord($text_qualifier)); //format for regexp2593 2594 $fields = array();2595 $field_num = 0;2596 while(strlen($text) > 0) {2597 if($text{0} == $text_qualifier) {2598 preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches);2599 2600 $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]);2601 $text = trim($matches[2]);2602 2603 $fields[$field_num++] = $value;2604 } else {2605 preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches);2606 2607 $value = $matches[1];2608 $text = trim($matches[2]);2609 2610 $fields[$field_num++] = $value;2611 }2612 }2613 return $fields;2614 } else2615 return false;2616 }2617 2771 2618 2772 function import_contacts($typeImport){ 2619 2773 2620 if($file = $_SESSION['contactcenter']['importCSV']) { 2621 unset($_SESSION['contactcenter']['importCSV']); 2774 $delim = ($typeImport == 'outlook' ? ';' : ','); 2775 2776 if($file = $_SESSION['contactcenter']['importCSV']) { 2777 unset($_SESSION['contactcenter']['importCSV']); 2622 2778 $len = filesize($file); 2623 2779 $count = 0; 2624 2780 $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); 2625 2781 $handle = @fopen($file, "r") or die(serialize($return['error'] = true)); 2626 2627 $input_header = fgets($handle);2628 if ($typeImport == 'outlook')2629 $delim = ';';2630 else if ($typeImport == 'auto')2631 $delim = strstr($input_header,',') ? ',' : ';';2632 else2633 $delim = ',';2634 $csv_header = $this->parse_line($input_header,$delim);2635 $firstContact = fgets($handle);2636 preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv2637 rewind($handle);2638 2639 2782 $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); 2640 2783 if(count($header) < 2 || count($header) > 100) { … … 2644 2787 return; 2645 2788 } 2646 2647 if ($matches[0][strlen($matches[0])-1] == ';') 2648 $delim = ';'; 2649 2650 $boGroup = CreateObject('contactcenter.bo_group'); 2651 $boPeople = CreateObject('contactcenter.bo_people_catalog'); 2789 2790 $boGroup = CreateObject('contactcenter.bo_group'); 2791 $boPeople = CreateObject('contactcenter.bo_people_catalog'); 2792 2652 2793 switch($typeImport){ 2653 2794 case 'outlook2000': … … 2666 2807 $phone_pos=7; 2667 2808 break; 2668 case 'expresso':2809 default: 2669 2810 $name_pos=0; 2670 2811 $email_pos=1; 2671 2812 $phone_pos=2; 2672 break; 2673 default: 2674 foreach($csv_header as $index => $fieldName) 2675 { 2676 switch($fieldName){ 2677 case 'Name': 2678 case 'Nome': 2679 case 'First Name': 2680 $name_pos = $index; 2681 break; 2682 case 'E-mail': 2683 case 'Email': 2684 case 'E-mail Address': 2685 case 'Endereço de correio eletrônico': 2686 case 'End. de email': 2687 $email_pos = $index; 2688 break; 2689 case 'Home Phone': 2690 case 'Phone': 2691 case 'Telefone': 2692 case 'Telefone principal': 2693 case 'Telefone comercial': 2694 $phone_pos = $index; 2695 break; 2696 } 2697 } 2698 break; 2699 } 2700 2813 } 2701 2814 2702 2815 while (($data = fgetcsv($handle, $len, $delim))) { 2816 2703 2817 foreach ($header as $key=>$heading) 2704 2818 $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 2705 2819 2706 2820 $sdata = array(); 2707 2821 $full_name = trim($row[$header[$name_pos]]); … … 2717 2831 $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 2718 2832 $sdata['connections']['default_phone']['connection_value'] = $phone; 2719 2720 // verifica se email j áexiste!2833 2834 // verifica se email jï¿œ existe! 2721 2835 $contact = $boGroup->verify_contact($email); 2722 2836 2723 $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];2724 2837 if($contact){ 2725 2838 $return['_existing']++; 2726 } 2839 } 2727 2840 else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 2728 2841 $return['_failure']++; 2729 $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>";2730 2842 } 2731 else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){ 2732 $return['_failure']++; 2733 $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 2843 else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){ 2844 $return['_failure']++; 2734 2845 } 2735 2846 else 2736 2847 $return['_new']++; 2737 } 2848 } 2738 2849 fclose($handle); 2739 2850 unlink($file); … … 2749 2860 $new = null; 2750 2861 $code = null; 2751 2862 2752 2863 if ($parent === '0') 2753 2864 { … … 2755 2866 $code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n"; 2756 2867 } 2757 2868 2758 2869 foreach ($tree as $id => $value) 2759 2870 { … … 2761 2872 2762 2873 switch ($value['type']) 2763 { 2874 { 2764 2875 case 'unknown': 2765 $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"; 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"; 2766 2877 break; 2767 2878 2768 2879 case 'catalog_group': 2769 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n"; 2880 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n"; 2770 2881 $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 2771 2882 break; … … 2776 2887 $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 2777 2888 break; 2778 2889 2779 2890 case 'catalog': 2780 2891 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n"; 2781 2782 } 2783 } 2784 2892 2893 } 2894 } 2895 2785 2896 return $code; 2786 2897 }
Note: See TracChangeset
for help on using the changeset viewer.