Passed
Branch master (ff9d34)
by Mike
09:14
created
lib/request/settings.php 1 patch
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
      * @return boolean
19 19
      */
20 20
     public function Handle($commandCode) {
21
-        if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SETTINGS))
22
-            return false;
21
+        if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SETTINGS)) {
22
+                    return false;
23
+        }
23 24
 
24 25
         //save the request parameters
25 26
         $request = array();
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
             }
51 52
             //TODO - check if it is necessary
52 53
             //no property name available - break
53
-            if (!$propertyName)
54
-                break;
54
+            if (!$propertyName) {
55
+                            break;
56
+            }
55 57
 
56 58
             //the property name is followed by either get or set
57 59
             if (self::$decoder->getElementStartTag(SYNC_SETTINGS_GET)) {
@@ -60,8 +62,10 @@  discard block
 block discarded – undo
60 62
                     case SYNC_SETTINGS_OOF:
61 63
                         $oofGet = new SyncOOF();
62 64
                         $oofGet->Decode(self::$decoder);
63
-                        if(!self::$decoder->getElementEndTag())
64
-                            return false; // SYNC_SETTINGS_GET
65
+                        if(!self::$decoder->getElementEndTag()) {
66
+                                                    return false;
67
+                        }
68
+                        // SYNC_SETTINGS_GET
65 69
                         break;
66 70
 
67 71
                     case SYNC_SETTINGS_USERINFORMATION:
@@ -76,8 +80,7 @@  discard block
 block discarded – undo
76 80
                         //TODO: a special status code needed?
77 81
                         ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to use get in request", $propertyName));
78 82
                 }
79
-            }
80
-            elseif (self::$decoder->getElementStartTag(SYNC_SETTINGS_SET)) {
83
+            } elseif (self::$decoder->getElementStartTag(SYNC_SETTINGS_SET)) {
81 84
                 //set is available for OOF, device password and device information
82 85
                 switch ($propertyName) {
83 86
                     case SYNC_SETTINGS_OOF:
@@ -104,16 +107,19 @@  discard block
 block discarded – undo
104 107
                         ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to use set in request", $propertyName));
105 108
                 }
106 109
 
107
-                if(!self::$decoder->getElementEndTag())
108
-                    return false; // SYNC_SETTINGS_SET
109
-            }
110
-            else {
110
+                if(!self::$decoder->getElementEndTag()) {
111
+                                    return false;
112
+                }
113
+                // SYNC_SETTINGS_SET
114
+            } else {
111 115
                 ZLog::Write(LOGLEVEL_WARN, sprintf("Neither get nor set found for property '%s'", $propertyName));
112 116
                 return false;
113 117
             }
114 118
 
115
-            if(!self::$decoder->getElementEndTag())
116
-                return false; // SYNC_SETTINGS_OOF or SYNC_SETTINGS_DEVICEPW or SYNC_SETTINGS_DEVICEINFORMATION or SYNC_SETTINGS_USERINFORMATION
119
+            if(!self::$decoder->getElementEndTag()) {
120
+                            return false;
121
+            }
122
+            // SYNC_SETTINGS_OOF or SYNC_SETTINGS_DEVICEPW or SYNC_SETTINGS_DEVICEINFORMATION or SYNC_SETTINGS_USERINFORMATION
117 123
 
118 124
             //break if it reached the endtag
119 125
             $e = self::$decoder->peek();
Please login to merge, or discard this patch.
lib/syncobjects/synctask.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,11 +128,13 @@
 block discarded – undo
128 128
         $ret = parent::Check($logAsDebug);
129 129
 
130 130
         // semantic checks general "turn off switch"
131
-        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false)
132
-            return $ret;
131
+        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) {
132
+                    return $ret;
133
+        }
133 134
 
134
-        if (!$ret)
135
-            return false;
135
+        if (!$ret) {
136
+                    return false;
137
+        }
136 138
 
137 139
         if (isset($this->startdate) && isset($this->duedate) && $this->duedate < $this->startdate) {
138 140
             ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'startdate' is HIGHER than 'duedate'. Check failed!", get_class($this) ));
Please login to merge, or discard this patch.
lib/syncobjects/syncobject.php 1 patch
Braces   +62 added lines, -56 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
             if (defined('UNSET_UNDEFINED_PROPERTIES') && UNSET_UNDEFINED_PROPERTIES && ($this instanceof SyncContact || $this instanceof SyncAppointment || $this instanceof SyncTask)) {
50 50
                 ZLog::Write(LOGLEVEL_INFO, sprintf("%s->emptySupported(): no supported list available, emptying all not set parameters", get_class($this)));
51 51
                 $supportedFields = array_keys($this->mapping);
52
-            }
53
-            else {
52
+            } else {
54 53
                 return false;
55 54
             }
56 55
         }
@@ -62,8 +61,9 @@  discard block
 block discarded – undo
62 61
             }
63 62
             $var = $this->mapping[$field][self::STREAMER_VAR];
64 63
             // add var to $this->unsetVars if $var is not set
65
-            if (!isset($this->$var))
66
-                $this->unsetVars[] = $var;
64
+            if (!isset($this->$var)) {
65
+                            $this->unsetVars[] = $var;
66
+            }
67 67
         }
68 68
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Supported variables to be unset: %s", implode(',', $this->unsetVars)));
69 69
         return true;
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
      * @return boolean
82 82
      */
83 83
     public function equals($odo, $log = false, $strictTypeCompare = false) {
84
-        if ($odo === false)
85
-            return false;
84
+        if ($odo === false) {
85
+                    return false;
86
+        }
86 87
 
87 88
         // check objecttype
88 89
         if (! ($odo instanceof SyncObject)) {
@@ -99,20 +100,17 @@  discard block
 block discarded – undo
99 100
                 if (!isset($this->$val) && !isset($odo->$val)) {
100 101
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() array '%s' is NOT SET in either object", $val));
101 102
                     continue;
102
-                }
103
-                elseif (is_array($this->$val) && is_array($odo->$val)) {
103
+                } elseif (is_array($this->$val) && is_array($odo->$val)) {
104 104
                     // if both arrays exist then seek for differences in the arrays
105 105
                     if (count(array_diff($this->$val, $odo->$val)) + count(array_diff($odo->$val, $this->$val)) > 0) {
106 106
                         ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() items in array '%s' differ", $val));
107 107
                         return false;
108 108
                     }
109
-                }
110
-                else {
109
+                } else {
111 110
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() array '%s' is set in one but not the other object", $val));
112 111
                     return false;
113 112
                 }
114
-            }
115
-            else {
113
+            } else {
116 114
                 if (isset($this->$val) && isset($odo->$val)) {
117 115
                     if ($strictTypeCompare){
118 116
                         if ($this->$val !== $odo->$val){
@@ -125,11 +123,9 @@  discard block
 block discarded – undo
125 123
                             return false;
126 124
                         }
127 125
                     }
128
-                }
129
-                else if (!isset($this->$val) && !isset($odo->$val)) {
126
+                } else if (!isset($this->$val) && !isset($odo->$val)) {
130 127
                     continue;
131
-                }
132
-                else {
128
+                } else {
133 129
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() false because field '%s' is only defined at one obj: '%s' != '%s'", $val, Utils::PrintAsString(isset($this->$val)), Utils::PrintAsString(isset($odo->$val))));
134 130
                     return false;
135 131
                 }
@@ -148,27 +144,32 @@  discard block
 block discarded – undo
148 144
         $str = get_class($this) . " (\n";
149 145
 
150 146
         $streamerVars = array();
151
-        foreach ($this->mapping as $k=>$v)
152
-            $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE]))?$v[self::STREAMER_TYPE]:false;
147
+        foreach ($this->mapping as $k=>$v) {
148
+                    $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE]))?$v[self::STREAMER_TYPE]:false;
149
+        }
153 150
 
154 151
         foreach (get_object_vars($this) as $k=>$v) {
155
-            if ($k == "mapping") continue;
152
+            if ($k == "mapping") {
153
+                continue;
154
+            }
156 155
 
157
-            if (array_key_exists($k, $streamerVars))
158
-                $strV = "(S) ";
159
-            else
160
-                $strV = "";
156
+            if (array_key_exists($k, $streamerVars)) {
157
+                            $strV = "(S) ";
158
+            } else {
159
+                            $strV = "";
160
+            }
161 161
 
162 162
             // self::STREAMER_ARRAY ?
163 163
             if (is_array($v)) {
164 164
                 $str .= "\t". $strV . $k ."(Array) size: " . count($v) ."\n";
165
-                foreach ($v as $value) $str .= "\t\t". Utils::PrintAsString($value) ."\n";
166
-            }
167
-            else if ($v instanceof SyncObject) {
165
+                foreach ($v as $value) {
166
+                    $str .= "\t\t". Utils::PrintAsString($value) ."\n";
167
+                }
168
+            } else if ($v instanceof SyncObject) {
168 169
                 $str .= "\t". $strV .$k ." => ". str_replace("\n", "\n\t\t\t", $v->__toString()) . "\n";
170
+            } else {
171
+                            $str .= "\t". $strV .$k ." => " . (isset($this->$k)? Utils::PrintAsString($this->$k) :"null") . "\n";
169 172
             }
170
-            else
171
-                $str .= "\t". $strV .$k ." => " . (isset($this->$k)? Utils::PrintAsString($this->$k) :"null") . "\n";
172 173
         }
173 174
         $str .= ")";
174 175
 
@@ -238,8 +239,9 @@  discard block
 block discarded – undo
238 239
         $defaultLogLevel = LOGLEVEL_WARN;
239 240
 
240 241
         // in some cases non-false checks should not provoke a WARN log but only a DEBUG log
241
-        if ($logAsDebug)
242
-            $defaultLogLevel = LOGLEVEL_DEBUG;
242
+        if ($logAsDebug) {
243
+                    $defaultLogLevel = LOGLEVEL_DEBUG;
244
+        }
243 245
 
244 246
         $objClass = get_class($this);
245 247
         foreach ($this->mapping as $k=>$v) {
@@ -247,13 +249,14 @@  discard block
 block discarded – undo
247 249
             // check sub-objects recursively
248 250
             if (isset($v[self::STREAMER_TYPE]) && isset($this->{$v[self::STREAMER_VAR]})) {
249 251
                 if ($this->{$v[self::STREAMER_VAR]} instanceof SyncObject) {
250
-                    if (! $this->{$v[self::STREAMER_VAR]}->Check($logAsDebug))
251
-                        return false;
252
-                }
253
-                else if (is_array($this->{$v[self::STREAMER_VAR]})) {
254
-                    foreach ($this->{$v[self::STREAMER_VAR]} as $subobj)
255
-                        if ($subobj instanceof SyncObject && !$subobj->Check($logAsDebug))
252
+                    if (! $this->{$v[self::STREAMER_VAR]}->Check($logAsDebug)) {
253
+                                            return false;
254
+                    }
255
+                } else if (is_array($this->{$v[self::STREAMER_VAR]})) {
256
+                    foreach ($this->{$v[self::STREAMER_VAR]} as $subobj) {
257
+                                            if ($subobj instanceof SyncObject && !$subobj->Check($logAsDebug))
256 258
                             return false;
259
+                    }
257 260
                 }
258 261
             }
259 262
 
@@ -329,11 +332,11 @@  discard block
 block discarded – undo
329 332
                             else if (!isset($this->mapping[$condition])) {
330 333
                                 ZLog::Write(LOGLEVEL_ERROR, sprintf("SyncObject->Check(): Can not compare parameter '%s' against the other value '%s' as it is not defined object from type %s. Please report this! Check skipped!", $objClass, $v[self::STREAMER_VAR], $condition));
331 334
                                 continue;
332
-                            }
333
-                            else {
335
+                            } else {
334 336
                                 $cmpPar = $this->mapping[$condition][self::STREAMER_VAR];
335
-                                if (isset($this->$cmpPar))
336
-                                    $cmp = $this->$cmpPar;
337
+                                if (isset($this->$cmpPar)) {
338
+                                                                    $cmp = $this->$cmpPar;
339
+                                }
337 340
                             }
338 341
 
339 342
                             if ($cmp === false) {
@@ -361,9 +364,9 @@  discard block
 block discarded – undo
361 364
                         if (is_array($this->{$v[self::STREAMER_VAR]})) {
362 365
                             // implosion takes 2bytes, so we just assume ", " here
363 366
                             $chkstr = implode(", ", $this->{$v[self::STREAMER_VAR]});
367
+                        } else {
368
+                                                    $chkstr = $this->{$v[self::STREAMER_VAR]};
364 369
                         }
365
-                        else
366
-                            $chkstr = $this->{$v[self::STREAMER_VAR]};
367 370
 
368 371
                         if (strlen($chkstr) > $condition) {
369 372
                             ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' is longer than %d. Check failed", $objClass, $v[self::STREAMER_VAR], $condition));
@@ -376,16 +379,16 @@  discard block
 block discarded – undo
376 379
                     // if $condition is false then the check really fails. Otherwise invalid emails are removed.
377 380
                     // if nothing is left (all emails were false), the parameter is set to condition
378 381
                     if ($rule === self::STREAMER_CHECK_EMAIL && isset($this->{$v[self::STREAMER_VAR]})) {
379
-                        if ($condition === false && ( (is_array($this->{$v[self::STREAMER_VAR]}) && empty($this->{$v[self::STREAMER_VAR]})) || strlen($this->{$v[self::STREAMER_VAR]}) == 0) )
380
-                            continue;
382
+                        if ($condition === false && ( (is_array($this->{$v[self::STREAMER_VAR]}) && empty($this->{$v[self::STREAMER_VAR]})) || strlen($this->{$v[self::STREAMER_VAR]}) == 0) ) {
383
+                                                    continue;
384
+                        }
381 385
 
382 386
                         $as_array = false;
383 387
 
384 388
                         if (is_array($this->{$v[self::STREAMER_VAR]})) {
385 389
                             $mails = $this->{$v[self::STREAMER_VAR]};
386 390
                             $as_array = true;
387
-                        }
388
-                        else {
391
+                        } else {
389 392
                             $mails = array( $this->{$v[self::STREAMER_VAR]} );
390 393
                         }
391 394
 
@@ -393,23 +396,26 @@  discard block
 block discarded – undo
393 396
                         foreach ($mails as $mail) {
394 397
                             if (! Utils::CheckEmail($mail)) {
395 398
                                 ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' contains an invalid email address '%s'. Address is removed.", $objClass, $v[self::STREAMER_VAR], $mail));
399
+                            } else {
400
+                                                            $output[] = $mail;
396 401
                             }
397
-                            else
398
-                                $output[] = $mail;
399 402
                         }
400 403
                         if (count($mails) != count($output)) {
401
-                            if ($condition === false)
402
-                                return false;
404
+                            if ($condition === false) {
405
+                                                            return false;
406
+                            }
403 407
 
404 408
                             // nothing left, use $condition as new value
405
-                            if (count($output) == 0)
406
-                                $output[] = $condition;
409
+                            if (count($output) == 0) {
410
+                                                            $output[] = $condition;
411
+                            }
407 412
 
408 413
                             // if we are allowed to rewrite the attribute, we do that
409
-                            if ($as_array)
410
-                                $this->{$v[self::STREAMER_VAR]} = $output;
411
-                            else
412
-                                $this->{$v[self::STREAMER_VAR]} = $output[0];
414
+                            if ($as_array) {
415
+                                                            $this->{$v[self::STREAMER_VAR]} = $output;
416
+                            } else {
417
+                                                            $this->{$v[self::STREAMER_VAR]} = $output[0];
418
+                            }
413 419
                         }
414 420
                     }// end STREAMER_CHECK_EMAIL
415 421
 
Please login to merge, or discard this patch.
lib/syncobjects/synctaskrecurrence.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,11 +137,13 @@
 block discarded – undo
137 137
         $ret = parent::Check($logAsDebug);
138 138
 
139 139
         // semantic checks general "turn off switch"
140
-        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false)
141
-            return $ret;
140
+        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) {
141
+                    return $ret;
142
+        }
142 143
 
143
-        if (!$ret)
144
-            return false;
144
+        if (!$ret) {
145
+                    return false;
146
+        }
145 147
 
146 148
         if (isset($this->start) && isset($this->until) && $this->until < $this->start) {
147 149
             ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'start' is HIGHER than 'until'. Check failed!", get_class($this) ));
Please login to merge, or discard this patch.
lib/syncobjects/syncappointment.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -260,11 +260,13 @@
 block discarded – undo
260 260
         $ret = parent::Check($logAsDebug);
261 261
 
262 262
         // semantic checks general "turn off switch"
263
-        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false)
264
-            return $ret;
263
+        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) {
264
+                    return $ret;
265
+        }
265 266
 
266
-        if (!$ret)
267
-            return false;
267
+        if (!$ret) {
268
+                    return false;
269
+        }
268 270
 
269 271
         if ($this->meetingstatus > 0) {
270 272
             if (!isset($this->organizername) || !isset($this->organizeremail)) {
Please login to merge, or discard this patch.
lib/core/changesmemorywrapper.php 1 patch
Braces   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
                     if (! $hasRights) {
59 59
                         // delete the folder only if it was an additional folder before, else ignore it
60 60
                         $synchedfolder = $this->GetFolder($addFolder->serverid);
61
-                        if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true)
62
-                            $this->ImportFolderDeletion($addFolder);
61
+                        if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true) {
62
+                                                    $this->ImportFolderDeletion($addFolder);
63
+                        }
63 64
                         continue;
64 65
                     }
65 66
                 }
@@ -85,8 +86,7 @@  discard block
 block discarded – undo
85 86
                         ZLog::Write(LOGLEVEL_INFO, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : previously synchronized folder '%s' is not to be synched anymore. Sending delete to mobile.", $folder->displayname));
86 87
                         $this->ImportFolderDeletion($folder);
87 88
                     }
88
-                }
89
-                else {
89
+                } else {
90 90
                     $folderIdsOnClient[] = $sid;
91 91
                 }
92 92
             }
@@ -173,8 +173,7 @@  discard block
 block discarded – undo
173 173
     public function ImportMessageDeletion($id, $asSoftDelete = false) {
174 174
         if ($asSoftDelete === true) {
175 175
             $this->changes[] = array(self::SOFTDELETION, $id);
176
-        }
177
-        else {
176
+        } else {
178 177
             $this->changes[] = array(self::DELETION, $id);
179 178
         }
180 179
         return true;
@@ -303,12 +302,12 @@  discard block
 block discarded – undo
303 302
             $ret = $this->destinationImporter->ImportFolderDeletion($folder);
304 303
 
305 304
             // if the operation was successful, update the HierarchyCache
306
-            if ($ret)
307
-                $this->DelFolder($id);
305
+            if ($ret) {
306
+                            $this->DelFolder($id);
307
+            }
308 308
 
309 309
             return $ret;
310
-        }
311
-        else {
310
+        } else {
312 311
             // if this folder is not in the cache, the change does not need to be streamed to the mobile
313 312
             if ($this->GetFolder($id)) {
314 313
 
@@ -363,8 +362,9 @@  discard block
 block discarded – undo
363 362
             $change = $this->changes[$this->step];
364 363
 
365 364
             if ($change[0] == self::CHANGE) {
366
-                if (! $this->GetFolder($change[1]->serverid, true))
367
-                    $change[1]->flags = SYNC_NEWMESSAGE;
365
+                if (! $this->GetFolder($change[1]->serverid, true)) {
366
+                                    $change[1]->flags = SYNC_NEWMESSAGE;
367
+                }
368 368
 
369 369
                 $this->exportImporter->ImportFolderChange($change[1]);
370 370
             }
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
 
377 377
             // return progress array
378 378
             return array("steps" => count($this->changes), "progress" => $this->step);
379
+        } else {
380
+                    return false;
379 381
         }
380
-        else
381
-            return false;
382 382
     }
383 383
 
384 384
     /**
Please login to merge, or discard this patch.
lib/core/interprocessdata.php 1 patch
Braces   +9 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
      * @access public
30 30
      */
31 31
     public function __construct() {
32
-        if (!isset($this->type) || !isset($this->allocate))
33
-            throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this)));
32
+        if (!isset($this->type) || !isset($this->allocate)) {
33
+                    throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this)));
34
+        }
34 35
 
35 36
         try {
36 37
             // ZP-987: use an own mutex + storage key for each device on non-shared-memory IPC
37 38
             // this method is not suitable for the TopCollector atm
38 39
             $type = Request::GetDeviceID();
39 40
             $this->ipcProvider = ZPush::GetRedis();
40
-        }
41
-        catch (Exception $e) {
41
+        } catch (Exception $e) {
42 42
             // ipcProvider could not initialise
43 43
             ZLog::Write(LOGLEVEL_ERROR, sprintf("%s could not initialise IPC Redis provider: %s", get_class($this), $e->getMessage()));
44 44
         }
@@ -204,8 +204,7 @@  discard block
 block discarded – undo
204 204
         elseif ($doCas == "replace") {
205 205
             if (!$rawdata) {
206 206
                 $ok = ($this->ipcProvider->get()->hset($key, $compKey, json_encode($data)) !== false);
207
-            }
208
-            else {
207
+            } else {
209 208
                 $ok = $this->ipcProvider->CASHash($key, $compKey, $rawdata, json_encode($data));
210 209
             }
211 210
         }
@@ -251,16 +250,13 @@  discard block
 block discarded – undo
251 250
         if ($returnRaw) {
252 251
             if ($_rawdata) {
253 252
                 return array(json_decode($_rawdata, true), $_rawdata);
254
-            }
255
-            else {
253
+            } else {
256 254
                 return array(array(), false);
257 255
             }
258
-        }
259
-        else {
256
+        } else {
260 257
             if ($_rawdata) {
261 258
                 return json_decode($_rawdata, true);
262
-            }
263
-            else {
259
+            } else {
264 260
                 return array();
265 261
             }
266 262
         }
@@ -282,8 +278,7 @@  discard block
 block discarded – undo
282 278
             }
283 279
             if (!$subkey) {
284 280
                 $_data[$devid][$user] = $_data;
285
-            }
286
-            else {
281
+            } else {
287 282
                 if (!isset($_data[$devid][$user])){
288 283
                     $_data[$devid][$user] = array();
289 284
                 }
Please login to merge, or discard this patch.
lib/core/syncparameters.php 1 patch
Braces   +36 added lines, -30 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
      * @return string/boolean       false if no uuid/counter available
68 68
      */
69 69
     public function GetSyncKey() {
70
-        if (isset($this->uuid) && isset($this->uuidCounter))
71
-            return StateManager::BuildStateKey($this->uuid, $this->uuidCounter);
70
+        if (isset($this->uuid) && isset($this->uuidCounter)) {
71
+                    return StateManager::BuildStateKey($this->uuid, $this->uuidCounter);
72
+        }
72 73
 
73 74
         return false;
74 75
     }
@@ -124,9 +125,9 @@  discard block
 block discarded – undo
124 125
         if (!$this->HasSyncKey()) {
125 126
             $this->uuid = $uuid;
126 127
             $this->uuidCounter = $uuidNewCounter;
128
+        } else if ($uuid !== $this->uuid) {
129
+                    throw new FatalException("SyncParameters->SetNewSyncKey(): new SyncKey must have the same UUID as current SyncKey");
127 130
         }
128
-        else if ($uuid !== $this->uuid)
129
-            throw new FatalException("SyncParameters->SetNewSyncKey(): new SyncKey must have the same UUID as current SyncKey");
130 131
 
131 132
         $this->uuidNewCounter = $uuidNewCounter;
132 133
         $this->counterconfirmed = false;
@@ -142,8 +143,9 @@  discard block
 block discarded – undo
142 143
      * @return string/boolean       returns false if uuid or counter are not available
143 144
      */
144 145
     public function GetNewSyncKey() {
145
-        if (isset($this->uuid) && isset($this->uuidNewCounter))
146
-            return StateManager::BuildStateKey($this->uuid, $this->uuidNewCounter);
146
+        if (isset($this->uuid) && isset($this->uuidNewCounter)) {
147
+                    return StateManager::BuildStateKey($this->uuid, $this->uuidNewCounter);
148
+        }
147 149
 
148 150
         return false;
149 151
     }
@@ -186,14 +188,17 @@  discard block
 block discarded – undo
186 188
      * @return boolean
187 189
      */
188 190
     public function RemoveSyncKey() {
189
-        if (isset($this->uuid))
190
-            unset($this->uuid);
191
+        if (isset($this->uuid)) {
192
+                    unset($this->uuid);
193
+        }
191 194
 
192
-        if (isset($this->uuidCounter))
193
-            unset($this->uuidCounter);
195
+        if (isset($this->uuidCounter)) {
196
+                    unset($this->uuidCounter);
197
+        }
194 198
 
195
-        if (isset($this->uuidNewCounter))
196
-            unset($this->uuidNewCounter);
199
+        if (isset($this->uuidNewCounter)) {
200
+                    unset($this->uuidNewCounter);
201
+        }
197 202
 
198 203
         ZLog::Write(LOGLEVEL_DEBUG, "SyncParameters->RemoveSyncKey(): saved sync key removed");
199 204
         return true;
@@ -208,8 +213,7 @@  discard block
 block discarded – undo
208 213
     public function GetBackendFolderId() {
209 214
         if ($this->backendfolderid) {
210 215
             return $this->backendfolderid;
211
-        }
212
-        else {
216
+        } else {
213 217
             return $this->GetFolderId();
214 218
         }
215 219
     }
@@ -295,8 +299,7 @@  discard block
 block discarded – undo
295 299
         // if the backend returned false as folderstat, we have to run the exporter
296 300
         if ($currentFolderStat === false || $this->confirmationChanged)  {
297 301
             $run = true;
298
-        }
299
-        else {
302
+        } else {
300 303
             // check if the folderstat differs from the saved one or expired
301 304
             $run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout());
302 305
         }
@@ -344,8 +347,9 @@  discard block
 block discarded – undo
344 347
                         $options !== self::CONTACTOPTIONS &&
345 348
                         $options !== self::NOTEOPTIONS &&
346 349
                         $options !== self::TASKOPTIONS &&
347
-                        $options !== self::SMSOPTIONS)
348
-            throw new FatalNotImplementedException(sprintf("SyncParameters->isAllowedType('%s') ContentParameters is invalid. Such type is not available.", $options));
350
+                        $options !== self::SMSOPTIONS) {
351
+                     throw new FatalNotImplementedException(sprintf("SyncParameters->isAllowedType('%s') ContentParameters is invalid. Such type is not available.", $options));
352
+         }
349 353
 
350 354
         return true;
351 355
     }
@@ -362,23 +366,25 @@  discard block
 block discarded – undo
362 366
      */
363 367
      private function normalizeType($options) {
364 368
         // return the requested CPO as it is defined
365
-        if (isset($this->contentParameters[$options]))
366
-            return $options;
369
+        if (isset($this->contentParameters[$options])) {
370
+                    return $options;
371
+        }
367 372
 
368 373
         $returnCPO = $options;
369 374
         // return email, calendar, contact or note CPO as default CPO if there no explicit default CPO defined
370 375
         if ($options == self::DEFAULTOPTIONS && !isset($this->contentParameters[self::DEFAULTOPTIONS])) {
371 376
 
372
-            if (isset($this->contentParameters[self::EMAILOPTIONS]))
373
-                $returnCPO = self::EMAILOPTIONS;
374
-            elseif (isset($this->contentParameters[self::CALENDAROPTIONS]))
375
-                $returnCPO = self::CALENDAROPTIONS;
376
-            elseif (isset($this->contentParameters[self::CONTACTOPTIONS]))
377
-                $returnCPO = self::CONTACTOPTIONS;
378
-            elseif (isset($this->contentParameters[self::NOTEOPTIONS]))
379
-                $returnCPO = self::NOTEOPTIONS;
380
-            elseif (isset($this->contentParameters[self::TASKOPTIONS]))
381
-                $returnCPO = self::TASKOPTIONS;
377
+            if (isset($this->contentParameters[self::EMAILOPTIONS])) {
378
+                            $returnCPO = self::EMAILOPTIONS;
379
+            } elseif (isset($this->contentParameters[self::CALENDAROPTIONS])) {
380
+                            $returnCPO = self::CALENDAROPTIONS;
381
+            } elseif (isset($this->contentParameters[self::CONTACTOPTIONS])) {
382
+                            $returnCPO = self::CONTACTOPTIONS;
383
+            } elseif (isset($this->contentParameters[self::NOTEOPTIONS])) {
384
+                            $returnCPO = self::NOTEOPTIONS;
385
+            } elseif (isset($this->contentParameters[self::TASKOPTIONS])) {
386
+                            $returnCPO = self::TASKOPTIONS;
387
+            }
382 388
 
383 389
             return $returnCPO;
384 390
         }
Please login to merge, or discard this patch.
lib/core/synccollections.php 1 patch
Braces   +122 added lines, -97 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
60 60
                 }
61 61
             }
62 62
             return true;
63
-        }
64
-        catch (ZPushException $e) {}
63
+        } catch (ZPushException $e) {}
65 64
         return false;
66 65
     }
67 66
 
@@ -109,20 +108,24 @@  discard block
 block discarded – undo
109 108
 
110 109
         $invalidStates = false;
111 110
         foreach($this->stateManager->GetSynchedFolders() as $folderid) {
112
-            if ($overwriteLoaded === false && isset($this->collections[$folderid]))
113
-                continue;
111
+            if ($overwriteLoaded === false && isset($this->collections[$folderid])) {
112
+                            continue;
113
+            }
114 114
 
115 115
             // Load Collection!
116
-            if (! $this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly))
117
-                $invalidStates = true;
116
+            if (! $this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) {
117
+                            $invalidStates = true;
118
+            }
118 119
         }
119 120
 
120 121
         // load the hierarchy data - there are no permissions to verify so we just set it to false
121
-        if ($loadHierarchy && !$this->LoadCollection(false, $loadState, false, false))
122
-            throw new StatusException("Invalid states found while loading hierarchy data. Forcing hierarchy sync");
122
+        if ($loadHierarchy && !$this->LoadCollection(false, $loadState, false, false)) {
123
+                    throw new StatusException("Invalid states found while loading hierarchy data. Forcing hierarchy sync");
124
+        }
123 125
 
124
-        if ($invalidStates)
125
-            throw new StateInvalidException("Invalid states found while loading collections. Forcing sync");
126
+        if ($invalidStates) {
127
+                    throw new StateInvalidException("Invalid states found while loading collections. Forcing sync");
128
+        }
126 129
 
127 130
         return true;
128 131
     }
@@ -159,8 +162,7 @@  discard block
 block discarded – undo
159 162
                 ZLog::Write(LOGLEVEL_DEBUG, "SyncCollections->LoadCollection(): Found collection with move state only, ignoring.");
160 163
                 return true;
161 164
             }
162
-        }
163
-        catch (StateInvalidException $sive) {
165
+        } catch (StateInvalidException $sive) {
164 166
             // in case there is something wrong with the state, just stop here
165 167
             // later when trying to retrieve the SyncParameters nothing will be found
166 168
 
@@ -175,8 +177,9 @@  discard block
 block discarded – undo
175 177
         }
176 178
 
177 179
         // if this is an additional folder the backend has to be setup correctly
178
-        if ($checkPermissions === true && ! ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId())))
179
-            throw new StatusException(sprintf("SyncCollections->LoadCollection(): could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), self::ERROR_WRONG_HIERARCHY);
180
+        if ($checkPermissions === true && ! ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) {
181
+                    throw new StatusException(sprintf("SyncCollections->LoadCollection(): could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), self::ERROR_WRONG_HIERARCHY);
182
+        }
180 183
 
181 184
         // add collection to object
182 185
         $addStatus = $this->AddCollection($spa);
@@ -186,8 +189,7 @@  discard block
 block discarded – undo
186 189
             try {
187 190
                 // make sure the hierarchy cache is loaded when we are loading hierarchy states
188 191
                 $this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey($confirmedOnly), ($folderid === false));
189
-            }
190
-            catch (StateNotFoundException $snfe) {
192
+            } catch (StateNotFoundException $snfe) {
191 193
                 // if we can't find the state, first we should try a sync of that folder, so
192 194
                 // we generate a fake change, so a sync on this folder is triggered
193 195
                 $this->changes[$folderid] = 1;
@@ -211,20 +213,23 @@  discard block
 block discarded – undo
211 213
      * @return boolean
212 214
      */
213 215
     public function SaveCollection($spa) {
214
-        if (! $this->saveData || !$spa->HasFolderId())
215
-            return false;
216
+        if (! $this->saveData || !$spa->HasFolderId()) {
217
+                    return false;
218
+        }
216 219
 
217 220
         if ($spa->IsDataChanged()) {
218 221
             $this->loadStateManager();
219 222
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->SaveCollection(): Data of folder '%s' changed", $spa->GetFolderId()));
220 223
 
221 224
             // save new windowsize
222
-            if (isset($this->globalWindowSize))
223
-                $spa->SetWindowSize($this->globalWindowSize);
225
+            if (isset($this->globalWindowSize)) {
226
+                            $spa->SetWindowSize($this->globalWindowSize);
227
+            }
224 228
 
225 229
             // update latest lifetime
226
-            if (isset($this->refLifetime))
227
-                $spa->SetReferenceLifetime($this->refLifetime);
230
+            if (isset($this->refLifetime)) {
231
+                            $spa->SetReferenceLifetime($this->refLifetime);
232
+            }
228 233
 
229 234
             return $this->stateManager->SetSynchedFolderState($spa);
230 235
         }
@@ -240,8 +245,9 @@  discard block
 block discarded – undo
240 245
      * @return boolean
241 246
      */
242 247
     public function AddCollection($spa) {
243
-        if (! $spa->HasFolderId())
244
-            return false;
248
+        if (! $spa->HasFolderId()) {
249
+                    return false;
250
+        }
245 251
 
246 252
         $this->collections[$spa->GetFolderId()] = $spa;
247 253
 
@@ -250,12 +256,14 @@  discard block
 block discarded – undo
250 256
             $this->lastSyncTime = $spa->GetLastSyncTime();
251 257
 
252 258
             // use SyncParameters PolicyKey as reference if available
253
-            if ($spa->HasReferencePolicyKey())
254
-                $this->refPolicyKey = $spa->GetReferencePolicyKey();
259
+            if ($spa->HasReferencePolicyKey()) {
260
+                            $this->refPolicyKey = $spa->GetReferencePolicyKey();
261
+            }
255 262
 
256 263
             // use SyncParameters LifeTime as reference if available
257
-            if ($spa->HasReferenceLifetime())
258
-                $this->refLifetime = $spa->GetReferenceLifetime();
264
+            if ($spa->HasReferenceLifetime()) {
265
+                            $this->refLifetime = $spa->GetReferenceLifetime();
266
+            }
259 267
 
260 268
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->AddCollection(): Updated reference PolicyKey '%s', reference Lifetime '%s', Last sync at '%s'", $this->refPolicyKey, $this->refLifetime, $this->lastSyncTime));
261 269
         }
@@ -272,10 +280,11 @@  discard block
 block discarded – undo
272 280
      * @return SyncParameters / boolean      false if no SyncParameters object is found for folderid
273 281
      */
274 282
     public function GetCollection($folderid) {
275
-        if (isset($this->collections[$folderid]))
276
-            return $this->collections[$folderid];
277
-        else
278
-            return false;
283
+        if (isset($this->collections[$folderid])) {
284
+                    return $this->collections[$folderid];
285
+        } else {
286
+                    return false;
287
+        }
279 288
     }
280 289
 
281 290
     /**
@@ -309,12 +318,14 @@  discard block
 block discarded – undo
309 318
      * @return boolean
310 319
      */
311 320
     public function AddParameter($spa, $key, $value) {
312
-        if (!$spa->HasFolderId())
313
-            return false;
321
+        if (!$spa->HasFolderId()) {
322
+                    return false;
323
+        }
314 324
 
315 325
         $folderid = $spa->GetFolderId();
316
-        if (!isset($this->addparms[$folderid]))
317
-            $this->addparms[$folderid] = array();
326
+        if (!isset($this->addparms[$folderid])) {
327
+                    $this->addparms[$folderid] = array();
328
+        }
318 329
 
319 330
         $this->addparms[$folderid][$key] = $value;
320 331
         return true;
@@ -330,13 +341,15 @@  discard block
 block discarded – undo
330 341
      * @return mixed            returns 'null' if nothing set
331 342
      */
332 343
     public function GetParameter($spa, $key) {
333
-        if (!$spa->HasFolderId())
334
-            return null;
344
+        if (!$spa->HasFolderId()) {
345
+                    return null;
346
+        }
335 347
 
336
-        if (isset($this->addparms[$spa->GetFolderId()]) && isset($this->addparms[$spa->GetFolderId()][$key]))
337
-            return $this->addparms[$spa->GetFolderId()][$key];
338
-        else
339
-            return null;
348
+        if (isset($this->addparms[$spa->GetFolderId()]) && isset($this->addparms[$spa->GetFolderId()][$key])) {
349
+                    return $this->addparms[$spa->GetFolderId()][$key];
350
+        } else {
351
+                    return null;
352
+        }
340 353
     }
341 354
 
342 355
     /**
@@ -375,8 +388,7 @@  discard block
 block discarded – undo
375 388
         // take the requested global windowsize or the max 512 if not defined
376 389
         if (isset($this->globalWindowSize)) {
377 390
             $globalWindowSize = $this->globalWindowSize;
378
-        }
379
-        else {
391
+        } else {
380 392
             $globalWindowSize = WINDOW_SIZE_MAX; // 512 by default
381 393
         }
382 394
 
@@ -452,28 +464,31 @@  discard block
 block discarded – undo
452 464
     public function CheckForChanges($lifetime = 600, $interval = 30, $onlyPingable = false) {
453 465
         $classes = array();
454 466
         foreach ($this->collections as $folderid => $spa){
455
-            if ($onlyPingable && $spa->GetPingableFlag() !== true || ! $folderid)
456
-                continue;
467
+            if ($onlyPingable && $spa->GetPingableFlag() !== true || ! $folderid) {
468
+                            continue;
469
+            }
457 470
 
458 471
             $class = $this->getPingClass($spa);
459 472
 
460
-            if (!isset($classes[$class]))
461
-                $classes[$class] = 0;
473
+            if (!isset($classes[$class])) {
474
+                            $classes[$class] = 0;
475
+            }
462 476
             $classes[$class] += 1;
463 477
         }
464
-        if (empty($classes))
465
-            $checkClasses = "policies only";
466
-        else if (array_sum($classes) > 4) {
478
+        if (empty($classes)) {
479
+                    $checkClasses = "policies only";
480
+        } else if (array_sum($classes) > 4) {
467 481
             $checkClasses = "";
468 482
             foreach($classes as $class=>$count) {
469
-                if ($count == 1)
470
-                    $checkClasses .= sprintf("%s ", $class);
471
-                else
472
-                    $checkClasses .= sprintf("%s(%d) ", $class, $count);
483
+                if ($count == 1) {
484
+                                    $checkClasses .= sprintf("%s ", $class);
485
+                } else {
486
+                                    $checkClasses .= sprintf("%s(%d) ", $class, $count);
487
+                }
473 488
             }
489
+        } else {
490
+                    $checkClasses = implode(" ", array_keys($classes));
474 491
         }
475
-        else
476
-            $checkClasses = implode(" ", array_keys($classes));
477 492
 
478 493
         $pingTracking = new PingTracking();
479 494
         $this->changes = array();
@@ -489,8 +504,9 @@  discard block
 block discarded – undo
489 504
         if (!empty($classes)) {
490 505
             // initialize all possible folders
491 506
             foreach ($this->collections as $folderid => $spa) {
492
-                if (($onlyPingable && $spa->GetPingableFlag() !== true) || ! $folderid)
493
-                    continue;
507
+                if (($onlyPingable && $spa->GetPingableFlag() !== true) || ! $folderid) {
508
+                                    continue;
509
+                }
494 510
 
495 511
                 $backendFolderId = $spa->GetBackendFolderId();
496 512
 
@@ -500,8 +516,9 @@  discard block
 block discarded – undo
500 516
                 // initialize sink if no immediate changes were found so far
501 517
                 if ($changesSink && empty($this->changes)) {
502 518
                     ZPush::GetBackend()->Setup($store);
503
-                    if (! ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId))
504
-                        throw new StatusException(sprintf("Error initializing ChangesSink for folder id %s/%s", $folderid, $backendFolderId), self::ERROR_WRONG_HIERARCHY);
519
+                    if (! ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) {
520
+                                            throw new StatusException(sprintf("Error initializing ChangesSink for folder id %s/%s", $folderid, $backendFolderId), self::ERROR_WRONG_HIERARCHY);
521
+                    }
505 522
                 }
506 523
 
507 524
                 // check if the folder stat changed since the last sync, if so generate a change for it (only on first run)
@@ -533,18 +550,21 @@  discard block
 block discarded – undo
533 550
 
534 551
             $nextInterval = $interval;
535 552
             // we should not block longer than the lifetime
536
-            if ($endat - $now < $nextInterval)
537
-                $nextInterval = $endat - $now;
553
+            if ($endat - $now < $nextInterval) {
554
+                            $nextInterval = $endat - $now;
555
+            }
538 556
 
539 557
             // Check if provisioning is necessary
540 558
             // if a PolicyKey was sent use it. If not, compare with the ReferencePolicyKey
541
-            if (PROVISIONING === true && $policyKey !== false && ZPush::GetProvisioningManager()->ProvisioningRequired($policyKey, true, false))
542
-                // the hierarchysync forces provisioning
559
+            if (PROVISIONING === true && $policyKey !== false && ZPush::GetProvisioningManager()->ProvisioningRequired($policyKey, true, false)) {
560
+                            // the hierarchysync forces provisioning
543 561
                 throw new StatusException("SyncCollections->CheckForChanges(): Policies or PolicyKey changed. Provisioning required.", self::ERROR_WRONG_HIERARCHY);
562
+            }
544 563
 
545 564
             // Check if a hierarchy sync is necessary
546
-            if ($this->countHierarchyChange())
547
-                throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED);
565
+            if ($this->countHierarchyChange()) {
566
+                            throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED);
567
+            }
548 568
 
549 569
             // Check if there are newer requests
550 570
             // If so, this process should be terminated if more than 60 secs to go
@@ -577,8 +597,7 @@  discard block
 block discarded – undo
577 597
                         if ($this->countHierarchyChange(true)) {
578 598
                             throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED);
579 599
                         }
580
-                    }
581
-                    else {
600
+                    } else {
582 601
                         // the backend will notify on the backend folderid
583 602
                         $folderid = ZPush::GetDeviceManager()->GetFolderIdForBackendId($backendFolderId);
584 603
 
@@ -587,14 +606,14 @@  discard block
 block discarded – undo
587 606
                             ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s'", $folderid));
588 607
                             $validNotifications = true;
589 608
                             $this->waitingTime = time()-$started;
590
-                        }
591
-                        else {
609
+                        } else {
592 610
                             ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s', but it is not relevant", $folderid));
593 611
                         }
594 612
                     }
595 613
                 }
596
-                if ($validNotifications)
597
-                    return true;
614
+                if ($validNotifications) {
615
+                                    return true;
616
+                }
598 617
             }
599 618
             // use polling mechanism
600 619
             else {
@@ -602,8 +621,7 @@  discard block
 block discarded – undo
602 621
                 if ($this->CountChanges($onlyPingable)) {
603 622
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Found changes polling"));
604 623
                     return true;
605
-                }
606
-                else {
624
+                } else {
607 625
                     sleep($nextInterval);
608 626
                 }
609 627
             } // end polling
@@ -625,14 +643,17 @@  discard block
 block discarded – undo
625 643
     public function CountChanges($onlyPingable = false) {
626 644
         $changesAvailable = false;
627 645
         foreach ($this->collections as $folderid => $spa) {
628
-            if ($onlyPingable && $spa->GetPingableFlag() !== true)
629
-                continue;
646
+            if ($onlyPingable && $spa->GetPingableFlag() !== true) {
647
+                            continue;
648
+            }
630 649
 
631
-            if (isset($this->addparms[$spa->GetFolderId()]["status"]) && $this->addparms[$spa->GetFolderId()]["status"] != SYNC_STATUS_SUCCESS)
632
-                continue;
650
+            if (isset($this->addparms[$spa->GetFolderId()]["status"]) && $this->addparms[$spa->GetFolderId()]["status"] != SYNC_STATUS_SUCCESS) {
651
+                            continue;
652
+            }
633 653
 
634
-            if ($this->CountChange($folderid))
635
-                $changesAvailable = true;
654
+            if ($this->CountChange($folderid)) {
655
+                            $changesAvailable = true;
656
+            }
636 657
         }
637 658
 
638 659
         return $changesAvailable;
@@ -667,11 +688,11 @@  discard block
 block discarded – undo
667 688
                 $exporter->ConfigContentParameters($spa->GetCPO());
668 689
                 $ret = $exporter->InitializeExporter($importer);
669 690
 
670
-                if ($ret !== false)
671
-                    $changecount = $exporter->GetChangeCount();
691
+                if ($ret !== false) {
692
+                                    $changecount = $exporter->GetChangeCount();
693
+                }
672 694
             }
673
-        }
674
-        catch (StatusException $ste) {
695
+        } catch (StatusException $ste) {
675 696
             if ($ste->getCode() == SYNC_STATUS_FOLDERHIERARCHYCHANGED) {
676 697
                 ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): exporter can not be re-configured due to state error, emulating change in folder to force Sync.");
677 698
                 $this->changes[$folderid] = 1;
@@ -684,8 +705,9 @@  discard block
 block discarded – undo
684 705
         }
685 706
 
686 707
         // start over if exporter can not be configured atm
687
-        if ($changecount === false)
688
-            ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): no changes received from Exporter.");
708
+        if ($changecount === false) {
709
+                    ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): no changes received from Exporter.");
710
+        }
689 711
 
690 712
         $this->changes[$folderid] = $changecount;
691 713
 
@@ -714,8 +736,9 @@  discard block
 block discarded – undo
714 736
          if ($exportChanges || $this->hierarchyExporterChecked === false) {
715 737
              try {
716 738
                  // if this is a validation (not first run), make sure to load the hierarchy data again
717
-                 if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false))
718
-                     throw new StatusException("Invalid states found while re-loading hierarchy data.");
739
+                 if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false)) {
740
+                                      throw new StatusException("Invalid states found while re-loading hierarchy data.");
741
+                 }
719 742
 
720 743
 
721 744
                  $changesMem = ZPush::GetDeviceManager()->GetHierarchyChangesWrapper();
@@ -730,19 +753,20 @@  discard block
 block discarded – undo
730 753
                      $ret = $exporter->InitializeExporter($changesMem);
731 754
                      while(is_array($exporter->Synchronize()));
732 755
 
733
-                     if ($ret !== false)
734
-                         $changecount = $changesMem->GetChangeCount();
756
+                     if ($ret !== false) {
757
+                                              $changecount = $changesMem->GetChangeCount();
758
+                     }
735 759
 
736 760
                      $this->hierarchyExporterChecked = true;
737 761
                  }
738
-             }
739
-             catch (StatusException $ste) {
762
+             } catch (StatusException $ste) {
740 763
                  throw new StatusException("SyncCollections->countHierarchyChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN);
741 764
              }
742 765
 
743 766
              // start over if exporter can not be configured atm
744
-             if ($changecount === false )
745
-                 ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter.");
767
+             if ($changecount === false ) {
768
+                              ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter.");
769
+             }
746 770
          }
747 771
          return ($changecount > 0);
748 772
      }
@@ -874,8 +898,9 @@  discard block
 block discarded – undo
874 898
      * @return
875 899
      */
876 900
      private function loadStateManager() {
877
-         if (!isset($this->stateManager))
878
-            $this->stateManager = ZPush::GetDeviceManager()->GetStateManager();
901
+         if (!isset($this->stateManager)) {
902
+                     $this->stateManager = ZPush::GetDeviceManager()->GetStateManager();
903
+         }
879 904
      }
880 905
 
881 906
      /**
Please login to merge, or discard this patch.