source: branches/1.2/preferences/changepersonaldata.php @ 578

Revision 578, 4.6 KB checked in by niltonneto, 15 years ago (diff)

Inclusão e correção de tradução.
Limpeza de código.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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'));
41        $GLOBALS['phpgw']->template->set_var('lang_ps_commercial_telephonenumber',
42        lang('Observation') . ': ' . lang('This telephone number will apear in searches for your name, and it will be visible for all ExpressoLivre Users') . '.');
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
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
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}$/';
64                        if (!preg_match($pattern, $_POST['telephonenumber']))
65                        {
66                                $errors[] = lang('Format of telephone number is invalid.');
67                        }
68                        else
69                        {
70                                // Use LDAP Replication mode, if available
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                               
86                                $info['telephonenumber'] = $_POST['telephonenumber'];
87                               
88                                if ($GLOBALS['phpgw_info']['user']['telephonenumber'])
89                                {
90                                        $result = @ldap_mod_replace($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info);
91                                }
92                                else
93                                {
94                                        $result = @ldap_mod_add($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info);
95                                }
96                        }
97                       
98                        if(is_array($errors))
99                        {
100                                $GLOBALS['phpgw']->common->phpgw_header();
101                                echo parse_navbar();
102                                $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
103                                $GLOBALS['phpgw']->template->pfp('out','form');
104                                $GLOBALS['phpgw']->common->phpgw_exit(True);
105                        }
106                }
107                $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18');
108        }
109        else
110        {
111                $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your Personal Data');
112                $GLOBALS['phpgw']->common->phpgw_header();
113                echo parse_navbar();
114
115                $GLOBALS['phpgw']->template->pfp('out','form');
116                $GLOBALS['phpgw']->common->phpgw_footer();
117        }
118?>
Note: See TracBrowser for help on using the repository browser.