diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9f11b75
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea/
diff --git a/.idea/calendarimporter.iml b/.idea/calendarimporter.iml
deleted file mode 100644
index c956989..0000000
--- a/.idea/calendarimporter.iml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/dictionaries/osboxes.xml b/.idea/dictionaries/osboxes.xml
deleted file mode 100644
index cfd3f23..0000000
--- a/.idea/dictionaries/osboxes.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- caldesc
- calendarimporter
- filepath
- ical
- importattachment
- kopano
- mapi
- mapisession
- storeid
- uids
- vtimezone
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index d821048..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 34195db..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index 07f31c0..0000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b..0000000
--- a/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 80759bc..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,770 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- DEFINITION_ORDER
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- project
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- project
-
-
- true
-
-
-
- DIRECTORY
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
- 1477949602474
-
-
- 1477949602474
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/php/module.calendar.php b/php/module.calendar.php
index d975fb6..4325998 100644
--- a/php/module.calendar.php
+++ b/php/module.calendar.php
@@ -58,6 +58,13 @@ class CalendarModule extends Module
"OOF"
);
+ $this->freeBusyStates = array( // http://www.kanzaki.com/docs/ical/fbtype.html
+ "FREE",
+ "BUSY-TENTATIVE",
+ "BUSY",
+ "BUSY-UNAVAILABLE"
+ );
+
$this->labels = array(
"NONE",
"IMPORTANT",
@@ -270,17 +277,20 @@ class CalendarModule extends Module
'DTEND' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "duedate")),
'CREATED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "creation_time")),
'LAST-MODIFIED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "last_modification_time")),
- 'PRIORITY' => $this->getProp($messageProps, "importance"),
+ 'PRIORITY' => intval($this->getProp($messageProps, "importance")),
'X-MICROSOFT-CDO-INTENDEDSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid...
'X-MICROSOFT-CDO-BUSYSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid...
+ 'FBTYPE' => $this->freeBusyStates[intval($this->getProp($messageProps, "busystatus"))],
'X-ZARAFA-LABEL' => $this->labels[intval($this->getProp($messageProps, "label"))],
'CLASS' => $this->getProp($messageProps, "private") ? "PRIVATE" : "PUBLIC",
'COMMENT' => "eid:" . $records[$index]
]);
// Add organizer
- $vEvent->add('ORGANIZER', 'mailto:' . $this->getProp($messageProps, "sender_email_address"));
- $vEvent->ORGANIZER['CN'] = $this->getProp($messageProps, "sender_name");
+ if(!empty( $this->getProp($messageProps, "sender_email_address"))) {
+ $vEvent->add('ORGANIZER', 'mailto:' . $this->getProp($messageProps, "sender_email_address"));
+ $vEvent->ORGANIZER['CN'] = $this->getProp($messageProps, "sender_name");
+ }
// Add Attendees
if (isset($messageProps["recipients"]) && count($messageProps["recipients"]["item"]) > 0) {
@@ -320,6 +330,13 @@ class CalendarModule extends Module
if (!empty($body)) {
$vEvent->add('DESCRIPTION', $body);
}
+
+ // Add categories
+ if (!empty($this->getProp($messageProps, "categories"))) {
+ $categories = array_map('trim', explode(';', trim($this->getProp($messageProps, "categories"), " ;")));
+
+ $vEvent->add('CATEGORIES', $categories);
+ }
}
// write combined ics file
@@ -674,7 +691,15 @@ class CalendarModule extends Module
$properties["comment"] = (string)$vEvent->COMMENT;
$properties["timezone"] = (string)$vEvent->DTSTART["TZID"];
$properties["organizer"] = (string)$vEvent->ORGANIZER;
- $properties["busystatus"] = array_search((string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}, $this->busyStates); // X-MICROSOFT-CDO-BUSYSTATUS
+ if(!empty((string)$vEvent->FBTYPE)) {
+ $properties["busystatus"] = array_search((string)$vEvent->FBTYPE, $this->freeBusyStates);
+ } else if(!empty((string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'})) {
+ $properties["busystatus"] = array_search((string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}, $this->busyStates);
+ } else if(!empty((string)$vEvent->{'X-MICROSOFT-CDO-BUSYSTATUS'})) {
+ $properties["busystatus"] = array_search((string)$vEvent->{'X-MICROSOFT-CDO-BUSYSTATUS'}, $this->busyStates);
+ } else {
+ $properties["busystatus"] = array_search("BUSY", $this->busyStates);
+ }
$properties["transp"] = (string)$vEvent->TRANSP;
//$properties["trigger"] = (string)$vEvent->COMMENT;
$properties["priority"] = (string)$vEvent->PRIORITY;
@@ -683,10 +708,27 @@ class CalendarModule extends Module
if (!empty($zLabel)) {
$properties["label"] = array_search($zLabel, $this->labels);
}
- $properties["last_modification_time"] = (string)$vEvent->{'LAST-MODIFIED'}->getDateTime()->getTimestamp();
- $properties["creation_time"] = (string)$vEvent->CREATED->getDateTime()->getTimestamp();
+ if (!empty((string)$vEvent->{'LAST-MODIFIED'})) {
+ $properties["last_modification_time"] = (string)$vEvent->{'LAST-MODIFIED'}->getDateTime()->getTimestamp();
+ } else {
+ $properties["last_modification_time"] = time();
+ }
+ if (!empty((string)$vEvent->CREATED)) {
+ $properties["creation_time"] = (string)$vEvent->CREATED->getDateTime()->getTimestamp();
+ } else {
+ $properties["creation_time"] = time();
+ }
$properties["rrule"] = (string)$vEvent->RRULE;
+ if (isset($vEvent->CATEGORIES) && count($vEvent->CATEGORIES) > 0) {
+ $categories = array();
+ foreach ($vEvent->CATEGORIES as $category) {
+ $categories[] = (string) $category;
+ }
+
+ $properties["categories"] = $categories;
+ }
+
// Attendees
$properties["attendees"] = array();
if (isset($vEvent->ATTENDEE) && count($vEvent->ATTENDEE) > 0) {