private void SetPostInfo_Click(object sender, EventArgs e) { #region 除选中的帖子 if (this.CheckCookie()) { if (DNTRequest.GetString("pid") != "") { string pidlist = DNTRequest.GetString("pid"); string posttableid = ViewState["posttablename"].ToString().Trim().Replace(BaseConfigs.GetTablePrefix + "posts", ""); posttableid = (posttableid == "" ? "1" : posttableid); foreach (string idlist in DNTRequest.GetString("pid").Split(',')) { int pid = int.Parse(idlist.Split('|')[0]); int tid = int.Parse(idlist.Split('|')[1]); #region 更新用户金币金币 PostInfo post = Posts.GetPostInfo(tid, pid); ForumInfo forum = Forums.GetForumInfo(post.Fid); int Losslessdel = Utils.StrDateDiffHours(post.Postdatetime, config.Losslessdel * 24); // 通过验证的用户可以删除帖子,如果是主题贴则另处理 if (post.Layer == 0) { TopicAdmins.DeleteTopics(tid.ToString(), byte.Parse(forum.Recyclebin.ToString()), false); //重新统计论坛帖数 Forums.SetRealCurrentTopics(forum.Fid); } else { int reval = Posts.DeletePost(posttableid, Convert.ToInt32(pid), false, true); if (reval > 0 && Losslessdel < 0) { UserCredits.UpdateUserCreditsByPosts(post.Posterid, -1); } // 删除主题游客缓存 ForumUtils.DeleteTopicCacheFile(tid.ToString()); //再次确保回复数精确 Topics.UpdateTopicReplies(tid); } #endregion } AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "批量删帖", "帖子ID:" + pidlist); base.RegisterStartupScript("PAGE", "window.location.href='forum_searchpost.aspx';"); } else { base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='forum_searchpost.aspx';</script>"); } } #endregion }
/// <summary> /// 更新用户金币 /// </summary> /// <param name="postTableId">分表id</param> /// <param name="pidlist">通过审核帖子的Pid列表</param> private void UpdateUserCredits(string tidlist, string pidlist) { string[] tidarray = tidlist.Split(','); string[] pidarray = pidlist.Split(','); float[] values = null; ForumInfo forum = null; PostInfo post = null; int fid = -1; for (int i = 0; i < pidarray.Length; i++) { //Topics.get post = Posts.GetPostInfo(int.Parse(tidarray[i]), int.Parse(pidarray[i])); //获取帖子信息 if (fid != post.Fid) //当上一个和当前主题不在一个版块内时,重新读取版块的金币设置 { fid = post.Fid; forum = Forums.GetForumInfo(fid); if (!forum.Replycredits.Equals("")) { int index = 0; float tempval = 0; values = new float[8]; foreach (string ext in Utils.SplitString(forum.Replycredits, ",")) { if (index == 0) { if (!ext.Equals("True")) { values = null; break; } index++; continue; } tempval = Utils.StrToFloat(ext, 0.0f); values[index - 1] = tempval; index++; if (index > 8) { break; } } } } if (values != null) { ///使用版块内金币 UserCredits.UpdateUserCreditsByPosts(post.Posterid, values); } else { ///使用默认金币 UserCredits.UpdateUserCreditsByPosts(post.Posterid); } } }
/// <summary> /// 更新用户积分 /// </summary> /// <param name="values">版块积分设置</param> private void UpdateUserCredits(float[] values) { if (values != null) { UserCredits.UpdateUserExtCredits(userid, values, false);//使用版块内积分 if (userid != -1) { UserCredits.WriteUpdateUserExtCreditsCookies(values); } } else { UserCredits.UpdateUserCreditsByPosts(userid);//使用默认积分 if (userid != -1) { UserCredits.WriteUpdateUserExtCreditsCookies(Scoresets.GetUserExtCredits(CreditsOperationType.PostReply)); } } }
protected override void ShowPage() { // 获取帖子ID topicid = DNTRequest.GetInt("topicid", -1); postid = DNTRequest.GetInt("postid", -1); // 如果主题ID非数字 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 = "删除" + post.Title; forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); int opinion = DNTRequest.GetInt("opinion", -1); if (!CheckPermission(post, opinion)) { return; } if (!allowdelpost) { AddErrLine("当前不允许删帖"); return; } int Losslessdel = Utils.StrDateDiffHours(post.Postdatetime, config.Losslessdel * 24); // 通过验证的用户可以删除帖子,如果是主题贴则另处理 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) { string opiniontext = ""; if (opinion != 1 && opinion != 2) { AddErrLine("参数错误"); return; } reval = Posts.DeletePost(Posts.GetPostTableID(topicid), postid, false, true); switch (opinion) { case 1: opiniontext = "positivediggs"; break; case 2: opiniontext = "negativediggs"; break; } Discuz.Data.DatabaseProvider.GetInstance().DeleteDebatePost(topicid, opiniontext, postid); } else { reval = Posts.DeletePost(Posts.GetPostTableID(topicid), postid, false, true); } // 删除主题游客缓存 ForumUtils.DeleteTopicCacheFile(topicid); //再次确保回复数精确 Topics.UpdateTopicReplies(topic.Tid); //更新指定版块的最新发帖数信息 Forums.UpdateLastPost(forum); if (reval > 0 && Losslessdel < 0) { UserCredits.UpdateUserCreditsByPosts(post.Posterid, -1); } } SetUrl(Urls.ShowTopicAspxRewrite(post.Tid, 1)); if (post.Layer == 0) { SetUrl(base.ShowForumAspxRewrite(post.Fid, 0)); } SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("删除帖子成功, 返回主题"); }