Passed
Branch master (ff9d34)
by Mike
09:14
created
lib/grommunio/listfolders.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 define('SSLCERT_FILE', null);
14 14
 define('SSLCERT_PASS', null);
15 15
 
16
-$supported_classes = array (
16
+$supported_classes = array(
17 17
     "IPF.Note"          => "SYNC_FOLDER_TYPE_USER_MAIL",
18 18
     "IPF.Task"          => "SYNC_FOLDER_TYPE_USER_TASK",
19 19
     "IPF.Appointment"   => "SYNC_FOLDER_TYPE_USER_APPOINTMENT",
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
     }
81 81
 }
82 82
 
83
-function listfolders_zarafa_admin_setup ($mapi, $user, $pass, $sslcert_file, $sslcert_pass) {
83
+function listfolders_zarafa_admin_setup($mapi, $user, $pass, $sslcert_file, $sslcert_pass) {
84 84
     $session = @mapi_logon_zarafa($user, $pass, $mapi, $sslcert_file, $sslcert_pass, 0, 'script', 'script');
85 85
 
86 86
     if (!$session) {
87
-        echo "User '$user' could not login. The script will exit. Errorcode: 0x". sprintf("%x", mapi_last_hresult()) . "\n";
87
+        echo "User '$user' could not login. The script will exit. Errorcode: 0x".sprintf("%x", mapi_last_hresult())."\n";
88 88
         exit(1);
89 89
     }
90 90
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             }
99 99
     }
100 100
     $zarafauserinfo['admin'] = 1;
101
-    $admin = (isset($zarafauserinfo['admin']) && $zarafauserinfo['admin'])?true:false;
101
+    $admin = (isset($zarafauserinfo['admin']) && $zarafauserinfo['admin']) ?true:false;
102 102
 
103 103
     if (!$stores || !$storeslist || !$adminStore || !$admin) {
104 104
         echo "There was error trying to log in as admin or retrieving admin info. The script will exit.\n";
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 }
110 110
 
111 111
 
112
-function listfolders_getlist ($adminStore, $session, $user) {
112
+function listfolders_getlist($adminStore, $session, $user) {
113 113
     global $supported_classes;
114 114
 
115 115
     if (strtoupper($user) == 'SYSTEM') {
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
         $storestables = @mapi_getmsgstorestable($session);
118 118
         $result = @mapi_last_hresult();
119 119
 
120
-        if ($result == NOERROR){
120
+        if ($result == NOERROR) {
121 121
             $rows = @mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_MDB_PROVIDER));
122 122
 
123
-            foreach($rows as $row) {
123
+            foreach ($rows as $row) {
124 124
                 if (isset($row[PR_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
125 125
                     if (!isset($row[PR_ENTRYID])) {
126 126
                         echo "Public folder are not available.\nIf this is a multi-tenancy system, use -u and -p and login with an admin user of the company.\nThe script will exit.\n";
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
     $hresult = mapi_last_hresult();
140 140
 
141 141
     // Cache the store for later use
142
-    if($hresult != NOERROR) {
142
+    if ($hresult != NOERROR) {
143 143
         echo "Could not open store for '$user'. The script will exit.\n";
144 144
         exit (1);
145 145
     }
146 146
 
147 147
     if (strtoupper($user) != 'SYSTEM') {
148 148
         $inbox = mapi_msgstore_getreceivefolder($userStore);
149
-        if(mapi_last_hresult() != NOERROR) {
149
+        if (mapi_last_hresult() != NOERROR) {
150 150
             printf("Could not open inbox for %s (0x%08X). The script will exit.\n", $user, mapi_last_hresult());
151 151
             exit (1);
152 152
         }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     $h_table = @mapi_folder_gethierarchytable($root, CONVENIENT_DEPTH);
159 159
     $subfolders = @mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_CONTAINER_CLASS, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_FOLDER_TYPE, PR_ATTR_HIDDEN));
160 160
 
161
-    echo "Available folders in store '$user':\n" . str_repeat("-", 50) . "\n";
162
-    foreach($subfolders as $folder) {
161
+    echo "Available folders in store '$user':\n".str_repeat("-", 50)."\n";
162
+    foreach ($subfolders as $folder) {
163 163
         // do not display hidden and search folders
164 164
         if ((isset($folder[PR_ATTR_HIDDEN]) && $folder[PR_ATTR_HIDDEN]) ||
165 165
             (isset($folder[PR_FOLDER_TYPE]) && $folder[PR_FOLDER_TYPE] == FOLDER_SEARCH)) {
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
         }
178 178
 
179 179
         if (isset($folder[PR_CONTAINER_CLASS]) && array_key_exists($folder[PR_CONTAINER_CLASS], $supported_classes)) {
180
-            echo "Folder name:\t". $folder[PR_DISPLAY_NAME] . "\n";
181
-            echo "Folder ID:\t". bin2hex($folder[PR_SOURCE_KEY]) . "\n";
182
-            echo "Type:\t\t". $supported_classes[$folder[PR_CONTAINER_CLASS]] . "\n";
180
+            echo "Folder name:\t".$folder[PR_DISPLAY_NAME]."\n";
181
+            echo "Folder ID:\t".bin2hex($folder[PR_SOURCE_KEY])."\n";
182
+            echo "Type:\t\t".$supported_classes[$folder[PR_CONTAINER_CLASS]]."\n";
183 183
             echo "\n";
184 184
         }
185 185
     }
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
         return ($version <= $vs[1]);
193 193
     }
194 194
 
195
-    if (extension_loaded("mapi")){
196
-        if (version_compare(phpversion("mapi"), $version) == -1){
195
+    if (extension_loaded("mapi")) {
196
+        if (version_compare(phpversion("mapi"), $version) == -1) {
197 197
             return false;
198 198
         }
199 199
     }
Please login to merge, or discard this patch.
lib/grommunio/mapistreamwrapper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $len = ($this->position + $len > $this->streamlength) ? ($this->streamlength - $this->position) : $len;
70 70
 
71 71
         // read 4 additional bytes from the stream so we can always truncate correctly
72
-        if ($this->toTruncate && $this->position+$len >= $this->streamlength) {
72
+        if ($this->toTruncate && $this->position + $len >= $this->streamlength) {
73 73
             $len += 4;
74 74
         }
75 75
         if ($this->mapistream) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @return boolean
97 97
      */
98 98
     public function stream_seek($offset, $whence = SEEK_SET) {
99
-        switch($whence) {
99
+        switch ($whence) {
100 100
             case SEEK_SET:
101 101
                 $mapiWhence = STREAM_SEEK_SET;
102 102
                 break;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
      static public function Open($mapistream, $truncatehtmlsafe = false) {
172 172
         $context = stream_context_create(array(self::PROTOCOL => array('stream' => &$mapistream, 'truncatehtmlsafe' => $truncatehtmlsafe)));
173
-        return fopen(self::PROTOCOL . "://",'r', false, $context);
173
+        return fopen(self::PROTOCOL."://", 'r', false, $context);
174 174
     }
175 175
 }
176 176
 
Please login to merge, or discard this patch.
lib/grommunio/importer.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             $folderidForBackendId = ZPush::GetDeviceManager()->GetFolderIdForBackendId($this->folderidHex);
62 62
             // Only append backend id if the mapping backendid<->folderid is available.
63 63
             if ($folderidForBackendId != $this->folderidHex) {
64
-                $this->prefix = $folderidForBackendId . ':';
64
+                $this->prefix = $folderidForBackendId.':';
65 65
             }
66 66
         }
67 67
         else {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         if ($entryid)
79 79
             $folder = mapi_msgstore_openentry($store, $entryid);
80 80
 
81
-        if(!$folder) {
81
+        if (!$folder) {
82 82
             $this->importer = false;
83 83
 
84 84
             // We throw an general error SYNC_FSSTATUS_CODEUNKNOWN (12) which is also SYNC_STATUS_FOLDERHIERARCHYCHANGED (12)
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
         $this->mapiprovider = new MAPIProvider($this->session, $this->store);
90 90
 
91 91
         if ($folderid) {
92
-            $this->importer = mapi_openproperty($folder, PR_COLLECTOR, IID_IExchangeImportContentsChanges, 0 , 0);
92
+            $this->importer = mapi_openproperty($folder, PR_COLLECTOR, IID_IExchangeImportContentsChanges, 0, 0);
93 93
         }
94 94
         else {
95
-            $this->importer = mapi_openproperty($folder, PR_COLLECTOR, IID_IExchangeImportHierarchyChanges, 0 , 0);
95
+            $this->importer = mapi_openproperty($folder, PR_COLLECTOR, IID_IExchangeImportHierarchyChanges, 0, 0);
96 96
         }
97 97
     }
98 98
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
         // Put the state information in a stream that can be used by ICS
117 117
         $stream = mapi_stream_create();
118
-        if(strlen($state) == 0)
118
+        if (strlen($state) == 0)
119 119
             $state = hex2bin("0000000000000000");
120 120
 
121 121
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS->Config(): initializing importer with state: 0x%s", bin2hex($state)));
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function ConfigContentParameters($contentparameters) {
149 149
         $filtertype = $contentparameters->GetFilterType();
150
-        switch($contentparameters->GetContentClass()) {
150
+        switch ($contentparameters->GetContentClass()) {
151 151
             case "Email":
152 152
                 $this->cutoffdate = ($filtertype) ? Utils::GetCutOffDate($filtertype) : false;
153 153
                 break;
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public function GetState() {
174 174
         $error = false;
175
-        if(!isset($this->statestream) || $this->importer === false)
175
+        if (!isset($this->statestream) || $this->importer === false)
176 176
             $error = true;
177 177
 
178 178
         if ($error === false && $this->folderid !== false && function_exists("mapi_importcontentschanges_updatestate"))
179
-            if(mapi_importcontentschanges_updatestate($this->importer, $this->statestream) != true)
179
+            if (mapi_importcontentschanges_updatestate($this->importer, $this->statestream) != true)
180 180
                 $error = true;
181 181
 
182 182
         if ($error == true)
183
-            throw new StatusException(sprintf("ImportChangesICS->GetState(): Error, state not available or unable to update: 0x%X", mapi_last_hresult()), (($this->folderid)?SYNC_STATUS_FOLDERHIERARCHYCHANGED:SYNC_FSSTATUS_CODEUNKNOWN), null, LOGLEVEL_WARN);
183
+            throw new StatusException(sprintf("ImportChangesICS->GetState(): Error, state not available or unable to update: 0x%X", mapi_last_hresult()), (($this->folderid) ?SYNC_STATUS_FOLDERHIERARCHYCHANGED:SYNC_FSSTATUS_CODEUNKNOWN), null, LOGLEVEL_WARN);
184 184
 
185 185
         mapi_stream_seek($this->statestream, 0, STREAM_SEEK_SET);
186 186
 
187 187
         $state = "";
188
-        while(true) {
188
+        while (true) {
189 189
             $data = mapi_stream_read($this->statestream, 4096);
190
-            if(strlen($data))
190
+            if (strlen($data))
191 191
                 $state .= $data;
192 192
             else
193 193
                 break;
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 
218 218
         // open the existing object
219 219
         $entryid = mapi_msgstore_entryidfromsourcekey($this->store, $this->folderid, hex2bin($messageid));
220
-        if(!$entryid) {
220
+        if (!$entryid) {
221 221
             ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->isModificationAllowed('%s'): Error, unable to resolve message id: 0x%X", $messageid, mapi_last_hresult()));
222 222
             return false;
223 223
         }
224 224
 
225 225
         $mapimessage = mapi_msgstore_openentry($this->store, $entryid);
226
-        if(!$mapimessage) {
226
+        if (!$mapimessage) {
227 227
             ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->isModificationAllowed('%s'): Error, unable to open entry id: 0x%X", $messageid, mapi_last_hresult()));
228 228
             return false;
229 229
         }
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
         // check the sync interval
232 232
         if ($this->cutoffdate !== false) {
233 233
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS->isModificationAllowed('%s'): cut off date is: %s", $messageid, $this->cutoffdate));
234
-            if (  ($this->contentClass == "Email"    && !MAPIUtils::IsInEmailSyncInterval($this->store, $mapimessage, $this->cutoffdate)) ||
235
-                  ($this->contentClass == "Calendar" && !MAPIUtils::IsInCalendarSyncInterval($this->store, $mapimessage, $this->cutoffdate)) ) {
234
+            if (($this->contentClass == "Email" && !MAPIUtils::IsInEmailSyncInterval($this->store, $mapimessage, $this->cutoffdate)) ||
235
+                  ($this->contentClass == "Calendar" && !MAPIUtils::IsInCalendarSyncInterval($this->store, $mapimessage, $this->cutoffdate))) {
236 236
 
237 237
                 ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->isModificationAllowed('%s'): Message in %s is outside the sync interval. Data not saved.", $messageid, $this->contentClass));
238 238
                 return false;
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
             $started = time();
312 312
             $exported = 0;
313 313
             try {
314
-                while(is_array($exporter->Synchronize())) {
314
+                while (is_array($exporter->Synchronize())) {
315 315
                     $exported++;
316 316
 
317 317
                     // stop if this takes more than 15 seconds and there are more than 5 changes still to be exported
318 318
                     // within 20 seconds this should be finished or it will not be performed
319
-                    if ((time() - $started) > 15 && ($potConflicts - $exported) > 5 ) {
320
-                        ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->lazyLoadConflicts(): conflict detection cancelled as operation is too slow. In %d seconds only %d from %d changes were processed.",(time() - $started), $exported, $potConflicts));
319
+                    if ((time() - $started) > 15 && ($potConflicts - $exported) > 5) {
320
+                        ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->lazyLoadConflicts(): conflict detection cancelled as operation is too slow. In %d seconds only %d from %d changes were processed.", (time() - $started), $exported, $potConflicts));
321 321
                         $this->conflictsLoaded = true;
322 322
                         return;
323 323
                     }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
             }
326 326
             // something really bad happened while exporting changes
327 327
             catch (StatusException $stex) {
328
-                ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->lazyLoadConflicts(): got StatusException code %d while exporting changes. Ignore and mark conflicts as loaded.",$stex->getCode()));
328
+                ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->lazyLoadConflicts(): got StatusException code %d while exporting changes. Ignore and mark conflicts as loaded.", $stex->getCode()));
329 329
             }
330 330
             $this->conflictsLoaded = true;
331 331
         }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
         $props[PR_PARENT_SOURCE_KEY] = $this->folderid;
348 348
 
349 349
         // set the PR_SOURCE_KEY if available or mark it as new message
350
-        if($id) {
350
+        if ($id) {
351 351
             list(, $sk) = Utils::SplitMessageId($id);
352 352
             $props[PR_SOURCE_KEY] = hex2bin($sk);
353 353
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
             // check for conflicts
359 359
             $this->lazyLoadConflicts();
360
-            if($this->memChanges->IsChanged($id)) {
360
+            if ($this->memChanges->IsChanged($id)) {
361 361
                 if ($this->flags & SYNC_CONFLICT_OVERWRITE_PIM) {
362 362
                     // in these cases the status SYNC_STATUS_CONFLICTCLIENTSERVEROBJECT should be returned, so the mobile client can inform the end user
363 363
                     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);
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                 else
367 367
                     ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from Server will be dropped! PIM overwrites server.", $id, get_class($message)));
368 368
             }
369
-            if($this->memChanges->IsDeleted($id)) {
369
+            if ($this->memChanges->IsDeleted($id)) {
370 370
                 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)));
371 371
                 return false;
372 372
             }
@@ -374,16 +374,16 @@  discard block
 block discarded – undo
374 374
         else
375 375
             $flags = SYNC_NEW_MESSAGE;
376 376
 
377
-        if(mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) {
377
+        if (mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) {
378 378
             $this->mapiprovider->SetMessage($mapimessage, $message);
379 379
             mapi_savechanges($mapimessage);
380 380
 
381 381
             if (mapi_last_hresult())
382 382
                 throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error, mapi_savechanges() failed: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_SYNCCANNOTBECOMPLETED);
383 383
 
384
-            $sourcekeyprops = mapi_getprops($mapimessage, array (PR_SOURCE_KEY));
384
+            $sourcekeyprops = mapi_getprops($mapimessage, array(PR_SOURCE_KEY));
385 385
 
386
-            return $this->prefix . bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
386
+            return $this->prefix.bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
387 387
         }
388 388
         else
389 389
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error updating object: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
@@ -407,16 +407,16 @@  discard block
 block discarded – undo
407 407
 
408 408
         // check for conflicts
409 409
         $this->lazyLoadConflicts();
410
-        if($this->memChanges->IsChanged($id)) {
410
+        if ($this->memChanges->IsChanged($id)) {
411 411
             ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageDeletion('%s'): Conflict detected. Data from Server will be dropped! PIM deleted object.", $id));
412 412
         }
413
-        elseif($this->memChanges->IsDeleted($id)) {
413
+        elseif ($this->memChanges->IsDeleted($id)) {
414 414
             ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageDeletion('%s'): Conflict detected. Data is already deleted. Request will be ignored.", $id));
415 415
             return true;
416 416
         }
417 417
 
418 418
         // do a 'soft' delete so people can un-delete if necessary
419
-        if(mapi_importcontentschanges_importmessagedeletion($this->importer, 1, array(hex2bin($sk))))
419
+        if (mapi_importcontentschanges_importmessagedeletion($this->importer, 1, array(hex2bin($sk))))
420 420
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageDeletion('%s'): Error updating object: 0x%X", $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
421 421
 
422 422
         return true;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      * @throws StatusException
436 436
      */
437 437
     public function ImportMessageReadFlag($id, $flags, $categories = array()) {
438
-        list($fsk,$sk) = Utils::SplitMessageId($id);
438
+        list($fsk, $sk) = Utils::SplitMessageId($id);
439 439
 
440 440
         // if $fsk is set, we convert it into a backend id.
441 441
         if ($fsk) {
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
             }
462 462
              */
463 463
 
464
-            $readstate = array ( "sourcekey" => hex2bin($sk), "flags" => $flags);
464
+            $readstate = array("sourcekey" => hex2bin($sk), "flags" => $flags);
465 465
 
466
-            if(!mapi_importcontentschanges_importperuserreadstatechange($this->importer, array($readstate) ))
466
+            if (!mapi_importcontentschanges_importperuserreadstatechange($this->importer, array($readstate)))
467 467
                 throw new StatusException(sprintf("ImportChangesICS->ImportMessageReadFlag('%s','%d'): Error setting read state: 0x%X", $id, $flags, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
468 468
         }
469 469
         // yeah OL sucks - ZP-779
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
      */
503 503
     public function ImportMessageMove($id, $newfolder) {
504 504
         list(,$sk) = Utils::SplitMessageId($id);
505
-        if (strtolower($newfolder) == strtolower(bin2hex($this->folderid)) )
505
+        if (strtolower($newfolder) == strtolower(bin2hex($this->folderid)))
506 506
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, source and destination are equal", $id, $newfolder), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST);
507 507
 
508 508
         // Get the entryid of the message we're moving
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             $srcmessage = mapi_msgstore_openentry($this->store, $entryid);
515 515
         }
516 516
 
517
-        if(!$entryid || !$srcmessage) {
517
+        if (!$entryid || !$srcmessage) {
518 518
             $code = SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID;
519 519
             $mapiLastHresult = mapi_last_hresult();
520 520
             // if we move to the trash and the source message is not found, we can also just tell the mobile that we successfully moved to avoid errors (ZP-624)
@@ -535,11 +535,11 @@  discard block
 block discarded – undo
535 535
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to open store of destination folder", $sk, $newfolder), SYNC_MOVEITEMSSTATUS_INVALIDDESTID);
536 536
 
537 537
         $dstentryid = mapi_msgstore_entryidfromsourcekey($dststore, hex2bin($newfolder));
538
-        if(!$dstentryid)
538
+        if (!$dstentryid)
539 539
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to resolve destination folder", $sk, $newfolder), SYNC_MOVEITEMSSTATUS_INVALIDDESTID);
540 540
 
541 541
         $dstfolder = mapi_msgstore_openentry($dststore, $dstentryid);
542
-        if(!$dstfolder)
542
+        if (!$dstfolder)
543 543
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to open destination folder", $sk, $newfolder), SYNC_MOVEITEMSSTATUS_INVALIDDESTID);
544 544
 
545 545
         $newmessage = mapi_folder_createmessage($dstfolder);
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, copy to destination message failed: 0x%X", $sk, $newfolder, mapi_last_hresult()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE);
553 553
 
554 554
         $srcfolderentryid = mapi_msgstore_entryidfromsourcekey($this->store, $this->folderid);
555
-        if(!$srcfolderentryid)
555
+        if (!$srcfolderentryid)
556 556
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to resolve source folder", $sk, $newfolder), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID);
557 557
 
558 558
         $srcfolder = mapi_msgstore_openentry($this->store, $srcfolderentryid);
@@ -568,15 +568,15 @@  discard block
 block discarded – undo
568 568
         if (!mapi_folder_deletemessages($srcfolder, array($entryid)))
569 569
             throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, delete of source message failed: 0x%X. Possible duplicates.", $sk, $newfolder, mapi_last_hresult()), SYNC_MOVEITEMSSTATUS_SOURCEORDESTLOCKED);
570 570
 
571
-        $sourcekeyprops = mapi_getprops($newmessage, array (PR_SOURCE_KEY));
571
+        $sourcekeyprops = mapi_getprops($newmessage, array(PR_SOURCE_KEY));
572 572
         if (isset($sourcekeyprops[PR_SOURCE_KEY]) && $sourcekeyprops[PR_SOURCE_KEY]) {
573 573
             $prefix = "";
574 574
             // prepend the destination short folderid, if it exists
575 575
             $destShortId = ZPush::GetDeviceManager()->GetFolderIdForBackendId($newfolder);
576 576
             if ($destShortId !== $newfolder) {
577
-                $prefix = $destShortId .":";
577
+                $prefix = $destShortId.":";
578 578
             }
579
-            return $prefix . bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
579
+            return $prefix.bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
580 580
         }
581 581
 
582 582
         return false;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
      * @throws StatusException
598 598
      */
599 599
     public function ImportFolderChange($folder) {
600
-        $id = isset($folder->BackendId)?$folder->BackendId : false;
600
+        $id = isset($folder->BackendId) ? $folder->BackendId : false;
601 601
         $parent = $folder->parentid;
602 602
         $parent_org = $folder->parentid;
603 603
         $displayname = u2wi($folder->displayname);
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 
636 636
             mapi_setprops($newfolder, array(PR_CONTAINER_CLASS => MAPIUtils::GetContainerClassFromFolderType($type)));
637 637
 
638
-            $props =  mapi_getprops($newfolder, array(PR_SOURCE_KEY));
638
+            $props = mapi_getprops($newfolder, array(PR_SOURCE_KEY));
639 639
             if (isset($props[PR_SOURCE_KEY])) {
640 640
                 $folder->BackendId = bin2hex($props[PR_SOURCE_KEY]);
641 641
                 $folderOrigin = DeviceManager::FLD_ORIGIN_USER;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
         if (!$mfolder)
664 664
             throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
665 665
 
666
-        $props =  mapi_getprops($mfolder, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_DISPLAY_NAME, PR_CONTAINER_CLASS));
666
+        $props = mapi_getprops($mfolder, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_DISPLAY_NAME, PR_CONTAINER_CLASS));
667 667
         if (!isset($props[PR_SOURCE_KEY]) || !isset($props[PR_PARENT_SOURCE_KEY]) || !isset($props[PR_DISPLAY_NAME]) || !isset($props[PR_CONTAINER_CLASS]))
668 668
             throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, folder data not available: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
669 669
 
@@ -686,23 +686,23 @@  discard block
 block discarded – undo
686 686
         // a changed parent id means that the folder should be moved
687 687
         if (bin2hex($props[PR_PARENT_SOURCE_KEY]) !== $parent) {
688 688
             $sourceparentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, $props[PR_PARENT_SOURCE_KEY]);
689
-            if(!$sourceparentfentryid)
689
+            if (!$sourceparentfentryid)
690 690
                 throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent source folder (no entry id): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
691 691
 
692 692
             $sourceparentfolder = mapi_msgstore_openentry($this->store, $sourceparentfentryid);
693
-            if(!$sourceparentfolder)
693
+            if (!$sourceparentfolder)
694 694
                 throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent source folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
695 695
 
696 696
             $destparentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($parent));
697
-            if(!$sourceparentfentryid)
697
+            if (!$sourceparentfentryid)
698 698
                 throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open destination folder (no entry id): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
699 699
 
700 700
             $destfolder = mapi_msgstore_openentry($this->store, $destparentfentryid);
701
-            if(!$destfolder)
701
+            if (!$destfolder)
702 702
                 throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open destination folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
703 703
 
704 704
             // mapi_folder_copyfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION
705
-            if(! mapi_folder_copyfolder($sourceparentfolder, $entryid, $destfolder, $displayname, FOLDER_MOVE))
705
+            if (!mapi_folder_copyfolder($sourceparentfolder, $entryid, $destfolder, $displayname, FOLDER_MOVE))
706 706
                 throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to move folder: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_FOLDEREXISTS);
707 707
 
708 708
             // the parent changed, but we got a backendID as parent and have to return an AS folderid - the parent-backendId must be mapped at this point already
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS->ImportFolderDeletion('%s','%s'): importing folder deletetion", $id, $parent));
741 741
 
742 742
         $folderentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($id));
743
-        if(!$folderentryid)
743
+        if (!$folderentryid)
744 744
             throw new StatusException(sprintf("ImportChangesICS->ImportFolderDeletion('%s','%s'): Error, unable to resolve folder", $id, $parent, mapi_last_hresult()), SYNC_FSSTATUS_FOLDERDOESNOTEXIST);
745 745
 
746 746
         // get the folder type from the MAPIProvider
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
         if (Utils::IsSystemFolder($type) || $this->mapiprovider->IsMAPIDefaultFolder($folderentryid))
750 750
             throw new StatusException(sprintf("ImportChangesICS->ImportFolderDeletion('%s','%s'): Error deleting system/default folder", $id, $parent), SYNC_FSSTATUS_SYSTEMFOLDER);
751 751
 
752
-        $ret = mapi_importhierarchychanges_importfolderdeletion ($this->importer, 0, array(PR_SOURCE_KEY => hex2bin($id)));
752
+        $ret = mapi_importhierarchychanges_importfolderdeletion($this->importer, 0, array(PR_SOURCE_KEY => hex2bin($id)));
753 753
         if (!$ret)
754 754
             throw new StatusException(sprintf("ImportChangesICS->ImportFolderDeletion('%s','%s'): Error deleting folder: 0x%X", $id, $parent, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
755 755
 
Please login to merge, or discard this patch.
lib/request/provisioning.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
         $rwstatus = ZPush::GetProvisioningManager()->GetProvisioningWipeStatus();
25 25
         $rwstatusWiped = false;
26 26
         $deviceInfoSet = false;
27
-        $wipeRequest = ! ($rwstatus < SYNC_PROVISION_RWSTATUS_PENDING);
27
+        $wipeRequest = !($rwstatus < SYNC_PROVISION_RWSTATUS_PENDING);
28 28
 
29 29
         // if this is a regular provisioning require that an authenticated remote user
30
-        if (! $wipeRequest) {
30
+        if (!$wipeRequest) {
31 31
             ZLog::Write(LOGLEVEL_DEBUG, "RequestProcessor::HandleProvision(): Forcing delayed Authentication");
32 32
             self::Authenticate();
33 33
         }
34 34
 
35 35
         $phase2 = true;
36 36
 
37
-        if(!self::$decoder->getElementStartTag(SYNC_PROVISION_PROVISION))
37
+        if (!self::$decoder->getElementStartTag(SYNC_PROVISION_PROVISION))
38 38
             return false;
39 39
 
40 40
         // Loop through Provision request tags. Possible are:
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         // - Policies
44 44
         // Each of them should only be once per request.
45 45
         WBXMLDecoder::ResetInWhile("provisioningMain");
46
-        while(WBXMLDecoder::InWhile("provisioningMain")) {
46
+        while (WBXMLDecoder::InWhile("provisioningMain")) {
47 47
             $requestName = "";
48 48
             if (self::$decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) {
49 49
                 $requestName = SYNC_PROVISION_REMOTEWIPE;
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
                 //set is available for OOF, device password and device information
62 62
             switch ($requestName) {
63 63
                 case SYNC_PROVISION_REMOTEWIPE:
64
-                    if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
64
+                    if (!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
65 65
                         return false;
66 66
 
67 67
                     $instatus = self::$decoder->getElementContent();
68 68
 
69
-                    if(!self::$decoder->getElementEndTag())
69
+                    if (!self::$decoder->getElementEndTag())
70 70
                         return false;
71 71
 
72
-                    if(!self::$decoder->getElementEndTag())
72
+                    if (!self::$decoder->getElementEndTag())
73 73
                         return false;
74 74
 
75 75
                     $phase2 = false;
@@ -78,40 +78,40 @@  discard block
 block discarded – undo
78 78
                     break;
79 79
 
80 80
                 case SYNC_PROVISION_POLICIES:
81
-                    if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY))
81
+                    if (!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY))
82 82
                         return false;
83 83
 
84
-                    if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYTYPE))
84
+                    if (!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYTYPE))
85 85
                         return false;
86 86
 
87 87
                     $policytype = self::$decoder->getElementContent();
88 88
                     if ($policytype != 'MS-WAP-Provisioning-XML' && $policytype != 'MS-EAS-Provisioning-WBXML') {
89 89
                         $status = SYNC_PROVISION_STATUS_SERVERERROR;
90 90
                     }
91
-                    if(!self::$decoder->getElementEndTag()) //policytype
91
+                    if (!self::$decoder->getElementEndTag()) //policytype
92 92
                         return false;
93 93
 
94 94
                     if (self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYKEY)) {
95 95
                         $devpolicykey = self::$decoder->getElementContent();
96 96
 
97
-                        if(!self::$decoder->getElementEndTag())
97
+                        if (!self::$decoder->getElementEndTag())
98 98
                             return false;
99 99
 
100
-                        if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
100
+                        if (!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
101 101
                             return false;
102 102
 
103 103
                         $instatus = self::$decoder->getElementContent();
104 104
 
105
-                        if(!self::$decoder->getElementEndTag())
105
+                        if (!self::$decoder->getElementEndTag())
106 106
                             return false;
107 107
 
108 108
                         $phase2 = false;
109 109
                     }
110 110
 
111
-                    if(!self::$decoder->getElementEndTag()) //policy
111
+                    if (!self::$decoder->getElementEndTag()) //policy
112 112
                         return false;
113 113
 
114
-                    if(!self::$decoder->getElementEndTag()) //policies
114
+                    if (!self::$decoder->getElementEndTag()) //policies
115 115
                         return false;
116 116
                     break;
117 117
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                     $deviceinformation = new SyncDeviceInformation();
124 124
                     $deviceinformation->Decode(self::$decoder);
125 125
                     $deviceinformation->Status = SYNC_SETTINGSSTATUS_SUCCESS;
126
-                    if (! $wipeRequest) {
126
+                    if (!$wipeRequest) {
127 127
                         // for this operation the device manager is available
128 128
                         ZPush::GetDeviceManager()->SaveDeviceInformation($deviceinformation);
129 129
                     }
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 
139 139
                 default:
140 140
                     //TODO: a special status code needed?
141
-                    ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to be used in a provision request", $requestName));
141
+                    ZLog::Write(LOGLEVEL_WARN, sprintf("This property ('%s') is not allowed to be used in a provision request", $requestName));
142 142
             }
143 143
 
144 144
         }
145 145
 
146
-        if(!self::$decoder->getElementEndTag()) //provision
146
+        if (!self::$decoder->getElementEndTag()) //provision
147 147
             return false;
148 148
 
149 149
         if (PROVISIONING !== true) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             self::$encoder->startTag(SYNC_PROVISION_POLICIES);
174 174
                 self::$encoder->startTag(SYNC_PROVISION_POLICY);
175 175
 
176
-                if(isset($policytype)) {
176
+                if (isset($policytype)) {
177 177
                     self::$encoder->startTag(SYNC_PROVISION_POLICYTYPE);
178 178
                         self::$encoder->content($policytype);
179 179
                     self::$encoder->endTag();
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
                     }
212 212
                     self::$topCollector->AnnounceInformation("Updated provisioning", true);
213 213
 
214
-                    self::$encoder->endTag();//data
214
+                    self::$encoder->endTag(); //data
215 215
                 }
216
-                self::$encoder->endTag();//policy
216
+                self::$encoder->endTag(); //policy
217 217
             self::$encoder->endTag(); //policies
218 218
         }
219 219
 
220 220
         //set the new final policy key in the provisioning manager
221
-        if (!$phase2 && ! $wipeRequest) {
221
+        if (!$phase2 && !$wipeRequest) {
222 222
             ZPush::GetProvisioningManager()->SetProvisioningPolicyKey($policykey);
223 223
             self::$topCollector->AnnounceInformation("Policies deployed", true);
224 224
         }
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
         //wipe data if a higher RWSTATUS is requested
227 227
         if ($rwstatus > SYNC_PROVISION_RWSTATUS_OK && $policystatus === SYNC_PROVISION_POLICYSTATUS_SUCCESS) {
228 228
             self::$encoder->startTag(SYNC_PROVISION_REMOTEWIPE, false, true);
229
-            ZPush::GetProvisioningManager()->SetProvisioningWipeStatus(($rwstatusWiped)?SYNC_PROVISION_RWSTATUS_WIPED:SYNC_PROVISION_RWSTATUS_REQUESTED);
230
-            self::$topCollector->AnnounceInformation(sprintf("Remote wipe %s", ($rwstatusWiped)?"executed":"requested"), true);
229
+            ZPush::GetProvisioningManager()->SetProvisioningWipeStatus(($rwstatusWiped) ?SYNC_PROVISION_RWSTATUS_WIPED:SYNC_PROVISION_RWSTATUS_REQUESTED);
230
+            self::$topCollector->AnnounceInformation(sprintf("Remote wipe %s", ($rwstatusWiped) ? "executed" : "requested"), true);
231 231
         }
232 232
 
233
-        self::$encoder->endTag();//provision
233
+        self::$encoder->endTag(); //provision
234 234
 
235 235
         return true;
236 236
     }
Please login to merge, or discard this patch.
lib/request/moveitems.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,34 +18,34 @@  discard block
 block discarded – undo
18 18
      * @return boolean
19 19
      */
20 20
     public function Handle($commandCode) {
21
-        if(!self::$decoder->getElementStartTag(SYNC_MOVE_MOVES))
21
+        if (!self::$decoder->getElementStartTag(SYNC_MOVE_MOVES))
22 22
             return false;
23 23
 
24 24
         $moves = array();
25
-        while(self::$decoder->getElementStartTag(SYNC_MOVE_MOVE)) {
25
+        while (self::$decoder->getElementStartTag(SYNC_MOVE_MOVE)) {
26 26
             $move = array();
27
-            if(self::$decoder->getElementStartTag(SYNC_MOVE_SRCMSGID)) {
27
+            if (self::$decoder->getElementStartTag(SYNC_MOVE_SRCMSGID)) {
28 28
                 $move["srcmsgid"] = self::$decoder->getElementContent();
29
-                if(!self::$decoder->getElementEndTag())
29
+                if (!self::$decoder->getElementEndTag())
30 30
                     break;
31 31
             }
32
-            if(self::$decoder->getElementStartTag(SYNC_MOVE_SRCFLDID)) {
32
+            if (self::$decoder->getElementStartTag(SYNC_MOVE_SRCFLDID)) {
33 33
                 $move["srcfldid"] = self::$decoder->getElementContent();
34
-                if(!self::$decoder->getElementEndTag())
34
+                if (!self::$decoder->getElementEndTag())
35 35
                     break;
36 36
             }
37
-            if(self::$decoder->getElementStartTag(SYNC_MOVE_DSTFLDID)) {
37
+            if (self::$decoder->getElementStartTag(SYNC_MOVE_DSTFLDID)) {
38 38
                 $move["dstfldid"] = self::$decoder->getElementContent();
39
-                if(!self::$decoder->getElementEndTag())
39
+                if (!self::$decoder->getElementEndTag())
40 40
                     break;
41 41
             }
42 42
             array_push($moves, $move);
43 43
 
44
-            if(!self::$decoder->getElementEndTag())
44
+            if (!self::$decoder->getElementEndTag())
45 45
                 return false;
46 46
         }
47 47
 
48
-        if(!self::$decoder->getElementEndTag())
48
+        if (!self::$decoder->getElementEndTag())
49 49
             return false;
50 50
 
51 51
         self::$encoder->StartWBXML();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $operationResults = array();
56 56
         $operationCounter = 0;
57 57
         $operationTotal = count($moves);
58
-        foreach($moves as $move) {
58
+        foreach ($moves as $move) {
59 59
             $operationCounter++;
60 60
             self::$encoder->startTag(SYNC_MOVE_RESPONSE);
61 61
             self::$encoder->startTag(SYNC_MOVE_SRCMSGID);
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             self::$encoder->endTag();
108 108
 
109 109
             self::$encoder->startTag(SYNC_MOVE_DSTMSGID);
110
-            self::$encoder->content( (($result !== false ) ? $result : $move["srcmsgid"]));
110
+            self::$encoder->content((($result !== false) ? $result : $move["srcmsgid"]));
111 111
             self::$encoder->endTag();
112 112
             self::$encoder->endTag();
113 113
         }
Please login to merge, or discard this patch.
lib/request/validatecert.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function Handle($commandCode) {
21 21
         // Parse input
22
-        if(!self::$decoder->getElementStartTag(SYNC_VALIDATECERT_VALIDATECERT))
22
+        if (!self::$decoder->getElementStartTag(SYNC_VALIDATECERT_VALIDATECERT))
23 23
             return false;
24 24
 
25 25
         $validateCert = new SyncValidateCert();
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         else
34 34
             $status = SYNC_VALIDATECERTSTATUS_CANTVALIDATESIG;
35 35
 
36
-        if(!self::$decoder->getElementEndTag())
36
+        if (!self::$decoder->getElementEndTag())
37 37
                 return false; // SYNC_VALIDATECERT_VALIDATECERT
38 38
 
39 39
         self::$encoder->startWBXML();
Please login to merge, or discard this patch.
lib/request/notify.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@
 block discarded – undo
18 18
      * @return boolean
19 19
      */
20 20
     public function Handle($commandCode) {
21
-        if(!self::$decoder->getElementStartTag(SYNC_AIRNOTIFY_NOTIFY))
21
+        if (!self::$decoder->getElementStartTag(SYNC_AIRNOTIFY_NOTIFY))
22 22
             return false;
23 23
 
24
-        if(!self::$decoder->getElementStartTag(SYNC_AIRNOTIFY_DEVICEINFO))
24
+        if (!self::$decoder->getElementStartTag(SYNC_AIRNOTIFY_DEVICEINFO))
25 25
             return false;
26 26
 
27
-        if(!self::$decoder->getElementEndTag())
27
+        if (!self::$decoder->getElementEndTag())
28 28
             return false;
29 29
 
30
-        if(!self::$decoder->getElementEndTag())
30
+        if (!self::$decoder->getElementEndTag())
31 31
             return false;
32 32
 
33 33
         self::$encoder->StartWBXML();
Please login to merge, or discard this patch.
lib/request/ping.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -60,40 +60,40 @@  discard block
 block discarded – undo
60 60
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): reference PolicyKey for PING: %s", $sc->GetReferencePolicyKey()));
61 61
 
62 62
         // receive PING initialization data
63
-        if($params_present) {
63
+        if ($params_present) {
64 64
             self::$topCollector->AnnounceInformation("Processing PING data");
65 65
             ZLog::Write(LOGLEVEL_DEBUG, "HandlePing(): initialization data received");
66 66
 
67
-            if(self::$decoder->getElementStartTag(SYNC_PING_LIFETIME)) {
67
+            if (self::$decoder->getElementStartTag(SYNC_PING_LIFETIME)) {
68 68
                 $sc->SetLifetime(self::$decoder->getElementContent());
69 69
                 self::$decoder->getElementEndTag();
70 70
             }
71 71
 
72
-            if(($el = self::$decoder->getElementStartTag(SYNC_PING_FOLDERS)) && $el[EN_FLAGS] & EN_FLAGS_CONTENT) {
72
+            if (($el = self::$decoder->getElementStartTag(SYNC_PING_FOLDERS)) && $el[EN_FLAGS] & EN_FLAGS_CONTENT) {
73 73
                 // cache requested (pingable) folderids
74 74
                 $pingable = array();
75 75
 
76
-                while(self::$decoder->getElementStartTag(SYNC_PING_FOLDER)) {
76
+                while (self::$decoder->getElementStartTag(SYNC_PING_FOLDER)) {
77 77
                     WBXMLDecoder::ResetInWhile("pingFolder");
78
-                    while(WBXMLDecoder::InWhile("pingFolder")) {
79
-                        if(self::$decoder->getElementStartTag(SYNC_PING_SERVERENTRYID)) {
78
+                    while (WBXMLDecoder::InWhile("pingFolder")) {
79
+                        if (self::$decoder->getElementStartTag(SYNC_PING_SERVERENTRYID)) {
80 80
                             $folderid = self::$decoder->getElementContent();
81 81
                             self::$decoder->getElementEndTag();
82 82
                         }
83
-                        if(self::$decoder->getElementStartTag(SYNC_PING_FOLDERTYPE)) {
83
+                        if (self::$decoder->getElementStartTag(SYNC_PING_FOLDERTYPE)) {
84 84
                             $class = self::$decoder->getElementContent();
85 85
                             self::$decoder->getElementEndTag();
86 86
                         }
87 87
 
88 88
                         $e = self::$decoder->peek();
89
-                        if($e[EN_TYPE] == EN_TYPE_ENDTAG) {
89
+                        if ($e[EN_TYPE] == EN_TYPE_ENDTAG) {
90 90
                             self::$decoder->getElementEndTag();
91 91
                             break;
92 92
                         }
93 93
                     }
94 94
 
95 95
                     $spa = $sc->GetCollection($folderid);
96
-                    if (! $spa) {
96
+                    if (!$spa) {
97 97
                         // The requested collection is not synchronized.
98 98
                         // check if the HierarchyCache is available, if not, trigger a HierarchySync
99 99
                         try {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                         ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): using saved sync state for '%s' id '%s'", $spa->GetContentClass(), $folderid));
119 119
                     }
120 120
                 }
121
-                if(!self::$decoder->getElementEndTag())
121
+                if (!self::$decoder->getElementEndTag())
122 122
                     return false;
123 123
 
124 124
                 // update pingable flags
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
                     if (in_array($folderid, $pingable)) {
128 128
                         $spa->SetPingableFlag(true);
129 129
                     }
130
-                    else  {
130
+                    else {
131 131
                         $spa->DelPingableFlag();
132 132
                     }
133 133
                 }
134 134
             }
135
-            if(!self::$decoder->getElementEndTag())
135
+            if (!self::$decoder->getElementEndTag())
136 136
                 return false;
137 137
 
138
-            if(!$this->lifetimeBetweenBound($sc->GetLifetime())){
138
+            if (!$this->lifetimeBetweenBound($sc->GetLifetime())) {
139 139
                 $pingstatus = SYNC_PINGSTATUS_HBOUTOFRANGE;
140 140
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): ping lifetime not between bound (higher bound:'%d' lower bound:'%d' current lifetime:'%d'. Returning SYNC_PINGSTATUS_HBOUTOFRANGE.", PING_HIGHER_BOUND_LIFETIME, PING_LOWER_BOUND_LIFETIME, $sc->GetLifetime()));
141 141
             }
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
         else {
147 147
             // if no ping initialization data was sent, we check if we have pingable folders
148 148
             // if not, we indicate that there is nothing to do.
149
-            if (! $sc->PingableFolders()) {
149
+            if (!$sc->PingableFolders()) {
150 150
                 $pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
151 151
                 ZLog::Write(LOGLEVEL_DEBUG, "HandlePing(): no pingable folders found and no initialization data sent. Returning SYNC_PINGSTATUS_FAILINGPARAMS.");
152 152
             }
153
-            elseif(!$this->lifetimeBetweenBound($sc->GetLifetime())){
153
+            elseif (!$this->lifetimeBetweenBound($sc->GetLifetime())) {
154 154
                 $pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
155 155
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): ping lifetime not between bound (higher bound:'%d' lower bound:'%d' current lifetime:'%d'. Returning SYNC_PINGSTATUS_FAILINGPARAMS.", PING_HIGHER_BOUND_LIFETIME, PING_LOWER_BOUND_LIFETIME, $sc->GetLifetime()));
156 156
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             }
166 166
         }
167 167
         catch (StatusException $ste) {
168
-            switch($ste->getCode()) {
168
+            switch ($ste->getCode()) {
169 169
                 case SyncCollections::ERROR_NO_COLLECTIONS:
170 170
                     $pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
171 171
                     break;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                 self::$encoder->content($foundchanges ? SYNC_PINGSTATUS_CHANGES : SYNC_PINGSTATUS_HBEXPIRED);
193 193
             self::$encoder->endTag();
194 194
 
195
-            if (! $pingstatus) {
195
+            if (!$pingstatus) {
196 196
                 self::$encoder->startTag(SYNC_PING_FOLDERS);
197 197
 
198 198
                 if (empty($fakechanges))
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
                 }
226 226
                 self::$encoder->endTag();
227 227
             }
228
-            elseif($pingstatus == SYNC_PINGSTATUS_HBOUTOFRANGE){
228
+            elseif ($pingstatus == SYNC_PINGSTATUS_HBOUTOFRANGE) {
229 229
                 self::$encoder->startTag(SYNC_PING_LIFETIME);
230
-                if($sc->GetLifetime() > PING_HIGHER_BOUND_LIFETIME){
230
+                if ($sc->GetLifetime() > PING_HIGHER_BOUND_LIFETIME) {
231 231
                     self::$encoder->content(PING_HIGHER_BOUND_LIFETIME);
232 232
                 }
233
-                else{
233
+                else {
234 234
                     self::$encoder->content(PING_LOWER_BOUND_LIFETIME);
235 235
                 }
236 236
                 self::$encoder->endTag();
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
      * @access private
254 254
      * @return boolean
255 255
      */
256
-    private function lifetimeBetweenBound($lifetime){
257
-        if(PING_HIGHER_BOUND_LIFETIME !== false && PING_LOWER_BOUND_LIFETIME !== false){
256
+    private function lifetimeBetweenBound($lifetime) {
257
+        if (PING_HIGHER_BOUND_LIFETIME !== false && PING_LOWER_BOUND_LIFETIME !== false) {
258 258
             return ($lifetime <= PING_HIGHER_BOUND_LIFETIME && $lifetime >= PING_LOWER_BOUND_LIFETIME);
259 259
         }
260
-        if(PING_HIGHER_BOUND_LIFETIME !== false){
260
+        if (PING_HIGHER_BOUND_LIFETIME !== false) {
261 261
             return $lifetime <= PING_HIGHER_BOUND_LIFETIME;
262 262
         }
263
-        if(PING_LOWER_BOUND_LIFETIME !== false){
263
+        if (PING_LOWER_BOUND_LIFETIME !== false) {
264 264
             return $lifetime >= PING_LOWER_BOUND_LIFETIME;
265 265
         }
266 266
         return true;
Please login to merge, or discard this patch.
lib/request/meetingresponse.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,33 +20,33 @@  discard block
 block discarded – undo
20 20
     public function Handle($commandCode) {
21 21
         $requests = Array();
22 22
 
23
-        if(!self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE))
23
+        if (!self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE))
24 24
             return false;
25 25
 
26
-        while(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUEST)) {
26
+        while (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUEST)) {
27 27
             $req = Array();
28 28
             WBXMLDecoder::ResetInWhile("meetingResponseRequest");
29
-            while(WBXMLDecoder::InWhile("meetingResponseRequest")) {
30
-                if(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_USERRESPONSE)) {
29
+            while (WBXMLDecoder::InWhile("meetingResponseRequest")) {
30
+                if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_USERRESPONSE)) {
31 31
                     $req["response"] = self::$decoder->getElementContent();
32
-                    if(!self::$decoder->getElementEndTag())
32
+                    if (!self::$decoder->getElementEndTag())
33 33
                         return false;
34 34
                 }
35 35
 
36
-                if(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_FOLDERID)) {
36
+                if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_FOLDERID)) {
37 37
                     $req["folderid"] = self::$decoder->getElementContent();
38
-                    if(!self::$decoder->getElementEndTag())
38
+                    if (!self::$decoder->getElementEndTag())
39 39
                         return false;
40 40
                 }
41 41
 
42
-                if(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUESTID)) {
42
+                if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUESTID)) {
43 43
                     $req["requestid"] = self::$decoder->getElementContent();
44
-                    if(!self::$decoder->getElementEndTag())
44
+                    if (!self::$decoder->getElementEndTag())
45 45
                         return false;
46 46
                 }
47 47
 
48 48
                 $e = self::$decoder->peek();
49
-                if($e[EN_TYPE] == EN_TYPE_ENDTAG) {
49
+                if ($e[EN_TYPE] == EN_TYPE_ENDTAG) {
50 50
                     self::$decoder->getElementEndTag();
51 51
                     break;
52 52
                 }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             array_push($requests, $req);
55 55
         }
56 56
 
57
-        if(!self::$decoder->getElementEndTag())
57
+        if (!self::$decoder->getElementEndTag())
58 58
             return false;
59 59
 
60 60
         // output the error code, plus the ID of the calendar item that was generated by the
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         self::$encoder->StartWBXML();
63 63
         self::$encoder->startTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE);
64 64
 
65
-        foreach($requests as $req) {
65
+        foreach ($requests as $req) {
66 66
             $status = SYNC_MEETRESPSTATUS_SUCCESS;
67 67
 
68 68
             try {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                     self::$encoder->content($status);
90 90
                 self::$encoder->endTag();
91 91
 
92
-                if($status == SYNC_MEETRESPSTATUS_SUCCESS && !empty($calendarid)) {
92
+                if ($status == SYNC_MEETRESPSTATUS_SUCCESS && !empty($calendarid)) {
93 93
                     self::$encoder->startTag(SYNC_MEETINGRESPONSE_CALENDARID);
94 94
                         self::$encoder->content($calendarid);
95 95
                     self::$encoder->endTag();
Please login to merge, or discard this patch.