From cb525a3d55f50a77950671d4ea43982f7c079cbd Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Mon, 24 Feb 2020 10:53:43 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201047858][DSGVO:=20Zustimmung=20bei=20Eintrag=20der=20E-Mail?=
 =?UTF-8?q?=20=C3=BCber=20UnlinkedMails]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../entityfields/mailastext_param/valueProcess.js          | 2 +-
 .../recordcontainers/dummyjdito/onUpdate.js                | 4 ++++
 process/DataPrivacy_lib/process.js                         | 7 ++++---
 process/IncomingEmailExecutor_lib/process.js               | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/entity/UnlinkedMailMappingWrapper_entity/entityfields/mailastext_param/valueProcess.js b/entity/UnlinkedMailMappingWrapper_entity/entityfields/mailastext_param/valueProcess.js
index 1e60e70898..706b1b035a 100644
--- a/entity/UnlinkedMailMappingWrapper_entity/entityfields/mailastext_param/valueProcess.js
+++ b/entity/UnlinkedMailMappingWrapper_entity/entityfields/mailastext_param/valueProcess.js
@@ -9,7 +9,7 @@ if (unlinkedMailId)
 {
     res = newSelect("AB_UNLINKEDMAIL.MAIL")
                             .from("AB_UNLINKEDMAIL")
-                            .and("AB_UNLINKEDMAIL.AB_UNLINKEDMAILID", unlinkedMailId)
+                            .where("AB_UNLINKEDMAIL.AB_UNLINKEDMAILID", unlinkedMailId)
                             .cell();
 }
 result.string(res);
\ No newline at end of file
diff --git a/entity/UnlinkedMailMappingWrapper_entity/recordcontainers/dummyjdito/onUpdate.js b/entity/UnlinkedMailMappingWrapper_entity/recordcontainers/dummyjdito/onUpdate.js
index 42654e03c0..f6cc9442f3 100644
--- a/entity/UnlinkedMailMappingWrapper_entity/recordcontainers/dummyjdito/onUpdate.js
+++ b/entity/UnlinkedMailMappingWrapper_entity/recordcontainers/dummyjdito/onUpdate.js
@@ -1,3 +1,4 @@
+import("DataPrivacy_lib");
 import("system.datetime");
 import("KeywordRegistry_basic");
 import("system.util");
@@ -65,6 +66,9 @@ var activityRes = incomingMailExec.createActivity(activityLinks);
 incomingMailExec.deleteUnlinkedMail(unlinkedMailId);
 
 if (communicationsToInsert.length > 0)
+{
     db.inserts(communicationsToInsert);
+    DataPrivacyUtils.notifyNeedDataPrivacyUpdate();
+}
 
 neon.refreshAll();//this is needed for the dashboard: other elements are refreshed and display for example unlinkedMails
\ No newline at end of file
diff --git a/process/DataPrivacy_lib/process.js b/process/DataPrivacy_lib/process.js
index 2978c36efa..5eed8a22d0 100644
--- a/process/DataPrivacy_lib/process.js
+++ b/process/DataPrivacy_lib/process.js
@@ -436,7 +436,8 @@ DataPrivacyUtils.collectAll = function(pContactId, pFilterCond)
  * Notify the user to update the data privacy informations.
  * It is only displayed if it is a Person.
  * 
- * @param {String} pContactId the current contactId
+ * @param {String} [pContactId] contactId that is used to vertify whether the contact is a person-contact (-> showmessage) 
+ * or not (-> do not show message), if param is null (-> show message without this check)
  * @param {Boolean} pShowMessage if false: nothing happens
  * 
  * @return {void}
@@ -449,8 +450,8 @@ DataPrivacyUtils.notifyNeedDataPrivacyUpdate = function(pContactId, pShowMessage
     var isActive = JSON.parse(project.getPreferenceValue("custom.dsgvo.active", "true"));
     if (!isActive)
         return;
- 
-    if (ContactUtils.getContactTypeByContactId(pContactId) > 1) { // if person
+    
+    if (pContactId == undefined || ContactUtils.getContactTypeByContactId(pContactId) > 1) { // if person
         // TODO: jump to DataPrivacy-Tab of contact
         question.showMessage(translate.text("Your changes may have an impact on the data privacy information (GDPR).\n Please update these."), question.INFORMATION, translate.text("Update data privacy information"));
     }
diff --git a/process/IncomingEmailExecutor_lib/process.js b/process/IncomingEmailExecutor_lib/process.js
index 57ee608b84..ce4cbed279 100644
--- a/process/IncomingEmailExecutor_lib/process.js
+++ b/process/IncomingEmailExecutor_lib/process.js
@@ -204,7 +204,7 @@ IncomingEmailExecutor.prototype.createActivity = function(pAdditionalLinks)
 
 IncomingEmailExecutor.prototype.deleteUnlinkedMail = function (pUnlinkedMailId)
 {
-    newWhere("AB_UNLINKEDMAIL.AB_UNLINKEDMAILID", pUnlinkedMailId, undefined, undefined, this._alias)
+    newWhereIfSet("AB_UNLINKEDMAIL.AB_UNLINKEDMAILID", pUnlinkedMailId, undefined, undefined, this._alias)
         .deleteData(true, "AB_UNLINKEDMAIL");
 }
 
-- 
GitLab