Beispiel #1
0
        protected bool CanViewValuedThread(PostV5 post)
        {
            if (post.PostType != PostType.ThreadContent)
            {
                return(true);
            }

            bool can;

            if (canViewValueThreads.TryGetValue(post.ForumID, out can) == false)
            {
                BasicThread thread = searchThreads.GetValue(post.ThreadID);
                if (thread.IsValued == false)
                {
                    can = true;
                }
                else
                {
                    can = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID).Can(My, ForumPermissionSetNode.Action.ViewValuedThread);
                }

                canViewValueThreads.Add(post.ForumID, can);
            }

            return(can);
        }
Beispiel #2
0
 protected bool CanDeleteReply(PostV5 post)
 {
     if (post == null)
     {
         return(true);
     }
     return(AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(post.ForumID).Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeletePosts, post.UserID));
 }
Beispiel #3
0
        protected string GetPostContent(PostV5 post)
        {
            if (StringUtil.GetByteCount(post.ContentForSearch) > 300)
            {
                return(StringUtil.CutString(post.ContentForSearch, 300));
            }

            return(post.ContentForSearch);
        }
Beispiel #4
0
 protected bool IsShowContent(PostV5 post)
 {
     if (Forum.IsShieldedUser(post.UserID) || post.IsShielded /*|| ForumPermission.Can(post.UserID, ForumPermissionSetNode.Action.DisplayContent) == false*/)
     {
         return(AlwaysViewShieldContents(post.UserID));
     }
     else
     {
         return(true);
     }
 }
Beispiel #5
0
        protected bool IsShieldedUser(PostV5 post)
        {
            if (UserBO.Instance.IsBanned(post.UserID, post.ForumID))
            {
                return(true);
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            return(permission.Can(post.UserID, ForumPermissionSetNode.Action.DisplayContent) == false);
        }
Beispiel #6
0
 protected bool IsLastPost(PostV5 post)
 {
     if (post.PostType == PostType.ThreadContent)
     {
         return(true);
     }
     if (post.PostID == LastPostID)
     {
         return(true);
     }
     return(false);
 }
Beispiel #7
0
        protected bool IsAlwaysViewShieldContents(PostV5 post)
        {
            bool canView;

            if (isAlwaysViewShieldContents.TryGetValue(post.ForumID, out canView) == false)
            {
                canView = post.Forum.ManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.AlwaysViewContents, post.UserID);
                isAlwaysViewShieldContents.Add(post.ForumID, canView);
            }

            return(canView);
        }
Beispiel #8
0
        protected bool IsAlwaysViewContents(PostV5 post)
        {
            bool canView;

            if (isAlwaysViewContents.TryGetValue(post.ForumID, out canView))
            {
                canView = post.Forum.Permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents);
                isAlwaysViewContents.Add(post.ForumID, canView);
            }

            return(canView);
        }
Beispiel #9
0
		public bool DeleteDenouncingWithData(int operatorID, int denouncingID)
		{
			if (ManagePermission.Can(operatorID, BackendPermissions.Action.Manage_Report) == false)
			{
				ThrowError(new NoPermissionDeleteDenouncingError());
				return false;
			}

			Denouncing denouncing = DenouncingDao.Instance.GetDenouncing(denouncingID);

			if (denouncing == null)
				return false;
			else
			{
				DenouncingDao.Instance.DeleteDenouncing(denouncingID);

				switch (denouncing.Type)
				{
					case DenouncingType.Blog:
						BlogBO.Instance.DeleteBlogArticle(operatorID, denouncing.TargetID, true);
						break;

					case DenouncingType.Photo:
						AlbumBO.Instance.DeletePhoto(operatorID, denouncing.TargetID, true);
						break;

					case DenouncingType.Share:
						ShareBO.Instance.DeleteShare(operatorID, denouncing.TargetID, true);
						break;

					case DenouncingType.Space:
						//老达TODO:怎么搞?
						break;

                    case DenouncingType.Topic:

                        PostBOV5.Instance.DeleteThreads(UserBO.Instance.GetAuthUser(operatorID), new int[] { denouncing.TargetID }, false, true, false, false, string.Empty);

                        break;

                    case DenouncingType.Reply:
                        PostV5 post = PostBOV5.Instance.GetPost(denouncing.TargetID, false);
                        PostBOV5.Instance.DeletePosts(UserBO.Instance.GetAuthUser(operatorID), post.ForumID, post.ThreadID, new int[] { post.PostID }, false, true, false, string.Empty);

                        break;
				}

                //CacheUtil.Remove("Denouncing/Count");

				return true;
			}
		}
        private void ProcessDownload3(HttpContext context, BasicThread thread, PostV5 post, int diskFileID)
        {
            Forum forum = ForumBO.Instance.GetForum(post.ForumID);
            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (false == permission.Can(userID, ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID)
            {
                ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif");
                return;
            }

            if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子
            {
                AuthUser user  = User.Current;
                bool     isBuy = false;
                if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取
                {
                }
                if (!isBuy)
                {
                    if (thread.Price > 0)
                    {
                        if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent)
                        {
                            if (false == post.IsFreeDiskFileID(diskFileID) && false == post.IsFreeAttachmentID(attachment.AttachmentID))
                            {
                                if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user))
                                {
                                    Context.ThrowError <CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!"));
                                    return;
                                    //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0);
                                }
                            }
                        }
                    }
                }
            }

            if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID))
            {
                if (false == OutputFileByID(context, attachment.FileID, attachment.FileName, attachment.FileType, outputMode))
                {
                    ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif");
                }
            }
            else
            {
                ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif");
            }
        }
Beispiel #11
0
        public string GetPostThreadUrl(int postID)
        {
            PostV5 post = Posts.GetValue(postID);

            if (post != null)
            {
                Forum forum = ForumBO.Instance.GetForum(post.ForumID);
                if (forum == null)
                {
                    return(string.Empty);
                }
                return(MaxLabs.bbsMax.Common.BbsUrlHelper.GetThreadUrl(forum.CodeName, post.ThreadID));
            }
            return(string.Empty);
        }
Beispiel #12
0
        protected string GetContent(int threadID)
        {
            PostV5 post = GetThreadContent(threadID);

            if (post == null)
            {
                return(string.Empty);
            }

            if (StringUtil.GetByteCount(post.ContentForSearch) > 300)
            {
                return(StringUtil.CutString(post.ContentForSearch, 300));
            }

            return(post.ContentForSearch);
        }
Beispiel #13
0
        protected bool AllowManagePost(PostV5 post)
        {
            if (post.PostType == PostType.ThreadContent)
            {
                return(false);
            }

            ManageForumPermissionSetNode managePermission = AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (managePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeletePosts, post.UserID))
            {
                return(true);
            }

            return(false);
        }
Beispiel #14
0
        protected bool CanViewPost(PostV5 post)
        {
            bool can;

            if (viewPost.TryGetValue(post.ForumID, out can) == false)
            {
                if (post.Forum.Permission.Can(My, ForumPermissionSetNode.Action.ViewReply))
                {
                    can = true;
                }
                else
                {
                    can = false;
                }
                viewPost.Add(post.ForumID, can);
            }

            return(can);
        }
Beispiel #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int attachmentID = _Request.Get <int>("attachmentID", Method.Get, 0);

            if (attachmentID < 1)
            {
                ShowError(new InvalidParamError("attachmentID").Message);
            }

            attachment = PostBOV5.Instance.GetAttachment(attachmentID, false);
            if (attachment == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            PostV5 post = PostBOV5.Instance.GetPost(attachment.PostID, false);

            if (post == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (post.UserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!attachment.IsBuyed(My))
                {
                    ShowError("您还没有购买此附件,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(post.UserID, ForumPointValueType.SellAttachment, post.ForumID);

            int pageNumber = _Request.Get <int>("page", Method.Get, 1);

            ExchangeList = PostBOV5.Instance.GetAttachmentExchanges(attachmentID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers <AttachmentExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
Beispiel #16
0
        /// <summary>
        /// 权限判断
        /// </summary>
        /// <param name="operatorUser">操作者</param>
        /// <param name="userid">目标用户</param>
        /// <param name="targetID">目标对象ID</param>
        /// <param name="action">操作</param>
        /// <returns></returns>
        public bool CanListUserEmoticons(AuthUser operatorUser, int userid, int targetID, string action)
        {
            switch (action)
            {
            case "post":
                PostV5 post = PostBOV5.Instance.GetPost(targetID, false);
                ManageForumPermissionSetNode permission = AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(post.ForumID);
                if (permission.Can(operatorUser, ManageForumPermissionSetNode.ActionWithTarget.UpdateThreads, post.UserID) ||
                    permission.Can(operatorUser, ManageForumPermissionSetNode.ActionWithTarget.UpdatePosts, post.UserID))
                {
                    return(true);
                }
                break;

            case "userinfo":
                return(UserBO.Instance.CanEditUserProfile(operatorUser, userid));
            }

            return(false);
        }
Beispiel #17
0
        protected bool HasBuyed(PostV5 post)
        {
            if (post.PostType != PostType.ThreadContent)
            {
                return(true);
            }

            BasicThread thread = searchThreads.GetValue(post.ThreadID);

            if (thread == null)
            {
                return(true);
            }

            if (thread.Price == 0 || thread.PostUserID == MyUserID || thread.IsOverSellDays(thread.Forum.ForumSetting))
            {
                return(true);
            }

            return(HasBuyThreadIDs.Contains(post.ThreadID));
        }
Beispiel #18
0
 protected bool CanSeeContent(PostV5 post, bool isThreadContent)
 {
     if (isThreadContent)
     {
         if (Thread.IsValued)
         {
             if (ForumPermission.Can(My, ForumPermissionSetNode.Action.ViewValuedThread))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else if (ForumPermission.Can(My, ForumPermissionSetNode.Action.ViewThread))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         if (ForumPermission.Can(My, ForumPermissionSetNode.Action.ViewReply))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Beispiel #19
0
 protected bool CanSeeContent(PostV5 post)
 {
     return(CanSeeContent(post, post.PostIndex == 0));
 }
Beispiel #20
0
 public abstract void GetPosts(int threadID, int totalReplies, int getOldCount, int getNewCount, ref BasicThread thread, out PostV5 threadContent, out PostCollectionV5 topPosts);
Beispiel #21
0
 protected bool IsLastPost(PostV5 post)
 {
     if (post.PostType == PostType.ThreadContent)
         return true;
     if (post.PostID == LastPostID)
         return true;
     return false;
 }
        private void ProcessDownload(HttpContext context, string fileID)
        {
            PostV5 post  = PostBOV5.Instance.GetPost(attachment.PostID, false);
            Forum  forum = ForumBO.Instance.GetForum(post.ForumID);

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            //if (!forum.Permission.ViewAttachment && attachment.UserID != userID)
            if (false == permission.Can(userID, ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID)
            {
                ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif");
                return;
            }

            if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子
            {
                AuthUser user  = User.Current;
                bool     isBuy = false;
                if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取
                {
                }
                if (!isBuy)
                {
                    BasicThread thread = PostBOV5.Instance.GetThread(post.ThreadID);
                    if (thread.Price > 0)
                    {
                        //Post firstPost = PostManager.GetThreadFirstPost(thread.ThreadID);
                        //if (firstPost != null && firstPost.PostID == post.PostID)//附件所在的帖子是主题的内容
                        if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent)
                        {
                            //if (!firstPost.FreeAttachmentIDs.Contains(attachment.AttachmentID))//attachment.DiskFileID))//不在[free]标签中
                            if (false == post.IsFreeAttachmentID(attachment.AttachmentID))
                            {
                                if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user))
                                {
                                    Context.ThrowError <CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子,没有权限下载附件!"));
                                    //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0);
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID))
            {
                //if (!IOUtil.DownloadFile(context.Response, context.Request, filePath, attachment.FileName, true, false))
                if (false == OutputFileByID(context, fileID, attachment.FileName, attachment.FileType, outputMode))
                {
                    ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif");
                    return;
                }
            }
            else
            {
                ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif");
                return;
            }

            context.Response.End();
        }
Beispiel #23
0
        /*
        #region 存储过程 bx_GetCachedPosts
        [StoredProcedure(Name = "bx_GetCachedPosts", Script = @"
CREATE PROCEDURE {name}
     @ThreadID            int
    ,@GetOldCount         int
    ,@GetNewCount         int 
    ,@TotalCount          int
    ,@BestPostID          int
    ,@TopMarkCount        int    
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @SQLString nvarchar(4000),@SQLString2 nvarchar(4000);
	SET @SQLString='';
    SET @SQLString2 = '';

    DECLARE @Condition nvarchar(4000);
    SET @Condition = '[ThreadID]=' + CAST(@ThreadID as varchar(16))+' AND [SortOrder]<4000000000000000 ';

    IF @BestPostID <> 0 BEGIN
        SET @TotalCount = @TotalCount - 1;
        SET @Condition = '[PostID]<>' + CAST(@BestPostID as varchar(16)) + ' AND ' + @Condition;
    END 

    DECLARE @ExcuteSqlString2 char(1);
    IF @GetOldCount + @GetNewCount >= @TotalCount BEGIN
        SET @SQLString = 'SELECT TOP '+ CAST((@GetOldCount + @GetNewCount) as varchar(16)) +' " + PostColumns + @" FROM [bx_Posts] WITH(NOLOCK) WHERE ' + @Condition + ' ORDER BY PostID DESC ';
        SET @SQLString2 = @SQLString;
        SET @ExcuteSqlString2 = '0';
    END
    ELSE BEGIN
        SET @ExcuteSqlString2 = '1';
        SET @SQLString = '
                            SELECT * FROM 
                            (SELECT TOP '+ CAST(@GetOldCount as varchar(16)) +' " + PostColumns + @" FROM [bx_Posts] WITH(NOLOCK) WHERE ' + @Condition + ' ORDER BY PostID ASC) AS T1
                         ';

        SET @SQLString2 = '
                            SELECT * FROM 
                            (SELECT TOP '+ CAST(@GetNewCount as varchar(16)) +' " + PostColumns + @" FROM [bx_Posts] WITH(NOLOCK) WHERE ' + @Condition + ' ORDER BY PostID DESC) AS T2
                          ';
    END
        
        DECLARE @PostFieldsString nvarchar(4000);
        " + PostFields2 + @"
     
END
"
            )]
        #endregion

        */
        public override void GetPosts(int threadID, int totalReplies, int getOldCount, int getNewCount, ref BasicThread thread, out PostV5 threadContent, out PostCollectionV5 topPosts)
        {
            threadContent = null;
            topPosts = null;

            using (SqlQuery query = new SqlQuery())
            {
                int bestPostID = 0;
                if (SetBestPost(query, thread))
                {
                    QuestionThread question = (QuestionThread)thread;
                    bestPostID = question.BestPostID;
                }

                query.CommandText = "bx_GetCachedPosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<int>("@TotalCount", totalReplies + 1, SqlDbType.Int);//要获取主题内容  所以回复总数加1
                query.CreateParameter<int>("@GetOldCount", getOldCount + 1, SqlDbType.Int);//要获取主题内容  所以加1
                query.CreateParameter<int>("@GetNewCount", getNewCount, SqlDbType.Int);

                SetTopMarkCountParam(query);
                query.CreateParameter<int>("@BestPostID", bestPostID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    topPosts = GetPosts(reader, true);
                    if (topPosts.Count > 0)
                    {
                        threadContent = topPosts[0];
                        topPosts.RemoveAt(0);
                    }
                }
            }
        }
Beispiel #24
0
 protected string GetSearchThreadUrl(PostV5 post)
 {
     return(BbsUrlHelper.GetSearchThreadUrl(post.Forum.CodeName, post.ThreadID, post.PostID, mode, searchText));
 }
Beispiel #25
0
 public abstract bool UpdateThread(int threadID, int postID, bool isApproved, int threadCatalogID, int iconID
                                   , string subject, int price, int lastEditorID, string lastEditorName, string content, bool enableHtml
                                   , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, AttachmentCollection attachments, IEnumerable <int> historyAttachmentIDs
                                   , ThreadAttachType attachType, string words, out BasicThread thread, out PostV5 post, out List <int> attachmentIDs, out Dictionary <string, int> fileIDs);
Beispiel #26
0
        public override Dictionary<BasicThread, PostCollectionV5> GetUnapprovedPosts(int forumID)
        {
            Dictionary<BasicThread, PostCollectionV5> unapprovedPosts = new Dictionary<BasicThread, PostCollectionV5>();

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetUnapprovedPosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ForumID", forumID, SqlDbType.Int);
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        BasicThread thread = GetThread(reader, null);
                        unapprovedPosts.Add(thread, new PostCollectionV5());
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            PostV5 post = new PostV5(reader);
                            foreach (BasicThread thread in unapprovedPosts.Keys)
                            {
                                if (thread.ThreadID == post.ThreadID)
                                {
                                    unapprovedPosts[thread].Add(post);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return unapprovedPosts;
        }
Beispiel #27
0
 protected bool IsShowContent(PostV5 post)
 {
     if (Forum.IsShieldedUser(post.UserID) || post.IsShielded /*|| ForumPermission.Can(post.UserID, ForumPermissionSetNode.Action.DisplayContent) == false*/)
     {
         return AlwaysViewShieldContents(post.UserID);
     }
     else
         return true;
 }
Beispiel #28
0
 protected bool CanSeeContent(PostV5 post, bool isThreadContent)
 {
     if (isThreadContent)
     {
         if (Thread.IsValued)
         {
             if (ForumPermission.Can(My, ForumPermissionSetNode.Action.ViewValuedThread))
                 return true;
             else
                 return false;
         }
         else if (ForumPermission.Can(My, ForumPermissionSetNode.Action.ViewThread))
             return true;
         else
             return false;
     }
     else
     {
         if (ForumPermission.Can(My, ForumPermissionSetNode.Action.ViewReply))
             return true;
         else
             return false;
     }
 }
Beispiel #29
0
 public abstract bool CreatePolemize(string agreeViewPoint, string againstViewPoint, DateTime polemizeExpiresDate
                                     , int forumID, int threadCatalogID, ThreadStatus threadStatus, int iconID
                                     , string subject, string subjectStyle, int postUserID, string postNickName, bool isLocked, bool isValued, string content, bool enableHtml
                                     , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, string ipAddress, AttachmentCollection attachments, IEnumerable <int> historyAttachmentIDs
                                     , ThreadAttachType attachType, string words, out BasicThread thread, out PostV5 post, out int totalThreads, out int totalPosts, out List <int> attachmentIDs, out Dictionary <string, int> fileIDs);
Beispiel #30
0
        public override Dictionary<int, PostV5> GetThreadContents(IEnumerable<int> threadIDs)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = @"
SELECT * FROM bx_Posts WITH (NOLOCK) WHERE PostType=1 AND ThreadID in(@ThreadIDs);
"
                    ;
                query.CommandType = CommandType.Text;

                query.CreateInParameter<int>("@ThreadIDs", threadIDs);

                Dictionary<int, PostV5> posts = new Dictionary<int, PostV5>();
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        PostV5 post = new PostV5(reader);
                        if (posts.ContainsKey(post.ThreadID) == false)
                            posts.Add(post.ThreadID, post);
                    }
                }

                return posts;
            }
        }
Beispiel #31
0
        private PostCollectionV5 GetPosts(XSqlDataReader reader, bool isFirstRead)
        {
            PostCollectionV5 posts = new PostCollectionV5();

            List<int> replyIDs = new List<int>();

            if (isFirstRead)
            {
                while (reader.Read())
                {
                    PostV5 post = new PostV5(reader);
                    post.Attachments = new AttachmentCollection();
                    post.PostMarks = new PostMarkCollection();
                    posts.Add(post);
                    replyIDs.Add(post.PostID);
                }
            }
            else
            {
                if (reader.NextResult())
                {
                    while (reader.Read())
                    {
                        PostV5 post = new PostV5(reader);
                        post.Attachments = new AttachmentCollection();
                        post.PostMarks = new PostMarkCollection();
                        posts.Add(post);
                        replyIDs.Add(post.PostID);
                    }
                }
            }
            //读取下一个结果集
            if (reader.NextResult())
            {
                while (reader.Read()) //附件列表
                {
                    Attachment attachment = new Attachment(reader);
                    int replyIndex = replyIDs.IndexOf(attachment.PostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].Attachments.Add(attachment);
                    }
                }
            }
            //历史附件
            if (reader.NextResult())
            {
                while (reader.Read()) //附件列表
                {
                    Attachment attachment = new Attachment(reader);
                    attachment.AttachType = AttachType.History;
                    int hpostID = reader.Get<int>("HPostID");
                    int replyIndex = replyIDs.IndexOf(hpostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].Attachments.Add(attachment);
                    }
                }
            }
            if (reader.NextResult())//评分列表
            {
                while (reader.Read())
                {
                    PostMark postMark = new PostMark(reader);
                    int replyIndex = replyIDs.IndexOf(postMark.PostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].PostMarks.Add(postMark);
                    }
                }
            }
            if (reader.NextResult())
            {
                string s = null;
                while (reader.Read())
                {
                    s = reader.Get<string>(0);
                }

#if !Publish
                if (reader.SqlQuery.TempInfo != null)
                    reader.SqlQuery.TempInfo += "-----" + s;
                else
                    reader.SqlQuery.TempInfo = s;
#endif
            }

            return posts;
        }
Beispiel #32
0
        private void ProcessBuyAttachment()
        {
            if (IsLogin == false)
            {
                ShowError("您还没有登陆,不能购买附件!");
            }
            else
            {
                Attachment tempAttachment = null;
                MaxLabs.bbsMax.FileSystem.PhysicalFile phyFile = null;
                if (tempAttachmentID <= 0)
                {
                    ShowError(new InvalidParamError("attachmentID"));
                }
                else
                {
                    tempAttachment = PostBOV5.Instance.GetAttachment(tempAttachmentID);

                    if (tempAttachment == null)
                    {
                        ShowError("该附件不存在,可能被移动或被删除!");
                    }
                    //diskFile = zzbird.Common.Disk.DiskManager.GetDiskFile(tempAttachment.DiskFileID);
                    phyFile = FileManager.GetFile(tempAttachment.FileID);
                }
                if (phyFile == null)
                {
                    ShowError("该附件不存在,可能被移动或被删除!");
                }

                if (MyUserID == tempAttachment.UserID || tempAttachment.Price == 0)
                {
                    ShowError("该附件您不需要购买!");
                }
                if (!tempAttachment.IsBuyed(My))//没购买过
                {
                    int trade = Math.Abs(tempAttachment.Price);

                    PostV5 post = PostBOV5.Instance.GetPost(tempAttachment.PostID, false);
                    if (post == null)
                    {
                        ShowError("该附件不存在,可能被移动或被删除!");
                    }

                    UserPoint tradePoint = ForumPointAction.Instance.GetUserPoint(tempAttachment.UserID, ForumPointValueType.SellAttachment, post.ForumID);

                    if (tradePoint == null)
                    {
                        ShowError("系统交易积分错误!");
                    }

                    using (ErrorScope es = new ErrorScope())
                    {
                        bool success = UserBO.Instance.TradePoint(MyUserID, tempAttachment.UserID, tempAttachment.Price, tradePoint.Type, false, true, null);
                        if (success == false)
                        {
                            es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                if (error is UserPointOverMinValueError)
                                {
                                    UserPointOverMinValueError tempError = (UserPointOverMinValueError)error;
                                    NotEnoughPointBuyAttachment notEnoughPointBuyAttachment = new NotEnoughPointBuyAttachment("", tempError.UserPoint, tempAttachment.Price, My.ExtendedPoints[(int)tempError.UserPoint.Type]);
                                    ShowError(notEnoughPointBuyAttachment);
                                }
                                else
                                {
                                    ShowError(error.Message);
                                }
                            });
                        }
                        else
                        {
                            //创建交易记录
                            if (!PostBOV5.Instance.CreateAttachmentExchange(tempAttachment.AttachmentID, MyUserID, tempAttachment.Price))
                            {
                                ShowError("购买成功,创建交易记录失败!");
                            }
                            else
                            {
                                //下载
                                //更新userprofile
                                if (My.BuyedAttachments.ContainsKey(tempAttachment.AttachmentID))
                                {
                                    My.BuyedAttachments[tempAttachment.AttachmentID] = true;
                                }

                                //Thread.FirstPost = null;
                                ShowSuccess("购买成功,现在可以查看、下载或收藏!", true);
                            }
                        }
                    }
                }
                else
                {
                    ShowError("您已经购买此附件,无需再次购买!");
                }
            }
        }
Beispiel #33
0
 public abstract bool UpdatePost(int postID, bool getExtendedInfo, bool isApproved, int iconID
                                 , string subject, int lastEditorID, string lastEditorName, string content, bool enableHtml
                                 , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, AttachmentCollection attachments, IEnumerable <int> historyAttachmentIDs
                                 , out PostV5 post, out List <int> attachmentIDs, out Dictionary <string, int> fileIDs);
Beispiel #34
0
        protected bool GetPosts(ThreadType threadType, out int?totalCount, out BasicThread thread, out PostCollectionV5 posts)
        {
            totalCount = null;
            thread     = null;
            posts      = null;
            ThreadType realThreadType = threadType;

            if (string.Compare(Type, SystemForum.RecycleBin.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                //totalCount = base.TotalPosts;
                return(true);
            }
            else if (string.Compare(Type, SystemForum.UnapproveThreads.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                //m_Thread.ThreadContent = m_PostList[0];
                totalCount = posts.TotalRecords;
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                return(true);
            }
            else if (string.Compare(Type, MyThreadType.MyUnapprovedThread.ToString(), true) == 0)
            //|| string.Compare(Type, MyThreadType.MyUnapprovedPostThread.ToString(), true) == 0)
            {
                int count;
                PostBOV5.Instance.GetUnapprovedPostThread(ThreadID, MyUserID, PageNumber, PageSize, out thread, out posts, out count);


                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }
                if (posts.Count > 0)
                {
                    thread.ThreadContent = posts[0];
                }
                else
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }


                totalCount = count;
                return(true);
            }
            else if (IsGetPost)
            {
                if (threadType != ThreadType.Normal)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal)), "type=getpost&postid=" + PostID);
                }

                thread = PostBOV5.Instance.GetThread(ThreadID);
                PostV5 post = PostBOV5.Instance.GetPost(PostID, true);
                if (post == null)
                {
                    ShowError("您要查看的帖子不存在或者已被删除");
                }

                posts = new PostCollectionV5();
                posts.Add(post);

                totalCount = 1;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #35
0
        protected bool HasBuyed(PostV5 post)
        {
            if (post.PostType != PostType.ThreadContent)
                return true;

            BasicThread thread = searchThreads.GetValue(post.ThreadID);
            if (thread == null)
                return true;

            if (thread.Price == 0 || thread.PostUserID == MyUserID || thread.IsOverSellDays(thread.Forum.ForumSetting))
                return true;

            return HasBuyThreadIDs.Contains(post.ThreadID);
        }
Beispiel #36
0
        protected bool isShowSignature(PostV5 reply)
        {
            if (reply.UserID == 0)
                return false;

            //if (My.IsSpider)
            //    return false;

            if (Forum.IsShieldedUser(reply.UserID))
                return false;

            if (string.IsNullOrEmpty(reply.User.SignatureFormatted))
                return false;

            if (reply.IsShielded)
                return false;

            if (AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(ForumID).Can(reply.UserID, ForumPermissionSetNode.Action.DisplayContent) == false)
                return false;

            if (reply.User.SignaturePropFlag.Available)
                return true;
            
            if (!reply.EnableSignature)
                return false;

            if (AllSettings.Current.BbsSettings.DisplaySignature.GetValue(reply.UserID))
            {
                return true;
            }

            return false;
        }
Beispiel #37
0
        protected bool IsShieldedUser(PostV5 post)
        {
            if (UserBO.Instance.IsBanned(post.UserID, post.ForumID))
                return true;

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            return permission.Can(post.UserID, ForumPermissionSetNode.Action.DisplayContent) == false;
        }
Beispiel #38
0
 public abstract void GetAttachment(int diskFileID, int postID, out Attachment attachment, out PostV5 post, out BasicThread thread);
Beispiel #39
0
        public override void GetPosts(int threadID, bool onlyNormal, int pageNumber, int pageSize, int? totalCount, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetPagePosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                query.CreateParameter<int?>("@TotalCount", totalCount, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadType", (int)threadType, SqlDbType.TinyInt);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);
                query.CreateParameter<bool>("@OnlyNormal", onlyNormal, SqlDbType.Bit);

                SetTopMarkCountParam(query);


                if (getThreadContent)
                {
                    if (thread != null && thread.ThreadContent != null)// && thread is BasicThread)
                    {
                        getThreadContent = false;
                    }
                }

                bool getBestPost = false;

                QuestionThread question = null;
                if (getThreadContent)
                {
                    if (thread != null && thread is QuestionThread)
                    {
                        question = (QuestionThread)thread;
                        getBestPost = question.BestPost == null;
                    }
                    else if (thread == null && getThread)
                    {
                        getBestPost = true;
                    }
                }

                if (pageNumber == 1)
                    getThreadContent = false;

                query.CreateParameter<bool>("@GetBestPost", getBestPost, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThreadContent", getThreadContent, SqlDbType.Bit);


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    if (checkThreadType)
                    {
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    bool hasReadThreadContentOrBestPost = false;

                    #region Read hasReadThreadContentOrBestPost value
                    if (checkThreadType == false)
                    {
                        while (reader.Read())
                        {
                            hasReadThreadContentOrBestPost = reader.Get<int>(0) == 1;
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                hasReadThreadContentOrBestPost = reader.Get<int>(0) == 1;
                            }
                        }
                    }
                    #endregion

                    PostCollectionV5 tempPosts = new PostCollectionV5();

                    #region 读取 主题内容 最佳答案 设置tempPosts  仅当 getExtendedInfo = false 时有
                    if (hasReadThreadContentOrBestPost)
                    {
                        //if (getExtendedInfo)
                        //{
                        //    tempPosts = GetPosts(reader, false);
                        //}
                        //else
                        //{
                            if (reader.NextResult())
                            {
                                tempPosts = new PostCollectionV5(reader);
                            }

                            if (reader.NextResult())
                            {
                                if (reader.Read())
                                {
                                    int id = reader.Get<int>("PostID");
                                    if (id != 0)
                                    {
                                        PostV5 post = new PostV5(reader);
                                        tempPosts.Add(post);
                                    }
                                }
                            }
                        //}
                    }
                    #endregion

                    if (getThread)
                    {
                        #region Read thread
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader,null);
                            }
                        }
                        #endregion
                    }

                    int total = 0;
                    if (onlyNormal == false)
                    {
                        if (reader.NextResult() && reader.Read())
                        {
                            total = reader.Get<int>(0);
                        }
                    }

                    if (thread != null && tempPosts.Count > 0)
                    {
                        SetThreadContent(thread, question, tempPosts, getBestPost, pageNumber, false);
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);

                        if (thread != null && (getBestPost || getThreadContent))
                        {
                            SetThreadContent(thread, question, posts, getBestPost, pageNumber, true);
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }

                    if (reader.NextResult())
                    {
                        string s = null;
                        while (reader.Read())
                        {
                            s = reader.Get<string>(0);
                        }

#if !Publish
                        if (reader.SqlQuery.TempInfo != null)
                            reader.SqlQuery.TempInfo += "-----" + s;
                        else
                            reader.SqlQuery.TempInfo = s;
#endif
                    }

                    if (pageNumber == 1 && thread != null && posts.Count > 0)
                        thread.ThreadContent = posts[0];
                        

                    posts.TotalRecords = total;
                }
            }
        }
Beispiel #40
0
        protected bool AllowManagePost(PostV5 post)
        {
            if (post.PostType == PostType.ThreadContent)
            {
                return false;
            }

            ManageForumPermissionSetNode managePermission = AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (managePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeletePosts, post.UserID))
                return true;

            return false;
        }
Beispiel #41
0
        protected bool IsAlwaysViewShieldContents(PostV5 post)
        {
            bool canView;
            if (isAlwaysViewShieldContents.TryGetValue(post.ForumID,out canView) == false)
            {
                canView = post.Forum.ManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.AlwaysViewContents, post.UserID);
                isAlwaysViewShieldContents.Add(post.ForumID, canView);
            }

            return canView;
        }
Beispiel #42
0
        public override bool CreateThread(int forumID, int threadCatalogID, ThreadStatus threadStatus, int iconID
            , string subject, string subjectStyle, int price, int postUserID, string postNickName, bool isLocked, bool isValued, string content, bool enableHtml
            , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, string ipAddress, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs
            , ThreadAttachType attachType, string words, out BasicThread thread, out PostV5 post, out int totalThreads, out int totalPosts, out List<int> attachmentIDs, out Dictionary<string, int> fileIDs)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = CommandType.StoredProcedure;
                query.CommandText = "bx_v5_CreateThread";

                SetCreateThreadParams(query, forumID, threadCatalogID, threadStatus, iconID, subject, subjectStyle, postUserID, postNickName, isLocked
                    , isValued, content, enableHtml, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress, attachments, historyAttachmentIDs, null, attachType, words);

                query.CreateParameter<int>("@ThreadID", SqlDbType.Int, ParameterDirection.Output);
                query.CreateParameter<int>("@PostID", SqlDbType.Int, ParameterDirection.Output);
                query.CreateParameter("@ThreadType", (int)ThreadType.Normal, SqlDbType.TinyInt);
                query.CreateParameter("@Price", price, SqlDbType.Int);


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    GetThread(reader, attachments, null, out thread, out post, out attachmentIDs, out fileIDs);
                }

                int returnValue = (int)query.Parameters["@ErrorCode"].Value;

                if (returnValue != -1)
                {
                    //threadID = Convert.ToInt32(query.Parameters["@ThreadID"].Value);
                    //postID = Convert.ToInt32(query.Parameters["@PostID"].Value);
                    totalThreads = (query.Parameters["@UserTotalThreads"].Value == DBNull.Value ? 0 : Convert.ToInt32(query.Parameters["@UserTotalThreads"].Value));
                    totalPosts = (query.Parameters["@UserTotalPosts"].Value == DBNull.Value ? 0 : Convert.ToInt32(query.Parameters["@UserTotalPosts"].Value));

                    return true;
                }
                else
                {
                    //threadID = 0;
                    //postID = 0;
                    totalPosts = 0;
                    totalThreads = 0;

                    return false;
                }
            }

        }
Beispiel #43
0
 public abstract bool CreatePost(int threadID, bool getPost, bool isApproved, PostType postType, int iconID, string subject, string content
                                 , bool enableHtml, bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, int forumID, int postUserID, string userName
                                 , string ipAddress, int parentID, bool updateSortOrder, AttachmentCollection attachments, IEnumerable <int> historyAttachmentIDs
                                 , BasicThread thread
                                 , out PostV5 post, out int totalPosts, out List <int> AttachmentIDs, out Dictionary <string, int> fileIDs, out bool threadEnableReplyNotice);
Beispiel #44
0
        public static string FormatRequotePost(string content, PostV5 reply, BasicThread thread)
        {
            //引用的时候  用户自定义的表情 不再使用快捷方式显示 (会照成无法显示,因为发帖页 只列出了当前发帖者的表情)
            //TODO:管理员编辑别人的帖子时 也会出现同样的情况--
            content = regex_faceShortcut.Replace(content, "");

            //bool userEmotion = reply.EnableEmoticons;
            //if(userEmotion)
            //{
            //    ForumSettingItem setting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(reply.ForumID);
            //    userEmotion = setting.CreatePostAllowEmoticon.GetValue(reply.UserID);
            //}
            //content = EmoticonParser.ParseToHtml(reply.UserID, content, userEmotion, userEmotion);

            if (thread.Price > 0)
            {

                PostV5 post = PostBOV5.Instance.GetThreadFirstPost(thread.ThreadID, false);
                if (post != null && post.PostID == reply.PostID) //需要购买的帖子
                {
                    content = ProcessFreeWhenRequoteTag(content);
                }
            }
            content = content.Replace("{$root}", Globals.AppRoot);

            content = regex_ubb.Replace(content, delegate(Match m)
            {
                string temp = regex_code.Replace(m.Groups[1].Value, delegate(Match m2)
                {
                    return string.Concat("[code]", m2.Groups[1].Value, "[/code]");
                });

                return temp;
            });

            ForumSettingItem setting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(thread.ForumID);
            if (setting.EnableHiddenTag)
            {
                content = regex_hide.Replace(content, "[******隐藏内容******]");
            }

            return content;//System.Web.HttpUtility.HtmlEncode(content);
        }
Beispiel #45
0
 private void GetThread(XSqlDataReader reader, AttachmentCollection attachments, DateTime? expiresDate, out BasicThread thread, out PostV5 post, out List<int> attachmentIDs, out Dictionary<string, int> fileIDs)
 {
     attachmentIDs = new List<int>();
     fileIDs = new Dictionary<string, int>();
     thread = null;
     post = null;
     while (reader.Read())
     {
         thread = GetThread(reader, expiresDate);
     }
     if (attachments.Count > 0)
     {
         //本地刚上传的附件 ID
         if (reader.NextResult())
         {
             while (reader.Read())
             {
                 attachmentIDs.Add(reader.Get<int>(0));
             }
         }
         //所有附件
         if (reader.NextResult())
         {
             while (reader.Read())
             {
                 string fileID = reader.Get<string>("fileID");
                 if (fileIDs.ContainsKey(fileID) == false)
                     fileIDs.Add(fileID, reader.Get<int>("attachmentID"));
             }
         }
     }
     if (reader.NextResult())
     {
         while (reader.Read())
         {
             post = new PostV5(reader);
         }
     }
 }
Beispiel #46
0
 protected bool CanSeeContent(PostV5 post)
 {
     return CanSeeContent(post, post.PostIndex == 0);
 }
Beispiel #47
0
        public override bool CreatePoll(string pollItems, int pollMultiple, bool pollIsAlwaysEyeable, DateTime pollExpiresDate
            , int forumID, int threadCatalogID, ThreadStatus threadStatus, int iconID
            , string subject, string subjectStyle, int postUserID, string postNickName, bool isLocked, bool isValued, string content, bool enableHtml
            , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, string ipAddress, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs
            , ThreadAttachType attachType, string words, out BasicThread thread, out PostV5 post, out int totalThreads, out int totalPosts, out List<int> attachmentIDs, out Dictionary<string, int> fileIDs)
        {

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = CommandType.StoredProcedure;
                query.CommandText = "bx_v5_CreatePoll";

                SetCreateThreadParams(query, forumID, threadCatalogID, threadStatus, iconID, subject, subjectStyle, postUserID, postNickName, isLocked
                    , isValued, content, enableHtml, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress, attachments, historyAttachmentIDs, null, attachType, words);

                query.CreateParameter("@PollItems", pollItems, SqlDbType.NText);
                query.CreateParameter("@Multiple", pollMultiple, SqlDbType.Int);
                query.CreateParameter("@AlwaysEyeable", pollIsAlwaysEyeable, SqlDbType.Bit);
                query.CreateParameter("@ExpiresDate", pollExpiresDate, SqlDbType.DateTime);

                PollItemCollectionV5 pollitems = null;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    GetThread(reader, attachments, pollExpiresDate, out thread, out post, out attachmentIDs, out fileIDs);

                    if (reader.NextResult())
                    {
                        pollitems = new PollItemCollectionV5(reader);
                    }
                }

                int returnValue = (int)query.Parameters["@ErrorCode"].Value;

                if (returnValue != -1)
                {
                    totalThreads = (query.Parameters["@UserTotalThreads"].Value == DBNull.Value ? 0 : Convert.ToInt32(query.Parameters["@UserTotalThreads"].Value));
                    totalPosts = (query.Parameters["@UserTotalPosts"].Value == DBNull.Value ? 0 : Convert.ToInt32(query.Parameters["@UserTotalPosts"].Value));
                }
                else
                {
                    totalThreads = 0;
                    totalPosts = 0;
                    return false;
                }


                string extendData = PollThreadV5.GetExtendData(pollIsAlwaysEyeable, pollExpiresDate, pollMultiple, pollitems, new List<int>());

                thread.SetExtendData(extendData);

                UpdateThreadExtendData(extendData, thread.ThreadID, query);

                return true;


            }

        }
        private void ProcessDownload3(HttpContext context, BasicThread thread, PostV5 post,int diskFileID)
        {
            Forum forum = ForumBO.Instance.GetForum(post.ForumID);
            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (false == permission.Can(userID,ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID)
            {
                ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif");
                return;
            }

            if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子
            {
                AuthUser user = User.Current;
                bool isBuy = false;
                if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取
                {
                }
                if (!isBuy)
                {
                    if (thread.Price > 0)
                    {
                        if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent)
                        {
                            if (false == post.IsFreeDiskFileID(diskFileID) && false == post.IsFreeAttachmentID(attachment.AttachmentID))
                            {
                                if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user))
                                {
                                    Context.ThrowError<CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!"));
                                    return;
                                    //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0);
                                }
                            }
                        }
                    }
                }

            }

            if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID))
            {
                if (false == OutputFileByID(context, attachment.FileID, attachment.FileName, attachment.FileType, outputMode))
                {
                    ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif");
                }

            }
            else
            {
                ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif");
            }
        }
Beispiel #49
0
        public override bool CreatePolemize(string agreeViewPoint, string againstViewPoint, DateTime polemizeExpiresDate
           , int forumID, int threadCatalogID, ThreadStatus threadStatus, int iconID
           , string subject, string subjectStyle, int postUserID, string postNickName, bool isLocked, bool isValued, string content, bool enableHtml
           , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, string ipAddress, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs
           ,ThreadAttachType attachType, string words, out BasicThread thread, out PostV5 post, out int totalThreads, out int totalPosts, out List<int> attachmentIDs, out Dictionary<string, int> fileIDs)
        {

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = CommandType.StoredProcedure;
                query.CommandText = "bx_v5_CreatePolemize";

                string extendData = PolemizeThreadV5.GetExtendData(againstViewPoint, againstViewPoint, 0, 0, 0, polemizeExpiresDate, null);

                SetCreateThreadParams(query, forumID, threadCatalogID, threadStatus, iconID, subject, subjectStyle, postUserID, postNickName, isLocked
                    , isValued, content, enableHtml, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress, attachments, historyAttachmentIDs, extendData, attachType, words);

                query.CreateParameter<string>("@AgreeViewPoint", agreeViewPoint, SqlDbType.NText);
                query.CreateParameter<string>("@AgainstViewPoint", againstViewPoint, SqlDbType.NText);
                query.CreateParameter<DateTime>("@ExpiresDate", polemizeExpiresDate, SqlDbType.DateTime);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    GetThread(reader, attachments, polemizeExpiresDate, out thread, out post, out attachmentIDs, out fileIDs);
                }

                int returnValue = (int)query.Parameters["@ErrorCode"].Value;

                if (returnValue != -1)
                {
                    totalThreads = (query.Parameters["@UserTotalThreads"].Value == DBNull.Value ? 0 : Convert.ToInt32(query.Parameters["@UserTotalThreads"].Value));
                    totalPosts = (query.Parameters["@UserTotalPosts"].Value == DBNull.Value ? 0 : Convert.ToInt32(query.Parameters["@UserTotalPosts"].Value));
                }
                else
                {
                    totalThreads = 0;
                    totalPosts = 0;
                    return false;
                }

                return true;


            }

        }
Beispiel #50
0
 protected bool CanDeleteReply(PostV5 post)
 {
     if (post == null)
         return true;
     return AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(post.ForumID).Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeletePosts, post.UserID);
 }
Beispiel #51
0
        public override bool UpdateThread(int threadID, int postID, bool isApproved, int threadCatalogID, int iconID
            , string subject, int price, int lastEditorID, string lastEditorName, string content, bool enableHtml
            , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs
            , ThreadAttachType attachType, string words, out BasicThread thread, out PostV5 post, out List<int> attachmentIDs, out Dictionary<string, int> fileIDs)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = CommandType.StoredProcedure;
                query.CommandText = "bx_v5_UpdateThread";

                SetUpdatePostParams(query, postID, iconID, subject, lastEditorID, lastEditorName
                    , content, enableHtml, enableMaxCode3, enableSignature, enableReplyNotice, isApproved, attachments, historyAttachmentIDs);

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadCatalogID", threadCatalogID, SqlDbType.Int);
                query.CreateParameter<int>("@Price", price, SqlDbType.Int);
                query.CreateParameter<int>("@AttachmentType", (int)attachType, SqlDbType.TinyInt);
                query.CreateParameter<string>("@Words", words, SqlDbType.NVarChar, 400);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    GetThread(reader, attachments, null, out thread, out post, out attachmentIDs, out fileIDs);
                }
            }

            return true;
        }
Beispiel #52
0
 protected string GetSearchThreadUrl(PostV5 post)
 {
     return BbsUrlHelper.GetSearchThreadUrl(post.Forum.CodeName, post.ThreadID, post.PostID, mode, searchText);
 }
Beispiel #53
0
        public override bool CreatePost(int threadID, bool getPost, bool isApproved, PostType postType, int iconID, string subject, string content
            , bool enableHtml, bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, int forumID, int postUserID, string userName
            , string ipAddress, int parentID, bool updateSortOrder, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs
            , BasicThread thread
            , out PostV5 post, out int totalPosts, out List<int> AttachmentIDs, out Dictionary<string, int> fileIDs, out bool threadEnableReplyNotice)
        {
            AttachmentIDs = new List<int>();
            fileIDs = new Dictionary<string, int>();
            threadEnableReplyNotice = true;

            post = null;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = CommandType.StoredProcedure;
                query.CommandText = "bx_v5_CreatePost";

                SetCreatePostParams(query, forumID, iconID, subject, postUserID, userName, content, enableHtml, enableMaxCode3
                    , enableSignature, enableReplyNotice, ipAddress, attachments, historyAttachmentIDs);

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<int>("@PostType", (int)postType, SqlDbType.TinyInt);

                query.CreateParameter<bool>("@IsApproved", isApproved, SqlDbType.Bit);
                query.CreateParameter<int>("@PostRandNumber", GetSortNumber("post"), SqlDbType.TinyInt);

                query.CreateParameter<int>("@ParentID", parentID, SqlDbType.Int);
                query.CreateParameter<bool>("@UpdateSortOrder", updateSortOrder, SqlDbType.Bit);
                query.CreateParameter("@GetExtendedInfo", true, SqlDbType.Bit);
                query.CreateParameter("@GetThreadEnableReplyNotice", true, SqlDbType.Bit);
                query.CreateParameter<int>("@PostID", SqlDbType.Int, ParameterDirection.Output);
                query.CreateParameter<bool>("@GetPost", getPost, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", false, SqlDbType.Bit);

                string extendData = null;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        threadEnableReplyNotice = reader.Get<bool>("EnableReplyNotice");
                    }

                    if (attachments.Count > 0)
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                AttachmentIDs.Add(reader.Get<int>(0));
                            }
                            if (reader.NextResult())
                            {
                                while (reader.Read())
                                {
                                    string fileID = reader.Get<string>("fileID");
                                    if (fileIDs.ContainsKey(fileID) == false)
                                        fileIDs.Add(fileID, reader.Get<int>("attachmentID"));
                                }
                            }
                        }
                    }

                    if (getPost)
                    {
                        PostCollectionV5 posts = GetPosts(reader, false);
                        if (posts.Count > 0)
                            post = posts[0];
                        else
                            post = null;
                    }

                    extendData = GetExtendData(thread, thread.ThreadType, reader, false);

                }

                if (getPost == false)
                {
                    post = new PostV5();
                    post.PostID = (int)query.Parameters["@PostID"].Value;
                }

                int returnValue = (int)query.Parameters["@ErrorCode"].Value;
                if (returnValue != -1)
                {
                    totalPosts = Convert.ToInt32(query.Parameters["@UserTotalPosts"].Value);
                    if (extendData != null)
                    {
                        UpdateThreadExtendData(extendData, threadID, query);
                    }
                }
                else
                {
                    totalPosts = 0;
                    return false;
                }

                return true;
            }
        }
Beispiel #54
0
        protected bool IsAlwaysViewContents(PostV5 post)
        {
            bool canView;
            if (isAlwaysViewContents.TryGetValue(post.ForumID, out canView))
            {
                canView = post.Forum.Permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents);
                isAlwaysViewContents.Add(post.ForumID, canView);
            }

            return canView;
        }
Beispiel #55
0
        public override bool UpdatePost(int postID, bool getExtendedInfo, bool isApproved, int iconID
           , string subject, int lastEditorID, string lastEditorName, string content, bool enableHtml
           , bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs
           , out PostV5 post, out List<int> attachmentIDs, out Dictionary<string, int> fileIDs)
        {
            post = null;
            attachmentIDs = new List<int>();
            fileIDs = new Dictionary<string, int>();
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = CommandType.StoredProcedure;
                query.CommandText = "bx_v5_UpdatePost";

                SetUpdatePostParams(query, postID, iconID, subject, lastEditorID, lastEditorName
                    , content, enableHtml, enableMaxCode3, enableSignature, enableReplyNotice, isApproved, attachments, historyAttachmentIDs);

                query.CreateParameter("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                //SetTopMarkCountParam(query);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    if (attachments.Count > 0)
                    {
                        while (reader.Read())
                        {
                            attachmentIDs.Add(reader.Get<int>(0));
                        }
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                string fileID = reader.Get<string>("fileID");
                                if (fileIDs.ContainsKey(fileID) == false)
                                    fileIDs.Add(fileID, reader.Get<int>("attachmentID"));
                            }
                        }
                    }

                    PostCollectionV5 posts = GetPosts(reader, attachments.Count == 0);

                    if (posts.Count > 0)
                        post = posts[0];
                    else
                        post = null;
                }
            }

            return true;
        }
Beispiel #56
0
        protected bool CanViewPost(PostV5 post)
        {
            bool can;

            if (viewPost.TryGetValue(post.ForumID, out can) == false)
            {
                if (post.Forum.Permission.Can(My, ForumPermissionSetNode.Action.ViewReply))
                {
                    can = true;
                }
                else
                    can = false;
                viewPost.Add(post.ForumID, can);
            }

            return can;
        }
Beispiel #57
0
        public override void GetAttachment(int diskFileID, int postID, out Attachment attachment, out PostV5 post, out BasicThread thread)
        {
            attachment = null;
            post = null;
            thread = null;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetAttachmentByDiskFileID";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter("@DiskFileID", diskFileID, SqlDbType.Int);
                query.CreateParameter("@PostID", postID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        attachment = new Attachment(reader);
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            post = new PostV5(reader);
                        }
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            thread = GetThread(reader, null);
                        }
                    }
                }
            }
        }
Beispiel #58
0
        protected bool CanViewValuedThread(PostV5 post)
        {
            if (post.PostType != PostType.ThreadContent)
                return true;

            bool can;

            if (canViewValueThreads.TryGetValue(post.ForumID, out can) == false)
            {
                BasicThread thread = searchThreads.GetValue(post.ThreadID);
                if (thread.IsValued == false)
                    can = true;
                else
                    can = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID).Can(My, ForumPermissionSetNode.Action.ViewValuedThread);

                canViewValueThreads.Add(post.ForumID, can);
            }

            return can;
        }
Beispiel #59
0
        public override Revertable2Collection<PostV5> GetPostsWithReverters(IEnumerable<int> postIDs)
        {
            if (ValidateUtil.HasItems(postIDs) == false)
                return null;

            Revertable2Collection<PostV5> posts = new Revertable2Collection<PostV5>();

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = @"
SELECT 
	A.*,
	SubjectReverter = ISNULL(R.SubjectReverter, ''),
	ContentReverter = ISNULL(R.ContentReverter, '')
FROM 
	bx_Posts A WITH(NOLOCK)
LEFT JOIN 
	bx_PostReverters R WITH(NOLOCK) ON R.PostID = A.PostID
WHERE 
	A.PostID IN (@PostIDs)";

                query.CreateInParameter<int>("@PostIDs", postIDs);

                using (XSqlDataReader reader = query.ExecuteReader())
                {

                    while (reader.Read())
                    {
                        string subjectReverter = reader.Get<string>("SubjectReverter");
                        string contentReverter = reader.Get<string>("ContentReverter");

                        PostV5 post = new PostV5(reader);

                        posts.Add(post, subjectReverter, contentReverter);
                    }
                }
            }

            return posts;
        }