|
Author: lektran
Date: Mon Nov 29 05:37:56 2010 New Revision: 1040016 URL: http://svn.apache.org/viewvc?rev=1040016&view=rev Log: Switched processWorkEffortEventReminder to use an EmailTemplateSetting record instead of its own property file. Modified: ofbiz/trunk/applications/workeffort/config/EventReminders.properties ofbiz/trunk/applications/workeffort/data/WorkEffortTypeData.xml ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java Modified: ofbiz/trunk/applications/workeffort/config/EventReminders.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/config/EventReminders.properties?rev=1040016&r1=1040015&r2=1040016&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/config/EventReminders.properties (original) +++ ofbiz/trunk/applications/workeffort/config/EventReminders.properties Mon Nov 29 05:37:56 2010 @@ -17,6 +17,10 @@ # under the License. ############################################################################### +# NOTE: This property file is now deprecated, you should instead configure your email template +# using the EmailTemplateSetting entity with the emailTemplateSettingId of "WEFF_EVENT_REMINDER". +# An example can be found in applications/workeffort/data/WorkEffortTypeData.xml + # The "from" address for emailed calendar event reminders eventReminders.emailFromAddress=[hidden email] # The screen widget used for emailed calendar event reminders. The parameters Map Modified: ofbiz/trunk/applications/workeffort/data/WorkEffortTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/data/WorkEffortTypeData.xml?rev=1040016&r1=1040015&r2=1040016&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/data/WorkEffortTypeData.xml (original) +++ ofbiz/trunk/applications/workeffort/data/WorkEffortTypeData.xml Mon Nov 29 05:37:56 2010 @@ -240,4 +240,7 @@ under the License. <ContactMechTypePurpose contactMechPurposeTypeId="ICAL_URL" contactMechTypeId="LDAP_ADDRESS"/> <ContactMechTypePurpose contactMechPurposeTypeId="ICAL_URL" contactMechTypeId="WEB_ADDRESS"/> + <!-- WorkEffort Email Template Settings --> + <EmailTemplateSetting emailTemplateSettingId="WEFF_EVENT_REMINDER" description="" fromAddress="[hidden email]" subject="Event Reminder" + bodyScreenLocation="component://workeffort/widget/WorkEffortScreens.xml#WorkEffortEventReminderEmail"/> </entity-engine-xml> Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=1040016&r1=1040015&r2=1040016&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java Mon Nov 29 05:37:56 2010 @@ -1009,8 +1009,9 @@ public class WorkEffortServices { return ServiceUtil.returnSuccess(); } - public static Map<String, Object> processWorkEffortEventReminder(DispatchContext ctx, Map<String, ? extends Object> context) { - LocalDispatcher dispatcher = ctx.getDispatcher(); + public static Map<String, Object> processWorkEffortEventReminder(DispatchContext dctx, Map<String, ? extends Object> context) { + LocalDispatcher dispatcher = dctx.getDispatcher(); + Delegator delegator = dctx.getDelegator(); Map<String, Object> parameters = UtilGenerics.checkMap(context.get("bodyParameters")); GenericValue reminder = (GenericValue) context.get("reminder"); GenericValue contactMech = null; @@ -1020,15 +1021,32 @@ public class WorkEffortServices { Debug.logError(e, module); } if (contactMech != null && "EMAIL_ADDRESS".equals(contactMech.get("contactMechTypeId"))) { - String screenLocation = UtilProperties.getPropertyValue("EventReminders", "eventReminders.emailScreenWidgetLocation"); - String fromAddress = UtilProperties.getPropertyValue("EventReminders", "eventReminders.emailFromAddress"); String toAddress = contactMech.getString("infoString"); - String subject = UtilProperties.getMessage("WorkEffortUiLabels", "WorkEffortEventReminder", (Locale) parameters.get("locale")); - Map<String, Object> emailCtx = UtilMisc.toMap("sendFrom", fromAddress, "sendTo", toAddress, "subject", subject, "bodyParameters", parameters, "bodyScreenUri", screenLocation); + + GenericValue emailTemplateSetting = null; try { - dispatcher.runAsync("sendMailFromScreen", emailCtx); - } catch (Exception e) { - Debug.logWarning("Error while emailing event reminder - workEffortId = " + reminder.get("workEffortId") + ", contactMechId = " + reminder.get("contactMechId") + ": " + e, module); + emailTemplateSetting = delegator.findOne("EmailTemplateSetting", true, "emailTemplateSettingId", "WEFF_EVENT_REMINDER"); + } catch (GenericEntityException e1) { + Debug.logError(e1, module); + } + if (emailTemplateSetting != null) { + Map<String, Object> emailCtx = UtilMisc.toMap("emailTemplateSettingId", "WEFF_EVENT_REMINDER", "sendTo", toAddress, "bodyParameters", parameters); + try { + dispatcher.runAsync("sendMailFromTemplateSetting", emailCtx); + } catch (Exception e) { + Debug.logWarning("Error while emailing event reminder - workEffortId = " + reminder.get("workEffortId") + ", contactMechId = " + reminder.get("contactMechId") + ": " + e, module); + } + } else { + // TODO: Remove this block after the next release 2010-11-29 + String screenLocation = UtilProperties.getPropertyValue("EventReminders", "eventReminders.emailScreenWidgetLocation"); + String fromAddress = UtilProperties.getPropertyValue("EventReminders", "eventReminders.emailFromAddress"); + String subject = UtilProperties.getMessage("WorkEffortUiLabels", "WorkEffortEventReminder", (Locale) parameters.get("locale")); + Map<String, Object> emailCtx = UtilMisc.toMap("sendFrom", fromAddress, "sendTo", toAddress, "subject", subject, "bodyParameters", parameters, "bodyScreenUri", screenLocation); + try { + dispatcher.runAsync("sendMailFromScreen", emailCtx); + } catch (Exception e) { + Debug.logWarning("Error while emailing event reminder - workEffortId = " + reminder.get("workEffortId") + ", contactMechId = " + reminder.get("contactMechId") + ": " + e, module); + } } return ServiceUtil.returnSuccess(); } |
| Free forum by Nabble | Edit this page |
