diff --git a/CHANGELOG.md b/CHANGELOG.md index 238a953d..82ec9503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.7.6 - 2016-04-19 + * Added a `API::convertIdFormat($itemId, $oldFormat, $destinationFormat, $mailbox)` function + ## 0.7.5 - 2016-04-18 * Removed `NTLMSoapClient\Exchange`. Folded the few lines of functionality in to `NTLMSoapClient` * Added `API::getServerTimezones($timezoneIDs = array(), $fullTimezoneData = false)` diff --git a/examples/basic/README.md b/examples/basic/README.md index 175b86ce..c73dcf02 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -9,3 +9,4 @@ libraries, so that you can utilize the API beyond what has been simplified. * [Impersonating Other Users](impersonation.php) * [Accessing a Primary SMTP Mailbox](primarySmtpAddress.php) * [Using the EWS Library with Office 365 and OAuth](authenticatingWithOAuth.php) + * [Converting EWS ID Formats](convertItemIdFormat.php) diff --git a/examples/basic/convertItemIdFormat.php b/examples/basic/convertItemIdFormat.php new file mode 100644 index 00000000..b4949a81 --- /dev/null +++ b/examples/basic/convertItemIdFormat.php @@ -0,0 +1,16 @@ +convertIdFormat( + $ews2007ItemId, + Enumeration\IdFormatType::EWS_LEGACY_ID, + Enumeration\IdFormatType::EWS_ID, + 'user@email.com' +); diff --git a/src/API.php b/src/API.php index 5c803060..e3af5ee9 100644 --- a/src/API.php +++ b/src/API.php @@ -565,4 +565,30 @@ public function getServerTimezones($timezoneIDs = array(), $fullTimezoneData = f return $timezones; } + + /** + * @param Type\ItemIdType $itemId + * @param $fromType + * @param $destinationType + * @param $mailbox + * + * @return Type\ItemIdType + */ + public function convertIdFormat(Type\ItemIdType $itemId, $fromType, $destinationType, $mailbox) + { + $result = $this->getClient()->ConvertId(array( + 'DestinationFormat' => $destinationType, + 'SourceIds' => array ( + 'AlternateId' => array( + 'Format' => $fromType, + 'Id' => $itemId->getId(), + 'Mailbox' => $mailbox + ) + ) + )); + + $itemId->setId($result->getId()); + + return $itemId; + } } diff --git a/src/API/NTLMSoapClient.php b/src/API/NTLMSoapClient.php index d00eadc5..6aca94b7 100644 --- a/src/API/NTLMSoapClient.php +++ b/src/API/NTLMSoapClient.php @@ -84,6 +84,13 @@ class NTLMSoapClient extends SoapClient protected $auth; + protected $callsWithoutTimezone = array( + 'DeleteItem', + 'SyncFolderItems', + 'GetServerTimeZones', + 'ConvertId' + ); + /** * @TODO: Make this smarter. It should know and search what headers to remove on what actions * @@ -104,7 +111,7 @@ public function __call($name, $args) $this->ewsHeaders['impersonation'] ); - if ($name != "DeleteItem" && $name != "SyncFolderItems" && $name != "GetServerTimeZones") { + if (!in_array($name, $this->callsWithoutTimezone)) { $this->__default_headers[] = $this->ewsHeaders['timezone']; }