/// <summary> /// /// </summary> /// <param name="tid"></param> /// <param name="pagesize"></param> /// <param name="pageindex"></param> /// <returns></returns> public static DataSet AdminGetPostList(int tid, int pagesize, int pageindex) { DataSet ds = Discuz.Data.Posts.GetPosts(tid, pagesize, pageindex, Discuz.Data.PostTables.GetPostTableId(tid)); if (ds == null) { ds = new DataSet(); ds.Tables.Add("post"); ds.Tables.Add(); return(ds); } ds.Tables[0].TableName = "post"; foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["attachment"].ToString().Equals("1")) { dr["attachment"] = Attachments.GetAttachmentCountByPid(Utils.StrToInt(dr["pid"], 0)); } } return(ds); }
/// <summary> /// 修复主题列表 /// </summary> /// <param name="topicList">主题id列表</param> /// <returns>更新记录数</returns> public static int RepairTopicList(string topicList) { if (!Utils.IsNumericList(topicList)) { return(0); } int revalcount = 0; string[] idlist = Posts.GetPostTableIdArray(topicList); string[] tidlist = topicList.Split(','); for (int i = 0; i < idlist.Length; i++) { int reval = Discuz.Data.TopicAdmins.RepairTopics(tidlist[i], BaseConfigs.GetTablePrefix + "posts" + (TypeConverter.StrToInt(idlist[i]))); if (reval > 0) { revalcount = reval + revalcount; Attachments.UpdateTopicAttachment(topicList); } } return(revalcount); }
/// <summary> /// 批量删除主题附件 /// </summary> /// <param name="tidList">主题Id列表</param> /// <param name="adminUid">管理员Uid</param> /// <param name="adminUserName">管理员用户名</param> /// <param name="adminUserGroupId">管理员用户组Id</param> /// <param name="adminUserGroupTitle">管理员用户组名称</param> /// <param name="adminIp">管理员Ip</param> public static void BatchDeleteTopicAttachs(string tidList, int adminUid, string adminUserName, int adminUserGroupId, string adminUserGroupTitle, string adminIp) { Attachments.DeleteAttachmentByTid(tidList); AdminVistLogs.InsertLog(adminUid, adminUserName, adminUserGroupId, adminUserGroupTitle, adminIp, "删除主题中的附件", "主题ID:" + tidList); }
/// <summary> /// 批量删除主题 /// </summary> /// <param name="tidList">主题Id列表</param> /// <param name="isChagePostNumAndCredits">是否要更新用户的主题数与积分</param> /// <param name="adminUid">管理员Uid</param> /// <param name="adminUserName">管理员用户名</param> /// <param name="adminUserGroupId">管理员用户组Id</param> /// <param name="adminUserGroupTitle">管理员用户组名称</param> /// <param name="adminIp">管理员Ip</param> public static void BatchDeleteTopics(string tidList, bool isChagePostNumAndCredits, int adminUid, string adminUserName, int adminUserGroupId, string adminUserGroupTitle, string adminIp) { DeleteTopics(tidList, isChagePostNumAndCredits ? 1 : 0, false); Attachments.UpdateTopicAttachment(tidList); AdminVistLogs.InsertLog(adminUid, adminUserName, adminUserGroupId, adminUserGroupTitle, adminIp, "批量删除主题", "主题ID:" + tidList); }
/// <summary> /// 在数据库中删除指定主题 /// </summary> /// <param name="topiclist">主题列表</param> /// <param name="subtractCredits">是否减少用户积分(0不减少,1减少)</param> /// <returns>删除个数</returns> public static int DeleteTopics(string topicList, int subTractCredits, bool reserveAttach) { if (!Utils.IsNumericList(topicList)) { return(-1); } GeneralConfigInfo configinfo = GeneralConfigs.GetConfig(); DataTable dt = Topics.GetTopicList(topicList); if (dt == null) { return(-1); } foreach (DataRow dr in dt.Rows) { if (TypeConverter.ObjectToInt(dr["digest"]) > 0) { UserCredits.UpdateUserExtCredits(TypeConverter.ObjectToInt(dr["posterid"]), -1, CreditsOperationType.Digest, 1, true); UserCredits.UpdateUserCredits(TypeConverter.ObjectToInt(dr["posterid"])); } } dt = Posts.GetPostList(topicList); if (dt != null) { Hashtable attUidCount = new Hashtable(); foreach (DataRow dr in dt.Rows) { //后台设置的项为多少天外的老帖删除不减积分,而不是多少天内删帖可以不减分 if (configinfo.Losslessdel == 0 || Utils.StrDateDiffHours(dr["postdatetime"].ToString(), configinfo.Losslessdel * 24) < 0) { CreditsOperationType creditsOperationType = TypeConverter.ObjectToInt(dr["layer"]) == 0 ? CreditsOperationType.PostTopic : CreditsOperationType.PostReply; //获取版块积分规则 float[] creditsValue = Forums.GetValues( creditsOperationType == CreditsOperationType.PostTopic ? Forums.GetForumInfo(TypeConverter.ObjectToInt(dr["fid"])).Postcredits : Forums.GetForumInfo(TypeConverter.ObjectToInt(dr["fid"])).Replycredits ); //如果未定义版块积分规则 if (creditsValue == null) { creditsValue = Scoresets.GetUserExtCredits(creditsOperationType); } UserCredits.UpdateUserExtCredits(TypeConverter.ObjectToInt(dr["posterid"]), creditsValue, 1, creditsOperationType, -1, true); int attCount = Attachments.GetAttachmentCountByPid(TypeConverter.ObjectToInt(dr["pid"])); if (attCount > 0) { int posterid = TypeConverter.ObjectToInt(dr["posterid"]); if (attUidCount.ContainsKey(posterid)) { attUidCount[posterid] = (int)attUidCount[posterid] + attCount; } else { attUidCount.Add(TypeConverter.ObjectToInt(dr["posterid"]), attCount); } } } UserCredits.UpdateUserCredits(TypeConverter.ObjectToInt(dr["posterid"])); } int i = 0; int[] tuidlist = new int[attUidCount.Count]; int[] attcountlist = new int[attUidCount.Count]; foreach (DictionaryEntry de in attUidCount) { tuidlist[i] = (int)de.Key; attcountlist[i] = (int)de.Value; i++; } UserCredits.UpdateUserCredits(tuidlist, attcountlist, CreditsOperationType.UploadAttachment, -1); } int reval = 0; foreach (string posttableid in Posts.GetPostTableIdArray(topicList)) { reval = Discuz.Data.TopicAdmins.DeleteTopicByTidList(topicList, posttableid); } if (reval > 0 && !reserveAttach) { Attachments.DeleteAttachmentByTid(topicList); } return(reval); }