protected override void ShowPage() { if (userid == -1) { AddErrLine("你尚未登录"); return; } pagetitle = "查看短消息"; user = Discuz.Forum.Users.GetUserInfo(userid); pmid = DNTRequest.GetQueryInt("pmid", -1); if (pmid <= 0) { AddErrLine("参数无效"); return; } if (!UserCredits.CheckUserCreditsIsEnough(userid, 1, CreditsOperationType.SendMessage, -1)) { canreplypm = false; } PrivateMessageInfo messageinfo = PrivateMessages.GetPrivateMessageInfo(pmid); if (messageinfo == null) { AddErrLine("无效的短消息ID"); return; } if (messageinfo.Msgfrom == "系统" && messageinfo.Msgfromid == 0) { messageinfo.Message = Utils.HtmlDecode(messageinfo.Message); } if (messageinfo != null) { //判断当前用户是否有权阅读此消息 if (messageinfo.Msgtoid == userid || messageinfo.Msgfromid == userid) { string action = DNTRequest.GetQueryString("action"); if (action.CompareTo("del") == 0) { ispost = true; int retval = PrivateMessages.DeletePrivateMessage(userid, pmid); if (retval < 1) { AddErrLine("消息未找到,可能已被删除"); return; } else { AddMsgLine("指定消息成功删除,现在将转入消息列表"); SetUrl("usercpinbox.aspx"); SetMetaRefresh(); return; } } if (action.CompareTo("noread") == 0) { PrivateMessages.SetPrivateMessageState(pmid, 1); //将短消息的状态置 1 表示未读 ispost = true; if (messageinfo.New != 1 && messageinfo.Folder == 0) { Discuz.Forum.Users.DecreaseNewPMCount(userid, -1); //将用户的未读短信息数据加 1 AddMsgLine("指定消息已被置成未读状态,现在将转入消息列表"); SetUrl("usercpinbox.aspx"); SetMetaRefresh(); } } else { PrivateMessages.SetPrivateMessageState(pmid, 0); //将短消息的状态置 0 表示已读 if (messageinfo.New == 1 && messageinfo.Folder == 0) { Discuz.Forum.Users.DecreaseNewPMCount(userid); //将用户的未读短信息数据减 1 } } msgfrom = messageinfo.Msgfrom; subject = messageinfo.Subject; message = Utils.StrFormat(messageinfo.Message); postdatetime = messageinfo.Postdatetime; resubject = "re:" + messageinfo.Subject; remessage = Utils.HtmlEncode("> ") + messageinfo.Message.Replace("\n", "\n> ") + "\r\n\r\n"; return; } } AddErrLine("对不起, 短消息不存在或已被删除."); }
protected override void ShowPage() { if (!IsLogin()) { return; } pagetitle = "查看短消息"; if (pmid <= 0) { AddErrLine("参数无效"); return; } if (!CreditsFacade.IsEnoughCreditsPM(userid)) { canreplypm = false; } PrivateMessageInfo messageinfo = PrivateMessages.GetPrivateMessageInfo(pmid); if (messageinfo == null) { AddErrLine("无效的短消息ID"); return; } if (messageinfo.Msgfrom == "系统" && messageinfo.Msgfromid == 0) { messageinfo.Message = Utils.HtmlDecode(messageinfo.Message); } if (messageinfo != null && (messageinfo.Msgtoid == userid || messageinfo.Msgfromid == userid)) { //判断当前用户是否有权阅读此消息 if (DNTRequest.GetQueryString("action").CompareTo("delete") == 0) { ispost = true; if (PrivateMessages.DeletePrivateMessage(userid, pmid) < 1) { AddErrLine("消息未找到,可能已被删除"); return; } else { AddMsgLine("指定消息成功删除,现在将转入消息列表"); SetUrl("usercpinbox.aspx"); SetMetaRefresh(); return; } } if (DNTRequest.GetQueryString("action").CompareTo("noread") == 0) { PrivateMessages.SetPrivateMessageState(pmid, 1); //将短消息的状态置 1 表示未读 ispost = true; if (messageinfo.New != 1 && messageinfo.Folder == 0) { Users.UpdateUserNewPMCount(userid, olid); //将用户的未读短信息数据加 1 AddMsgLine("指定消息已被置成未读状态,现在将转入消息列表"); SetUrl("usercpinbox.aspx"); SetMetaRefresh(); } } else { PrivateMessages.SetPrivateMessageState(pmid, 0); //将短消息的状态置 0 表示已读 if (messageinfo.New == 1 && messageinfo.Folder == 0) { Users.UpdateUserNewPMCount(userid, olid); //将用户的未读短信息数据减 1 } } msgto = (messageinfo.Folder == 0) ? messageinfo.Msgfrom : messageinfo.Msgto; msgfrom = messageinfo.Msgfrom; subject = messageinfo.Subject; message = UBB.ParseUrl(Utils.StrFormat(messageinfo.Message)); postdatetime = messageinfo.Postdatetime; resubject = "re:" + messageinfo.Subject; remessage = Utils.HtmlEncode("> ") + messageinfo.Message.Replace("\n", "\n> ") + "\r\n\r\n"; return; } AddErrLine("对不起, 短消息不存在或已被删除."); newnoticecount = Notices.GetNewNoticeCountByUid(userid); }