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

📄 msgmgr.java

📁 cwbbs 云网论坛源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        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();        msgDb = msgDb.getMsgDb(id);        boolean re = false;        String manager = privilege.isUserLogin(request)?privilege.getUser(request):"";        try {            re = msgDb.ChangeBold(manager, intBold, edate, StrUtil.getIp(request));        }        catch (ResKeyException e) {            throw new ErrMsgException(e.getMessage(request));        }        return re;    }        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 (re) {                String userName = privilege.isUserLogin(request)?privilege.getUser(request):"";                MsgOperateDb mod = new MsgOperateDb();                mod.create(new JdbcTemplate(), new Object[] {                    new Long(SequenceMgr.nextID(SequenceMgr.TOPIC_OP)),                            new Long(id),                            new Integer(value == 1 ? MsgOperateDb.OP_TYPE_ELITE :                                        MsgOperateDb.OP_TYPE_ELITE_CANCEL), null,                            userName,                            new java.util.Date(), msgDb.getTitle(), name, msgDb.getAddDate(),                            msgDb.getboardcode(), request.getRemoteAddr()                });            }                        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");                String nick;                if (privilege.isUserLogin(request)) {                    UserDb ud = new UserDb();                    ud = ud.getUser(privilege.getUser(request));                    nick = ud.getNick();                }                else {                    nick = UserDb.ADMIN;                }                s = StrUtil.format(s, new Object[] {msgDb.getTitle(),                                   nick});                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;    }        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) {                        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) {                        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;    }        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 (md==null || !md.isLoaded())            throw new ErrMsgException(SkinUtil.LoadString(request, "err_msg_lost"));        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) {                        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();                                                re = ipa.editTopic(application, request, md, fu);                    }                }            }        }        return re;    }        public boolean vote(HttpServletRequest request) throws ErrMsgException {        long voteid = ParamUtil.getLong(request, "voteid");        Privilege privilege = new Privilege();        if (!privilege.isUserLogin(request))            throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.ERR_NOT_LOGIN));        String[] opts = ParamUtil.getParameters(request, "votesel");        if (opts==null)            throw new ErrMsgException(MsgDb.LoadString(request, "err_vote_none"));        String name = privilege.getUser(request);        MsgDb msgDb = getMsgDb(voteid);        if (msgDb.getIsLocked()==1)            throw new ErrMsgException(msgDb.LoadString(request, "err_locked"));         if (!privilege.canVote(request, msgDb.getboardcode()))            throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID));        MsgPollDb mpd = new MsgPollDb();        mpd = (MsgPollDb)mpd.getQObjectDb(new Long(msgDb.getId()));        Date d = mpd.getDate("expire_date");                if (d!=null) {            if (DateUtil.compare(d, new java.util.Date()) != 1)                throw new ErrMsgException(StrUtil.format(msgDb.LoadString(request,                        "err_vote_expire"),                                          new Object[] {ForumSkin.formatDate(request, d)}));        }        int len = opts.length;        int max_choice = mpd.getInt("max_choice");        if (len > max_choice) {            throw new ErrMsgException(StrUtil.format(msgDb.LoadString(request,                    "err_vote_max_count"),                                          new Object[] {"" + max_choice}));        }                MsgPollOptionDb mpod = new MsgPollOptionDb();        Vector v = mpd.getOptions(voteid);        int optLen = v.size();        for (int i=0; i<optLen; i++) {            MsgPollOptionDb mo = mpod.getMsgPollOptionDb(voteid, i);            String vote_user = StrUtil.getNullString(mo.getString("vote_user"));            String[] ary = StrUtil.split(vote_user, ",");                        if (ary!=null) {                int len2 = ary.length;                for (int k=0; k<len2; k++) {                    if (ary[k].equals(name))                        throw new ErrMsgException(SkinUtil.LoadString(request, "res.forum.MsgDb", "err_vote_repeat"));                }            }        }        boolean re = true;        for (int i=0; i<len; i++) {            MsgPollOptionDb mo = mpod.getMsgPollOptionDb(voteid, StrUtil.toInt(opts[i]));            mo.set("vote_count", new Integer(mo.getInt("vote_count") + 1));            String vote_user = StrUtil.getNullString(mo.getString("vote_user")).trim();             if (vote_user.equals(""))                vote_user = name;            else                vote_user += "," + name;            mo.set("vote_user", vote_user);            try {                re = mo.save();            }            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;    }    public FileUpload getFileUpload() {        return fileUpload;    }    private long id = -1;    private boolean blog;    private String name;}

⌨️ 快捷键说明

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