1<?php
2# MantisBT - A PHP based bugtracking system
3
4# MantisBT is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# MantisBT is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Reset a Users Password
19 *
20 * @package MantisBT
21 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
24 *
25 * @uses core.php
26 * @uses authentication_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses form_api.php
30 * @uses gpc_api.php
31 * @uses html_api.php
32 * @uses lang_api.php
33 */
34
35require_once( 'core.php' );
36require_api( 'authentication_api.php' );
37require_api( 'config_api.php' );
38require_api( 'constant_inc.php' );
39require_api( 'form_api.php' );
40require_api( 'gpc_api.php' );
41require_api( 'html_api.php' );
42require_api( 'lang_api.php' );
43
44form_security_validate( 'manage_user_reset' );
45
46auth_reauthenticate();
47
48$f_user_id = gpc_get_int( 'user_id' );
49
50$t_data = array(
51	'query' => array( 'id' => $f_user_id )
52);
53
54$t_command = new UserResetPasswordCommand( $t_data );
55# The case of trying to reset a protected account now causes the Command to
56# trigger an exception, so we do not need any special handling here.
57$t_result = $t_command->execute();
58
59$t_redirect_url = 'manage_user_page.php';
60
61form_security_purge( 'manage_user_reset' );
62
63layout_page_header( null, $t_redirect_url );
64layout_page_begin( 'manage_overview_page.php' );
65
66switch( $t_result['action'] ) {
67	case UserResetPasswordCommand::RESULT_RESET:
68		if(    ( ON == config_get( 'send_reset_password' ) )
69			&& ( ON == config_get( 'enable_email_notification' ) )
70		) {
71			# Password reset confirmation sent by email
72			html_operation_successful( $t_redirect_url, lang_get( 'account_reset_msg' ) );
73		} else {
74			# Email notification disabled, password set to blank
75			html_operation_successful( $t_redirect_url, lang_get( 'account_reset_msg2' ) );
76		}
77		break;
78	case UserResetPasswordCommand::RESULT_UNLOCK:
79		html_operation_successful( $t_redirect_url, lang_get( 'account_unlock_msg' ) );
80		break;
81}
82
83layout_page_end();
84