コード例 #1
0
        /// <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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: AdminTopics.cs プロジェクト: terryxym/DiscuzNT
        /// <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);
        }
コード例 #3
0
ファイル: TopicAdmins.cs プロジェクト: xslonglianxia/DiscuzNT
        /// <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);
        }