Commit df451dc4 authored by Sebastian Kummer's avatar Sebastian Kummer

ZO-81 Transport notes as appointments (for real!), set note lastmodified

time from appointment's dtstamp on incoming, set body for notes only if
the asbody element is incoming.
parent f7021fd9
......@@ -1646,7 +1646,9 @@ class MAPIProvider {
$props = array();
$props[$noteprops["messageclass"]] = "IPM.StickyNote";
// set body otherwise the note will be "broken" when editing it in outlook
if (isset($note->asbody)) {
$this->setASbody($note->asbody, $props, $noteprops);
}
$props[$noteprops["internetcpid"]] = INTERNET_CPID_UTF8;
mapi_setprops($mapimessage, $props);
......
......@@ -88,27 +88,33 @@ class ImportChangesStream implements IImportChanges {
return false;
}
// Acacia ZO-42: to sync Notes to Outlook we sync them as Tasks
// Acacia ZO-42: to sync Notes to Outlook we sync them as Appointments
if ($this->classAsString == "SyncNote" && ZPush::GetDeviceManager()->IsOutlookClient()) {
// update category from SyncNote->Color
$message->SetCategoryFromColor();
$task = new SyncTask();
$task->complete = 0;
$task->sensitivity = 0;
$task->reminder = 0;
$appointment = new SyncAppointment();
$appointment->busystatus = 0;
$appointment->sensitivity = 0;
$appointment->alldayevent = 0;
$appointment->reminder = 0;
$appointment->meetingstatus = 0;
$appointment->responserequested = 0;
$task->flags = $message->flags;
$appointment->flags = $message->flags;
if (isset($message->asbody))
$task->asbody = $message->asbody;
$appointment->asbody = $message->asbody;
if (isset($message->categories))
$task->categories = $message->categories;
$appointment->categories = $message->categories;
if (isset($message->subject))
$task->subject = $message->subject;
$appointment->subject = $message->subject;
if (isset($message->lastmodified))
$task->startdate = $message->lastmodified;
$appointment->dtstamp = $message->lastmodified;
$message = $task;
$appointment->starttime = time();
$appointment->endtime = $appointment->starttime + 1;
$message = $appointment;
}
// prevent sending the same object twice in one request
......
......@@ -283,8 +283,8 @@ class Ping extends RequestProcessor {
*/
private function isClassValid($class, $spa) {
if ($class == $spa->GetContentClass() ||
// Acacia ZO-42: Notes are synched as Tasks
(self::$deviceManager->IsOutlookClient() && $class == "Tasks" && $spa->GetContentClass() == "Notes")
// Acacia ZO-42: Notes are synched as Appointments
(self::$deviceManager->IsOutlookClient() && $class == "Calendar" && $spa->GetContentClass() == "Notes")
) {
return true;
}
......
......@@ -453,10 +453,10 @@ class Sync extends RequestProcessor {
if(($el = self::$decoder->getElementStartTag(SYNC_DATA)) && ($el[EN_FLAGS] & EN_FLAGS_CONTENT)) {
$message = ZPush::getSyncObjectFromFolderClass($spa->GetContentClass());
// Acacia ZO-42: OL sends Notes as Tasks
// Acacia ZO-42: OL sends Notes as Appointments
if ($spa->GetContentClass() == "Notes" && self::$deviceManager->IsOutlookClient()) {
ZLog::Write(LOGLEVEL_DEBUG, "HandleSync(): Outlook sends Notes as Tasks, read as SyncTask and convert it into a SyncNote object.");
$message = new SyncTask();
ZLog::Write(LOGLEVEL_DEBUG, "HandleSync(): Outlook sends Notes as Appointments, read as SyncAppointment and convert it into a SyncNote object.");
$message = new SyncAppointment();
$message->Decode(self::$decoder);
$note = new SyncNote();
......@@ -466,16 +466,13 @@ class Sync extends RequestProcessor {
$note->categories = $message->categories;
if (isset($message->subject))
$note->subject = $message->subject;
if (isset($message->dtstamp))
$note->lastmodified = $message->dtstamp;
// set SyncNote->Color from a color category
$note->SetColorFromCategory();
$message = $note;
// on type change, OL sends messages without a body. Ignore these updates.
if (!isset($message->asbody)) {
$message = false;
}
}
else {
$message->Decode(self::$decoder);
......
......@@ -97,9 +97,6 @@ class SyncNote extends SyncObject {
* @return void
*/
public function SetColorFromCategory() {
// default to yellow
$result = array("Yellow Category");
if (!empty($this->categories)) {
$result = array_intersect($this->categories, array_values(self::$colors));
if (empty($result)) {
......@@ -109,11 +106,15 @@ class SyncNote extends SyncObject {
$result = array("White Category");
}
}
}
if (!empty($result)) {
$this->Color = array_search($result[0], self::$colors);
}
}
// unset or empty category means we have to reset the color to yellow
else {
$this->Color = 3;
}
}
/**
* Sets the category for a Color if color categories are not yet set.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment