示例#1
0
 private boolean canDeleteComment(CmsComment comment, CmsUser user) {
   // 匿名用户评论文章的所有者可以删除
   if (comment.getCommentUser() == null && !comment.getContent().getUser().equals(user)) {
     return false;
   } else if (comment.getCommentUser() == null && comment.getContent().getUser().equals(user)) {
     return true;
   } else {
     // 非匿名用户评论 文章的所有者可以删除,评论者也可以删除
     if (comment.getCommentUser().equals(user) || comment.getContent().getUser().equals(user)) {
       return true;
     } else {
       return false;
     }
   }
 }
示例#2
0
 /** 查看评论回复 */
 @RequestMapping(value = "/member/comment_replay.jspx")
 public String guestbook_replay(
     Integer id,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   CmsComment comment = commentMng.findById(id);
   if (!comment.getCommentUser().equals(user)) {
     WebErrors errors = WebErrors.create(request);
     errors.addErrorCode("error.noPermissionsView");
     return FrontUtils.showError(request, response, model, errors);
   }
   model.addAttribute("comment", comment);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_COMMENT, COMMENT_REPLY);
 }