Package com.liusoft.dlog4j.formbean

Examples of com.liusoft.dlog4j.formbean.BBSReplyForm


   * @throws Exception
   */
  protected ActionForward doPublishReply(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSReplyForm rform = (BBSReplyForm) form;
    super.validateClientId(request, rform);
    ActionMessages msgs = new ActionMessages();
    while (true) {
      if (StringUtils.isEmpty(rform.getTitle())) {
        msgs.add("title", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if (StringUtils.isEmpty(rform.getContent())) {
        msgs.add("content", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if (loginUser == null) {
        msgs.add("reply", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("reply", new ActionMessage("error.user_not_available"));
        break;
      }
      SiteBean site = getSiteByID(rform.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      //��������
      if(isUserInBlackList(site, loginUser)){
        msgs.add("reply", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      TopicOutlineBean topic = BBSTopicDAO.getTopicOutlineByID(rform.getTid());
      if (topic == null
          || topic.getStatus() != TopicBean.STATUS_NORMAL
          || topic.getSite().getId() != site.getId()
          || !topic.getForum().canCreateOrUpdateTopic(loginUser)) {
        msgs.add("log", new ActionMessage("error.topic_not_available",
            new Integer(rform.getTid())));
        break;
      }
      // ����TopicBean
      TopicReplyBean reply = new TopicReplyBean();
      reply.setClient(new ClientInfo(request, rform.getClientType()));
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          rform.getContent()), MAX_REPLY_LENGTH);
      reply.setContent(super.filterScriptAndStyle(content));
      reply.setReplyTime(new Date());
      reply.setSite(site);
      reply.setTitle(super.autoFiltrate(site, rform.getTitle()));
      reply.setTopic(topic);
      reply.setUser(loginUser);
      BBSReplyDAO.create(reply);
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("new_reply");
    }
    StringBuffer ext = new StringBuffer();
    ext.append("fid=");
    ext.append(rform.getFid());
    ext.append("&tid=");
    ext.append(rform.getTid());
    return makeForward(mapping.findForward("topic"), rform.getSid(), ext
        .toString());
  }
View Full Code Here


   * @throws Exception
   */
  protected ActionForward doEditReply(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSReplyForm rform = (BBSReplyForm) form;
    super.validateClientId(request, rform);
    ActionMessages msgs = new ActionMessages();
    while (true) {
      if (StringUtils.isEmpty(rform.getTitle())) {
        msgs.add("title", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if (StringUtils.isEmpty(rform.getContent())) {
        msgs.add("content",
            new ActionMessage("error.empty_not_allowed"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if (loginUser == null) {
        msgs.add("reply", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("reply", new ActionMessage("error.user_not_available"));
        break;
      }
      SiteBean site = super.getSiteByID(rform.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      TopicReplyBean rbean = BBSReplyDAO.getTopicReplyByID(rform.getId());
      if (rbean != null
          && rbean.getStatus() == TopicReplyBean.STATUS_NORMAL) {
        String title = super.autoFiltrate(site, rform.getTitle());
        if (!StringUtils.equals(title, rbean.getTitle()))
          rbean.setTitle(title);
        String content = StringUtils.abbreviate(super.autoFiltrate(
            null, rform.getContent()), MAX_REPLY_LENGTH);
        if (!StringUtils.equals(content, rbean.getContent()))
          rbean.setContent(super.filterScriptAndStyle(content));
        BBSReplyDAO.flush();
      }
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("new_reply");
    }
    StringBuffer ext = new StringBuffer();
    ext.append("fid=");
    ext.append(rform.getFid());
    ext.append("&tid=");
    ext.append(rform.getTid());
    if (rform.getPage() > 1) {
      ext.append("&page=");
      ext.append(rform.getPage());
    }
    return makeForward(mapping.findForward("topic"), rform.getSid(), ext
        .toString());
  }
View Full Code Here

   * @throws Exception
   */
  protected ActionForward doDeleteReply(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSReplyForm rform = (BBSReplyForm) form;

    while (true) {
      UserBean loginUser = super.getLoginUser(request, response);
      if (loginUser == null)
        break;
      TopicReplyBean trb = BBSReplyDAO.getTopicReplyByID(rform.getId());
      if (trb == null)
        break;
      if (trb.getUser().getId() != loginUser.getId()
          && loginUser.getOwnSiteId() != rform.getSid())
        break;
      BBSReplyDAO.delete(trb);
      break;
    }
    StringBuffer ext = new StringBuffer();
    ext.append("fid=");
    ext.append(rform.getFid());
    ext.append("&tid=");
    ext.append(rform.getTid());
    ext.append("&page=");
    ext.append(rform.getPage());
    return makeForward(mapping.findForward("topic"), rform.getSid(), ext
        .toString());
  }
View Full Code Here

TOP

Related Classes of com.liusoft.dlog4j.formbean.BBSReplyForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.