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

📄 bbsdocaction.java

📁 简易java框架开源论坛系统,简 易java框架开源论坛系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
						// 处理用户帖子管理权限
						if (user != null) {
							if (BBSRights.checkRights(reply, "lockMessage",
									user))
								map.put("lockMessage", "true");
							if (BBSRights.checkRights(reply, "editMessage",
									user))
								map.put("editMessage", "true");
							if (BBSRights
									.checkRights(reply, "delMessage", user))
								map.put("delMessage", "true");
							if (BBSRights.checkRights(reply, "lockUser", user))
								map.put("lockUser", "true");
						}

						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", "目录不存在,可能是地址链接错误!");
			}
			if (obj.getTagPic() != null && obj.getTagPic().equals(""))
				obj.setTagPic(null);
			CommUtil.Obj2Map(obj, form.getTextElement());
		}

		return module.findPage("edit");
	}

	/**
	 * 置顶操作,把帖子置顶或者取消置顶
	 * 
	 * @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 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.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);
		}

		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 doQueryMaster(WebForm form, Module module) {
		int currentPage = CommUtil.null2Int(form.get("page"));
		int pageSize = CommUtil.null2Int(form.get("pageSize"));
		if (currentPage < 1)
			currentPage = 1;
		if (pageSize < 1)
			pageSize = 15;
		IPageList pList = BBSUtil.queryMessage("1=1 and inputUser='"
				+ getCurrentUser().getUserName() + "'", 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");
	}

	public Page doQueryPartin(WebForm form, Module module) {
		int currentPage = CommUtil.null2Int(form.get("page"));
		int pageSize = CommUtil.null2Int(form.get("pageSize"));
		if (currentPage < 1)
			currentPage = 1;
		if (pageSize < 1)
			pageSize = 15;
		IPageList pList = BBSUtil
				.queryMsg(
						"cid in (select parentId from BBSDoc where inputUser='"
								+ getCurrentUser().getUserName()
								+ "' and status >0 and parentId is not null or parentId <> '')",
						null, 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");
	}

	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 = " dirSn=?";
			paras.add(sn);
			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);
			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 当前操作用户
	 */
	private ActiveUser getCurrentUser() {
		ActiveUser user = (ActiveUser) ActionContext.getContext().getSession()
				.getAttribute("bbsuser");
		return user;
	}
}

⌨️ 快捷键说明

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