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")); } }
private ForumPost setTopicView(int id) { ForumPost post = postService.GetPostByTopic(id); ForumTopic topic = topicService.GetById(post.TopicId, ctx.owner.obj); ForumBoard board = getTree().GetById(post.ForumBoardId); if (!PermissionUtil.Check(this, board)) { return(null); } List <ForumBoard> pathboards = getTree().GetPath(board.Id); set("location", ForumLocationUtil.GetReply(pathboards, topic, ctx)); set("post.ReplyTitle", "re:" + post.Title); set("post.ForumBoardId", post.ForumBoardId); set("post.TopicId", post.TopicId); set("post.ParentId", post.Id); set("post.ReplyActionUrl", to(Create)); return(post); }
//------------------------------------ 版主管理:帖子评分 ----------------------------------------- public void SaveCredit(int id) { ForumPost post = postService.GetById(id, ctx.owner.obj); if (post == null) { echoRedirect(alang("exPostNotFound")); return; } ForumBoard board = boardService.GetById(post.ForumBoardId, ctx.owner.obj); if (!PermissionUtil.Check(this, board)) { return; } int rateMaxValue = ((ForumApp)ctx.app.obj).MaxRateValue; int currencyValue = ctx.PostInt("CurrencyValue"); if (((currencyValue != 0) && (currencyValue >= -rateMaxValue)) && (currencyValue <= rateMaxValue)) { postService.SetPostCredit(post, ctx.PostInt("CurrencyId"), currencyValue, ctx.Post("Reason"), (User)ctx.viewer.obj); userIncomeService.AddIncome(post.Creator, ctx.PostInt("CurrencyId"), currencyValue); echoRedirect(lang("opok")); } else { errors.Add(alang("exCreditNotValid")); run(AddCredit, id); } }
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 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 SaveGlobalStickySort() { int topicId = ctx.PostInt("id"); String cmd = ctx.Post("cmd"); ForumApp app = ctx.app.obj as ForumApp; PermissionUtil.Check(this, app); if (cmd == "up") { forumService.StickyMoveUp(app, topicId); echoRedirect("ok"); } else if (cmd == "down") { forumService.StickyMoveDown(app, topicId); echoRedirect("ok"); } else { errors.Add(lang("exUnknowCmd")); echoError(); } }
public void Move(int id) { ForumApp app = ctx.app.obj as ForumApp; PermissionUtil.Check(this, app); set("ActionLink", to(new AdminSaveController().Move, id) + "?ids=" + ids); set("ActionName", getActionName()); set("dropForums", getTree().DropList("targetForum", 0)); }
public void GlobalSticky(int id) { ForumApp app = ctx.app.obj as ForumApp; if (PermissionUtil.Check(this, app) == false) { return; } adminPrivate(id); set("ActionLink", to(new AdminSaveController().GlobalSticky, id) + "?ids=" + ids); }
//--------------------------------------------------------------------------------- public void GlobalSortSticky() { ForumApp app = ctx.app.obj as ForumApp; PermissionUtil.Check(this, app); List <ForumTopic> globalStickyList = forumService.GetStickyTopics(app); bindList("list", "t", globalStickyList); set("reorderLink", to(new AdminSaveController().SaveGlobalStickySort)); String location = ForumLocationUtil.GetGlobalTopicSort(ctx); set("location", location); }
public override void CheckPermission() { int topicId = ctx.route.id; ForumTopic topic = topicService.GetById(topicId, ctx.owner.obj); Boolean isSelfEdit = topic.Creator.Id == ctx.viewer.Id; if (isSelfEdit) { return; } ForumBoard board = getTree().GetById(topic.ForumBoard.Id); if (PermissionUtil.Check(this, board) == false) { ctx.web.CompleteRequest(); } }
public void DeleteTopic(int id) { ForumTopic topic = topicService.GetById(id, ctx.owner.obj); if (topic == null) { echo(alang("exPostNotFound")); return; } ForumBoard board = boardService.GetById(topic.ForumBoard.Id, ctx.owner.obj); if (!PermissionUtil.Check(this, board)) { return; } topicService.DeleteToTrash(topic, (User)ctx.viewer.obj, ctx.Ip); echoRedirect(lang("opok"), alink.ToAppData(board)); }
public void DeletePost(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.Check(this, board)) { return; } postService.DeleteToTrash(post, (User)ctx.viewer.obj, ctx.Ip); echoRedirect(lang("opok")); }
public void UnBan(int id) { ForumPost post = postService.GetById(id, ctx.owner.obj); if (post == null) { actionContent(alang("exPostNotFound")); return; } ForumBoard board = boardService.GetById(post.ForumBoardId, ctx.owner.obj); if (!PermissionUtil.Check(this, board)) { return; } postService.UnBanPost(post, (User)ctx.viewer.obj, ctx.app.Id, ctx.Ip); new ForumCacheRemove(this.boardService, topicService, this).BanPost(post); echoRedirect(lang("opok")); }
//------------------------------------ 版主管理:帖子评分 ----------------------------------------- public void AddCredit(int id) { if (rateService.IsUserRate((User)ctx.viewer.obj, id)) { echoText(alang("exRewarded")); return; } ForumPost post = postService.GetById(id, ctx.owner.obj); if (post == null) { echoRedirect(alang("exPostNotFound")); return; } if (post.Creator.Id == ctx.viewer.Id) { echoText(alang("exNotAllowSelfCredit")); return; } ForumBoard board = boardService.GetById(post.ForumBoardId, ctx.owner.obj); if (!PermissionUtil.Check(this, board)) { return; } target(SaveCredit, id); IList currencyList = currencyService.GetForumRateCurrency(); dropList("CurrencyId", currencyList, "Name=Id", 0); List <PropertyItem> values = getCurrencyValues(); dropList("CurrencyValue", values, "Value=Value", 2); }
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); } } }
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)); }