public void Update(int id) { ForumPost post = postService.GetById(id, ctx.owner.obj); if (post == null) { echo(alang("exPostNotFound")); return; } ForumBoard board = boardService.GetById(post.ForumBoardId, ctx.owner.obj); if (PermissionUtil.IsSelfEdit(ctx, post) == false) { if (!PermissionUtil.Check(this, board)) { return; } } post = ForumValidator.ValidatePostEdit(post, ctx); if (errors.HasErrors) { run(Edit, id); } else { postService.Update(post, (User)ctx.viewer.obj); new ForumCacheRemove(boardService, topicService, this).UpdatePost(post); echoToParent(lang("opok")); } }
public void Update(int id) { ForumTopic topic = topicService.GetById(id, ctx.owner.obj); if (topic == null) { echoRedirect(alang("exTopicNotFound")); return; } ForumBoard board = boardService.GetById(topic.ForumBoard.Id, ctx.owner.obj); if (PermissionUtil.IsSelfEdit(ctx, topic) == false) { if (!PermissionUtil.Check(this, board)) { return; } } topic = ForumValidator.ValidateTopicEdit(topic, ctx); if (ctx.HasErrors) { run(Edit, id); } else { topicService.Update(topic, (User)ctx.viewer.obj, ctx.owner.obj); new ForumCacheRemove(boardService, topicService, this).UpdateTopic(topic); echoRedirect(lang("opok"), alink.ToAppData(topic)); } }
public void Edit(int id) { ForumPost post = postService.GetById(id, ctx.owner.obj); if (post == null) { echo(alang("exPostNotFound")); return; } ForumBoard board = getTree().GetById(post.ForumBoardId); if (PermissionUtil.IsSelfEdit(ctx, post) == false) { if (!PermissionUtil.Check(this, board)) { return; } } target(Update, post.Id); List <ForumBoard> pathboards = getTree().GetPath(board.Id); set("location", ForumLocationUtil.GetPostEdit(pathboards, post, ctx)); set("post.Title", post.Title); editor("Content", post.Content, "280px"); }
public void Edit(int id) { ForumTopic topic = topicService.GetById(id, ctx.owner.obj); if (topic == null) { echoRedirect(alang("exTopicNotFound")); return; } ForumBoard board = getTree().GetById(topic.ForumBoard.Id); if (PermissionUtil.IsSelfEdit(ctx, topic) == false) { if (!PermissionUtil.Check(this, board)) { return; } } ForumPost post = postService.GetPostByTopic(topic.Id); target(Update, id); List <ForumBoard> pathboards = getTree().GetPath(board.Id); set("location", ForumLocationUtil.GetTopicEdit(pathboards, topic, ctx)); setCategory(topic, board); set("post.Title", post.Title); set("post.TagList", topic.Tag.TextString); editor("Content", post.Content, "300px"); set("attachmentLink", to(new AttachmentController().Admin, id)); }