[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * phpGroupWare - preferences * |
---|
| 4 | * http://www.phpgroupware.org * |
---|
| 5 | * Written by Joseph Engo <jengo@phpgroupware.org> * |
---|
| 6 | * -------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 15 | 'noheader' => True, |
---|
| 16 | 'nonavbar' => True, |
---|
| 17 | 'currentapp' => 'preferences' |
---|
| 18 | ); |
---|
| 19 | |
---|
| 20 | include('../header.inc.php'); |
---|
| 21 | |
---|
| 22 | $n_passwd = $_POST['n_passwd']; |
---|
| 23 | $n_passwd_2 = $_POST['n_passwd_2']; |
---|
| 24 | |
---|
| 25 | if(!$GLOBALS['phpgw']->acl->check('changepassword', 1) || $_POST['cancel']) |
---|
| 26 | { |
---|
| 27 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
| 28 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | $GLOBALS['phpgw']->template->set_file(array( |
---|
| 32 | 'form' => 'changepassword.tpl' |
---|
| 33 | )); |
---|
| 34 | $GLOBALS['phpgw']->template->set_var('lang_enter_password',lang('Enter your new password')); |
---|
| 35 | $GLOBALS['phpgw']->template->set_var('lang_reenter_password',lang('Re-enter your password')); |
---|
| 36 | $GLOBALS['phpgw']->template->set_var('lang_change',lang('Change')); |
---|
| 37 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 38 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/preferences/changepassword.php')); |
---|
| 39 | |
---|
| 40 | if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ldap') |
---|
| 41 | { |
---|
| 42 | $GLOBALS['phpgw']->template->set_var('sql_message',lang('note: This feature does *not* change your email password. This will ' |
---|
| 43 | . 'need to be done manually.')); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | if ($_POST['change']) |
---|
| 47 | { |
---|
| 48 | if ($n_passwd != $n_passwd_2) |
---|
| 49 | { |
---|
| 50 | $errors[] = lang('The two passwords are not the same'); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | if (! $n_passwd) |
---|
| 54 | { |
---|
| 55 | $errors[] = lang('You must enter a password'); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | if(is_array($errors)) |
---|
| 59 | { |
---|
| 60 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 61 | echo parse_navbar(); |
---|
| 62 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
| 63 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 64 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | $o_passwd = $GLOBALS['phpgw_info']['user']['passwd']; |
---|
| 68 | $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); |
---|
| 69 | if(!$passwd_changed) |
---|
| 70 | { |
---|
| 71 | $errors[] = lang('Failed to change password. Please contact your administrator.'); |
---|
| 72 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 73 | echo parse_navbar(); |
---|
| 74 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
| 75 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 76 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | $GLOBALS['phpgw_info']['user']['passwd'] = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); |
---|
| 81 | $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 82 | $GLOBALS['hook_values']['old_passwd'] = $o_passwd; |
---|
| 83 | $GLOBALS['hook_values']['new_passwd'] = $n_passwd; |
---|
| 84 | $GLOBALS['phpgw']->hooks->process('changepassword'); |
---|
| 85 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); |
---|
| 86 | } |
---|
| 87 | } |
---|
| 88 | else |
---|
| 89 | { |
---|
| 90 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your password'); |
---|
| 91 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 92 | echo parse_navbar(); |
---|
| 93 | |
---|
| 94 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 95 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 96 | } |
---|
| 97 | ?> |
---|