示例#1
0
        /// <summary>
        /// 将主题设置精华/解除精华
        /// </summary>
        /// <param name="topiclist">要设置的主题列表</param>
        /// <param name="intValue">精华级别( 0 为解除精华)</param>
        /// <returns>更新主题个数</returns>
        public static int SetDigest(string topiclist, int intValue)
        {
            string useridlist = GetUserListWithDigestTopiclist(topiclist, intValue > 0 ? 1 : 0);
            int    mount      = SetTopicStatus(topiclist, "digest", intValue);

            if (mount > 0)
            {
                if (Utils.IsNumericList(useridlist))
                {
                    Discuz.Data.Users.UpdateUserDigest(useridlist);
                }

                if (!string.IsNullOrEmpty(useridlist) && Utils.IsNumericList(useridlist))
                {
                    //UserCredits.UpdateUserCreditsAndExtCredits(useridlist, CreditsOperationType.Digest, intValue > 0 ? 1 : -1);
                    foreach (string uid in Utils.SplitString(useridlist, ","))
                    {
                        if (intValue > 0)
                        {
                            CreditsFacade.SetDigest(TypeConverter.StrToInt(uid));
                        }
                        else
                        {
                            CreditsFacade.UnDigest(TypeConverter.StrToInt(uid));
                        }
                    }
                }
            }
            return(mount);
        }
示例#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);
        }