📄 msgmgr.java
字号:
PluginMgr pm = new PluginMgr(); Vector vplugin = pm.getAllPluginUnitOfBoard(msgDb.getboardcode()); 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.AddQuickReply(application, request, msgDb.getId()); } } } } if (re) { if (privilege.isUserLogin(request)) { ScoreMgr sm = new ScoreMgr(); Vector v = sm.getAllScore(); Iterator ir = v.iterator(); while (ir.hasNext()) { ScoreUnit su = (ScoreUnit) ir.next(); IPluginScore ips = su.getScore(); if (ips != null) ips.AddQuickReply(application, request, msgDb.getId()); } } } return re; } public boolean delTopic(ServletContext application, HttpServletRequest request, long delId) throws ErrMsgException { boolean isPluginValid = false; MsgDb msgDb = getMsgDb(delId); if (!msgDb.isLoaded()) throw new ErrMsgException(LoadString(request, "err_topic_del_lost")); blog = msgDb.isBlog(); PluginMgr pm = new PluginMgr(); Vector vplugin = pm.getAllPluginUnitOfBoard(msgDb.getboardcode()); if (vplugin.size() > 0) { Iterator irplugin = vplugin.iterator(); while (irplugin.hasNext()) { PluginUnit pu = (PluginUnit) irplugin.next(); IPluginPrivilege ipp = pu.getPrivilege(); if (!ipp.canManage(request, delId)) { String s = LoadString(request, "err_pvg_plugin"); s = s.replaceFirst("\\$p", pu.getName(request)); throw new ErrMsgException(s); } } isPluginValid = true; } if (!isPluginValid) { if (!privilege.canDel(request, delId)) { throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID)); } } Leaf lf = new Leaf(); lf = lf.getLeaf(msgDb.getboardcode()); boolean re = false; if (lf!=null && lf.getDelMode() == lf.DEL_DUSTBIN) { try { if (msgDb.getReplyid() != -1 && (msgDb.getCheckStatus() == MsgDb.CHECK_STATUS_PASS || msgDb.getCheckStatus() == MsgDb.CHECK_STATUS_DUSTBIN)) { MsgDb rootMsgDb = msgDb.getMsgDb(msgDb.getReplyid()); rootMsgDb.setRecount(rootMsgDb.getRecount()-1); rootMsgDb.save(); } re = msgDb.checkMsg(msgDb.CHECK_STATUS_DUSTBIN); if (re) { MsgDb md = getMsgDb(lf.getAddId()); if (md.getRootid() == msgDb.getId()) { long newid = msgDb.getNewAddIdOfBoard(); if (newid != -1) msgDb.setBoardNewAddId(newid); } } } catch (ResKeyException e) { throw new ErrMsgException(e.getMessage(request)); } } else { if (vplugin.size() > 0) { Iterator irplugin = vplugin.iterator(); while (irplugin.hasNext()) { PluginUnit pu = (PluginUnit) irplugin.next(); IPluginMsgAction ipa = pu.getMsgAction(); ipa.delTopic(application, request, msgDb); } } String plugin2Code = msgDb.getPlugin2Code(); if (!plugin2Code.equals("")) { Plugin2Mgr p2m = new Plugin2Mgr(); Plugin2Unit p2u = p2m.getPlugin2Unit(plugin2Code); if (p2u != null) { p2u.getMsgAction().delTopic(application, request, msgDb); } } try { re = msgDb.delTopic(application, delId); Indexer idx = new Indexer(); idx.delDocument(delId); } catch (ResKeyException e1) { throw new ErrMsgException(e1.getMessage(request)); } } if (re) { try { String manager = 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(msgDb.getId()), new Integer(MsgOperateDb.OP_TYPE_DEL), null, manager, new java.util.Date(),msgDb.getTitle(),msgDb.getName(),msgDb.getAddDate(),msgDb.getboardcode(), request.getRemoteAddr() }); } catch (ResKeyException e) { throw new ErrMsgException(e.getMessage(request)); } Config cfg = Config.getInstance(); if (cfg.getBooleanProperty("forum.sendMsgToUserOnDelTopic")) { boolean isSend = true; String s = SkinUtil.LoadString(request, "res.forum.MsgDb", "shortmsg_del_topic_content"); if (!privilege.isUserLogin(request)) { s = StrUtil.format(s, new Object[] {msgDb.getTitle(), UserDb.ADMIN}); } else { UserDb ud = new UserDb(); ud = ud.getUser(privilege.getUser(request)); s = StrUtil.format(s, new Object[] {msgDb.getTitle(), ud.getNick()}); BoardManagerDb bmd = privilege.getUserManagerIdentityOfBoard(request, msgDb.getboardcode()); if (bmd!=null) { if (bmd.isHide()) isSend = false; } } if (isSend) { String reason = ParamUtil.get(request, "reason"); if (!reason.equals("")) { s += StrUtil.format(SkinUtil.LoadString(request, "res.forum.MsgDb", "op_reason"), new Object[] {reason}); } MessageDb msg = new MessageDb(); msg.setTitle(SkinUtil.LoadString(request, "res.forum.MsgDb", "shortmsg_del_topic_title")); msg.setContent(s); msg.setSender(MessageDb.USER_SYSTEM); msg.setReceiver(msgDb.getName()); msg.setIp(request.getRemoteAddr()); msg.setType(msg.TYPE_SYSTEM); msg.create(); } } } return re; } public boolean delTopicAbsolutely(ServletContext application, HttpServletRequest request, long delId) throws ErrMsgException { boolean isPluginValid = false; MsgDb msgDb = getMsgDb(delId); if (!msgDb.isLoaded()) throw new ErrMsgException(LoadString(request, "err_topic_del_lost")); blog = msgDb.isBlog(); PluginMgr pm = new PluginMgr(); Vector vplugin = pm.getAllPluginUnitOfBoard(msgDb.getboardcode()); if (vplugin.size() > 0) { Iterator irplugin = vplugin.iterator(); while (irplugin.hasNext()) { PluginUnit pu = (PluginUnit) irplugin.next(); IPluginPrivilege ipp = pu.getPrivilege(); if (!ipp.canManage(request, delId)) { String s = LoadString(request, "err_pvg_plugin"); s = s.replaceFirst("\\$p", pu.getName(request)); throw new ErrMsgException(s); } } isPluginValid = true; } if (!isPluginValid) { if (!privilege.canDel(request, delId)) { throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID)); } } if (vplugin.size() > 0) { Iterator irplugin = vplugin.iterator(); while (irplugin.hasNext()) { PluginUnit pu = (PluginUnit) irplugin.next(); IPluginMsgAction ipa = pu.getMsgAction(); ipa.delTopic(application, request, msgDb); } } String plugin2Code = msgDb.getPlugin2Code(); if (!plugin2Code.equals("")) { Plugin2Mgr p2m = new Plugin2Mgr(); Plugin2Unit p2u = p2m.getPlugin2Unit(plugin2Code); if (p2u != null) { p2u.getMsgAction().delTopic(application, request, msgDb); } } boolean re = false; try { re = msgDb.delTopic(application, delId); Config cfg = Config.getInstance(); if (cfg.getBooleanProperty("forum.sendMsgToUserOnDelTopic")) { boolean isSend = true; String s = SkinUtil.LoadString(request, "res.forum.MsgDb", "shortmsg_del_topic_content"); if (!privilege.isUserLogin(request)) { s = StrUtil.format(s, new Object[] {msgDb.getTitle(), UserDb.ADMIN}); } else { UserDb ud = new UserDb(); ud = ud.getUser(privilege.getUser(request)); s = StrUtil.format(s, new Object[] {msgDb.getTitle(), ud.getNick()}); BoardManagerDb bmd = privilege.getUserManagerIdentityOfBoard(request, msgDb.getboardcode()); if (bmd!=null) { if (bmd.isHide()) isSend = false; } } if (isSend) { MessageDb msg = new MessageDb(); msg.setTitle(SkinUtil.LoadString(request, "res.forum.MsgDb", "shortmsg_del_topic_title")); msg.setContent(s); msg.setSender(msg.USER_SYSTEM); msg.setReceiver(msgDb.getName()); msg.setIp(request.getRemoteAddr()); msg.setType(msg.TYPE_SYSTEM); msg.create(); } } if (re) { Indexer idx = new Indexer(); idx.delDocument(delId); } } catch (ResKeyException e1) { logger.error("delTopic:" + e1.getMessage(request)); } return re; } public boolean setOnTop(HttpServletRequest request, long id, int value) throws ErrMsgException { if (!privilege.canManage(request, id)) { throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID)); } if (value==MsgDb.LEVEL_TOP_FORUM) { if (!privilege.isMasterLogin(request)) { throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.PVG_INVALID)); } } String strExpire = ParamUtil.get(request, "levelExpire"); Date levelExpire = DateUtil.parse(strExpire, "yyyy-MM-dd HH:mm:ss"); return setOnTop(request, id, value, levelExpire); } public boolean setOnTop(HttpServletRequest request, long id, int value, Date levelExpire) throws ErrMsgException { boolean re = false; MsgDb msg = getMsgDb(id);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -