Changeset 3630 for branches/2.2/mobile/inc
- Timestamp:
- 12/23/10 16:42:45 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/mobile/inc/class.ui_mobilecc.inc.php
r3629 r3630 18 18 'change_letter' => true, 19 19 'choose_contact' => true, 20 'init_cc' => true 20 'init_cc' => true, 21 'contact_view' => true, 22 'contact_add_edit' => true, 23 'contact_add' => true, 24 'contact_edit' => true 21 25 ); 22 26 var $template; … … 250 254 if(!empty($contacts)) { 251 255 foreach($contacts as $id => $contact) { 252 256 253 257 $p->set_var('show_check',$show_checkbox?"inline":"none"); 258 $p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par"); 259 260 if($contact["catalog"]!=="bo_group_manager") { //Contatos 261 $id=strpos($contact["catalog"],"ldap")===false?$contact["id_contact"]:$id; 254 262 $p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par"); 255 263 … … 284 292 continue; 285 293 294 $p->set_var('show_tel',$vtel); 295 $p->set_var('email',$mail); 296 $p->set_var('tel',$tel); 297 $p->set_var('contact_id',$id); 298 $p->set_var('lang_tel',lang("tel")); 299 $p->set_var('contact_name',$functions->strach_string($cn,17)); 300 301 $block = "row_contacts"; 302 } 303 else { //Grupos 304 $id=$contact["id_group"]; 305 $mail = $cn = $contact["title"]; 306 $p->set_var('group_id',$contact["id_group"]); 307 $p->set_var('group_name',$contact["title"]); 308 $block = "row_groups"; 309 } 310 311 if($request_from==null) { 312 $p->set_var('lang_see_details',strtoupper(lang("see details"))); 313 $cat_encode = urlencode($contact["catalog"]); 314 $p->set_var('href_details',"ui_mobilecc.contact_view&id=$id&catalog=".urlencode($contact["catalog"])); 315 } 316 else { 317 $p->set_var('lang_see_details',strtoupper(lang("select"))); 318 $p->set_var("href_details","ui_mobilemail.add_recipient&mail=$mail&cn=$cn"); 319 } 320 321 $p->fp('rows',$block,True); 286 322 $p->set_var('show_tel',$vtel); 287 323 $p->set_var('email',$mail); … … 321 357 return $p->fp('out','rows_contacts'); 322 358 } 359 360 /** 361 * Show details from contact selected 362 * 363 * @param $id int 364 * @param $catalog String 365 * @return $contact 366 */ 367 function contact_view($params) { // bo_people_catalog, bo_global_ldap_catalog 368 369 if ( empty($params['id']) || empty($params['catalog']) ){ 370 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.init_cc'); 371 } 372 373 $this->template->set_file( 374 Array( 375 'cc_v' => 'contact_view.tpl' 376 ) 377 ); 378 379 $this->template->set_block('cc_v','body'); 380 $this->template->set_block('cc_v','people'); 381 $this->template->set_block('cc_v','people_ldap'); 382 $this->template->set_block('cc_v','group'); 383 $this->template->set_block('cc_v','group_row'); 384 $this->template->set_block('cc_v','buttom'); 385 386 switch ($params['catalog']){ 387 388 case 'bo_shared_people_manager'; 389 case 'bo_people_catalog': 390 391 $this->bo->set_catalog($params['catalog']); 392 393 $result = $this->bo->bo->get_single_entry($params['id'], array("given_names"=>true,"names_ordered"=>true,"alias"=>true,"family_names"=>true,"companies"=>true,"relations"=>true,"connections"=>true)); 394 395 asort($result['connections']); 396 397 $this->template->set_var('photo', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo&id='.$id); 398 $this->template->set_var('id',$params['id']); 399 $this->template->set_var('catalog',$params['catalog']); 400 401 $this->template->set_var('cc_name',$result['names_ordered']); 402 $this->template->set_var('lang_title_alias',lang("Alias")); 403 $this->template->set_var('lang_alias',$result['alias']); 404 405 $this->template->set_var('lang_title_name',lang("Name")); 406 $this->template->set_var('lang_name',$result['given_names']); 407 408 $this->template->set_var('lang_title_lastname',lang("Family Names")); 409 $this->template->set_var('lang_lastname',$result['family_names']); 410 411 $email_to = ""; 412 $var_phone = ""; 413 $var_email = ""; 414 foreach($result['connections'] as $conn): 415 if ( $conn['id_type'] == 1 ){ 416 if ( !empty($var_email) ) 417 $var_email .= ' | '; 418 $var_email .= $conn['connection_value']; 419 420 if ( empty($email_to) ) 421 $email_to = $var_email; 422 423 }else if ($conn['id_type'] == 2){ 424 if ( !empty($var_phone)) 425 $var_phone .= ' | '; 426 $var_phone .= $conn['connection_value']; 427 } 428 endforeach; 429 430 $this->template->set_var('email_to', $email_to); 431 432 $this->template->set_var('lang_title_email',lang("Email")); 433 $this->template->set_var('lang_email',$var_email); 434 435 $this->template->set_var('lang_title_phone',lang("Phone")); 436 $this->template->set_var('lang_phone',$var_phone); 437 438 $this->template->set_var('lang_edit',lang("edit")); 439 440 $this->template->parse("row_body","people"); 441 442 if ($params['catalog'] == 'bo_people_catalog') 443 $this->template->parse("buttom_editar","buttom"); 444 445 break; 446 447 case 'bo_group_manager': 448 449 $this->bo->set_catalog($params['catalog']); 450 $result = $this->bo->bo->get_single_entry($params['id'], array("id_group"=>true,"title"=>true,"short_name"=>true)); 451 $data = $this->bo->bo->get_contacts_by_group($params['id']); 452 453 $this->template->set_var('gr_name', $result['title']); 454 $this->template->set_var('email_to', '<'.$result['short_name'].'>'); 455 456 $this->template->set_var('lang_title_name',lang("Name")); 457 $this->template->set_var('lang_title_email',lang("Email")); 458 459 foreach($data as $dados){ 460 $this->template->set_var('lang_name', $dados['names_ordered']); 461 $this->template->set_var('lang_email', $dados['connection_value']); 462 463 $this->template->fp('group_rows','group_row',True); 464 } 465 466 $this->template->parse("row_body","group"); 467 break; 468 469 default: 470 471 if(strpos($params['catalog'],'bo_global_ldap_catalog')==false){ 472 473 $this->bo->set_catalog($params['catalog']); 474 475 $fields = $this->bo->bo->get_fields(true); 476 $result = $this->bo->bo->get_single_entry($params['id'], $fields); 477 478 $this->template->set_var('photo', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo&id='.$id); 479 480 $this->template->set_var('cc_name',$result['names_ordered'][0]); 481 482 $this->template->set_var('lang_title_name',lang("Name")); 483 $this->template->set_var('lang_name',$result['given_names'][0]); 484 485 $this->template->set_var('lang_title_lastname',lang("Family Names")); 486 $this->template->set_var('lang_lastname',$result['family_names'][0]); 487 488 $email_to = ""; 489 $var_phone = ""; 490 $var_email = ""; 491 foreach($result['connections'] as $conn): 492 if ( $conn['id_type'] == 1 ){ 493 if ( !empty($var_email) ) 494 $var_email .= ' | '; 495 $var_email .= $conn['connection_value']; 496 497 if ( empty($email_to) ) 498 $email_to = $var_email; 499 500 }else if ($conn['id_type'] == 2){ 501 if ( !empty($var_phone)) 502 $var_phone .= ' | '; 503 $var_phone .= $conn['connection_value']; 504 } 505 endforeach; 506 507 $this->template->set_var('email_to', $email_to); 508 509 $this->template->set_var('lang_title_email',lang("Email")); 510 $this->template->set_var('lang_email',$var_email); 511 512 $this->template->set_var('lang_title_phone',lang("Phone")); 513 $this->template->set_var('lang_phone',$var_phone); 514 515 $this->template->parse("row_body","people_ldap"); 516 517 }else{ 518 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.init_cc'); 519 } 520 521 break; 522 } 523 524 $this->template->set_var('lang_contact_title',lang("context contact")); 525 $this->template->set_var('lang_back',lang("back")); 526 $this->template->set_var('lang_use_contact',lang("use contact")); 527 $this->template->set_var('lang_selecteds',lang("selecteds")); 528 529 $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','body')); 530 } 531 532 /** 533 * View Add/Edit contact 534 * 535 * @param $id int 536 * @param $catalog String 537 * @return $contact 538 */ 539 function contact_add_edit($params) { 540 541 $this->template->set_file( 542 Array( 543 'cc_e' => 'contact_add_edit.tpl' 544 ) 545 ); 546 547 $this->template->set_block('cc_e','body'); 548 549 if ( empty($params['id']) ){ 550 $title_contact = "title add contact"; 551 $form_action = "index.php?menuaction=mobile.ui_mobilecc.contact_add"; 552 $confirm = lang("confirm add"); 553 $params['catalog'] = 'bo_people_catalog'; 554 }else{ 555 $title_contact = "title edit contact"; 556 $form_action = "index.php?menuaction=mobile.ui_mobilecc.contact_edit"; 557 $confirm = lang("confirm edit"); 558 559 $this->bo->set_catalog($params['catalog']); 560 $result = $this->bo->bo->get_single_entry($params['id'], array("given_names"=>true,"names_ordered"=>true,"alias"=>true,"family_names"=>true,"companies"=>true,"relations"=>true,"connections"=>true)); 561 562 $this->template->set_var('lang_alias',$result['alias']); 563 $this->template->set_var('lang_name',$result['given_names']); 564 $this->template->set_var('lang_lastname',$result['family_names']); 565 566 $var_phone = ""; 567 $var_email = ""; 568 foreach($result['connections'] as $conn): 569 if ( $conn['id_type'] == 1 ){ 570 if ( (empty($var_email)) && ($conn['connection_is_default']) ){ 571 $var_email = $conn['connection_value']; 572 $var_connection_email = $conn['id_connection']; 573 } 574 }else if ($conn['id_type'] == 2){ 575 if ( (empty($var_phone)) && ($conn['connection_is_default'])){ 576 $var_phone = $conn['connection_value']; 577 $var_connection_phone = $conn['id_connection']; 578 } 579 } 580 endforeach; 581 582 $this->template->set_var('var_connection_email', $var_connection_email); 583 $this->template->set_var('lang_email',$var_email); 584 585 $this->template->set_var('var_connection_phone', $var_connection_phone); 586 $this->template->set_var('lang_phone',$var_phone); 587 588 } 589 590 $this->template->set_var('cc_name',$result['names_ordered']); 591 $this->template->set_var('lang_title_alias',lang("Alias")); 592 $this->template->set_var('lang_title_name',lang("Name")); 593 $this->template->set_var('lang_title_lastname',lang("Family Names")); 594 $this->template->set_var('lang_title_email',lang("Email")); 595 $this->template->set_var('lang_title_phone',lang("Phone")); 596 597 $this->template->set_var('catalog', $params['catalog']); 598 599 $this->template->set_var('lang_title_add_edit',lang($title_contact)); 600 $this->template->set_var('form_action', $form_action); 601 602 $this->template->set_var('lang_contact_title',lang("context contact")); 603 $this->template->set_var('lang_back',lang("back")); 604 $this->template->set_var('lang_cancel',lang("cancel")); 605 $this->template->set_var('lang_confirm', $confirm); 606 $this->template->set_var('lang_selecteds',lang("selecteds")); 607 $this->template->set_var('id',$params['id']); 608 609 $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','body')); 610 } 611 612 /** 613 * Add contact 614 * 615 * @param $id int 616 * @param $catalog String 617 * @return $contact 618 */ 619 function contact_add($params) { 620 621 $data['alias'] = $params['alias']; 622 $data['given_names'] = $params['given_names']; 623 $data['family_names'] = $params['family_names']; 624 $data['names_ordered'] = $data['given_names'] . ' ' . $data['family_names']; 625 $data['is_quick_add'] = true; 626 627 $this->bo->set_catalog($params['catalog']); 628 629 if ( !empty($params['email']) ){ 630 $data['connections']['default_email']['connection_value'] = $params['email']; 631 } 632 633 if ( !empty($params['phone']) ){ 634 $data['connections']['default_phone']['connection_value'] = $params['phone']; 635 } 636 637 $this->bo->set_catalog($params['catalog']); 638 $contact_id = $this->bo->bo->quick_add($data); 639 640 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_view&id='.$contact_id.'&catalog='.$params['catalog']); 641 } 642 643 /** 644 * Edit contact 645 * 646 * @param $id int 647 * @param $catalog String 648 * @return $contact 649 */ 650 function contact_edit($params) { 651 652 $data['alias'] = $params['alias']; 653 $data['given_names'] = $params['given_names']; 654 $data['family_names'] = $params['family_names']; 655 $data['names_ordered'] = $data['given_names'] . ' ' . $data['family_names']; 656 657 $cont = 0; 658 659 $this->bo->set_catalog($params['catalog']); 660 $types = $this->bo->bo->get_all_connections_types(); 661 662 if ( !empty($params['email']) || !empty($params['id_connection_email']) ){ 663 $cont++; 664 665 if (empty($params['id_connection_email'])){ 666 $data['connections']['connection' . $cont]['connection_is_default'] = true; 667 $data['connections']['connection' . $cont]['connection_name'] = $types[1]; 668 } 669 670 $data['connections']['connection' . $cont]['id_connection'] = $params['id_connection_email']; 671 $data['connections']['connection' . $cont]['id_typeof_connection'] = 1; 672 $data['connections']['connection' . $cont]['connection_value'] = $params['email']; 673 674 } 675 676 if ( !empty($params['phone']) || !empty($params['id_connection_phone']) ){ 677 $cont++; 678 679 if (empty($params['id_connection_phone'])){ 680 $data['connections']['connection' . $cont]['connection_is_default'] = true; 681 $data['connections']['connection' . $cont]['connection_name'] = $types[2]; 682 } 683 684 $data['connections']['connection' . $cont]['id_connection'] = $params['id_connection_phone']; 685 $data['connections']['connection' . $cont]['id_typeof_connection'] = 2; 686 $data['connections']['connection' . $cont]['connection_value'] = $params['phone']; 687 688 } 689 690 $contact_id = $this->bo->bo->update_single_info($params['id'], $data); 691 692 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_view&id='.$contact_id.'&catalog='.$params['catalog']); 693 694 } 695 696 /** 697 * Verify if the data is valid 698 * 699 * @param $type String 700 * @param $data String 701 * @return Boolean 702 */ 703 static function validateData($type,$data){ 704 705 switch($type){ 706 case 'phone' : "/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i"; 707 break; 708 709 case 'email' : $pattern = "/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i"; 710 break; 711 } 712 713 return preg_match($pattern, $data) ? true : false; 714 715 } 716 323 717 324 718 } 325 719 326 720 327 328 329 721 ?>
Note: See TracChangeset
for help on using the changeset viewer.