[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * ExpressoLivre - preferences * |
---|
| 4 | * http://www.celepar.pr.gov.br * |
---|
| 5 | * Written by Joseph Engo <jengo@phpgroupware.org> * |
---|
| 6 | * Modify by João Alfredo Knopik Junior <jakjr@celepar.pr.gov.br> * |
---|
| 7 | * * |
---|
| 8 | * -------------------------------------------- * |
---|
| 9 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 10 | * under the terms of the GNU General Public License as published by the * |
---|
| 11 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 12 | * option) any later version. * |
---|
| 13 | \**************************************************************************/ |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 17 | 'noheader' => True, |
---|
| 18 | 'nonavbar' => True, |
---|
| 19 | 'currentapp' => 'preferences' |
---|
| 20 | ); |
---|
| 21 | |
---|
| 22 | include('../header.inc.php'); |
---|
| 23 | |
---|
| 24 | if($_POST['cancel']) |
---|
| 25 | { |
---|
| 26 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
| 27 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 31 | { |
---|
| 32 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 33 | } |
---|
| 34 | $GLOBALS['phpgw']->js->validate_file('jscode','scripts','preferences');#diretorio, arquivo.js, aplicacao |
---|
| 35 | |
---|
| 36 | $GLOBALS['phpgw']->template->set_file(array( |
---|
| 37 | 'form' => 'changepersonaldata.tpl' |
---|
| 38 | )); |
---|
| 39 | |
---|
| 40 | $GLOBALS['phpgw']->template->set_var('lang_commercial_telephonenumber',lang('Commercial Telephone number')); |
---|
[88] | 41 | $GLOBALS['phpgw']->template->set_var('lang_ps_commercial_telephonenumber', |
---|
[578] | 42 | lang('Observation') . ': ' . lang('This telephone number will apear in searches for your name, and it will be visible for all ExpressoLivre Users') . '.'); |
---|
[2] | 43 | $GLOBALS['phpgw']->template->set_var('lang_change',lang('Change')); |
---|
| 44 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 45 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/preferences/changepersonaldata.php')); |
---|
| 46 | |
---|
[578] | 47 | /* Get telephone number from ldap or from post */ |
---|
| 48 | $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
| 49 | $result = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uid='.$GLOBALS['phpgw_info']['user']['account_lid'], array('telephonenumber')); |
---|
| 50 | $entrie = ldap_get_entries($ldap_conn, $result); |
---|
| 51 | $GLOBALS['phpgw']->template->set_var('telephonenumber',$_POST['telephonenumber'] ? $_POST['telephonenumber'] : $entrie[0]['telephonenumber'][0]); |
---|
| 52 | ldap_close($ldap_conn); |
---|
| 53 | |
---|
[2] | 54 | if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ldap') |
---|
| 55 | { |
---|
| 56 | $GLOBALS['phpgw']->template->set_var('sql_message',lang('note: This feature is *exclusive* for ldap repository.')); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | if ($_POST['change']) |
---|
| 60 | { |
---|
| 61 | if ($_POST['telephonenumber'] != $GLOBALS['phpgw_info']['user']['telephonenumber']) |
---|
| 62 | { |
---|
| 63 | $pattern = '/\([0-9]{2,3}\)[0-9]{4}-[0-9]{4}$/'; |
---|
[1225] | 64 | if ((strlen($_POST['telephonenumber']) != 0) && (!preg_match($pattern, $_POST['telephonenumber']))) |
---|
[2] | 65 | { |
---|
| 66 | $errors[] = lang('Format of telephone number is invalid.'); |
---|
| 67 | } |
---|
| 68 | else |
---|
| 69 | { |
---|
[578] | 70 | // Use LDAP Replication mode, if available |
---|
[392] | 71 | if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && |
---|
| 72 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && |
---|
| 73 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) |
---|
| 74 | { |
---|
| 75 | $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect( |
---|
| 76 | $GLOBALS['phpgw_info']['server']['ldap_master_host'], |
---|
| 77 | $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], |
---|
| 78 | $GLOBALS['phpgw_info']['server']['ldap_master_root_pw'] |
---|
| 79 | ); |
---|
| 80 | } |
---|
| 81 | else |
---|
| 82 | { |
---|
| 83 | $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
| 84 | } |
---|
| 85 | |
---|
[2] | 86 | if ($GLOBALS['phpgw_info']['user']['telephonenumber']) |
---|
| 87 | { |
---|
[1225] | 88 | if (strlen($_POST['telephonenumber']) == 0) { |
---|
| 89 | $info['telephonenumber'] = $GLOBALS['phpgw_info']['user']['telephonenumber']; |
---|
| 90 | $result = @ldap_mod_del($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); |
---|
| 91 | } |
---|
| 92 | else { |
---|
| 93 | $info['telephonenumber'] = $_POST['telephonenumber']; |
---|
| 94 | $result = @ldap_mod_replace($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); |
---|
| 95 | } |
---|
[2] | 96 | } |
---|
| 97 | else |
---|
| 98 | { |
---|
[1225] | 99 | $info['telephonenumber'] = $_POST['telephonenumber']; |
---|
[2] | 100 | $result = @ldap_mod_add($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | if(is_array($errors)) |
---|
| 105 | { |
---|
| 106 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 107 | echo parse_navbar(); |
---|
| 108 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
| 109 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 110 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); |
---|
| 114 | } |
---|
| 115 | else |
---|
| 116 | { |
---|
| 117 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your Personal Data'); |
---|
| 118 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 119 | echo parse_navbar(); |
---|
| 120 | |
---|
| 121 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 122 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 123 | } |
---|
| 124 | ?> |
---|