mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
JSPUI support for collection dropdown
This commit is contained in:
@@ -34,7 +34,9 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.DCDate;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.Site;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
import org.dspace.core.I18nUtil;
|
||||
@@ -201,6 +203,47 @@ public class Subscribe
|
||||
return (Collection[]) collections.toArray(collArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out which collections the currently logged in e-person can subscribe to
|
||||
*
|
||||
* @param context
|
||||
* DSpace context
|
||||
* @param eperson
|
||||
* EPerson
|
||||
* @return array of collections the currently logged in e-person can subscribe to
|
||||
*/
|
||||
public static Collection[] getAvailableSubscriptions(Context context)
|
||||
throws SQLException
|
||||
{
|
||||
return getAvailableSubscriptions(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out which collections an e-person can subscribe to
|
||||
*
|
||||
* @param context
|
||||
* DSpace context
|
||||
* @param eperson
|
||||
* EPerson
|
||||
* @return array of collections e-person can subscribe to
|
||||
*/
|
||||
public static Collection[] getAvailableSubscriptions(Context context, EPerson eperson)
|
||||
throws SQLException
|
||||
{
|
||||
Collection[] collections;
|
||||
|
||||
if (eperson != null)
|
||||
{
|
||||
context.setCurrentUser(eperson);
|
||||
}
|
||||
|
||||
Site site = (Site) Site.find(context, 0);
|
||||
|
||||
collections = Collection.findAuthorized(context, null, Constants.ADD);
|
||||
|
||||
return collections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is that e-person subscribed to that collection?
|
||||
*
|
||||
|
@@ -731,6 +731,7 @@ jsp.mydspace.request.export.migratecollection = Export (migrat
|
||||
jsp.mydspace.request.export.migrateitem = Export (migrate) Item
|
||||
jsp.mydspace.subscriptions.info1 = Your subscriptions have been updated.
|
||||
jsp.mydspace.subscriptions.info2 = To subscribe to a collection, visit the collection's home page, and click on the "Subscribe" button.
|
||||
jsp.mydspace.subscriptions.select_collection = ( Select Collection )
|
||||
jsp.mydspace.subscriptions.info3 = Below are the collections you are subscribed to. You will be sent an e-mail each day detailing new items that have become available in these collections. On days that no new items have appeared, no e-mail will be sent.
|
||||
jsp.mydspace.subscriptions.info4 = You are not currently subscribed to any collections.
|
||||
jsp.mydspace.subscriptions.remove.button = Remove All Subscriptions
|
||||
@@ -1821,4 +1822,4 @@ jsp.request.item.request-free-acess.free = Change to Open Access
|
||||
jsp.request.item.request-free-acess.name = Name:
|
||||
jsp.request.item.request-free-acess.email = E-mail:
|
||||
|
||||
org.dspace.app.webui.jsptag.ItemTag.restrict = <span class="glyphicon glyphicon-lock"> </span> Request a copy
|
||||
org.dspace.app.webui.jsptag.ItemTag.restrict = <span class="glyphicon glyphicon-lock"> </span> Request a copy
|
||||
|
@@ -14,6 +14,7 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.dspace.app.util.CollectionDropDown;
|
||||
import org.dspace.app.webui.util.JSPManager;
|
||||
import org.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -102,10 +103,14 @@ public class SubscribeServlet extends DSpaceServlet
|
||||
HttpServletResponse response, boolean updated)
|
||||
throws ServletException, IOException, SQLException
|
||||
{
|
||||
// collections the currently logged in user can subscribe to
|
||||
Collection[] avail = Subscribe.getAvailableSubscriptions(context);
|
||||
|
||||
// Subscribed collections
|
||||
Collection[] subs = Subscribe.getSubscriptions(context, context
|
||||
.getCurrentUser());
|
||||
|
||||
request.setAttribute("availableSubscriptions", avail);
|
||||
request.setAttribute("subscriptions", subs);
|
||||
request.setAttribute("updated", Boolean.valueOf(updated));
|
||||
|
||||
|
@@ -27,8 +27,11 @@
|
||||
|
||||
<%@ page import="org.dspace.content.Community" %>
|
||||
<%@ page import="org.dspace.content.Collection" %>
|
||||
<%@ page import="org.dspace.app.util.CollectionDropDown" %>
|
||||
|
||||
<%
|
||||
Collection[] availableSubscriptions =
|
||||
(Collection[]) request.getAttribute("availableSubscriptions");
|
||||
Collection[] subscriptions =
|
||||
(Collection[]) request.getAttribute("subscriptions");
|
||||
boolean updated =
|
||||
@@ -49,10 +52,27 @@
|
||||
{
|
||||
%>
|
||||
<p><strong><fmt:message key="jsp.mydspace.subscriptions.info1"/></strong></p>
|
||||
<p><fmt:message key="jsp.mydspace.subscriptions.info2"/></p>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<p><fmt:message key="jsp.mydspace.subscriptions.info2"/></p>
|
||||
<form class="form-group" action="<%= request.getContextPath() %>/submit" method="post">
|
||||
|
||||
<select id="available-subscriptions" class="ds-select-field" name="collection">
|
||||
<option value="-1">( Vyberte kolekci )</option>
|
||||
<%
|
||||
for (int i = 0; i < availableSubscriptions.length; i++)
|
||||
{
|
||||
%>
|
||||
<option value="<%= availableSubscriptions[i].getID() %>"><%= CollectionDropDown.collectionPath(availableSubscriptions[i], 0) %></option>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</select>
|
||||
<input class="btn btn-sm btn-info" type="submit" name="submit_subscribe" value="<fmt:message key="jsp.collection-home.subscribe"/>" />
|
||||
|
||||
</form>
|
||||
|
||||
<%
|
||||
if (subscriptions.length > 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user