From de429536bb4a156cc4be08d58d187662470a6ca8 Mon Sep 17 00:00:00 2001
From: Andre Loreth <a.loreth@adito.de>
Date: Fri, 26 Oct 2018 17:04:04 +0200
Subject: [PATCH] =?UTF-8?q?#1024216=20H=C3=A4ufigkeit=20implementieren?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 entity/Appointment_entity/contentProcess.js | 26 ++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/entity/Appointment_entity/contentProcess.js b/entity/Appointment_entity/contentProcess.js
index 927ff03b31..633c2abfe2 100644
--- a/entity/Appointment_entity/contentProcess.js
+++ b/entity/Appointment_entity/contentProcess.js
@@ -6,9 +6,16 @@ import("system.datetime");
 import("system.eMath");
 import("system.util");
 
+// $param.entry is potentially a recurrence exception.
 if(vars.exists("$param.entry"))
 {
     var entry = JSON.parse(vars.getString("$param.entry"));
+    var masterEntry = null;
+    if (vars.exists("$param.masterEntry") && vars.get("$param.masterEntry") != "") {
+        masterEntry = JSON.parse(vars.get("$param.masterEntry"));
+    }
+    
+    logging.log("Appointment is recurrence exception: " + (masterEntry != null))
 
     var uid = entry[calendars.ID];    
     var summary = entry[calendars.SUMMARY];
@@ -26,11 +33,24 @@ if(vars.exists("$param.entry"))
     var transparency = entry[calendars.TRANSPARENCY];
     var categories = entry[calendars.CATEGORIES];
     
+    var masterBegin = masterEntry != null ? masterEntry[calendars.DTSTART] : null
+    var masterEnd = masterEntry != null ? masterEntry[calendars.DTEND] : null
+    
+    // Recurrence
+    var recurrenceID = entry[calendars.RECURRENCEID];
+    var rrule = null;
+    if (masterEntry != null) { // Entry is a recurrence exception, therefore get rrule from master
+        rrule = masterEntry[calendars.RRULE] != null ? masterEntry[calendars.RRULE][0] : null;
+    } else {
+        rrule = entry[calendars.RRULE] != null ? entry[calendars.RRULE][0] : null;
+    }
+    
     //@TODO Icon 
-  
     result.object([
-        [uid, '', '', attendees.length, startdate, enddate, summary, organizer, attendees, status, links, description, location, '', classification, transparency, categories] //reminder, remindercheck
-        ]);
+        [uid, '', '', attendees.length, startdate, enddate, summary, organizer,
+            attendees, status, links, description, location, '', classification,
+            transparency, categories, rrule, recurrenceID, null, masterBegin, masterEnd] //reminder, remindercheck
+    ]);
 }
 else
 {
-- 
GitLab