mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-23 18:03:11 +00:00
- Added <dspace:selecteperson> JSP tag, similar-ish to HTML <SELECT>
- Updated collection creation wizard, eperson admin tool to use it git-svn-id: http://scm.dspace.org/svn/repo/trunk@805 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -375,7 +375,7 @@
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>eperson-list</servlet-name>
|
||||
<url-pattern>/dspace-admin/eperson-list</url-pattern>
|
||||
<url-pattern>/tools/eperson-list</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
|
@@ -265,6 +265,35 @@
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<name>selecteperson</name>
|
||||
<tagclass>org.dspace.app.webui.jsptag.SelectEPersonTag</tagclass>
|
||||
<info>
|
||||
Tag for producing an e-person select widget in a form. Somewhat
|
||||
analogous to the HTML SELECT element. An input
|
||||
field is produced with a button which pops up a window from which
|
||||
e-people can be selected. Selected e-epeople are added to the field
|
||||
in the form. If the selector is for multiple e-people, a 'remove
|
||||
selected from list' button is also added.
|
||||
|
||||
On any form that has a selecteperson tag (only one allowed per page),
|
||||
you need to include the following Javascript code on all of the submit
|
||||
buttons, to ensure that the e-people IDs are posted and that the popup
|
||||
window is close:
|
||||
|
||||
onclick="javascript:finishEPerson();"
|
||||
</info>
|
||||
<attribute>
|
||||
<name>multiple</name>
|
||||
<required>true</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>selected</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<name>sfxlink</name>
|
||||
|
@@ -66,18 +66,26 @@
|
||||
<form method=POST>
|
||||
|
||||
<center>
|
||||
<table width="70%">
|
||||
<table width="90%">
|
||||
<tr>
|
||||
<td>
|
||||
<td colspan=3 align=center>
|
||||
<input type="submit" name="submit_add" value="Add EPerson...">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=3><strong>OR</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" name="submit_browse" value="Browse EPeople...">
|
||||
<dspace:selecteperson multiple="false" />
|
||||
</td>
|
||||
<td>
|
||||
then <input type="submit" name="submit_edit" value="Edit..." onclick="javascript:finishEPerson();">
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="submit_delete" value="Delete..." onclick="javascript:finishEPerson();">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</center>
|
||||
|
||||
|
@@ -146,21 +146,13 @@ incoming submissions, but will not be able to reject them.</P>
|
||||
<tr>
|
||||
<td width="40%"></td>
|
||||
<td class="submitFormHelp">
|
||||
Click on the 'Choose E-people' button to choose e-people to add to the list.</td>
|
||||
Click on the 'Select E-people' button to choose e-people to add to the list.</td>
|
||||
<td width="40%"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td align=center class="submitFormLabel">
|
||||
<select size=10 name="epersonList" multiple>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td align=center>
|
||||
<input type=button value="Choose E-people" onclick="javascript:eperson_window();">
|
||||
<input type=button value="Remove Selected" onclick="javascript:removeSelected(epersonList);">
|
||||
<dspace:selecteperson multiple="yes" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -178,7 +170,7 @@ incoming submissions, but will not be able to reject them.</P>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<input type=submit name="submit_next" value="Next >" onclick="javascript:selectList(epersonList);">
|
||||
<input type=submit name="submit_next" value="Next >" onclick="javascript:finishEPerson();">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@@ -63,63 +63,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="<%= request.getContextPath() %>/styles.css.jsp">
|
||||
<link rel="shortcut icon" href="<%= request.getContextPath() %>/favicon.ico" type="image/x-icon">
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
|
||||
<!-- Begin
|
||||
// Open eperson popup window
|
||||
function eperson_window()
|
||||
{
|
||||
var newWindow;
|
||||
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=640,height=480';
|
||||
newWindow = window.open("<%= request.getContextPath() %>/dspace-admin/eperson-list", "dspace_epeople", props);
|
||||
}
|
||||
|
||||
// Add to list of e-people on this page -- invoked by eperson popup window
|
||||
function addEPerson(id, email, name)
|
||||
{
|
||||
var newplace = window.document.forms[0].epersonList.options.length;
|
||||
|
||||
// First we check to see if e-person is already there
|
||||
for (var i = 0; i < window.document.forms[0].epersonList.options.length; i++)
|
||||
{
|
||||
if (window.document.forms[0].epersonList.options[i].value == id)
|
||||
{
|
||||
newplace = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (newplace > -1)
|
||||
{
|
||||
window.document.forms[0].epersonList.options[newplace] = new Option(name + " (" + email + ")", id);
|
||||
}
|
||||
}
|
||||
|
||||
// Marks all the epeople as selected for the submit button.
|
||||
function selectList()
|
||||
{
|
||||
sourceList = window.document.forms[0].epersonList;
|
||||
for(var i = 0; i < sourceList.options.length; i++)
|
||||
{
|
||||
if (sourceList.options[i] != null)
|
||||
sourceList.options[i].selected = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deletes the selected items of supplied list.
|
||||
function removeSelected(sourceList)
|
||||
{
|
||||
var maxCnt = sourceList.options.length;
|
||||
for(var i = maxCnt - 1; i >= 0; i--)
|
||||
{
|
||||
if ((sourceList.options[i] != null) && (sourceList.options[i].selected == true))
|
||||
{
|
||||
sourceList.options[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// End -->
|
||||
</script>
|
||||
<SCRIPT LANGUAGE="JavaScript" src="<%= request.getContextPath() %>/utils.js"></script>
|
||||
</head>
|
||||
|
||||
<%-- HACK: leftmargin, topmargin: for non-CSS compliant Microsoft IE browser --%>
|
||||
|
@@ -47,6 +47,7 @@
|
||||
- epeople - EPerson[] - all epeople to browse
|
||||
- sortby - Integer - field to sort by (constant from EPerson.java)
|
||||
- first - Integer - index of first eperson to display
|
||||
- multiple - if non-null, this is for selecting multiple epeople
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
@@ -62,6 +63,7 @@
|
||||
(EPerson[]) request.getAttribute("epeople");
|
||||
int sortBy = ((Integer)request.getAttribute("sortby" )).intValue();
|
||||
int first = ((Integer)request.getAttribute("first")).intValue();
|
||||
boolean multiple = (request.getAttribute("multiple") != null);
|
||||
|
||||
// Make sure we won't run over end of list
|
||||
int last = first + PAGESIZE;
|
||||
@@ -88,8 +90,8 @@
|
||||
if (sortBy == EPerson.EMAIL) sortByParam = "email";
|
||||
if (sortBy == EPerson.ID) sortByParam = "id";
|
||||
|
||||
String jumpLink = request.getContextPath() + "/dspace-admin/eperson-list?sortby=" + sortByParam + "&first=";
|
||||
String sortLink = request.getContextPath() + "/dspace-admin/eperson-list?first=" + first + "&sortby=";
|
||||
String jumpLink = request.getContextPath() + "/dspace-admin/eperson-list?multiple=" + multiple + "&sortby=" + sortByParam + "&first=";
|
||||
String sortLink = request.getContextPath() + "/dspace-admin/eperson-list?multiple=" + multiple + "&first=" + first + "&sortby=";
|
||||
%>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
@@ -108,6 +110,17 @@ function addEPerson(id, email, name)
|
||||
{
|
||||
self.opener.addEPerson(id, email, name);
|
||||
}
|
||||
|
||||
// Clear selected items from main e-people list
|
||||
function clearEPeople()
|
||||
{
|
||||
var list = self.opener.document.forms[0].eperson_id;
|
||||
while (list.options.length > 0)
|
||||
{
|
||||
list.options[0] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// End -->
|
||||
</script>
|
||||
</head>
|
||||
@@ -140,6 +153,15 @@ function addEPerson(id, email, name)
|
||||
|
||||
<%
|
||||
String row = "even";
|
||||
|
||||
String buttonText = (multiple ? "Add" : "Select");
|
||||
// If this is a dialogue to select a *single* e-person, we want
|
||||
// to clear any existing entry in the e-person list, and
|
||||
// to close this window when a 'select' button is clicked
|
||||
String clearList = (multiple ? "" : "clearEPeople();");
|
||||
String closeWindow = (multiple ? "" : "window.close();");
|
||||
|
||||
|
||||
for (int i = first; i <= last; i++)
|
||||
{
|
||||
EPerson e = epeople[i];
|
||||
@@ -147,7 +169,7 @@ function addEPerson(id, email, name)
|
||||
String fullname = e.getFullName().replace('\'', ' ');
|
||||
%>
|
||||
<tr>
|
||||
<td class="<%= row %>RowOddCol"><input type=button value="Add" onClick="javascript:addEPerson(<%= e.getID() %>, '<%= e.getEmail() %>', '<%= fullname %>');"></td>
|
||||
<td class="<%= row %>RowOddCol"><input type=button value="<%= buttonText %>" onClick="javascript:<%= clearList %>addEPerson(<%= e.getID() %>, '<%= e.getEmail() %>', '<%= fullname %>');<%= closeWindow %>"></td>
|
||||
<td class="<%= row %>RowEvenCol"><%= e.getID() %></td>
|
||||
<td class="<%= row %>RowOddCol"><%= e.getEmail() %></td>
|
||||
<td class="<%= row %>RowEvenCol">
|
116
dspace/jsp/utils.js
Normal file
116
dspace/jsp/utils.js
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* utils.js
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2004, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Utility Javascript methods for DSpace
|
||||
*/
|
||||
|
||||
// Popup window - here so it can be referred to by several methods
|
||||
var popupWindow;
|
||||
|
||||
// =========================================================
|
||||
// Methods for e-person popup window
|
||||
// =========================================================
|
||||
|
||||
// Add to list of e-people on this page -- invoked by eperson popup window
|
||||
function addEPerson(id, email, name)
|
||||
{
|
||||
var newplace = window.document.forms[0].eperson_id.options.length;
|
||||
|
||||
// First we check to see if e-person is already there
|
||||
for (var i = 0; i < window.document.forms[0].eperson_id.options.length; i++)
|
||||
{
|
||||
if (window.document.forms[0].eperson_id.options[i].value == id)
|
||||
{
|
||||
newplace = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (newplace > -1)
|
||||
{
|
||||
window.document.forms[0].eperson_id.options[newplace] = new Option(name + " (" + email + ")", id);
|
||||
}
|
||||
}
|
||||
|
||||
// This needs to be invoked in the 'onClick' javascript event for buttons
|
||||
// on pages with a dspace:selecteperson element in them
|
||||
function finishEPerson()
|
||||
{
|
||||
selectAll(window.document.forms[0].eperson_id);
|
||||
popupWindow.close();
|
||||
}
|
||||
|
||||
|
||||
// =========================================================
|
||||
// Miscellaneous utility methods
|
||||
// =========================================================
|
||||
|
||||
// Open a popup window (or bring to front if already open)
|
||||
function popup_window(winURL, winName)
|
||||
{
|
||||
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=640,height=480';
|
||||
popupWindow = window.open(winURL, winName, props);
|
||||
popupWindow.focus();
|
||||
}
|
||||
|
||||
|
||||
// Select all options in a <SELECT> list
|
||||
function selectAll(sourceList)
|
||||
{
|
||||
for(var i = 0; i < sourceList.options.length; i++)
|
||||
{
|
||||
if (sourceList.options[i] != null)
|
||||
sourceList.options[i].selected = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deletes the selected options from supplied <SELECT> list
|
||||
function removeSelected(sourceList)
|
||||
{
|
||||
var maxCnt = sourceList.options.length;
|
||||
for(var i = maxCnt - 1; i >= 0; i--)
|
||||
{
|
||||
if ((sourceList.options[i] != null) && (sourceList.options[i].selected == true))
|
||||
{
|
||||
sourceList.options[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
181
dspace/src/org/dspace/app/webui/jsptag/SelectEPersonTag.java
Normal file
181
dspace/src/org/dspace/app/webui/jsptag/SelectEPersonTag.java
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* SelectEPersonTag
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.dspace.app.webui.jsptag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.dspace.eperson.EPerson;
|
||||
|
||||
/**
|
||||
* <P>Tag for producing an e-person select widget in a form. Somewhat
|
||||
* analogous to the HTML SELECT element. An input
|
||||
* field is produced with a button which pops up a window from which
|
||||
* e-people can be selected. Selected e-epeople are added to the field
|
||||
* in the form. If the selector is for multiple e-people, a 'remove
|
||||
* selected from list' button is also added.</P>
|
||||
*
|
||||
* <P>On any form that has a selecteperson tag (only one allowed per page),
|
||||
* you need to include the following Javascript code on all of the submit
|
||||
* buttons, to ensure that the e-people IDs are posted and that the popup
|
||||
* window is closed:</P>
|
||||
*
|
||||
* <P><code>onclick="javascript:finishEPerson();"</code></P>
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class SelectEPersonTag extends TagSupport
|
||||
{
|
||||
/** Multiple e-people? */
|
||||
private boolean multiple;
|
||||
|
||||
/** Which eperson/epeople are initially in the list? */
|
||||
private EPerson[] epeople;
|
||||
|
||||
|
||||
public SelectEPersonTag()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter for multiple attribute
|
||||
*
|
||||
* @param s attribute from JSP
|
||||
*/
|
||||
public void setMultiple(String s)
|
||||
{
|
||||
if (s != null && (s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("true")))
|
||||
{
|
||||
multiple = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiple = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for e-people in list
|
||||
*
|
||||
* @param e attribute from JSP
|
||||
*/
|
||||
public void setMultiple(Object e)
|
||||
{
|
||||
if (e instanceof EPerson)
|
||||
{
|
||||
epeople = new EPerson[1];
|
||||
epeople[0] = (EPerson) e;
|
||||
}
|
||||
else if(e instanceof EPerson[])
|
||||
{
|
||||
epeople = (EPerson[]) e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void release()
|
||||
{
|
||||
multiple = false;
|
||||
epeople = null;
|
||||
}
|
||||
|
||||
|
||||
public int doStartTag()
|
||||
throws JspException
|
||||
{
|
||||
try
|
||||
{
|
||||
JspWriter out = pageContext.getOut();
|
||||
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
|
||||
|
||||
out.print("<table><tr><td colspan=2><select multiple name=\"eperson_id\" SIZE=");
|
||||
out.print(multiple ? "10" : "1");
|
||||
out.println(">");
|
||||
|
||||
if (epeople != null)
|
||||
{
|
||||
for (int i = 0; i < epeople.length; i++)
|
||||
{
|
||||
out.print("<OPTION VALUE=\"" + epeople[i].getID() + "\">");
|
||||
out.print(epeople[i].getFullName() + " (" + epeople[i].getEmail() + ")");
|
||||
out.println("</OPTION>");
|
||||
}
|
||||
}
|
||||
|
||||
out.print("</SELECT></TD>");
|
||||
|
||||
if (multiple)
|
||||
{
|
||||
out.print("</TR><TR><TD width=\"50%\" align=\"center\">");
|
||||
}
|
||||
else
|
||||
{
|
||||
out.print("<TD>");
|
||||
}
|
||||
|
||||
String p = (multiple ? "people" : "person");
|
||||
out.print("<input type=\"button\" value=\"Select E-" + p + "...\" onclick=\"javascript:popup_window('" +
|
||||
req.getContextPath() + "/tools/eperson-list?multiple=" + multiple +
|
||||
"', 'eperson_popup');\">");
|
||||
|
||||
if (multiple)
|
||||
{
|
||||
out.print("</TD><TD width=\"50%\" align=\"center\">");
|
||||
out.print("<input type=\"button\" value=\"Remove Selected\" onclick=\"javascript:removeSelected(window.document.forms[0].eperson_id);\">");
|
||||
}
|
||||
|
||||
out.println("</TD></TR></TABLE>");
|
||||
}
|
||||
catch (IOException ie)
|
||||
{
|
||||
throw new JspException(ie);
|
||||
}
|
||||
|
||||
return SKIP_BODY;
|
||||
}
|
||||
}
|
@@ -343,7 +343,7 @@ public class CollectionWizardServlet extends DSpaceServlet
|
||||
}
|
||||
|
||||
// Add people from the form to the group
|
||||
int[] ids = UIUtil.getIntParameters(request, "epersonList");
|
||||
int[] ids = UIUtil.getIntParameters(request, "eperson_id");
|
||||
|
||||
if (ids != null)
|
||||
{
|
||||
|
@@ -45,7 +45,6 @@ package org.dspace.app.webui.servlet.admin;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -56,7 +55,6 @@ import org.dspace.app.webui.util.JSPManager;
|
||||
import org.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.eperson.EPerson;
|
||||
|
||||
/**
|
||||
@@ -75,10 +73,7 @@ public class EPersonAdminServlet extends DSpaceServlet
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
doDSPost(context, request, response);
|
||||
|
||||
// GET just displays the list of e-people
|
||||
//showMain(context, request, response);
|
||||
showMain(context, request, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +93,6 @@ public class EPersonAdminServlet extends DSpaceServlet
|
||||
e.setEmail("newuser"+e.getID());
|
||||
e.update();
|
||||
|
||||
//showEPeople(context, request, response);
|
||||
|
||||
request.setAttribute("eperson", e);
|
||||
|
||||
JSPManager.showJSP(request, response,
|
||||
@@ -229,58 +222,6 @@ public class EPersonAdminServlet extends DSpaceServlet
|
||||
showMain(context, request, response);
|
||||
context.complete();
|
||||
}
|
||||
else if (button.equals("submit_browse"))
|
||||
{
|
||||
// user wants to browse
|
||||
|
||||
String pageRequest = request.getParameter("page_request");
|
||||
int pageIndex = UIUtil.getIntParameter(request, "page_index");
|
||||
String sortby = request.getParameter("sortby");
|
||||
int sortField = EPerson.EMAIL; // default
|
||||
int pageSize = 50;
|
||||
|
||||
if (sortby == null)
|
||||
{
|
||||
}
|
||||
else if (sortby.equals("lastname"))
|
||||
{
|
||||
sortField = EPerson.LASTNAME;
|
||||
}
|
||||
else if (sortby.equals("id"))
|
||||
{
|
||||
sortField = EPerson.ID;
|
||||
}
|
||||
|
||||
if (pageIndex == -1)
|
||||
{
|
||||
pageIndex = 0; // default page is 0
|
||||
}
|
||||
|
||||
// get back "next" and "previous" messages
|
||||
// can also insert numbers here
|
||||
if (pageRequest != null)
|
||||
{
|
||||
if (pageRequest.equals("next"))
|
||||
{
|
||||
pageIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pageIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
EPerson[] epeople = EPerson.findAll(context, sortField);
|
||||
|
||||
int pageCount = ((epeople.length-1)/pageSize)+1;
|
||||
|
||||
request.setAttribute("epeople", epeople );
|
||||
request.setAttribute("page_size", new Integer(pageSize ));
|
||||
request.setAttribute("page_count", new Integer(pageCount));
|
||||
request.setAttribute("page_index", new Integer(pageIndex));
|
||||
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/eperson-browse.jsp");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cancel etc. pressed - show list again
|
||||
@@ -289,38 +230,6 @@ public class EPersonAdminServlet extends DSpaceServlet
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show list of E-people
|
||||
*
|
||||
* @param context Current DSpace context
|
||||
* @param request Current HTTP request
|
||||
* @param response Current HTTP response
|
||||
*/
|
||||
private void showEPeople(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// First get the sort field
|
||||
String sortFieldParam = request.getParameter("sortby");
|
||||
int sortField = EPerson.LASTNAME;
|
||||
|
||||
if (sortFieldParam != null && sortFieldParam.equals("email"))
|
||||
{
|
||||
sortField = EPerson.EMAIL;
|
||||
}
|
||||
else if (sortFieldParam != null && sortFieldParam.equals("id"))
|
||||
{
|
||||
sortField = EPerson.ID;
|
||||
}
|
||||
|
||||
EPerson[] epeople = EPerson.findAll(context, sortField);
|
||||
|
||||
request.setAttribute("epeople", epeople);
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/list-epeople.jsp");
|
||||
}
|
||||
|
||||
|
||||
private void showMain(Context c,
|
||||
HttpServletRequest request, HttpServletResponse response )
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
|
@@ -66,6 +66,9 @@ public class EPersonListServlet extends DSpaceServlet
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// Are we for selecting a single or multiple epeople?
|
||||
boolean multiple = UIUtil.getBoolParameter(request, "multiple");
|
||||
|
||||
// What are we sorting by. Lastname is default
|
||||
int sortBy = EPerson.LASTNAME;
|
||||
|
||||
@@ -95,7 +98,11 @@ public class EPersonListServlet extends DSpaceServlet
|
||||
request.setAttribute("sortby", new Integer(sortBy));
|
||||
request.setAttribute("first", new Integer(first));
|
||||
request.setAttribute("epeople", epeople);
|
||||
if (multiple)
|
||||
{
|
||||
request.setAttribute("multiple", new Boolean(true));
|
||||
}
|
||||
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/eperson-list.jsp");
|
||||
JSPManager.showJSP(request, response, "/tools/eperson-list.jsp");
|
||||
}
|
||||
}
|
||||
|
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* EditEPersonServlet.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.dspace.app.webui.servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.webui.servlet.DSpaceServlet;
|
||||
import org.dspace.app.webui.util.JSPManager;
|
||||
import org.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.eperson.EPerson;
|
||||
|
||||
/**
|
||||
* Servlet for editing and creating e-people
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class EditEPersonServlet extends DSpaceServlet
|
||||
{
|
||||
/** Logger */
|
||||
private static Logger log = Logger.getLogger(EditEPersonServlet.class);
|
||||
|
||||
|
||||
protected void doDSGet(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// GET just displays the list of e-people
|
||||
showEPeople(context, request, response);
|
||||
}
|
||||
|
||||
|
||||
protected void doDSPost(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
String button = UIUtil.getSubmitButton(request, "submit");
|
||||
|
||||
if (button.equals("submit_update"))
|
||||
{
|
||||
// Update the metadata for an e-person
|
||||
EPerson e = EPerson.find(context,
|
||||
UIUtil.getIntParameter(request, "eperson_id"));
|
||||
|
||||
e.setEmail(request.getParameter("email").trim());
|
||||
|
||||
e.setFirstName(request.getParameter("firstname").equals("")
|
||||
? null
|
||||
: request.getParameter("firstname"));
|
||||
|
||||
e.setLastName(request.getParameter("lastname").equals("")
|
||||
? null
|
||||
: request.getParameter("lastname"));
|
||||
|
||||
// FIXME: More data-driven?
|
||||
e.setMetadata("phone",
|
||||
request.getParameter("phone").equals("")
|
||||
? null
|
||||
: request.getParameter("phone"));
|
||||
|
||||
e.setCanLogIn(request.getParameter("active") != null &&
|
||||
request.getParameter("active").equals("true"));
|
||||
|
||||
e.setRequireCertificate(
|
||||
request.getParameter("require_certificate") != null &&
|
||||
request.getParameter("require_certificate").equals("true"));
|
||||
|
||||
e.update();
|
||||
|
||||
showEPeople(context, request, response);
|
||||
context.complete();
|
||||
}
|
||||
else if (button.equals("submit_add"))
|
||||
{
|
||||
// Add a new E-person - simply add to the list, and let the user
|
||||
// edit with the main form
|
||||
EPerson e = EPerson.create(context);
|
||||
|
||||
e.update();
|
||||
|
||||
showEPeople(context, request, response);
|
||||
context.complete();
|
||||
}
|
||||
else if (button.equals("submit_delete"))
|
||||
{
|
||||
// Start delete process - go through verification step
|
||||
EPerson e = EPerson.find(context,
|
||||
UIUtil.getIntParameter(request, "eperson_id"));
|
||||
|
||||
request.setAttribute("eperson", e);
|
||||
|
||||
JSPManager.showJSP(request, response,
|
||||
"/dspace-admin/confirm-delete-eperson.jsp");
|
||||
}
|
||||
else if (button.equals("submit_confirm_delete"))
|
||||
{
|
||||
// User confirms deletion of type
|
||||
EPerson e = EPerson.find(context,
|
||||
UIUtil.getIntParameter(request, "eperson_id"));
|
||||
|
||||
e.delete();
|
||||
|
||||
showEPeople(context, request, response);
|
||||
context.complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cancel etc. pressed - show list again
|
||||
showEPeople(context, request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show list of E-people
|
||||
*
|
||||
* @param context Current DSpace context
|
||||
* @param request Current HTTP request
|
||||
* @param response Current HTTP response
|
||||
*/
|
||||
private void showEPeople(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// First get the sort field
|
||||
String sortFieldParam = request.getParameter("sortby");
|
||||
int sortField = EPerson.LASTNAME;
|
||||
|
||||
if (sortFieldParam != null && sortFieldParam.equals("email"))
|
||||
{
|
||||
sortField = EPerson.EMAIL;
|
||||
}
|
||||
else if (sortFieldParam != null && sortFieldParam.equals("id"))
|
||||
{
|
||||
sortField = EPerson.ID;
|
||||
}
|
||||
|
||||
EPerson[] epeople = EPerson.findAll(context, sortField);
|
||||
|
||||
request.setAttribute("epeople", epeople);
|
||||
JSPManager.showJSP(request, response, "/dspace-admin/list-epeople.jsp");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user