/// <summary> /// 移动主题到指定版块 /// </summary> /// <param name="topiclist">要移动的主题列表</param> /// <param name="fid">转到的版块ID</param> /// <returns>更新记录数</returns> public static int MoveTopics(string topiclist, int fid, int oldfid, int topicType) { if (!Utils.IsNumericList(topiclist)) { return(-1); } //更新帖子 foreach (string tid in topiclist.Split(',')) { DatabaseProvider.GetInstance().UpdatePost(topiclist, fid, PostTables.GetPostTableName(TypeConverter.StrToInt(tid))); } //更新主题 int reval = Discuz.Data.Topics.UpdateTopic(topiclist, fid, topicType); if (reval > 0) { AdminForumStats.ReSetFourmTopicAPost(fid); AdminForumStats.ReSetFourmTopicAPost(oldfid); Forums.SetRealCurrentTopics(fid); Forums.SetRealCurrentTopics(oldfid); } //生成置顶帖 ResetTopTopicList(); return(reval); }
/// <summary> /// 更新父版块最后发帖信息 /// </summary> /// <param name="foruminfo"></param> /// <param name="postinfo"></param> private static void UpdateParentForumLastPost(ForumInfo foruminfo, PostInfo postinfo) { int parentFid = Utils.StrToInt(foruminfo.Parentidlist.Split(',')[1], 0);//去parentidlist属性split后的第一个数组元素,因为第0个是分类 if (parentFid > 0) { string fidList = ""; //获取到游客可以访问到的版块fidlist foreach (string fid in AdminForums.FindChildNode(parentFid.ToString()).Split(',')) { if (fid == "0") { continue; } foreach (DataRow dr in Forums.GetOpenForumList().Rows) { if (dr["fid"].ToString().Trim() == fid.Trim()) { fidList += fid + ","; break; } } } if (string.IsNullOrEmpty(fidList)) { return; } int forumsTid = Data.Forums.GetForumsLastPostTid(fidList.TrimEnd(',')); if (forumsTid > 0) { postinfo = Discuz.Data.Posts.GetLastPostByTid(forumsTid, PostTables.GetPostTableName(forumsTid)); } else { postinfo.Pid = postinfo.Tid = 0; postinfo.Title = postinfo.Topictitle = "从未"; postinfo.Postdatetime = "1900-1-1"; postinfo.Poster = ""; postinfo.Posterid = 0; } Discuz.Data.Forums.UpdateForumLastPost(GetForumInfo(parentFid), postinfo); } }
/// <summary> /// 更新指定版块的最新发帖数信息 /// </summary> /// <param name="foruminfo"></param> public static void UpdateLastPost(ForumInfo foruminfo) { PostInfo postinfo = new PostInfo(); int tid = Discuz.Data.Topics.GetLastPostTid(foruminfo, Forums.GetVisibleForum()); if (tid > 0) { postinfo = Discuz.Data.Posts.GetLastPostByTid(tid, PostTables.GetPostTableName(tid)); } else { postinfo.Pid = postinfo.Tid = 0; postinfo.Title = postinfo.Topictitle = "从未"; postinfo.Postdatetime = "1900-1-1"; postinfo.Poster = ""; postinfo.Posterid = 0; } Discuz.Data.Forums.UpdateForumLastPost(foruminfo, postinfo); if (foruminfo.Layer > 1) { UpdateParentForumLastPost(foruminfo, postinfo); } }