Commit bb28568f authored by Manfred Kutas's avatar Manfred Kutas

ZP-1019 Move SplitMessageId function to Utils class.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 2c514c06
...@@ -393,7 +393,7 @@ class ImportChangesICS implements IImportChanges { ...@@ -393,7 +393,7 @@ class ImportChangesICS implements IImportChanges {
// set the PR_SOURCE_KEY if available or mark it as new message // set the PR_SOURCE_KEY if available or mark it as new message
if($id) { if($id) {
list(, $sk) = MAPIUtils::SplitMessageId($id); list(, $sk) = Utils::SplitMessageId($id);
$props[PR_SOURCE_KEY] = hex2bin($sk); $props[PR_SOURCE_KEY] = hex2bin($sk);
// on editing an existing message, check if it is in the synchronization interval // on editing an existing message, check if it is in the synchronization interval
...@@ -456,7 +456,7 @@ class ImportChangesICS implements IImportChanges { ...@@ -456,7 +456,7 @@ class ImportChangesICS implements IImportChanges {
* @return boolean * @return boolean
*/ */
public function ImportMessageDeletion($id, $asSoftDelete = false) { public function ImportMessageDeletion($id, $asSoftDelete = false) {
list(,$sk) = MAPIUtils::SplitMessageId($id); list(,$sk) = Utils::SplitMessageId($id);
// check if the message is in the current syncinterval // check if the message is in the current syncinterval
if (!$this->isMessageInSyncInterval($sk)) if (!$this->isMessageInSyncInterval($sk))
throw new StatusException(sprintf("ImportChangesICS->ImportMessageDeletion('%s'): Message is outside the sync interval and so far not deleted.", $id), SYNC_STATUS_OBJECTNOTFOUND); throw new StatusException(sprintf("ImportChangesICS->ImportMessageDeletion('%s'): Message is outside the sync interval and so far not deleted.", $id), SYNC_STATUS_OBJECTNOTFOUND);
...@@ -490,7 +490,7 @@ class ImportChangesICS implements IImportChanges { ...@@ -490,7 +490,7 @@ class ImportChangesICS implements IImportChanges {
* @throws StatusException * @throws StatusException
*/ */
public function ImportMessageReadFlag($id, $flags) { public function ImportMessageReadFlag($id, $flags) {
list($fsk,$sk) = MAPIUtils::SplitMessageId($id); list($fsk,$sk) = Utils::SplitMessageId($id);
// if $fsk is set, we convert it into a backend id. // if $fsk is set, we convert it into a backend id.
if ($fsk) { if ($fsk) {
...@@ -556,7 +556,7 @@ class ImportChangesICS implements IImportChanges { ...@@ -556,7 +556,7 @@ class ImportChangesICS implements IImportChanges {
* @throws StatusException * @throws StatusException
*/ */
public function ImportMessageMove($id, $newfolder) { public function ImportMessageMove($id, $newfolder) {
list(,$sk) = MAPIUtils::SplitMessageId($id); list(,$sk) = Utils::SplitMessageId($id);
if (strtolower($newfolder) == strtolower(bin2hex($this->folderid)) ) if (strtolower($newfolder) == strtolower(bin2hex($this->folderid)) )
throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, source and destination are equal", $id, $newfolder), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST); throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, source and destination are equal", $id, $newfolder), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST);
......
...@@ -624,7 +624,7 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -624,7 +624,7 @@ class BackendKopano implements IBackend, ISearchProvider {
*/ */
public function Fetch($folderid, $id, $contentparameters) { public function Fetch($folderid, $id, $contentparameters) {
// id might be in the new longid format, so we have to split it here // id might be in the new longid format, so we have to split it here
list($fsk, $sk) = MAPIUtils::SplitMessageId($id); list($fsk, $sk) = Utils::SplitMessageId($id);
// get the entry id of the message // get the entry id of the message
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($sk)); $entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($sk));
if(!$entryid) if(!$entryid)
...@@ -774,7 +774,7 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -774,7 +774,7 @@ class BackendKopano implements IBackend, ISearchProvider {
*/ */
public function MeetingResponse($requestid, $folderid, $response) { public function MeetingResponse($requestid, $folderid, $response) {
// Use standard meeting response code to process meeting request // Use standard meeting response code to process meeting request
list($fid, $requestid) = MAPIUtils::SplitMessageId($requestid); list($fid, $requestid) = Utils::SplitMessageId($requestid);
$reqentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($requestid)); $reqentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($requestid));
if (!$reqentryid) if (!$reqentryid)
throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s', '%s', '%s'): Error, unable to entryid of the message 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s', '%s', '%s'): Error, unable to entryid of the message 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ);
......
...@@ -619,20 +619,4 @@ class MAPIUtils { ...@@ -619,20 +619,4 @@ class MAPIUtils {
} }
// TODO check if we need to do this for encrypted (and signed?) message as well // TODO check if we need to do this for encrypted (and signed?) message as well
} }
/**
* Splits the id into folder id and message id parts. A colon in the $id indicates
* that the id has folderid:messageid format.
*
* @param string $id
*
* @access public
* @return array
*/
public static function SplitMessageId($id) {
if (strpos($id, ':') !== false) {
return explode(':', $id);
}
return array(null, $id);
}
} }
...@@ -449,7 +449,7 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges { ...@@ -449,7 +449,7 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges {
} }
$message = false; $message = false;
list($fsk, $sk) = MAPIUtils::SplitMessageId($id); list($fsk, $sk) = Utils::SplitMessageId($id);
$sourcekey = hex2bin($sk); $sourcekey = hex2bin($sk);
$parentsourcekey = hex2bin(ZPush::GetDeviceManager()->GetBackendIdForFolderId($fsk)); $parentsourcekey = hex2bin(ZPush::GetDeviceManager()->GetBackendIdForFolderId($fsk));
......
...@@ -125,7 +125,7 @@ class SendMail extends RequestProcessor { ...@@ -125,7 +125,7 @@ class SendMail extends RequestProcessor {
$sm->source->folderid = self::$deviceManager->GetBackendIdForFolderId($sm->source->folderid); $sm->source->folderid = self::$deviceManager->GetBackendIdForFolderId($sm->source->folderid);
} }
if (isset($sm->source->itemid)) { if (isset($sm->source->itemid)) {
list(, $sk) = MAPIUtils::SplitMessageId($sm->source->itemid); list(, $sk) = Utils::SplitMessageId($sm->source->itemid);
$sm->source->itemid = $sk; $sm->source->itemid = $sk;
} }
// replyflag and forward flags are actually only for the correct icon. // replyflag and forward flags are actually only for the correct icon.
......
...@@ -1111,6 +1111,22 @@ class Utils { ...@@ -1111,6 +1111,22 @@ class Utils {
ZLog::Write(LOGLEVEL_WARN, sprintf("Utils->GetFolderOriginFromId(): Unknown folder origin for folder with id '%s'", $fid)); ZLog::Write(LOGLEVEL_WARN, sprintf("Utils->GetFolderOriginFromId(): Unknown folder origin for folder with id '%s'", $fid));
return 'unknown'; return 'unknown';
} }
/**
* Splits the id into folder id and message id parts. A colon in the $id indicates
* that the id has folderid:messageid format.
*
* @param string $id
*
* @access public
* @return array
*/
public static function SplitMessageId($id) {
if (strpos($id, ':') !== false) {
return explode(':', $id);
}
return array(null, $id);
}
} }
......
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