added community admin "Send E-Mail To All Members" menu option

This commit is contained in:
Eric J. Bowersox 2001-12-04 19:17:00 +00:00
parent d89c2bfdcb
commit e35045acf4
10 changed files with 307 additions and 1 deletions

View File

@ -184,6 +184,7 @@
<permission id="NoKeyRequired" role="Global.AnyAdmin"/>
<permission id="ShowHiddenMembers" role="Community.AnyAdmin"/>
<permission id="ShowHiddenObjects" role="Community.AnyAdmin"/>
<permission id="MassMail" role="Community.AnyAdmin"/>
</permissions>
</security-definition>
<security-definition id="Conference" parent="Community"> <!-- will move eventually -->

View File

@ -179,4 +179,8 @@ public interface CommunityContext extends SearchMode
public abstract SecurityInfo getSecurityInfo();
public abstract boolean canMassMail();
public abstract void massMail(String subject, String text) throws AccessError, DataException;
} // end interface CommunityContext

View File

@ -1821,6 +1821,51 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend
} // end setProperties
public List getMassMailList() throws DataException
{
if (logger.isDebugEnabled())
logger.debug("getMassMailList() for community " + cid);
if (deleted)
throw new DataException("This community has been deleted.");
Connection conn = null; // database connection
ArrayList rc = new ArrayList(); // return from this function
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT c.email FROM contacts c, users u, sigmember m "
+ "WHERE c.contactid = u.contactid AND u.uid = m.uid AND m.sigid = ");
sql.append(cid).append(" AND u.is_anon = 0;");
if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString());
// execute the query and copy the results to the ArrayList
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
rc.add(rs.getString(1));
} // end try
catch (SQLException e)
{ // database error - this is a DataException
logger.error("DB error getting mailing list: " + e.getMessage(),e);
throw new DataException("unable to get community mailing list: " + e.getMessage(),e);
} // end catch
finally
{ // make sure the connection is released before we go
env.releaseConnection(conn);
} // end finally
return rc;
} // end getMassMailList
/*--------------------------------------------------------------------------------
* Implementations from interface CommunityDataBackend
*--------------------------------------------------------------------------------

View File

@ -1360,6 +1360,33 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end getSecurityInfo
public boolean canMassMail()
{
return env.testPermission("Community.MassMail");
} // end canMassMail
public void massMail(String subject, String text) throws AccessError, DataException
{
if (!(env.testPermission("Community.MassMail")))
{ // no can do, man!
logger.error("user not permitted to modify the community's information");
throw new AccessError("You are not permitted to send E-mail to all community members.");
} // end if
// get the mailing list
List mail_list = getData().getMassMailList();
if (mail_list.size()>0)
{ // send the mail in the background!
MailerAgent agent = new MailerAgent(env,env.getUser().realUserName(),env.getUser().realEmailAddress(),
mail_list,subject,text);
agent.start();
} // end if
} // end massMail
/*--------------------------------------------------------------------------------
* Implementations from interface CommunityBackend
*--------------------------------------------------------------------------------

View File

@ -158,4 +158,6 @@ public interface CommunityData
public abstract void setProperties(CommunityProperties props) throws DataException;
public abstract List getMassMailList() throws DataException;
} // end interface CommunityData

View File

@ -96,6 +96,15 @@ public class CommunityAdmin extends VeniceServlet
*--------------------------------------------------------------------------------
*/
/* Command values for CommunityAdmin:
* A = Display Audit Records
* DEL = Delete Community
* F = Set Features/Services (not implemented yet)
* I = E-Mail to All Members
* M = Membership Control
* P = Edit Profile
* T = Set Category
*/
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
@ -302,6 +311,20 @@ public class CommunityAdmin extends VeniceServlet
} // end if ("A" command)
if (cmd.equals("I"))
{ // "I" = "Send E-Mail To All Members"
if (!(comm.canMassMail()))
{ // we can't send mass mail to the community, so what are we doing here?
logger.error("you can't mass-mail the community - not gonna do it, wouldn't be prudent");
return new ErrorBox("Access Error","You do not have permission to sent mass mail to this community.",
on_error);
} // end if
return new CommunityEMail(comm); // return the view object
} // end if ("I" command)
if (cmd.equals("DEL"))
{ // "DEL" = "Delete Community" (requires a confirmation)
if (!(comm.canDelete()))
@ -587,6 +610,37 @@ public class CommunityAdmin extends VeniceServlet
} // end if ("M" command)
if (cmd.equals("I"))
{ // "I" - "Send E-Mail To Community"
if (!(comm.canMassMail()))
{ // we can't send mass mail to the community, so what are we doing here?
logger.error("you can't mass-mail the community - not gonna do it, wouldn't be prudent");
return new ErrorBox("Access Error","You do not have permission to sent mass mail to this community.",
on_error);
} // end if
try
{ // attempt to do the mass mailing!
comm.massMail(request.getParameter("subj"),request.getParameter("pb"));
} // end try
catch (AccessError ae)
{ // some sort of access error - display an error dialog
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error creating the conference
return new ErrorBox("Database Error","Database error getting mailing list: " + de.getMessage(),
on_error);
} // end catch
throw new RedirectResult(on_error); // bounce back to the menu
} // end if ("I" command)
// on unknown command, redirect to the GET function
return doVeniceGet(request,engine,user,rdat);

View File

@ -36,6 +36,7 @@ public class CommunityAdminTop extends ContentMenuPanel
addChoice("Set Community Category","sigadmin?sig=$s&cmd=T");
addChoice("Set Community Features","sigadmin?sig=$s&cmd=F");
addChoice("Membership Control","sigadmin?sig=$s&cmd=M");
addChoice("E-Mail To All Members","sigadmin?sig=$s&cmd=I");
addChoice("Display Audit Records","sigadmin?sig=$s&cmd=A");
// TODO: More options
addChoice("Delete Community","sigadmin?sig=$s&cmd=DEL");

View File

@ -0,0 +1,115 @@
/*
* 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 java.util.*;
import javax.servlet.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
public class CommunityEMail implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.CommunityEMail";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private CommunityContext comm; // the community we're in
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public CommunityEMail(CommunityContext comm)
{
this.comm = comm;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static CommunityEMail retrieve(ServletRequest request)
{
return (CommunityEMail)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Community E-Mail: " + comm.getName();
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "comm_email.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getCommunityID()
{
return comm.getCommunityID();
} // end getCommunityID
public final String getCommunityName()
{
return comm.getName();
} // end getCommunityName
} // end class CommunityEMail

57
web/format/comm_email.jsp Normal file
View File

@ -0,0 +1,57 @@
<%--
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.*" %>
<%
CommunityEMail data = CommunityEMail.retrieve(request);
Variables.failIfNull(data);
RenderData rdat = RenderConfig.createRenderData(application,request,response);
%>
<% if (rdat.useHTMLComments()) { %><!-- E-mail to community #<%= data.getCommunityID() %> --><% } %>
<% rdat.writeContentHeader(out,"Community E-Mail:",data.getCommunityName()); %>
<FORM METHOD="POST" ACTION="<%= rdat.getEncodedServletPath("sigadmin") %>"><DIV CLASS="content">
<INPUT TYPE="HIDDEN" NAME="sig" VALUE="<%= data.getCommunityID() %>">
<INPUT TYPE="HIDDEN" NAME="cmd" VALUE="I">
<TABLE BORDER=0 CELLPADDING=0>
<TR VALIGN=MIDDLE>
<TD ALIGN=LEFT CLASS="content" COLSPAN=2><%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %>
Send E-mail to all members of the community:
</FONT></TD>
</TR>
<TR VALIGN=MIDDLE>
<TD ALIGN=LEFT CLASS="content">
<%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %>Subject:</FONT>
</TD>
<TD ALIGN=LEFT CLASS="cinput"><INPUT TYPE=TEXT CLASS="cinput" NAME="subj" SIZE=65
MAXLENGTH=255 VALUE=""></TD>
</TR>
<TR VALIGN=MIDDLE>
<TD ALIGN=LEFT CLASS="cinput" COLSPAN=2><TEXTAREA NAME="pb" WRAP=HARD ROWS=7 COLS=80></TEXTAREA></TD>
</TR>
<TR VALIGN=MIDDLE><TD ALIGN=LEFT COLSPAN=2 CLASS="content">
<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>
</DIV></FORM>

View File

@ -70,4 +70,4 @@
ALT="Cancel" WIDTH=80 HEIGHT=24 BORDER=0>
</TD></TR>
</TABLE>
</DIV></FORM>
</DIV></FORM>