Beispiel #1
0
        /// <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"]));
                    }
                }
            }
        }
Beispiel #2
0
        /// <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);
            }

            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);
                    CreditsFacade.UnDigest(TypeConverter.ObjectToInt(dr["posterid"]));
                }
            }

            List <PostInfo> list = Posts.GetPostList(topicList);

            if (list != null && list.Count != 0)
            {
                int       lastFid   = 0;
                ForumInfo forumInfo = null;
                foreach (PostInfo postInfo in list)
                {
                    //如果与上一个帖子是同一版块,将不再重新读取版块信息
                    if (lastFid != postInfo.Fid)
                    {
                        lastFid   = postInfo.Fid;
                        forumInfo = Forums.GetForumInfo(lastFid);
                    }
                    CreditsFacade.DeletePost(postInfo, forumInfo, reserveAttach);
                }
            }

            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);
        }
Beispiel #3
0
        /// <summary>
        /// 移动主题到指定版块
        /// </summary>
        /// <param name="topiclist">要移动的主题列表</param>
        /// <param name="fid">转到的版块ID</param>
        /// <param name="savelink">是否在原版块保留连接</param>
        /// <returns>更新记录数</returns>
        public static int MoveTopics(string topiclist, int fid, int oldfid, bool savelink, int topicType)
        {
            if (!Utils.IsNumericList(topiclist))
            {
                return(-1);
            }
            string    tidList = "";
            DataTable dt      = Topics.GetTopicList(topiclist);

            foreach (DataRow dr in dt.Rows)
            {
                if (TypeConverter.ObjectToInt(dr["closed"]) <= 1 || TypeConverter.ObjectToInt(dr["fid"]) != oldfid)
                {
                    tidList += dr["tid"].ToString() + ",";
                }
            }
            tidList = tidList.TrimEnd(',');

            if (string.IsNullOrEmpty(tidList))
            {
                return(-1);
            }
            Discuz.Data.TopicAdmins.DeleteClosedTopics(fid, tidList);

            //转移帖子
            MoveTopics(tidList, fid, oldfid, topicType);

            //如果保存链接则复制一条记录到原版块
            if (savelink)
            {
                if (Discuz.Data.TopicAdmins.CopyTopicLink(oldfid, tidList) <= 0)
                {
                    return(-2);
                }

                AdminForumStats.ReSetFourmTopicAPost(oldfid);
                Forums.SetRealCurrentTopics(oldfid);
            }
            return(1);
        }
Beispiel #4
0
        /// <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);
        }