implemented quick E-mail and SIG invitation emails

This commit is contained in:
Eric J. Bowersox 2001-02-25 07:42:11 +00:00
parent 680b84b9d8
commit 129b69973b
18 changed files with 662 additions and 38 deletions

5
TODO
View File

@ -3,8 +3,6 @@ Lots!
- Unimplemented functions on the SIG Administration page: - Unimplemented functions on the SIG Administration page:
Set SIG Features (sigadmin, command=F) Set SIG Features (sigadmin, command=F)
- Implement SIG invitations ("Invite" button on the profile).
- Unimplemented functions in the system admin menu: - Unimplemented functions in the system admin menu:
Set Global Parameters Set Global Parameters
View/Edit Banned Users View/Edit Banned Users
@ -24,9 +22,6 @@ Lots!
We may include a welcome message up top to be displayed if the user's not We may include a welcome message up top to be displayed if the user's not
logged in. logged in.
- Implement quick e-mail from the user profile display (engine support and
UI).
- Slippage during posting is still untested. - Slippage during posting is still untested.
- Not everybody likes purple. Provide a way to change the default colors. - Not everybody likes purple. Provide a way to change the default colors.

View File

@ -75,6 +75,11 @@
<!-- This section holds "stock messages" with replaceable parameters that may <!-- This section holds "stock messages" with replaceable parameters that may
be fed to emailed output. --> be fed to emailed output. -->
<messages> <messages>
<!-- A "signature" that gets appended to emailed messages. -->
<signature>
Venice - community services, conferencing and more. http://venice.sourceforge.net
</signature>
<!-- This is the message sent out with the email confirmation number. --> <!-- This is the message sent out with the email confirmation number. -->
<!-- Parameters: $USERNAME - account user name, $CONFNUM - confirmation number --> <!-- Parameters: $USERNAME - account user name, $CONFNUM - confirmation number -->
<email-confirm> <email-confirm>
@ -102,6 +107,48 @@ please contact the server administrator for further assistance.
-- The Management -- The Management
</reminder> </reminder>
<!-- Invitation message to a public SIG -->
<!-- Parameters: $SIGNAME = name of SIG, $SIGALIAS = alias of SIG, $PERSONAL = personal message,
$FULLNAME = name of inviter, $USERNAME = user name of inviter -->
<invite-public>
Hi! I would like to invite you to join the "$SIGNAME" Special Interest Group (SIG) on the Venice
conferencing system. To do so, you must register as a user, which is absolutely free! Just point
your Web browser at &lt;http://delenn:8080/venice/sig/$SIGALIAS&gt; and click the "Create Account" link
at the top of the page, or click the "Log In" link if you already have a Venice account. Once you have
completed the process, click the "Join Now" button. You will then be able to take part in the conferences
that are going on in the SIG.
$PERSONAL
Hope to see you in "$SIGNAME" soon!
-- $FULLNAME (Venice user ID: $USERNAME)
</invite-public>
<!-- Invitation message to a private SIG -->
<!-- Parameters: $SIGNAME = name of SIG, $SIGALIAS = alias of SIG, $JOINKEY = join key for SIG,
$PERSONAL = personal message, $FULLNAME = name of inviter,
$USERNAME = user name of inviter -->
<invite-private>
Hi! I would like to invite you to join the "$SIGNAME" Special Interest Group (SIG) on the Venice
conferencing system. To do so, you must register as a user, which is absolutely free! Just point
your Web browser at &lt;http://delenn:8080/venice/sig/$SIGALIAS&gt; and click the "Create Account" link
at the top of the page, or click the "Log In" link if you already have a Venice account. Once you have
completed the process, click the "Join Now" button. You will be prompted for the "password" for this
SIG, which is "$JOINKEY". You will then be able to take part in the conferences that are going on in the SIG.
$PERSONAL
Hope to see you in "$SIGNAME" soon!
-- $FULLNAME (Venice user ID: $USERNAME)
</invite-private>
<!-- Subject line for invitation messages -->
<!-- Parameters: $SIGNAME = name of SIG -->
<subj-invite>Invitation to "$SIGNAME" SIG</subj-invite>
</messages> </messages>
</venice-config> </venice-config>

View File

@ -162,4 +162,9 @@ public interface SIGContext extends SearchMode
public abstract void delete() throws DataException, AccessError; public abstract void delete() throws DataException, AccessError;
public abstract void sendInvitation(String address, String personal_message)
throws AccessError, DataException, EmailException;
public abstract boolean canSendInvitation();
} // end interface SIGContext } // end interface SIGContext

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -71,4 +71,11 @@ public interface UserProfile
public abstract String getDescription(); public abstract String getDescription();
public abstract boolean isAnonymous();
public abstract boolean canSendQuickEmail();
public abstract void sendQuickEmail(String subject, String text)
throws AccessError, DataException, EmailException;
} // end interface UserProfile } // end interface UserProfile

View File

@ -1458,6 +1458,24 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end userIsAnonymous } // end userIsAnonymous
public String realUserName()
{
return sig.realUserName();
} // end realUserName
public String realEmailAddress() throws DataException
{
return sig.realEmailAddress();
} // end realEmailAddress
public String realFullName() throws DataException
{
return sig.realFullName();
} // end realFullName
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface SIGBackend * Implementations from interface SIGBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@ package com.silverwrist.venice.core.impl;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
import com.silverwrist.venice.security.Capability; import com.silverwrist.venice.security.Capability;
import com.silverwrist.venice.security.DefaultLevels; import com.silverwrist.venice.security.DefaultLevels;
@ -387,7 +388,7 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
conn = datapool.getConnection(); conn = datapool.getConnection();
// load the profile for the user // load the profile for the user
return new UserProfileImpl(engine,conn,getSIGData().getHostUID(), return new UserProfileImpl(engine,user,conn,getSIGData().getHostUID(),
Capability.canSeeHiddenContactFields(user.realBaseLevel())); Capability.canSeeHiddenContactFields(user.realBaseLevel()));
} // end try } // end try
@ -1221,6 +1222,55 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
} // end delete } // end delete
public void sendInvitation(String address, String personal_message)
throws AccessError, DataException, EmailException
{
if (user.userIsAnonymous())
throw new AccessError("You must be logged in to send an invitation.");
SIGData my_sig = getSIGData();
my_sig.testMembership(level,is_member);
// Prepare the message text to be sent to the user.
boolean is_pub = my_sig.isPublicSIG();
String msg = engine.getStockMessage(is_pub ? "invite-public" : "invite-private");
String signame = my_sig.getName();
msg = StringUtil.replaceAllInstances(msg,"$SIGNAME",signame);
msg = StringUtil.replaceAllInstances(msg,"$SIGALIAS",my_sig.getAlias());
if (!is_pub)
msg = StringUtil.replaceAllInstances(msg,"$JOINKEY",my_sig.getJoinKey());
msg = StringUtil.replaceAllInstances(msg,"$PERSONAL",personal_message);
msg = StringUtil.replaceAllInstances(msg,"$FULLNAME",user.realFullName());
String uname = user.realUserName();
msg = StringUtil.replaceAllInstances(msg,"$USERNAME",uname);
StringBuffer msg_buf = new StringBuffer(msg);
msg_buf.append("\n\n--\n").append(engine.getStockMessage("signature"));
// Prepare the subject line to be sent to the user.
String subject = engine.getStockMessage("subj-invite");
subject = StringUtil.replaceAllInstances(subject,"$SIGNAME",signame);
// Get a SimpleEmailer object, set it up, and send it.
SimpleEmailer em = engine.createEmailer();
em.setFrom(uname,user.realEmailAddress());
em.setTo(address);
em.setSubject(subject);
em.setText(msg_buf.toString());
em.send();
} // end sendInvitation
public boolean canSendInvitation()
{
if (user.userIsAnonymous())
return false;
SIGData sd = getSIGDataNE();
if (sd==null)
return false;
return sd.checkMembership(level,is_member);
} // end canSendInvitation
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface UserBackend * Implementations from interface UserBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -1256,6 +1306,24 @@ class SIGUserContextImpl implements SIGContext, SIGBackend
} // end userIsAnonymous } // end userIsAnonymous
public String realUserName()
{
return user.realUserName();
} // end realUserName
public String realEmailAddress() throws DataException
{
return user.realEmailAddress();
} // end realEmailAddress
public String realFullName() throws DataException
{
return user.realFullName();
} // end realFullName
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface SIGBackend * Implementations from interface SIGBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -25,10 +25,20 @@ import com.silverwrist.venice.core.InternalStateError;
class SimpleEmailer class SimpleEmailer
{ {
private Session session; // the email session /*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private Session session; // the email session
private MimeMessage msg; // the message being composed private MimeMessage msg; // the message being composed
public SimpleEmailer(Properties props, javax.mail.Session session) /*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
SimpleEmailer(Properties props, javax.mail.Session session)
{ {
this.session = session; this.session = session;
msg = new MimeMessage(session); msg = new MimeMessage(session);
@ -54,6 +64,11 @@ class SimpleEmailer
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setTo(String to) throws EmailException public void setTo(String to) throws EmailException
{ {
try try
@ -75,6 +90,37 @@ class SimpleEmailer
} // end setTo } // end setTo
public void setFrom(String from_name, String from_addr) throws EmailException
{
try
{ // set the "from" address
InternetAddress addr = new InternetAddress(from_addr);
addr.setPersonal(from_name);
msg.setFrom(addr);
// make sure the "Sender" address reflects our email address
InternetAddress sender = InternetAddress.getLocalAddress(session);
msg.setHeader("Sender",sender.toString());
} // end try
catch (AddressException e1)
{ // the address was somehow invalid
throw new EmailException("invalid email sender address",e1);
} // end catch
catch (MessagingException e2)
{ // msg.setRecipients should NOT be throwing a MessageException here!
throw new InternalStateError("condition should not apply to message here",e2);
} // end catch
catch (java.io.UnsupportedEncodingException e3)
{ // we can't really have that happen here, either!
throw new InternalStateError("condition should not apply to message here",e3);
} // end catch
} // end setFrom
public void setSubject(String subject) public void setSubject(String subject)
{ {
try try

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -31,4 +31,10 @@ public interface UserBackend
public abstract boolean userIsAnonymous(); public abstract boolean userIsAnonymous();
public abstract String realUserName();
public abstract String realEmailAddress() throws DataException;
public abstract String realFullName() throws DataException;
} // end interface UserBackend } // end interface UserBackend

View File

@ -58,6 +58,7 @@ class UserContextImpl implements UserContext, UserBackend
private String description; // personal description private String description; // personal description
private String my_email = null; // my email address (cached) private String my_email = null; // my email address (cached)
private String my_pseud = null; // my pseud (cached) private String my_pseud = null; // my pseud (cached)
private String full_name = null; // my full name (cached)
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructor * Constructor
@ -439,8 +440,10 @@ class UserContextImpl implements UserContext, UserBackend
rc = new ContactInfoImpl(uid); rc = new ContactInfoImpl(uid);
if (my_email==null) if (my_email==null)
my_email = rc.getEmail(); my_email = rc.getEmail();
if (full_name==null)
full_name = rc.getGivenName() + " " + rc.getFamilyName();
if (my_pseud==null) if (my_pseud==null)
my_pseud = rc.getGivenName() + " " + rc.getFamilyName(); my_pseud = full_name;
return rc; return rc;
} // end getContactInfo } // end getContactInfo
@ -485,7 +488,8 @@ class UserContextImpl implements UserContext, UserBackend
} // end if } // end if
my_pseud = ci.getGivenName() + " " + ci.getFamilyName(); // update this field full_name = ci.getGivenName() + " " + ci.getFamilyName(); // update this field
my_pseud = full_name;
if (my_email==null) // filling in, this is not necessarily the first time if (my_email==null) // filling in, this is not necessarily the first time
my_email = ci.getEmail(); my_email = ci.getEmail();
@ -568,7 +572,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = datapool.getConnection();
UserProfileImpl prof = new UserProfileImpl(engine,conn,xusername, UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xusername,
Capability.canSeeHiddenContactFields(level)); Capability.canSeeHiddenContactFields(level));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found it!"); logger.debug("...found it!");
@ -599,7 +603,8 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = datapool.getConnection(); conn = datapool.getConnection();
UserProfileImpl prof = new UserProfileImpl(engine,conn,xuid,Capability.canSeeHiddenContactFields(level)); UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xuid,
Capability.canSeeHiddenContactFields(level));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found it!"); logger.debug("...found it!");
return prof; return prof;
@ -925,6 +930,28 @@ class UserContextImpl implements UserContext, UserBackend
} // end userIsAnonymous } // end userIsAnonymous
public String realUserName()
{
return username;
} // end realUserName
public String realEmailAddress() throws DataException
{
if (my_email==null)
getContactInfo();
return my_email;
} // end realEmailAddress
public String realFullName() throws DataException
{
if (full_name==null)
getContactInfo();
return full_name;
} // end realFullName
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Operations private to implementation package * Operations private to implementation package
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -19,12 +19,26 @@ package com.silverwrist.venice.core.impl;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.db.*; import com.silverwrist.venice.db.*;
class UserProfileImpl implements UserProfile class UserProfileImpl implements UserProfile
{ {
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(UserProfileImpl.class.getName());
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private EngineBackend engine; // the engine back end private EngineBackend engine; // the engine back end
private UserBackend user; // the user that generated this profile
private int uid; // user ID private int uid; // user ID
private String username; // user name private String username; // user name
private String given_name; // given name ("first name") private String given_name; // given name ("first name")
@ -50,64 +64,95 @@ class UserProfileImpl implements UserProfile
private java.util.Date last_login; // date of last login private java.util.Date last_login; // date of last login
private java.util.Date last_update; // date of last update private java.util.Date last_update; // date of last update
private String real_email; // real email address private String real_email; // real email address
private boolean is_anon; // is this the anonymous account?
UserProfileImpl(EngineBackend engine, Connection conn, String username, boolean override) /*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
UserProfileImpl(EngineBackend engine, UserBackend user, Connection conn, String username, boolean override)
throws DataException, SQLException throws DataException, SQLException
{ {
if (logger.isDebugEnabled())
logger.debug("load UserProfileImpl by name: " + username + " (" + override + ")");
this.engine = engine; this.engine = engine;
this.user = user;
// first retrieve from the users table // first retrieve from the users table
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description " StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description, "
+ "FROM users WHERE username = '"); + "is_anon FROM users WHERE username = '");
sql.append(SQLUtil.encodeString(username)).append("';"); sql.append(SQLUtil.encodeString(username)).append("';");
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next())) if (!(rs.next()))
{ // we didn't find the user
logger.error("unable to find user with username '" + username + "'");
throw new DataException("User '" + username + "' not found."); throw new DataException("User '" + username + "' not found.");
} // end if
// load the "elementary" fields // load the "elementary" fields
this.uid = rs.getInt("uid"); this.uid = rs.getInt(1);
this.username = rs.getString("username"); this.username = rs.getString(2);
int contact_id = rs.getInt("contactid"); int contact_id = rs.getInt(3);
created = SQLUtil.getFullDateTime(rs,"created"); created = SQLUtil.getFullDateTime(rs,4);
last_login = SQLUtil.getFullDateTime(rs,"lastaccess"); last_login = SQLUtil.getFullDateTime(rs,5);
descr = rs.getString("description"); descr = rs.getString(6);
is_anon = rs.getBoolean(7);
loadContact(conn,contact_id,override); loadContact(conn,contact_id,override);
} // end constructor } // end constructor
UserProfileImpl(EngineBackend engine, Connection conn, int uid, boolean override) UserProfileImpl(EngineBackend engine, UserBackend user, Connection conn, int uid, boolean override)
throws DataException, SQLException throws DataException, SQLException
{ {
if (logger.isDebugEnabled())
logger.debug("load UserProfileImpl by UID: " + uid + " (" + override + ")");
this.engine = engine; this.engine = engine;
this.user = user;
// first retrieve from the users table // first retrieve from the users table
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description " StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description, "
+ "FROM users WHERE uid = "); + "is_anon FROM users WHERE uid = ");
sql.append(uid).append(';'); sql.append(uid).append(';');
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next())) if (!(rs.next()))
{ // we didn't find user
logger.error("unable to find user with uid " + uid);
throw new DataException("User #" + String.valueOf(uid) + " not found."); throw new DataException("User #" + String.valueOf(uid) + " not found.");
} // end if
// load the "elementary" fields // load the "elementary" fields
this.uid = rs.getInt("uid"); this.uid = rs.getInt(1);
this.username = rs.getString("username"); this.username = rs.getString(2);
int contact_id = rs.getInt("contactid"); int contact_id = rs.getInt(3);
created = SQLUtil.getFullDateTime(rs,"created"); created = SQLUtil.getFullDateTime(rs,4);
last_login = SQLUtil.getFullDateTime(rs,"lastaccess"); last_login = SQLUtil.getFullDateTime(rs,5);
descr = rs.getString("description"); descr = rs.getString(6);
is_anon = rs.getBoolean(7);
loadContact(conn,contact_id,override); loadContact(conn,contact_id,override);
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Internal functions
*--------------------------------------------------------------------------------
*/
private void loadContact(Connection conn, int contact_id, boolean override) throws SQLException private void loadContact(Connection conn, int contact_id, boolean override) throws SQLException
{ {
if (logger.isDebugEnabled())
logger.debug("loadContact for contact ID " + contact_id + " (" + override + ")");
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("SELECT * FROM contacts WHERE contactid = "); StringBuffer sql = new StringBuffer("SELECT * FROM contacts WHERE contactid = ");
sql.append(contact_id).append(';'); sql.append(contact_id).append(';');
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) if (rs.next())
{ // load all the record data { // load all the record data
@ -194,6 +239,11 @@ class UserProfileImpl implements UserProfile
} // end loadContact } // end loadContact
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getUID() public int getUID()
{ {
return uid; return uid;
@ -344,4 +394,49 @@ class UserProfileImpl implements UserProfile
} // end getDescription } // end getDescription
public boolean isAnonymous()
{
return is_anon;
} // end isAnonymous
public boolean canSendQuickEmail()
{
return !is_anon && !(user.userIsAnonymous());
} // end canSendQuickEmail
public void sendQuickEmail(String subject, String text) throws AccessError, DataException, EmailException
{
if (logger.isDebugEnabled())
logger.debug("Send Quick E-Mail (from uid " + user.realUID() + " to uid " + uid + ")");
if (user.userIsAnonymous())
{ // we can't send quick emails if we're anonymous!
logger.error("sending user is not logged in.");
throw new AccessError("You must be logged in to send a quick E-mail message.");
} // end if
if (is_anon)
{ // we can't send quick emails to the anonymous user
logger.error("target user is the anonymous user");
throw new AccessError("You cannot send email to the anonymous user.");
} // end if
// assemble the full text
StringBuffer text_buf = new StringBuffer(text);
text_buf.append("\n\n--\n").append(engine.getStockMessage("signature"));
// create the emailer object, fill it in, and send it
SimpleEmailer em = engine.createEmailer();
em.setFrom(user.realUserName(),user.realEmailAddress());
em.setTo(real_email);
em.setSubject(subject);
em.setText(text_buf.toString());
em.send();
} // end sendQuickEmail
} // end class UserProfileImpl } // end class UserProfileImpl

View File

@ -198,6 +198,19 @@ public class SIGOperations extends VeniceServlet
} // end if ("C" command) } // end if ("C" command)
if (cmd.equals("I"))
{ // "I" - Send Invitation (requires SIG parameter)
SIGContext sig = getSIGParameter(request,user,true,"top");
if (!(sig.canSendInvitation()))
return new ErrorBox("SIG Error","You are not permitted to send an invitation.",
"sig/" + sig.getAlias());
// present the "Invitation" dialog
return new Invitation(sig);
} // end if ("I" command)
// this is an error! // this is an error!
logger.error("invalid command to SIGOperations.doGet: " + cmd); logger.error("invalid command to SIGOperations.doGet: " + cmd);
return new ErrorBox("Internal Error","Invalid command to SIGOperations.doGet","top"); return new ErrorBox("Internal Error","Invalid command to SIGOperations.doGet","top");
@ -318,6 +331,48 @@ public class SIGOperations extends VeniceServlet
} // end if ("C" command) } // end if ("C" command)
if (cmd.equals("I"))
{ // "I" = Send invitation (requires SIG parameter)
SIGContext sig = getSIGParameter(request,user,true,"top");
String on_error = "sig/" + sig.getAlias();
if (isImageButtonClicked(request,"cancel")) // cancel - go back to SIG opening page
throw new RedirectResult(on_error);
if (isImageButtonClicked(request,"send"))
{ // the "send" button was pressed
try
{ // send out the invitation
sig.sendInvitation(request.getParameter("addr"),request.getParameter("pb"));
} // end try
catch (AccessError ae)
{ // access error - display error box
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error doing something
return new ErrorBox("Database Error","Database error creating SIG: " + de.getMessage(),on_error);
} // end catch
catch (EmailException ee)
{ // error sending the email message
return new ErrorBox("E-Mail Error","Error sending e-mail: " + ee.getMessage(),on_error);
} // end catch
// all sent - go back to SIG profile display
throw new RedirectResult(on_error);
} // end if ("send" pressed)
// error - don't know what button was clicked
logger.error("no known button click on SIGOperations.doPost, cmd=I");
return new ErrorBox("Internal Error","Unknown command button pressed",on_error);
} // end if ("I" command)
// this is an error! // this is an error!
logger.error("invalid command to SIGOperations.doPost: " + cmd); logger.error("invalid command to SIGOperations.doPost: " + cmd);
return new ErrorBox("Internal Error","Invalid command to SIGOperations.doPost","top"); return new ErrorBox("Internal Error","Invalid command to SIGOperations.doPost","top");

View File

@ -20,11 +20,19 @@ package com.silverwrist.venice.servlets;
import java.io.*; import java.io.*;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.*; import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*; import com.silverwrist.venice.servlets.format.*;
public class UserDisplay extends VeniceServlet public class UserDisplay extends VeniceServlet
{ {
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(UserDisplay.class.getName());
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Overrides from class HttpServlet * Overrides from class HttpServlet
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -53,6 +61,7 @@ public class UserDisplay extends VeniceServlet
{ // load the profile corresponding to that username and display it { // load the profile corresponding to that username and display it
UserProfile prof = user.getProfile(uname); UserProfile prof = user.getProfile(uname);
changeMenuTop(request); changeMenuTop(request);
setMyLocation(request,"user" + request.getPathInfo());
return new UserProfileData(prof); return new UserProfileData(prof);
} // end try } // end try
@ -64,4 +73,69 @@ public class UserDisplay extends VeniceServlet
} // end doVeniceGet } // end doVeniceGet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
{
String uname = request.getPathInfo().substring(1); // the username we're looking at
UserProfile prof;
String on_error;
if (logger.isDebugEnabled())
logger.debug("Posting to profile: " + uname);
try
{ // load the profile corresponding to that username and display it
prof = user.getProfile(uname);
on_error = "user/" + prof.getUserName();
} // end try
catch (DataException de)
{ // unable to get the user name
logger.error("error retrieving user profile: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error finding user: " + de.getMessage(),"top");
} // end catch
String cmd = getStandardCommandParam(request);
if (cmd.equals("E"))
{ // send a quick email message - let's do it!
if (logger.isDebugEnabled())
logger.debug("sending quick email message");
try
{ // send a quick email message...
prof.sendQuickEmail(request.getParameter("subj"),request.getParameter("pb"));
} // end try
catch (AccessError ae)
{ // throw an access error box
logger.error("access error sending email: " + ae.getMessage(),ae);
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error
logger.error("database error sending email: " + de.getMessage(),de);
return new ErrorBox("Database Error","Database error sending message: " + de.getMessage(),on_error);
} // end catch
catch (EmailException ee)
{ // error sending the actual email
logger.error("email exception: " + ee.getMessage(),ee);
return new ErrorBox("E-Mail Error","Error sending e-mail: " + ee.getMessage(),on_error);
} // end catch
} // end if
if (logger.isDebugEnabled())
logger.debug("redisplaying profile window");
changeMenuTop(request);
setMyLocation(request,"user" + request.getPathInfo());
return new UserProfileData(prof);
} // end doVenicePost
} // end class UserDisplay } // end class UserDisplay

View File

@ -0,0 +1,108 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.servlets.format;
import javax.servlet.ServletRequest;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
public class Invitation implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.Invitation";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private SIGContext sig; // the SIG context
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public Invitation(SIGContext sig)
{
this.sig = sig;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static Invitation retrieve(ServletRequest request)
{
return (Invitation)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Send Invitation";
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "invitation.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getSIGID()
{
return sig.getSIGID();
} // end getSIGID
public String getSIGName()
{
return sig.getName();
} // end getSIGName
} // end class Invitation

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are

52
web/format/invitation.jsp Normal file
View File

@ -0,0 +1,52 @@
<%--
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
The Original Code is the Venice Web Communities System.
The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
Contributor(s):
--%>
<%@ page import = "java.util.*" %>
<%@ page import = "com.silverwrist.util.StringUtil" %>
<%@ page import = "com.silverwrist.venice.core.*" %>
<%@ page import = "com.silverwrist.venice.servlets.Variables" %>
<%@ page import = "com.silverwrist.venice.servlets.format.*" %>
<%
Invitation data = Invitation.retrieve(request);
Variables.failIfNull(data);
RenderData rdat = RenderConfig.createRenderData(application,request,response);
%>
<% if (rdat.useHTMLComments()) { %><!-- Send invitation to SIG #<%= data.getSIGID() %> --><% } %>
<% rdat.writeContentHeader(out,"Send SIG Invitation:",data.getSIGName()); %>
<FORM METHOD=POST ACTION="<%= rdat.getEncodedServletPath("sigops") %>">
<INPUT TYPE="HIDDEN" NAME="sig" VALUE="<%= data.getSIGID() %>">
<INPUT TYPE="HIDDEN" NAME="cmd" VALUE="I">
<TABLE BORDER=0 CELLPADDING=0>
<TR VALIGN=MIDDLE>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>Send to:&nbsp;</FONT></TD>
<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME="addr" SIZE=65 MAXLENGTH=255 VALUE=""></TD>
</TR>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT COLSPAN=2>
<TD ALIGN=LEFT><%= rdat.getStdFontTag(null,2) %>Personal message to be added to invitation:</FONT></TD>
</TD></TR>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT COLSPAN=2>
<TEXTAREA NAME="pb" WRAP=HARD ROWS=7 COLS=80></TEXTAREA>
</TD></TR>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT COLSPAN=2>
<INPUT TYPE="IMAGE" SRC="<%= rdat.getFullImagePath("bn_send_email.gif") %>" NAME="send"
ALT="Send E-Mail" WIDTH=80 HEIGHT=24 BORDER=0>&nbsp;
<INPUT TYPE="IMAGE" SRC="<%= rdat.getFullImagePath("bn_cancel.gif") %>" NAME="cancel"
ALT="Cancel" WIDTH=80 HEIGHT=24 BORDER=0>
</TD></TR>
</TABLE>
</FORM>
<% rdat.writeFooter(out); %>

View File

@ -50,9 +50,9 @@
<% if (data.isUserLoggedIn()) { %> <% if (data.isUserLoggedIn()) { %>
<DIV ALIGN="CENTER"> <DIV ALIGN="CENTER">
<% if (sig.isMember()) { %> <% if (sig.canSendInvitation()) { %>
<A HREF="/TODO"><IMG SRC="<%= rdat.getFullImagePath("bn_invite.gif") %>" ALT="Invite" <A HREF="<%= rdat.getEncodedServletPath("sigops?cmd=I&sig=" + sig.getSIGID()) %>"><IMG
WIDTH=80 HEIGHT=24 BORDER=0></A> SRC="<%= rdat.getFullImagePath("bn_invite.gif") %>" ALT="Invite" WIDTH=80 HEIGHT=24 BORDER=0></A>
<% } else if (sig.canJoin()) { %> <% } else if (sig.canJoin()) { %>
<A HREF="<%= rdat.getEncodedServletPath("sigops?cmd=J&sig=" + sig.getSIGID()) %>"><IMG <A HREF="<%= rdat.getEncodedServletPath("sigops?cmd=J&sig=" + sig.getSIGID()) %>"><IMG
SRC="<%= rdat.getFullImagePath("bn_join_now.gif") %>" ALT="Join Now" SRC="<%= rdat.getFullImagePath("bn_join_now.gif") %>" ALT="Join Now"

View File

@ -89,4 +89,25 @@
<% } // end if %> <% } // end if %>
</TABLE> </TABLE>
<% if (prof.canSendQuickEmail()) { %>
<HR><%= rdat.getStdFontTag(null,2) %><B>Send Quick E-Mail To <%= prof.getUserName() %>:</B></FONT><BR>
<FORM METHOD=POST ACTION="<%= rdat.getEncodedServletPath("user/" + prof.getUserName()) %>">
<INPUT TYPE="HIDDEN" NAME="cmd" VALUE="E">
<TABLE BORDER=0 CELLPADDING=0>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT>
<%= rdat.getStdFontTag(null,2) %>Subject: </FONT>
<INPUT TYPE="TEXT" NAME="subj" SIZE=65 MAXLENGTH=255 VALUE="">
</TD></TR>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT>
<TEXTAREA NAME="pb" WRAP=HARD ROWS=7 COLS=80></TEXTAREA>
</TD></TR>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT>
<INPUT TYPE=IMAGE SRC="<%= rdat.getFullImagePath("bn_send_email.gif") %>" NAME="send"
ALT="Send E-Mail" WIDTH=80 HEIGHT=24 BORDER=0>
</TR>
</TABLE>
</FORM>
<% } // end if %>
<% rdat.writeFooter(out); %> <% rdat.writeFooter(out); %>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B