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); }
public void Create() { ForumPost post = ForumValidator.ValidatePost(ctx); if (!checkLock(post.TopicId)) { return; } ForumBoard board = boardService.GetById(post.ForumBoardId, ctx.owner.obj); if (!PermissionUtil.Check(this, board)) { return; } ctx.SetItem("boardId", board.Id); if (ctx.HasErrors) { run(ReplyTopic, post.TopicId); } else { Result result = postService.Insert(post, (User)ctx.viewer.obj, ctx.owner.obj, (IApp)ctx.app.obj); if (result.IsValid) { new ForumCacheRemove(boardService, topicService, this).CreatePost(post); String lnkTopicLastPage = getTopicLastPage(post); echoRedirect(lang("opok"), lnkTopicLastPage); } else { echoRedirect(result.ErrorsHtml); } } }