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

📄 msgmgr.java~73~

📁 云网论坛CWBBS 源码,内容丰富,学习,参考,教学的好资料,具体见内说明,
💻 JAVA~73~
📖 第 1 页 / 共 4 页
字号:
        boolean re = false;
        try {
            re = msgDb.ChangeColor(id, color, edate);
        }
        catch (ResKeyException e) {
            throw new ErrMsgException(e.getMessage(request));
        }
        return re;
    }

    /**
     * 标题加粗
     * @param request HttpServletRequest
     * @return boolean
     * @throws ErrMsgException
     */
    public boolean ChangeBold(HttpServletRequest request) throws
            ErrMsgException {
        long id = ParamUtil.getLong(request, "id");
        if (!privilege.canManage(request, id)) {
            throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID));
        }

        String boldExpire = ParamUtil.get(request, "boldExpire");
        Date edate = null;
        try {
            edate = DateUtil.parse(boldExpire, "yyyy-MM-dd");
        }
        catch (Exception e) {
            logger.error("ChangeBold:" + e.getMessage());
        }
        if (edate==null)
            throw new ErrMsgException(LoadString(request, "err_expire_date"));

        String sBold = ParamUtil.get(request, "isBold");
        int intBold = 0;
        if (!sBold.equals("")) {
            if (StrUtil.isNumeric(sBold))
                intBold = Integer.parseInt(sBold);
        }
        MsgDb msgDb = new MsgDb();
        boolean re = false;
        try {
            re = msgDb.ChangeBold(id, intBold, edate);
        }
        catch (ResKeyException e) {
            throw new ErrMsgException(e.getMessage(request));
        }
        return re;
    }

    /**
     * 置为精华
     * @param request HttpServletRequest
     * @param id long
     * @param value int
     * @return boolean
     * @throws ErrMsgException
     */
    public boolean setElite(HttpServletRequest request, long id, int value) throws
            ErrMsgException {
        if (!privilege.canManage(request, id)) {
            throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID));
        }
        MsgDb msgDb = new MsgDb();
        msgDb = msgDb.getMsgDb(id);
        boolean re = false;
        try {
            re = msgDb.setElite(value);

            // 发送短消息提醒用户主题被置为精华
            if (value==1) {
                MessageDb shortmsg = new MessageDb();
                shortmsg.setTitle(SkinUtil.LoadString(request, "res.forum.MsgDb",
                                                      "shortmsg_set_elite_title"));
                String s = SkinUtil.LoadString(request, "res.forum.MsgDb",
                                               "shortmsg_set_elite_content");
                s = StrUtil.format(s, new Object[] {msgDb.getTitle(),
                                   privilege.getUser(request)});
                shortmsg.setContent(s);
                shortmsg.setSender(shortmsg.USER_SYSTEM);
                shortmsg.setReceiver(msgDb.getName());
                shortmsg.setIp(request.getRemoteAddr());
                shortmsg.setType(shortmsg.TYPE_SYSTEM);
                shortmsg.create();
            }
        }
        catch (ResKeyException e) {
            throw new ErrMsgException(e.getMessage(request));
        }
        return re;
    }

    /**
     * 编辑高级方式发布的贴子
     * @param application ServletContext
     * @param request HttpServletRequest
     * @return boolean
     * @throws ErrMsgException
     */
    public boolean editTopicWE(ServletContext application,
                               HttpServletRequest request) throws
            ErrMsgException {
        MultiFileUpload mfu = (MultiFileUpload)doUpload(application, request);

        String name, boardcode;
        boardcode = mfu.getFieldValue("boardcode");
        if (boardcode == null || boardcode.trim().equals(""))
            throw new ErrMsgException(LoadString(request, "err_need_board"));

        Privilege privilege = new Privilege();

        MsgDb md = new MsgDb();
        long editid = Long.parseLong(mfu.getFieldValue("editid"));
        md = md.getMsgDb(editid);
        if (md==null || !md.isLoaded())
            throw new ErrMsgException(SkinUtil.LoadString(request, "err_msg_lost"));

        if (!privilege.canEdit(request, md))
            return false;

        name = privilege.getUser(request);

        boolean re = md.editTopicWE(application, request, name, mfu);
        if (re)
            blog = md.isBlog();
        if (re) {
            // 编辑plugin2插件
            String plugin2Code = md.getPlugin2Code();
            if (!plugin2Code.equals("")) {
                Plugin2Mgr p2m = new Plugin2Mgr();
                Plugin2Unit p2u = p2m.getPlugin2Unit(plugin2Code);
                if (p2u != null) {
                    p2u.getMsgAction().editTopic(application, request, md,
                                                 mfu);
                }
            }
        }
        if (re) {
            // 插件对应编辑贴子的action
            String pluginCode = md.getRootMsgPluginCode();
            logger.info("edittopicwe:pluginCode=" + pluginCode);
            PluginMgr pm = new PluginMgr();
            Vector vplugin = pm.getAllPluginUnitOfBoard(boardcode);
            if (vplugin.size() > 0) {
                Iterator irplugin = vplugin.iterator();
                while (irplugin.hasNext()) {
                    PluginUnit pu = (PluginUnit) irplugin.next();
                    boolean isPlugin = false;
                    if (pu.getType().equals(pu.TYPE_BOARD))
                        isPlugin = true;
                    else if (pu.getType().equals(pu.TYPE_TOPIC) && pluginCode.equals(pu.getCode()))
                        isPlugin = true;
                    logger.info("edittopicwe: pu.getCode()=" + pu.getCode() + " pluginCode=" + pluginCode);
                    if (isPlugin) {
                        IPluginMsgAction ipa = pu.getMsgAction();
                        re = ipa.editTopic(application, request, md, mfu);
                    }
                }
            }
        }
        return re;
    }

    /**
     * 编辑普通及UBB方式发的贴子
     * @param application ServletContext
     * @param request HttpServletRequest
     * @return boolean
     * @throws ErrMsgException
     */
    public boolean editTopic(ServletContext application,
                             HttpServletRequest request) throws ErrMsgException {
        Privilege privilege = new Privilege();
        if (!privilege.isUserLogin(request))
            throw new ErrMsgException(SkinUtil.LoadString(request, "err_not_login")); // "请先登录!");

        FileUpload fu = doUpload(application, request);
        String boardcode = fu.getFieldValue("boardcode");
        if (boardcode == null || boardcode.trim().equals(""))
            throw new ErrMsgException(LoadString(request, "err_need_board"));

        MsgDb md = new MsgDb();
        long editid = Long.parseLong(fu.getFieldValue("editid"));
        md = getMsgDb(editid);

        if (!privilege.canEdit(request, md))
            return false;

        String name = privilege.getUser(request);

        boolean re = md.editTopic(application, request, name, fu);
        if (re)
            blog = md.isBlog();

        if (re) {
            String plugin2Code = md.getPlugin2Code();
            if (!plugin2Code.equals("")) {
                Plugin2Mgr p2m = new Plugin2Mgr();
                Plugin2Unit p2u = p2m.getPlugin2Unit(plugin2Code);
                if (p2u != null) {
                    p2u.getMsgAction().editTopic(application, request, md,
                                                 fu);
                }
            }
        }

        if (re) {
            // 插件对应编辑贴子的action
            String pluginCode = md.getRootMsgPluginCode();

            PluginMgr pm = new PluginMgr();
            Vector vplugin = pm.getAllPluginUnitOfBoard(boardcode);
            if (vplugin.size() > 0) {
                Iterator irplugin = vplugin.iterator();
                while (irplugin.hasNext()) {
                    PluginUnit pu = (PluginUnit) irplugin.next();
                    boolean isPlugin = false;
                    if (pu.getType().equals(pu.TYPE_BOARD))
                        isPlugin = true;
                    else if (pu.getType().equals(pu.TYPE_TOPIC) && pluginCode.equals(pu.getCode()))
                        isPlugin = true;
                    if (isPlugin) {
                        IPluginMsgAction ipa = pu.getMsgAction();
                        // logger.info("plugin name:" + pu.getName(request));
                        re = ipa.editTopic(application, request, md, fu);
                    }
                }
            }
        }
        return re;
    }

    /**
     * 投票
     * @param request HttpServletRequest
     * @return boolean
     * @throws ErrMsgException
     */
    public boolean vote(HttpServletRequest request) throws ErrMsgException {
        long voteid = ParamUtil.getLong(request, "voteid");
        String votesel = request.getParameter("votesel");

        Privilege privilege = new Privilege();
        if (!privilege.isUserLogin(request))
            throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.ERR_NOT_LOGIN));

        String name = privilege.getUser(request);

        MsgDb msgDb = getMsgDb(voteid);

        if (msgDb.getIsLocked()==1)
            throw new ErrMsgException(msgDb.LoadString(request, "err_locked")); // "该贴已被锁定!");

        if (!privilege.canUserDo(name, msgDb.getboardcode(), "vote"))
            throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID));

        boolean re = false;
        try {
            re = msgDb.vote(voteid, Integer.parseInt(votesel), name);
        }
        catch (ResKeyException e) {
            throw new ErrMsgException(e.getMessage(request));
        }
        return re;
    }

    public Vector getBoardManagers(String boardcode) {
        MsgDb msgDb = new MsgDb();
        return msgDb.getBoardManagers(boardcode);
    }

    public String getprivurl() {
        String privurl = "";
        if (privurl!=null)
            privurl = fileUpload.getFieldValue("privurl");
        return privurl;
    }

    public String getCurBoardCode() {
        String boardcode = StrUtil.getNullString(fileUpload.getFieldValue("boardcode"));
        return boardcode;
    }

    public void setId(long id) {
        this.id = id;
    }

    public void setBlog(boolean blog) {
        this.blog = blog;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getId() {
        return id;
    }

    public boolean isBlog() {
        return blog;
    }

    public String getName() {
        return name;
    }

    private long id = -1;
    private boolean blog;
    private String name;

}

⌨️ 快捷键说明

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