Author: hansbak
Date: Fri Dec 24 04:37:20 2010 New Revision: 1052447 URL: http://svn.apache.org/viewvc?rev=1052447&view=rev Log: several improvements and completion of the email contactlist subscribe and unsubscribe functions. Modified: ofbiz/trunk/applications/marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml ofbiz/trunk/applications/marketing/servicedef/secas.xml ofbiz/trunk/applications/marketing/servicedef/services.xml ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml ofbiz/trunk/applications/party/data/PartyTypeData.xml ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java ofbiz/trunk/framework/images/webapp/images/ecommain.css ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml ofbiz/trunk/specialpurpose/ecommerce/templates/email/ContactListVerifyEmail.ftl ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/miniSignUpForContactList.ftl ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/viewprofile.ftl ofbiz/trunk/specialpurpose/ecommerce/widget/EmailContactListScreens.xml Modified: ofbiz/trunk/applications/marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml (original) +++ ofbiz/trunk/applications/marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml Fri Dec 24 04:37:20 2010 @@ -182,6 +182,65 @@ under the License. <field-to-result field="parameters.productStoreId" result-name="productStoreId" /> <field-to-result field="parameters.contactListId" result-name="contactListId" /> </simple-method> + <simple-method method-name="updateContactListPartyNoUserLogin" short-description="Update Add Party To ContactList No User Login" login-required="false"> + <entity-one value-field="contactList" entity-name="ContactList"/> + <entity-and list="contactListPartyStatusList" entity-name="ContactListPartyStatus"> + <field-map field-name="contactListId" from-field="parameters.contactListId"/> + <field-map field-name="partyId" from-field="parameters.partyId"/> + <field-map field-name="optInVerifyCode" from-field="parameters.optInVerifyCode"/> + <field-map field-name="fromDate" from-field="parameters.fromDate"/> + </entity-and> + <if-not-empty field="contactListPartyStatusList"> + <set-service-fields service-name="updateContactListParty" map="parameters" to-map="updateContactListPartyMap"/> + <entity-one value-field="systemUserLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <set field="updateContactListPartyMap.userLogin" from-field="systemUserLogin"/> + <call-service service-name="updateContactListParty" in-map-name="updateContactListPartyMap"/> + <else> + <add-error><fail-message message="Invalid verify code for the ${contactList.contactListName}"/></add-error> + <check-errors/> + </else> + </if-not-empty> + </simple-method> + <simple-method method-name="unsubscribeContactListParty" short-description="Unsubscribe for contact list" login-required="false"> + <!-- check valid email --> + <call-class-method method-name="isEmail" class-name="org.ofbiz.base.util.UtilValidate" ret-field="isEmail"> + <field field="parameters.email"/> + </call-class-method> + <if-compare operator="equals" value="false" field="isEmail" type="Boolean"> + <add-error><fail-property resource="MarketingUiLabels" property="MarketingCampaignInvalidEmailInput"/></add-error> + <check-errors/> + </if-compare> + + <entity-one value-field="userLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <if-empty field="parameters.partyId"> + <set field="parameters.partyId" value="_NA_"/> + </if-empty> + <entity-and list="partyContactWithPurposes" entity-name="PartyContactWithPurpose"> + <field-map field-name="partyId" from-field="parameters.partyId"/> + <field-map field-name="infoString" from-field="parameters.email"/> + <field-map field-name="contactMechTypeId" value="EMAIL_ADDRESS"/> + <field-map field-name="contactMechPurposeTypeId" value="OTHER_EMAIL"/> + </entity-and> + <filter-list-by-date list="partyContactWithPurposes" from-field-name="contactFromDate" thru-field-name="contactThruDate"/> + <filter-list-by-date list="partyContactWithPurposes" from-field-name="purposeFromDate" thru-field-name="purposeThruDate"/> + <!-- if there is email contact mech for party then update contact list party's status to CLPT_UNSUBS_PENDING --> + <if-not-empty field="partyContactWithPurposes"> + <set field="updateContactListPartyMap.contactListId" from-field="parameters.contactListId"/> + <set field="updateContactListPartyMap.partyId" from-field="parameters.partyId"/> + <set field="updateContactListPartyMap.preferredContactMechId" from-field="partyContactWithPurposes[0].contactMechId"/> + <set field="updateContactListPartyMap.statusId" value="CLPT_UNSUBS_PENDING"/> + <set field="updateContactListPartyMap.userLogin" from-field="userLogin"/> + <call-service service-name="updateContactListParty" in-map-name="updateContactListPartyMap"/> + <else> + <add-error><fail-message message="The email address (${parameters.email}) does not have the Other Email Address as contact purpose."/></add-error> + <check-errors/> + </else> + </if-not-empty> + </simple-method> <simple-method method-name="updatePartyEmailContactListParty" short-description="Update ContactList Party Contact Mech"> <set field="lookupMap.preferredContactMechId" from-field="parameters.oldContactMechId"/> <find-by-and entity-name="ContactListParty" map="lookupMap" list="ContactListParties"/> @@ -395,29 +454,158 @@ under the License. </if-not-empty> </simple-method> + <simple-method method-name="sendContactListPartySubscribeEmail" short-description="Send contact list party subscribe email" login-required="true"> + <set field="productStoreId" type="String" from-field="parameters.productStoreId"/> + <entity-one value-field="contactList" entity-name="ContactList"/> + <entity-one value-field="contactListParty" entity-name="ContactListParty"/> + <!-- get the latest accepted status --> + <!-- look up the last ContactListPartyStatus with statusId=CLPT_ACCEPTED --> + <entity-condition entity-name="ContactListPartyStatus" list="lastContactListPartyStatusList"> + <condition-list combine="and"> + <condition-expr field-name="contactListId" from-field="parameters.contactListId"/> + <condition-expr field-name="partyId" from-field="parameters.partyId"/> + <condition-expr field-name="fromDate" from-field="parameters.fromDate"/> + <condition-expr field-name="statusId" value="CLPT_ACCEPTED"/> + </condition-list> + <order-by field-name="-statusDate"/> + </entity-condition> + <first-from-list entry="contactListPartyStatus" list="lastContactListPartyStatusList"/> + + <if-empty field="productStoreId"> + <entity-one value-field="webSite" entity-name="WebSite"> + <field-map field-name="webSiteId" from-field="contactList.verifyEmailWebSiteId"/> + </entity-one> + <set field="productStoreId" from-field="webSite.productStoreId"/> + </if-empty> + <entity-one entity-name="ProductStoreEmailSetting" value-field="storeEmail" auto-field-map="false"> + <field-map field-name="productStoreId" from-field="productStoreId"/> + <field-map field-name="emailType" value="SUB_CONT_LIST_NOTI"/> + </entity-one> + <entity-one entity-name="ContactMech" value-field="contactMech" auto-field-map="false"> + <field-map field-name="contactMechId" from-field="parameters.preferredContactMechId"/> + </entity-one> + <if-not-empty field="storeEmail.bodyScreenLocation"> + <!-- send email from screen --> + <set field="bodyParameters.contactListId" from-field="parameters.contactListId"/> + <set field="bodyParameters.partyId" from-field="parameters.partyId"/> + <set field="bodyParameters.contactList" from-field="contactList"/> + <set field="bodyParameters.contactListParty" from-field="contactListParty"/> + <set field="bodyParameters.contactListPartyStatus" from-field="contactListPartyStatus"/> + + <set field="emailParams.bodyParameters" from-field="bodyParameters"/> + <set field="emailParams.userLogin" from-field="userLogin"/> + <set field="emailParams.webSiteId" from-field="contactList.verifyEmailWebSiteId"/> + <set field="emailParams.sendTo" from-field="contactMech.infoString"/> + <set field="emailParams.sendFrom" from-field="storeEmail.fromAddress"/> + <set field="emailParams.subject" value="${storeEmail.subject} ${contactList.contactListName}"/> + <set field="emailParams.bodyScreenUri" from-field="storeEmail.bodyScreenLocation"/> + <set field="emailParams.contentType" value="text/html"/> + <call-service service-name="sendMailFromScreen" in-map-name="emailParams"/> + </if-not-empty> + </simple-method> + + <simple-method method-name="sendContactListPartyUnSubscribeVerifyEmail" short-description="Send contact list party unsubscribe verify email" login-required="true"> + <if> + <condition> + <and> + <not><if-has-permission permission="MARKETING" action="_VIEW"/></not> + </and> + </condition> + <then><add-error><fail-message message="Security Error: to run sendContactListPartyVerifyEmail you must have the MARKETING_VIEW or MARKETING_ADMIN permissions."/></add-error></then> + </if> + <check-errors/> + + <entity-one entity-name="ContactList" value-field="contactList"/> + <entity-one entity-name="ContactListParty" value-field="contactListParty"/> + <get-related-one value-field="contactListParty" relation-name="PreferredContactMech" to-value-field="preferredContactMech"/> + + <!-- get the latest accepted status --> + <!-- look up the last ContactListPartyStatus with statusId=CLPT_ACCEPTED --> + <entity-condition entity-name="ContactListPartyStatus" list="lastContactListPartyStatusList"> + <condition-list combine="and"> + <condition-expr field-name="contactListId" from-field="parameters.contactListId"/> + <condition-expr field-name="partyId" from-field="parameters.partyId"/> + <condition-expr field-name="fromDate" from-field="parameters.fromDate"/> + <condition-expr field-name="statusId" value="CLPT_ACCEPTED"/> + </condition-list> + <order-by field-name="-statusDate"/> + </entity-condition> + <first-from-list entry="contactListPartyStatus" list="lastContactListPartyStatusList"/> + + <set field="productStoreId" type="String" from-field="parameters.productStoreId"/> + <entity-one value-field="contactList" entity-name="ContactList"/> + <if-empty field="productStoreId"> + <entity-one value-field="webSite" entity-name="WebSite"> + <field-map field-name="webSiteId" from-field="contactList.verifyEmailWebSiteId"/> + </entity-one> + <set field="productStoreId" from-field="webSite.productStoreId"/> + </if-empty> + <entity-one entity-name="ProductStoreEmailSetting" value-field="storeEmail" auto-field-map="false"> + <field-map field-name="productStoreId" from-field="productStoreId"/> + <field-map field-name="emailType" value="UNSUB_CONT_LIST_VERI"/> + </entity-one> + <entity-one entity-name="ContactMech" value-field="contactMech" auto-field-map="false"> + <field-map field-name="contactMechId" from-field="parameters.preferredContactMechId"/> + </entity-one> + <if-not-empty field="storeEmail.bodyScreenLocation"> + <!-- create communication event --> + <set field="createCommunicationEventInMap.contactListId" from-field="contactList.contactListId"/> + <set field="createCommunicationEventInMap.partyIdTo" from-field="contactListParty.partyId"/> + <set field="createCommunicationEventInMap.contactMechIdTo" from-field="contactListParty.preferredContactMechId"/> + <set field="createCommunicationEventInMap.fromString" from-field="storeEmail.fromAddress"/> + <set field="createCommunicationEventInMap.toString" from-field="contactMech.infoString"/> + <set field="createCommunicationEventInMap.userLogin" from-field="contactMech.userLogin"/> + <set field="createCommunicationEventInMap.subject" value="${storeEmail.subject} ${contactList.contactListName}"/> + <call-service service-name="createCommunicationEvent" in-map-name="createCommunicationEventInMap"> + <result-to-field result-name="communicationEventId"/> + </call-service> + + <!-- send email from screen --> + <set field="bodyParameters.contactListId" from-field="parameters.contactListId"/> + <set field="bodyParameters.partyId" from-field="parameters.partyId"/> + <set field="bodyParameters.contactList" from-field="contactList"/> + <set field="bodyParameters.contactListParty" from-field="contactListParty"/> + <set field="bodyParameters.contactListPartyStatus" from-field="contactListPartyStatus"/> + + <set field="emailParams.webSiteId" from-field="contactList.verifyEmailWebSiteId"/> + <set field="emailParams.bodyParameters" from-field="bodyParameters"/> + <set field="emailParams.communicationEventId" from-field="communicationEventId"/> + <set field="emailParams.userLogin" from-field="userLogin"/> + <set field="emailParams.sendTo" from-field="contactMech.infoString"/> + <set field="emailParams.sendFrom" from-field="storeEmail.fromAddress"/> + <set field="emailParams.subject" value="${storeEmail.subject} ${contactList.contactListName}"/> + <set field="emailParams.bodyScreenUri" from-field="storeEmail.bodyScreenLocation"/> + <set field="emailParams.contentType" value="text/html"/> + <call-service service-name="sendMailFromScreen" in-map-name="emailParams"/> + </if-not-empty> + </simple-method> <simple-method method-name="sendContactListPartyUnSubscribeEmail" short-description="Send contact list party unsubscribe email" login-required="true"> <set field="productStoreId" type="String" from-field="parameters.productStoreId"/> + <entity-one value-field="contactList" entity-name="ContactList"/> + <if-empty field="productStoreId"> + <entity-one value-field="webSite" entity-name="WebSite"> + <field-map field-name="webSiteId" from-field="contactList.verifyEmailWebSiteId"/> + </entity-one> + <set field="productStoreId" from-field="webSite.productStoreId"/> + </if-empty> <entity-one entity-name="ProductStoreEmailSetting" value-field="storeEmail" auto-field-map="false"> <field-map field-name="productStoreId" from-field="productStoreId"/> <field-map field-name="emailType" value="UNSUB_CONT_LIST_NOTI"/> </entity-one> - <entity-and entity-name="PartyContactMechPurpose" list="partyContactMechPurposes"> - <field-map field-name="partyId" from-field="userLogin.partyId"/> - <field-map field-name="contactMechPurposeTypeId" value="PRIMARY_EMAIL"/> - </entity-and> - <first-from-list list="partyContactMechPurposes" entry="partyContactMechPurpose"/> <entity-one entity-name="ContactMech" value-field="contactMech" auto-field-map="false"> - <field-map field-name="contactMechId" from-field="partyContactMechPurpose.contactMechId"/> + <field-map field-name="contactMechId" from-field="parameters.preferredContactMechId"/> </entity-one> <if-not-empty field="storeEmail.bodyScreenLocation"> <set field="bodyParameters.contactListId" from-field="parameters.contactListId"/> - <set field="bodyParameters.partyId" from-field="userLogin.partyId"/> + <set field="bodyParameters.partyId" from-field="parameters.partyId"/> + <set field="emailParams.webSiteId" from-field="contactList.verifyEmailWebSiteId"/> <set field="emailParams.bodyParameters" from-field="bodyParameters"/> <set field="emailParams.userLogin" from-field="userLogin"/> <set field="emailParams.sendTo" from-field="contactMech.infoString"/> <set field="emailParams.sendFrom" from-field="storeEmail.fromAddress"/> - <set field="emailParams.subject" from-field="storeEmail.subject"/> + <set field="emailParams.subject" value="${storeEmail.subject} ${contactList.contactListName}"/> <set field="emailParams.bodyScreenUri" from-field="storeEmail.bodyScreenLocation"/> + <set field="emailParams.contentType" value="text/html"/> <call-service service-name="sendMailFromScreen" in-map-name="emailParams"/> </if-not-empty> </simple-method> Modified: ofbiz/trunk/applications/marketing/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/servicedef/secas.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/marketing/servicedef/secas.xml Fri Dec 24 04:37:20 2010 @@ -24,6 +24,10 @@ under the License. <condition field-name="statusId" operator="equals" value="CLPT_PENDING"/> <action service="sendContactListPartyVerifyEmail" mode="async" persist="true"/> </eca> + <eca service="createContactListPartyStatus" event="commit"> + <condition field-name="statusId" operator="equals" value="CLPT_ACCEPTED"/> + <action service="sendContactListPartySubscribeEmail" mode="async" persist="true"/> + </eca> <eca service="updatePartyEmailAddress" event="return"> <action service="updatePartyEmailContactListParty" mode="sync"/> </eca> @@ -31,6 +35,14 @@ under the License. <condition field-name="statusId" operator="equals" value="CLPT_REJECTED"/> <action service="sendContactListPartyUnSubscribeEmail" mode="sync" persist="true"/> </eca> + <eca service="createContactListPartyStatus" event="commit"> + <condition field-name="statusId" operator="equals" value="CLPT_UNSUBSCRIBED"/> + <action service="sendContactListPartyUnSubscribeEmail" mode="async" persist="true"/> + </eca> + <eca service="createContactListPartyStatus" event="commit"> + <condition field-name="statusId" operator="equals" value="CLPT_UNSUBS_PENDING"/> + <action service="sendContactListPartyUnSubscribeVerifyEmail" mode="async" persist="true"/> + </eca> <!-- update contact list communication status --> <eca service="updateCommunicationEvent" event="commit"> Modified: ofbiz/trunk/applications/marketing/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/servicedef/services.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/servicedef/services.xml (original) +++ ofbiz/trunk/applications/marketing/servicedef/services.xml Fri Dec 24 04:37:20 2010 @@ -78,6 +78,14 @@ under the License. <attribute name="email" type="String" mode="IN" optional="false"/> <attribute name="partyId" type="String" mode="IN" optional="true"/> </service> + <service name="unsubscribeContactListParty" engine="simple" + location="component://marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml" invoke="unsubscribeContactListParty" auth="false"> + <description>Unsubscribe an input email for a ContactList with _NA_ party using the system userLogin. + The intent is for anonymous unsubscribe to email lists. Also validates email format.</description> + <attribute name="contactListId" type="String" mode="IN" optional="false"/> + <attribute name="email" type="String" mode="IN" optional="false"/> + <attribute name="partyId" type="String" mode="IN" optional="true"/> + </service> <!-- MarketingCampaignRole Services --> <service name="addRoleToMarketingCampaign" default-entity-name="MarketingCampaignRole" engine="simple" @@ -149,6 +157,19 @@ under the License. <attribute name="optInVerifyCode" type="String" mode="IN" optional="true"/> <override name="fromDate" optional="true"/> </service> + <service name="updateContactListPartyNoUserLogin" default-entity-name="ContactListParty" engine="simple" + location="component://marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml" invoke="updateContactListPartyNoUserLogin" auth="false"> + <description>Update Party to ContactList Join</description> + <auto-attributes include="pk" mode="IN" optional="false"/> + <auto-attributes include="nonpk" mode="IN" optional="true"/> + <attribute name="webSiteId" type="String" mode="IN" optional="true"/> + <attribute name="productStoreId" type="String" mode="INOUT" optional="true"/> + <attribute name="contactListId" type="String" mode="INOUT" optional="true"/> + <attribute name="optInVerifyCode" type="String" mode="IN" optional="true"/> + <attribute name="email" type="String" mode="IN" optional="true"/> + <override name="partyId" optional="true"/> + <override name="fromDate" optional="true"/> + </service> <service name="updatePartyEmailContactListParty" engine="simple" location="component://marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml" invoke="updatePartyEmailContactListParty" auth="true"> <description>Update ContactList Party Contact Mech</description> @@ -169,6 +190,7 @@ under the License. <auto-attributes include="nonpk" mode="IN" optional="true"> <exclude field-name="setByUserLoginId"/> </auto-attributes> + <attribute name="preferredContactMechId" mode="IN" type="String" optional="false"/> <override name="statusId" optional="false"/> <override name="fromDate" optional="true"/> </service> @@ -183,12 +205,31 @@ under the License. <attribute name="communicationEventId" type="String" mode="IN" optional="false"/> <attribute name="contactListId" type="String" mode="OUT" optional="true"/> </service> + <service name="sendContactListPartySubscribeEmail" engine="simple" + location="component://marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml" invoke="sendContactListPartySubscribeEmail" auth="false"> + <attribute name="productStoreId" mode="IN" type="String" optional="true"/> + <attribute name="partyId" mode="IN" type="String" optional="true"/> + <attribute name="contactListId" mode="IN" type="String" optional="true"/> + <attribute name="preferredContactMechId" mode="IN" type="String" optional="false"/> + <attribute name="fromDate" mode="IN" type="Timestamp" optional="true"/> + <attribute name="statusId" mode="IN" type="String" optional="true"/> + </service> + <service name="sendContactListPartyUnSubscribeVerifyEmail" engine="simple" + location="component://marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml" invoke="sendContactListPartyUnSubscribeVerifyEmail" auth="false"> + <attribute name="productStoreId" mode="IN" type="String" optional="true"/> + <attribute name="partyId" mode="IN" type="String" optional="true"/> + <attribute name="contactListId" mode="IN" type="String" optional="true"/> + <attribute name="preferredContactMechId" mode="IN" type="String" optional="false"/> + <attribute name="fromDate" mode="IN" type="Timestamp" optional="true"/> + <attribute name="statusId" mode="IN" type="String" optional="true"/> + </service> <service name="sendContactListPartyUnSubscribeEmail" engine="simple" location="component://marketing/script/org/ofbiz/marketing/contact/ContactListServices.xml" invoke="sendContactListPartyUnSubscribeEmail" auth="false"> <attribute name="productStoreId" mode="IN" type="String" optional="true"/> <attribute name="partyId" mode="IN" type="String" optional="true"/> <attribute name="contactListId" mode="IN" type="String" optional="true"/> - <attribute name="fromDate" mode="IN" type="String" optional="true"/> + <attribute name="preferredContactMechId" mode="IN" type="String" optional="false"/> + <attribute name="fromDate" mode="IN" type="Timestamp" optional="true"/> <attribute name="statusId" mode="IN" type="String" optional="true"/> </service> Modified: ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java (original) +++ ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java Fri Dec 24 04:37:20 2010 @@ -85,7 +85,7 @@ public class MarketingServices { String contactMechId = (String) serviceResults.get("contactMechId"); // create a new association at this fromDate to the anonymous party with status accepted input = UtilMisc.toMap("userLogin", userLogin, "contactListId", contactList.get("contactListId"), - "partyId", partyId, "fromDate", fromDate, "statusId", "CLPT_ACCEPTED", "preferredContactMechId", contactMechId); + "partyId", partyId, "fromDate", fromDate, "statusId", "CLPT_PENDING", "preferredContactMechId", contactMechId); serviceResults = dispatcher.runSync("createContactListParty", input); if (ServiceUtil.isError(serviceResults)) { throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults)); Modified: ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml Fri Dec 24 04:37:20 2010 @@ -329,6 +329,7 @@ under the License. </request-map> <request-map uri="contactListOptOut" track-serverhit="false" track-visit="false"> <security https="true" auth="false"/> + <event type="service" invoke="updateContactListPartyNoUserLogin"/> <response name="success" type="view" value="ContactListOptOut"/> </request-map> Modified: ofbiz/trunk/applications/party/data/PartyTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/data/PartyTypeData.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/party/data/PartyTypeData.xml (original) +++ ofbiz/trunk/applications/party/data/PartyTypeData.xml Fri Dec 24 04:37:20 2010 @@ -154,6 +154,9 @@ under the License. <Enumeration description="Party Invitation" enumCode="INVITE_EMAIL" enumId="PRDS_PARTYINV_EMAIL" sequenceId="04" enumTypeId="PARTY_EMAIL"/> <Enumeration description="Contact-Us Notification" enumCode="CONT_EMAIL" enumId="CONT_NOTI_EMAIL" sequenceId="05" enumTypeId="PARTY_EMAIL"/> <Enumeration description="Unsubscribe Contact List Notification" enumCode="UNSUB_CONT_EMAIL" enumId="UNSUB_CONT_LIST_NOTI" sequenceId="01" enumTypeId="PARTY_EMAIL"/> + <Enumeration description="Subscribe Contact List Notification" enumCode="SUB_CONT_EMAIL" enumId="SUB_CONT_LIST_NOTI" sequenceId="02" enumTypeId="PARTY_EMAIL"/> + <Enumeration description="Unsubscribe Contact List Verify" enumCode="UNSUB_CONT_VERIFY_EMAIL" enumId="UNSUB_CONT_LIST_VERI" sequenceId="03" enumTypeId="PARTY_EMAIL"/> + <Enumeration description="Contact List E-mail Template" enumCode="CONT_EMAIL_TEMPLATE" enumId="CONT_EMAIL_TEMPLATE" sequenceId="04" enumTypeId="PARTY_EMAIL"/> <!-- the groups which are the main roles on he party listing --> <RoleType description="Main Role" hasTable="N" parentTypeId="" roleTypeId="MAIN_ROLE"/> Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Fri Dec 24 04:37:20 2010 @@ -54,6 +54,7 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.common.email.NotificationServices; import org.ofbiz.content.data.DataResourceWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -292,7 +293,6 @@ public class CommunicationEventServices Map<String, Object> sendMailParams = FastMap.newInstance(); sendMailParams.put("sendFrom", communicationEvent.getRelatedOne("FromContactMech").getString("infoString")); sendMailParams.put("subject", communicationEvent.getString("subject")); - sendMailParams.put("body", communicationEvent.getString("content")); sendMailParams.put("contentType", communicationEvent.getString("contentMimeTypeId")); sendMailParams.put("userLogin", userLogin); @@ -305,7 +305,7 @@ public class CommunicationEventServices EntityUtil.getFilterByDateExpr(), EntityUtil.getFilterByDateExpr("contactFromDate", "contactThruDate")); EntityConditionList<EntityCondition> conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND); - Set<String> fieldsToSelect = UtilMisc.toSet("infoString"); + Set<String> fieldsToSelect = UtilMisc.toSet("partyId", "preferredContactMechId", "fromDate", "infoString"); eli = delegator.find("ContactListPartyAndContactMech", conditions, null, fieldsToSelect, null, new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true)); @@ -347,6 +347,7 @@ public class CommunicationEventServices sendMailParams.put("sendTo", emailAddress); sendMailParams.put("partyId", partyId); + // if it is a NEWSLETTER then we do not want the outgoing emails stored, so put a communicationEventId in the sendMail context to prevent storeEmailAsCommunicationEvent from running /* @@ -371,10 +372,51 @@ public class CommunicationEventServices // There was a successful earlier attempt, so skip this address continue; } - + + // Send e-mail Debug.logInfo("Sending email to contact list [" + contactListId + "] party [" + partyId + "] : " + emailAddress, module); // Make the attempt to send the email to the address - Map<String, Object> tmpResult = dispatcher.runSync("sendMail", sendMailParams, 360, true); + + Map<String, Object> tmpResult = null; + + // Retrieve a contact list party status + List<GenericValue> contactListPartyStatuses = delegator.findByAnd("ContactListPartyStatus", UtilMisc.toMap("contactListId", contactListId, "partyId", contactListPartyAndContactMech.getString("partyId"), "fromDate", contactListPartyAndContactMech.getTimestamp("fromDate"), "statusId", "CLPT_ACCEPTED")); + GenericValue contactListPartyStatus = EntityUtil.getFirst(contactListPartyStatuses); + if (UtilValidate.isNotEmpty(contactListPartyStatus)) { + // prepare body parameters + Map<String, Object> bodyParameters = FastMap.newInstance(); + bodyParameters.put("contactListId", contactListId); + bodyParameters.put("partyId", contactListPartyAndContactMech.getString("partyId")); + bodyParameters.put("preferredContactMechId", contactListPartyAndContactMech.getString("preferredContactMechId")); + bodyParameters.put("emailAddress", emailAddress); + bodyParameters.put("fromDate", contactListPartyAndContactMech.getTimestamp("fromDate")); + bodyParameters.put("optInVerifyCode", contactListPartyStatus.getString("optInVerifyCode")); + bodyParameters.put("content", communicationEvent.getString("content")); + NotificationServices.setBaseUrl(delegator, contactList.getString("verifyEmailWebSiteId"), bodyParameters); + + GenericValue webSite = delegator.findOne("WebSite", UtilMisc.toMap("webSiteId", contactList.getString("verifyEmailWebSiteId")), false); + if (UtilValidate.isNotEmpty(webSite)) { + GenericValue productStore = webSite.getRelatedOne("ProductStore"); + if (UtilValidate.isNotEmpty(productStore)) { + List<GenericValue> productStoreEmailSettings = productStore.getRelatedByAnd("ProductStoreEmailSetting", UtilMisc.toMap("emailType", "CONT_EMAIL_TEMPLATE")); + GenericValue productStoreEmailSetting = EntityUtil.getFirst(productStoreEmailSettings); + if (UtilValidate.isNotEmpty(productStoreEmailSetting)) { + // send e-mail using screen template + sendMailParams.put("bodyScreenUri", productStoreEmailSetting.getString("bodyScreenLocation")); + sendMailParams.put("bodyParameters", bodyParameters); + sendMailParams.remove("body"); + tmpResult = dispatcher.runSync("sendMailFromScreen", sendMailParams, 360, true); + } + } + } + } + + // If the e-mail does not be sent then send normal e-mail + if (UtilValidate.isEmpty(tmpResult)) { + sendMailParams.put("body", communicationEvent.getString("content")); + tmpResult = dispatcher.runSync("sendMail", sendMailParams, 360, true); + } + if (tmpResult == null || ServiceUtil.isError(tmpResult)) { if (ServiceUtil.getErrorMessage(tmpResult).startsWith("[ADDRERR]")) { // address error; mark the communication event as BOUNCED Modified: ofbiz/trunk/framework/images/webapp/images/ecommain.css URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/ecommain.css?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/ecommain.css (original) +++ ofbiz/trunk/framework/images/webapp/images/ecommain.css Fri Dec 24 04:37:20 2010 @@ -124,7 +124,8 @@ font-weight:700; margin:2px; } -input[type=submit]:hover { +input[type=submit]:hover, +input[type=button]:hover { color:red; cursor:pointer; text-decoration:underline; Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml Fri Dec 24 04:37:20 2010 @@ -124,7 +124,10 @@ under the License. <ProductStoreEmailSetting productStoreId="9000" emailType="CONT_NOTI_EMAIL" bodyScreenLocation="component://ecommerce/widget/EmailContactListScreens.xml#ContactUsEmailNotification" subject="Contact-us Information Notification" fromAddress="[hidden email]" /> + <ProductStoreEmailSetting productStoreId="9000" emailType="SUB_CONT_LIST_NOTI" bodyScreenLocation="component://ecommerce/widget/EmailContactListScreens.xml#ContactListSubscribeEmail" subject="Subscribe Contact List" fromAddress="[hidden email]"/> + <ProductStoreEmailSetting productStoreId="9000" emailType="UNSUB_CONT_LIST_VERI" bodyScreenLocation="component://ecommerce/widget/EmailContactListScreens.xml#ContactListUnsubscribeVerifyEmail" subject="Verify Unsubscribe Contact List" fromAddress="[hidden email]"/> <ProductStoreEmailSetting productStoreId="9000" emailType="UNSUB_CONT_LIST_NOTI" bodyScreenLocation="component://ecommerce/widget/EmailContactListScreens.xml#ContactListUnsubscribeEmail" subject="Unsubscribe Contact List" fromAddress="[hidden email]"/> + <ProductStoreEmailSetting productStoreId="9000" emailType="CONT_EMAIL_TEMPLATE" bodyScreenLocation="component://ecommerce/widget/EmailContactListScreens.xml#ContactListEmailTemplate"/> <WebAnalyticsConfig productStoreId="9000" webAnalyticsTypeId="GOOGLE_ANALYTICS" webAnalyticsCode="123456" isEnabled="Y" description="This is code provided from google analytics" contentId="GOOGLE_ANA_CNT"/> <WebAnalyticsConfig productStoreId="9000" webAnalyticsTypeId="BING_ANALYTICS" webAnalyticsCode="123456" isEnabled="Y" description="This is code provided from bing analytics" contentId="BING_ANA_CNT"/> Modified: ofbiz/trunk/specialpurpose/ecommerce/templates/email/ContactListVerifyEmail.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/templates/email/ContactListVerifyEmail.ftl?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/templates/email/ContactListVerifyEmail.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/templates/email/ContactListVerifyEmail.ftl Fri Dec 24 04:37:20 2010 @@ -35,11 +35,12 @@ under the License. <p class="tabletext">To complete your subscription use the verify form in your <a href="${baseEcommerceSecureUrl}viewprofile">online profile</a>, or use the following link:</p> <#if (contactListPartyStatus.optInVerifyCode)?has_content><p class="tabletext">Your verify code is: ${contactListPartyStatus.optInVerifyCode}</p></#if> -<#assign verifyUrl = baseEcommerceSecureUrl + "updateContactListParty" /> -<form method="post" id="updateContactListParty" action="${verifyUrl}"> +<#assign verifyUrl = baseEcommerceSecureUrl + "updateContactListPartyNoUserLogin" /> +<form method="post" id="updateContactListPartyNoUserLogin" action="${verifyUrl}"> <fieldset> <input type="hidden" name="contactListId" value="${contactListParty.contactListId}" /> <input type="hidden" name="partyId" value="${contactListParty.partyId}" /> + <input type="hidden" name="preferredContactMechId" value="${contactListParty.preferredContactMechId?if_exists}" /> <input type="hidden" name="fromDate" value="${contactListParty.fromDate}" /> <input type="hidden" name="statusId" value="CLPT_ACCEPTED" /> <input type="hidden" name="optInVerifyCode" value="${contactListPartyStatus.optInVerifyCode?if_exists}" /> Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Fri Dec 24 04:37:20 2010 @@ -1316,6 +1316,17 @@ under the License. <response name="success" type="view" value="main"/> <response name="error" type="view" value="main"/> </request-map> + <request-map uri="unsubscribeContactListParty"> + <security https="false" auth="false"/> + <event type="service" invoke="unsubscribeContactListParty"/> + <response name="success" type="view" value="main"/> + <response name="error" type="view" value="main"/> + </request-map> + <request-map uri="contactListOptOut" track-serverhit="false" track-visit="false"> + <security https="true" auth="false"/> + <event type="service" invoke="updateContactListPartyNoUserLogin"/> + <response name="success" type="view" value="ContactListOptOut"/> + </request-map> <!-- ======================= Content Requests: Forums/Content/Articles ======================= --> @@ -1566,6 +1577,12 @@ under the License. <response name="success" type="view" value="viewprofile"/> <response name="error" type="view" value="viewprofile"/> </request-map> + <request-map uri="updateContactListPartyNoUserLogin"> + <security https="true" auth="false"/> + <event type="service" invoke="updateContactListPartyNoUserLogin"/> + <response name="success" type="view" value="main"/> + <response name="error" type="view" value="main"/> + </request-map> <request-map uri="choosecatalog"> <security https="true" auth="false"/> @@ -2051,5 +2068,8 @@ under the License. <!-- Product in the different UOM --> <view-map name="ProductUomDropDownOnly" type="screen" page="component://order/widget/ordermgr/OrderEntryCatalogScreens.xml#ProductUomDropDownOnly"/> + + <!-- Contact List --> + <view-map name="ContactListOptOut" type="screen" page="component://marketing/widget/ContactListScreens.xml#OptOutResponse"/> <!-- End of View Mappings --> </site-conf> Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/miniSignUpForContactList.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/miniSignUpForContactList.ftl?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/miniSignUpForContactList.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/miniSignUpForContactList.ftl Fri Dec 24 04:37:20 2010 @@ -27,6 +27,15 @@ under the License. </select> </#macro> +<script type="text/javascript" language="JavaScript"> + function unsubscribe() { + var form = document.getElementById("signUpForContactListForm"); + form.action = "<@ofbizUrl>unsubscribeContactListParty</@ofbizUrl>" + document.getElementById("statusId").value = "CLPT_UNSUBS_PENDING"; + form.submit(); + } +</script> + <div id="miniSignUpForContactList" class="screenlet"> <div class="screenlet-title-bar"> <ul> @@ -39,10 +48,10 @@ under the License. <#-- The visitor potentially has an account and party id --> <#if userLogin?has_content && userLogin.userLoginId != "anonymous"> <#-- They are logged in so lets present the form to sign up with their email address --> - <form method="post" action="<@ofbizUrl>createContactListParty</@ofbizUrl>" name="signUpForContactListForm"> + <form method="post" action="<@ofbizUrl>createContactListParty</@ofbizUrl>" name="signUpForContactListForm" id="signUpForContactListForm"> <fieldset> <input type="hidden" name="partyId" value="${partyId}"/> - <input type="hidden" name="statusId" value="CLPT_PENDING"/> + <input type="hidden" id="statusId" name="statusId" value="CLPT_PENDING"/> <p>${uiLabelMap.EcommerceSignUpForContactListComments}</p> <div> <@contactList publicEmailContactLists=publicEmailContactLists/> @@ -56,6 +65,7 @@ under the License. </div> <div> <input type="submit" value="${uiLabelMap.EcommerceSubscribe}"/> + <input type="button" value="${uiLabelMap.EcommerceUnsubscribe}" onclick="javascript:unsubscribe();"/> </div> </fieldset> </form> @@ -69,6 +79,7 @@ under the License. <#-- There is no party info so just offer an anonymous (non-partyId) related newsletter sign up --> <form method="post" action="<@ofbizUrl>signUpForContactList</@ofbizUrl>" name="signUpForContactListForm" id="signUpForContactListForm"> <fieldset> + <input type="hidden" id="statusId" name="statusId"/> <div> <label>${uiLabelMap.EcommerceSignUpForContactListComments}</label> <@contactList publicEmailContactLists=publicEmailContactLists/> @@ -78,6 +89,7 @@ under the License. </div> <div> <input type="submit" value="${uiLabelMap.EcommerceSubscribe}"/> + <input type="button" value="${uiLabelMap.EcommerceUnsubscribe}" onclick="javascript:unsubscribe();"/> </div> </fieldset> </form> Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/viewprofile.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/viewprofile.ftl?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/viewprofile.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/viewprofile.ftl Fri Dec 24 04:37:20 2010 @@ -491,6 +491,7 @@ under the License. <input type="hidden" name="productStoreId" value="${productStoreId?if_exists}" /> <input type="hidden" name="partyId" value="${party.partyId}"/> <input type="hidden" name="contactListId" value="${contactListParty.contactListId}"/> + <input type="hidden" name="preferredContactMechId" value="${contactListParty.preferredContactMechId}"/> <input type="hidden" name="fromDate" value="${contactListParty.fromDate}"/> <input type="hidden" name="statusId" value="CLPT_REJECTED"/> <input type="submit" value="${uiLabelMap.EcommerceUnsubscribe}" class="smallSubmit"/> @@ -501,6 +502,7 @@ under the License. <div> <input type="hidden" name="partyId" value="${party.partyId}"/> <input type="hidden" name="contactListId" value="${contactListParty.contactListId}"/> + <input type="hidden" name="preferredContactMechId" value="${contactListParty.preferredContactMechId}"/> <input type="hidden" name="fromDate" value="${contactListParty.fromDate}"/> <input type="hidden" name="statusId" value="CLPT_ACCEPTED"/> <input type="text" size="10" name="optInVerifyCode" value="" class="inputBox"/> @@ -512,6 +514,7 @@ under the License. <div> <input type="hidden" name="partyId" value="${party.partyId}"/> <input type="hidden" name="contactListId" value="${contactListParty.contactListId}"/> + <input type="hidden" name="preferredContactMechId" value="${contactListParty.preferredContactMechId}"/> <input type="hidden" name="fromDate" value="${contactListParty.fromDate}"/> <input type="hidden" name="statusId" value="CLPT_PENDING"/> <input type="submit" value="${uiLabelMap.EcommerceSubscribe}" class="smallSubmit"/> Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/EmailContactListScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/EmailContactListScreens.xml?rev=1052447&r1=1052446&r2=1052447&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/widget/EmailContactListScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/widget/EmailContactListScreens.xml Fri Dec 24 04:37:20 2010 @@ -62,15 +62,55 @@ under the License. </section> </screen> + <screen name="ContactListSubscribeEmail"> + <section> + <actions> + <entity-one entity-name="ContactList" value-field="contactList"/> + <entity-one entity-name="PartyNameView" value-field="partyName"/> + <set field="baseEcommerceSecureUrl" value="${baseSecureUrl}/ecommerce/control/"/> + </actions> + <widgets> + <platform-specific><html><html-template location="component://ecommerce/templates/email/ContactListSubscribeEmail.ftl"/></html></platform-specific> + </widgets> + </section> + </screen> + + <screen name="ContactListUnsubscribeVerifyEmail"> + <section> + <actions> + <entity-one entity-name="ContactList" value-field="contactList"/> + <entity-one entity-name="PartyNameView" value-field="partyName"/> + <set field="baseEcommerceSecureUrl" value="${baseSecureUrl}/ecommerce/control/"/> + </actions> + <widgets> + <platform-specific><html><html-template location="component://ecommerce/templates/email/ContactListUnsubscribeVerifyEmail.ftl"/></html></platform-specific> + </widgets> + </section> + </screen> + <screen name="ContactListUnsubscribeEmail"> <section> <actions> <entity-one entity-name="ContactList" value-field="contactList"/> <entity-one entity-name="PartyNameView" value-field="partyName"/> + <set field="baseEcommerceSecureUrl" value="${baseSecureUrl}/ecommerce/control/"/> </actions> <widgets> <platform-specific><html><html-template location="component://ecommerce/templates/email/ContactListUnsubscribeEmail.ftl"/></html></platform-specific> </widgets> </section> </screen> + + <screen name="ContactListEmailTemplate"> + <section> + <actions> + <entity-one entity-name="ContactList" value-field="contactList"/> + <entity-one entity-name="PartyNameView" value-field="partyName"/> + <set field="baseEcommerceSecureUrl" value="${baseSecureUrl}/ecommerce/control/"/> + </actions> + <widgets> + <platform-specific><html><html-template location="component://ecommerce/templates/email/ContactListEmailTemplate.ftl"/></html></platform-specific> + </widgets> + </section> + </screen> </screens> |
Free forum by Nabble | Edit this page |