From 05b50833b20c94dc139489b382791e43af5aad13 Mon Sep 17 00:00:00 2001
From: "a.schindlbeck" <a.schindlbeck@adito.de>
Date: Wed, 12 Dec 2018 16:24:01 +0100
Subject: [PATCH] =?UTF-8?q?#1029757=20Exchange=20=C3=84nderungen?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Appointment_entity/Appointment_entity.aod | 10 +-------
 .../status/possibleItemsProcess.js            |  2 +-
 .../recordcontainers/jditorc/onUpdate.js      | 14 ++++-------
 process/Appointment_lib/process.js            | 25 ++++++++++++++++---
 4 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/entity/Appointment_entity/Appointment_entity.aod b/entity/Appointment_entity/Appointment_entity.aod
index 79ecf9b8b9..8c65a287ac 100644
--- a/entity/Appointment_entity/Appointment_entity.aod
+++ b/entity/Appointment_entity/Appointment_entity.aod
@@ -3,7 +3,7 @@
   <name>Appointment_entity</name>
   <title>Termin</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
-  <recordContainer>jdito</recordContainer>
+  <recordContainer>jDitoRC</recordContainer>
   <entityFields>
     <entityField>
       <name>SUMMARY</name>
@@ -169,13 +169,5 @@
         <element>MASTEREND.value</element>
       </recordFields>
     </jDitoRecordContainer>
-    <jDitoRecordContainer>
-      <name>jdito</name>
-      <jDitoRecordAlias></jDitoRecordAlias>
-      <contentProcess>%aditoprj%/entity/Appointment_entity/contentProcess.js</contentProcess>
-      <onInsert>%aditoprj%/entity/Appointment_entity/onInsert.js</onInsert>
-      <onUpdate>%aditoprj%/entity/Appointment_entity/onUpdate.js</onUpdate>
-      <onDelete>%aditoprj%/entity/Appointment_entity/onDelete.js</onDelete>
-    </jDitoRecordContainer>
   </recordContainers>
 </entity>
diff --git a/entity/Appointment_entity/entityfields/status/possibleItemsProcess.js b/entity/Appointment_entity/entityfields/status/possibleItemsProcess.js
index af4adc5462..00519fe1e8 100644
--- a/entity/Appointment_entity/entityfields/status/possibleItemsProcess.js
+++ b/entity/Appointment_entity/entityfields/status/possibleItemsProcess.js
@@ -13,7 +13,7 @@ if( calendars.getBackendType() != calendars.BACKEND_EXCHANGEWS )
 else 
 {
     result.object( [ 
-            [calendars.STATUS_BUSY, translate.text("Gebucht")],
+            //[calendars.STATUS_BUSY, translate.text("Gebucht")],
             [calendars.STATUS_TENTATIVE, translate.text("Vorläufig")],
             [calendars.STATUS_OOF, translate.text("Außer Haus")],
             [calendars.STATUS_FREE, translate.text("frei")] 
diff --git a/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js b/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js
index c26d2893e0..d58c694cc4 100644
--- a/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js
+++ b/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js
@@ -16,14 +16,10 @@ if(vars.exists("$param.entry"))
 {
     var event = JSON.parse(vars.getString("$param.entry"));
 
-    var ok = false;
-    if ( calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS  && event[calendars.ORGANIZER2]["cn"] != event[calendars.USER2]["cn"])
-    {
-        question.showMessage(translate.text("Ein Gruppentermin kann nur durch den Organisator bearbeitet werden."));
-        ok = true;
-    }
-    else
-    {
+    //if ( calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS  && event[calendars.ORGANIZER2]["cn"] != event[calendars.USER2]["cn"])
+    //    question.showMessage(translate.text("Ein Gruppentermin kann nur durch den Organisator bearbeitet werden."));
+    //else
+    //{
         event[calendars.ID] = vars.getString("$field.UID");
         event[calendars.TYPE] = calendars.VEVENT;
         event[calendars.STATUS] = vars.getString("$field.STATUS");
@@ -53,7 +49,7 @@ if(vars.exists("$param.entry"))
         calendars.updateEntry(event);
          
         ok = true;
-    }
+    //}
 }
 // Liefert die AffectedUsers
 function getAffectedUsers( pEvent )
diff --git a/process/Appointment_lib/process.js b/process/Appointment_lib/process.js
index 4c7859a726..37a89036a2 100644
--- a/process/Appointment_lib/process.js
+++ b/process/Appointment_lib/process.js
@@ -1,3 +1,5 @@
+import("system.logging");
+import("system.calendars");
 import("system.neon");
 import("system.text");
 
@@ -73,7 +75,24 @@ AppointmentUtils.setPartStat = function (currentUserUri, attendees, newState) {
  */
 AppointmentUtils.sendExchangedAction = function(event, newState)
 {
-    event["X-ADITO-STATUSACTION"] = newState;    // "ACCEPT", "DECLINE", ""
-    event[calendars.AFFECTEDUSERS] = "";
-    calendars.updateEntry(event);
+    switch(newState)
+    {
+        case "ACCEPTED":
+            newState = "ACCEPT";
+            break;
+        case "DECLINED":
+            newState = "DECLINE";
+            break;
+        case "TENTATIVE":
+            newState = "TENTATIVELYACCEPT";
+            break;
+        default :
+            newState = "TENTATIVELYACCEPT";
+    }
+    
+    
+    jsonEvent = JSON.parse(event);
+    jsonEvent["X-ADITO-STATUSACTION"] = newState;    // "ACCEPT", "DECLINE", ""
+    jsonEvent[calendars.AFFECTEDUSERS] = "";
+    calendars.updateEntry(jsonEvent);
 }
\ No newline at end of file
-- 
GitLab