Changeset 3634
- Timestamp:
- 12/28/10 09:15:49 (13 years ago)
- Location:
- branches/2.2/mobile
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/mobile/inc/class.ui_mobilecc.inc.php
r3631 r3634 334 334 * @return $contact 335 335 */ 336 function contact_view($params) { // bo_people_catalog, bo_global_ldap_catalog336 function contact_view($params) { 337 337 338 338 if ( empty($params['id']) || empty($params['catalog']) ){ … … 345 345 ) 346 346 ); 347 348 if ( isset($params['success'])){ 349 $GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg(lang('contact save successfully')); 350 } 347 351 348 352 $this->template->set_block('cc_v','body'); … … 352 356 $this->template->set_block('cc_v','group_row'); 353 357 $this->template->set_block('cc_v','buttom'); 358 $this->template->set_block('cc_v','buttom_use_contact'); 354 359 355 360 switch ($params['catalog']){ … … 396 401 } 397 402 endforeach; 398 399 $this->template->set_var('email_to', $email_to); 403 404 if ( !empty($email_to)){ 405 $this->template->set_var('email_to', $email_to); 406 $this->template->parse("buttom_use","buttom_use_contact"); 407 } 400 408 401 409 $this->template->set_var('lang_title_email',lang("Email")); … … 516 524 $this->template->set_block('cc_e','body'); 517 525 526 $view = false; 527 if ( isset($params['erro'])){ 528 $GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params['erro']); 529 530 $result['alias'] = $params['alias']; 531 $result['given_names'] = $params['given_names']; 532 $result['family_names'] = $params['family_names']; 533 $result['names_ordered'] = $params['names_ordered']; 534 $var_phone = $params['phone']; 535 $var_email = $params['email']; 536 $var_connection_email = $params['id_connection_email']; 537 $var_connection_phone = $params['id_connection_phone']; 538 $view = true; 539 540 } 541 518 542 if ( empty($params['id']) ){ 519 543 $title_contact = "title add contact"; … … 526 550 $confirm = lang("confirm edit"); 527 551 528 $this->bo->set_catalog($params['catalog']); 529 $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)); 530 531 $this->template->set_var('lang_alias',$result['alias']); 532 $this->template->set_var('lang_name',$result['given_names']); 533 $this->template->set_var('lang_lastname',$result['family_names']); 534 535 $var_phone = ""; 536 $var_email = ""; 537 foreach($result['connections'] as $conn): 538 if ( $conn['id_type'] == 1 ){ 539 if ( (empty($var_email)) && ($conn['connection_is_default']) ){ 540 $var_email = $conn['connection_value']; 541 $var_connection_email = $conn['id_connection']; 552 $view = true; 553 554 if ( !isset($params['erro'])){ 555 $this->bo->set_catalog($params['catalog']); 556 $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)); 557 558 $var_phone = ""; 559 $var_email = ""; 560 foreach($result['connections'] as $conn): 561 if ( $conn['id_type'] == 1 ){ 562 if ( (empty($var_email)) && ($conn['connection_is_default']) ){ 563 $var_email = $conn['connection_value']; 564 $var_connection_email = $conn['id_connection']; 565 } 566 }else if ($conn['id_type'] == 2){ 567 if ( (empty($var_phone)) && ($conn['connection_is_default'])){ 568 $var_phone = $conn['connection_value']; 569 $var_connection_phone = $conn['id_connection']; 570 } 542 571 } 543 }else if ($conn['id_type'] == 2){ 544 if ( (empty($var_phone)) && ($conn['connection_is_default'])){ 545 $var_phone = $conn['connection_value']; 546 $var_connection_phone = $conn['id_connection']; 547 } 548 } 549 endforeach; 550 551 $this->template->set_var('var_connection_email', $var_connection_email); 552 $this->template->set_var('lang_email',$var_email); 553 554 $this->template->set_var('var_connection_phone', $var_connection_phone); 555 $this->template->set_var('lang_phone',$var_phone); 556 572 endforeach; 573 } 574 575 576 } 577 578 if ($view){ 579 $this->template->set_var('lang_alias',$result['alias']); 580 $this->template->set_var('lang_name',$result['given_names']); 581 $this->template->set_var('lang_lastname',$result['family_names']); 582 583 $this->template->set_var('var_connection_email', $var_connection_email); 584 $this->template->set_var('lang_email',$var_email); 585 586 $this->template->set_var('var_connection_phone', $var_connection_phone); 587 $this->template->set_var('lang_phone',$var_phone); 588 557 589 } 558 590 … … 594 626 $data['is_quick_add'] = true; 595 627 596 $this->bo->set_catalog($params['catalog']); 597 598 if ( !empty($params['email']) ){ 599 $data['connections']['default_email']['connection_value'] = $params['email']; 600 } 601 602 if ( !empty($params['phone']) ){ 603 $data['connections']['default_phone']['connection_value'] = $params['phone']; 604 } 605 606 $this->bo->set_catalog($params['catalog']); 607 $contact_id = $this->bo->bo->quick_add($data); 608 609 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_view&id='.$contact_id.'&catalog='.$params['catalog']); 610 } 611 628 $answer = $this->verifyData($params); 629 630 if (!empty($answer)){ 631 $retorno = 'alias='.$data['alias'] . '&given_names='.$data['given_names'] . '&family_names='.$data['family_names'] . '&names_ordered='.$data['given_names'] . ' ' . $data['family_names']; 632 $retorno .= '&id_connection_email='.$params['id_connection_email'] . '&id_connection_phone='.$params['id_connection_phone']; 633 $retorno .= '&email='.$params['email'] . '&phone='.$params['phone']; 634 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_add_edit&erro='.$answer.'&'.$retorno); 635 } 636 else 637 { 638 $this->bo->set_catalog($params['catalog']); 639 640 if ( !empty($params['email']) ){ 641 $data['connections']['default_email']['connection_value'] = $params['email']; 642 } 643 644 if ( !empty($params['phone']) ){ 645 $data['connections']['default_phone']['connection_value'] = $params['phone']; 646 } 647 648 $this->bo->set_catalog($params['catalog']); 649 $contact_id = $this->bo->bo->quick_add($data); 650 651 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_view&id='.$contact_id.'&catalog='.$params['catalog'] . '&success=1'); 652 } 653 } 654 612 655 /** 613 656 * Edit contact … … 626 669 $cont = 0; 627 670 628 $this->bo->set_catalog($params['catalog']); 629 $types = $this->bo->bo->get_all_connections_types(); 630 631 if ( !empty($params['email']) || !empty($params['id_connection_email']) ){ 632 $cont++; 633 634 if (empty($params['id_connection_email'])){ 635 $data['connections']['connection' . $cont]['connection_is_default'] = true; 636 $data['connections']['connection' . $cont]['connection_name'] = $types[1]; 637 } 638 639 $data['connections']['connection' . $cont]['id_connection'] = $params['id_connection_email']; 640 $data['connections']['connection' . $cont]['id_typeof_connection'] = 1; 641 $data['connections']['connection' . $cont]['connection_value'] = $params['email']; 642 643 } 644 645 if ( !empty($params['phone']) || !empty($params['id_connection_phone']) ){ 646 $cont++; 647 648 if (empty($params['id_connection_phone'])){ 649 $data['connections']['connection' . $cont]['connection_is_default'] = true; 650 $data['connections']['connection' . $cont]['connection_name'] = $types[2]; 651 } 652 653 $data['connections']['connection' . $cont]['id_connection'] = $params['id_connection_phone']; 654 $data['connections']['connection' . $cont]['id_typeof_connection'] = 2; 655 $data['connections']['connection' . $cont]['connection_value'] = $params['phone']; 656 657 } 658 659 $contact_id = $this->bo->bo->update_single_info($params['id'], $data); 660 661 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_view&id='.$contact_id.'&catalog='.$params['catalog']); 662 663 } 664 665 /** 666 * Verify if the data is valid 667 * 668 * @param $type String 669 * @param $data String 671 $answer = $this->verifyData($params); 672 673 if (!empty($answer)){ 674 $retorno = '&catalog=' . $params['catalog'] . '&id='. $params['id'] .'&alias='.$data['alias'] . '&given_names='.$data['given_names'] . '&family_names='.$data['family_names'] . '&names_ordered='.$data['given_names'] . ' ' . $data['family_names']; 675 $retorno .= '&id_connection_email='.$params['id_connection_email'] . '&id_connection_phone='.$params['id_connection_phone']; 676 $retorno .= '&email='.$params['email'] . '&phone='.$params['phone']; 677 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_add_edit&erro='.$answer.'&'.$retorno); 678 } 679 else 680 { 681 682 $this->bo->set_catalog($params['catalog']); 683 $types = $this->bo->bo->get_all_connections_types(); 684 685 if ( !empty($params['email']) || !empty($params['id_connection_email']) ){ 686 $cont++; 687 688 if (empty($params['id_connection_email'])){ 689 $data['connections']['connection' . $cont]['connection_is_default'] = true; 690 $data['connections']['connection' . $cont]['connection_name'] = $types[1]; 691 } 692 693 $data['connections']['connection' . $cont]['id_connection'] = $params['id_connection_email']; 694 $data['connections']['connection' . $cont]['id_typeof_connection'] = 1; 695 $data['connections']['connection' . $cont]['connection_value'] = $params['email']; 696 697 } 698 699 if ( !empty($params['phone']) || !empty($params['id_connection_phone']) ){ 700 $cont++; 701 702 if (empty($params['id_connection_phone'])){ 703 $data['connections']['connection' . $cont]['connection_is_default'] = true; 704 $data['connections']['connection' . $cont]['connection_name'] = $types[2]; 705 } 706 707 $data['connections']['connection' . $cont]['id_connection'] = $params['id_connection_phone']; 708 $data['connections']['connection' . $cont]['id_typeof_connection'] = 2; 709 $data['connections']['connection' . $cont]['connection_value'] = $params['phone']; 710 711 } 712 713 $contact_id = $this->bo->bo->update_single_info($params['id'], $data); 714 715 header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_view&id='.$contact_id.'&catalog='.$params['catalog'].'&success=1'); 716 717 } 718 719 } 720 721 /** 722 * Validate data when register contact 723 * Validate E-mail, Phone and Name(NotEmpty) 724 * 725 * @param $data Array 670 726 * @return Boolean 671 727 */ 672 static function validateData($type,$data){ 673 674 switch($type){ 675 case 'phone' : "/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i"; 676 break; 677 678 case 'email' : $pattern = "/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i"; 679 break; 680 } 681 682 return preg_match($pattern, $data) ? true : false; 728 static function verifyData($data){ 729 730 $valid = ''; 731 $field = false; 732 733 // Verify if phone is valid 734 if ( !empty($data['phone']) && empty($valid) ){ 735 736 $field = true; 737 738 $pattern = "#^(?:(?:\(?\+?(?P<country>\d{2,4})\)?\s*)?\(?(?P<city>\d{2,3})\)?\s*)?(?P<n1>\d{3,4})[-\s.]?(?P<n2>\d{4})$#"; 739 740 if (!preg_match($pattern, $data['phone'])){ 741 $valid = lang('invalid field phone'); 742 } 743 744 } 745 746 // Verify if e-mail is valid 747 if ( !empty($data['email']) ){ 748 749 $field = true; 750 751 $pattern = "^[a-z0-9_\.\-]+@[a-z0-9_\.\-]*[a-z0-9_\-]+\.[a-z]{2,4}$"; 752 753 if (!eregi($pattern, $data['email'])){ 754 $valid = lang('invalid field e-mail'); 755 } 756 757 } 758 759 // Verify if exist e-mail or phone 760 if (!$field) 761 $valid = lang('Tel or email is required'); 762 763 // Verify if name is empty 764 if ( empty($data['given_names']) ) 765 $valid = lang('Name is mandatory'); 766 767 return $valid; 683 768 684 769 } -
branches/2.2/mobile/setup/phpgw_pt-br.lang
r3630 r3634 152 152 title edit contact mobile pt-br Editando Contato 153 153 title add contact mobile pt-br Adicionando Contato 154 invalid field e-mail mobile pt-br Campo E-Mail inválido 155 invalid field phone mobile pt-br Campo Telefone inválido 156 contact save successfully mobile pt-br Contato salvo com sucesso 157 Name is mandatory mobile pt-br Nome é obrigatório 158 Tel or email is required mobile pt-br Você precisa informar ou o e-mail ou o telefone -
branches/2.2/mobile/templates/default/cc_main.tpl
r3615 r3634 47 47 Selecionados: 48 48 <button id="remover" class="btn-generico" onClick="document.getElementById('menuaction').value='mobile.ui_mobilecc.delete_contacts';document.getElementById('formu_contacts').submit();">remover</button> 49 <button id="adicionar_contato" class="btn-generico" >adicionar contato</button>49 <button id="adicionar_contato" onClick="location.href=('../mobile/index.php?menuaction=mobile.ui_mobilecc.contact_add_edit')" class="btn-generico" >adicionar contato</button> 50 50 51 51 </div> -
branches/2.2/mobile/templates/default/contact_add_edit.tpl
r3630 r3634 25 25 <div id="operacao_lista"> 26 26 {lang_selecteds}: 27 <button id="cancelar" class="btn-generico" onclick=" javascript:history.go(-1);" >{lang_cancel}</button>27 <button id="cancelar" class="btn-generico" onclick="location.href=('../mobile/index.php?menuaction=mobile.ui_mobilecc.init_cc')" >{lang_cancel}</button> 28 28 <button id="confirmar_edicao" class="btn-generico" onclick="javascript:document.formcontact.submit();">{lang_confirm}</button> 29 29 </div> 30 30 31 31 <!-- END body --> 32 -
branches/2.2/mobile/templates/default/contact_view.tpl
r3630 r3634 13 13 <div id="operacao_lista"> 14 14 {lang_selecteds}: 15 <button id="remover" class="btn-generico" onclick="location.href=('../mobile/index.php?menuaction=mobile.ui_mobilemail.new_msg&type=from_mobilecc&input_to={email_to}')" >{lang_use_contact}</button>15 {buttom_use} 16 16 {buttom_editar} 17 17 </div> … … 23 23 24 24 <!-- END body --> 25 26 <!-- BEGIN buttom_use_contact --> 27 <button id="remover" class="btn-generico" onclick="location.href=('../mobile/index.php?menuaction=mobile.ui_mobilemail.new_msg&type=from_mobilecc&input_to={email_to}')" >{lang_use_contact}</button> 28 <!-- END buttom_use_contact --> 25 29 26 30 <!-- BEGIN buttom -->
Note: See TracChangeset
for help on using the changeset viewer.