Author: hansbak
Date: Fri Dec 24 05:45:19 2010 New Revision: 1052449 URL: http://svn.apache.org/viewvc?rev=1052449&view=rev Log: make the ecommerce 'contactus' not require login, add captcha and will try to match entered email address to party, whennot create the party. Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml ofbiz/trunk/framework/images/webapp/images/ecommain.css ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/AnonContactus.ftl Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.xml?rev=1052449&r1=1052448&r2=1052449&view=diff ============================================================================== --- ofbiz/trunk/framework/common/config/CommonUiLabels.xml (original) +++ ofbiz/trunk/framework/common/config/CommonUiLabels.xml Fri Dec 24 05:45:19 2010 @@ -1108,6 +1108,9 @@ <value xml:lang="zh">æ æ³æ¾å°</value> <value xml:lang="zh_TW">ç¡æ³æ¾å°</value> </property> + <property key="CommonCaptchaCode"> + <value xml:lang="en">Captcha Code</value> + </property> <property key="CommonChange"> <value xml:lang="ar">تغÙÙر</value> <value xml:lang="de">Verändern</value> @@ -2273,6 +2276,9 @@ <value xml:lang="zh">çµåé®ä»¶</value> <value xml:lang="zh_TW">é»åéµä»¶</value> </property> + <property key="CommonEmailAlreadyExist"> + <value xml:lang="en">Email already exist</value> + </property> <property key="CommonEmailPassword"> <value xml:lang="ar">ÙÙÙ Ø© سر اÙبرÙد اÙØ¥ÙÙترÙÙÙ</value> <value xml:lang="cs">Email heslo</value> @@ -3695,6 +3701,9 @@ <property key="CommonReleaseDate"> <value xml:lang="en">Release Date</value> </property> + <property key="CommonReloadCaptchaCode"> + <value xml:lang="en">Reload Captcha Code</value> + </property> <property key="CommonInventory"> <value xml:lang="en">Inventory</value> <value xml:lang="fr">Stockage</value> @@ -4347,6 +4356,9 @@ <value xml:lang="zh_CN">æ¶æ¯</value> <value xml:lang="zh_TW">è¨æ¯</value> </property> + <property key="CommonMessageMissing"> + <value xml:lang="en">Message is missing</value> + </property> <property key="CommonMessages"> <value xml:lang="de">Meldungen</value> <value xml:lang="en">Messages</value> @@ -8631,6 +8643,9 @@ <value xml:lang="zh_CN">å¼</value> <value xml:lang="zh_TW">æ¸å¼</value> </property> + <property key="CommonVerifyCaptchaCode"> + <value xml:lang="en">Verify Captcha Code</value> + </property> <property key="CommonView"> <value xml:lang="ar">Ù Ø´Ùد</value> <value xml:lang="cs">Náhled</value> Modified: ofbiz/trunk/framework/images/webapp/images/ecommain.css URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/ecommain.css?rev=1052449&r1=1052448&r2=1052449&view=diff ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/ecommain.css (original) +++ ofbiz/trunk/framework/images/webapp/images/ecommain.css Fri Dec 24 05:45:19 2010 @@ -151,6 +151,7 @@ padding-right:11px; text-align:right; white-space:nowrap; width:1%; +vertical-align:top; } #ecom-header { Modified: ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml?rev=1052449&r1=1052448&r2=1052449&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml Fri Dec 24 05:45:19 2010 @@ -3319,6 +3319,9 @@ <value xml:lang="zh">主é¢</value> <value xml:lang="zh_TW">æ¨é¡</value> </property> + <property key="EcommerceSubjectMissing"> + <value xml:lang="en">Subject is missing</value> + </property> <property key="EcommerceSubscribe"> <value xml:lang="da">Abonnér</value> <value xml:lang="de">Abonnieren</value> Modified: ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=1052449&r1=1052448&r2=1052449&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml Fri Dec 24 05:45:19 2010 @@ -1256,4 +1256,83 @@ under the License. <store-value value-field="loggedInUser"/> </if-compare-field> </simple-method> + <simple-method method-name="createAnonContact" short-description="Create a non Contact" login-required="false"> + <entity-one value-field="systemUserLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <set field="parameters.userLogin" from-field="systemUserLogin"/> + <set field="isExistingEmail" type="Boolean" value="false"/> + <if-empty field="parameters.subject"> + <add-error><fail-property resource="EcommerceUiLabels" property="EcommerceSubjectMissing"/></add-error> + </if-empty> + <if-empty field="parameters.content"> + <add-error><fail-property resource="CommonUiLabels" property="CommonMessageMissing"/></add-error> + </if-empty> + <if-empty field="parameters.emailAddress"> + <add-error><fail-property resource="PartyUiLabels" property="PartyEmailAddressMissingError"/></add-error> + <else> + <if-validate-method field="parameters.emailAddress" method="isEmail" class="org.ofbiz.base.util.UtilValidate"> + <!-- Check existing email --> + <entity-condition list="contacts" entity-name="PartyContactDetailByPurpose"> + <condition-list> + <condition-expr field-name="infoString" from-field="parameters.emailAddress"/> + <condition-expr field-name="contactMechTypeId" value="EMAIL_ADDRESS"/> + <condition-expr field-name="contactMechPurposeTypeId" value="PRIMARY_EMAIL"/> + </condition-list> + </entity-condition> + <if-not-empty field="contacts"> + <first-from-list entry="contact" list="contacts"/> + <set field="isExistingEmail" type="Boolean" value="true"/> + </if-not-empty> + <else> + <add-error><fail-property resource="PartyUiLabels" property="PartyEmailAddressNotFormattedCorrectly"/></add-error> + </else> + </if-validate-method> + </else> + </if-empty> + <call-object-method obj-field="parameters.captcha" method-name="toLowerCase" ret-field="parameters.captcha"/> + <call-object-method obj-field="parameters.captchaCode" method-name="toLowerCase" ret-field="parameters.captchaCode"/> + <if-compare-field operator="not-equals" field="parameters.captcha" to-field="parameters.captchaCode"> + <add-error><fail-property resource="MyPortalUiLabels" property="MyPortalCaptchaMissingError"/></add-error> + </if-compare-field> + <check-errors/> + <!-- If email already exist, will go to confirm screen. --> + <if> + <condition> + <and> + <if-empty field="parameters.partyId"/> + <if-compare operator="equals" value="true" field="isExistingEmail"/> + </and> + </condition> + <then> + <entity-one value-field="person" entity-name="Person"> + <field-map field-name="partyId" from-field="contact.partyId"/> + </entity-one> + <field-to-request field="person" request-name="person"/> + <return response-code="confirm"/> + </then> + </if> + <!-- If person doesn't exist, will create new person and contact. --> + <if-empty field="parameters.partyId"> + <set-service-fields service-name="createPerson" to-map="newPerson" map="parameters"/> + <call-service service-name="createPerson" in-map-name="newPerson"> + <result-to-field result-name="partyId" field="parameters.partyId"/> + </call-service> + <set-service-fields service-name="createPartyContactMech" to-map="newContact" map="parameters"/> + <set field="newContact.infoString" from-field="parameters.emailAddress"/> + <set field="newContact.contactMechTypeId" value="EMAIL_ADDRESS"/> + <set field="newContact.contactMechPurposeTypeId" value="PRIMARY_EMAIL"/> + <call-service service-name="createPartyContactMech" in-map-name="newContact"> + <result-to-field result-name="contactMechId" field="parameters.contactMechIdFrom"/> + </call-service> + <else> + <set field="parameters.contactMechIdFrom" from-field="contact.contactMechId"/> + </else> + </if-empty> + <set-service-fields service-name="createCommunicationEventWithoutPermission" to-map="newComm" map="parameters"/> + <set field="newComm.partyIdFrom" from-field="parameters.partyId"/> + <call-service service-name="createCommunicationEventWithoutPermission" in-map-name="newComm"> + <default-message property="CommonGenericServiceSuccessMessage" resource="CommonUiLabels"></default-message> + </call-service> + </simple-method> </simple-methods> 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=1052449&r1=1052448&r2=1052449&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 05:45:19 2010 @@ -1295,6 +1295,7 @@ under the License. </request-map> <request-map uri="AnonContactus"> <security https="true" auth="false"/> + <event type="java" invoke="getCodeCaptcha" path="org.ofbiz.common.Captcha"/> <response name="success" type="view" value="AnonContactus"/> </request-map> <request-map uri="contactsubmit"> @@ -1305,9 +1306,10 @@ under the License. </request-map> <request-map uri="submitAnonContact"> <security https="true" auth="false"/> - <event type="service" invoke="sendContactUsEmailToCompany"/> - <response name="success" type="view" value="AnonContactus"/> - <response name="error" type="view" value="AnonContactus"/> + <event type="simple" invoke="createAnonContact" path="component://ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml"/> + <response name="success" type="request-redirect" value="main"/> + <response name="confirm" type="request" value="AnonContactus"/> + <response name="error" type="request" value="AnonContactus"/> </request-map> <request-map uri="signUpForContactList"> @@ -1923,6 +1925,17 @@ under the License. <security auth="false" https="false"/> <response name="success" type="view" value="ProductUomDropDownOnly" save-last-view="true"/> </request-map> + + <!-- Captcha --> + <request-map uri="reloadCaptchaImage"> + <security https="true" auth="false"/> + <response name="success" type="view" value="reloadCaptchaImage"/> + </request-map> + <request-map uri="reloadCaptchaCode"> + <security https="true" auth="false"/> + <response name="success" type="view" value="reloadCaptchaCode"/> + </request-map> + <!-- End of Request Mappings --> <!-- View Mappings --> @@ -2071,5 +2084,9 @@ under the License. <!-- Contact List --> <view-map name="ContactListOptOut" type="screen" page="component://marketing/widget/ContactListScreens.xml#OptOutResponse"/> + + <!-- Captcha --> + <view-map name="reloadCaptchaImage" type="screen" page="component://myportal/widget/CommonScreens.xml#reloadCaptchaImage"/> + <view-map name="reloadCaptchaCode" type="screen" page="component://myportal/widget/CommonScreens.xml#reloadCaptchaCode"/> <!-- End of View Mappings --> </site-conf> Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/AnonContactus.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/AnonContactus.ftl?rev=1052449&r1=1052448&r2=1052449&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/AnonContactus.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/AnonContactus.ftl Fri Dec 24 05:45:19 2010 @@ -17,44 +17,119 @@ specific language governing permissions under the License. --> -<h3>${uiLabelMap.CommonContactUs}</h3> -<form id="contactForm" method="post" action="<@ofbizUrl>submitAnonContact</@ofbizUrl>"> - <fieldset> - <input type="hidden" name="partyIdFrom" value="${(userLogin.partyId)?if_exists}" /> - <input type="hidden" name="partyIdTo" value="${productStore.payToPartyId?if_exists}"/> - <input type="hidden" name="contactMechTypeId" value="WEB_ADDRESS" /> - <input type="hidden" name="communicationEventTypeId" value="WEB_SITE_COMMUNICATI" /> - <input type="hidden" name="productStoreId" value="${productStore.productStoreId}" /> - <input type="hidden" name="emailType" value="CONT_NOTI_EMAIL" /> - <input type="hidden" name="note" value="${Static["org.ofbiz.base.util.UtilHttp"].getFullRequestUrl(request).toString()}" /> - <div> - <label for="comment">${uiLabelMap.CommonComment}:</label> - <textarea name="content" id="comment" class="required" cols="50" rows="5"></textarea> +<div class="screenlet"> + <div class="screenlet-title-bar"> + <h3>${uiLabelMap.CommonContactUs}</h3> + </div> +<#if parameters.person?has_content> + <#assign person = parameters.person/> + <div class="screenlet-body"> + <form name="contactForm" method="post" action="<@ofbizUrl>submitAnonContact</@ofbizUrl>"> + <input type="hidden" name="partyIdFrom" value="${(userLogin.partyId)?if_exists}" /> + <input type="hidden" name="partyIdTo" value="${productStore.payToPartyId?if_exists}"/> + <input type="hidden" name="contactMechTypeId" value="WEB_ADDRESS" /> + <input type="hidden" name="communicationEventTypeId" value="WEB_SITE_COMMUNICATI" /> + <input type="hidden" name="productStoreId" value="${productStore.productStoreId}" /> + <input type="hidden" name="emailType" value="CONT_NOTI_EMAIL" /> + <input type="hidden" name="captchaCode" value="${requestParameters.captchaCode?if_exists}"/> + <input type="hidden" name="captcha" value="${requestParameters.captcha?if_exists}"/> + <input type="hidden" name="partyId" value="${person.partyId?if_exists}"/> + <input type="hidden" name="emailAddress" value="${requestParameters.emailAddress?if_exists}"/> + <table class="basic-table" cellspacing="0"> + <tbody> + <tr> + <td class="label">${uiLabelMap.EcommerceSubject}</td> + <td><input type="text" name="subject" id="subject" class="required" value="${requestParameters.subject?if_exists}"/>*</td> + </tr> + <tr> + <td class="label">${uiLabelMap.CommonMessage}</td> + <td><textarea name="content" id="message" class="required" cols="50" rows="5">${requestParameters.content?if_exists}</textarea>*</td> + </tr> + <tr> + <td class="label">${uiLabelMap.FormFieldTitle_emailAddress}</td> + <td>${requestParameters.emailAddress?if_exists} (${uiLabelMap.CommonEmailAlreadyExist})</td> + </tr> + <tr> + <td class="label">${uiLabelMap.CommonFrom}</td> + <td>${person.firstName?if_exists} ${person.lastName?if_exists} (${uiLabelMap.FormFieldTitle_existingCustomer})</td> + </tr> + <tr> + <td class="label"></td> + <td><a class="smallsubmit" href="javascript: void(0)" onclick="document.contactForm.submit();">${uiLabelMap.CommonConfirm}</a><a href="<@ofbizUrl>AnonContactus</@ofbizUrl>" class="smallsubmit">${uiLabelMap.CommonCancel}</a></td> + </tr> + </tbody> + </table> + </form> + </div> +<#else> +<script type="text/javascript" language="JavaScript"> +<!-- + function reloadCaptcha(){ + var submitToUri = "<@ofbizUrl>reloadCaptchaImage</@ofbizUrl>"; + $.post(submitToUri, null, + function(data){ + document.getElementById("captchaImage").innerHTML = data; + }); + reloadCaptchaCode(); + } + function reloadCaptchaCode(){ + var submitToUri = "<@ofbizUrl>reloadCaptchaCode</@ofbizUrl>"; + $.post(submitToUri, null, + function(data){ + document.getElementById("captchaCode").innerHTML = data; + }); + } + //--> +</script> + <div class="screenlet-body"> + <form id="contactForm" method="post" action="<@ofbizUrl>submitAnonContact</@ofbizUrl>"> + <input type="hidden" name="partyIdFrom" value="${(userLogin.partyId)?if_exists}" /> + <input type="hidden" name="partyIdTo" value="${productStore.payToPartyId?if_exists}"/> + <input type="hidden" name="contactMechTypeId" value="WEB_ADDRESS" /> + <input type="hidden" name="communicationEventTypeId" value="WEB_SITE_COMMUNICATI" /> + <input type="hidden" name="productStoreId" value="${productStore.productStoreId}" /> + <input type="hidden" name="emailType" value="CONT_NOTI_EMAIL" /> + <table class="basic-table" cellspacing="0"> + <tbody> + <tr> + <td></td> + <td><div id="captchaCode"><input type="hidden" value="${parameters.ID_KEY}" name="captchaCode"/></div></td> + </tr> + <tr> + <td class="label">${uiLabelMap.EcommerceSubject}</td> + <td><input type="text" name="subject" id="subject" class="required" value="${requestParameters.subject?if_exists}"/>*</td> + </tr> + <tr> + <td class="label">${uiLabelMap.CommonMessage}</td> + <td><textarea name="content" id="message" class="required" cols="50" rows="5">${requestParameters.content?if_exists}</textarea>*</td> + </tr> + <tr> + <td class="label">${uiLabelMap.FormFieldTitle_emailAddress}</td> + <td><input type="text" name="emailAddress" id="emailAddress" class="required" value="${requestParameters.emailAddress?if_exists}"/>*</td> + </tr> + <tr> + <td class="label">${uiLabelMap.PartyFirstName}</td> + <td><input type="text" name="firstName" id="firstName" class="required" value="${requestParameters.firstName?if_exists}"/></td> + </tr> + <tr> + <td class="label">${uiLabelMap.PartyLastName}</td> + <td><input type="text" name="lastName" id="lastName" class="required" value="${requestParameters.lastName?if_exists}"/></td> + </tr> + <tr> + <td class="label">${uiLabelMap.CommonCaptchaCode}</td> + <td><div id="captchaImage"><img src="${parameters.captchaFileName}" alt="" /></div><a href="javascript:reloadCaptcha();">${uiLabelMap.CommonReloadCaptchaCode}</a></td> + </tr> + <tr> + <td class="label">${uiLabelMap.CommonVerifyCaptchaCode}</td> + <td><input type="text" autocomplete="off" maxlength="30" size="23" name="captcha"/>*</td> + </tr> + <tr> + <td class="label"></td> + <td><input type="submit" value="${uiLabelMap.CommonSubmit}" /></td> + </tr> + </tbody> + </table> + </form> </div> - <div> - <label for="emailAddress">${uiLabelMap.FormFieldTitle_emailAddress} *</label> - <input type="text" name="emailAddress" id="emailAddress" class="required" /> - </div> - <div> - <label for="firstName">${uiLabelMap.FormFieldTitle_firstName}</label> - <input type="text" name="firstName" id="firstName" class="required" /> - </div> - <div> - <label for="lastName">${uiLabelMap.FormFieldTitle_lastName}</label> - <input type="text" name="lastName" id="lastName" class="required" /> - </div> - <div> - <label for="postalCode">${uiLabelMap.CommonZipPostalCode}</label> - <input name="postalCode" id="postalCode" type="text" /> - </div> - <div> - <label>${uiLabelMap.CommonCountry}</label> - <select name="countryCode" id="countryCodeGeoId" class="required"> - ${screens.render("component://common/widget/CommonScreens.xml#countries")} - </select> - </div> - </fieldset> - <div> - <input type="submit" value="${uiLabelMap.CommonSubmit}" /> - </div> -</form> \ No newline at end of file +</#if> +</div> \ No newline at end of file |
Free forum by Nabble | Edit this page |