diff -r 67a4c839c7e1 -r fcc42560afe6 plugins/SpecialUserPrefs.php --- a/plugins/SpecialUserPrefs.php Sun Aug 09 01:27:45 2009 -0400 +++ b/plugins/SpecialUserPrefs.php Mon Aug 10 22:43:26 2009 -0400 @@ -212,11 +212,10 @@ $db->_die(); $row = $db->fetchrow(); $db->free_result(); - $old_pass = $session->pk_decrypt($row['password'], ENC_HEX); $new_email = $_POST['newemail']; - $result = $session->update_user($session->user_id, false, $old_pass, false, $new_email); + $result = $session->change_email($session->user_id, $new_email); if ( $result != 'success' ) { $message = '

' . $lang->get('usercp_emailpassword_err_list') . '

'; @@ -226,9 +225,9 @@ $email_changed = true; } // Obtain password - if ( !empty($_POST['crypt_data']) || !empty($_POST['newpass']) ) + if ( !empty($_POST['crypt_data']) || !empty($_POST['newpass']) || $session->password_change_disabled ) { - $newpass = $session->get_aes_post('newpass'); + $newpass = $session->password_change_disabled ? '' : $session->get_aes_post('newpass'); // At this point we know if we _want_ to change the password... // We can't check the password to see if it matches the confirmation @@ -274,10 +273,31 @@ redirect(makeUrl(get_main_page()), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20); } } - $session->login_without_crypto($session->username, $newpass); + $session->login_without_crypto($username, $newpass); redirect(makeUrlNS('Special', 'Preferences'), $lang->get('usercp_emailpassword_msg_pass_success'), $lang->get('usercp_emailpassword_msg_password_changed'), 5); } } + else if ( $email_changed ) + { + $session->logout(USER_LEVEL_CHPREF); + $activation = $session->user_level >= USER_LEVEL_MOD ? 'none' : getConfig('account_activation', 'none'); + switch($activation) + { + default: + $message_body = $lang->get('usercp_emailpassword_msg_password_changed'); + $timeout = 5; + break; + case 'admin': + $message_body = $lang->get('usercp_emailpassword_msg_need_activ_user'); + $timeout = 20; + break; + case 'user': + $message_body = $lang->get('usercp_emailpassword_msg_need_activ_admin'); + $timeout = 20; + break; + } + redirect(makeUrlNS('Special', 'Preferences'), $lang->get('usercp_emailpassword_msg_email_success'), $message_body, $timeout); + } } } $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_emailpassword_title'); @@ -308,20 +328,32 @@ } echo '
'; + echo '
'; + echo '' . $lang->get('usercp_emailpassword_grp_chpasswd') . ''; // Password change form + if ( $session->password_change_disabled ) + { + echo '

' . $lang->get('usercp_emailpassword_msg_change_disabled') . '

'; + if ( $session->password_change_dest['url'] ) + { + echo '

' . $lang->get('usercp_emailpassword_msg_change_disabled_url') . ' + ' . htmlspecialchars($session->password_change_dest['title']) . '

'; + } + } + else + { + echo $lang->get('usercp_emailpassword_field_newpass') . '
+ ' . ( getConfig('pw_strength_enable') == '1' ? ' Loading...' : '' ) . ' +
+
+ ' . $lang->get('usercp_emailpassword_field_newpass_confirm') . '
+ + ' . ( getConfig('pw_strength_enable') == '1' ? '

+ ' . $lang->get('usercp_emailpassword_msg_password_min_score') . '' : '' ); + } + echo '

'; echo '
- ' . $lang->get('usercp_emailpassword_grp_chpasswd') . ' - ' . $lang->get('usercp_emailpassword_field_newpass') . '
- ' . ( getConfig('pw_strength_enable') == '1' ? ' Loading...' : '' ) . ' -
-
- ' . $lang->get('usercp_emailpassword_field_newpass_confirm') . '
- - ' . ( getConfig('pw_strength_enable') == '1' ? '

- ' . $lang->get('usercp_emailpassword_msg_password_min_score') . '' : '' ) . ' -

-
' . $lang->get('usercp_emailpassword_grp_chemail') . ' ' . $lang->get('usercp_emailpassword_field_newemail') . '
@@ -333,12 +365,14 @@
'; - echo $session->generate_aes_form(); + if ( !$session->password_change_disabled ) + echo $session->generate_aes_form(); + echo ''; // ENCRYPTION CODE ?> - + password_change_disabled && getConfig('pw_strength_enable') == '1' ): ?>