* @ajax_enabled
*/
protected ActionForward doAddFriend(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
FormBean fbean = (FormBean) form;
validateClientId(request, fbean);
String msg = null;
//�ж��û��Ƿ��¼
SessionUserObject loginUser = super.getLoginUser(request, response, false);
if(loginUser != null){
int friendId = RequestUtils.getParam(request, "uid", -1);
UserBean friend = UserDAO.getUserByID(friendId);
if(friend==null)
msg = getMessage(request,null,"error.user_not_found", new Integer(friendId));
else if(friendId == loginUser.getId())
msg = getMessage(request,null,"error.cannot_add_myself");
else{
FriendBean fb = new FriendBean();
fb.setAddTime(new Date());
fb.setFriend(friend);
fb.setOwner(loginUser.getId());
fb.setType(FriendBean.TYPE_GENERAL);
fb.setRole(FriendBean.ROLE_GENERAL);
UserDAO.addFriend(fb);
msg = getMessage(request,null,"error.friend_added", new Integer(friendId));
}
}
else
msg = getMessage(request,null,"error.user_not_login");
return msgbox(mapping,form,request,response,msg,fbean.getFromPage());
}