From 9244433dd70a6b4741320b3d8907eed695eadc80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 3 Mar 2015 17:21:32 +0100
Subject: [PATCH] CRM: Do not mark mails as read when viewed in the backoffice
 through fckeditor

---
 .../SkinTemplateItem/portal_skins/erp5_crm/Base_openEvent.xml  | 3 ++-
 .../SkinTemplateItem/portal_skins/erp5_crm/Base_readEvent.xml  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_openEvent.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_openEvent.xml
index 085b60aacf..0f0a85cd32 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_openEvent.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_openEvent.xml
@@ -65,7 +65,8 @@ user = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
 if user is None:\n
   # If the referer contains the url of the event we are probably viewing the event\n
   # from ERP5 interface. We do not want to mark the event as received in that case\n
-  if not (\'/event_module/%s\' % event_id) in request.HTTP_REFERER:\n
+  # It can also be from fckeditor, in this case we don\'t have the event url in REFERER.\n
+  if not ( (\'/event_module/%s\' % event_id) in request.HTTP_REFERER or \'fckeditor\' in request.HTTP_REFERER):\n
     if portal.Base_getHMACHexdigest(portal.Base_getEventHMACKey(), event_id) != request["hash"]:\n
       from zExceptions import Unauthorized\n
       raise Unauthorized()\n
diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_readEvent.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_readEvent.xml
index 2056c2dbfb..e463fff861 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_readEvent.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Base_readEvent.xml
@@ -65,7 +65,8 @@ user = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
 if user is None:\n
   # If the referer contains the url of the event we are probably viewing the event\n
   # from ERP5 interface. We do not want to mark the event as delivered in that case\n
-  if not (\'/event_module/%s\' % event_id) in request.HTTP_REFERER:\n
+  # It can also be from fckeditor, in this case we don\'t have the event url in REFERER.\n
+  if not ( (\'/event_module/%s\' % event_id) in request.HTTP_REFERER or \'fckeditor\' in request.HTTP_REFERER):\n
     if portal.Base_getHMACHexdigest(portal.Base_getEventHMACKey(), event_id) != request["hash"]:\n
       from zExceptions import Unauthorized\n
       raise Unauthorized()\n
-- 
2.30.9