📄 bbsdocaction.java
字号:
if(BBSRights.checkRights(reply,"lockUser",user))
map.put("lockUser","true");
}
map.put("userName",reply.getInputUser());
map.put("encodUserName",URLEncoder.encode(reply.getInputUser(),"utf-8"));
/*
inputUser=UserInfo.readByUserName(reply.getInputUser());
if(inputUser!=null)
{
map.put("userName",inputUser.getUserName());
map.put("userScore",inputUser.getScore());
map.put("userQq",inputUser.getQq());
map.put("userCid",inputUser.getCid());
map.put("userSign",inputUser.getIntro());
map.put("userPhoto",inputUser.getPhoto());
} */
replyList.add(map);
}
}
form.addResult("list",replyList);
form.addResult("pages",new Integer(pList.getPages()));
form.addResult("rows",new Integer(pList.getRowCount()));
form.addResult("gotoPageHTML",CommUtil.showPageHtml(pList.getCurrentPage(),pList.getPages()));
}
}
return module.findPage("show");
}
/**
* 编辑帖子-从持久层读取数据到VO中显示
* @param form
* @param module
* @return 帖子编辑页面
*/
public Page doEdit(WebForm form,Module module)
{
String cid=CommUtil.null2String(form.get("cid"));
ActiveUser user=getCurrentUser();
BBSDoc obj=BBSDoc.read(cid);
if(obj!=null)
{
if(!BBSRights.checkRights(obj,"edit",user))return new Page("popedomError","/bbs/norights.htm","page");
BBSDir dir=BBSDir.readBySN(obj.getDirSn());
if(dir!=null)
{
form.addResult("dir",dir);
}
else
{
form.addResult("msg","目录不存在,可能是地址链接错误!");
}
UserInfo u=UserInfo.readByUserName(user.getUserName());
if(BBSUtil.noRandomCode(u))form.addResult("need_verify","true");
if(BBSUtil.canUploadImg(u))form.addResult("canUpload","true");
form.addResult("user",u);
if(obj.getTagPic()!=null && obj.getTagPic().equals(""))obj.setTagPic(null);
CommUtil.Obj2Map(obj,form.getTextElement());
form.addResult("vRTypeOptions",obj.showVRTypesSelect());
}
return module.findPage("edit");
}
/**
* 编辑帖子-从持久层读取数据到VO中显示
* @param form
* @param module
* @return 帖子编辑页面
*/
public Page doShowMove(WebForm form,Module module)
{
//String dirSn=CommUtil.null2String(form.get("dirSn"));
List list=BBSDir.query("status>=0 order by parentSn,sequence");
form.addResult("list",list);
return module.findPage("showMove");
}
/**
* 置顶操作,把帖子置顶或者取消置顶
* @param form
* @param module
* @return 返回帖子列表显示Page
*/
public Page doSetTopMessage(WebForm form,Module module)
{
String cid=CommUtil.null2String(form.get("cid"));
ActiveUser user=getCurrentUser();
BBSDoc obj=BBSDoc.read(cid);
if(obj!=null)
{
if(!BBSRights.checkRights(obj,"setTopMessage",user))return new Page("popedomError","/bbs/norights.htm","page");
obj.setTopMessage(new Integer(obj.getTopMessage()!=null && (obj.getTopMessage().intValue()==1)?0:1));
obj.update();
form.addResult("msg","操作成功!");
}
return doQuery(form,module);
}
/**
* 精华帖子操作,把帖子标记为精华或者取消精华
* @param form
* @param module
* @return 返回帖子列表显示Page
*/
public Page doSetEliteMessage(WebForm form,Module module)
{
String cid=CommUtil.null2String(form.get("cid"));
ActiveUser user=getCurrentUser();
BBSDoc obj=BBSDoc.read(cid);
if(obj!=null)
{
if(!BBSRights.checkRights(obj,"setEliteMessage",user))return new Page("popedomError","/bbs/norights.htm","page");
obj.setEliteMessage(new Integer(obj.getEliteMessage()!=null && (obj.getEliteMessage().intValue()==1)?0:1));
obj.update();
form.addResult("msg","操作成功!");
}
return doQuery(form,module);
}
/**
* 删除帖子
* @param form
* @param module
* @return 返回帖子列表Page
*/
public Page doMoveMessage(WebForm form,Module module) throws Exception
{
String cid=CommUtil.null2String(form.get("cid"));
ActiveUser user=getCurrentUser();
BBSDoc obj=BBSDoc.read(cid);
if(obj!=null)
{
if(!BBSRights.checkRights(obj,"moveMessage",user))return new Page("popedomError","/bbs/norights.htm","page");
BBSDir dir=BBSDir.readBySN((String)form.get("dirSn"));
if(dir!=null){
obj.setDirSn(dir.getSn());
obj.setDirPath(dir.getDirPath());
obj.update();
form.addResult("msg","移动成功!");
}
else
{
form.addResult("msg","移动失败!");
}
}
return doShow(form,module);
}
/**
* 删除帖子
* @param form
* @param module
* @return 返回帖子列表Page
*/
public Page doDel(WebForm form,Module module)
{
String cid=CommUtil.null2String(form.get("cid"));
ActiveUser user=getCurrentUser();
BBSDoc obj=BBSDoc.read(cid);
if(obj!=null)
{
if(!BBSRights.checkRights(obj,"del",user))return new Page("popedomError","/bbs/norights.htm","page");
obj.del();
form.addResult("msg","删除成功!");
}
return doQuery(form,module);
}
/**
* 最后更新的帖子-把最新的精华的帖子从特久层读出并到View层显示
* @param form
* @param module
* @return 帖子列表Page
*/
public Page doLastElite(WebForm form, Module module)
{
int currentPage=CommUtil.null2Int(form.get("page"));
int pageSize=CommUtil.null2Int(form.get("pageSize"));
String sn=CommUtil.null2String(form.get("sn"));
if(sn.equals(""))sn=CommUtil.null2String(form.get("dirSn"));
BBSDir dir=BBSDir.readBySN(sn);
if(dir==null){
dir=new BBSDir();
dir.setTitle("最新精华");
dir.setSn(sn);
dir.setIntro("论坛中的所有精华帖!");
}
if(currentPage<1)currentPage=1;
if(pageSize<1)pageSize=15;
String sqlWhere="eliteMessage>0 ";
Collection paras=new ArrayList();
if(dir.getSn()!=null &&(!"".equals(dir.getSn())) ){
sqlWhere+=" and dirSn=?";
paras.add(sn);
}
form.addResult("dir",dir);
IPageList pList=BBSUtil.queryMessage(sqlWhere,paras,pageSize,currentPage);
if(pList!=null){
form.addResult("list",pList.getResult());
form.addResult("pages",new Integer(pList.getPages()));
form.addResult("rows",new Integer(pList.getRowCount()));
form.addResult("page",new Integer(pList.getCurrentPage()));
form.addResult("gotoPageHTML",CommUtil.showPageHtml(pList.getCurrentPage(),pList.getPages()));
}
return module.findPage("list");
}
/**
* 查询列表帖子
* @param form
* @param module
* @return 帖子列表Page
*/
public Page doQuery(WebForm form, Module module)
{
int currentPage=CommUtil.null2Int(form.get("page"));//页码
int pageSize=CommUtil.null2Int(form.get("pageSize"));//每页大小
String sn=CommUtil.null2String(form.get("sn"));//目录编号
String title=CommUtil.null2String(form.get("title"));//标题
if(sn.equals(""))sn=CommUtil.null2String(form.get("dirSn"));//目录编码
String inputUser=CommUtil.null2String(form.get("inputUser")); //录入人
BBSDir dir=BBSDir.readBySN(sn);
if(dir!=null)
{
if(currentPage<1)currentPage=1;
if(pageSize<1)pageSize=15;
Collection paras=new ArrayList();
String sqlWhere=" dirPath like ?";
paras.add(dir.getDirPath()+"%");
if(!title.equals(""))
{
sqlWhere+=" and title like ?";
paras.add("%"+title+"%");
}
if(!inputUser.equals(""))
{
sqlWhere+=" and inputUser=?";
paras.add(inputUser);
}
IPageList pList=BBSUtil.queryMessage(sqlWhere,paras,pageSize,currentPage);
form.addResult("dir",dir);
List children=dir.children();
if(children!=null && children.size()>0)form.addResult("childrenList",children);
if(pList!=null){
form.addResult("list",pList.getResult());
form.addResult("pages",new Integer(pList.getPages()));
form.addResult("rows",new Integer(pList.getRowCount()));
form.addResult("page",new Integer(pList.getCurrentPage()));
form.addResult("gotoPageHTML",CommUtil.showPageHtml(pList.getCurrentPage(),pList.getPages()));
}
}
else
{
form.addResult("msg","所查询的目录不存在!");
}
return module.findPage("list");
}
/**
* 替换表情字符
* @param s
* @return 把表情标记换成相应的图片
*/
public String replaceEmotTag(String s) {
String makeContent = new String();
String[] r = new String[50];
for (int i = 1; i < 50; i++)
r[i] = "\\[em" + (i < 10 ? "0" + i : i + "") + "\\]";//eval("/em"+(i<10?"0"+i:i+"")+"/;");
StringTokenizer strToken = new StringTokenizer(s, "\n");
while (strToken.hasMoreTokens()) {
makeContent = makeContent + "<br>" + strToken.nextToken();
}
for (int i = 1; i < 50; i++) {
makeContent = makeContent.replaceAll(r[i], "<img src=/images/emot/em"
+ (i < 10 ? "0" + i : i + "") + ".gif>");//s.replace(r[i],"<img
// src=img/emot/em"+(i<10?"0"+i:i+"")+".gif>");
}
r = null;
return makeContent;
}
/**
* 通过Session获得当前登录用户
* @return 当前操作用户
*/
public Page doSystemInit(WebForm form, Module module)
{
//if(true)return null;
List list=BBSDoc.query("parentId is null or parentId=''");
if(list!=null)
{
for(int i=0;i<list.size();i++)
{
BBSDoc doc=(BBSDoc)list.get(i);
doc.setReplyNum(new Integer(doc.replyNum().intValue()));
doc.update();
}
}
list=BBSDir.query("1=1");
if(list!=null)
{
for(int i=0;i<list.size();i++)
{
BBSDir doc=(BBSDir)list.get(i);
doc.setReplyNum(new Integer(doc.replyNum().intValue()));
doc.setMessageNum(new Integer(doc.messageNum().intValue()));
doc.update();
}
}
return null;
}
private ActiveUser getCurrentUser()
{
ActiveUser user=(ActiveUser)ActionContext.getContext().getSession().getAttribute("bbsuser");
return user;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -