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

📄 manageh.java

📁 天乙社区6.0是一套基于JAVA技术的网络虚拟社区
💻 JAVA
字号:
package com.laoer.bbscs.web.action;

import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.sys.*;
import com.laoer.comm.util.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.util.*;

/**
 * <p>Title: TianYi BBS</p>
 * <p>Description: TianYi BBS System</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: LAOER.COM/TIANYISOFT.NET</p>
 * @author laoer
 * @version 6.0
 */

public class Manageh
    extends BaseAction {
  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {
    ActionErrors errors = new ActionErrors();
    ManageForm form = (ManageForm) actionForm;

    UserCheck uc = this.getUserCheck(httpServletRequest, httpServletResponse,
                                     form.getBid());
    if (uc.isGuest()) {
      errors.add("error.pleaselogin", new ActionError("error.pleaselogin"));
      saveErrors(httpServletRequest, errors);
      //return actionMapping.findForward("login");
      return SysUtil.getPassLogin(actionMapping);
    }

    if (uc.getBs() == null) {
      errors.add("error.baordsno", new ActionError("error.baordsno"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }

    if (!uc.isCanPostNotNeedExp()) {
      errors.add("error.purviewerror", new ActionError("error.purviewerror"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }

    if (form.getAction().equals("list")) {
      List bulist = this.getBlackUserService().findBlackUserList( (short) 0, 0,
          form.getBid());
      httpServletRequest.setAttribute("bulist", bulist);
      form.setYear(Util.getYear());
      form.setMonth(Util.getMonth());
      form.setDay(Util.getDay());
      httpServletRequest.setAttribute("manageForm", form);
      form.setBulletin(uc.getBs().getBulletin());
      form.setAction("bull");
      httpServletRequest.setAttribute("boardsForm", form);

      httpServletRequest.setAttribute("caninuser",
                                      Util.notNull(uc.getBs().getUserCanIn()));
      httpServletRequest.setAttribute("bid", String.valueOf(form.getBid()));
      return actionMapping.findForward("manageh");
    }

    if (form.getAction().equals("add")) {
      UserInfo buuser = this.getUserInfoService().findUserInfoByUserName(form.
          getBlackUserName());
      if (buuser == null) {
        errors.add("error.user.nouser", new ActionError("error.user.nouser"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }

      if (this.getBlackUserService().findBlackUserByUserName(form.
          getBlackUserName(), (short) 0, 0, form.getBid()) != null) {
        errors.add("error.blackuser.exist",
                   new ActionError("error.blackuser.exist"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }

      BlackUser bu = new BlackUser();
      bu.setAddName(uc.getUsername());
      bu.setAtBoard(0);
      bu.setAtBoards(form.getBid());
      bu.setAtSite( (short) 0);
      bu.setOutTime(Util.Date2Long(form.getYear(), form.getMonth(), form.getDay()));
      bu.setReason(form.getReason());
      bu.setUserID(buuser.getId().longValue());
      bu.setUserName(form.getBlackUserName());
      bu = this.getBlackUserService().saveBlackUser(bu);
      if (bu == null) {
        errors.add("error.blackuser.add", new ActionError("error.blackuser.add"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      ActionForward f = new ActionForward("/manageh" + Constant.FILEPREFIX +
                                          "?action=list&bid=" +
                                          form.getBid(), true);
      return f;
    }

    if (form.getAction().equals("del")) {
      BlackUser bu = this.getBlackUserService().findBlackUserByUserName(form.
          getBlackUserName(), (short) 0, 0, form.getBid());
      if (bu != null) {
        this.getBlackUserService().removeBlackUser(bu);
      }
      ActionForward f = new ActionForward("/manageh" + Constant.FILEPREFIX +
                                          "?action=list&bid=" +
                                          form.getBid(), true);
      return f;
    }

    if (form.getAction().equals("bull")) {
      if (! (uc.isSuperAdmin() || uc.isBmaster() || uc.isMainMaster())) {
        errors.add("error.purviewerror1", new ActionError("error.purviewerror1"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      Boards bs = uc.getBs();
      bs.setBulletin(form.getBulletin());
      bs = getBoardsService().saveBoards(bs);
      if (bs != null) {
        getBoardList().getBoardsHm().put(bs.getId(), bs);
      }
      ActionForward f = new ActionForward("/manageh" + Constant.FILEPREFIX +
                                          "?action=list&bid=" +
                                          form.getBid(), true);
      return f;
    }

    if (form.getAction().equals("addcanin")) {
      if (! (uc.isSuperAdmin() || uc.isBmaster() || uc.isMainMaster())) {
        errors.add("error.purviewerror1", new ActionError("error.purviewerror1"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      UserInfo caninuser = this.getUserInfoService().findUserInfoByUserName(
          form.getCanInUserName());
      if (caninuser == null) {
        errors.add("error.user.nouser", new ActionError("error.user.nouser"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      Boards bs = uc.getBs();
      if ( ("," +
            Util.notNull(bs.getUserCanIn())).indexOf("," +
          form.getCanInUserName() + ",") !=
          -1) {
        errors.add("error.reg.name1", new ActionError("error.reg.name1"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      bs.setUserCanIn(bs.getUserCanIn() + form.getCanInUserName() + ",");
      bs = getBoardsService().saveBoards(bs);
      if (bs != null) {
        getBoardList().getBoardsHm().put(bs.getId(), bs);
      }
      ActionForward f = new ActionForward("/manageh" + Constant.FILEPREFIX +
                                          "?action=list&bid=" +
                                          form.getBid(), true);
      return f;
    }

    if (form.getAction().equals("delcanin")) {
      if (! (uc.isSuperAdmin() || uc.isBmaster() || uc.isMainMaster())) {
        errors.add("error.purviewerror1", new ActionError("error.purviewerror1"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      Boards bs = uc.getBs();
      String caninuser = Util.notNull(bs.getUserCanIn());
      if ( ("," + caninuser).indexOf("," + form.getCanInUserName() + ",") != -1) {
        caninuser = Util.replace(caninuser, form.getCanInUserName() + ",", "");
      }
      bs.setUserCanIn(caninuser);
      bs = getBoardsService().saveBoards(bs);
      if (bs != null) {
        getBoardList().getBoardsHm().put(bs.getId(), bs);
      }
      ActionForward f = new ActionForward("/manageh" + Constant.FILEPREFIX +
                                          "?action=list&bid=" +
                                          form.getBid(), true);
      return f;
    }

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

⌨️ 快捷键说明

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