$package('itsm.security')
/**  
* @fileOverview 修改用户密码主函数.
* @author Tan
* @version 1.0  
*/  
/**  
* @author Tan  
* @constructor 修改用户密码主函数.
* @description 修改用户密码主函数.
* @date 2011-05-28
* @since version 1.0 
*/
itsm.security.editUserPassword=function(){
	
	return {
		
		editUserPassword:function(){
			if($('#edit_user_password_form').form('validate')){
				var _param = $('#edit_user_password_div form').serialize();
				$.post('user!resetPassword.action',_param,function(data){
					if(data){
						$('#oldPassword,#newPassword,#repeatPassword').val('');
						msgShow(i18n['editSuccess'],'show');
					}else{
						$.messager.alert(i18n['msg_msg'],'<br/>'+i18n['oldPasswordError'],'error');
					}
				})
			}	
		},
		userPasswordReset:function(loginName){
			$.messager.confirm(i18n['msg_msg'],'<br/>'+i18n['confirmUserPasswordReset'],function(r){
				if(r){
					$.post('user!resetPassword.action','editUserPasswordDTO.loginName='+loginName+'&editUserPasswordDTO.resetPassword=resetPassword',function(data){
						$('#password,#rpassword').val('Password123');
						msgShow(i18n['editSuccess'],'show');
						$.post('email!sendMailByLoginName.action','loginName='+loginName+'&title='+i18n['passwordReset']+'&content='+loginName+i18n['passwordResetInfo'],function(result){
						});
						
						
					})
				}
			});
			
		},
		init:function(){
			$('#link_eidt_user_password').click(itsm.security.editUserPassword.editUserPassword);
		}
	}
}();

$(document).ready(itsm.security.editUserPassword.init);

