mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-23 09:53:09 +00:00
Modified group editor to go in /tools and mostly work with
new popup eperson selector git-svn-id: http://scm.dspace.org/svn/repo/trunk@823 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -395,7 +395,7 @@
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>groups</servlet-name>
|
||||
<url-pattern>/dspace-admin/groups</url-pattern>
|
||||
<url-pattern>/tools/groups</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
|
@@ -59,7 +59,7 @@
|
||||
links.add("/dspace-admin/edit-epeople");
|
||||
|
||||
labels.add("Groups");
|
||||
links.add("/dspace-admin/groups");
|
||||
links.add("/tools/groups");
|
||||
|
||||
labels.add("Items");
|
||||
links.add("/tools/edit-item");
|
||||
|
96
dspace/jsp/tools/group-edit.jsp
Normal file
96
dspace/jsp/tools/group-edit.jsp
Normal file
@@ -0,0 +1,96 @@
|
||||
<%--
|
||||
- group_edit.jsp
|
||||
-
|
||||
- $Id$
|
||||
-
|
||||
- Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
|
||||
- Institute of Technology. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions are
|
||||
- met:
|
||||
-
|
||||
- - Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
-
|
||||
- - Redistributions in binary form must reproduce the above copyright
|
||||
- notice, this list of conditions and the following disclaimer in the
|
||||
- documentation and/or other materials provided with the distribution.
|
||||
-
|
||||
- - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
- Massachusetts Institute of Technology nor the names of their
|
||||
- contributors may be used to endorse or promote products derived from
|
||||
- this software without specific prior written permission.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
- DAMAGE.
|
||||
--%>
|
||||
|
||||
|
||||
<%--
|
||||
- Show contents of a group (name, epeople)
|
||||
-
|
||||
- Attributes:
|
||||
- group - group to be edited
|
||||
-
|
||||
- Returns:
|
||||
- cancel - if user wants to cancel
|
||||
- add_eperson - go to group_eperson_select.jsp to choose eperson
|
||||
- change_name - alter name & redisplay
|
||||
- eperson_remove - remove eperson & redisplay
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
|
||||
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||
|
||||
<%@ page import="org.dspace.eperson.EPerson" %>
|
||||
<%@ page import="org.dspace.eperson.Group" %>
|
||||
|
||||
<%
|
||||
Group group = (Group) request.getAttribute("group");
|
||||
EPerson [] epeople = (EPerson []) request.getAttribute("members");
|
||||
|
||||
%>
|
||||
|
||||
<dspace:layout title="Edit Group"
|
||||
navbar="admin"
|
||||
locbar="link"
|
||||
parentlink="/dspace-admin"
|
||||
parenttitle="Administer"
|
||||
nocache="true">
|
||||
|
||||
<h1>Edit Group : <%=group.getName()%> (<%=group.getID()%>)</h1>
|
||||
|
||||
<p align="center">
|
||||
<form method=post>
|
||||
Name: <input name="group_name" value="<%=group.getName()%>">
|
||||
<input type="hidden" name="group_id" value="<%=group.getID()%>">
|
||||
<input type="submit" name="submit_change_name" value="Update Name">
|
||||
</form>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
|
||||
<center><h3>Current Group Members</h3></center>
|
||||
|
||||
<form method=POST>
|
||||
<input type="hidden" name="group_id" value="<%=group.getID()%>">
|
||||
<dspace:selecteperson multiple="true" selected="<%= epeople %>"/>
|
||||
<input type="submit" name="submit_members_update" value="Update Members" onclick="javascript:finishEPerson();">
|
||||
</form>
|
||||
</dspace:layout>
|
118
dspace/jsp/tools/group-list.jsp
Normal file
118
dspace/jsp/tools/group-list.jsp
Normal file
@@ -0,0 +1,118 @@
|
||||
<%--
|
||||
- group_list.jsp
|
||||
-
|
||||
- $Id$
|
||||
-
|
||||
- Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
|
||||
- Institute of Technology. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions are
|
||||
- met:
|
||||
-
|
||||
- - Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
-
|
||||
- - Redistributions in binary form must reproduce the above copyright
|
||||
- notice, this list of conditions and the following disclaimer in the
|
||||
- documentation and/or other materials provided with the distribution.
|
||||
-
|
||||
- - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
- Massachusetts Institute of Technology nor the names of their
|
||||
- contributors may be used to endorse or promote products derived from
|
||||
- this software without specific prior written permission.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
- DAMAGE.
|
||||
--%>
|
||||
|
||||
|
||||
<%--
|
||||
- Display list of Groups, with 'edit' and 'delete' buttons next to them
|
||||
-
|
||||
- Attributes:
|
||||
-
|
||||
- groups - Group [] of groups to work on
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
|
||||
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||
|
||||
<%@ page import="org.dspace.eperson.EPerson" %>
|
||||
<%@ page import="org.dspace.eperson.Group" %>
|
||||
|
||||
<%
|
||||
Group[] groups =
|
||||
(Group[]) request.getAttribute("groups");
|
||||
%>
|
||||
|
||||
<dspace:layout title="Group Editor"
|
||||
navbar="admin"
|
||||
locbar="link"
|
||||
parentlink="/dspace-admin"
|
||||
parenttitle="Administer"
|
||||
nocache="true">
|
||||
|
||||
<h1>Group Editor</h1>
|
||||
|
||||
<P>Note that you do not need to manually add users to the "anonymous"
|
||||
group - all users are members implicitly.</P>
|
||||
|
||||
<P>Warning - if you try to delete a group that is referred to by an
|
||||
authorization policy or is a workflow group you will get an internal
|
||||
server error.</P>
|
||||
|
||||
<p align="center">
|
||||
<form method=POST>
|
||||
<input type="submit" name="submit_add" value="Create New Group">
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<table class="miscTable" align="center">
|
||||
<tr>
|
||||
<th class="oddRowOddCol"><strong>ID</strong></th>
|
||||
<th class="oddRowEvenCol"><strong>Name</strong></th>
|
||||
<th class="oddRowOddCol"> </th>
|
||||
<th class="oddRowEvenCol"> </th>
|
||||
</tr>
|
||||
|
||||
<%
|
||||
String row = "even";
|
||||
for (int i = 0; i < groups.length; i++)
|
||||
{
|
||||
%>
|
||||
<form method=POST>
|
||||
<tr>
|
||||
<td class="<%= row %>RowOddCol"><%= groups[i].getID() %></td>
|
||||
<td class="<%= row %>RowEvenCol">
|
||||
<%= groups[i].getName() %>
|
||||
</td>
|
||||
<td class="<%= row %>RowOddCol">
|
||||
<input type="hidden" name="group_id" value="<%= groups[i].getID() %>">
|
||||
<input type="submit" name="submit_edit" value="Edit...">
|
||||
</td>
|
||||
<td class="<%= row %>RowEvenCol">
|
||||
<input type="submit" name="submit_group_delete" value="Delete">
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
<%
|
||||
row = (row.equals("odd") ? "even" : "odd");
|
||||
}
|
||||
%>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</dspace:layout>
|
@@ -57,6 +57,7 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.AuthorizeManager;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
@@ -72,132 +73,146 @@ public class GroupEditServlet extends DSpaceServlet
|
||||
HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// Find out if there's a group parameter
|
||||
int groupID = UIUtil.getIntParameter(request, "group");
|
||||
Group g = null;
|
||||
|
||||
if (groupID >= 0)
|
||||
{
|
||||
g = Group.find(c, groupID);
|
||||
}
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
// Show edit page for group
|
||||
request.setAttribute("group", g);
|
||||
request.setAttribute("members", g.getMembers());
|
||||
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-edit.jsp" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// show the main page (select groups)
|
||||
showMainPage(c, request, response);
|
||||
}
|
||||
doDSPost(c, request, response);
|
||||
}
|
||||
|
||||
protected void doDSPost(Context c,
|
||||
HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// Find out if there's a group parameter
|
||||
int groupID = UIUtil.getIntParameter(request, "group_id");
|
||||
Group group = null;
|
||||
|
||||
if (groupID >= 0)
|
||||
{
|
||||
group = Group.find(c, groupID);
|
||||
}
|
||||
|
||||
// group is set
|
||||
if (group != null)
|
||||
{
|
||||
// is this user authorized to edit this group?
|
||||
AuthorizeManager.authorizeAction(c, group, Constants.ADD);
|
||||
|
||||
String button = UIUtil.getSubmitButton(request, "submit");
|
||||
|
||||
// just chosen a group to edit - get group and pass it to group-edit.jsp
|
||||
if( button.equals("submit_edit") || button.equals("submit_add_eperson_cancel") )
|
||||
{
|
||||
// just chosen a group to edit - get group and pass it to group-edit.jsp
|
||||
Group group = Group.find(c, UIUtil.getIntParameter(request, "group_id"));
|
||||
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-edit.jsp" );
|
||||
JSPManager.showJSP(request, response, "/tools/group-edit.jsp" );
|
||||
}
|
||||
else if( button.equals( "submit_add" ) )
|
||||
{
|
||||
// want to add a group - create a blank one, and pass to group_edit.jsp
|
||||
Group group = Group.create(c);
|
||||
|
||||
group.setName("new group"+group.getID());
|
||||
group.update();
|
||||
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-edit.jsp" );
|
||||
}
|
||||
// alter group's name and return to group-edit.jsp
|
||||
else if( button.equals("submit_change_name") )
|
||||
{
|
||||
// alter group's name and return to group-edit.jsp
|
||||
Group group = Group.find(c, UIUtil.getIntParameter(request, "group_id"));
|
||||
|
||||
group.setName( request.getParameter("group_name") );
|
||||
group.update();
|
||||
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-edit.jsp" );
|
||||
JSPManager.showJSP(request, response, "/tools/group-edit.jsp" );
|
||||
}
|
||||
else if( button.equals("submit_add_eperson_add") )
|
||||
// update the members of the group
|
||||
else if( button.equals("submit_members_update") )
|
||||
{
|
||||
Group group = Group.find(c, UIUtil.getIntParameter(request, "group_id"));
|
||||
int [] eperson_ids = UIUtil.getIntParameters(request,"eperson_id");
|
||||
|
||||
if( eperson_ids != null )
|
||||
{
|
||||
// now get members, and add new ones and remove missing ones
|
||||
EPerson [] members = group.getMembers();
|
||||
|
||||
for(int x=0; x<eperson_ids.length; x++)
|
||||
{
|
||||
if( eperson_ids[x] != -1 )
|
||||
{
|
||||
// add a user to the group, return to group-edit.jsp
|
||||
EPerson e = EPerson.find(c, eperson_ids[x]);
|
||||
// look for this ID in the EPerson array
|
||||
int foundIndex = -1;
|
||||
|
||||
for(int y=0; y<members.length; y++)
|
||||
{
|
||||
if(members[y].getID() == eperson_ids[x])
|
||||
{
|
||||
foundIndex = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(foundIndex != -1)
|
||||
{
|
||||
// didn't find it, add eperson
|
||||
EPerson e = EPerson.find(c, eperson_ids[x]);
|
||||
group.addMember( e );
|
||||
}
|
||||
else
|
||||
{
|
||||
// found it, clear entry in members table
|
||||
members[foundIndex] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// now go through the members array, and any that
|
||||
// weren't set to NULL are no longer members, so remove them
|
||||
for(int y=0; y<members.length; y++)
|
||||
{
|
||||
if(members[y] != null)
|
||||
{
|
||||
group.removeMember(members[y]);
|
||||
}
|
||||
}
|
||||
|
||||
group.update();
|
||||
}
|
||||
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-edit.jsp" );
|
||||
}
|
||||
else if( button.equals( "submit_add_eperson") )
|
||||
{
|
||||
// go to group-eperson-select.jsp
|
||||
Group group = Group.find(c, UIUtil.getIntParameter(request, "group_id"));
|
||||
EPerson [] epeople = EPerson.findAll(c, EPerson.EMAIL);
|
||||
|
||||
request.setAttribute("group", group );
|
||||
request.setAttribute("epeople", epeople);
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-eperson-select.jsp" );
|
||||
}
|
||||
else if( button.equals( "submit_remove_eperson" ) )
|
||||
{
|
||||
// remove the eperson, show group-edit.jsp
|
||||
Group group = Group.find(c, UIUtil.getIntParameter(request, "group_id"));
|
||||
EPerson e = EPerson.find(c,UIUtil.getIntParameter(request,"eperson_id") );
|
||||
|
||||
group.removeMember( e );
|
||||
group.update();
|
||||
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-edit.jsp" );
|
||||
JSPManager.showJSP(request, response, "/tools/group-edit.jsp" );
|
||||
}
|
||||
else if( button.equals( "submit_group_delete" ) )
|
||||
{
|
||||
// delete group, return to group-list.jsp
|
||||
Group group = Group.find(c,
|
||||
UIUtil.getIntParameter(request, "group_id"));
|
||||
// bogus authorize, only admins can do this
|
||||
AuthorizeManager.authorizeAction(c, group, Constants.WRITE);
|
||||
|
||||
// delete group, return to group-list.jsp
|
||||
group.delete();
|
||||
|
||||
showMainPage(c, request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
// all other input, show main page
|
||||
// unknown action, show main page
|
||||
showMainPage(c, request, response);
|
||||
}
|
||||
|
||||
// Show edit page for group
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
|
||||
JSPManager.showJSP(request, response, "/tools/group-edit.jsp" );
|
||||
}
|
||||
else // no group set
|
||||
{
|
||||
// want to add a group - create a blank one, and pass to group_edit.jsp
|
||||
String button = UIUtil.getSubmitButton(request, "submit");
|
||||
if( button.equals( "submit_add" ) )
|
||||
{
|
||||
group = Group.create(c);
|
||||
|
||||
group.setName("new group"+group.getID());
|
||||
group.update();
|
||||
|
||||
request.setAttribute("group", group);
|
||||
request.setAttribute("members", group.getMembers());
|
||||
JSPManager.showJSP(request, response, "/tools/group-edit.jsp" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// show the main page (select groups)
|
||||
showMainPage(c, request, response);
|
||||
}
|
||||
}
|
||||
c.complete();
|
||||
|
||||
}
|
||||
@@ -213,7 +228,7 @@ public class GroupEditServlet extends DSpaceServlet
|
||||
|
||||
request.setAttribute("groups", groups);
|
||||
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/group-list.jsp" );
|
||||
JSPManager.showJSP(request, response, "/tools/group-list.jsp" );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user