You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by pa...@apache.org on 2001/11/19 02:44:34 UTC
cvs commit: jakarta-jetspeed/webapp/WEB-INF/templates/vm/emails NewUserConfirmation.vm
paulsp 01/11/18 17:44:34
Modified: src/java/org/apache/jetspeed/modules/actions
SendConfirmationEmail.java
webapp/WEB-INF/conf JetspeedResources.properties
webapp/WEB-INF/templates/vm/emails NewUserConfirmation.vm
Log:
Made changes to simplify the he configuration and internationalization of the
New user confirmation email.
SendConfirmationEmail.java
o Removed deprecated Criteria parameter in SimpleEmail
o Moved Email header settings to the email template file
JetspeedResources.properties
o Removed confirm.email.subject. Subject now set in email template file
NewUserConfirmation.vm
o Set fields in the email header
o Use the jetspeed properties confirm.email.name and confirm.email.from
o Any internationalization can be done in this template
Revision Changes Path
1.13 +17 -37 jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/SendConfirmationEmail.java
Index: SendConfirmationEmail.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/SendConfirmationEmail.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SendConfirmationEmail.java 2001/11/16 03:46:56 1.12
+++ SendConfirmationEmail.java 2001/11/19 01:44:34 1.13
@@ -70,8 +70,7 @@
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.DynamicURI;
import org.apache.turbine.util.mail.SimpleEmail;
-import org.apache.turbine.util.mail.Email;
-import org.apache.turbine.util.db.Criteria;
+//import org.apache.turbine.util.mail.Email;
import org.apache.turbine.util.Log;
// turbine velocity
@@ -81,60 +80,40 @@
import org.apache.velocity.context.Context;
/**
- This action will attempt to send a confirmation email to the user.
- This class is used in two places, the first one is for new users.
- The second is where a user is updating their information after they
- have already created their account. If they are updating and they change
- their email address, then we want to re-confirm it to prevent people from
- screwing up their email address.
-*/
+ * This action will attempt to send a confirmation email to the user.
+ * This class is used in two places, the first one is for new users.
+ * The second is where a user is updating their information after they
+ * have already created their account. If they are updating and they change
+ * their email address, then we want to re-confirm it to prevent people from
+ * screwing up their email address.
+ *
+ *@author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
+ */
public class SendConfirmationEmail extends Action
{
public void doPerform( RunData data ) throws Exception
{
- String username = data.getParameters().getString("username", "");
- String password = data.getParameters().getString("password", "");
-
- User user = JetspeedSecurity.getUser(username);
-
- String email = data.getParameters().getString("email", "");
- String firstname = data.getParameters().getString("firstname", "");
- String lastname = data.getParameters().getString("lastname", "");
- String nextscreen = data.getParameters().getString("nextscreen", "");
- String secretkey = user.getConfirmed();
-
+ User user = JetspeedSecurity.getUser(data.getParameters().getString("username", ""));
DynamicURI url = new DynamicURI(data)
.addPathInfo(JetspeedResources.PATH_TEMPLATE_KEY, "ConfirmRegistration")
- .addPathInfo("username", username )
- .addPathInfo("secretkey", secretkey)
- .addPathInfo("password", password );
-
- Criteria crit = new Criteria();
- String sender = JetspeedResources.getString("confirm.email.from");
- crit.add ( Email.SENDER_EMAIL, sender );
- String senderName = JetspeedResources.getString("confirm.email.name");
- crit.add ( Email.SENDER_NAME, senderName );
- crit.add ( Email.RECEIVER_EMAIL, email );
- crit.add ( Email.RECEIVER_NAME, firstname + " " + lastname );
- // FIXME: Need to get language specific subject for e-mail
- crit.add ( Email.EMAIL_SUBJECT, JetspeedResources
- .getString("confirm.email.subject") );
+ .addPathInfo("username", user.getUserName())
+ .addPathInfo("secretkey", user.getConfirmed())
+ .addPathInfo("password", user.getPassword());
try
{
//build body via template
StringWriter email_body = new StringWriter();
Context emailContext = TurbineVelocity.getContext();
+ SimpleEmail se = new SimpleEmail();
emailContext.put( "data", data );
emailContext.put( "user", user );
emailContext.put("config",new JetspeedResources());
emailContext.put("urltojetspeed",url);
- emailContext.put("secretkey",secretkey);
+ emailContext.put("email",se);
String templateFile = JetspeedResources.getString("confirm.email.template");
String templatePath = TemplateLocator.locateEmailTemplate(data, templateFile);
TurbineVelocity.handleRequest(emailContext, templatePath, email_body);
- SimpleEmail se = new SimpleEmail(crit);
- emailContext.put("email",se);
se.setMsg( email_body.toString() );
Properties props = System.getProperties();
@@ -143,6 +122,7 @@
props.put("mail.smtp.host", mailServerMachine);
se.send();
+
data.setMessage (Localization.getString("SENDCONFIRMATIONEMAIL_SENT"));
}
catch ( Exception e )
1.45 +2 -3 jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
Index: JetspeedResources.properties
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- JetspeedResources.properties 2001/11/16 03:46:56 1.44
+++ JetspeedResources.properties 2001/11/19 01:44:34 1.45
@@ -1,7 +1,7 @@
################################################################################
# Jetspeed Configuration
# Author: Kevin A. Burton (burton@apache.org)
-# $Id: JetspeedResources.properties,v 1.44 2001/11/16 03:46:56 paulsp Exp $
+# $Id: JetspeedResources.properties,v 1.45 2001/11/19 01:44:34 paulsp Exp $
################################################################################
# This is the main file you will need to configuration Jetspeed. If there are
# any secondary files they will be pointed to from this file.
@@ -407,7 +407,6 @@
mail.server=localhost
confirm.email.from=Postmaster@localhost
confirm.email.name=Jetspeed Administrator
-confirm.email.subject=Jetspeed registration
confirm.email.enable=false
confirm.email.template=NewUserConfirmation.vm
@@ -426,5 +425,5 @@
# Cache-Control = "max-age: n" where n is the number of seconds
# Last-Modified = (current time)
# Expires = (current time + n seconds)
-http.lifetime=5
+http.lifetime=0
1.2 +11 -5 jakarta-jetspeed/webapp/WEB-INF/templates/vm/emails/NewUserConfirmation.vm
Index: NewUserConfirmation.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/emails/NewUserConfirmation.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NewUserConfirmation.vm 2001/11/16 03:46:56 1.1
+++ NewUserConfirmation.vm 2001/11/19 01:44:34 1.2
@@ -1,13 +1,19 @@
-Dear $user.FirstName $user.LastName,
+## Set Email headers
+#set ($ignored = $email.addTo($user.Email, "$!{user.FirstName} $!{user.LastName}") )
+#set ($ignored = $email.setFrom($config.getString("confirm.email.from"),$config.getString("confirm.email.name") ))
+#set ($ignored = $email.setSubject("Jetspeed new user registration"))
+##
+Dear $!{user.FirstName} $!{user.LastName},
Welcome to the Jetspeed Portal from Apache. Your new account has been
created. Please login using the following secret key to confirm you
registration:
- $secretkey
+ ${user.Confirmed}
+#if (${urltojetspeed})
You can go to the following URL to confirm your account:
- $urltojetspeed
+ ${urltojetspeed}
+#end
Thank you,
-Jetspeed Portal Administrator
-
+$config.getString("confirm.email.name")
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>