svn commit: r781649 - in /ofbiz/trunk: applications/party/script/org/ofbiz/party/communication/ applications/party/servicedef/ applications/party/src/org/ofbiz/party/communication/ applications/party/webapp/partymgr/WEB-INF/ specialpurpose/ecommerce/we...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r781649 - in /ofbiz/trunk: applications/party/script/org/ofbiz/party/communication/ applications/party/servicedef/ applications/party/src/org/ofbiz/party/communication/ applications/party/webapp/partymgr/WEB-INF/ specialpurpose/ecommerce/we...

hansbak-2
Author: hansbak
Date: Thu Jun  4 04:22:13 2009
New Revision: 781649

URL: http://svn.apache.org/viewvc?rev=781649&view=rev
Log:
ecommerce component updated to use the new com_role_read status, as reported by Andy in the dev list

Modified:
    ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventEvents.xml
    ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml
    ofbiz/trunk/applications/party/servicedef/services.xml
    ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java
    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/ViewProfile.groovy
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/messagelist.ftl
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/includes/header.ftl

Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventEvents.xml?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventEvents.xml (original)
+++ ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventEvents.xml Thu Jun  4 04:22:13 2009
@@ -21,41 +21,6 @@
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
 
-    <simple-method method-name="setCommEventToRead" short-description="">
-        <entity-one entity-name="CommunicationEventRole" value-field="eventRole"/>
-        <if-compare operator="equals" value="COM_ROLE_CREATED" field="eventRole.statusId">
-            <call-simple-method method-name="checkCommEventAccess"/>
-            <if-compare operator="equals" value="true" field="found">
-                <entity-one entity-name="UserLogin" value-field="userLogin">
-                    <field-map field-name="userLoginId" value="system"/>
-                </entity-one>
-                <set-service-fields service-name="setCommunicationEventRoleStatus"
-                    map="parameters" to-map="updStat"/>
-                <set field="updStat.statusId" value="COM_ROLE_READ"/>
-                <set field="updStat.userLogin" from-field="userLogin"/>
-                <call-service service-name="setCommunicationEventRoleStatus" in-map-name="updStat"
-                include-user-login="false"/>
-            </if-compare>
-        </if-compare>
-    </simple-method>
-
-    <simple-method method-name="checkCommEventAccess"
-        short-description="check if the user has access to the email of this party">
-        <set field="found" value="false"/>
-        <if-compare-field operator="not-equals" field="parameters.partyId" to-field="userLogin.partyId">
-            <entity-and list="emailOwners" entity-name="PartyRelationship" filter-by-date="true">
-                <field-map field-name="partyIdFrom" value="${userLogin.partyId}"/>
-                <field-map field-name="roleTypeIdFrom" value="EMAIL_ADMIN"/>
-                <field-map field-name="partyIdTo" from-field="parameters.partyId"/>
-            </entity-and>
-            <if-not-empty field="emailOwners">
-                <set field="found" value="true"/>
-            </if-not-empty>
-            <else>
-                <set field="found" value="true"/>
-            </else>
-        </if-compare-field>
-    </simple-method>
     <simple-method method-name="addContentToCommEvent"
         short-description="Add content to email communication">
         <!-- Call layout to get field -->

Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml (original)
+++ ofbiz/trunk/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml Thu Jun  4 04:22:13 2009
@@ -414,50 +414,6 @@
         </if-not-empty>
     </simple-method>
 
-    <simple-method method-name="markEventRead" short-description="Automatically Marks a Communication Event as Read" login-required="false">
-        <if-empty field="parameters.communicationEventId">
-            <set from-field="parameters.messageId" field="parameters.communicationEventId"/>
-        </if-empty>
-        <entity-one entity-name="CommunicationEvent" value-field="event"/>
-
-        <!--  get the 'system' user to run the update service as -->
-        <entity-one entity-name="UserLogin" value-field="system">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-                
-        <if>
-            <condition>
-                <and>
-                    <or>
-                        <!--  valid statuses which can go to read -->
-                        <if-compare field="event.statusId" operator="equals" value="COM_ENTERED"/>
-                        <if-compare field="event.statusId" operator="equals" value="COM_PENDING"/>
-                        <if-compare field="event.statusId" operator="equals" value="COM_IN_PROGRESS"/>                        
-                        <if-compare field="event.statusId" operator="equals" value="COM_COMPLETE"/>
-                    </or>
-                    <or>
-                       <!--  if the user is not logged in, its okay to update, assumption is an external event -->
-                       <if-empty field="userLogin"/>
-                       <!--  if the user is logged in, make sure they are the owner of the event -->                  
-                       <and>
-                           <not><if-empty field="userLogin"/></not>
-                           <if-compare-field field="event.partyIdTo" to-field="userLogin.partyId" operator="equals"/>
-                           <!--  note: it is not okay for an admin to mark another user's event as read -->
-                       </and>                  
-                    </or>
-                </and>                
-            </condition>
-            <then>              
-                <set field="updateCtx.communicationEventId" from-field="event.communicationEventId"/>                
-                <set field="updateCtx.statusId" value="COM_READ"/>
-                <set field="updateCtx.userLogin" from-field="userLogin"/>
-                <if-empty field="userLogin">
-                    <set field="updateCtx.userLogin" from-field="system"/>
-                </if-empty>
-                <call-service service-name="updateCommunicationEvent" in-map-name="updateCtx" include-user-login="false"/>
-            </then>            
-        </if>              
-    </simple-method>
 
     <simple-method method-name="sendEmailDated"
         short-description="Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired, then send the email">
@@ -567,6 +523,35 @@
             </if-empty>
         </if-compare-field>
     </simple-method>
+    <simple-method method-name="setCommEventRoleToRead" short-description="set the status for a particular party role to the status COM_ROLE_READ">
+        <if-empty field="parameters.partyId">
+            <set field="parameters.partyId" from-field="parameters.userLogin.partyId"/>
+        </if-empty>
+        <if-empty field="parameters.roleTypeId">
+            <entity-and entity-name="CommunicationEventRole" list="communicationEventRoles">
+                <field-map field-name="communicationEventId" from-field="parameters.communicationEventId"/>
+                <field-map field-name="partyId" from-field="parameters.partyId"/>
+            </entity-and>
+            <first-from-list entry="eventRole" list="communicationEventRoles"/>
+            <set field="parameters.roleTypeId" from-field="eventRole.roleTypeId"/>
+            <else>
+                <entity-one entity-name="CommunicationEventRole" value-field="eventRole"/>
+            </else>
+        </if-empty>
+        <if-not-empty field="eventRole">
+            <if-compare operator="equals" value="COM_ROLE_CREATED" field="eventRole.statusId">
+                <entity-one entity-name="UserLogin" value-field="userLogin">
+                    <field-map field-name="userLoginId" value="system"/>
+                </entity-one>
+                <set-service-fields service-name="setCommunicationEventRoleStatus"
+                    map="parameters" to-map="updStat"/>
+                <set field="updStat.statusId" value="COM_ROLE_READ"/>
+                <set field="updStat.userLogin" from-field="userLogin"/>
+                <call-service service-name="setCommunicationEventRoleStatus" in-map-name="updStat"
+                    include-user-login="false"/>
+            </if-compare>
+        </if-not-empty>
+    </simple-method>
     <simple-method method-name="setCommunicationEventRoleStatus" short-description="Set The Communication Event Status for a specific role">
         <entity-one entity-name="CommunicationEventRole" value-field="communicationEventRole"/>
         <field-to-result field="communicationEventRole.statusId" result-name="oldStatusId"/>

Modified: ofbiz/trunk/applications/party/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services.xml?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/party/servicedef/services.xml Thu Jun  4 04:22:13 2009
@@ -776,15 +776,11 @@
         <auto-attributes include="pk" mode="INOUT" optional="true" entity-name="CommunicationEventWorkEff"/>
         <auto-attributes include="nonpk" mode="IN" optional="true" entity-name="CommunicationEventWorkEff"/>
     </service>
-    <service name="markCommEventRead" engine="simple"
-            location="component://party/script/org/ofbiz/party/communication/CommunicationEventServices.xml" invoke="markEventRead" auth="false">
+    <service name="setCommEventRoleToRead" engine="simple" default-entity-name="CommunicationEventRole"
+        location="component://party/script/org/ofbiz/party/communication/CommunicationEventServices.xml" invoke="setCommEventRoleToRead" auth="false">
         <description>Marks a communication event as read</description>
-        <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
-    </service>
-    <service name="markMessageRead" engine="simple"
-            location="component://party/script/org/ofbiz/party/communication/CommunicationEventServices.xml" invoke="markEventRead" auth="false">
-        <description>Marks a communication event as read</description>
-        <attribute name="messageId" type="String" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN" optional="true"/>
+        <override name="communicationEventId" optional="false"/>
     </service>
     <service name="sendCommEventAsEmail" engine="java"
             location="org.ofbiz.party.communication.CommunicationEventServices" invoke="sendCommEventAsEmail" auth="true"

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=781649&r1=781648&r2=781649&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 Thu Jun  4 04:22:13 2009
@@ -1206,6 +1206,8 @@
     
     /*
      * Event which marks a communication event as read, and returns a 1px image to the browser/mail client
+     * Is updated because the read status is now stored in the communicationEventRole
+     * This services is updated but could not be tested. assumed is "read" for partyIdTo on the commevent
      */
     public static String markCommunicationAsRead(HttpServletRequest request, HttpServletResponse response) {        
         String communicationEventId = null;        
@@ -1226,9 +1228,16 @@
         // update the communication event
         if (communicationEventId != null) {
             Debug.logInfo("Marking communicationEventId [" + communicationEventId + "] from path info : " + request.getPathInfo() + " as read.", module);
+            GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
+            GenericValue communicationEvent = null;
+            try {                
+                communicationEvent = delegator.findOne("CommunicationEvent", UtilMisc.toMap("communicationEventId", communicationEventId), true);                
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);            
+            }
             LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
             try {                
-                dispatcher.runAsync("markCommEventRead", UtilMisc.toMap("communicationEventId", communicationEventId));                
+                dispatcher.runAsync("setCommEventRoleToRead", UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", communicationEvent.getString("partyIdTo")));                
             } catch (GenericServiceException e) {
                 Debug.logError(e, module);            
             }

Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Thu Jun  4 04:22:13 2009
@@ -718,7 +718,7 @@
     </request-map>
     <request-map uri="ViewCommunicationEvent">
         <security https="true" auth="true"/>
-        <event  type="simple" invoke="setCommEventToRead" path="component://party/script/org/ofbiz/party/communication/CommunicationEventEvents.xml"/>
+        <event type="service" invoke="setCommEventRoleToRead"/>
         <response name="success" type="view" value="ViewCommunicationEvent"/>
     </request-map>
     <request-map uri="addContentToCommEvent">

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/ViewProfile.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/ViewProfile.groovy?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/ViewProfile.groovy (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/ViewProfile.groovy Thu Jun  4 04:22:13 2009
@@ -58,10 +58,10 @@
     orderBy = ["-entryDate"];
     findOpts = new EntityFindOptions();
     findOpts.setMaxRows(5);
-    exprs = [EntityCondition.makeCondition("partyIdTo", EntityOperator.EQUALS, partyId)];
-    exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "COM_READ"));
+    exprs = [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)];
+    exprs.add(EntityCondition.makeCondition("roleStatusId", EntityOperator.NOT_EQUAL, "COM_ROLE_READ"));
     condition = EntityCondition.makeCondition(exprs, EntityOperator.AND);
-    messages = delegator.findList("CommunicationEvent", condition, null, orderBy, findOpts, false);
+    messages = delegator.findList("CommunicationEventAndRole", condition, null, orderBy, findOpts, false);
     context.messages = messages;
     context.profileMessages = true;
 

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=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Thu Jun  4 04:22:13 2009
@@ -1227,7 +1227,7 @@
     </request-map>
     <request-map uri="readmessage">
         <security https="true" auth="true"/>
-        <event type="service" invoke="markCommEventRead"/>
+        <event type="service" invoke="setCommEventRoleToRead"/>
         <response name="success" type="view" value="messagedetail"/>
         <response name="error" type="view" value="messagedetail"/>
     </request-map>

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/messagelist.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/messagelist.ftl?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/messagelist.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/messagelist.ftl Thu Jun  4 04:22:13 2009
@@ -34,7 +34,10 @@
                 <td><div class="tabletext">${communicationEvent.subject?default("")}</div></td>
                 <td><div class="tabletext">${communicationEvent.entryDate}</div></td>
                 <td align="right">
-                  <a href="<@ofbizUrl>readmessage?communicationEventId=${communicationEvent.communicationEventId}</@ofbizUrl>" class="buttontext">${uiLabelMap.EcommerceRead}</a>
+                  <form method="post" action="<@ofbizUrl>readmessage</@ofbizUrl>" name="ecomm_read_mess">
+                    <input name="communicationEventId" value="${communicationEvent.communicationEventId}" type="hidden"/>
+                  </form>
+                  <a href="javascript:document.ecomm_read_mess.submit()">${uiLabelMap.EcommerceRead}</a>
                   <#if isSentMessage>
                     <a href="<@ofbizUrl>newmessage?communicationEventId=${communicationEvent.communicationEventId}</@ofbizUrl>" class="buttontext">${uiLabelMap.PartyReply}</a>
                   </#if>

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/includes/header.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/includes/header.ftl?rev=781649&r1=781648&r2=781649&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/includes/header.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/includes/header.ftl Thu Jun  4 04:22:13 2009
@@ -63,6 +63,7 @@
       <!-- NOTE: these are in reverse order because they are stacked right to left instead of left to right -->
       <#if !userLogin?has_content || (userLogin.userLoginId)?if_exists != "anonymous">
         <li id="header-bar-viewprofile"><a href="<@ofbizUrl>viewprofile</@ofbizUrl>">${uiLabelMap.CommonProfile}</a></li>
+        <li id="header-bar-ListMessages"><a href="<@ofbizUrl>messagelist</@ofbizUrl>">${uiLabelMap.CommonMessages}</a></li>
         <li id="header-bar-ListQuotes"><a href="<@ofbizUrl>ListQuotes</@ofbizUrl>">${uiLabelMap.OrderOrderQuotes}</a></li>
         <li id="header-bar-ListRequests"><a href="<@ofbizUrl>ListRequests</@ofbizUrl>">${uiLabelMap.OrderRequests}</a></li>
         <li id="header-bar-editShoppingList"><a href="<@ofbizUrl>editShoppingList</@ofbizUrl>">${uiLabelMap.EcommerceShoppingLists}</a></li>