Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a77f549

Browse files
committedDec 31, 2011
Merge branch 'fix-13690' into master-1.2.x
Happy new year ;-)
2 parents ce8f757 + cc61982 commit a77f549

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed
 

‎lang/strings_english.txt

+2
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ $s_confirm_account_pruning = 'Are you sure you want to delete old accounts that
975975

976976
# manage_user_page.php
977977
$s_edit_user_title = 'Edit User';
978+
$s_account_unlock_button = 'Unlock Account';
978979
$s_reset_password_button = 'Reset Password';
979980
$s_delete_user_button = 'Delete User';
980981
$s_reset_password_msg = 'Reset Password sends the confirmation URL via e-mail.';
@@ -987,6 +988,7 @@ $s_users_new = 'New';
987988
$s_account_reset_protected_msg = 'Account protected. Cannot reset the password.';
988989
$s_account_reset_msg = 'A confirmation request has been sent to the selected user\'s e-mail address. Using this, the user will be able to change their password.';
989990
$s_account_reset_msg2 = 'Account password has been set to blank...';
991+
$s_account_unlock_msg = 'The account has been unlocked.';
990992

991993
# manage_user_update.php
992994
$s_manage_user_protected_msg = 'Account protected. Access level and enabled protected. Otherwise, account has been updated...';

‎manage_user_edit_page.php

+27-16
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
?>
120120
</td>
121121
</tr>
122-
122+
123123
<!-- Access Level -->
124124
<tr <?php echo helper_alternate_class() ?>>
125125
<td class="category">
@@ -175,38 +175,49 @@
175175
<br />
176176

177177
<!-- RESET AND DELETE -->
178+
<?php
179+
$t_reset = helper_call_custom_function( 'auth_can_change_password', array() );
180+
$t_unlock = OFF != config_get( 'max_failed_login_count' ) && $t_user['failed_login_count'] > 0;
181+
$t_delete = !( ( user_is_administrator( $t_user_id ) && ( user_count_level( config_get_global( 'admin_site_threshold' ) ) <= 1 ) ) );
182+
183+
if( $t_reset || $t_unlock || $t_delete ) {
184+
?>
178185
<div class="border center">
179186

180-
<!-- Reset Button -->
181-
<?php if( helper_call_custom_function( 'auth_can_change_password', array() ) ) { ?>
187+
<!-- Reset/Unlock Button -->
188+
<?php if( $t_reset || $t_unlock ) { ?>
182189
<form method="post" action="manage_user_reset.php">
183190
<?php echo form_security_field( 'manage_user_reset' ) ?>
184191
<input type="hidden" name="user_id" value="<?php echo $t_user['id'] ?>" />
192+
<?php if( $t_reset ) { ?>
185193
<input type="submit" class="button" value="<?php echo lang_get( 'reset_password_button' ) ?>" />
194+
<?php } else { ?>
195+
<input type="submit" class="button" value="<?php echo lang_get( 'account_unlock_button' ) ?>" />
196+
<?php } ?>
186197
</form>
187198
<?php } ?>
188199

189200
<!-- Delete Button -->
190-
<?php if ( !( ( user_is_administrator( $t_user_id ) && ( user_count_level( config_get_global( 'admin_site_threshold' ) ) <= 1 ) ) ) ) { ?>
201+
<?php if ( $t_delete ) { ?>
191202
<form method="post" action="manage_user_delete.php">
192203
<?php echo form_security_field( 'manage_user_delete' ) ?>
193-
194204
<input type="hidden" name="user_id" value="<?php echo $t_user['id'] ?>" />
195205
<input type="submit" class="button" value="<?php echo lang_get( 'delete_user_button' ) ?>" />
196206
</form>
197207
<?php } ?>
198208
</div>
199-
<br />
200-
<?php if( !$t_ldap ) { ?>
201-
<div align="center">
202-
<?php
203-
if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
204-
echo lang_get( 'reset_password_msg' );
205-
} else {
206-
echo lang_get( 'reset_password_msg2' );
207-
}
208-
?>
209-
</div>
209+
<?php if( $t_reset ) { ?>
210+
<div align="center">
211+
<br />
212+
<?php
213+
if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
214+
echo lang_get( 'reset_password_msg' );
215+
} else {
216+
echo lang_get( 'reset_password_msg2' );
217+
}
218+
?>
219+
</div>
220+
<?php } ?>
210221
<?php } ?>
211222

212223

‎manage_user_reset.php

+23-12
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@
4040
# current user.
4141
access_ensure_global_level( $t_user['access_level'] );
4242

43-
if ( !helper_call_custom_function( 'auth_can_change_password', array() ) ) {
44-
trigger_error( ERROR_LOST_PASSWORD_NOT_ENABLED, ERROR );
43+
# If the password can be changed, we reset it, otherwise we unlock
44+
# the account (i.e. reset failed login count)
45+
$t_reset = helper_call_custom_function( 'auth_can_change_password', array() );
46+
47+
if ( $t_reset ) {
48+
$t_result = user_reset_password( $f_user_id );
49+
} else {
50+
$t_result = user_reset_failed_login_count_to_zero( $f_user_id );
4551
}
4652

4753
$t_result = user_reset_password( $f_user_id );
@@ -54,18 +60,23 @@
5460
echo '<br />';
5561
echo '<div align="center">';
5662

57-
if ( false == $t_result ) {
58-
# PROTECTED
59-
echo lang_get( 'account_reset_protected_msg' ) . '<br />';
60-
} else {
61-
# SUCCESS
62-
if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
63-
# send the new random password via email
64-
echo lang_get( 'account_reset_msg' ) . '<br />';
63+
if ( $t_reset ) {
64+
if ( false == $t_result ) {
65+
# PROTECTED
66+
echo lang_get( 'account_reset_protected_msg' ) . '<br />';
6567
} else {
66-
# email notification disabled, then set the password to blank
67-
echo lang_get( 'account_reset_msg2' ) . '<br />';
68+
# SUCCESSFUL RESET
69+
if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
70+
# send the new random password via email
71+
echo lang_get( 'account_reset_msg' ) . '<br />';
72+
} else {
73+
# email notification disabled, then set the password to blank
74+
echo lang_get( 'account_reset_msg2' ) . '<br />';
75+
}
6876
}
77+
} else {
78+
# UNLOCK
79+
echo lang_get( 'account_unlock_msg' ) . '<br />';
6980
}
7081

7182
print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );

0 commit comments

Comments
 (0)
Please sign in to comment.