⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movepostaction.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
字号:
package com.laoer.bbscs.bbs.action;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.laoer.bbscs.bbs.actionform.*;
import com.laoer.bbscs.bbs.business.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import com.laoer.bbscs.servlet.*;
import com.laoer.bbscs.db.*;
import org.apache.struts.util.*;
import java.util.*;

public class MovePostAction
    extends Action {

  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {
    ActionErrors errors = new ActionErrors();
    MovePostActionForm form = (MovePostActionForm) actionForm;
    UserSessionCheck myUserSessionCheck = new UserSessionCheck(form.getSid(),
        httpServletRequest);
    if (!myUserSessionCheck.checkSession(form.getBid())) {
      errors.add("error.timeout", new ActionError("error.timeout"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }
    if (myUserSessionCheck.isGuest()) {
      errors.add("noguest", new ActionError("error.user.noguest"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }
    httpServletRequest.setAttribute("myUserSessionCheck", myUserSessionCheck);
    httpServletRequest.setAttribute("sid", form.getSid());
    httpServletRequest.setAttribute("bid", form.getBid());
    httpServletRequest.setAttribute("recid", form.getRecid());
    httpServletRequest.setAttribute("pages", form.getPages());
    httpServletRequest.setAttribute("mainid", form.getMainid());

    if (form.getAction().equals("show")) {
      Boards myBoards = BoardsFactory.getInstance();
      if (myBoards == null) {
        errors.add("errornull", new ActionError("error"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      myBoards.setUserInfo(myUserSessionCheck.getUser().getUserInfo());
      List blist;
      if (myUserSessionCheck.isSuperAdmin()) {
        blist = myBoards.getBoardsList(null, "BoardListDstSuper");
      }
      else {
        blist = myBoards.getBoardsList(null, "BoardListDst");
      }
      httpServletRequest.setAttribute("blist", blist);
      return actionMapping.findForward("movepost");
    }
    if (form.getAction().equals("move")) {
      UserInfo myUserInfo = myUserSessionCheck.getUser().getUserInfo();
      int mypower = 0; //气力值
      mypower = myUserInfo.getPower();
      if (mypower <= 0 &&
          ! (myUserSessionCheck.isSuperAdmin() ||
             myUserSessionCheck.isBMaster() ||
             myUserSessionCheck.isMainMaster() ||
             myUserSessionCheck.isAssiMaster() ||
             myUserSessionCheck.isHideMaster())) {
        errors.add("nopower", new ActionError("error.post.nopower"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      BoardsInfo aBoardsInfo = new BoardsInfo();
      aBoardsInfo.setID(Long.parseLong(form.getMoveto()));
      Boards aBoards = BoardsFactory.getInstance();
      aBoards.setBoardsInfo(aBoardsInfo);
      int result = aBoards.getBoards(null, "ID", true);
      if (result != Sys.RESULT_RIGHT) {
        errors.add("error.baordsno", new ActionError("error.baordsno"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      aBoardsInfo = aBoards.getBoardsInfo();
      ForumInfo afi = new ForumInfo();
      afi.setBoardID(Long.parseLong(form.getBid()));
      afi.setID(Long.parseLong(form.getRecid()));
      Forum af = ForumFactory.getInstance();
      af.setForumInfo(afi);
      if (af.getPost(null, "ID", true) != Sys.RESULT_RIGHT) {
        errors.add("getpost", new ActionError("error.post.getpost"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      afi = af.getForumInfo();
      MessageResources messages = getResources(httpServletRequest);
      Locale locale = getLocale(httpServletRequest);
      ForumInfo bfi = new ForumInfo();
      bfi.setBoardID(aBoardsInfo.getID());
      bfi.setBoardName(aBoardsInfo.getBoardsName());
      bfi.setTitle(messages.getMessage(locale, "zhuantie.zhuanzai") +
                   afi.getTitle());
      String detail = "";
      detail = messages.getMessage(locale, "zhuantie.zhuanzaizi",
                                   afi.getBoardName(), afi.getUserName(),
                                   afi.getTitle()) + "<br>" + afi.getDetailText();
      long postTime = Util.getaLongTime();
      long aID = TableID.nextID(4);
      String IP = httpServletRequest.getRemoteAddr();
      int artSize = 0;
      try {
        artSize = detail.getBytes(Sys.SYSINFO.CHARSET).length;
      }
      catch (Exception e) {
      }
      bfi.setID(aID);
      bfi.setID1(0);
      bfi.setID2(aID);
      bfi.setFace(afi.getFace());
      bfi.setDetail(detail);
      bfi.setSign(afi.getSign());
      bfi.setArtSize(artSize);
      bfi.setEmail_Inform(0);
      bfi.setMsg_Inform(0);
      bfi.setPostTime(postTime);
      bfi.setLastTime(postTime);
      bfi.setIPAddress(IP);
      bfi.setUserID(myUserInfo.getID());
      bfi.setUserName(myUserInfo.getUserName());
      bfi.setIsNew(1);
      bfi.setNickName(myUserInfo.getNickName());
      af.setUserInfo(myUserInfo);
      af.setForumInfo(bfi);
      af.setUserSessionCheck(myUserSessionCheck);

      result = af.createPost(null, "new");
      if (result != Sys.RESULT_RIGHT) {
        errors.add("error.posterror", new ActionError("error.posterror"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      aBoards = null;
      aBoardsInfo = null;
      bfi = null;
      afi = null;
      af = null;
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("",
          Sys.getURL() + "readAction.do?sid=" + form.getSid() +
          "&bid=" + form.getBid() + "&pages=" + form.getPages() + "&recid=" +
          form.getMainid()));
             return actionMapping.findForward("forwards");*/

      ActionForward f = new ActionForward("/readAction.do?sid=" + form.getSid() +
                                          "&bid=" + form.getBid() + "&pages=" +
                                          form.getPages() + "&recid=" +
                                          form.getMainid(), true);
      return f;

    }
    return actionMapping.findForward("error");
  }
}

⌨️ 快捷键说明

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