source: trunk/preferences/changepersonaldata.php @ 392

Revision 392, 4.3 KB checked in by niltonneto, 16 years ago (diff)

Opção de configuração para LDAP Master e Slaves.

  • 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: This telephone number will apear in the searches for your name, and 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('telephonenumber',$_POST['telephonenumber'] ? $_POST['telephonenumber'] : $GLOBALS['phpgw_info']['user']['telephonenumber']);
46        $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/preferences/changepersonaldata.php'));
47
48        if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ldap')
49        {
50                $GLOBALS['phpgw']->template->set_var('sql_message',lang('note: This feature is *exclusive* for ldap repository.'));
51        }
52
53        if ($_POST['change'])
54        {
55                if ($_POST['telephonenumber'] != $GLOBALS['phpgw_info']['user']['telephonenumber'])
56                {
57                        $pattern = '/\([0-9]{2,3}\)[0-9]{4}-[0-9]{4}$/';
58                        if (!preg_match($pattern, $_POST['telephonenumber']))
59                        {
60                                $errors[] = lang('Format of telephone number is invalid.');
61                        }
62                        else
63                        {
64                                // LDAP Replication mode.
65                                if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) &&
66                                         (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) &&
67                                         (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) )
68                                {
69                                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(
70                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_host'],
71                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'],
72                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']
73                                                                                                   );
74                                }
75                                else
76                                {
77                                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
78                                }
79                               
80                                $info['telephonenumber'] = $_POST['telephonenumber'];
81                               
82                                if ($GLOBALS['phpgw_info']['user']['telephonenumber'])
83                                {
84                                        $result = @ldap_mod_replace($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info);
85                                }
86                                else
87                                {
88                                        $result = @ldap_mod_add($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info);
89                                }
90                        }
91                       
92                        if(is_array($errors))
93                        {
94                                $GLOBALS['phpgw']->common->phpgw_header();
95                                echo parse_navbar();
96                                $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
97                                $GLOBALS['phpgw']->template->pfp('out','form');
98                                $GLOBALS['phpgw']->common->phpgw_exit(True);
99                        }
100                }
101                $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18');
102        }
103        else
104        {
105                $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your Personal Data');
106                $GLOBALS['phpgw']->common->phpgw_header();
107                echo parse_navbar();
108
109                $GLOBALS['phpgw']->template->pfp('out','form');
110                $GLOBALS['phpgw']->common->phpgw_footer();
111        }
112?>
Note: See TracBrowser for help on using the repository browser.