/** * Imports a single message * * @param string $id * @param SyncObject $message * * @access public * @return boolean/string - failure / id of message * @throws StatusException */ public function ImportMessageChange($id, $message) { $parentsourcekey = $this->folderid; if ($id) { $sourcekey = hex2bin($id); } $flags = 0; $props = array(); $props[PR_PARENT_SOURCE_KEY] = $parentsourcekey; // set the PR_SOURCE_KEY if available or mark it as new message if ($id) { $props[PR_SOURCE_KEY] = $sourcekey; // check for conflicts $this->lazyLoadConflicts(); if ($this->memChanges->IsChanged($id)) { if ($this->flags & SYNC_CONFLICT_OVERWRITE_PIM) { // in these cases the status SYNC_STATUS_CONFLICTCLIENTSERVEROBJECT should be returned, so the mobile client can inform the end user throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Server overwrites PIM. User is informed.", $id, get_class($message)), SYNC_STATUS_CONFLICTCLIENTSERVEROBJECT, null, LOGLEVEL_INFO); return false; } else { ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from Server will be dropped! PIM overwrites server.", $id, get_class($message))); } } if ($this->memChanges->IsDeleted($id)) { ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Object was deleted on server.", $id, get_class($message))); return false; } } else { $flags = SYNC_NEW_MESSAGE; } if (mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) { $this->mapiprovider->SetMessage($mapimessage, $message); mapi_message_savechanges($mapimessage); if (mapi_last_hresult()) { throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error, mapi_message_savechanges() failed: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_SYNCCANNOTBECOMPLETED); } $sourcekeyprops = mapi_getprops($mapimessage, array(PR_SOURCE_KEY)); return bin2hex($sourcekeyprops[PR_SOURCE_KEY]); } else { throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error updating object: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND); } }
function ImportMessageChange($id, $message) { $parentsourcekey = $this->_folderid; if ($id) { $sourcekey = hex2bin($id); } $flags = 0; $props = array(); $props[PR_PARENT_SOURCE_KEY] = $parentsourcekey; // set the PR_SOURCE_KEY if available or mark it as new message if ($id) { $props[PR_SOURCE_KEY] = $sourcekey; // check for conflicts $this->_lazyLoadConflicts(); if ($this->_memChanges->isChanged($id)) { if ($this->_flags & SYNC_CONFLICT_OVERWRITE_PIM) { debugLog("Conflict detected. Data from PIM will be dropped! Server overwrites PIM."); return false; } else { debugLog("Conflict detected. Data from Server will be dropped! PIM overwrites server."); } } if ($this->_memChanges->isDeleted($id)) { debugLog("Conflict detected. Data from PIM will be dropped! Object was deleted on server."); return false; } } else { $flags = SYNC_NEW_MESSAGE; } if (mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) { $this->_setMessage($mapimessage, $message); mapi_message_savechanges($mapimessage); $sourcekeyprops = mapi_getprops($mapimessage, array(PR_SOURCE_KEY)); } else { debugLog("Unable to update object {$id}:" . sprintf("%x", mapi_last_hresult())); return false; } return bin2hex($sourcekeyprops[PR_SOURCE_KEY]); }
function ImportMessageFlag($id, $flag) { $emailflag = $this->_emailflagmapping; $entryid = mapi_msgstore_entryidfromsourcekey($this->_store, hex2bin($id)); $mapimessage = mapi_msgstore_openentry($this->_store, $entryid); if ($mapimessage == false) { debugLog("Unable to openentry in ImportMessageFlag: " . sprintf("%x", mapi_last_hresult())); } else { // we need this for importing changes in the end... $flags = 0; $props = array(); $props = mapi_getprops($mapimessage, array(PR_PARENT_SOURCE_KEY, PR_SOURCE_KEY)); // so now do the job with the flags. Delete flags not being sent, set flags that are in sync packet // flagicon is just necessary for Zarafa WebAccess. Outlook does not need it. $setflags = array(); $delflags = array(); if (isset($flag->flagstatus) && $flag->flagstatus != "") { $setflags += array($this->_getPropIDFromString($emailflag["flagstatus"]) => $flag->flagstatus); switch ($flag->flagstatus) { case '2': $setflags += array($this->_getPropIDFromString($emailflag["flagicon"]) => 6); break; default: $setflags += array($this->_getPropIDFromString($emailflag["flagicon"]) => 0); break; } } else { $delflags[] = $this->_getPropIDFromString($emailflag["flagstatus"]); $delflags[] = $this->_getPropIDFromString($emailflag["flagicon"]); } // dw2412 in case the flag should be removed... just do it compatible with o2k7 if (isset($flag->flagstatus) && ($flag->flagstatus == 0 || $flag->flagstatus == "") || !isset($flag->flagstatus)) { $delflags[] = $this->_getPropIDFromString($emailflag["flagstatus"]); $delflags[] = $this->_getPropIDFromString($emailflag["flagicon"]); $delflags[] = $this->_getPropIDFromString("PT_SYSTIME:{00062003-0000-0000-C000-000000000046}:0x8104"); $delflags[] = $this->_getPropIDFromString("PT_SYSTIME:{00062003-0000-0000-C000-000000000046}:0x8105"); $delflags[] = $this->_getPropIDFromString("PT_SYSTIME:{00062008-0000-0000-C000-000000000046}:0x8516"); $delflags[] = $this->_getPropIDFromString("PT_SYSTIME:{00062008-0000-0000-C000-000000000046}:0x8517"); $delflags[] = $this->_getPropIDFromString("PT_SYSTIME:{00062006-0000-0000-C000-000000000046}:0x85A0"); $delflags[] = $this->_getPropIDFromString("PT_STRING8:{00062006-0000-0000-C000-000000000046}:0x85A1"); $delflags[] = $this->_getPropIDFromString("PT_STRING8:{00062006-0000-0000-C000-000000000046}:0x85A4"); $setflags += array($this->_getPropIDFromString("PT_STRING8:{00062008-0000-0000-C000-000000000046}:0x8530") => ""); $setflags += array($this->_getPropIDFromString("PT_BOOLEAN:{00062008-0000-0000-C000-000000000046}:0x8503") => "0"); $setflags += array($this->_getPropIDFromString("PT_LONG:{00062003-0000-0000-C000-000000000046}:0x8101") => "0"); $setflags += array($this->_getPropIDFromString("PT_DOUBLE:{00062003-0000-0000-C000-000000000046}:0x8102") => "0"); $setflags += array($this->_getPropIDFromString("PT_BOOLEAN:{00062003-0000-0000-C000-000000000046}:0x811C") => "0"); $setflags += array(mapi_prop_tag(PT_LONG, 0xe2b) => "0"); //dw2412 responsible for displaying flag in O2K7, added as 'PR_TODO_ITEM_FLAGS' to the mapitags.php $setflags += array($this->_getPropIDFromString($emailflag["reminderset"]) => "0"); } else { if (isset($flag->flagtype) && $flag->flagtype != "") { $setflags += array($this->_getPropIDFromString($emailflag["flagtype"]) => $flag->flagtype); } else { $delflags[] = $this->_getPropIDFromString($emailflag["flagtype"]); } if (isset($flag->startdate) && $flag->startdate != "") { $setflags += array($this->_getPropIDFromString($emailflag["startdate"]) => $flag->startdate); } else { $delflags[] = $this->_getPropIDFromString($emailflag["startdate"]); } if (isset($flag->duedate) && $flag->duedate != "") { $setflags += array($this->_getPropIDFromString($emailflag["duedate"]) => $flag->duedate); } else { $delflags[] = $this->_getPropIDFromString($emailflag["duedate"]); } if (isset($flag->datecompleted) && $flag->datecompleted != "") { $setflags += array($this->_getPropIDFromString($emailflag["datecompleted"]) => $flag->datecompleted); } else { $delflags[] = $this->_getPropIDFromString($emailflag["datecompleted"]); } if (isset($flag->reminderset) && $flag->reminderset != "") { $setflags += array($this->_getPropIDFromString($emailflag["reminderset"]) => $flag->reminderset); } else { if ($flag->flagstatus > 0) { $setflags += array($this->_getPropIDFromString($emailflag["reminderset"]) => "0"); } else { $delflags[] = $this->_getPropIDFromString($emailflag["reminderset"]); } } if (isset($flag->remindertime) && $flag->remindertime != "") { $setflags += array($this->_getPropIDFromString($emailflag["remindertime"]) => $flag->remindertime); } else { $delflags[] = $this->_getPropIDFromString($emailflag["remindertime"]); } if (isset($flag->ordinaldate) && $flag->ordinaldate != "") { $setflags += array($this->_getPropIDFromString($emailflag["ordinaldate"]) => $flag->ordinaldate); } else { $delflags[] = $this->_getPropIDFromString($emailflag["ordinaldate"]); } if (isset($flag->subordinaldate) && $flag->subordinaldate != "") { $setflags += array($this->_getPropIDFromString($emailflag["subordinaldate"]) => $flag->subordinaldate); } else { $delflags[] = $this->_getPropIDFromString($emailflag["subordinaldate"]); } if (isset($flag->completetime) && $flag->completetime != "") { $setflags += array($this->_getPropIDFromString($emailflag["completetime"]) => $flag->completetime); } else { $delflags[] = $this->_getPropIDFromString($emailflag["completetime"]); } } // hopefully I'm doing this right. It should prevent the back sync of whole message mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage); mapi_setprops($mapimessage, $setflags); mapi_deleteprops($mapimessage, $delflags); mapi_savechanges($mapimessage); return true; } }
function ImportMessageChange($id, $message) { $parentsourcekey = $this->_folderid; if ($id) { $sourcekey = hex2bin($id); } $flags = 0; $props = array(); $props[PR_PARENT_SOURCE_KEY] = $parentsourcekey; // set the PR_SOURCE_KEY if available or mark it as new message if ($id) { $props[PR_SOURCE_KEY] = $sourcekey; } else { $flags = SYNC_NEW_MESSAGE; } if (mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) { $this->_setMessage($mapimessage, $message); mapi_message_savechanges($mapimessage); $sourcekeyprops = mapi_getprops($mapimessage, array(PR_SOURCE_KEY)); } else { debugLog("Unable to update object {$id}:" . sprintf("%x", mapi_last_hresult())); return false; } return bin2hex($sourcekeyprops[PR_SOURCE_KEY]); }
/** * Imports a single message * * @param string $id * @param SyncObject $message * * @access public * @return boolean/string - failure / id of message * @throws StatusException */ public function ImportMessageChange($id, $message) { $flags = 0; $props = array(); $props[PR_PARENT_SOURCE_KEY] = $this->folderid; // set the PR_SOURCE_KEY if available or mark it as new message if ($id) { list(, $sk) = Utils::SplitMessageId($id); $props[PR_SOURCE_KEY] = hex2bin($sk); // on editing an existing message, check if it is in the synchronization interval if (!$this->isMessageInSyncInterval($sk)) { throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Message is outside the sync interval. Data not saved.", $id, get_class($message)), SYNC_STATUS_SYNCCANNOTBECOMPLETED); } // check for conflicts $this->lazyLoadConflicts(); if ($this->memChanges->IsChanged($id)) { if ($this->flags & SYNC_CONFLICT_OVERWRITE_PIM) { // in these cases the status SYNC_STATUS_CONFLICTCLIENTSERVEROBJECT should be returned, so the mobile client can inform the end user throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Server overwrites PIM. User is informed.", $id, get_class($message)), SYNC_STATUS_CONFLICTCLIENTSERVEROBJECT, null, LOGLEVEL_INFO); return false; } else { ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from Server will be dropped! PIM overwrites server.", $id, get_class($message))); } } if ($this->memChanges->IsDeleted($id)) { ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Object was deleted on server.", $id, get_class($message))); return false; } // KOE ZP-990: OL updates the deleted category which causes a race condition if more than one KOE is connected to that user if (ZPush::GetDeviceManager()->IsKoe() && KOE_CAPABILITY_RECEIVEFLAGS && $message instanceof SyncMail && !isset($message->flag) && isset($message->categories)) { // check if the categories changed $mapiCategories = $this->mapiprovider->GetMessageCategories($props[PR_PARENT_SOURCE_KEY], $props[PR_SOURCE_KEY]); if (empty($message->categories) && empty($mapiCategories) || is_array($mapiCategories) && count(array_diff($mapiCategories, $message->categories)) == 0 && count(array_diff($message->categories, $mapiCategories)) == 0) { ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesICS->ImportMessageChange(): KOE update of flag categories. Ignoring incoming update."); return $id; } } } else { $flags = SYNC_NEW_MESSAGE; } if (mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) { $this->mapiprovider->SetMessage($mapimessage, $message); mapi_message_savechanges($mapimessage); if (mapi_last_hresult()) { throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error, mapi_message_savechanges() failed: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_SYNCCANNOTBECOMPLETED); } $sourcekeyprops = mapi_getprops($mapimessage, array(PR_SOURCE_KEY)); return $this->prefix . bin2hex($sourcekeyprops[PR_SOURCE_KEY]); } else { throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error updating object: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND); } }