forumPerms.jsp
资源名称:NetOffice.rar [点击查看]
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:19k
源码类别:
电子政务应用
开发平台:
Java
- <%
- /**
- * $RCSfile: forumPerms.jsp,v $
- * $Revision: 1.3.2.1 $
- * $Date: 2001/02/09 20:38:41 $
- */
- %>
- <%@ page import="java.util.*,
- java.net.URLEncoder,
- 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"/>
- <%! ////////////////////////
- // global page variables
- private final int READ = ForumPermissions.READ;
- private final int CREATE_THREAD = ForumPermissions.CREATE_THREAD;
- private final int CREATE_MESSAGE = ForumPermissions.CREATE_MESSAGE;
- private final int[] perms = { READ, CREATE_THREAD, CREATE_MESSAGE };
- private final String[] permDescriptions = {
- "浏览论坛内容","发表论坛论题","回复论坛帖子"
- };
- %>
- <%! ///////////////////
- // global methods
- private int[] getIntListboxParams( String[] paramVal ) {
- if( paramVal == null ) {
- return new int[0];
- }
- int[] params = new int[paramVal.length];
- for (int i=0;i<paramVal.length;i++)
- {
- try {
- params[i] = Integer.parseInt(paramVal[i]);
- } catch( NumberFormatException nfe ) {}
- }
- return params;
- }
- %>
- <% ////////////////////////////////
- // 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);
- ForumPermissions permissions = forumFactory.getPermissions(authToken);
- boolean isSystemAdmin = permissions.get(ForumPermissions.SYSTEM_ADMIN);
- boolean isForumAdmin = permissions.get(ForumPermissions.FORUM_ADMIN);
- // redirect to error page if we're not a group admin or a system admin
- if( !isForumAdmin && !isSystemAdmin ) {
- request.setAttribute("message","您没有权限管理论坛!");
- response.sendRedirect("error.jsp");
- return;
- }
- %>
- <% ////////////////////
- // get parameters
- int forumID = ParamUtils.getIntParameter(request,"forum",-1);
- // action parameters
- boolean doAddUserPerm = ParamUtils.getBooleanParameter(request,"doAddUserPerm");
- boolean doAddGroupPerm = ParamUtils.getBooleanParameter(request,"doAddGroupPerm");
- boolean doRemoveUserPerm = ParamUtils.getBooleanParameter(request,"doRemoveUserPerm");
- boolean doRemoveGroupPerm = ParamUtils.getBooleanParameter(request,"doRemoveGroupPerm");
- int permType = ParamUtils.getIntParameter(request,"permType",-1);
- int[] usersWithPerm = getIntListboxParams(request.getParameterValues("usersWithPerm"));
- int[] groupsWithPerm = getIntListboxParams(request.getParameterValues("groupsWithPerm"));
- int[] userList = getIntListboxParams(request.getParameterValues("userList"));
- String userAddUsername = request.getParameter("userListField");
- int[] groupList = getIntListboxParams(request.getParameterValues("groupList"));
- int[] userPermTypesList = getIntListboxParams(request.getParameterValues("userPermTypes"));
- int[] groupPermTypesList = getIntListboxParams(request.getParameterValues("groupPermTypes"));
- %>
- <% /////////////////////
- // other page variables
- boolean doAction = (
- doAddUserPerm || doAddGroupPerm || doRemoveUserPerm || doRemoveGroupPerm
- );
- %>
- <% ///////////////////////
- // error variables
- boolean errors = false;
- %>
- <% //////////////////////////////////
- // global variables
- ProfileManager manager = forumFactory.getProfileManager();
- %>
- <% /////////////////////
- // try to load the forum from the passed in forumID
- Forum forum = null;
- try {
- forum = forumFactory.getForum(forumID);
- }
- catch( ForumNotFoundException fnfe ) {
- response.sendRedirect("error.jsp?msg="
- + URLEncoder.encode("论坛 " + forumID + " 没有发现!") );
- return;
- }
- catch( UnauthorizedException ue ) {
- response.sendRedirect("error.jsp?msg="
- + URLEncoder.encode("您没有权限管理此论坛!"));
- return;
- }
- %>
- <% /////////////////////
- // this forum's properties
- String forumName = forum.getName();
- String forumDescription = forum.getDescription();
- Iterator allUsers = manager.users();
- Iterator allGroups = manager.groups();
- int[] usersWithReadPerm = new int[0];
- int[] usersWithThreadPerm = new int[0];
- int[] usersWithMessagePerm = new int[0];
- int[] groupsWithReadPerm = new int[0];
- int[] groupsWithThreadPerm = new int[0];
- int[] groupsWithMessagePerm = new int[0];
- try {
- usersWithReadPerm = forum.usersWithPermission(READ);
- usersWithThreadPerm = forum.usersWithPermission(CREATE_THREAD);
- usersWithMessagePerm = forum.usersWithPermission(CREATE_MESSAGE);
- groupsWithReadPerm = forum.groupsWithPermission(READ);
- groupsWithThreadPerm = forum.groupsWithPermission(CREATE_THREAD);
- groupsWithMessagePerm = forum.groupsWithPermission(CREATE_MESSAGE);
- }
- catch( UnauthorizedException ue ) {}
- %>
- <% /////////////////////////
- // do an action!
- if( doAction ) {
- // add a new user permission
- if( doAddUserPerm ) {
- try {
- for( int i=0; i<userList.length; i++ ) {
- User user = manager.getUser(userList[i]);
- for( int j=0; j<userPermTypesList.length; j++ ) {
- forum.addUserPermission(user,userPermTypesList[j]);
- }
- }
- } catch( UserNotFoundException unfe ) {
- } catch( UnauthorizedException ue ) {
- }
- try {
- if( !"-Enter Username-".equals(userAddUsername)
- && userAddUsername != null )
- {
- User user = manager.getUser(userAddUsername);
- for( int j=0; j<userPermTypesList.length; j++ ) {
- forum.addUserPermission(user,userPermTypesList[j]);
- }
- }
- } catch( UserNotFoundException unfe ) {
- } catch( UnauthorizedException ue ) {
- }
- }
- // remove a user permission
- if( doRemoveUserPerm ) {
- try {
- for( int i=0; i<usersWithPerm.length; i++ ) {
- User user = manager.getUser(usersWithPerm[i]);
- forum.removeUserPermission(user,permType);
- }
- } catch( UserNotFoundException unfe ) {
- } catch( UnauthorizedException ue ) {
- }
- }
- // add a new group permission
- if( doAddGroupPerm ) {
- try {
- for( int i=0; i<groupList.length; i++ ) {
- Group group = manager.getGroup(groupList[i]);
- for( int j=0; j<groupPermTypesList.length; j++ ) {
- forum.addGroupPermission(group,groupPermTypesList[j]);
- }
- }
- } catch( GroupNotFoundException gnfe ) {
- } catch( UnauthorizedException ue ) {
- }
- }
- // remove a user permission
- if( doRemoveGroupPerm ) {
- try {
- for( int i=0; i<groupsWithPerm.length; i++ ) {
- Group group = manager.getGroup(groupsWithPerm[i]);
- forum.removeGroupPermission(group,permType);
- }
- } catch( GroupNotFoundException gnfe ) {
- } catch( UnauthorizedException ue ) {
- }
- }
- }
- %>
- <% ////////////////////
- // if we did something, redirect to this page again (since we're doing POSTS
- // on the form)
- // uncommented so i can debug parameters!!
- if( doAction ) {
- response.sendRedirect("forumPerms.jsp?forum="+forumID);
- return;
- }
- %>
- <html>
- <head>
- <title></title>
- <link rel="stylesheet" href="style/global.css">
- <script language="JavaScript" type="text/javascript">
- <!--
- function selAllListBox( el, chkbx ) {
- if( chkbx.checked ) {
- for( var i=0; i<el.options.length; i++ ) {
- el.options[i].selected = true;
- }
- }
- }
- //-->
- </script>
- </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>
- <b>此论坛的许可状况:</b>
- <%= forumName %>
- <p>
- <%-- Permissions summary table --%>
- <table bgcolor="#666666" cellpadding="0" cellspacing="0" width="80%" align="center" border="0">
- <td>
- <table bgcolor="#666666" cellpadding="3" cellspacing="1" width="100%" border="0">
- <tr bgcolor="#eeeeee">
- <td>
- 许可列表
- </td>
- </tr>
- <tr bgcolor="#ffffff">
- <td>
- <table cellpadding="3" cellspacing="0" width="100%" border="0">
- <td>
- <br>
- <%-- user permission summary --%>
- 用户 在此论坛中的许可详细情况:
- <p>
- <table cellpadding="3" cellspacing="0" border="0" align="center">
- <tr>
- <form action="forumPerms.jsp">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <input type="hidden" name="doRemoveUserPerm" value="true">
- <input type="hidden" name="permType" value="<%= READ %>">
- <td align="center">
- <b><%= usersWithReadPerm.length %></b>
- 拥有<font color="#008000">论坛浏览</font>许可:
- <br>
- <select size="5" name="usersWithPerm" multiple>
- <% for( int i=0; i<usersWithReadPerm.length; i++ ) { %>
- <% try { %>
- <% User user = manager.getUser(usersWithReadPerm[i]); %>
- <% int userID = user.getID(); %>
- <% if( userID == -1 ) { %>
- <option value="<%= userID %>">◎匿名过客
- <% } else if( userID == 0 ) { %>
- <option value="<%= userID %>">◎所有注册用户
- <% } else { %>
- <option value="<%= userID %>"><%= user.getUsername() %>
- <% } %>
- <% } catch( UserNotFoundException unfe ) {} %>
- <% } %>
- </select><br>
- (<input type="checkbox" id="cb03"
- onclick="selAllListBox(this.form.usersWithPerm,this);">
- <label for="cb03">全选</label>) <br>
- <input type="submit" value="删除">
- </td>
- </form>
- <form action="forumPerms.jsp">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <input type="hidden" name="doRemoveUserPerm" value="true">
- <input type="hidden" name="permType" value="<%= CREATE_THREAD %>">
- <td align="center">
- <b><%= usersWithThreadPerm.length %></b>
- 拥有<font color="#008000">创建论题</font>许可:
- <br>
- <select size="5" name="usersWithPerm" multiple>
- <% for( int i=0; i<usersWithThreadPerm.length; i++ ) { %>
- <% try { %>
- <% User user = manager.getUser(usersWithThreadPerm[i]); %>
- <% int userID = user.getID(); %>
- <% if( userID == -1 ) { %>
- <option value="<%= userID %>">◎匿名过客
- <% } else if( userID == 0 ) { %>
- <option value="<%= userID %>">◎所有注册用户
- <% } else { %>
- <option value="<%= userID %>"><%= user.getUsername() %>
- <% } %>
- <% } catch( UserNotFoundException unfe ) {} %>
- <% } %>
- </select><br>
- (<input type="checkbox" id="cb04"
- onclick="selAllListBox(this.form.usersWithPerm,this);">
- <label for="cb04">全选</label>) <br>
- <input type="submit" value="删除">
- </td>
- </form>
- <form action="forumPerms.jsp">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <input type="hidden" name="doRemoveUserPerm" value="true">
- <input type="hidden" name="permType" value="<%= CREATE_MESSAGE %>">
- <td align="center">
- <b><%= usersWithMessagePerm.length %></b>
- 拥有<font color="#008000">回复帖子</font>许可:
- <br>
- <select size="5" name="usersWithPerm" multiple>
- <% for( int i=0; i<usersWithMessagePerm.length; i++ ) { %>
- <% try { %>
- <% User user = manager.getUser(usersWithMessagePerm[i]); %>
- <% int userID = user.getID(); %>
- <% if( userID == -1 ) { %>
- <option value="<%= userID %>">◎匿名过客
- <% } else if( userID == 0 ) { %>
- <option value="<%= userID %>">◎所有注册用户
- <% } else { %>
- <option value="<%= userID %>"><%= user.getUsername() %>
- <% } %>
- <% } catch( UserNotFoundException unfe ) {} %>
- <% } %>
- </select><br>
- (<input type="checkbox" id="cb05"
- onclick="selAllListBox(this.form.usersWithPerm,this);">
- <label for="cb05">全选</label>) <br>
- <input type="submit" value="删除">
- </td>
- </form>
- </tr>
- </table>
- <%-- /user permission summary --%>
- <p>
- <hr size="0" width="75%">
- <p>
- <%-- group permission summary --%>
- 用户组 在此论坛的许可的详细情况:
- <p>
- <table cellpadding="3" cellspacing="0" border="0" align="center">
- <tr>
- <form action="forumPerms.jsp">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <input type="hidden" name="doRemoveGroupPerm" value="true">
- <input type="hidden" name="permType" value="<%= READ %>">
- <td align="center">
- <b><%= groupsWithReadPerm.length %></b>
- 拥有<font color="#008000">论坛浏览</font>许可:
- <br>
- <select size="5" name="groupsWithPerm">
- <% for( int i=0; i<groupsWithReadPerm.length; i++ ) { %>
- <% try { %>
- <% Group group = manager.getGroup(groupsWithReadPerm[i]); %>
- <option value="<%= group.getID() %>"><%= group.getName() %>
- <% } catch( GroupNotFoundException gnfe ) {%> <%= groupsWithReadPerm[i] %> <%} %>
- <% } %>
- </select><br>
- (<input type="checkbox" id="cb06"
- onclick="selAllListBox(this.form.groupsWithPerm,this);">
- <label for="cb06">全选</label>) <br>
- <input type="submit" value="删除">
- </td>
- </form>
- <form action="forumPerms.jsp">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <input type="hidden" name="doRemoveGroupPerm" value="true">
- <input type="hidden" name="permType" value="<%= CREATE_THREAD %>">
- <td align="center">
- <b><%= groupsWithThreadPerm.length %></b>
- 拥有<font color="#008000">创建论题</font>许可:
- <br>
- <select size="5" name="groupsWithPerm">
- <% for( int i=0; i<groupsWithThreadPerm.length; i++ ) { %>
- <% try { %>
- <% Group group = manager.getGroup(groupsWithThreadPerm[i]); %>
- <option value="<%= group.getID() %>"><%= group.getName() %>
- <% } catch( GroupNotFoundException gnfe ) {} %>
- <% } %>
- </select><br>
- (<input type="checkbox" id="cb07"
- onclick="selAllListBox(this.form.groupsWithPerm,this);">
- <label for="cb07">全选</label>) <br>
- <input type="submit" value="删除">
- </td>
- </form>
- <form action="forumPerms.jsp">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <input type="hidden" name="doRemoveGroupPerm" value="true">
- <input type="hidden" name="permType" value="<%= CREATE_MESSAGE %>">
- <td align="center">
- <b><%= groupsWithMessagePerm.length %></b>
- 拥有<font color="#008000">回复帖子</font>许可:
- <br>
- <select size="5" name="groupsWithPerm">
- <% for( int i=0; i<groupsWithMessagePerm.length; i++ ) { %>
- <% try { %>
- <% Group group = manager.getGroup(groupsWithMessagePerm[i]); %>
- <option value="<%= group.getID() %>"><%= group.getName() %>
- <% } catch( GroupNotFoundException gnfe ) {} %>
- <% } %>
- </select><br>
- (<input type="checkbox" id="cb08"
- onclick="selAllListBox(this.form.groupsWithPerm,this);">
- <label for="cb08">全选</label>) <br>
- <input type="submit" value="删除">
- </td>
- </form>
- </tr>
- </table>
- <%-- /group permission summary --%>
- </td>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </table>
- <%-- /Permissions summary table --%>
- <p>
- <%-- Add new user permission --%>
- <form action="forumPerms.jsp" method="get">
- <input type="hidden" name="doAddUserPerm" value="true">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <table bgcolor="#666666" cellpadding="0" cellspacing="0" width="80%" align="center" border="0">
- <td>
- <table bgcolor="#666666" cellpadding="3" cellspacing="1" width="100%" border="0">
- <tr bgcolor="#eeeeee">
- <td width="99%">
- 增加新<b>用户</b>许可
- </td>
- <td width="1%" nowrap>
- (<a href="createUser.jsp">增加一个新用户</a>)
- </td>
- </tr>
- <tr bgcolor="#ffffff">
- <td colspan="2">
- <table cellpadding="3" cellspacing="0" width="100%" border="0">
- <td>
- <p>
- <table cellpadding="3" cellspacing="0" border="0" align="center">
- <tr>
- <td nowrap>设置</td>
- <td width="1%">
- <select name="userList" size="2" multiple>
- <option value="-1">◎匿名过客
- <option value="0">◎所有注册用户
- </select>
- (<input type="checkbox" id="cb01"
- onclick="selAllListBox(this.form.userList,this);">
- <label for="cb01">全选</label>)
- <br>
- <input type="text" size="20" name="userListField"
- value="输入用户名"
- onclick="this.select();">
- <br>
- </td>
- <td>在此论坛中有</td>
- <td>
- <select name="userPermTypes" size="<%= perms.length %>" multiple>
- <% for( int i=0; i<perms.length; i++ ) { %>
- <option value="<%= perms[i] %>"><%= permDescriptions[i] %>
- <% } %>
- </select>
- <br>
- (<input type="checkbox" id="cb02"
- onclick="selAllListBox(this.form.userPermTypes,this);">
- <label for="cb02">全选</label>)
- </td>
- <td>的许可</td>
- </tr>
- <tr>
- <td colspan="5" align="center">
- <input type="submit" name="" value="增加用户许可">
- </td>
- </tr>
- </table>
- </td>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </table>
- </form>
- <%-- /Add new user permission --%>
- <p>
- <%-- Add new group permission --%>
- <form action="forumPerms.jsp" method="get">
- <input type="hidden" name="doAddGroupPerm" value="true">
- <input type="hidden" name="forum" value="<%= forumID %>">
- <table bgcolor="#666666" cellpadding="0" cellspacing="0" width="80%" align="center" border="0">
- <td>
- <table bgcolor="#666666" cellpadding="3" cellspacing="1" width="100%" border="0">
- <tr bgcolor="#eeeeee">
- <td width="99%">
- 增加新<b>用户组</b>许可
- </td>
- <td width="1%" nowrap>
- (<a href="createGroup.jsp">增加一个新用户组</a>)
- </td>
- </tr>
- <tr bgcolor="#ffffff">
- <td colspan="2">
- <table cellpadding="3" cellspacing="0" width="100%" border="0">
- <td>
- <p>
- <table cellpadding="3" cellspacing="0" border="0" align="center">
- <tr>
- <td nowrap>设置</td>
- <td>
- <select name="groupList" size="4" multiple>
- <% while( allGroups.hasNext() ) { %>
- <% Group group = (Group)allGroups.next(); %>
- <option value="<%= group.getID() %>"><%= group.getName() %>
- <% } %>
- </select>
- <br>
- (<input type="checkbox" id="cb11"
- onclick="selAllListBox(this.form.groupList,this);">
- <label for="cb11">全选</label>)
- </td>
- <td>在此论坛中拥有</td>
- <td>
- <select name="groupPermTypes" size="<%= perms.length %>" multiple>
- <% for( int i=0; i<perms.length; i++ ) { %>
- <option value="<%= perms[i] %>"><%= permDescriptions[i] %>
- <% } %>
- </select>
- <br>
- (<input type="checkbox" id="cb12"
- onclick="selAllListBox(this.form.groupPermTypes,this);">
- <label for="cb12">全选</label>)
- </td>
- <td>的许可</td>
- </tr>
- <tr>
- <td colspan="5" align="center">
- <input type="submit" name="" value="增加用户组许可">
- </td>
- </tr>
- </table>
- </td>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </table>
- </form>
- <%-- /Add new user permission --%>
- </body>
- </html>