createGroup.jsp
资源名称:NetOffice.rar [点击查看]
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:5k
源码类别:
电子政务应用
开发平台:
Java
- <%
- /**
- * $RCSfile: createGroup.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.*"
- errorPage="error.jsp"
- %>
- <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 administer users:
- ForumFactory forumFactory = ForumFactory.getInstance(authToken);
- boolean isSystemAdmin = ((Boolean)session.getValue("jiveAdmin.systemAdmin")).booleanValue();
- boolean isGroupAdmin = ((Boolean)session.getValue("jiveAdmin.groupAdmin")).booleanValue();
- // redirect to error page if we're not a group admin or a system admin
- if( !isGroupAdmin && !isSystemAdmin ) {
- throw new UnauthorizedException("对不起,您没有权限创建用户组!");
- }
- %>
- <% ////////////////////
- // get parameters
- String groupName = ParamUtils.getParameter(request,"groupName");
- String groupDescription = ParamUtils.getParameter(request,"groupDescription");
- boolean doCreate = ParamUtils.getBooleanParameter(request,"doCreate");
- %>
- <% //////////////////////////////////
- // global error variables
- String errorMessage = "";
- boolean errorGroupName = (groupName == null);
- boolean errorGroupAlreadyExists = false;
- boolean errors = (errorGroupName);
- %>
- <% //////////////////
- // load user of this page:
- ProfileManager manager = forumFactory.getProfileManager();
- // UserNotFoundException is caught by error page
- User user = manager.getUser(authToken.getUserID());
- %>
- <% ////////////////////
- // create the group
- if( !errors && doCreate ) {
- try {
- Group newGroup = manager.createGroup(groupName);
- // add this user as an administrator of the new group
- newGroup.addAdministrator(user);
- if( groupDescription != null ) {
- newGroup.setDescription( groupDescription );
- }
- }
- catch( GroupAlreadyExistsException gaee ) {
- errorGroupAlreadyExists = true;
- }
- }
- %>
- <% ////////////////
- // error check
- errors = (errorGroupName || errorGroupAlreadyExists);
- %>
- <% ////////////////////
- // set error messages
- if( errors ) {
- if( errorGroupName ) {
- errorMessage = "请输入用户组名称。";
- }
- else if( errorGroupAlreadyExists ) {
- errorMessage = "此用户组已经存在,请选择另一个名称。";
- }
- else {
- errorMessage = "在创建用户组时发生一般错误,请检查输入各项。";
- }
- }
- %>
- <% //////////////////////////////////////////////////////////////////////
- // if a user was successfully created, say so and return (to stop the
- // jsp from executing
- if( !errors ) {
- response.sendRedirect(
- response.encodeRedirectURL("groups.jsp?msg=用户组创建成功!")
- );
- 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>
- <span class="errorText">
- <%= doCreate?errorMessage:"" %>
- </span>
- <p>
- <font size="-1">
- 这里将创建一个没有许可,没有管理权限,和没有用户成员的用户组,
- 在你创建完成之后,你应该编辑他的各种属性。
- </font>
- <p>
- <%-- form --%>
- <form action="createGroup.jsp" method="post" name="f">
- <input type="hidden" name="doCreate" value="true">
- <b>新用户组信息:</b>
- <p>
- <table bgcolor="#999999" cellspacing="0" cellpadding="0" border="0" width="95%" align="right">
- <td>
- <table bgcolor="#999999" cellspacing="1" cellpadding="3" border="0" width="100%">
- <%-- name row --%>
- <tr bgcolor="#ffffff">
- <td><font size="-1">用户组名称:</i></font></td>
- <td><input type="text" name="groupName" size="30" maxlength="100"
- value="<%= (groupName!=null)?groupName:"" %>">
- </td>
- </tr>
- <%-- description row --%>
- <tr bgcolor="#ffffff">
- <td><font size="-1">用户组描述:<br>(可选)</i></font></td>
- <td>
- <textarea name="groupDescription" wrap="virtual" cols="40" rows="5"
- ><%= (groupDescription!=null)?groupDescription:"" %></textarea>
- </td>
- </tr>
- </table>
- </td>
- </table>
- <br clear="all"><br>
- <script language="JavaScript" type="text/javascript">
- <!--
- document.f.groupName.focus();
- //-->
- </script>
- <p>
- <center>
- <input type="submit" value="创建用户组">
- </center>
- </form>
- <%-- /form --%>
- </body>
- </html>