implemented common sysadmin E-mail message editor and three E-mail message
editors
This commit is contained in:
parent
cbae9cdd8e
commit
6cf37bfee2
|
@ -17,6 +17,8 @@
|
|||
*#
|
||||
|
||||
## Define macros around the "std" object.
|
||||
#macro( dollarprefix $data )$std.dollarPrefix($data)#end
|
||||
|
||||
#macro( formatURL $type $url )$std.formatURL($type,$url)#end
|
||||
|
||||
#macro( encodeHTML $data )$std.encodeHTML($data)#end
|
||||
|
|
|
@ -591,6 +591,15 @@ INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) VALUES
|
|||
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)
|
||||
VALUES (3, 13, 'system.admin', 'System Administration', NULL);
|
||||
INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_nsid, perm_name) VALUES
|
||||
(3, 0, 'TEXT', 'Set Frame Look-And-Feel Parameters', 'SERVLET', 'sysadmin/frame_laf.js.vs', 1, 'set.property'),
|
||||
(3, 1, 'TEXT', 'Set E-Mail Parameters', 'SERVLET', 'sysadmin/email.js.vs', 5, 'set.property'),
|
||||
(3, 2, 'TEXT', 'Set Session Parameters', 'SERVLET', 'sysadmin/session.js.vs', 7, 'set.property');
|
||||
(3, 0, 'TEXT', 'Set Frame Look-And-Feel Parameters', 'SERVLET', 'sysadmin/frame_laf.js.vs', 1,
|
||||
'set.property'),
|
||||
(3, 1, 'TEXT', 'Set E-Mail Parameters', 'SERVLET', 'sysadmin/email.js.vs', 5,
|
||||
'set.property'),
|
||||
(3, 2, 'TEXT', 'Set Session Parameters', 'SERVLET', 'sysadmin/session.js.vs', 7,
|
||||
'set.property'),
|
||||
(3, 3, 'TEXT', 'Edit Confirmation E-Mail Message', 'SERVLET', 'sysadmin/confirm_email.js.vs', 12,
|
||||
'set.property'),
|
||||
(3, 4, 'TEXT', 'Edit Password Changed E-Mail Message', 'SERVLET', 'sysadmin/pwchange_email.js.vs', 12,
|
||||
'set.property'),
|
||||
(3, 5, 'TEXT', 'Edit Password Reminder E-Mail Message', 'SERVLET', 'sysadmin/pwremind_email.js.vs', 12,
|
||||
'set.property');
|
||||
|
|
|
@ -49,6 +49,12 @@ public class StdObject
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String dollarPrefix(String data)
|
||||
{
|
||||
return "$" + data;
|
||||
|
||||
} // end dollarPrefix
|
||||
|
||||
public String formatURL(String type, String url)
|
||||
{
|
||||
if (m_rewriter==null)
|
||||
|
|
40
venice-data/scripts/sysadmin/confirm_email.js
Normal file
40
venice-data/scripts/sysadmin/confirm_email.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
// 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.util);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
|
||||
// Set up the parameters to call the edit-email.js script.
|
||||
my_ns = "/util/sysadmin/edit-email.js";
|
||||
req.setObject(my_ns,"namespace",VeniceNamespaces.MAIL_MESSAGES_NAMESPACE);
|
||||
req.setObject(my_ns,"subject.property","confirm.message.title");
|
||||
req.setObject(my_ns,"body.block","confirm.message");
|
||||
req.setObject(my_ns,"caller","sysadmin/confirm_email.js.vs");
|
||||
req.setObject(my_ns,"returnto","sysadmin/main.js.vs");
|
||||
req.setObject(my_ns,"title","E-Mail Confirmation");
|
||||
|
||||
// Set up the varmap.
|
||||
varmap = new TreeMap();
|
||||
varmap.put("username","The name of the user account being confirmed");
|
||||
varmap.put("confnum","The confirmation number");
|
||||
req.setObject(my_ns,"varmap",varmap);
|
||||
|
||||
// Execute and return the value from the common script.
|
||||
dynamo.scriptOutput(dynamo.exec(my_ns));
|
40
venice-data/scripts/sysadmin/pwchange_email.js
Normal file
40
venice-data/scripts/sysadmin/pwchange_email.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
// 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.util);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
|
||||
// Set up the parameters to call the edit-email.js script.
|
||||
my_ns = "/util/sysadmin/edit-email.js";
|
||||
req.setObject(my_ns,"namespace",VeniceNamespaces.MAIL_MESSAGES_NAMESPACE);
|
||||
req.setObject(my_ns,"subject.property","password.change.message.title");
|
||||
req.setObject(my_ns,"body.block","password.change.message");
|
||||
req.setObject(my_ns,"caller","sysadmin/pwchange_email.js.vs");
|
||||
req.setObject(my_ns,"returnto","sysadmin/main.js.vs");
|
||||
req.setObject(my_ns,"title","Password Changed by Password Recovery");
|
||||
|
||||
// Set up the varmap.
|
||||
varmap = new TreeMap();
|
||||
varmap.put("username","The name of the user account with the password changed");
|
||||
varmap.put("password","The new password");
|
||||
req.setObject(my_ns,"varmap",varmap);
|
||||
|
||||
// Execute and return the value from the common script.
|
||||
dynamo.scriptOutput(dynamo.exec(my_ns));
|
42
venice-data/scripts/sysadmin/pwremind_email.js
Normal file
42
venice-data/scripts/sysadmin/pwremind_email.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
// 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.util);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
|
||||
// Set up the parameters to call the edit-email.js script.
|
||||
my_ns = "/util/sysadmin/edit-email.js";
|
||||
req.setObject(my_ns,"namespace",VeniceNamespaces.MAIL_MESSAGES_NAMESPACE);
|
||||
req.setObject(my_ns,"subject.property","reminder.message.title");
|
||||
req.setObject(my_ns,"body.block","reminder.message");
|
||||
req.setObject(my_ns,"caller","sysadmin/pwremind_email.js.vs");
|
||||
req.setObject(my_ns,"returnto","sysadmin/main.js.vs");
|
||||
req.setObject(my_ns,"title","Password Reminder");
|
||||
|
||||
// Set up the varmap.
|
||||
varmap = new TreeMap();
|
||||
varmap.put("username","The name of the user account to remind on");
|
||||
varmap.put("reminder","The password reminder message");
|
||||
varmap.put("uid","The user ID of the user account");
|
||||
varmap.put("auth","The authentication string for use in password recovery");
|
||||
req.setObject(my_ns,"varmap",varmap);
|
||||
|
||||
// Execute and return the value from the common script.
|
||||
dynamo.scriptOutput(dynamo.exec(my_ns));
|
129
venice-data/util/sysadmin/edit-email.js
Normal file
129
venice-data/util/sysadmin/edit-email.js
Normal file
|
@ -0,0 +1,129 @@
|
|||
// 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
// Parameters to this script are passed in the request with a namespace of "/util/sysadmin/edit-email.js":
|
||||
// namespace = Namespace of the subject property and message text block
|
||||
// subject.property = Name of property where the subject text is stored
|
||||
// body.block = Name of block where message text is stored
|
||||
// caller = SERVLET URL of caller, so form can POST back to it
|
||||
// returnto = SERVLET URL of page to bounce back to after update completed
|
||||
// title = Title of the message being edited
|
||||
// varmap = A Map which contains the variable replacement definitions to display below the body text box (optional)
|
||||
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.except);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.security);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
user = vlib.getUser(req);
|
||||
|
||||
// Get the namespace and name parameters.
|
||||
my_ns = "/util/sysadmin/edit-email.js";
|
||||
namespace = req.getObject(my_ns,"namespace");
|
||||
subject_property = req.getObject(my_ns,"subject.property");
|
||||
body_block = req.getObject(my_ns,"body.block");
|
||||
return_URL = req.getObject(my_ns,"returnto");
|
||||
vlib.setOnError(req,return_URL);
|
||||
vlib.setOnErrorType(req,"SERVLET");
|
||||
|
||||
// Make sure we are permitted to be here.
|
||||
srm = cast.querySecurityReferenceMonitor(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"srm"));
|
||||
acl = srm.getGlobalAcl();
|
||||
if (!(acl.testPermission(user,namespace,"set.property") && acl.testPermission(user,namespace,"set.block")))
|
||||
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
|
||||
"You are not permitted to edit the system E-mail messages."));
|
||||
|
||||
// Get the global properties store.
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
blocks = vcast.getGlobalBlocksStore(req);
|
||||
|
||||
error_message = null;
|
||||
rc = null;
|
||||
subject_text = "";
|
||||
body_text = "";
|
||||
|
||||
if (rhelp.isVerb("GET"))
|
||||
{ // load the initial values of the text fields
|
||||
subject_text = globals.getObject(namespace,subject_property);
|
||||
body_text = blocks.getObject(namespace,body_block);
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // did they click Cancel?
|
||||
if (rhelp.isImageButtonClicked("cancel"))
|
||||
rc = new Redirect("SERVLET",return_URL);
|
||||
else
|
||||
{ // retrieve the form parameters
|
||||
subject_text = rhelp.getParameterString("subject");
|
||||
body_text = rhelp.getParameterString("body");
|
||||
|
||||
if (stringutils.isEmpty(subject_text))
|
||||
error_message = "Subject text not specified.";
|
||||
else if (stringutils.isEmpty(body_text))
|
||||
error_message = "Body text not specified.";
|
||||
else if (body_text.length()>65535)
|
||||
error_message = "Body text is too long.";
|
||||
|
||||
if (error_message==null)
|
||||
{ // attempt to set the properties!
|
||||
try
|
||||
{ // set the two properties
|
||||
globals.setObject(user,namespace,subject_property,subject_text.toString());
|
||||
blocks.setObject(user,namespace,body_block,body_text.toString());
|
||||
|
||||
// all done - bounce back to return location
|
||||
rc = new Redirect("SERVLET",return_URL);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // thrown an exception from the above process - what sort?
|
||||
etype = dynamo.exceptionType(e) + "";
|
||||
logger.error("Caught exception of type " + etype);
|
||||
if (etype.match(/DatabaseException/))
|
||||
rc = new ErrorBox("Database Error",e,"SERVLET",return_URL);
|
||||
else if (etype.match(/DynamoSecurityException/))
|
||||
rc = new ErrorBox("Security Error",e,"SERVLET",return_URL);
|
||||
else
|
||||
rc = new ErrorBox("Unknown Exception",e,"SERVLET",return_URL);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else
|
||||
|
||||
if (rc==null)
|
||||
{ // generate the form as a Velocity object
|
||||
rc = new VelocityView("Edit E-Mail Message","sysadmin/edit-email.vm");
|
||||
rc.setParameter("msgtitle",req.getObject(my_ns,"title"));
|
||||
rc.setParameter("action",req.getObject(my_ns,"caller"));
|
||||
rc.setParameter("subject",subject_text);
|
||||
rc.setParameter("body",body_text);
|
||||
tmp = PropertyUtils.getPropertyNoErr(req,my_ns,"varmap");
|
||||
if (tmp!=null)
|
||||
rc.setParameter("varmap",tmp);
|
||||
if (error_message!=null)
|
||||
rc.setParameter("error_message",error_message);
|
||||
|
||||
} // end if
|
||||
|
||||
dynamo.scriptOutput(rc);
|
|
@ -17,6 +17,8 @@
|
|||
*#
|
||||
|
||||
## Define macros around the "std" object.
|
||||
#macro( dollarprefix $data )$std.dollarPrefix($data)#end
|
||||
|
||||
#macro( formatURL $type $url )$std.formatURL($type,$url)#end
|
||||
|
||||
#macro( encodeHTML $data )$std.encodeHTML($data)#end
|
||||
|
|
|
@ -122,3 +122,8 @@ td.sideboxtop {
|
|||
td.sidebox {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.formerror {
|
||||
font-weight: bold;
|
||||
font-color: red;
|
||||
}
|
||||
|
|
51
venice-data/velocity/sysadmin/edit-email.vm
Normal file
51
venice-data/velocity/sysadmin/edit-email.vm
Normal file
|
@ -0,0 +1,51 @@
|
|||
#*
|
||||
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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*#
|
||||
#*
|
||||
Parameters:
|
||||
msgtitle = Title of the E-mail message being edited.
|
||||
action = Action URL to which the form should be posted.
|
||||
subject = Default subject for the message.
|
||||
body = Default body for the message.
|
||||
varmap = Listing of variables in the input, with explanations; a Map (may be null)
|
||||
error_message = Error message to be displayed for this form (may be null).
|
||||
*#
|
||||
#header2( "Edit E-Mail Message" $msgtitle )
|
||||
#if( $error_message )
|
||||
<div align="center" class="formerror">#encodeHTML( $error_message ) Please try again.</div>
|
||||
#end
|
||||
<form method="POST" action="#formatURL( "SERVLET" $action )">
|
||||
<table align="center" border="0" cellpadding="2" cellspacing="0">
|
||||
<tr valign="middle"><td align="left">
|
||||
Subject: <input type="text" name="subject" size="60" maxlength="254" value="$!subject" />
|
||||
</td></tr>
|
||||
<tr valign="top"><td align="left">
|
||||
<textarea name="body" rows="30" cols="80" wrap="hard">#encodeHTML( $!body )</textarea>
|
||||
</td></tr>
|
||||
#if( $varmap )
|
||||
<tr valign="top"><td align="left">
|
||||
<b><u>Variables:</u></b>
|
||||
#foreach( $var in $varmap.keySet() )
|
||||
<br />#dollarprefix( $var ) = #encodeHTML( ${varmap.get($var)} )
|
||||
#end
|
||||
</td></tr>
|
||||
#end
|
||||
<tr valign="middle"><td align="center">
|
||||
#button( "INPUT" "update" ) #button( "INPUT" "cancel" )
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user