// 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. // // Contributor(s): importPackage(Packages.com.silverwrist.util); 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); importClass(Packages.com.silverwrist.venice.VeniceNamespaces); importPackage(Packages.com.silverwrist.venice.content); importPackage(Packages.com.silverwrist.venice.frame); req = bsf.lookupBean("request"); req_help = bsf.lookupBean("request_help"); user = vlib.getUser(req); vlib.setOnError(req,"sysadmin/main.js.vs"); vlib.setOnErrorType(req,"SERVLET"); // Make sure we are permitted to be here. srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"srm")); acl = srm.getGlobalAcl(); if (!( acl.testPermission(user,VeniceNamespaces.MAIL_PROPS_NAMESPACE,"set.property") && acl.testPermission(user,VeniceNamespaces.MAIL_PROPS_NAMESPACE,"set.block"))) dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error","You are not permitted to modify E-mail settings.")); // Get the global properties store. globals = vcast.getGlobalPropertiesStore(req); blocks = vcast.getGlobalBlocksStore(req); // Create the dialog. loader = cast.queryDialogLoader(req); dlg = loader.loadDialogResource("sysadmin/email.dlg.xml"); my_ns = VeniceNamespaces.MAIL_PROPS_NAMESPACE; // shortcut rc = null; if (req_help.isVerb("GET")) { // Load the dialog with its initial values. dlg.setValue("host",globals.getObject(my_ns,"smtp.host")); dlg.setValue("fromaddr",globals.getObject(my_ns,"system.mail.from.addr")); dlg.setValue("fromname",globals.getObject(my_ns,"system.mail.from.name")); dlg.setValue("mailer",globals.getObject(my_ns,"mailer.name")); dlg.setValue("uinfo",globals.getObject(my_ns,"user.info.header")); dlg.setValue("disclaimer",blocks.getObject(my_ns,"user.disclaimer")); dlg.setValue("sig",blocks.getObject(my_ns,"signature")); } // end if else { // Load information from the dialog op = dlg.getClickedButton(req) + ""; if (op=="cancel") // user cancelled - bounce back to the previous menu rc = new Redirect("SERVLET","sysadmin/main.js.vs"); else { // load and validate the dialog dlg.load(req); try { // validate the dialog dlg.validate(req); // set the appropriate values into the system properties globals.setObject(user,my_ns,"smtp.host",dlg.getValue("host")); globals.setObject(user,my_ns,"system.mail.from.addr",dlg.getValue("fromaddr")); globals.setObject(user,my_ns,"system.mail.from.name",dlg.getValue("fromname")); globals.setObject(user,my_ns,"mailer.name",dlg.getValue("mailer")); globals.setObject(user,my_ns,"user.info.header",dlg.getValue("uinfo")); blocks.setObject(user,my_ns,"user.disclaimer",dlg.getValue("disclaimer")); blocks.setObject(user,my_ns,"signature",dlg.getValue("sig")); // All done - bounce back to the menu. rc = new Redirect("SERVLET","sysadmin/main.js.vs"); } // 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(/ValidationException/)) dlg.setErrorMessage(dynamo.exceptionMessage(e) + " Please try again."); else if (etype.match(/DatabaseException/)) rc = new ErrorBox("Database Error",e,"SERVLET","sysadmin/main.js.vs"); else if (etype.match(/DynamoSecurityException/)) rc = new ErrorBox("Security Error",e,"SERVLET","sysadmin/main.js.vs"); else rc = new ErrorBox("Unknown Exception",e,"SERVLET","sysadmin/main.js.vs"); } // end catch } // end else } // end else if (rc==null) rc = new FrameDialog(dlg); // output dialog if we don't have another value dynamo.scriptOutput(rc);