Пример #1
0
        public void Create()
        {
            if (ForumValidator.IsIntervalShort(ctx))
            {
                echoError("对不起,您发布太快,请稍等一会儿再发布");
                return;
            }

            int boardId = ctx.GetInt("boardId");

            ForumBoard board = boardService.GetById(boardId, ctx.owner.obj);

            if (board == null)
            {
                echo(alang("exBoardNotFound"));
                return;
            }
            if (!SecurityHelper.Check(this, board))
            {
                return;
            }

            ForumTopic topic = ForumValidator.ValidateTopic(ctx);

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            if (ctx.PostIsCheck("saveContentPic") == 1)
            {
                topic.Content = wojilu.Net.PageLoader.ProcessPic(topic.Content, null);
            }

            topic.ForumBoard = new ForumBoard(boardId);
            Result result = topicService.CreateTopic(topic, (User)ctx.viewer.obj, ctx.owner.obj, (IApp)ctx.app.obj);

            if (result.HasErrors)
            {
                errors.Join(result);
                echoError();
                return;
            }

            saveUploadedAttachments(topic);

            if (ctx.HasErrors)
            {
                echoText(errors.ErrorsHtml);
                return;
            }

            echoRedirect(lang("opok"), alink.ToAppData(topic));
            ForumValidator.AddCreateTime(ctx);
        }
Пример #2
0
        public void Create()
        {
            if (ForumValidator.IsIntervalShort(ctx))
            {
                echoError("对不起,您发布太快,请稍等一会儿再发布");
                return;
            }

            ForumPost post = ForumValidator.ValidatePost(ctx);

            if (!checkLock(post.TopicId))
            {
                return;
            }

            ForumBoard board = ctx.GetItem("forumBoard") as ForumBoard;

            if (board == null || board.Id != post.ForumBoardId)
            {
                return;
            }

            ctx.SetItem("boardId", board.Id);

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            Result result = postService.Insert(post, (User)ctx.viewer.obj, ctx.owner.obj, (IApp)ctx.app.obj);

            if (result.HasErrors)
            {
                echoError(result);
                return;
            }

            int lastPageNo = getLastPageNo(post);

            if (ctx.PostInt("__ajaxUpdate") > 0)
            {
                echoAjaxUpdate(post, board, lastPageNo);
            }
            else
            {
                String lnkTopicLastPage = getTopicLastPage(post, lastPageNo);
                echoRedirect(lang("opok"), lnkTopicLastPage);
            }

            ForumValidator.AddCreateTime(ctx);
        }