Import and export of free/busy state

This commit is contained in:
Christoph Haas 2016-12-05 18:47:21 +01:00
parent 38f3ad7cd6
commit 92660c34b1
2 changed files with 147 additions and 25 deletions

View File

@ -2,7 +2,6 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e7c9c2bb-66f1-4e37-904c-d33d8c113bde" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/php/module.calendar.php" afterPath="$PROJECT_DIR$/php/module.calendar.php" />
</list>
<ignored path="calendarimporter.iws" />
@ -27,16 +26,39 @@
<file leaf-file-name="module.calendar.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/php/module.calendar.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="279">
<caret line="691" column="13" selection-start-line="691" selection-start-column="13" selection-end-line="691" selection-end-column="13" />
<state relative-caret-position="748">
<caret line="700" column="60" selection-start-line="700" selection-start-column="60" selection-end-line="700" selection-end-column="60" />
<folding>
<element signature="e#6#914#0#PHP" expanded="true" />
<element signature="e#1004#1022#0#PHP" expanded="true" />
<marker date="1480959958013" expanded="false" signature="13026:16843" ph="{...}" />
<marker date="1480959958013" expanded="false" signature="17066:23319" ph="{...}" />
<marker date="1480959958013" expanded="false" signature="23520:25269" ph="{...}" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="plugin.calendarimporter.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/plugin.calendarimporter.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="13" column="25" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ImportPanel.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-6381">
<caret line="113" column="29" selection-start-line="113" selection-start-column="21" selection-end-line="113" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -196,6 +218,46 @@
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="php" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="vendor" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="php" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="vendor" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="sabre" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
@ -228,6 +290,24 @@
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="js" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="settings" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="calendarimporter" />
@ -342,12 +422,12 @@
<workItem from="1480509394154" duration="63000" />
<workItem from="1480548170124" duration="207000" />
<workItem from="1480584080034" duration="27000" />
<workItem from="1480955138355" duration="887000" />
<workItem from="1480955138355" duration="4533000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="24940000" />
<option name="totallyTimeSpent" value="28586000" />
</component>
<component name="ToolWindowManager">
<frame x="65" y="24" width="1776" height="983" extended-state="6" />
@ -397,6 +477,9 @@
<folding>
<element signature="e#6#914#0#PHP" expanded="true" />
<element signature="e#1004#1022#0#PHP" expanded="true" />
<marker date="1480959958013" expanded="false" signature="13026:16843" ph="{...}" />
<marker date="1480959958013" expanded="false" signature="17066:23319" ph="{...}" />
<marker date="1480959958013" expanded="false" signature="23520:25269" ph="{...}" />
</folding>
</state>
</provider>
@ -677,13 +760,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.calendarimporter.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-165">
<caret line="13" column="25" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/resources/css/calendarimporter-main.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
@ -736,13 +812,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="583">
<caret line="113" column="29" selection-start-line="113" selection-start-column="21" selection-end-line="113" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/composer.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
@ -750,13 +819,32 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-6381">
<caret line="113" column="29" selection-start-line="113" selection-start-column="21" selection-end-line="113" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.calendarimporter.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="13" column="25" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/module.calendar.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="279">
<caret line="691" column="13" selection-start-line="691" selection-start-column="13" selection-end-line="691" selection-end-column="13" />
<state relative-caret-position="748">
<caret line="700" column="60" selection-start-line="700" selection-start-column="60" selection-end-line="700" selection-end-column="60" />
<folding>
<element signature="e#6#914#0#PHP" expanded="true" />
<element signature="e#1004#1022#0#PHP" expanded="true" />
<marker date="1480959958013" expanded="false" signature="13026:16843" ph="{...}" />
<marker date="1480959958013" expanded="false" signature="17066:23319" ph="{...}" />
<marker date="1480959958013" expanded="false" signature="23520:25269" ph="{...}" />
</folding>
</state>
</provider>

View File

@ -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
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) {
@ -318,6 +328,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
@ -672,7 +689,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;
@ -692,6 +717,15 @@ class CalendarModule extends Module
}
$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) {