public virtual void UpdateQ(long id) { ForumTopic topic = topicService.GetById(id, ctx.owner.obj); ForumBoard board = getTree().GetById(topic.ForumBoard.Id); topic = ForumValidator.ValidateTopicEdit(topic, ctx); if (topic.Replies == 0) { topic.Reward = ctx.PostInt("Reward"); topic.RewardAvailable = topic.Reward; } if (ctx.HasErrors) { run(EditQ, id); } else { if (ctx.PostIsCheck("saveContentPic") == 1) { topic.Content = wojilu.Net.PageLoader.ProcessPic(topic.Content, null); } topicService.Update(topic, (User)ctx.viewer.obj, ctx.owner.obj); echoRedirect(lang("opok"), alink.ToAppData(topic)); } }
public void UpdateCategory(int id) { ForumBoard board = boardService.GetById(id, ctx.owner.obj); if (board == null) { echoRedirect(alang("exCategoryNotFound")); return; } board = ForumValidator.ValidateBoard(board, ctx); // 确保只是作为分类 board.IsCategory = 1; if (errors.HasErrors) { run(EditCategory, board.Id); return; } Result result = boardService.Update(board); if (result.HasErrors) { errors.Join(result); run(EditCategory, board.Id); return; } String logmsg = string.Format(alang("editBoardCategory") + ":{0}(id:{1})", board.Name, id); logService.Add((User)ctx.viewer.obj, ctx.app.Id, logmsg, ctx.Ip); echoRedirect(lang("opok"), Index); }
public void SaveCategory() { ForumBoard fb = ForumValidator.ValidateBoard(ctx); if (errors.HasErrors) { run(AddCategory); return; } // 确保只是作为分类 fb.IsCategory = 1; Result result = boardService.Insert(fb); if (result.HasErrors) { errors.Join(result); run(AddCategory); return; } String str = ((ForumApp)ctx.app.obj).Security; boardService.UpdateSecurity(fb, str); logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("addBoardCategory") + ":" + fb.Name, ctx.Ip); echoToParentPart(lang("opok")); }
public void Update(int id) { ForumLink link = linkService.GetById(id, ctx.owner.obj); if (link == null) { echoRedirect(lang("exDataNotFound")); return; } link = ForumValidator.ValidateLink(link, ctx); if (errors.HasErrors) { run(Edit, id); return; } Result result = linkService.Update(link); if (result.HasErrors) { errors.Join(result); run(Edit, id); return; } logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("logEditLink") + ":" + link.Name, ctx.Ip); redirect(List); }
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 Create() { ForumCategory category = ForumValidator.ValidateCategory(ctx); if (errors.HasErrors) { run(Admin, category.BoardId); return; } ForumBoard board = boardService.GetById(category.BoardId, ctx.owner.obj); if (board == null) { run(Admin, category.BoardId); return; } category.AppId = board.AppId; Result result = categoryService.Insert(category); if (result.HasErrors) { errors.Join(result); run(Admin, category.BoardId); return; } logService.Add((User)ctx.viewer.obj, ctx.app.Id, string.Format(alang("logAddCategory"), category.Name, board.Name), ctx.Ip); redirect(Admin, board.Id); }
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 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); }
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 UpdateBoard(int id) { ForumBoard board = boardService.GetById(id, ctx.owner.obj); if (board == null) { echoRedirect(alang("exBoardNotFound")); return; } board = ForumValidator.ValidateBoard(board, ctx); if (errors.HasErrors) { run(EditBoard, id); return; } Result result = boardService.Update(board); if (result.HasErrors) { errors.Join(result); run(EditBoard, id); return; } // 上传图片处理 if (ctx.HasUploadFiles) { HttpFile uploadFile = ctx.GetFileSingle(); if (uploadFile.ContentLength > 1) { Result uploadResult = Uploader.SaveImg(uploadFile); if (uploadResult.IsValid) { boardService.UpdateLogo(board, uploadResult.Info.ToString()); } } } String logmsg = string.Format(alang("editBoard") + ":{0}(id:{1})", board.Name, id); logService.Add((User)ctx.viewer.obj, ctx.app.Id, logmsg, ctx.Ip); echoToParentPart(lang("opok"), to(Index)); }
public virtual void Update(long id) { ForumPost post = postService.GetById(id, ctx.owner.obj); ForumBoard board = boardService.GetById(post.ForumBoardId, ctx.owner.obj); post = ForumValidator.ValidatePostEdit(post, ctx); if (errors.HasErrors) { run(Edit, id); } else { postService.Update(post, (User)ctx.viewer.obj); String parentUrl = getTopicLastPage(post); echoToParent(lang("opok"), parentUrl); } }
public void SaveBoard() { ForumBoard fb = ForumValidator.ValidateBoard(ctx); if (errors.HasErrors) { run(AddSubBoard, fb.Id); return; } Result result = boardService.Insert(fb); if (result.HasErrors) { errors.Join(result); run(AddSubBoard, fb.Id); return; } String str = ((ForumApp)ctx.app.obj).Security; boardService.UpdateSecurity(fb, str); // 上传图片处理 if (ctx.HasUploadFiles) { HttpFile uploadFile = ctx.GetFileSingle(); if (uploadFile.ContentLength > 1) { Result uploadResult = Uploader.SaveImg(uploadFile); if (uploadResult.IsValid) { boardService.UpdateLogo(fb, uploadResult.Info.ToString()); } } } logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("addBoard") + ":" + fb.Name, ctx.Ip); echoToParentPart(lang("opok")); }
public void Create() { ForumLink link = ForumValidator.ValidateLink(ctx); if (errors.HasErrors) { run(New); return; } Result result = linkService.Insert(link); if (result.HasErrors) { errors.Join(result); run(New); return; } logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("logAddLink") + ":" + link.Name, ctx.Ip); redirect(List); }
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 Update(int id) { ForumTopic topic = topicService.GetById(id, ctx.owner.obj); ForumBoard board = getTree().GetById(topic.ForumBoard.Id); topic = ForumValidator.ValidateTopicEdit(topic, ctx); if (ctx.HasErrors) { run(Edit, id); } else { if (ctx.PostIsCheck("saveContentPic") == 1) { topic.Content = wojilu.Net.PageLoader.ProcessPic(topic.Content, null); } 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 Update(int id) { ForumCategory category = categoryService.GetById(id, ctx.owner.obj); if (category == null) { echoRedirect(lang("exDataNotFound")); return; } category = ForumValidator.ValidateCategory(category, ctx); Result result = categoryService.Update(category); if (result.HasErrors) { errors.Join(result); run(Edit, id); } else { logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("logEditCategory") + ":" + category.Name, ctx.Ip); redirect(Admin, category.BoardId); } }