git-svn-id: http://scm.dspace.org/svn/repo/trunk@2209 9c30dcfa-912a-0410-8fc2-9e0234be79fd

This commit is contained in:
Stuart Lewis
2007-09-20 15:24:32 +00:00
parent 4a85015b9c
commit 567a726316
4 changed files with 68 additions and 19 deletions

View File

@@ -39,34 +39,27 @@
*/ */
package org.dspace.app.webui.servlet; package org.dspace.app.webui.servlet;
import java.io.IOException; import com.sun.mail.smtp.SMTPAddressFailedException;
import java.sql.SQLException;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.app.webui.util.Authenticate;
import org.dspace.app.webui.util.JSPManager; import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil; import org.dspace.app.webui.util.UIUtil;
import org.dspace.authenticate.AuthenticationManager; import org.dspace.authenticate.AuthenticationManager;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.core.ConfigurationManager; import org.dspace.core.*;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.eperson.AccountManager; import org.dspace.eperson.AccountManager;
import org.dspace.eperson.EPerson; import org.dspace.eperson.EPerson;
import com.sun.mail.smtp.SMTPAddressFailedException; import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Hashtable; import java.util.Hashtable;
import javax.naming.*;
import javax.naming.directory.*;
/** /**
* Servlet for handling user registration and forgotten passwords. * Servlet for handling user registration and forgotten passwords.
@@ -534,6 +527,43 @@ public class RegisterServlet extends DSpaceServlet
eperson.update(); eperson.update();
request.setAttribute("eperson", eperson); request.setAttribute("eperson", eperson);
// Notify of new user registration
String notifyRecipient = ConfigurationManager.getProperty("registration.notify");
if (notifyRecipient == null) {
notifyRecipient = "";
}
notifyRecipient = notifyRecipient.trim();
if(!notifyRecipient.equals(""))
{
try
{
Email adminEmail = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "registration_notify"));
adminEmail.addRecipient(notifyRecipient);
adminEmail.addArgument(eperson.getFirstName() + " " + eperson.getLastName()); // Name
adminEmail.addArgument(eperson.getEmail()); // Email
adminEmail.setReplyTo(eperson.getEmail());
adminEmail.send();
log.info(LogManager.getHeader(context, "registerion_alert", "user="
+ eperson.getEmail()));
}
catch (MessagingException me)
{
log.warn(LogManager.getHeader(context,
"error_emailing_administrator", ""), me);
JSPManager.showInternalError(request, response);
}
}
JSPManager.showJSP(request, response, "/register/registered.jsp"); JSPManager.showJSP(request, response, "/register/registered.jsp");
context.complete(); context.complete();
} }

View File

@@ -66,6 +66,7 @@ SF Patch 1794700 Bug fix for stat-monthly and stat-report-monthly
(Chris yates) (Chris yates)
- SF Patch #1724330 Removes "null" being displayed in community-home.jsp - SF Patch #1724330 Removes "null" being displayed in community-home.jsp
- SF Patch #1763535 Alert DSpace administrator of new user registration
(Robert Tansley / Stuart Lewis) (Robert Tansley / Stuart Lewis)
- SF Patch #1587225 Google and html sitemap generator - SF Patch #1587225 Google and html sitemap generator

View File

@@ -79,6 +79,9 @@ mail.admin = dspace-help@myu.edu
# Recipient for server errors and alerts # Recipient for server errors and alerts
# alert.recipient = email-address-here # alert.recipient = email-address-here
# Recipient for new user registration emails
# registration.notify.new = email-address-here
##### File Storage ###### ##### File Storage ######

View File

@@ -0,0 +1,15 @@
# Registration notification email
#
# Parameters: {0} Name:
# {1} Email:
# {2} Registration Date:
#
# See org.dspace.core.Email for information on the format of this file.
#
Subject: DSpace: Registration Notification
A new user has registered on the system:
Name: {0}
Email: {1}
Date: {2}