source: trunk/preferences/templates/default/changepassword_default.php @ 1681

Revision 1681, 3.3 KB checked in by rafaelraymundo, 14 years ago (diff)

Ticket #770 - função em common_functions,inc.php determina include p/templates.

Line 
1<?php
2
3                // Default number of letters = 3
4                if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass'])
5                        $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3;
6                // Default number of special letters = 0
7                if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass'])
8                        $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0;
9                if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd))
10                {
11                        $errors[] = lang('Your actual password is wrong');
12                }
13                else if ($n_passwd != $n_passwd_2)
14                {
15                        $errors[] = lang('The two passwords are not the same');
16                }
17                else if ($a_passwd == $n_passwd)
18                {
19                        $errors[] = lang('Your old password and your new password are the same. Choose a different new password');
20                }
21                else if (! $n_passwd)
22                {
23                        $errors[] = lang('You must enter a password');
24                }
25                else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] )
26                {
27                        $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']);
28                }
29
30                // Special Letters
31                $speccial_letter = 0;
32                for ($i=0; $i<strlen($n_passwd); $i++)
33                {
34                        $letter = $n_passwd[$i];
35                        if (! ereg ("[a-zA-Z]", $letter ) )
36                                $speccial_letter++;
37                }
38                if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'])
39                {
40                        $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']);
41                }
42
43                if(is_array($errors))
44                {
45                        $GLOBALS['phpgw']->common->phpgw_header();
46                        echo parse_navbar();
47                        $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
48                        $GLOBALS['phpgw']->template->pfp('out','form');
49                        $GLOBALS['phpgw']->common->phpgw_exit(True);
50                }
51
52                $o_passwd = $GLOBALS['phpgw_info']['user']['passwd'];
53                $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd);
54                if(!$passwd_changed)
55                {
56                        $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.';
57                        $GLOBALS['phpgw']->common->phpgw_header();
58                        echo parse_navbar();
59                        $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
60                        $GLOBALS['phpgw']->template->pfp('out','form');
61                        $GLOBALS['phpgw']->common->phpgw_exit(True);
62                }
63                else
64                {
65                        $GLOBALS['phpgw_info']['user']['passwd'] = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd);
66                        $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
67                        $GLOBALS['hook_values']['old_passwd'] = $o_passwd;
68                        $GLOBALS['hook_values']['new_passwd'] = $n_passwd;
69                        $GLOBALS['phpgw']->hooks->process('changepassword');
70
71                        if($GLOBALS['phpgw_info']['server']['certificado'])
72                        {
73                        if(!$GLOBALS['phpgw_info']['server']['atributousuarios'] or $GLOBALS['phpgw_info']['server']['atributousuarios'] == "person")
74                                {
75                                        $RR = grava_senha_criptografada_com_certificado_no_ldap($GLOBALS['phpgw_info']['user']['account_id'],$n_passwd);
76                                }
77                        }
78
79                        if ($GLOBALS['phpgw_info']['server']['use_https'] == 1)
80                                Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php');
81                        else
82                                $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18');
83                }
84
85?>
Note: See TracBrowser for help on using the repository browser.