@@ -21,8 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Constructor. |
| 23 | 23 | */ |
| 24 | - public function __construct(GLogger $glogger) |
|
| 25 | - { |
|
| 24 | + public function __construct(GLogger $glogger) { |
|
| 26 | 25 | $this->logger = $glogger; |
| 27 | 26 | $this->syncstate = new GrommunioSyncState($glogger, SYNC_DB); |
| 28 | 27 | } |
@@ -35,8 +34,7 @@ discard block |
||
| 35 | 34 | * |
| 36 | 35 | * @return bool |
| 37 | 36 | */ |
| 38 | - public function Logon($user, $pass) |
|
| 39 | - { |
|
| 37 | + public function Logon($user, $pass) { |
|
| 40 | 38 | $this->logger->trace('%s / password', $user); |
| 41 | 39 | |
| 42 | 40 | $gDavVersion = 'grommunio-dav' . @constant('GDAV_VERSION'); |
@@ -59,8 +57,7 @@ discard block |
||
| 59 | 57 | * |
| 60 | 58 | * @return string |
| 61 | 59 | */ |
| 62 | - public function GetUser() |
|
| 63 | - { |
|
| 60 | + public function GetUser() { |
|
| 64 | 61 | $this->logger->trace($this->user); |
| 65 | 62 | |
| 66 | 63 | return $this->user; |
@@ -76,8 +73,7 @@ discard block |
||
| 76 | 73 | * |
| 77 | 74 | * @return string |
| 78 | 75 | */ |
| 79 | - public function CreateFolder($principalUri, $url, $class, $displayname) |
|
| 80 | - { |
|
| 76 | + public function CreateFolder($principalUri, $url, $class, $displayname) { |
|
| 81 | 77 | $props = mapi_getprops($this->GetStore($principalUri), [PR_IPM_SUBTREE_ENTRYID]); |
| 82 | 78 | $folder = mapi_msgstore_openentry($this->GetStore($principalUri), $props[PR_IPM_SUBTREE_ENTRYID]); |
| 83 | 79 | $newfolder = mapi_folder_createfolder($folder, $url, $displayname); |
@@ -93,8 +89,7 @@ discard block |
||
| 93 | 89 | * |
| 94 | 90 | * @return bool |
| 95 | 91 | */ |
| 96 | - public function DeleteFolder($id) |
|
| 97 | - { |
|
| 92 | + public function DeleteFolder($id) { |
|
| 98 | 93 | $folder = $this->GetMapiFolder($id); |
| 99 | 94 | if (!$folder) { |
| 100 | 95 | return false; |
@@ -116,8 +111,7 @@ discard block |
||
| 116 | 111 | * |
| 117 | 112 | * @return array |
| 118 | 113 | */ |
| 119 | - public function GetFolders($principalUri, $classes) |
|
| 120 | - { |
|
| 114 | + public function GetFolders($principalUri, $classes) { |
|
| 121 | 115 | $this->logger->trace("principal '%s', classes '%s'", $principalUri, $classes); |
| 122 | 116 | $folders = []; |
| 123 | 117 | |
@@ -179,8 +173,7 @@ discard block |
||
| 179 | 173 | * |
| 180 | 174 | * @return array |
| 181 | 175 | */ |
| 182 | - public function GetObjects($id, $fileExtension, $filters = []) |
|
| 183 | - { |
|
| 176 | + public function GetObjects($id, $fileExtension, $filters = []) { |
|
| 184 | 177 | $folder = $this->GetMapiFolder($id); |
| 185 | 178 | $properties = $this->GetCustomProperties($id); |
| 186 | 179 | $table = mapi_folder_getcontentstable($folder, MAPI_DEFERRED_ERRORS); |
@@ -251,8 +244,7 @@ discard block |
||
| 251 | 244 | * |
| 252 | 245 | * @return mapiresource |
| 253 | 246 | */ |
| 254 | - public function CreateObject($folderId, $folder, $objectId) |
|
| 255 | - { |
|
| 247 | + public function CreateObject($folderId, $folder, $objectId) { |
|
| 256 | 248 | $mapimessage = mapi_folder_createmessage($folder); |
| 257 | 249 | // we save the objectId in PROP_APPTTSREF so we find it by this id |
| 258 | 250 | $properties = $this->GetCustomProperties($folderId); |
@@ -270,8 +262,7 @@ discard block |
||
| 270 | 262 | * |
| 271 | 263 | * @return mapiresource |
| 272 | 264 | */ |
| 273 | - public function GetMapiFolder($folderid) |
|
| 274 | - { |
|
| 265 | + public function GetMapiFolder($folderid) { |
|
| 275 | 266 | $this->logger->trace('Id: %s', $folderid); |
| 276 | 267 | $arr = explode(':', $folderid); |
| 277 | 268 | $entryid = mapi_msgstore_entryidfromsourcekey($this->GetStore($arr[0]), hex2bin($arr[1])); |
@@ -284,8 +275,7 @@ discard block |
||
| 284 | 275 | * |
| 285 | 276 | * @return MAPIAddressbook |
| 286 | 277 | */ |
| 287 | - public function GetAddressBook() |
|
| 288 | - { |
|
| 278 | + public function GetAddressBook() { |
|
| 289 | 279 | // TODO should be a singleton |
| 290 | 280 | return mapi_openaddressbook($this->session); |
| 291 | 281 | } |
@@ -297,8 +287,7 @@ discard block |
||
| 297 | 287 | * |
| 298 | 288 | * @return false|MAPIStore if store not available |
| 299 | 289 | */ |
| 300 | - public function OpenMapiStore($username = null) |
|
| 301 | - { |
|
| 290 | + public function OpenMapiStore($username = null) { |
|
| 302 | 291 | $msgstorestable = mapi_getmsgstorestable($this->session); |
| 303 | 292 | $msgstores = mapi_table_queryallrows($msgstorestable, [PR_DEFAULT_STORE, PR_ENTRYID, PR_MDB_PROVIDER]); |
| 304 | 293 | |
@@ -338,8 +327,7 @@ discard block |
||
| 338 | 327 | * |
| 339 | 328 | * @return false|MAPIStore if the store is not available |
| 340 | 329 | */ |
| 341 | - public function GetStore($storename) |
|
| 342 | - { |
|
| 330 | + public function GetStore($storename) { |
|
| 343 | 331 | if ($storename == null) { |
| 344 | 332 | $storename = $this->GetUser(); |
| 345 | 333 | } |
@@ -370,8 +358,7 @@ discard block |
||
| 370 | 358 | * |
| 371 | 359 | * @return false|\grommunio\DAV\MAPIStore on error |
| 372 | 360 | */ |
| 373 | - public function GetStoreById($id) |
|
| 374 | - { |
|
| 361 | + public function GetStoreById($id) { |
|
| 375 | 362 | $arr = explode(':', $id); |
| 376 | 363 | |
| 377 | 364 | return $this->GetStore($arr[0]); |
@@ -382,8 +369,7 @@ discard block |
||
| 382 | 369 | * |
| 383 | 370 | * @return MAPISession |
| 384 | 371 | */ |
| 385 | - public function GetSession() |
|
| 386 | - { |
|
| 372 | + public function GetSession() { |
|
| 387 | 373 | return $this->session; |
| 388 | 374 | } |
| 389 | 375 | |
@@ -398,8 +384,7 @@ discard block |
||
| 398 | 384 | * |
| 399 | 385 | * @return string |
| 400 | 386 | */ |
| 401 | - public function GetIdOfMapiMessage($folderId, $mapimessage) |
|
| 402 | - { |
|
| 387 | + public function GetIdOfMapiMessage($folderId, $mapimessage) { |
|
| 403 | 388 | $this->logger->trace("Finding ID of %s", $mapimessage); |
| 404 | 389 | $properties = $this->GetCustomProperties($folderId); |
| 405 | 390 | |
@@ -433,8 +418,7 @@ discard block |
||
| 433 | 418 | * |
| 434 | 419 | * @return null|mapiresource |
| 435 | 420 | */ |
| 436 | - public function GetMapiMessageForId($folderId, $objectUri, $mapifolder = null, $extension = null) |
|
| 437 | - { |
|
| 421 | + public function GetMapiMessageForId($folderId, $objectUri, $mapifolder = null, $extension = null) { |
|
| 438 | 422 | $this->logger->trace("Searching for '%s' in '%s' (%s) (%s)", $objectUri, $folderId, $mapifolder, $extension); |
| 439 | 423 | |
| 440 | 424 | if (!$mapifolder) { |
@@ -530,8 +514,7 @@ discard block |
||
| 530 | 514 | * |
| 531 | 515 | * @return string |
| 532 | 516 | */ |
| 533 | - public function GetObjectIdFromObjectUri($objectUri, $extension) |
|
| 534 | - { |
|
| 517 | + public function GetObjectIdFromObjectUri($objectUri, $extension) { |
|
| 535 | 518 | if (!$extension) { |
| 536 | 519 | return $objectUri; |
| 537 | 520 | } |
@@ -550,8 +533,7 @@ discard block |
||
| 550 | 533 | * |
| 551 | 534 | * @return bool installed version is superior to the checked string |
| 552 | 535 | */ |
| 553 | - protected function checkMapiExtVersion($version = "") |
|
| 554 | - { |
|
| 536 | + protected function checkMapiExtVersion($version = "") { |
|
| 555 | 537 | if (!extension_loaded("mapi")) { |
| 556 | 538 | return false; |
| 557 | 539 | } |
@@ -575,8 +557,7 @@ discard block |
||
| 575 | 557 | * |
| 576 | 558 | * @return mixed |
| 577 | 559 | */ |
| 578 | - protected function GetCustomProperties($id) |
|
| 579 | - { |
|
| 560 | + protected function GetCustomProperties($id) { |
|
| 580 | 561 | if (!isset($this->customprops[$id])) { |
| 581 | 562 | $this->logger->trace("Fetching properties id:%s", $id); |
| 582 | 563 | $store = $this->GetStoreById($id); |
@@ -599,8 +580,7 @@ discard block |
||
| 599 | 580 | * @return array |
| 600 | 581 | */ |
| 601 | 582 | // TODO getting named properties |
| 602 | - public function GetCalendarRestriction($store, $start, $end) |
|
| 603 | - { |
|
| 583 | + public function GetCalendarRestriction($store, $start, $end) { |
|
| 604 | 584 | $props = MapiProps::GetAppointmentProperties(); |
| 605 | 585 | $props = getPropIdsFromStrings($store, $props); |
| 606 | 586 | |
@@ -692,8 +672,7 @@ discard block |
||
| 692 | 672 | * |
| 693 | 673 | * @return array |
| 694 | 674 | */ |
| 695 | - public function Sync($folderId, $syncToken, $fileExtension, $limit = null) |
|
| 696 | - { |
|
| 675 | + public function Sync($folderId, $syncToken, $fileExtension, $limit = null) { |
|
| 697 | 676 | $arr = explode(':', $folderId); |
| 698 | 677 | $phpwrapper = new PHPWrapper($this->GetStoreById($folderId), $this->logger, $this->GetCustomProperties($folderId), $fileExtension, $this->syncstate, $arr[1]); |
| 699 | 678 | $mapiimporter = mapi_wrap_importcontentschanges($phpwrapper); |
@@ -21,8 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Constructor. |
| 23 | 23 | */ |
| 24 | - public function __construct(GrommunioDavBackend $gDavBackend, GLogger $glogger) |
|
| 25 | - { |
|
| 24 | + public function __construct(GrommunioDavBackend $gDavBackend, GLogger $glogger) { |
|
| 26 | 25 | $this->gDavBackend = $gDavBackend; |
| 27 | 26 | $this->logger = $glogger; |
| 28 | 27 | } |
@@ -45,8 +44,7 @@ discard block |
||
| 45 | 44 | * |
| 46 | 45 | * @return array |
| 47 | 46 | */ |
| 48 | - public function getAddressBooksForUser($principalUri) |
|
| 49 | - { |
|
| 47 | + public function getAddressBooksForUser($principalUri) { |
|
| 50 | 48 | $this->logger->trace("principalUri: %s", $principalUri); |
| 51 | 49 | |
| 52 | 50 | return $this->gDavBackend->GetFolders($principalUri, static::CONTAINER_CLASSES); |
@@ -66,8 +64,7 @@ discard block |
||
| 66 | 64 | * |
| 67 | 65 | * @param string $addressBookId |
| 68 | 66 | */ |
| 69 | - public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) |
|
| 70 | - { |
|
| 67 | + public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { |
|
| 71 | 68 | // TODO is our logger able to log this object? It probably needs to be adapted. |
| 72 | 69 | $this->logger->trace("addressBookId: %s - proppatch: %s", $addressBookId, $propPatch); |
| 73 | 70 | } |
@@ -83,8 +80,7 @@ discard block |
||
| 83 | 80 | * |
| 84 | 81 | * @return mixed |
| 85 | 82 | */ |
| 86 | - public function createAddressBook($principalUri, $url, array $properties) |
|
| 87 | - { |
|
| 83 | + public function createAddressBook($principalUri, $url, array $properties) { |
|
| 88 | 84 | $this->logger->trace("principalUri: %s - url: %s - properties: %s", $principalUri, $url, $properties); |
| 89 | 85 | // TODO Add displayname |
| 90 | 86 | return $this->gDavBackend->CreateFolder($principalUri, $url, static::CONTAINER_CLASS, ""); |
@@ -95,8 +91,7 @@ discard block |
||
| 95 | 91 | * |
| 96 | 92 | * @param mixed $addressBookId |
| 97 | 93 | */ |
| 98 | - public function deleteAddressBook($addressBookId) |
|
| 99 | - { |
|
| 94 | + public function deleteAddressBook($addressBookId) { |
|
| 100 | 95 | $this->logger->trace("addressBookId: %s", $addressBookId); |
| 101 | 96 | $success = $this->gDavBackend->DeleteFolder($addressBookId); |
| 102 | 97 | // TODO evaluate $success |
@@ -122,8 +117,7 @@ discard block |
||
| 122 | 117 | * |
| 123 | 118 | * @return array |
| 124 | 119 | */ |
| 125 | - public function getCards($addressbookId) |
|
| 126 | - { |
|
| 120 | + public function getCards($addressbookId) { |
|
| 127 | 121 | $result = $this->gDavBackend->GetObjects($addressbookId, static::FILE_EXTENSION); |
| 128 | 122 | $this->logger->trace("addressbookId: %s found %d objects", $addressbookId, count($result)); |
| 129 | 123 | |
@@ -144,8 +138,7 @@ discard block |
||
| 144 | 138 | * |
| 145 | 139 | * @return array |
| 146 | 140 | */ |
| 147 | - public function getCard($addressBookId, $cardUri, $mapifolder = null) |
|
| 148 | - { |
|
| 141 | + public function getCard($addressBookId, $cardUri, $mapifolder = null) { |
|
| 149 | 142 | $this->logger->trace("addressBookId: %s - cardUri: %s", $addressBookId, $cardUri); |
| 150 | 143 | |
| 151 | 144 | if (!$mapifolder) { |
@@ -208,8 +201,7 @@ discard block |
||
| 208 | 201 | * |
| 209 | 202 | * @return null|string |
| 210 | 203 | */ |
| 211 | - public function createCard($addressBookId, $cardUri, $cardData) |
|
| 212 | - { |
|
| 204 | + public function createCard($addressBookId, $cardUri, $cardData) { |
|
| 213 | 205 | $this->logger->trace("addressBookId: %s - cardUri: %s - cardData: %s", $addressBookId, $cardUri, $cardData); |
| 214 | 206 | $objectId = $this->gDavBackend->GetObjectIdFromObjectUri($cardUri, static::FILE_EXTENSION); |
| 215 | 207 | $folder = $this->gDavBackend->GetMapiFolder($addressBookId); |
@@ -248,8 +240,7 @@ discard block |
||
| 248 | 240 | * |
| 249 | 241 | * @return null|string |
| 250 | 242 | */ |
| 251 | - public function updateCard($addressBookId, $cardUri, $cardData) |
|
| 252 | - { |
|
| 243 | + public function updateCard($addressBookId, $cardUri, $cardData) { |
|
| 253 | 244 | $this->logger->trace("addressBookId: %s - cardUri: %s - cardData: %s", $addressBookId, $cardUri, $cardData); |
| 254 | 245 | |
| 255 | 246 | $mapimessage = $this->gDavBackend->GetMapiMessageForId($addressBookId, $cardUri, null, static::FILE_EXTENSION); |
@@ -270,8 +261,7 @@ discard block |
||
| 270 | 261 | * |
| 271 | 262 | * @return null|string |
| 272 | 263 | */ |
| 273 | - private function setData($addressBookId, $mapimessage, $vcf) |
|
| 274 | - { |
|
| 264 | + private function setData($addressBookId, $mapimessage, $vcf) { |
|
| 275 | 265 | $this->logger->trace("mapimessage: %s - vcf: %s", $mapimessage, $vcf); |
| 276 | 266 | $store = $this->gDavBackend->GetStoreById($addressBookId); |
| 277 | 267 | $session = $this->gDavBackend->GetSession(); |
@@ -296,8 +286,7 @@ discard block |
||
| 296 | 286 | * |
| 297 | 287 | * @return bool |
| 298 | 288 | */ |
| 299 | - public function deleteCard($addressBookId, $cardUri) |
|
| 300 | - { |
|
| 289 | + public function deleteCard($addressBookId, $cardUri) { |
|
| 301 | 290 | $this->logger->trace("addressBookId: %s - cardUri: %s", $addressBookId, $cardUri); |
| 302 | 291 | $mapifolder = $this->gDavBackend->GetMapiFolder($addressBookId); |
| 303 | 292 | $objectId = $this->gDavBackend->GetObjectIdFromObjectUri($cardUri, static::FILE_EXTENSION); |
@@ -366,8 +355,7 @@ discard block |
||
| 366 | 355 | * |
| 367 | 356 | * @return array |
| 368 | 357 | */ |
| 369 | - public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) |
|
| 370 | - { |
|
| 358 | + public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { |
|
| 371 | 359 | $this->logger->trace("addressBookId: %s - syncToken: %s - syncLevel: %d - limit: %d", $addressBookId, $syncToken, $syncLevel, $limit); |
| 372 | 360 | |
| 373 | 361 | return $this->gDavBackend->Sync($addressBookId, $syncToken, static::FILE_EXTENSION, $limit); |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @see PHPUnit_Framework_TestCase::setUp() |
| 27 | 27 | */ |
| 28 | - protected function setUp() |
|
| 29 | - { |
|
| 28 | + protected function setUp() { |
|
| 30 | 29 | $gloggerMock = $this->getMockBuilder(GLogger::class)->disableOriginalConstructor()->getMock(); |
| 31 | 30 | $this->gDavBackendMock = $this->getMockBuilder(GrommunioDavBackend::class)->disableOriginalConstructor()->getMock(); |
| 32 | 31 | $this->kCardDavBackend = new GrommunioCardDavBackend($this->gDavBackendMock, $gloggerMock); |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | * |
| 38 | 37 | * @see PHPUnit_Framework_TestCase::tearDown() |
| 39 | 38 | */ |
| 40 | - protected function tearDown() |
|
| 41 | - { |
|
| 39 | + protected function tearDown() { |
|
| 42 | 40 | $this->kCardDavBackend = null; |
| 43 | 41 | $this->gDavBackendMock = null; |
| 44 | 42 | } |
@@ -46,8 +44,7 @@ discard block |
||
| 46 | 44 | /** |
| 47 | 45 | * Tests if the constructor is created without errors. |
| 48 | 46 | */ |
| 49 | - public function testConstruct() |
|
| 50 | - { |
|
| 47 | + public function testConstruct() { |
|
| 51 | 48 | $this->assertTrue(is_object($this->kCardDavBackend)); |
| 52 | 49 | } |
| 53 | 50 | } |
@@ -23,8 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @see PHPUnit_Framework_TestCase::setUp() |
| 25 | 25 | */ |
| 26 | - protected function setUp() |
|
| 27 | - { |
|
| 26 | + protected function setUp() { |
|
| 28 | 27 | $gloggerMock = $this->getMockBuilder(GLogger::class)->disableOriginalConstructor()->getMock(); |
| 29 | 28 | $this->gDavBackend = new GrommunioDavBackend($gloggerMock); |
| 30 | 29 | } |
@@ -34,16 +33,14 @@ discard block |
||
| 34 | 33 | * |
| 35 | 34 | * @see PHPUnit_Framework_TestCase::tearDown() |
| 36 | 35 | */ |
| 37 | - protected function tearDown() |
|
| 38 | - { |
|
| 36 | + protected function tearDown() { |
|
| 39 | 37 | $this->gDavBackend = null; |
| 40 | 38 | } |
| 41 | 39 | |
| 42 | 40 | /** |
| 43 | 41 | * Tests if the constructor is created without errors. |
| 44 | 42 | */ |
| 45 | - public function testConstruct() |
|
| 46 | - { |
|
| 43 | + public function testConstruct() { |
|
| 47 | 44 | $this->assertTrue(is_object($this->gDavBackend)); |
| 48 | 45 | } |
| 49 | 46 | |
@@ -56,8 +53,7 @@ discard block |
||
| 56 | 53 | * |
| 57 | 54 | * @dataProvider ObjectUriProvider |
| 58 | 55 | */ |
| 59 | - public function testGetObjectIdFromObjectUri($objectUri, $extension, $expected) |
|
| 60 | - { |
|
| 56 | + public function testGetObjectIdFromObjectUri($objectUri, $extension, $expected) { |
|
| 61 | 57 | $this->assertEquals($expected, $this->gDavBackend->GetObjectIdFromObjectUri($objectUri, $extension)); |
| 62 | 58 | } |
| 63 | 59 | |
@@ -66,8 +62,7 @@ discard block |
||
| 66 | 62 | * |
| 67 | 63 | * @return array |
| 68 | 64 | */ |
| 69 | - public function ObjectUriProvider() |
|
| 70 | - { |
|
| 65 | + public function ObjectUriProvider() { |
|
| 71 | 66 | return [ |
| 72 | 67 | ['1234.ics', '.ics', '1234'], // ok, cut .ics |
| 73 | 68 | ['5678AF.vcf', '.vcf', '5678AF'], // ok, cut .vcf |