postopt.java

来自「一个jsp写的bbs」· Java 代码 · 共 797 行 · 第 1/3 页

JAVA
797
字号
          f.setIsTop(0);
          try {
            this.getForumService().saveForum(f);
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.top.untop.ok"));
          }
          catch (BbscsException ex3) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_TOP_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.top.unerror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_TOP_ISUNTOP,
                                               mr.getMessage(locale, "error.post.top.untop"));
        }
      }
      this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
      return mapping.findForward(this.FORWARD_AJAX);
    }

    if (optForm.getAction().equalsIgnoreCase("cannotdel") || optForm.getAction().equalsIgnoreCase("candel")) {
      Forum f = this.getForumService().findForumByID(optForm.getId(), bid);
      if (f == null) {
        this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
                                             mr.getMessage(locale, "error.post.getpost"));
        this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
        return mapping.findForward(this.FORWARD_AJAX);
      }
      if (optForm.getAction().equalsIgnoreCase("cannotdel")) {
        if (f.getCanNotDel() == 0) {
          f.setCanNotDel(1);
          try {
            this.getForumService().saveForum(f);
            //UserInfo ui = this.getUserService().findUserInfoById(f.getUserID());
            //if (ui != null) {
            //  ui.setLiterary(ui.getLiterary() + 1);//增加用户文采值
            //  this.getUserService().saveUserInfo(ui);
            //}

            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.cannotdel.setok"));
          }
          catch (BbscsException ex4) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_CANNOTDEL_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.cannotdel.seterror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_CANNOTDEL_EXIST,
                                               mr.getMessage(locale, "error.post.notdel.exist"));
        }
      }
      if (optForm.getAction().equalsIgnoreCase("candel")) {
        if (f.getCanNotDel() != 0) {
          f.setCanNotDel(0);
          try {
            this.getForumService().saveForum(f);
            //UserInfo ui = this.getUserService().findUserInfoById(f.getUserID());
            //if (ui != null) {
            //  ui.setLiterary(ui.getLiterary() - 1);//减少用户文采值
            //  this.getUserService().saveUserInfo(ui);
            //}

            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.uncannotdel.setok"));
          }
          catch (BbscsException ex5) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_CANNOTDEL_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.cannotdel.unerror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_CANNOTDEL_ISUN,
                                               mr.getMessage(locale, "error.post.iscandel"));
        }
      }
      this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
      return mapping.findForward(this.FORWARD_AJAX);
    }

    if (optForm.getAction().equalsIgnoreCase("commend") || optForm.getAction().equalsIgnoreCase("uncommend")) {
      Forum f = this.getForumService().findForumByID(optForm.getId(), bid);
      if (f == null) {
        this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
                                             mr.getMessage(locale, "error.post.getpost"));
        this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
        return mapping.findForward(this.FORWARD_AJAX);
      }
      if (optForm.getAction().equalsIgnoreCase("commend")) {
        if (f.getCommend() == 0) {
          //long topBid = board.getId().longValue();
          //if (board.getParentIDs() != null && board.getParentIDs().size() > 0) {
          //  topBid = ( (Long) board.getParentIDs().get(0)).longValue();
          //}
          //f.setCommend(board.getTopBid());
          try {
            this.getForumService().saveForumCommend(0, board, f);
            //this.getForumService().saveForumChangeUser(f, 1, 1);
            //this.getForumService().createCommendPage(board.getTopBid());
            //UserInfo ui = this.getUserService().findUserInfoById(f.getUserID());
            //if (ui != null) {
            //  ui.setLiterary(ui.getLiterary() + 1);//增加用户文采值
            //  this.getUserService().saveUserInfo(ui);
            //}

            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.commend.setok"));
          }
          catch (BbscsException ex3) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_COMMEND_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.commend.seterror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_COMMEND_EXIST,
                                               mr.getMessage(locale, "error.post.commend.exist"));
        }
      }
      if (optForm.getAction().equalsIgnoreCase("uncommend")) {
        if (f.getCommend() != 0) {
          //f.setCommend(0);
          try {
            this.getForumService().saveForumCommend(1, board, f);
            //UserInfo ui = this.getUserService().findUserInfoById(f.getUserID());
            //if (ui != null) {
            //  ui.setLiterary(ui.getLiterary() - 1); //减少用户文采值
            //  this.getUserService().saveUserInfo(ui);
            //}

            //this.getForumService().saveForumChangeUser(f, 1, -1);
            //long topBid = board.getId().longValue();
            //if (board.getParentIDs() != null && board.getParentIDs().size() > 0) {
            //  topBid = ( (Long) board.getParentIDs().get(0)).longValue();
            //}

            //this.getForumService().createCommendPage(board.getTopBid());
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.uncommend.setok"));
          }
          catch (BbscsException ex3) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_COMMEND_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.commend.unerror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_COMMEND_ISUN,
                                               mr.getMessage(locale, "error.post.uncommend.exist"));
        }
      }
      this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
      return mapping.findForward(this.FORWARD_AJAX);
    }

    if (optForm.getAction().equalsIgnoreCase("lock") || optForm.getAction().equalsIgnoreCase("unlock")) {
      Forum f = this.getForumService().findForumByID(optForm.getId(), bid);
      if (f == null) {
        this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
                                             mr.getMessage(locale, "error.post.getpost"));
        this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
        return mapping.findForward(this.FORWARD_AJAX);
      }
      if (optForm.getAction().equalsIgnoreCase("lock")) {
        if (f.getIsLock() == 0) {
          f.setIsLock(1);
          try {
            this.getForumService().saveForum(f);
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.lock.setok"));
          }
          catch (BbscsException ex3) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_LOCK_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.lock.seterror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_LOCK_EXIST,
                                               mr.getMessage(locale, "error.post.lock.exist"));
        }
      }
      if (optForm.getAction().equalsIgnoreCase("unlock")) {
        if (f.getIsLock() != 0) {
          f.setIsLock(0);
          try {
            this.getForumService().saveForum(f);
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                                 mr.getMessage(locale, "post.unlock.setok"));
          }
          catch (BbscsException ex3) {
            this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_LOCK_SET_ERROR,
                                                 mr.getMessage(locale, "error.post.lock.unerror"));
          }
        }
        else {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_LOCK_ISUN,
                                               mr.getMessage(locale, "error.post.unlock.exist"));
        }
      }
      this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
      return mapping.findForward(this.FORWARD_AJAX);
    }

    if (optForm.getAction().equalsIgnoreCase("elite")) {
      Forum f = this.getForumService().findForumByID(optForm.getId(), bid);
      if (f == null) {
        this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
                                             mr.getMessage(locale, "error.post.getpost"));
        this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
        return mapping.findForward(this.FORWARD_AJAX);
      }
      if (f.getElite() == 0) {
        f.setElite(bid);
        f.setDoEliteName(us.getUserName());
        f.setDoEliteTime(System.currentTimeMillis());
        UserInfo ui = this.getUserService().findUserInfoById(f.getUserID());
        if (ui == null) {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_USER_NOEXIST,
                                               mr.getMessage(locale, "error.getuser"));
          this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
          return mapping.findForward(this.FORWARD_AJAX);
        }
        try {
          this.getForumService().savePostElite(f, ui);
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
                                               mr.getMessage(locale, "post.elite.setok"));
        }
        catch (BbscsException ex6) {
          this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_ELITE_SET_ERROR,
                                               mr.getMessage(locale, "post.elite.seterror"));
        }
      }
      else {
        this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_ELITE_EXIST,
                                             mr.getMessage(locale, "post.elite.isexist"));
      }
      this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
      return mapping.findForward(this.FORWARD_AJAX);
    }

    if (optForm.getAction().equalsIgnoreCase("mailsend")) {
      Forum f = this.getForumService().findForumByID(optForm.getId(), bid);
      if (f == null) {
        this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
                                             mr.getMessage(locale, "error.post.getpost"));
        this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
        return mapping.findForward(this.FORWARD_AJAX);
      }
      if (StringUtils.isNotBlank(us.getEmail()) && this.getSysConfig().getUseEmail() == 1) {
        try {
          if (this.getSysConfig().getSmtpAuth() == 1) {
            DefaultAuthenticator defaultAuthenticator = new DefaultAuthenticator(this.getSysConfig().
                getSmtpUser(), this.getSysConfig().getSmtpPasswd());
            this.getHtmlEmail().setAuthenticator(defaultAuthenticator);
          }
          this.getHtmlEmail().setHostName(this.getSysConfig().getSmtpServer());
          this.getHtmlEmail().setSmtpPort(this.getSysConfig().getSmtpPort());
          this.getHtmlEmail().setFrom(this.getSysConfig().getSenderEmail());
          this.getHtmlEmail().setSubject(f.getTitle());
          String detail = "";
          if (f.getEditType() == 0) {
            detail = BBSCSUtil.filterText(f.getDetail(), (board.getAllowHTML() == 1),
                                          (board.getAllowUBB() == 1), true);
            //this.getHtmlEmail().setHtmlMsg();
          }
          else {
            detail = f.getDetail();
            //this.getHtmlEmail().setHtmlMsg(f.getDetail());

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?