/// <summary> /// 设置待验证的主题,包括通过,忽略,删除等操作 /// </summary> /// <param name="postTableId">回复表ID</param> /// <param name="ignore">忽略的主题列表</param> /// <param name="validate">验证通过的主题列表</param> /// <param name="delete">删除的主题列表</param> /// <param name="fidlist">版块列表</param> public static void PassAuditNewTopic(string postTableId, string ignore, string validate, string delete, string fidlist) { if (!Utils.IsNumeric(postTableId) || (!string.IsNullOrEmpty(ignore) && !Utils.IsNumericList(ignore)) || (!string.IsNullOrEmpty(validate) && !Utils.IsNumericList(validate)) || (!string.IsNullOrEmpty(delete) && !Utils.IsNumericList(delete)) || (!string.IsNullOrEmpty(fidlist) && !Utils.IsNumericList(fidlist))) { return; } Data.Topics.PassAuditNewTopic(postTableId, ignore, validate, delete, fidlist); //获取验证通过的主题列表信息,为用户增加发主题的扩展积分 if (!string.IsNullOrEmpty(validate)) { foreach (DataRow topicInfo in Topics.GetTopicList(validate).Rows) { ForumInfo forumInfo = Forums.GetForumInfo(TypeConverter.ObjectToInt(topicInfo["fid"]));//获取主题的版块信息 float[] forumPostcredits = Forums.GetValues(forumInfo.Postcredits); if (forumPostcredits != null) //使用版块内积分 { UserCredits.UpdateUserCreditsByPostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"]), forumPostcredits); } else //使用默认积分 { UserCredits.UpdateUserCreditsByPostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"])); } } } }
/// <summary> /// 删除主题帖(layer=0)或是回复时更新用户积分 /// </summary> /// <param name="postInfo">帖子信息</param> /// <param name="forumInfo">版块信息</param> /// <param name="reserveAttach">是否保留附件</param> public static void DeletePost(PostInfo postInfo, ForumInfo forumInfo, bool reserveAttach) { GeneralConfigInfo configInfo = GeneralConfigs.GetConfig(); if (configInfo.Losslessdel == 0 || Utils.StrDateDiffHours(postInfo.Postdatetime, configInfo.Losslessdel * 24) < 0) { CreditsOperationType creditsOperationType = postInfo.Layer == 0 ? CreditsOperationType.PostTopic : CreditsOperationType.PostReply; //获取版块积分规则 float[] creditsValue = Forums.GetValues( creditsOperationType == CreditsOperationType.PostTopic ? forumInfo.Postcredits : forumInfo.Replycredits ); //如果未定义版块积分规则 if (creditsValue == null) { creditsValue = Scoresets.GetUserExtCredits(creditsOperationType); } UpdateUserExtCredits(postInfo.Posterid, creditsValue, 1, creditsOperationType, -1, true); //当不保留附件时,对附件进行相应的减分操作 if (!reserveAttach) { int attCount = Attachments.GetAttachmentCountByPid(postInfo.Pid); if (attCount != 0) { DeleteAttachments(postInfo.Posterid, attCount); } } } }
/// <summary> /// 发主题时更新用户积分 /// </summary> /// <param name="userId">用户id</param> /// <param name="forumInfo">版块信息</param> /// <param name="isNeedAnimation">是否需要积分动画</param> public static void PostTopic(int userId, ForumInfo forumInfo, bool isNeedAnimation) { if (userId == -1) { return; } float[] values = Forums.GetValues(forumInfo.Postcredits); if (values != null) ///使用版块内积分 { UpdateUserExtCredits(userId, values, false); } else ///使用默认积分 { UpdateUserExtCredits(userId, 1, CreditsOperationType.PostTopic, 1, false); } if (isNeedAnimation) { WriteUpdateUserExtCreditsCookies(values != null ? values : Scoresets.GetUserExtCredits(CreditsOperationType.PostTopic)); } }
/// <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); }