/// <summary> /// 撤消评分 /// </summary> /// <param name="tid"></param> /// <param name="postidlist"></param> /// <param name="userid"></param> /// <param name="username"></param> /// <param name="reason"></param> public static void CancelRatePosts(string ratelogidlist, int tid, string pid, int userid, string username, int groupid, string grouptitle, int forumid, string forumname, string reason) { if (!Utils.IsNumeric(pid)) { return; } int rateduserid = Posts.GetPostInfo(tid, Utils.StrToInt(pid, 0)).Posterid; //被评分的用户的UID if (rateduserid <= 0) { return; } string posttableid = Data.PostTables.GetPostTableId(tid); DataTable dt = AdminRateLogs.LogList(ratelogidlist.Split(',').Length, 1, "id IN(" + ratelogidlist + ")");//得到要删除的评分日志列表 foreach (DataRow dr in dt.Rows) { SetPostRate(posttableid, TypeConverter.StrToInt(pid), TypeConverter.ObjectToInt(dr["extcredits"]), TypeConverter.ObjectToInt(dr["score"]), false); //乘-1是要进行分值的反向操作 Discuz.Data.Users.UpdateUserExtCredits(rateduserid, TypeConverter.ObjectToInt(dr["extcredits"]), (-1) * TypeConverter.ObjectToFloat(dr["score"])); } AdminRateLogs.DeleteLog("[id] IN(" + ratelogidlist + ")"); //当帖子已无评分记录时,则清空帖子相关的评分信息字段(rate,ratetimes) if (AdminRateLogs.LogList(1, 1, "pid = " + pid).Rows.Count == 0) { Discuz.Data.Posts.CancelPostRate(pid, posttableid); } TopicInfo topicinfo = Topics.GetTopicInfo(tid); Discuz.Data.ModeratorManageLog.InsertModeratorLog(userid.ToString(), username, groupid, grouptitle, Utils.GetRealIP(), Utils.GetDateTime(), forumid.ToString(), forumname, tid.ToString(), topicinfo == null ? "暂无标题" : topicinfo.Title, "撤消评分", reason); }
/// <summary> /// 给指定帖子评分 /// </summary> /// <param name="postidlist">帖子列表</param> /// <param name="score">要加/减的分值列表</param> /// <param name="extcredits">对应的扩展积分列表</param> /// <returns>更新数量</returns> public static int RatePosts(int tid, string postidlist, string score, string extcredits, int userid, string username, string reason) { if (!Utils.IsNumericList(postidlist)) { return(0); } float[] extcreditslist = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 }; string[] tmpScorelist = Utils.SplitString(score, ","); string[] tmpExtcreditslist = Utils.SplitString(extcredits, ","); int tempExtc = 0; string posttableid = Data.PostTables.GetPostTableId(tid); for (int i = 0; i < tmpExtcreditslist.Length; i++) { tempExtc = TypeConverter.StrToInt(tmpExtcreditslist[i], -1); if (tempExtc > 0 && tempExtc < extcreditslist.Length) { extcreditslist[tempExtc - 1] = TypeConverter.StrToInt(tmpScorelist[i]); //更新相应帖子的积分数 foreach (string pid in Utils.SplitString(postidlist, ",")) { if (pid.Trim() != string.Empty) { SetPostRate(posttableid, TypeConverter.StrToInt(pid), TypeConverter.StrToInt(tmpExtcreditslist[i]), TypeConverter.StrToFloat(tmpScorelist[i]), true); } } AdminRateLogs.InsertLog(postidlist, userid, username, tempExtc, TypeConverter.StrToFloat(tmpScorelist[i]), reason); } } return(CreditsFacade.UpdateUserExtCredits(GetUserListWithPostlist(tid, postidlist), extcreditslist)); }