diff --git a/TODO b/TODO index 868b954..351fb69 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,6 @@ Lots! - Unimplemented functions on the SIG Administration page: Set SIG Features (sigadmin, command=F) -- Implement SIG invitations ("Invite" button on the profile). - - Unimplemented functions in the system admin menu: Set Global Parameters 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 logged in. -- Implement quick e-mail from the user profile display (engine support and - UI). - - Slippage during posting is still untested. - Not everybody likes purple. Provide a way to change the default colors. diff --git a/etc/venice-config.xml b/etc/venice-config.xml index 3a72196..7a41ec9 100644 --- a/etc/venice-config.xml +++ b/etc/venice-config.xml @@ -75,6 +75,11 @@ + + +Venice - community services, conferencing and more. http://venice.sourceforge.net + + @@ -102,6 +107,48 @@ please contact the server administrator for further assistance. -- The Management + + + + +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 <http://delenn:8080/venice/sig/$SIGALIAS> 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) + + + + + +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 <http://delenn:8080/venice/sig/$SIGALIAS> 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) + + + + + Invitation to "$SIGNAME" SIG + diff --git a/src/com/silverwrist/venice/core/SIGContext.java b/src/com/silverwrist/venice/core/SIGContext.java index 3bdf3d7..7687a4a 100644 --- a/src/com/silverwrist/venice/core/SIGContext.java +++ b/src/com/silverwrist/venice/core/SIGContext.java @@ -162,4 +162,9 @@ public interface SIGContext extends SearchMode 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 diff --git a/src/com/silverwrist/venice/core/UserProfile.java b/src/com/silverwrist/venice/core/UserProfile.java index 90911b0..6147e57 100644 --- a/src/com/silverwrist/venice/core/UserProfile.java +++ b/src/com/silverwrist/venice/core/UserProfile.java @@ -7,7 +7,7 @@ * 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 Community System. + * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are @@ -71,4 +71,11 @@ public interface UserProfile 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 diff --git a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java index 26d3392..7b753c7 100644 --- a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java @@ -1458,6 +1458,24 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend } // 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 *-------------------------------------------------------------------------------- diff --git a/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java b/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java index 0bbd127..947a34c 100644 --- a/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java @@ -20,6 +20,7 @@ package com.silverwrist.venice.core.impl; import java.sql.*; import java.util.*; import org.apache.log4j.*; +import com.silverwrist.util.StringUtil; import com.silverwrist.venice.db.*; import com.silverwrist.venice.security.Capability; import com.silverwrist.venice.security.DefaultLevels; @@ -387,7 +388,7 @@ class SIGUserContextImpl implements SIGContext, SIGBackend conn = datapool.getConnection(); // 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())); } // end try @@ -1221,6 +1222,55 @@ class SIGUserContextImpl implements SIGContext, SIGBackend } // 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 *-------------------------------------------------------------------------------- @@ -1256,6 +1306,24 @@ class SIGUserContextImpl implements SIGContext, SIGBackend } // 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 *-------------------------------------------------------------------------------- diff --git a/src/com/silverwrist/venice/core/impl/SimpleEmailer.java b/src/com/silverwrist/venice/core/impl/SimpleEmailer.java index e9213ac..48982df 100644 --- a/src/com/silverwrist/venice/core/impl/SimpleEmailer.java +++ b/src/com/silverwrist/venice/core/impl/SimpleEmailer.java @@ -7,7 +7,7 @@ * 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 Community System. + * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are @@ -25,10 +25,20 @@ import com.silverwrist.venice.core.InternalStateError; class SimpleEmailer { - private Session session; // the email session + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private Session session; // the email session 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; msg = new MimeMessage(session); @@ -54,6 +64,11 @@ class SimpleEmailer } // end constructor + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + public void setTo(String to) throws EmailException { try @@ -75,6 +90,37 @@ class SimpleEmailer } // 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) { try diff --git a/src/com/silverwrist/venice/core/impl/UserBackend.java b/src/com/silverwrist/venice/core/impl/UserBackend.java index 5f937a0..c41b836 100644 --- a/src/com/silverwrist/venice/core/impl/UserBackend.java +++ b/src/com/silverwrist/venice/core/impl/UserBackend.java @@ -7,7 +7,7 @@ * 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 Community System. + * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are @@ -31,4 +31,10 @@ public interface UserBackend public abstract boolean userIsAnonymous(); + public abstract String realUserName(); + + public abstract String realEmailAddress() throws DataException; + + public abstract String realFullName() throws DataException; + } // end interface UserBackend diff --git a/src/com/silverwrist/venice/core/impl/UserContextImpl.java b/src/com/silverwrist/venice/core/impl/UserContextImpl.java index 206bb2f..98e9a68 100644 --- a/src/com/silverwrist/venice/core/impl/UserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/UserContextImpl.java @@ -58,6 +58,7 @@ class UserContextImpl implements UserContext, UserBackend private String description; // personal description private String my_email = null; // my email address (cached) private String my_pseud = null; // my pseud (cached) + private String full_name = null; // my full name (cached) /*-------------------------------------------------------------------------------- * Constructor @@ -439,8 +440,10 @@ class UserContextImpl implements UserContext, UserBackend rc = new ContactInfoImpl(uid); if (my_email==null) my_email = rc.getEmail(); + if (full_name==null) + full_name = rc.getGivenName() + " " + rc.getFamilyName(); if (my_pseud==null) - my_pseud = rc.getGivenName() + " " + rc.getFamilyName(); + my_pseud = full_name; return rc; } // end getContactInfo @@ -485,7 +488,8 @@ class UserContextImpl implements UserContext, UserBackend } // 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 my_email = ci.getEmail(); @@ -568,7 +572,7 @@ class UserContextImpl implements UserContext, UserBackend try { // retrieve a connection from the data pool conn = datapool.getConnection(); - UserProfileImpl prof = new UserProfileImpl(engine,conn,xusername, + UserProfileImpl prof = new UserProfileImpl(engine,this,conn,xusername, Capability.canSeeHiddenContactFields(level)); if (logger.isDebugEnabled()) logger.debug("...found it!"); @@ -599,7 +603,8 @@ class UserContextImpl implements UserContext, UserBackend try { // retrieve a connection from the data pool 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()) logger.debug("...found it!"); return prof; @@ -925,6 +930,28 @@ class UserContextImpl implements UserContext, UserBackend } // 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 *-------------------------------------------------------------------------------- diff --git a/src/com/silverwrist/venice/core/impl/UserProfileImpl.java b/src/com/silverwrist/venice/core/impl/UserProfileImpl.java index e8483dd..4339ab0 100644 --- a/src/com/silverwrist/venice/core/impl/UserProfileImpl.java +++ b/src/com/silverwrist/venice/core/impl/UserProfileImpl.java @@ -7,7 +7,7 @@ * 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 Community System. + * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * 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.util.*; +import org.apache.log4j.*; import com.silverwrist.venice.core.*; import com.silverwrist.venice.db.*; 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 UserBackend user; // the user that generated this profile private int uid; // user ID private String username; // user 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_update; // date of last update 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 { + if (logger.isDebugEnabled()) + logger.debug("load UserProfileImpl by name: " + username + " (" + override + ")"); this.engine = engine; + this.user = user; // first retrieve from the users table Statement stmt = conn.createStatement(); - StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description " - + "FROM users WHERE username = '"); + StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description, " + + "is_anon FROM users WHERE username = '"); sql.append(SQLUtil.encodeString(username)).append("';"); ResultSet rs = stmt.executeQuery(sql.toString()); 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."); + } // end if + // load the "elementary" fields - this.uid = rs.getInt("uid"); - this.username = rs.getString("username"); - int contact_id = rs.getInt("contactid"); - created = SQLUtil.getFullDateTime(rs,"created"); - last_login = SQLUtil.getFullDateTime(rs,"lastaccess"); - descr = rs.getString("description"); + this.uid = rs.getInt(1); + this.username = rs.getString(2); + int contact_id = rs.getInt(3); + created = SQLUtil.getFullDateTime(rs,4); + last_login = SQLUtil.getFullDateTime(rs,5); + descr = rs.getString(6); + is_anon = rs.getBoolean(7); loadContact(conn,contact_id,override); } // 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 { + if (logger.isDebugEnabled()) + logger.debug("load UserProfileImpl by UID: " + uid + " (" + override + ")"); this.engine = engine; + this.user = user; // first retrieve from the users table Statement stmt = conn.createStatement(); - StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description " - + "FROM users WHERE uid = "); + StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description, " + + "is_anon FROM users WHERE uid = "); sql.append(uid).append(';'); ResultSet rs = stmt.executeQuery(sql.toString()); 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."); + } // end if + // load the "elementary" fields - this.uid = rs.getInt("uid"); - this.username = rs.getString("username"); - int contact_id = rs.getInt("contactid"); - created = SQLUtil.getFullDateTime(rs,"created"); - last_login = SQLUtil.getFullDateTime(rs,"lastaccess"); - descr = rs.getString("description"); + this.uid = rs.getInt(1); + this.username = rs.getString(2); + int contact_id = rs.getInt(3); + created = SQLUtil.getFullDateTime(rs,4); + last_login = SQLUtil.getFullDateTime(rs,5); + descr = rs.getString(6); + is_anon = rs.getBoolean(7); loadContact(conn,contact_id,override); } // end constructor + /*-------------------------------------------------------------------------------- + * Internal functions + *-------------------------------------------------------------------------------- + */ + 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(); StringBuffer sql = new StringBuffer("SELECT * FROM contacts WHERE contactid = "); sql.append(contact_id).append(';'); + ResultSet rs = stmt.executeQuery(sql.toString()); if (rs.next()) { // load all the record data @@ -194,6 +239,11 @@ class UserProfileImpl implements UserProfile } // end loadContact + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + public int getUID() { return uid; @@ -344,4 +394,49 @@ class UserProfileImpl implements UserProfile } // 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 diff --git a/src/com/silverwrist/venice/servlets/SIGOperations.java b/src/com/silverwrist/venice/servlets/SIGOperations.java index 294caf3..f272c3a 100644 --- a/src/com/silverwrist/venice/servlets/SIGOperations.java +++ b/src/com/silverwrist/venice/servlets/SIGOperations.java @@ -198,6 +198,19 @@ public class SIGOperations extends VeniceServlet } // 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! logger.error("invalid command to SIGOperations.doGet: " + cmd); return new ErrorBox("Internal Error","Invalid command to SIGOperations.doGet","top"); @@ -318,6 +331,48 @@ public class SIGOperations extends VeniceServlet } // 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! logger.error("invalid command to SIGOperations.doPost: " + cmd); return new ErrorBox("Internal Error","Invalid command to SIGOperations.doPost","top"); diff --git a/src/com/silverwrist/venice/servlets/UserDisplay.java b/src/com/silverwrist/venice/servlets/UserDisplay.java index b1d9af1..ea0c8b2 100644 --- a/src/com/silverwrist/venice/servlets/UserDisplay.java +++ b/src/com/silverwrist/venice/servlets/UserDisplay.java @@ -20,11 +20,19 @@ package com.silverwrist.venice.servlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; +import org.apache.log4j.*; import com.silverwrist.venice.core.*; import com.silverwrist.venice.servlets.format.*; public class UserDisplay extends VeniceServlet { + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static Category logger = Category.getInstance(UserDisplay.class.getName()); + /*-------------------------------------------------------------------------------- * Overrides from class HttpServlet *-------------------------------------------------------------------------------- @@ -53,6 +61,7 @@ public class UserDisplay extends VeniceServlet { // load the profile corresponding to that username and display it UserProfile prof = user.getProfile(uname); changeMenuTop(request); + setMyLocation(request,"user" + request.getPathInfo()); return new UserProfileData(prof); } // end try @@ -64,4 +73,69 @@ public class UserDisplay extends VeniceServlet } // 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 diff --git a/src/com/silverwrist/venice/servlets/format/Invitation.java b/src/com/silverwrist/venice/servlets/format/Invitation.java new file mode 100644 index 0000000..6290b7a --- /dev/null +++ b/src/com/silverwrist/venice/servlets/format/Invitation.java @@ -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 . + * + * 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 , + * 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 diff --git a/src/com/silverwrist/venice/servlets/format/SIGProfileData.java b/src/com/silverwrist/venice/servlets/format/SIGProfileData.java index d6a3338..47967f0 100644 --- a/src/com/silverwrist/venice/servlets/format/SIGProfileData.java +++ b/src/com/silverwrist/venice/servlets/format/SIGProfileData.java @@ -7,7 +7,7 @@ * 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 Community System. + * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are diff --git a/web/format/invitation.jsp b/web/format/invitation.jsp new file mode 100644 index 0000000..97eeb2c --- /dev/null +++ b/web/format/invitation.jsp @@ -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 . + + 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 , + 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()) { %><% } %> +<% rdat.writeContentHeader(out,"Send SIG Invitation:",data.getSIGName()); %> +
"> + + + + + + + + + + + +
<%= rdat.getStdFontTag(null,2) %>Send to: 
+ <%= rdat.getStdFontTag(null,2) %>Personal message to be added to invitation:
+ +
+ " NAME="send" + ALT="Send E-Mail" WIDTH=80 HEIGHT=24 BORDER=0>  + " NAME="cancel" + ALT="Cancel" WIDTH=80 HEIGHT=24 BORDER=0> +
+
+<% rdat.writeFooter(out); %> \ No newline at end of file diff --git a/web/format/sigprofile.jsp b/web/format/sigprofile.jsp index e4c6004..833c134 100644 --- a/web/format/sigprofile.jsp +++ b/web/format/sigprofile.jsp @@ -50,9 +50,9 @@ <% if (data.isUserLoggedIn()) { %>
- <% if (sig.isMember()) { %> - " ALT="Invite" - WIDTH=80 HEIGHT=24 BORDER=0> + <% if (sig.canSendInvitation()) { %> + ">" ALT="Invite" WIDTH=80 HEIGHT=24 BORDER=0> <% } else if (sig.canJoin()) { %> ">" ALT="Join Now" diff --git a/web/format/userprofile.jsp b/web/format/userprofile.jsp index 49aa240..ed4c6ba 100644 --- a/web/format/userprofile.jsp +++ b/web/format/userprofile.jsp @@ -89,4 +89,25 @@ <% } // end if %> + +<% if (prof.canSendQuickEmail()) { %> +
<%= rdat.getStdFontTag(null,2) %>Send Quick E-Mail To <%= prof.getUserName() %>:
+
"> + + + + + +
+ <%= rdat.getStdFontTag(null,2) %>Subject: + +
+ +
+ " NAME="send" + ALT="Send E-Mail" WIDTH=80 HEIGHT=24 BORDER=0> +
+
+<% } // end if %> + <% rdat.writeFooter(out); %> diff --git a/web/images/bn_send_email.gif b/web/images/bn_send_email.gif new file mode 100644 index 0000000..f4e42a7 Binary files /dev/null and b/web/images/bn_send_email.gif differ