Commit cb0793aa authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #14 in ZO/z-push from feature/ZO-81-appointments-for-note-synching to develop

* commit '30c07ae3':
  ZO-81 Fix color name in comment.
  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.
  ZO-81 Set PR_ICON_INDEX and PidLidNoteColor from categories sent from Outlook, translate note color to category when streaming to outlook, fallback to yellow if no category is sent, fixed typos
  ZO-81 Use Task as Note transport, set category from color when streaming to Outlook, set color from category when saving from Outlook.
  ZO-81 Transport note color in apppointment location, don't import/save message if no body is transmitted by OL, color has hidden instance SyncNote variable, set other appointment values: busystatus (free), sensitivity (dafault), alldayevent (false), reminder (no), mettingstatus (no meeting) and responserequested (no), send last modification timestamp in dtstamp.
  ZO-81 Transport Notes as Appointments.
parents 4b07e2b2 30c07ae3
......@@ -464,6 +464,8 @@ class MAPIMapping {
"lastmodified" => PR_LAST_MODIFICATION_TIME,
"messageclass" => PR_MESSAGE_CLASS,
"subject" => PR_SUBJECT,
"Color" => "PT_LONG:PSETID_Note:0x8B00",
"Iconindex" => PR_ICON_INDEX,
);
}
......
......@@ -1632,6 +1632,11 @@ class MAPIProvider {
// Setting it to an empty array will unset the property in Zarafa as well
if (!isset($note->categories)) $note->categories = array();
// update icon index to correspond to the color
if (isset($note->Color) && $note->Color > -1 && $note->Color < 5) {
$note->Iconindex = 768 + $note->Color;
}
$this->setPropsInMAPI($mapimessage, $note, MAPIMapping::GetNoteMapping());
$noteprops = MAPIMapping::GetNoteProperties();
......@@ -1641,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
$this->setASbody($note->asbody, $props, $noteprops);
if (isset($note->asbody)) {
$this->setASbody($note->asbody, $props, $noteprops);
}
$props[$noteprops["internetcpid"]] = INTERNET_CPID_UTF8;
mapi_setprops($mapimessage, $props);
......
......@@ -88,19 +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()) {
$task = new SyncTask();
$task->flags = $message->flags;
// update category from SyncNote->Color
$message->SetCategoryFromColor();
$appointment = new SyncAppointment();
$appointment->busystatus = 0;
$appointment->sensitivity = 0;
$appointment->alldayevent = 0;
$appointment->reminder = 0;
$appointment->meetingstatus = 0;
$appointment->responserequested = 0;
$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;
// TODO color of the note
$appointment->subject = $message->subject;
if (isset($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
......
......@@ -680,6 +680,7 @@ define("SYNC_NOTES_MESSAGECLASS", "Notes:MessageClass");
define("SYNC_NOTES_LASTMODIFIEDDATE", "Notes:LastModifiedDate");
define("SYNC_NOTES_CATEGORIES", "Notes:Categories");
define("SYNC_NOTES_CATEGORY", "Notes:Category");
define("SYNC_NOTES_IGNORE_COLOR","Notes:IgnoreColor");
//RightsManagement //post 14.0
define("SYNC_RIGHTSMANAGEMENT_SUPPORT", "RightsManagement:RightsManagementSupport");
......
......@@ -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 Tasks 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,15 +466,21 @@ class Sync extends RequestProcessor {
$note->categories = $message->categories;
if (isset($message->subject))
$note->subject = $message->subject;
// TODO color of the note
if (isset($message->dtstamp))
$note->lastmodified = $message->dtstamp;
// set SyncNote->Color from a color category
$note->SetColorFromCategory();
$message = $note;
}
else {
$message->Decode(self::$decoder);
// set Ghosted fields
$message->emptySupported(self::$deviceManager->GetSupportedFields($spa->GetFolderId()));
}
// set Ghosted fields
$message->emptySupported(self::$deviceManager->GetSupportedFields($spa->GetFolderId()));
if(!self::$decoder->getElementEndTag()) // end applicationdata
return false;
}
......
......@@ -47,11 +47,27 @@
class SyncNote extends SyncObject {
// Outlook transports note colors as categories
static private $colors = array(
0 => "Blue Category",
1 => "Green Category",
2 => "Red Category",
3 => "Yellow Category",
4 => "White Category",
);
// Purple and orange are not supported in PidLidNoteColor
static private $unsupportedColors = array(
"Purple Category",
"Orange Category",
);
public $asbody;
public $categories;
public $lastmodified;
public $messageclass;
public $subject;
public $Color;
function SyncNote() {
$mapping = array(
......@@ -67,8 +83,60 @@ class SyncNote extends SyncObject {
SYNC_NOTES_MESSAGECLASS => array ( self::STREAMER_VAR => "messageclass"),
SYNC_NOTES_SUBJECT => array ( self::STREAMER_VAR => "subject"),
SYNC_NOTES_IGNORE_COLOR => array ( self::STREAMER_VAR => "Color"),
);
parent::SyncObject($mapping);
}
/**
* Sets the color index from a known category.
*
* @access public
* @return void
*/
public function SetColorFromCategory() {
if (!empty($this->categories)) {
$result = array_intersect($this->categories, array_values(self::$colors));
if (empty($result)) {
$result = array_intersect($this->categories, array_values(self::$unsupportedColors));
if (!empty($result)) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncNote->SetColorFromCategory(): unsupported color '%s', setting to color white", $result[0]));
$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.
*
* @access public
* @return boolean
*/
public function SetCategoryFromColor() {
// is a color other than yellow set
if (isset($this->Color) && $this->Color != 3 && $this->Color > -1 && $this->Color < 5) {
// check existing categories - do not rewrite category if the category is already a supported or unsupported color
if (!empty($this->categories) &&
(!empty(array_intersect($this->categories, array_values(self::$unsupportedColors))) ||
!empty(array_intersect($this->categories, array_values(self::$colors))) )) {
return false;
}
if(!isset($this->categories)) {
$this->categories = array();
}
$this->categories[] = self::$colors[$this->Color];
return true;
}
}
}
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