createForum.jsp
资源名称:NetOffice.rar [点击查看]
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:4k
源码类别:
电子政务应用
开发平台:
Java
- <%
- /**
- * $RCSfile: createForum.jsp,v $
- * $Revision: 1.3 $
- * $Date: 2000/12/18 02:06:21 $
- */
- %>
- <%@ page import="java.util.*,
- com.coolservlets.forum.*,
- com.coolservlets.forum.util.*,
- com.coolservlets.forum.util.admin.*" %>
- <jsp:useBean id="adminBean" scope="session"
- class="com.coolservlets.forum.util.admin.AdminBean"/>
- <% ////////////////////////////////
- // Jive authorization check
- // check the bean for the existence of an authorization token.
- // Its existence proves the user is valid. If it's not found, redirect
- // to the login page
- Authorization authToken = adminBean.getAuthToken();
- if( authToken == null ) {
- response.sendRedirect( "/mainctrl/bbs/admin" );
- return;
- }
- %>
- <% ////////////////////
- // Security check
- // make sure the user is authorized to create forums::
- ForumFactory forumFactory = ForumFactory.getInstance(authToken);
- ForumPermissions permissions = forumFactory.getPermissions(authToken);
- boolean isSystemAdmin = permissions.get(ForumPermissions.SYSTEM_ADMIN);
- boolean isUserAdmin = permissions.get(ForumPermissions.FORUM_ADMIN);
- // redirect to error page if we're not a forum admin or a system admin
- if( !isUserAdmin && !isSystemAdmin ) {
- request.setAttribute("message","您没有权限创建论坛!");
- response.sendRedirect("error.jsp");
- return;
- }
- %>
- <% ////////////////////
- // Get parameters
- boolean doCreate = ParamUtils.getBooleanParameter(request,"doCreate");
- String forumName = ParamUtils.getParameter(request,"forumName");
- String forumDescription = ParamUtils.getParameter(request,"forumDescription");
- %>
- <% ////////////////////
- // Error variables
- boolean forumNameError = (forumName==null);
- boolean errors = forumNameError;
- String errorMessage = "发生一般错误。";
- %>
- <% //////////////////////////////
- // create forum if no errors and redirect to forum main page
- if( !errors && doCreate ) {
- Forum newForum = null;
- String message = null;
- try {
- if( forumDescription == null ) {
- forumDescription = "";
- }
- newForum = forumFactory.createForum( forumName, forumDescription );
- message = "论坛 "" + forumName + "" 创建成功!";
- request.setAttribute("message",message);
- response.sendRedirect("forumPerms.jsp?forum="+newForum.getID());
- return;
- }
- catch( UnauthorizedException ue ) {
- message = "创建论坛 "" + forumName
- + "" 发生错误- 您没有权限创建论坛。";
- }
- catch( Exception e ) {
- message = "创建论坛 "" + forumName + "" 发生错误。";
- }
- request.setAttribute("message",message);
- response.sendRedirect("error.jsp");
- return;
- }
- %>
- <html>
- <head>
- <title></title>
- <link rel="stylesheet" href="style/global.css">
- </head>
- <body background="images/shadowBack.gif" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
- <% ///////////////////////
- // pageTitleInfo variable (used by include/pageTitle.jsp)
- String[] pageTitleInfo = { "论坛", "创建论坛" };
- %>
- <% ///////////////////
- // pageTitle include
- %><%@ include file="include/pageTitle.jsp" %>
- <p>
- <% ///////////////////////////////////////////
- // print out error message if there was one
- if( errors && doCreate ) {
- %> <span class="errorText">
- <%= errorMessage %>
- </span>
- <p>
- <% } %>
- 注意:此处创建的论坛将没有任何许可,
- 你应该在创建论坛之后,设置此论坛的访问许可。
- <form action="createForum.jsp" method="post">
- <input type="hidden" name="doCreate" value="true">
- <%-- forum name --%>
- 论坛名称:
- <% if( forumNameError && doCreate ) { %>
- <span class="errorText">
- 论坛名称是必须的。
- </span>
- <% } %>
- <ul>
- <input type="text" name="forumName" value="<%= (forumName!=null)?forumName:"" %>">
- </ul>
- <%-- forum description --%>
- 论坛描述: <i>(可选)</i>
- <ul>
- <textarea name="forumDescription" cols="30" rows="5" wrap="virtual"><%= (forumDescription!=null)?forumDescription:"" %></textarea>
- </ul>
- <%-- create button --%>
- <input type="submit" value="创建">
- </form>
- </body>
- </html>