コード例 #1
0
        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"));
            }
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        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));
        }