public static PostInfo GetLastPostByTid(int tid, string tableName) { PostInfo postinfo = new PostInfo(); DataTable dt = DatabaseProvider.GetInstance().GetLastPostByTid(tid, tableName); if (dt.Rows.Count > 0) { postinfo.Pid = TypeConverter.ObjectToInt(dt.Rows[0]["pid"]); postinfo.Tid = TypeConverter.ObjectToInt(dt.Rows[0]["tid"]); postinfo.Title = dt.Rows[0]["title"].ToString().Trim(); postinfo.Postdatetime = dt.Rows[0]["postdatetime"].ToString().Trim(); postinfo.Poster = dt.Rows[0]["poster"].ToString().Trim(); postinfo.Posterid = TypeConverter.ObjectToInt(dt.Rows[0]["posterid"]); postinfo.Topictitle = Topics.GetTopicInfo(postinfo.Tid, 0, 0).Title; } else { postinfo.Pid = 0; postinfo.Tid = 0; postinfo.Title = "从未"; postinfo.Topictitle = "从未"; postinfo.Postdatetime = "1900-1-1"; postinfo.Poster = ""; postinfo.Posterid = 0; } dt.Dispose(); return postinfo; }
/// <summary> /// 创建帖子 /// </summary> /// <param name="postInfo">帖子信息</param> /// <param name="postTableId">分表ID</param> /// <returns>帖子ID</returns> public static int CreatePost(PostInfo postInfo, string postTableId) { int postId = DatabaseProvider.GetInstance().CreatePost(postInfo, postTableId); //更新TTCache缓存中的用户信息 if (postInfo.Invisible == 0 && Users.appDBCache && Users.IUserService != null) { UserInfo userInfo = Users.IUserService.GetUserInfo(postInfo.Posterid); if (userInfo != null) { userInfo.Lastpost = postInfo.Postdatetime; userInfo.Lastpostid = postId; userInfo.Lastposttitle = postInfo.Title; userInfo.Posts = userInfo.Posts + 1; userInfo.Lastactivity = DateTime.Now.ToString(); userInfo.Newpm = 1; Users.IUserService.UpdateUser(userInfo); } } //更新Cache缓存中的用户信息 if (postInfo.Invisible == 0 && Topics.appDBCache && Topics.ITopicService != null) Topics.ITopicService.ResetTopicByTid(postInfo.Tid); //创建Cache缓存中的帖子信息(权限于当前正在使用的分表) if (appDBCache && IPostService != null && PostTables.GetPostTableId(postInfo.Tid) == postTableId) { postInfo.Pid = postId; IPostService.CreatePost(postInfo, postTableId); } return postId; }
/// <summary> /// 发送回复通知 /// </summary> /// <param name="postinfo">回复信息</param> /// <param name="topicinfo">所属主题信息</param> /// <param name="replyuserid">回复的某一楼的作者</param> public static void SendPostReplyNotice(PostInfo postinfo, TopicInfo topicinfo, int replyuserid) { NoticeInfo noticeinfo = new NoticeInfo(); noticeinfo.Note = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 给您回帖, <a href =\"showtopic.aspx?topicid={2}&postid={3}#{3}\">{4}</a>.", postinfo.Posterid, postinfo.Poster, topicinfo.Tid, postinfo.Pid, topicinfo.Title)); noticeinfo.Type = NoticeType.PostReplyNotice; noticeinfo.New = 1; noticeinfo.Posterid = postinfo.Posterid; noticeinfo.Poster = postinfo.Poster; noticeinfo.Postdatetime = Utils.GetDateTime(); noticeinfo.Fromid = topicinfo.Tid; noticeinfo.Uid = replyuserid; //当回复人与帖子作者不是同一人时,则向帖子作者发送通知 if (postinfo.Posterid != replyuserid && replyuserid > 0) { Notices.CreateNoticeInfo(noticeinfo); } //当上面通知的用户与该主题作者不同,则还要向主题作者发通知 if (postinfo.Posterid != topicinfo.Posterid && topicinfo.Posterid != replyuserid && topicinfo.Posterid > 0) { noticeinfo.Uid = topicinfo.Posterid; Notices.CreateNoticeInfo(noticeinfo); } }
public static PostInfo GetPostInfo(string postTableId, int pid) { PostInfo postInfo = new PostInfo(); IDataReader reader = DatabaseProvider.GetInstance().GetPostInfo(postTableId, pid); if (reader.Read()) { postInfo = LoadSinglePostInfo(reader); reader.Close(); return postInfo; } reader.Close(); return null; }
protected override void OnTopicCreated(TopicInfo topic, PostInfo post, AttachmentInfo[] attachs) { SpacePostInfo spacepost = new SpacePostInfo(); spacepost.Author = post.Poster; string content = Posts.GetPostMessageHTML(post, attachs); spacepost.Category = ""; spacepost.Content = content; spacepost.Postdatetime = DateTime.Now; spacepost.PostStatus = 1; spacepost.PostUpDateTime = DateTime.Now; spacepost.Title = post.Title; spacepost.Uid = post.Posterid; DbProvider.GetInstance().AddSpacePost(spacepost); }
public void Edit(Discuz.Entity.PostInfo post) { OnPostEdited(post); }
/// <summary> /// 创建帖子 /// </summary> /// <param name="postinfo">帖子信息类</param> /// <returns>返回帖子id</returns> public int CreatePost(PostInfo postinfo, string posttableid) { IDataParameter[] prams = { DbHelper.MakeInParam("@fid",(DbType)SqlDbType.SmallInt,2,postinfo.Fid), DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,postinfo.Tid), DbHelper.MakeInParam("@parentid",(DbType)SqlDbType.Int,4,postinfo.Parentid), DbHelper.MakeInParam("@layer",(DbType)SqlDbType.Int,4,postinfo.Layer), DbHelper.MakeInParam("@poster",(DbType)SqlDbType.VarChar,15,postinfo.Poster), DbHelper.MakeInParam("@posterid",(DbType)SqlDbType.Int,4,postinfo.Posterid), DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,60,postinfo.Title), DbHelper.MakeInParam("@postdatetime",(DbType)SqlDbType.SmallDateTime,4, DateTime.Parse(postinfo.Postdatetime)), DbHelper.MakeInParam("@message",(DbType)SqlDbType.NText,0,postinfo.Message), DbHelper.MakeInParam("@ip",(DbType)SqlDbType.VarChar,15,postinfo.Ip), DbHelper.MakeInParam("@lastedit",(DbType)SqlDbType.NVarChar,50,postinfo.Lastedit), DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.Int,4,postinfo.Invisible), DbHelper.MakeInParam("@usesig",(DbType)SqlDbType.Int,4,postinfo.Usesig), DbHelper.MakeInParam("@htmlon",(DbType)SqlDbType.Int,4,postinfo.Htmlon), DbHelper.MakeInParam("@smileyoff",(DbType)SqlDbType.Int,4,postinfo.Smileyoff), DbHelper.MakeInParam("@bbcodeoff",(DbType)SqlDbType.Int,4,postinfo.Bbcodeoff), DbHelper.MakeInParam("@parseurloff",(DbType)SqlDbType.Int,4,postinfo.Parseurloff), DbHelper.MakeInParam("@attachment",(DbType)SqlDbType.Int,4,postinfo.Attachment), DbHelper.MakeInParam("@rate",(DbType)SqlDbType.SmallInt,2,postinfo.Rate), DbHelper.MakeInParam("@ratetimes",(DbType)SqlDbType.Int,4,postinfo.Ratetimes) }; return Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure, string.Format("{0}createpost{1}", BaseConfigs.GetTablePrefix, posttableid), prams).ToString(), -1); }
public void UpdateLastPost(ForumInfo forumInfo, PostInfo postInfo) { UpdateLastPost(postInfo.Tid, postInfo.Topictitle, postInfo.Postdatetime.ToString(), postInfo.Posterid, postInfo.Poster, forumInfo.Fid, forumInfo.Parentidlist); }
public void Delete(Discuz.Entity.PostInfo post) { OnPostDeleted(post); }
/// <summary> /// 根据主题ID列表取出主题帖子 /// </summary> /// <param name="posttableid">分表ID</param> /// <param name="tidlist">主题ID列表</param> /// <returns></returns> public static void WriteAggregationPostData(PostInfo[] posts, string tablelist, string tidlist, string configPath, string topiclistnodepath, string websitetopiclistnodepath) { //得到所选择帖子信息 DataTable dt = Data.Posts.GetTopicListByTidlist(tablelist, tidlist); Discuz.Common.Xml.XmlDocumentExtender doc = new Discuz.Common.Xml.XmlDocumentExtender(); if (File.Exists(configPath)) doc.Load(configPath); //清除以前选择 XmlNode topiclistnode = doc.InitializeNode(topiclistnodepath, false); XmlNode oldTopicListNode = topiclistnode.Clone(); //复制一份到新节点 topiclistnode.RemoveAll(); //清除新节点的内容,只存留其结构 XmlNode websitetopiclistnode = doc.InitializeNode(websitetopiclistnodepath); string selecttidlist = DNTRequest.GetString("tid"); foreach (string tid in tidlist.Split(',')) { XmlNode topic = GetOldTopicNode(oldTopicListNode, tid); if (topic == null) { topic = GetTopicInDataTable(posts, dt, doc, tid); } if (topic != null) topiclistnode.AppendChild(topic); } foreach (XmlNode node in topiclistnode) { if (("," + selecttidlist + ",").IndexOf("," + node.ChildNodes[20].InnerText + ",") >= 0) websitetopiclistnode.AppendChild(node.Clone()); } doc.Save(configPath); }
/// <summary> /// 更新指定帖子信息 /// </summary> /// <param name="postsInfo">帖子信息</param> /// <returns>更新数量</returns> public static int UpdatePost(PostInfo postInfo) { if (postInfo == null || postInfo.Pid < 1) return 0; RemoveShowTopicCache(postInfo.Tid.ToString()); return Data.Posts.UpdatePost(postInfo, GetPostTableId(postInfo.Tid)); }
/// <summary> /// 是否有编辑帖子的权限 /// </summary> /// <param name="postInfo"></param> /// <param name="userId"></param> /// <param name="userAdminId"></param> /// <param name="msg"></param> /// <returns></returns> public static bool CanEditPost(PostInfo postInfo, int userId, int userAdminId, ref string msg) { //非创始人且作者与当前编辑者不同时 if (postInfo.Posterid != userId && BaseConfigs.GetFounderUid != userId) { // Edit By Cyrano, 忽视创始人逻辑 //if (postInfo.Posterid == BaseConfigs.GetFounderUid) //{ // msg = "您无权编辑创始人的帖子"; // return false; //} // Edit By Cyrano, 忽视管理组的等级限定 //if (postInfo.Posterid != -1) //{ // UserGroupInfo postergroup = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(postInfo.Posterid).Groupid); // if (postergroup.Radminid > 0 && postergroup.Radminid < userAdminId) // { // msg = "您无权编辑更高权限人的帖子"; // return false; // } //} } return true; }
/// <summary> /// 附件操作 /// </summary> /// <param name="attachmentinfo">附件信息</param> /// <param name="topicId">主题id</param> /// <param name="postId">帖子id</param> /// <param name="postInfo">帖子信息</param> /// <param name="returnMsg">返回信息</param> /// <param name="userId">当前用户id</param> /// <param name="config">配置信息</param> /// <param name="userGroupInfo">当前用户组信息</param> /// <returns></returns> public static bool UpdateAttachment(AttachmentInfo[] attachmentArray, int topicId, int postId, PostInfo postInfo, ref StringBuilder returnMsg, int userId, GeneralConfigInfo config, UserGroupInfo userGroupInfo) { if (attachmentArray == null) return false; if (attachmentArray.Length > config.Maxattachments) { //returnMsg = new StringBuilder("系统设置为每个帖子附件不得多于" + config.Maxattachments + "个"); returnMsg = new StringBuilder(); returnMsg.AppendFormat("您添加了{0}个图片/附件,多于系统设置的{1}个.<br/>请重新编辑该帖并删除多余图片/附件.", attachmentArray.Length, config.Maxattachments); return false; } int newAttachCount = Attachments.BindAttachment(attachmentArray, topicId, postId, userId, userGroupInfo); //int errorAttachment = Attachments.BindAttachment(attachmentinfoarray, postid, sb, topicid, userid, usergroupinfo, out newAttachCount); int[] aid = new int[attachmentArray.Length]; int attType = 0;//普通附件,2为图片附件 for (int i = 0; i < attachmentArray.Length; i++) { //attachmentinfoarray[i].Tid = topicid; //attachmentinfoarray[i].Pid = postid; Attachments.UpdateAttachment(attachmentArray[i]); aid[i] = attachmentArray[i].Aid; attType = attachmentArray[i].Filetype.ToLower().StartsWith("image") ? 2 : 1; } string tempMessage = Attachments.FilterLocalTags(aid, attachmentArray, postInfo.Message); if (tempMessage != postInfo.Message) { postInfo.Message = tempMessage; postInfo.Pid = postId; Posts.UpdatePost(postInfo); } if (newAttachCount > 0) UserCredits.UpdateUserExtCreditsByUploadAttachment(userId, newAttachCount); UpdateTopicAndPostAttachmentType(topicId, postId, attType); return true; }
protected override void ShowPage() { //pagetitle = "编辑帖子"; #region 判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); this.disablepostctrl = 0; if (admininfo != null) disablepostctrl = admininfo.Disablepostctrl; #endregion if (userid == -1) { forum = new ForumInfo(); topic = new TopicInfo(); postinfo = new PostInfo(); AddErrLine("您尚未登录"); return; } #region 获取帖子和主题相关信息 // 如果帖子ID非数字 if (postid == -1) { AddErrLine("无效的帖子ID"); return; } postinfo = Posts.GetPostInfo(topicid, postid); // 如果帖子不存在 if (postinfo == null) { AddErrLine("不存在的帖子ID"); return; } pagetitle = (postinfo.Title == "") ? "编辑帖子" : postinfo.Title; htmlon = postinfo.Htmlon; message = postinfo.Message; isfirstpost = postinfo.Layer == 0; // 获取主题ID if (topicid != postinfo.Tid || postinfo.Tid == -1) { AddErrLine("无效的主题ID"); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(postinfo.Tid); // 如果该主题不存在 if (topic == null) { AddErrLine("不存在的主题ID"); return; } if (topic.Special == 1 && postinfo.Layer == 0) { pollinfo = Polls.GetPollInfo(topic.Tid); polloptionlist = Polls.GetPollOptionList(topic.Tid); } if (topic.Special == 4 && postinfo.Layer == 0) { debateinfo = Debates.GetDebateTopic(topic.Tid); } #endregion #region 获取并检查版块信息 ///得到所在版块信息 forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepostctrl, usergroupinfo); // 如果该版块不存在 if (forum == null || forum.Layer == 0) { AddErrLine("版块已不存在"); forum = new ForumInfo(); return; } if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (forum.Applytopictype == 1) //启用主题分类 topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); customeditbuttons = Caches.GetCustomEditButtonList(); #endregion //是否有编辑帖子的权限 if (!UserAuthority.CanEditPost(postinfo, userid, useradminid, ref msg)) { AddErrLine(msg); return; } #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); userinfo = Users.GetShortUserInfo(userid); if (canpostattach && (config.Enablealbum == 1) && apb != null && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } else caninsertalbum = false; attachmentlist = Attachments.GetAttachmentListByPid(postinfo.Pid); attachmentcount = attachmentlist.Rows.Count; //当前用户是否有允许下载附件权限 allowviewattach = UserAuthority.DownloadAttachment(forum, userid, usergroupinfo); #endregion smileyoff = (!DNTRequest.IsPost()) ? postinfo.Smileyoff : 1 - forum.Allowsmilies; allowimg = forum.Allowimgcode; parseurloff = postinfo.Parseurloff; bbcodeoff = (usergroupinfo.Allowcusbbcode == 1) ? postinfo.Bbcodeoff : 1; usesig = postinfo.Usesig; userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); if (bonusCreditsTrans > 0 && bonusCreditsTrans < 9) { bonusextcreditsinfo = Scoresets.GetScoreSet(bonusCreditsTrans); mybonustranscredits = Users.GetUserExtCredits(userid, bonusCreditsTrans); } //是否有访问当前版块的权限 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); return; } // 判断当前用户是否有修改权限, 检查是否具有版主的身份 if (!Moderators.IsModer(useradminid, userid, forumid)) { if (postinfo.Posterid != userid) { AddErrLine("你并非作者, 且你当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有修改该帖的权限"); return; } else if (config.Edittimelimit > 0 && Utils.StrDateDiffMinutes(postinfo.Postdatetime, config.Edittimelimit) > 0) { AddErrLine("抱歉, 系统规定只能在帖子发表" + config.Edittimelimit + "分钟内才可以修改"); return; } else if(config.Edittimelimit==-1) { AddErrLine("抱歉,系统不允许修改帖子"); return; } } #region htmltitle标题 if (postinfo.Layer == 0) canhtmltitle = usergroupinfo.Allowhtmltitle == 1; if (Topics.GetMagicValue(topic.Magic, MagicType.HtmlTitle) == 1) htmltitle = Topics.GetHtmlTitle(topic.Tid).Replace("\"", "\\\"").Replace("'", "\\'"); #endregion #region tag信息 enabletag = (config.Enabletag & forum.Allowtag) == 1; if (enabletag && Topics.GetMagicValue(topic.Magic, MagicType.TopicTag) == 1) { foreach (TagInfo tag in ForumTags.GetTagsListByTopic(topic.Tid)) { if (tag.Orderid > -1) topictags += string.Format(" {0}", tag.Tagname); } topictags = topictags.Trim(); } #endregion userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return (x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid); }); //如果是提交... if (ispost) { SetBackLink("editpost.aspx?topicid=" + postinfo.Tid + "&postid=" + postinfo.Pid); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } //设置相关帖子信息 SetPostInfo(admininfo, userinfo, Utils.StrToInt(DNTRequest.GetString("htmlon"), 0) == 1); if (IsErr()) return; //通过验证的用户可以编辑帖子 Posts.UpdatePost(postinfo); //设置附件相关信息 System.Text.StringBuilder sb = SetAttachmentInfo(); if (IsErr()) return; UserCredits.UpdateUserCredits(userid); #region 设置提示信息和跳转链接 //辩论地址 if (topic.Special == 4) SetUrl(Urls.ShowDebateAspxRewrite(topic.Tid)); else if (DNTRequest.GetQueryString("referer") != "")//ajax快速回复将传递referer参数 SetUrl(string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", topic.Tid, postinfo.Pid, forumpageid)); else if (pageid > 1)//如果不是ajax,则应该是带pageid的参数 { if (config.Aspxrewrite == 1) SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, pageid, postinfo.Pid)); else SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, pageid, forumpageid)); } else//如果都为空.就跳转到第一页(以免意外情况) { if (config.Aspxrewrite == 1) SetUrl(string.Format("showtopic-{0}{1}", topic.Tid, config.Extname)); else SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={1}", topic.Tid, forumpageid)); } if (sb.Length > 0) { SetMetaRefresh(5); SetShowBackLink(true); if (infloat == 1) { AddErrLine(sb.ToString()); return; } else { sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>编辑帖子成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); sb.Append("</table>"); AddMsgLine(sb.ToString()); } } else { //编辑主题和回复需要审核 if (postinfo.Layer == 0) SetMetaRefresh(2, base.ShowForumAspxRewrite(forumid, forumpageid)); else SetMetaRefresh(); SetShowBackLink(false); if (useradminid != 1 && (needaudit || topic.Displayorder == -2 || postinfo.Invisible == 1)) { if (postinfo.Layer == 0) SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid)); else SetUrl(base.ShowTopicAspxRewrite(topic.Tid, forumpageid)); AddMsgLine("编辑成功, 但需要经过审核才可以显示"); } else { MsgForward("editpost_succeed"); AddMsgLine("编辑帖子成功, 返回该主题"); } } #endregion // 删除主题游客缓存 if (postinfo.Layer == 0) ForumUtils.DeleteTopicCacheFile(topic.Tid); } else AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); }
/// <summary> /// 是否有编辑帖子的权限 /// </summary> /// <param name="postInfo"></param> /// <param name="userId"></param> /// <param name="userAdminId"></param> /// <param name="msg"></param> /// <returns></returns> public static bool CanEditPost(PostInfo postInfo, int userId, int userAdminId, ref string msg) { //非创始人且作者与当前编辑者不同时 if (postInfo.Posterid != userId && BaseConfigs.GetFounderUid != userId) { if (postInfo.Posterid == BaseConfigs.GetFounderUid) { msg = "您无权编辑创始人的帖子"; return false; } if (postInfo.Posterid != -1) { UserGroupInfo postergroup = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(postInfo.Posterid).Groupid); if (postergroup.Radminid > 0 && postergroup.Radminid < userAdminId) { msg = "您无权编辑更高权限人的帖子"; return false; } } } return true; }
protected override void ShowPage() { if (postid == -1) { AddErrLine("无效的帖子ID"); return; } // 获取该帖子的信息 post = Posts.GetPostInfo(topicid, postid); if (post == null) { AddErrLine("不存在的帖子ID"); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(topicid); if (topic == null) { AddErrLine("不存在的主题ID"); return; } if (topicid != post.Tid) { AddErrLine("主题ID无效"); return; } topictitle = topic.Title; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); forumname = forum.Name; pagetitle = string.Format("删除{0}", post.Title); forumnav = ShowForumAspxRewrite(forum.Pathlist.Trim(), forumid, forumpageid); if (!CheckPermission(post,DNTRequest.GetInt("opinion", -1))) return; if (!allowDelPost) { AddErrLine("当前不允许删帖"); return; } // 通过验证的用户可以删除帖子,如果是主题帖则另处理 if (post.Layer == 0) { TopicAdmins.DeleteTopics(topicid.ToString(), byte.Parse(forum.Recyclebin.ToString()), false); //重新统计论坛帖数 Forums.SetRealCurrentTopics(forum.Fid); ForumTags.DeleteTopicTags(topicid); } else { int reval; if (topic.Special == 4) { if (DNTRequest.GetInt("opinion", -1) != 1 && DNTRequest.GetInt("opinion", -1) != 2) { AddErrLine("参数错误"); return; } reval = Posts.DeletePost(Posts.GetPostTableId(topicid), postid, false, true); Debates.DeleteDebatePost(topicid, DNTRequest.GetInt("opinion", -1), postid); } else reval = Posts.DeletePost(Posts.GetPostTableId(topicid), postid, false, true); Posts.RemoveShowTopicCache(topicid.ToString()); // 删除主题游客缓存 ForumUtils.DeleteTopicCacheFile(topicid); //再次确保回复数精确 Topics.UpdateTopicReplyCount(topic.Tid); //更新指定版块的最新发帖数信息 Forums.UpdateLastPost(forum); if (reval > 0 && Utils.StrDateDiffHours(post.Postdatetime, config.Losslessdel * 24) < 0) UserCredits.UpdateUserCreditsByPosts(post.Posterid, -1); } SetUrl(post.Layer == 0 ? base.ShowForumAspxRewrite(post.Fid, 0) : Urls.ShowTopicAspxRewrite(post.Tid, 1)); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("删除帖子成功, 返回主题"); }
private bool CheckPermission(PostInfo post, int opinion) { isModer = Moderators.IsModer(useradminid, userid, forumid); if (userid == post.Posterid && !isModer) { if (post.Layer < 1 && topic.Replies > 0) { AddErrLine("已经被回复过的主帖不能被删除"); return false; } if (Utils.StrDateDiffMinutes(post.Postdatetime, config.Edittimelimit) > 0 || post.Posterid != userid) //不是作者或者超过编辑时限 { AddErrLine("已经超过了编辑帖子时限,不能删除帖子"); return false; } allowDelPost = true; } else { AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); // 如果所属管理组有删帖的管理权限,并且是管理员或总版主 if (admininfo != null && admininfo.Allowdelpost == 1 && Moderators.IsModer(useradminid, userid, forumid)) { allowDelPost = true; if (post.Layer == 0)//管理者跳转至删除主题 HttpContext.Current.Response.Redirect(string.Format("{0}topicadmin.aspx?action=moderate&operat=delete&forumid={1}&topicid={2}", forumpath, post.Fid, post.Tid)); else //跳转至批量删帖 HttpContext.Current.Response.Redirect(string.Format("{0}topicadmin.aspx?action=moderate&operat=delposts&forumid={1}&topicid={2}&postid={3}&opinion={4}", forumpath, post.Fid, post.Tid, post.Pid, opinion)); return false; } else allowDelPost = false; } return true; }
public void UpdateLastPost(ForumInfo foruminfo, PostInfo postinfo) { DbParameter[] parms ={ DbHelper.MakeInParam("@lasttid", (DbType)SqlDbType.Int, 4, postinfo.Tid), DbHelper.MakeInParam("@lasttitle", (DbType)SqlDbType.NChar, 60, postinfo.Topictitle), DbHelper.MakeInParam("@lastpost", (DbType)SqlDbType.DateTime, 8, postinfo.Postdatetime), DbHelper.MakeInParam("@lastposterid", (DbType)SqlDbType.Int, 4, postinfo.Posterid), DbHelper.MakeInParam("@lastposter", (DbType)SqlDbType.NChar, 20, postinfo.Poster), DbHelper.MakeInParam("@fid", (DbType)SqlDbType.Int, 4, foruminfo.Fid) }; string sql = string.Format("UPDATE [{0}forums] SET [lasttid] = @lasttid, [lasttitle] = @lasttitle, [lastpost] = @lastpost, [lastposterid] = @lastposterid, [lastposter] = @lastposter WHERE [fid] = @fid OR [fid] IN ({1})", BaseConfigs.GetTablePrefix, foruminfo.Parentidlist); DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms); }
/// <summary> /// 获取主题帖是否可见信息 /// </summary> /// <param name="forum">版块信息</param> /// <param name="useradminid">当前用户adminid</param> /// <param name="uid">当前用户id</param> /// <param name="userGroup">当前用户组信息</param> /// <param name="postinfo">帖子信息</param> /// <returns>0显示;1隐藏</returns> public static int GetTopicPostInvisible(ForumInfo forum, int useradminid, int uid, UserGroupInfo userGroup, PostInfo postinfo) { if (useradminid == 1 || Moderators.IsModer(useradminid, uid, forum.Fid)) return 0; if (!ForumUtils.HasAuditWord(postinfo.Message) && forum.Modnewtopics == 0 && userGroup.ModNewTopics == 0 && !Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postmodperiods)) return 0; return 1; }
/// <summary> /// 更新指定版块的最新发帖数信息 /// </summary> /// <param name="foruminfo"></param> public static void UpdateLastPost(ForumInfo foruminfo) { PostInfo postinfo = new PostInfo(); int tid = DatabaseProvider.GetInstance().GetLastPostTid(foruminfo, Forums.GetVisibleForum()); if (tid > 0) { DataTable dt = Posts.GetLastPostByTid(tid); if (dt.Rows.Count > 0) { postinfo.Pid = Convert.ToInt32(dt.Rows[0]["pid"].ToString()); postinfo.Tid = Convert.ToInt32(dt.Rows[0]["tid"].ToString()); postinfo.Title = dt.Rows[0]["title"].ToString().Trim(); postinfo.Postdatetime = dt.Rows[0]["postdatetime"].ToString().Trim(); postinfo.Poster = dt.Rows[0]["poster"].ToString().Trim(); postinfo.Posterid = Convert.ToInt32(dt.Rows[0]["posterid"].ToString()); postinfo.Topictitle = Topics.GetTopicInfo(postinfo.Tid).Title; } else { postinfo.Pid = 0; postinfo.Tid = 0; postinfo.Title = "从未"; postinfo.Topictitle = "从未"; postinfo.Postdatetime = "1900-1-1"; postinfo.Poster = ""; postinfo.Posterid = 0; } dt.Dispose(); } else { postinfo.Pid = 0; postinfo.Tid = 0; postinfo.Title = "从未"; postinfo.Topictitle = "从未"; postinfo.Postdatetime = "1900-1-1"; postinfo.Poster = ""; postinfo.Posterid = 0; } DatabaseProvider.GetInstance().UpdateLastPost(foruminfo, postinfo); if (foruminfo.Layer > 0) //递归调用并更新相应父版块信息 { foruminfo = Forums.GetForumInfo(foruminfo.Parentid); UpdateLastPost(foruminfo); } }
/// <summary> /// 创建帖子 /// </summary> /// <param name="postInfo">帖子信息类</param> /// <returns>返回帖子id</returns> public static int CreatePost(PostInfo postInfo) { int pid = Data.Posts.CreatePost(postInfo, GetPostTableId(postInfo.Tid)); //本帖具有正反方立场 if (postInfo.Debateopinion > 0) { DebatePostExpandInfo dpei = new DebatePostExpandInfo(); dpei.Tid = postInfo.Tid; dpei.Pid = pid; dpei.Opinion = postInfo.Debateopinion; dpei.Diggs = 0; Data.Debates.CreateDebateExpandInfo(dpei); } RemoveShowTopicCache(postInfo.Tid.ToString()); return pid; }
/// <summary> /// 创建帖子 /// </summary> /// <param name="postInfo">帖子信息类</param> /// <returns>返回帖子id</returns> public static int CreatePost(PostInfo postInfo) { int pid = 0; lock (lockHelper) { pid = Data.Posts.CreatePost(postInfo, GetPostTableId(postInfo.Tid)); } //本帖具有正反方立场 if (postInfo.Debateopinion > 0) { DebatePostExpandInfo dpei = new DebatePostExpandInfo(); dpei.Tid = postInfo.Tid; dpei.Pid = pid; dpei.Opinion = postInfo.Debateopinion; dpei.Diggs = 0; Data.Debates.CreateDebateExpandInfo(dpei); } //将数据同步到sphinx增量表中 if (pid > 0 && EntLibConfigs.GetConfig() != null && EntLibConfigs.GetConfig().Sphinxconfig.Enable) { GetSphinxSqlService().CreatePost(GetPostTableName(), pid, postInfo.Tid, postInfo.Fid, postInfo.Posterid, postInfo.Postdatetime, postInfo.Title, postInfo.Message); } return pid; }
/// <summary> /// 获得推荐的论坛主题帖对象数组 /// </summary> /// <param name="nodename">节点名称</param> /// <returns></returns> public PostInfo[] GetPostListFromFile(string nodeName) { if (postInfos != null) return postInfos; XmlNodeList xmlnodelist = xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/Forum/Topiclist/Topic"); postInfos = new PostInfo[xmlnodelist.Count]; int rowcount = 0; foreach (XmlNode xmlnode in xmlnodelist) { postInfos[rowcount] = new PostInfo(); postInfos[rowcount].Tid = TypeConverter.ObjectToInt(xmlDoc.GetSingleNodeValue(xmlnode, "topicid")); postInfos[rowcount].Title = (xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "title"); postInfos[rowcount].Poster = (xmlDoc.GetSingleNodeValue(xmlnode, "poster") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "poster"); postInfos[rowcount].Posterid = TypeConverter.ObjectToInt(xmlDoc.GetSingleNodeValue(xmlnode, "posterid")); postInfos[rowcount].Postdatetime = (xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime"); postInfos[rowcount].Message = (xmlDoc.GetSingleNodeValue(xmlnode, "shortdescription") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "shortdescription"); postInfos[rowcount].Fid = TypeConverter.ObjectToInt(xmlDoc.GetSingleNodeValue(xmlnode, "fid")); postInfos[rowcount].Forumname = (xmlDoc.GetSingleNodeValue(xmlnode, "forumname") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "forumname"); postInfos[rowcount].ForumRewriteName = (xmlDoc.GetSingleNodeValue(xmlnode, "forumrewritename") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "forumrewritename"); rowcount++; } return postInfos; }
/// <summary> /// 得到空间格式的帖子内容 /// </summary> /// <param name="postinfo">帖子描述</param> /// <param name="attArray">附件集合</param> /// <returns>空间格式</returns> public static string GetPostMessageHTML(PostInfo postInfo, AttachmentInfo[] attachmentArray) { string message = ""; PostpramsInfo postpramsInfo = new PostpramsInfo(); //处理帖子内容 postpramsInfo.Smileyoff = postInfo.Smileyoff; postpramsInfo.Bbcodeoff = postInfo.Bbcodeoff; postpramsInfo.Parseurloff = postInfo.Parseurloff; postpramsInfo.Allowhtml = postInfo.Htmlon; postpramsInfo.Sdetail = postInfo.Message; postpramsInfo.Showimages = 1 - postInfo.Smileyoff; postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); postpramsInfo.Pid = postInfo.Pid; //强制隐藏hide内容 postpramsInfo.Hide = 1; //设定这是为个人空间进行的解析 postpramsInfo.Isforspace = 1; //先简单判断是否是动网兼容模式 if (!postpramsInfo.Ubbmode) message = UBB.UBBToHTML(postpramsInfo); else message = Utils.HtmlEncode(postInfo.Message); if (postpramsInfo.Jammer == 1) message = ForumUtils.AddJammer(postInfo.Message); if (postInfo.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message)) { //获取在[hide]标签中的附件id string[] attHidArray = GetHiddenAttachIdList(postpramsInfo.Sdetail, postpramsInfo.Hide); ShowtopicPagePostInfo info = new ShowtopicPagePostInfo(); info.Posterid = postInfo.Posterid; info.Pid = postInfo.Pid; for (int i = 0; i < attachmentArray.Length; i++) { ShowtopicPageAttachmentInfo sAtt = new ShowtopicPageAttachmentInfo(); sAtt.Aid = attachmentArray[i].Aid; sAtt.Attachment = attachmentArray[i].Attachment; sAtt.Description = attachmentArray[i].Description; sAtt.Downloads = attachmentArray[i].Downloads; sAtt.Filename = attachmentArray[i].Filename; sAtt.Filesize = attachmentArray[i].Filesize; sAtt.Filetype = attachmentArray[i].Filetype; sAtt.Pid = attachmentArray[i].Pid; sAtt.Postdatetime = attachmentArray[i].Postdatetime; sAtt.Readperm = attachmentArray[i].Readperm; sAtt.Sys_index = attachmentArray[i].Sys_index; sAtt.Sys_noupload = attachmentArray[i].Sys_noupload; sAtt.Tid = attachmentArray[i].Tid; sAtt.Uid = attachmentArray[i].Uid; message = Attachments.GetMessageWithAttachInfo(postpramsInfo, 1, attHidArray, info, sAtt, message); } } return message; }
private static XmlNode GetTopicInDataTable(PostInfo[] posts, DataTable dt, Discuz.Common.Xml.XmlDocumentExtender doc, string tid) { foreach (DataRow dr in dt.Rows) { if (dr["tid"].ToString() != tid) continue; PostInfo newpost = null; foreach (PostInfo post in posts) { if (post.Tid.ToString() == dr["tid"].ToString()) newpost = post; } //创建Topic节点 XmlElement topic = doc.CreateElement("Topic"); doc.AppendChildElementByDataRow(ref topic, dt.Columns, dr, "tid,message"); doc.AppendChildElementByNameValue(ref topic, "topicid", dr["tid"].ToString()); string tempubbstr = UBB.ClearUBB(dr["message"].ToString()); if (tempubbstr.Length > 200) tempubbstr = tempubbstr.Substring(0, 200) + "..."; if (newpost != null) tempubbstr = newpost.Message; doc.AppendChildElementByNameValue(ref topic, "shortdescription", tempubbstr, true); doc.AppendChildElementByNameValue(ref topic, "fulldescription", UBB.ClearUBB(dr["message"].ToString()), true); ForumInfo forumInfo = Forums.GetForumInfo(TypeConverter.ObjectToInt(dr["fid"])); if (forumInfo != null) { doc.AppendChildElementByNameValue(ref topic, "forumname", forumInfo.Name); doc.AppendChildElementByNameValue(ref topic, "forumnamerewritename", forumInfo.Rewritename); } else { doc.AppendChildElementByNameValue(ref topic, "forumname", ""); doc.AppendChildElementByNameValue(ref topic, "forumnamerewritename", ""); } return topic; } return null; }
public void UnBan(Discuz.Entity.PostInfo post) { OnPostUnBanned(post); }
/// <summary> /// 更新指定帖子信息 /// </summary> /// <param name="postsInfo">帖子信息</param> /// <returns>更新数量</returns> public static int UpdatePost(PostInfo postInfo) { if (postInfo == null || postInfo.Pid < 1) return 0; //将数据同步到sphinx增量表中 if (postInfo.Pid > 0 && EntLibConfigs.GetConfig() != null && EntLibConfigs.GetConfig().Sphinxconfig.Enable) { GetSphinxSqlService().UpdatePost(GetPostTableName(), postInfo.Pid, postInfo.Tid, postInfo.Fid, postInfo.Posterid, postInfo.Postdatetime, postInfo.Title, postInfo.Message); } return Data.Posts.UpdatePost(postInfo, GetPostTableId(postInfo.Tid)); }
/// <summary> /// 通过主题ID得到主帖内容,此方法可继续扩展 /// </summary> /// <param name="tid"></param> /// <returns>ShowtopicPagePostInfo</returns> public static PostInfo GetTopicPostInfo(int tid) { PostInfo postInfo = new PostInfo(); IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(tid, PostTables.GetPostTableId(tid)); if (reader.Read()) { postInfo = LoadSinglePostInfo(reader); } reader.Close(); return postInfo; }
/// <summary> /// 创建帖子 /// </summary> /// <param name="postinfo">帖子信息类</param> /// <returns>返回帖子id</returns> public int CreatePost(PostInfo postInfo, string postTableId) { DbParameter[] parms = { DbHelper.MakeInParam("@fid",(DbType)SqlDbType.SmallInt,2,postInfo.Fid), DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,postInfo.Tid), DbHelper.MakeInParam("@parentid",(DbType)SqlDbType.Int,4,postInfo.Parentid), DbHelper.MakeInParam("@layer",(DbType)SqlDbType.Int,4,postInfo.Layer), DbHelper.MakeInParam("@poster",(DbType)SqlDbType.VarChar,15,postInfo.Poster), DbHelper.MakeInParam("@posterid",(DbType)SqlDbType.Int,4,postInfo.Posterid), DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,60,postInfo.Title), DbHelper.MakeInParam("@topictitle",(DbType)SqlDbType.NVarChar,60,postInfo.Topictitle), DbHelper.MakeInParam("@postdatetime",(DbType)SqlDbType.DateTime,8, DateTime.Parse(postInfo.Postdatetime)), DbHelper.MakeInParam("@message",(DbType)SqlDbType.NText,0,postInfo.Message), DbHelper.MakeInParam("@ip",(DbType)SqlDbType.VarChar,15,postInfo.Ip), DbHelper.MakeInParam("@lastedit",(DbType)SqlDbType.NVarChar,50,postInfo.Lastedit), DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.Int,4,postInfo.Invisible), DbHelper.MakeInParam("@usesig",(DbType)SqlDbType.Int,4,postInfo.Usesig), DbHelper.MakeInParam("@htmlon",(DbType)SqlDbType.Int,4,postInfo.Htmlon), DbHelper.MakeInParam("@smileyoff",(DbType)SqlDbType.Int,4,postInfo.Smileyoff), DbHelper.MakeInParam("@bbcodeoff",(DbType)SqlDbType.Int,4,postInfo.Bbcodeoff), DbHelper.MakeInParam("@parseurloff",(DbType)SqlDbType.Int,4,postInfo.Parseurloff), DbHelper.MakeInParam("@attachment",(DbType)SqlDbType.Int,4,postInfo.Attachment), DbHelper.MakeInParam("@rate",(DbType)SqlDbType.SmallInt,2,postInfo.Rate), DbHelper.MakeInParam("@ratetimes",(DbType)SqlDbType.Int,4,postInfo.Ratetimes) }; int pid = TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure, string.Format("{0}createpost{1}", BaseConfigs.GetTablePrefix, postTableId), parms), -1); if (pid != -1) UpdateTrendStat(TrendType.Post); return pid; }
/// <summary> /// 装帖子信息 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static PostInfo LoadSinglePostInfo(IDataReader reader) { PostInfo postInfo = new PostInfo(); postInfo.Pid = TypeConverter.ObjectToInt(reader["pid"]); postInfo.Fid = TypeConverter.ObjectToInt(reader["fid"]); postInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]); postInfo.Parentid = TypeConverter.ObjectToInt(reader["parentid"]); postInfo.Layer = TypeConverter.ObjectToInt(reader["layer"]); postInfo.Poster = reader["poster"].ToString(); postInfo.Posterid = TypeConverter.ObjectToInt(reader["posterid"]); postInfo.Title = reader["title"].ToString(); postInfo.Postdatetime = reader["postdatetime"].ToString(); postInfo.Message = reader["message"].ToString(); postInfo.Ip = reader["ip"].ToString(); postInfo.Lastedit = reader["lastedit"].ToString(); postInfo.Invisible = TypeConverter.ObjectToInt(reader["invisible"]); postInfo.Usesig = TypeConverter.ObjectToInt(reader["usesig"]); postInfo.Htmlon = TypeConverter.ObjectToInt(reader["htmlon"]); postInfo.Smileyoff = TypeConverter.ObjectToInt(reader["smileyoff"]); postInfo.Bbcodeoff = TypeConverter.ObjectToInt(reader["bbcodeoff"]); postInfo.Parseurloff = TypeConverter.ObjectToInt(reader["parseurloff"]); postInfo.Attachment = TypeConverter.ObjectToInt(reader["attachment"]); postInfo.Rate = TypeConverter.ObjectToInt(reader["rate"]); postInfo.Ratetimes = TypeConverter.ObjectToInt(reader["ratetimes"]); return postInfo; }
/// <summary> /// 创建主题帖信息 /// </summary> /// <param name="topicinfo"></param> /// <returns></returns> public PostInfo CreatePost(TopicInfo topicinfo) { PostInfo postinfo = new PostInfo(); postinfo.Fid = forumid; postinfo.Tid = topicinfo.Tid; postinfo.Poster = username; postinfo.Posterid = userid; postinfo.Title = useradminid == 1 ? Utils.HtmlEncode(DNTRequest.GetString("title")) : postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); postinfo.Postdatetime = curdatetime; postinfo.Message = message; postinfo.Ip = DNTRequest.GetIP(); postinfo.Invisible = ForumUtils.HasAuditWord(postinfo.Message) ? 0 : 1; postinfo.Invisible = UserAuthority.GetPostInvisible(forum, useradminid, disablepost); postinfo.Usesig = TypeConverter.StrToInt(DNTRequest.GetString("usesig")); postinfo.Htmlon = (usergroupinfo.Allowhtml == 1 && (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)) ? 1 : 0; postinfo.Smileyoff = (smileyoff == 0 && forum.Allowsmilies == 1) ? TypeConverter.StrToInt(DNTRequest.GetString("smileyoff")) : smileyoff; postinfo.Bbcodeoff = (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) ? postinfo.Bbcodeoff = TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1; postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff")); postinfo.Topictitle = topicinfo.Title; try { postinfo.Pid = Posts.CreatePost(postinfo); } catch { TopicAdmins.DeleteTopics(topicinfo.Tid.ToString(), false); AddErrLine("帖子保存出现异常"); } //创建投票 if (createpoll) { msg = Polls.CreatePoll(DNTRequest.GetFormString("PollItemname"), DNTRequest.GetString("multiple") == "on" ? 1 : 0, DNTRequest.GetInt("maxchoices", 1), DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0, enddatetime, topicinfo.Tid, pollitem, userid); } return postinfo; }
/// <summary> /// 更新指定帖子信息 /// </summary> /// <param name="postInfo">帖子信息</param> /// <returns>更新数量</returns> public static int UpdatePost(PostInfo postInfo, string postTableId) { int result = DatabaseProvider.GetInstance().UpdatePost(postInfo, postTableId); //更新Cache缓存中的帖子信息 if (appDBCache && IPostService != null) { IPostService.UpdatePost(postInfo, postTableId); } return result; }
/// <summary> /// 更新指定帖子信息 /// </summary> /// <param name="__postsInfo">帖子信息</param> /// <returns>更新数量</returns> public int UpdatePost(PostInfo __postsInfo, string posttableid) { IDataParameter[] prams = { DbHelper.MakeInParam("@pid",(DbType)SqlDbType.Int,4,__postsInfo.Pid), DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,160,__postsInfo.Title), DbHelper.MakeInParam("@message",(DbType)SqlDbType.NText,0,__postsInfo.Message), DbHelper.MakeInParam("@lastedit",(DbType)SqlDbType.VarChar,50,__postsInfo.Lastedit), DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.Int,4,__postsInfo.Invisible), DbHelper.MakeInParam("@usesig",(DbType)SqlDbType.Int,4,__postsInfo.Usesig), DbHelper.MakeInParam("@htmlon",(DbType)SqlDbType.Int,4,__postsInfo.Htmlon), DbHelper.MakeInParam("@smileyoff",(DbType)SqlDbType.Int,4,__postsInfo.Smileyoff), DbHelper.MakeInParam("@bbcodeoff",(DbType)SqlDbType.Int,4,__postsInfo.Bbcodeoff), DbHelper.MakeInParam("@parseurloff",(DbType)SqlDbType.Int,4,__postsInfo.Parseurloff), }; return DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, BaseConfigs.GetTablePrefix + "updatepost" + posttableid, prams); }
public void CreatePost(Discuz.Entity.PostInfo post) { OnPostCreated(post); }