/// <summary> /// 装载帖子列表 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <param name="reader"></param> /// <returns></returns> public static List <ShowtopicPagePostInfo> LoadPostList(PostpramsInfo postpramsInfo, IDataReader reader) { List <ShowtopicPagePostInfo> postList = new List <ShowtopicPagePostInfo>(); //序号(楼层)的初值 int id = (postpramsInfo.Pageindex - 1) * postpramsInfo.Pagesize; while (reader.Read()) { //当帖子中的posterid字段为0时, 表示该数据出现异常 if (TypeConverter.ObjectToInt(reader["posterid"]) == 0) { continue; } ShowtopicPagePostInfo postInfo = LoadSingleShowtopicPagePostInfo(reader); //扩展属性 id++; postInfo.Id = id; postList.Add(postInfo); } reader.Close(); return(postList); }
/// <summary> /// 获取ShowtopicPagePostInfo对象与ShowtopicPageAttachmentInfo对象列表 /// </summary> /// <param name="postPramsInfo">参数对象</param> /// <param name="attachmentList">输出附件列表</param> /// <returns></returns> public static ShowtopicPagePostInfo GetPostInfoWithAttachments(PostpramsInfo postPramsInfo, out List <ShowtopicPageAttachmentInfo> attachmentList) { attachmentList = new List <ShowtopicPageAttachmentInfo>(); //得到帖子对应主题的所有附件,因为ACCESS不支持存储过程,故此方法在ACCESS版中做了特殊处理 IDataReader attachmentReader; IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(out attachmentReader, postPramsInfo, PostTables.GetPostTableId(postPramsInfo.Tid)); //Access版运行此处逻辑 bool isAccess = false; if (attachmentReader == null) { attachmentReader = reader; } else { isAccess = true; } while (attachmentReader.Read()) { attachmentList.Add(Attachments.LoadSingleAttachmentInfo(attachmentReader)); } //bool next = false; //Access版运行此处逻辑 if (!isAccess) { reader.NextResult(); } ShowtopicPagePostInfo postInfo = null; if (reader.Read()) { postInfo = LoadSingleShowtopicPagePostInfo(reader); } reader.Close(); if (!attachmentReader.IsClosed) { attachmentReader.Close(); } return(postInfo); }
/// <summary> /// 获取帖子参数信息(PostPramsInfo) /// </summary> /// <param name="price"></param> /// <returns></returns> public PostpramsInfo GetPostPramsInfo(int price) { //获取当前页主题列表 PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Fid = forum.Fid; postpramsInfo.Tid = topicid; postpramsInfo.Jammer = forum.Jammer; postpramsInfo.Pagesize = pagesize; // 得到Ppp设置 postpramsInfo.Pageindex = pageid; postpramsInfo.Getattachperm = forum.Getattachperm; postpramsInfo.Usergroupid = usergroupid; postpramsInfo.Attachimgpost = config.Attachimgpost; postpramsInfo.Showattachmentpath = config.Showattachmentpath; postpramsInfo.Price = price; postpramsInfo.Usergroupreadaccess = (ismoder == 1) ? int.MaxValue : usergroupinfo.Readaccess; postpramsInfo.CurrentUserid = userid; postpramsInfo.Showimages = forum.Allowimgcode; postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); postpramsInfo.Smiliesmax = config.Smiliesmax; postpramsInfo.Bbcodemode = config.Bbcodemode; postpramsInfo.CurrentUserGroup = usergroupinfo; postpramsInfo.Topicinfo = topic; postpramsInfo.Condition = Posts.GetPostPramsInfoCondition(onlyauthor, topicid, topic.Posterid); //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容 //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见 postpramsInfo.Hide = (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1)) ? -1 : 1; postpramsInfo.Pid = Posts.GetFirstPostId(topic.Tid); UserInfo userInfo = Users.GetUserInfo(userid); postpramsInfo.Usercredits = userInfo == null ? 0 : userInfo.Credits; debatepost = Posts.GetSinglePost(postpramsInfo, out attachmentlist, ismoder == 1); postpramsInfo.Pid = 0; return(postpramsInfo); }
/// <summary> /// 根据附件加载帖子内容 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <param name="attachList">附件列表</param> /// <param name="isModer">是否是管理人员</param> /// <param name="allowGetAttach">是否允许获取附件</param> /// <param name="originalHideStatus">帖子原始Hide属性</param> /// <param name="postInfo">帖子信息 </param> private static void LoadPostMessage(PostpramsInfo postpramsInfo, List <ShowtopicPageAttachmentInfo> attachList, bool isModer, int allowGetAttach, int originalHideStatus, ShowtopicPagePostInfo postInfo) { UserGroupInfo tmpGroupInfo; if (!Utils.InArray(postInfo.Groupid.ToString(), "4,5,6")) { //处理帖子内容 postpramsInfo.Smileyoff = postInfo.Smileyoff; postpramsInfo.Bbcodeoff = postInfo.Bbcodeoff; postpramsInfo.Parseurloff = postInfo.Parseurloff; postpramsInfo.Allowhtml = postInfo.Htmlon; postpramsInfo.Sdetail = postInfo.Message; postpramsInfo.Pid = postInfo.Pid; //校正hide处理 tmpGroupInfo = UserGroups.GetUserGroupInfo(postInfo.Groupid); if (tmpGroupInfo.Allowhidecode == 0) { postpramsInfo.Hide = 0; } //先简单判断是否是动网兼容模式 if (!postpramsInfo.Ubbmode) { postInfo.Message = UBB.UBBToHTML(postpramsInfo); } else { postInfo.Message = Utils.HtmlEncode(postInfo.Message); } if (postpramsInfo.Jammer == 1) { postInfo.Message = ForumUtils.AddJammer(postInfo.Message); } string message = postInfo.Message; if (postInfo.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message)) { //获取在[hide]标签中的附件id string[] attHidArray = Posts.GetHiddenAttachIdList(postpramsInfo.Sdetail, postpramsInfo.Hide); List <ShowtopicPageAttachmentInfo> attachDeleteList = new List <ShowtopicPageAttachmentInfo>(); foreach (ShowtopicPageAttachmentInfo attach in attachList) { message = Attachments.GetMessageWithAttachInfo(postpramsInfo, allowGetAttach, attHidArray, postInfo, attach, message); if ((postpramsInfo.CurrentUserGroup.Radminid == 1 || attach.Uid == postpramsInfo.CurrentUserid || attach.Attachprice <= 0 || attach.Isbought == 1) ||//当为发帖人或不为收费附件或已购买该收费附件时 Utils.InArray(attach.Aid.ToString(), attHidArray)) { ; } else { attachDeleteList.Add(attach); } } foreach (ShowtopicPageAttachmentInfo attach in attachDeleteList) { attachList.Remove(attach); } postInfo.Message = message; } //恢复hide初值 postpramsInfo.Hide = originalHideStatus; } else//发帖人已经被禁止发言 { if (isModer) { postInfo.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽, 您拥有管理权限, 以下是帖子内容</div>" + postInfo.Message; } else { postInfo.Message = "该用户帖子内容已被屏蔽"; List <ShowtopicPageAttachmentInfo> delattlist = new List <ShowtopicPageAttachmentInfo>(); foreach (ShowtopicPageAttachmentInfo attach in attachList) { if (attach.Pid == postInfo.Pid) { delattlist.Add(attach); } } foreach (ShowtopicPageAttachmentInfo attach in delattlist) { attachList.Remove(attach); } } } }
/// <summary> /// 装载ShowtopicPagePostInfo对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static ShowtopicPagePostInfo LoadSingleShowtopicPagePostInfo(IDataReader reader) { ShowtopicPagePostInfo postInfo = new ShowtopicPagePostInfo(); postInfo.Pid = Int32.Parse(reader["pid"].ToString()); postInfo.Attachment = Int32.Parse(reader["attachment"].ToString()); postInfo.Fid = TypeConverter.ObjectToInt(reader["fid"]); postInfo.Title = reader["title"].ToString().Trim(); postInfo.Layer = Int32.Parse(reader["layer"].ToString()); postInfo.Message = reader["message"].ToString().TrimEnd(); postInfo.Lastedit = reader["lastedit"].ToString().Trim(); postInfo.Postdatetime = reader["postdatetime"].ToString().Trim(); postInfo.Poster = reader["poster"].ToString().Trim(); postInfo.Posterid = Int32.Parse(reader["posterid"].ToString()); postInfo.Invisible = Int32.Parse(reader["invisible"].ToString()); postInfo.Usesig = Int32.Parse(reader["usesig"].ToString()); postInfo.Htmlon = Int32.Parse(reader["htmlon"].ToString()); postInfo.Smileyoff = Int32.Parse(reader["smileyoff"].ToString()); postInfo.Parseurloff = Int32.Parse(reader["parseurloff"].ToString()); postInfo.Bbcodeoff = Int32.Parse(reader["bbcodeoff"].ToString()); postInfo.Rate = Int32.Parse(reader["rate"].ToString()); postInfo.Ratetimes = Int32.Parse(reader["ratetimes"].ToString()); postInfo.Ubbmessage = reader["message"].ToString().TrimEnd(); if (postInfo.Posterid > 0) { postInfo.Oltime = reader["oltime"].ToString().Trim(); postInfo.Lastvisit = reader["lastvisit"].ToString().Trim(); postInfo.Nickname = reader["nickname"].ToString().Trim(); postInfo.Username = reader["username"].ToString().Trim(); postInfo.Groupid = Utils.StrToInt(reader["groupid"], 0); postInfo.Spaceid = Utils.StrToInt(reader["spaceid"], 0); postInfo.Gender = Utils.StrToInt(reader["gender"], 2); postInfo.Bday = reader["bday"].ToString().Trim(); postInfo.Showemail = Utils.StrToInt(reader["showemail"], 0); postInfo.Digestposts = Utils.StrToInt(reader["digestposts"], 0); postInfo.Credits = Utils.StrToInt(reader["credits"], 0); postInfo.Extcredits1 = TypeConverter.StrToFloat(reader["extcredits1"].ToString()); postInfo.Extcredits2 = TypeConverter.StrToFloat(reader["extcredits2"].ToString()); postInfo.Extcredits3 = TypeConverter.StrToFloat(reader["extcredits3"].ToString()); postInfo.Extcredits4 = TypeConverter.StrToFloat(reader["extcredits4"].ToString()); postInfo.Extcredits5 = TypeConverter.StrToFloat(reader["extcredits5"].ToString()); postInfo.Extcredits6 = TypeConverter.StrToFloat(reader["extcredits6"].ToString()); postInfo.Extcredits7 = TypeConverter.StrToFloat(reader["extcredits7"].ToString()); postInfo.Extcredits8 = TypeConverter.StrToFloat(reader["extcredits8"].ToString()); postInfo.Posts = Utils.StrToInt(reader["posts"], 0); postInfo.Joindate = reader["joindate"].ToString().Trim(); postInfo.Lastactivity = reader["lastactivity"].ToString().Trim(); postInfo.Userinvisible = Int32.Parse(reader["invisible"].ToString()); postInfo.Avatar = reader["avatar"].ToString(); postInfo.Avatarwidth = Utils.StrToInt(reader["avatarwidth"], 0); postInfo.Avatarheight = Utils.StrToInt(reader["avatarheight"], 0); postInfo.Medals = reader["medals"].ToString(); postInfo.Signature = reader["signature"].ToString(); postInfo.Location = reader["location"].ToString(); postInfo.Customstatus = reader["customstatus"].ToString(); postInfo.Website = reader["website"].ToString(); postInfo.Icq = reader["icq"].ToString(); postInfo.Qq = reader["qq"].ToString(); postInfo.Msn = reader["msn"].ToString(); postInfo.Yahoo = reader["yahoo"].ToString(); postInfo.Skype = reader["skype"].ToString(); //部分属性需要根据不同情况来赋值 //根据用户自己的设置决定是否显示邮箱地址 if (postInfo.Showemail == 0) { postInfo.Email = ""; } else { postInfo.Email = reader["email"].ToString().Trim(); } // 最后活动时间50分钟内的为在线, 否则不在线 if (Utils.StrDateDiffMinutes(postInfo.Lastactivity, 50) < 0) { postInfo.Onlinestate = 1; } else { postInfo.Onlinestate = 0; } //作者ID为-1即表明作者为游客, 为了区分会直接公开显示游客发帖时的IP, 这里将IP最后一位修改为* postInfo.Ip = reader["ip"].ToString().Trim(); } else { postInfo.Nickname = "游客"; postInfo.Username = "******"; postInfo.Groupid = 7; postInfo.Showemail = 0; postInfo.Digestposts = 0; postInfo.Credits = 0; postInfo.Extcredits1 = 0; postInfo.Extcredits2 = 0; postInfo.Extcredits3 = 0; postInfo.Extcredits4 = 0; postInfo.Extcredits5 = 0; postInfo.Extcredits6 = 0; postInfo.Extcredits7 = 0; postInfo.Extcredits8 = 0; postInfo.Posts = 0; postInfo.Joindate = "2006-9-1 1:1:1"; postInfo.Lastactivity = "2006-9-1 1:1:1";; postInfo.Userinvisible = 0; postInfo.Avatar = ""; postInfo.Avatarwidth = 0; postInfo.Avatarheight = 0; postInfo.Medals = ""; postInfo.Signature = ""; postInfo.Location = ""; postInfo.Customstatus = ""; postInfo.Website = ""; postInfo.Icq = ""; postInfo.Qq = ""; postInfo.Msn = ""; postInfo.Yahoo = ""; postInfo.Skype = ""; //部分属性需要根据不同情况来赋值 postInfo.Email = ""; postInfo.Onlinestate = 1; postInfo.Medals = ""; postInfo.Ip = reader["ip"].ToString().Trim(); if (postInfo.Ip.IndexOf('.') > -1) { postInfo.Ip = postInfo.Ip.Substring(0, postInfo.Ip.LastIndexOf(".") + 1) + "*"; } } return(postInfo); }