@@ -49,38 +49,38 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | function __construct() { |
| 51 | 51 | $mapping = array( |
| 52 | - SYNC_POOMCAL_TIMEZONE => array ( self::STREAMER_VAR => "timezone", |
|
| 52 | + SYNC_POOMCAL_TIMEZONE => array(self::STREAMER_VAR => "timezone", |
|
| 53 | 53 | self::STREAMER_RONOTIFY => true), |
| 54 | 54 | |
| 55 | - SYNC_POOMCAL_DTSTAMP => array ( self::STREAMER_VAR => "dtstamp", |
|
| 55 | + SYNC_POOMCAL_DTSTAMP => array(self::STREAMER_VAR => "dtstamp", |
|
| 56 | 56 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
| 57 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO)), |
|
| 57 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO)), |
|
| 58 | 58 | |
| 59 | - SYNC_POOMCAL_STARTTIME => array ( self::STREAMER_VAR => "starttime", |
|
| 59 | + SYNC_POOMCAL_STARTTIME => array(self::STREAMER_VAR => "starttime", |
|
| 60 | 60 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
| 61 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPLOWER => SYNC_POOMCAL_ENDTIME ), |
|
| 62 | - self::STREAMER_RONOTIFY => true ), |
|
| 61 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPLOWER => SYNC_POOMCAL_ENDTIME), |
|
| 62 | + self::STREAMER_RONOTIFY => true), |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | - SYNC_POOMCAL_SUBJECT => array ( self::STREAMER_VAR => "subject", |
|
| 66 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETEMPTY), |
|
| 65 | + SYNC_POOMCAL_SUBJECT => array(self::STREAMER_VAR => "subject", |
|
| 66 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETEMPTY), |
|
| 67 | 67 | self::STREAMER_RONOTIFY => true, |
| 68 | - self::STREAMER_PRIVATE => self::STRIP_PRIVATE_SUBSTITUTE ), |
|
| 69 | - |
|
| 70 | - SYNC_POOMCAL_UID => array ( self::STREAMER_VAR => "uid"), |
|
| 71 | - SYNC_POOMCAL_ORGANIZERNAME => array ( self::STREAMER_VAR => "organizername", // verified below |
|
| 72 | - self::STREAMER_PRIVATE => 'Undisclosed Organizer' ), |
|
| 73 | - SYNC_POOMCAL_ORGANIZEREMAIL => array ( self::STREAMER_VAR => "organizeremail", // verified below |
|
| 74 | - self::STREAMER_PRIVATE => 'undisclosed@localhost' ), |
|
| 75 | - SYNC_POOMCAL_LOCATION => array ( self::STREAMER_VAR => "location", |
|
| 68 | + self::STREAMER_PRIVATE => self::STRIP_PRIVATE_SUBSTITUTE), |
|
| 69 | + |
|
| 70 | + SYNC_POOMCAL_UID => array(self::STREAMER_VAR => "uid"), |
|
| 71 | + SYNC_POOMCAL_ORGANIZERNAME => array(self::STREAMER_VAR => "organizername", // verified below |
|
| 72 | + self::STREAMER_PRIVATE => 'Undisclosed Organizer'), |
|
| 73 | + SYNC_POOMCAL_ORGANIZEREMAIL => array(self::STREAMER_VAR => "organizeremail", // verified below |
|
| 74 | + self::STREAMER_PRIVATE => 'undisclosed@localhost'), |
|
| 75 | + SYNC_POOMCAL_LOCATION => array(self::STREAMER_VAR => "location", |
|
| 76 | 76 | self::STREAMER_RONOTIFY => true, |
| 77 | 77 | self::STREAMER_PRIVATE => true), |
| 78 | - SYNC_POOMCAL_ENDTIME => array ( self::STREAMER_VAR => "endtime", |
|
| 78 | + SYNC_POOMCAL_ENDTIME => array(self::STREAMER_VAR => "endtime", |
|
| 79 | 79 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
| 80 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => SYNC_POOMCAL_STARTTIME ), |
|
| 81 | - self::STREAMER_RONOTIFY => true ), |
|
| 80 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => SYNC_POOMCAL_STARTTIME), |
|
| 81 | + self::STREAMER_RONOTIFY => true), |
|
| 82 | 82 | |
| 83 | - SYNC_POOMCAL_RECURRENCE => array ( self::STREAMER_VAR => "recurrence", |
|
| 83 | + SYNC_POOMCAL_RECURRENCE => array(self::STREAMER_VAR => "recurrence", |
|
| 84 | 84 | self::STREAMER_TYPE => "SyncRecurrence", |
| 85 | 85 | self::STREAMER_RONOTIFY => true), |
| 86 | 86 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | // 1 = Personal |
| 90 | 90 | // 2 = Private |
| 91 | 91 | // 3 = Confident |
| 92 | - SYNC_POOMCAL_SENSITIVITY => array ( self::STREAMER_VAR => "sensitivity", |
|
| 93 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) ), |
|
| 92 | + SYNC_POOMCAL_SENSITIVITY => array(self::STREAMER_VAR => "sensitivity", |
|
| 93 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2, 3)), |
|
| 94 | 94 | self::STREAMER_RONOTIFY => true, |
| 95 | - self::STREAMER_VALUEMAP => array( 0 => "Normal", |
|
| 95 | + self::STREAMER_VALUEMAP => array(0 => "Normal", |
|
| 96 | 96 | 1 => "Personal", |
| 97 | 97 | 2 => "Private", |
| 98 | 98 | 3 => "Confident")), |
@@ -103,29 +103,29 @@ discard block |
||
| 103 | 103 | // 2 = Busy |
| 104 | 104 | // 3 = Out of office |
| 105 | 105 | // 4 = Working Elsewhere |
| 106 | - SYNC_POOMCAL_BUSYSTATUS => array ( self::STREAMER_VAR => "busystatus", |
|
| 107 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, |
|
| 108 | - self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,4) ), |
|
| 106 | + SYNC_POOMCAL_BUSYSTATUS => array(self::STREAMER_VAR => "busystatus", |
|
| 107 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, |
|
| 108 | + self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2, 3, 4)), |
|
| 109 | 109 | self::STREAMER_RONOTIFY => true, |
| 110 | - self::STREAMER_PRIVATE => 2, // if private is stripped, value will be set to 2 (busy) |
|
| 111 | - self::STREAMER_VALUEMAP => array( 0 => "Free", |
|
| 110 | + self::STREAMER_PRIVATE => 2, // if private is stripped, value will be set to 2 (busy) |
|
| 111 | + self::STREAMER_VALUEMAP => array(0 => "Free", |
|
| 112 | 112 | 1 => "Tentative", |
| 113 | 113 | 2 => "Busy", |
| 114 | 114 | 3 => "Out of office", |
| 115 | 115 | 4 => "Working Elsewhere")), |
| 116 | 116 | |
| 117 | - SYNC_POOMCAL_ALLDAYEVENT => array ( self::STREAMER_VAR => "alldayevent", |
|
| 118 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO), |
|
| 117 | + SYNC_POOMCAL_ALLDAYEVENT => array(self::STREAMER_VAR => "alldayevent", |
|
| 118 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO), |
|
| 119 | 119 | self::STREAMER_RONOTIFY => true, |
| 120 | - self::STREAMER_VALUEMAP => array( 0 => "No", |
|
| 120 | + self::STREAMER_VALUEMAP => array(0 => "No", |
|
| 121 | 121 | 1 => "Yes")), |
| 122 | 122 | |
| 123 | - SYNC_POOMCAL_REMINDER => array ( self::STREAMER_VAR => "reminder", |
|
| 124 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1), |
|
| 123 | + SYNC_POOMCAL_REMINDER => array(self::STREAMER_VAR => "reminder", |
|
| 124 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -1), |
|
| 125 | 125 | self::STREAMER_RONOTIFY => true, |
| 126 | - self::STREAMER_PRIVATE => true ), // if private is stripped, value will be unset (no reminder) |
|
| 126 | + self::STREAMER_PRIVATE => true), // if private is stripped, value will be unset (no reminder) |
|
| 127 | 127 | |
| 128 | - SYNC_POOMCAL_RTF => array ( self::STREAMER_VAR => "rtf", |
|
| 128 | + SYNC_POOMCAL_RTF => array(self::STREAMER_VAR => "rtf", |
|
| 129 | 129 | self::STREAMER_PRIVATE => true), |
| 130 | 130 | |
| 131 | 131 | // Meetingstatus values |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | // 11 = as 3 |
| 139 | 139 | // 13 = as 5 |
| 140 | 140 | // 15 = as 7 |
| 141 | - SYNC_POOMCAL_MEETINGSTATUS => array ( self::STREAMER_VAR => "meetingstatus", |
|
| 142 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,3,5,7,9,11,13,15) ), |
|
| 141 | + SYNC_POOMCAL_MEETINGSTATUS => array(self::STREAMER_VAR => "meetingstatus", |
|
| 142 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 3, 5, 7, 9, 11, 13, 15)), |
|
| 143 | 143 | self::STREAMER_RONOTIFY => true, |
| 144 | - self::STREAMER_VALUEMAP => array( 0 => "Not a meeting", |
|
| 144 | + self::STREAMER_VALUEMAP => array(0 => "Not a meeting", |
|
| 145 | 145 | 1 => "Meeting", |
| 146 | 146 | 3 => "Meeting received", |
| 147 | 147 | 5 => "Meeting canceled", |
@@ -151,55 +151,55 @@ discard block |
||
| 151 | 151 | 13 => "Meeting canceled", |
| 152 | 152 | 15 => "Meeting canceled and received",)), |
| 153 | 153 | |
| 154 | - SYNC_POOMCAL_ATTENDEES => array ( self::STREAMER_VAR => "attendees", |
|
| 154 | + SYNC_POOMCAL_ATTENDEES => array(self::STREAMER_VAR => "attendees", |
|
| 155 | 155 | self::STREAMER_TYPE => "SyncAttendee", |
| 156 | 156 | self::STREAMER_ARRAY => SYNC_POOMCAL_ATTENDEE, |
| 157 | 157 | self::STREAMER_RONOTIFY => true, |
| 158 | 158 | self::STREAMER_PRIVATE => true), |
| 159 | 159 | |
| 160 | - SYNC_POOMCAL_BODY => array ( self::STREAMER_VAR => "body", |
|
| 160 | + SYNC_POOMCAL_BODY => array(self::STREAMER_VAR => "body", |
|
| 161 | 161 | self::STREAMER_RONOTIFY => true, |
| 162 | 162 | self::STREAMER_PRIVATE => true), |
| 163 | - SYNC_POOMCAL_BODYTRUNCATED => array ( self::STREAMER_VAR => "bodytruncated", |
|
| 163 | + SYNC_POOMCAL_BODYTRUNCATED => array(self::STREAMER_VAR => "bodytruncated", |
|
| 164 | 164 | self::STREAMER_PRIVATE => true), |
| 165 | - SYNC_POOMCAL_EXCEPTIONS => array ( self::STREAMER_VAR => "exceptions", |
|
| 165 | + SYNC_POOMCAL_EXCEPTIONS => array(self::STREAMER_VAR => "exceptions", |
|
| 166 | 166 | self::STREAMER_TYPE => "SyncAppointmentException", |
| 167 | 167 | self::STREAMER_ARRAY => SYNC_POOMCAL_EXCEPTION, |
| 168 | 168 | self::STREAMER_RONOTIFY => true), |
| 169 | 169 | |
| 170 | - SYNC_POOMCAL_CATEGORIES => array ( self::STREAMER_VAR => "categories", |
|
| 170 | + SYNC_POOMCAL_CATEGORIES => array(self::STREAMER_VAR => "categories", |
|
| 171 | 171 | self::STREAMER_ARRAY => SYNC_POOMCAL_CATEGORY, |
| 172 | 172 | self::STREAMER_RONOTIFY => true, |
| 173 | 173 | self::STREAMER_PRIVATE => true), |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | 176 | if (Request::GetProtocolVersion() >= 12.0) { |
| 177 | - $mapping[SYNC_AIRSYNCBASE_BODY] = array ( self::STREAMER_VAR => "asbody", |
|
| 177 | + $mapping[SYNC_AIRSYNCBASE_BODY] = array(self::STREAMER_VAR => "asbody", |
|
| 178 | 178 | self::STREAMER_TYPE => "SyncBaseBody", |
| 179 | 179 | self::STREAMER_RONOTIFY => true, |
| 180 | 180 | self::STREAMER_PRIVATE => true |
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | - $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = array ( self::STREAMER_VAR => "nativebodytype"); |
|
| 183 | + $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = array(self::STREAMER_VAR => "nativebodytype"); |
|
| 184 | 184 | |
| 185 | 185 | //unset these properties because airsyncbase body and attachments will be used instead |
| 186 | 186 | unset($mapping[SYNC_POOMCAL_BODY], $mapping[SYNC_POOMCAL_BODYTRUNCATED]); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(Request::GetProtocolVersion() >= 14.0) { |
|
| 190 | - $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL] = array ( self::STREAMER_VAR => "disallownewtimeprop", |
|
| 189 | + if (Request::GetProtocolVersion() >= 14.0) { |
|
| 190 | + $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL] = array(self::STREAMER_VAR => "disallownewtimeprop", |
|
| 191 | 191 | self::STREAMER_RONOTIFY => true, |
| 192 | 192 | self::STREAMER_PRIVATE => 1); // don't permit new time proposal |
| 193 | - $mapping[SYNC_POOMCAL_RESPONSEREQUESTED] = array ( self::STREAMER_VAR => "responserequested", |
|
| 193 | + $mapping[SYNC_POOMCAL_RESPONSEREQUESTED] = array(self::STREAMER_VAR => "responserequested", |
|
| 194 | 194 | self::STREAMER_RONOTIFY => true); |
| 195 | - $mapping[SYNC_POOMCAL_RESPONSETYPE] = array ( self::STREAMER_VAR => "responsetype", |
|
| 195 | + $mapping[SYNC_POOMCAL_RESPONSETYPE] = array(self::STREAMER_VAR => "responsetype", |
|
| 196 | 196 | self::STREAMER_RONOTIFY => true); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if(Request::GetProtocolVersion() >= 14.1) { |
|
| 200 | - $mapping[SYNC_POOMCAL_ONLINEMEETINGCONFLINK] = array ( self::STREAMER_VAR => "onlineMeetingConfLink", |
|
| 199 | + if (Request::GetProtocolVersion() >= 14.1) { |
|
| 200 | + $mapping[SYNC_POOMCAL_ONLINEMEETINGCONFLINK] = array(self::STREAMER_VAR => "onlineMeetingConfLink", |
|
| 201 | 201 | self::STREAMER_RONOTIFY => true); |
| 202 | - $mapping[SYNC_POOMCAL_ONLINEMEETINGEXTERNALLINK] = array ( self::STREAMER_VAR => "onlineMeetingExternalLink", |
|
| 202 | + $mapping[SYNC_POOMCAL_ONLINEMEETINGEXTERNALLINK] = array(self::STREAMER_VAR => "onlineMeetingExternalLink", |
|
| 203 | 203 | self::STREAMER_RONOTIFY => true); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // we should never forward this changes to a backend |
| 51 | 51 | if (!isset($this->destinationImporter)) { |
| 52 | - foreach($state as $addKey => $addFolder) { |
|
| 52 | + foreach ($state as $addKey => $addFolder) { |
|
| 53 | 53 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : process folder '%s'", $addFolder->displayname)); |
| 54 | 54 | if (isset($addFolder->NoBackendFolder) && $addFolder->NoBackendFolder == true) { |
| 55 | 55 | // check rights for readonly access only |
| 56 | 56 | $hasRights = ZPush::GetBackend()->Setup($addFolder->Store, true, $addFolder->BackendId, true); |
| 57 | 57 | // delete the folder on the device |
| 58 | - if (! $hasRights) { |
|
| 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 | 61 | if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true) |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * Implement interfaces which are never used |
| 126 | 126 | */ |
| 127 | - public function GetState() { return false;} |
|
| 127 | + public function GetState() { return false; } |
|
| 128 | 128 | public function LoadConflicts($contentparameters, $state) { return true; } |
| 129 | 129 | public function ConfigContentParameters($contentparameters) { return true; } |
| 130 | 130 | public function ImportMessageReadFlag($id, $flags, $categories = array()) { return true; } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | if (isset($this->destinationImporter)) { |
| 219 | 219 | // normally the $folder->type is not set, but we need this value to check if the change operation is permitted |
| 220 | 220 | // e.g. system folders can normally not be changed - set the type from cache and let the destinationImporter decide |
| 221 | - if (!isset($folder->type) || ! $folder->type) { |
|
| 221 | + if (!isset($folder->type) || !$folder->type) { |
|
| 222 | 222 | $cacheFolder = $this->GetFolder($folder->serverid); |
| 223 | 223 | $folder->type = $cacheFolder->type; |
| 224 | 224 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->ImportFolderChange(): Set foldertype for folder '%s' from cache as it was not sent: '%s'", $folder->displayname, $folder->type)); |
@@ -358,12 +358,12 @@ discard block |
||
| 358 | 358 | * @return array |
| 359 | 359 | */ |
| 360 | 360 | public function Synchronize() { |
| 361 | - if($this->step < count($this->changes) && isset($this->exportImporter)) { |
|
| 361 | + if ($this->step < count($this->changes) && isset($this->exportImporter)) { |
|
| 362 | 362 | |
| 363 | 363 | $change = $this->changes[$this->step]; |
| 364 | 364 | |
| 365 | 365 | if ($change[0] == self::CHANGE) { |
| 366 | - if (! $this->GetFolder($change[1]->serverid, true)) |
|
| 366 | + if (!$this->GetFolder($change[1]->serverid, true)) |
|
| 367 | 367 | $change[1]->flags = SYNC_NEWMESSAGE; |
| 368 | 368 | |
| 369 | 369 | $this->exportImporter->ImportFolderChange($change[1]); |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | * @access protected |
| 164 | 164 | * @return boolean |
| 165 | 165 | */ |
| 166 | - protected function setData($data, $id = 2, $ttl=-1) { |
|
| 166 | + protected function setData($data, $id = 2, $ttl = -1) { |
|
| 167 | 167 | return $this->ipcProvider ? $this->ipcProvider->setKey($id, json_encode($data), $ttl) : false; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
| 171 | - protected function setDeviceUserData($key, $data, $devid, $user, $subkey=-1, $doCas=false, $rawdata = false) { |
|
| 171 | + protected function setDeviceUserData($key, $data, $devid, $user, $subkey = -1, $doCas = false, $rawdata = false) { |
|
| 172 | 172 | $compKey = $this->getComposedKey($devid, $user, $subkey); |
| 173 | 173 | |
| 174 | 174 | // overwrite |
| 175 | - if (! $doCas) { |
|
| 175 | + if (!$doCas) { |
|
| 176 | 176 | $ok = ($this->ipcProvider->get()->hset($key, $compKey, json_encode($data)) !== false); |
| 177 | 177 | } |
| 178 | 178 | // merge data and do CAS on the $compKey |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $ok = false; |
| 181 | 181 | $okCount = 0; |
| 182 | 182 | // TODO: make this configurable (retrycount)? |
| 183 | - while(! $ok && $okCount < 5) { |
|
| 183 | + while (!$ok && $okCount < 5) { |
|
| 184 | 184 | $newData = $data; |
| 185 | 185 | // step 1: get current data |
| 186 | 186 | $_rawdata = $this->ipcProvider->get()->hget($key, $compKey); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $ok = false; |
| 215 | 215 | $okCount = 0; |
| 216 | 216 | // TODO: make this configurable (retrycount)? |
| 217 | - while(! $ok && $okCount < 5) { |
|
| 217 | + while (!$ok && $okCount < 5) { |
|
| 218 | 218 | // step 1: get current data |
| 219 | 219 | $_rawdata = $this->ipcProvider->get()->hget($key, $compKey); |
| 220 | 220 | $newData = json_decode($_rawdata, true); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | break; |
| 224 | 224 | } |
| 225 | 225 | // step 2: if data exists, delete the keys of $data from it |
| 226 | - foreach($data as $delKey) { |
|
| 226 | + foreach ($data as $delKey) { |
|
| 227 | 227 | unset($newData[$delKey]); |
| 228 | 228 | } |
| 229 | 229 | $rawNewData = json_encode($newData); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | return $ok; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - protected function getDeviceUserData($key, $devid, $user, $subkey=-1, $returnRaw=false) { |
|
| 248 | + protected function getDeviceUserData($key, $devid, $user, $subkey = -1, $returnRaw = false) { |
|
| 249 | 249 | $compKey = $this->getComposedKey($devid, $user, $subkey); |
| 250 | 250 | $_rawdata = $this->ipcProvider->get()->hget($key, $compKey); |
| 251 | 251 | if ($returnRaw) { |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - protected function delDeviceUserData($key, $devid, $user, $subkey=-1) { |
|
| 269 | + protected function delDeviceUserData($key, $devid, $user, $subkey = -1) { |
|
| 270 | 270 | $compKey = $this->getComposedKey($devid, $user, $subkey); |
| 271 | 271 | return $this->ipcProvider->get()->hdel($key, $compKey); |
| 272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $_data[$devid][$user] = $_data; |
| 285 | 285 | } |
| 286 | 286 | else { |
| 287 | - if (!isset($_data[$devid][$user])){ |
|
| 287 | + if (!isset($_data[$devid][$user])) { |
|
| 288 | 288 | $_data[$devid][$user] = array(); |
| 289 | 289 | } |
| 290 | 290 | $_data[$devid][$user][$subkey] = $_linedata; |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | return $this->ipcProvider->get()->hGetAll($key); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - protected function getComposedKey($key1, $key2, $key3=-1) { |
|
| 300 | + protected function getComposedKey($key1, $key2, $key3 = -1) { |
|
| 301 | 301 | $_k = $key1; |
| 302 | 302 | if ($key2 > -1) { |
| 303 | - $_k .="|-|". $key2; |
|
| 303 | + $_k .= "|-|".$key2; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | if ($key3 > -1) { |
| 307 | - $_k .="|-|". $key3; |
|
| 307 | + $_k .= "|-|".$key3; |
|
| 308 | 308 | } |
| 309 | 309 | return $_k; |
| 310 | 310 | } |
@@ -293,12 +293,12 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function IsExporterRunRequired($currentFolderStat, $doLog = false) { |
| 295 | 295 | // if the backend returned false as folderstat, we have to run the exporter |
| 296 | - if ($currentFolderStat === false || $this->confirmationChanged) { |
|
| 296 | + if ($currentFolderStat === false || $this->confirmationChanged) { |
|
| 297 | 297 | $run = true; |
| 298 | 298 | } |
| 299 | 299 | else { |
| 300 | 300 | // check if the folderstat differs from the saved one or expired |
| 301 | - $run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout()); |
|
| 301 | + $run = !($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout()); |
|
| 302 | 302 | } |
| 303 | 303 | if ($doLog) { |
| 304 | 304 | $expDate = ($this->HasFolderStatTimeout()) ? date('Y-m-d H:i:s', $this->GetFolderStatTimeout()) : "not set"; |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | */ |
| 405 | 405 | public function __call($name, $arguments) { |
| 406 | 406 | $lowname = strtolower($name); |
| 407 | - $operator = substr($lowname, 0,3); |
|
| 408 | - $var = substr($lowname,3); |
|
| 407 | + $operator = substr($lowname, 0, 3); |
|
| 408 | + $var = substr($lowname, 3); |
|
| 409 | 409 | |
| 410 | 410 | if (array_key_exists($var, $this->unsetdata)) { |
| 411 | 411 | return parent::__call($name, $arguments); |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | $this->stateManager->DoNotDeleteOldStates(); |
| 109 | 109 | |
| 110 | 110 | $invalidStates = false; |
| 111 | - foreach($this->stateManager->GetSynchedFolders() as $folderid) { |
|
| 111 | + foreach ($this->stateManager->GetSynchedFolders() as $folderid) { |
|
| 112 | 112 | if ($overwriteLoaded === false && isset($this->collections[$folderid])) |
| 113 | 113 | continue; |
| 114 | 114 | |
| 115 | 115 | // Load Collection! |
| 116 | - if (! $this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) |
|
| 116 | + if (!$this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) |
|
| 117 | 117 | $invalidStates = true; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | // TODO remove resync of folders |
| 153 | 153 | // this forces a resync of all states |
| 154 | - if (! $spa instanceof SyncParameters) { |
|
| 154 | + if (!$spa instanceof SyncParameters) { |
|
| 155 | 155 | throw new StateInvalidException("Saved state are not of type SyncParameters"); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // if this is an additional folder the backend has to be setup correctly |
| 178 | - if ($checkPermissions === true && ! ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
| 178 | + if ($checkPermissions === true && !ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
| 179 | 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 | 180 | |
| 181 | 181 | // add collection to object |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @return boolean |
| 212 | 212 | */ |
| 213 | 213 | public function SaveCollection($spa) { |
| 214 | - if (! $this->saveData || !$spa->HasFolderId()) |
|
| 214 | + if (!$this->saveData || !$spa->HasFolderId()) |
|
| 215 | 215 | return false; |
| 216 | 216 | |
| 217 | 217 | if ($spa->IsDataChanged()) { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @return boolean |
| 241 | 241 | */ |
| 242 | 242 | public function AddCollection($spa) { |
| 243 | - if (! $spa->HasFolderId()) |
|
| 243 | + if (!$spa->HasFolderId()) |
|
| 244 | 244 | return false; |
| 245 | 245 | |
| 246 | 246 | $this->collections[$spa->GetFolderId()] = $spa; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @return boolean |
| 286 | 286 | */ |
| 287 | 287 | public function HasCollections() { |
| 288 | - return ! empty($this->collections); |
|
| 288 | + return !empty($this->collections); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -451,8 +451,8 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | public function CheckForChanges($lifetime = 600, $interval = 30, $onlyPingable = false) { |
| 453 | 453 | $classes = array(); |
| 454 | - foreach ($this->collections as $folderid => $spa){ |
|
| 455 | - if ($onlyPingable && $spa->GetPingableFlag() !== true || ! $folderid) |
|
| 454 | + foreach ($this->collections as $folderid => $spa) { |
|
| 455 | + if ($onlyPingable && $spa->GetPingableFlag() !== true || !$folderid) |
|
| 456 | 456 | continue; |
| 457 | 457 | |
| 458 | 458 | $class = $this->getPingClass($spa); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $checkClasses = "policies only"; |
| 466 | 466 | else if (array_sum($classes) > 4) { |
| 467 | 467 | $checkClasses = ""; |
| 468 | - foreach($classes as $class=>$count) { |
|
| 468 | + foreach ($classes as $class=>$count) { |
|
| 469 | 469 | if ($count == 1) |
| 470 | 470 | $checkClasses .= sprintf("%s ", $class); |
| 471 | 471 | else |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | ZPush::GetDeviceManager()->AnnounceProcessAsPush(); |
| 482 | 482 | ZPush::GetTopCollector()->AnnounceInformation(sprintf("lifetime %ds", $lifetime), true); |
| 483 | - ZLog::Write(LOGLEVEL_INFO, sprintf("SyncCollections->CheckForChanges(): Waiting for %s changes... (lifetime %d seconds)", (empty($classes))?'policy':'store', $lifetime)); |
|
| 483 | + ZLog::Write(LOGLEVEL_INFO, sprintf("SyncCollections->CheckForChanges(): Waiting for %s changes... (lifetime %d seconds)", (empty($classes)) ? 'policy' : 'store', $lifetime)); |
|
| 484 | 484 | |
| 485 | 485 | // use changes sink where available |
| 486 | 486 | $changesSink = ZPush::GetBackend()->HasChangesSink(); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | if (!empty($classes)) { |
| 490 | 490 | // initialize all possible folders |
| 491 | 491 | foreach ($this->collections as $folderid => $spa) { |
| 492 | - if (($onlyPingable && $spa->GetPingableFlag() !== true) || ! $folderid) |
|
| 492 | + if (($onlyPingable && $spa->GetPingableFlag() !== true) || !$folderid) |
|
| 493 | 493 | continue; |
| 494 | 494 | |
| 495 | 495 | $backendFolderId = $spa->GetBackendFolderId(); |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | // initialize sink if no immediate changes were found so far |
| 501 | 501 | if ($changesSink && empty($this->changes)) { |
| 502 | 502 | ZPush::GetBackend()->Setup($store); |
| 503 | - if (! ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) |
|
| 503 | + if (!ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) |
|
| 504 | 504 | throw new StatusException(sprintf("Error initializing ChangesSink for folder id %s/%s", $folderid, $backendFolderId), self::ERROR_WRONG_HIERARCHY); |
| 505 | 505 | } |
| 506 | 506 | |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("refpolkey:'%s', sent polkey:'%s'", $policyKey, Request::GetPolicyKey())); |
| 528 | 528 | $policyKey = Request::GetPolicyKey(); |
| 529 | 529 | } |
| 530 | - while(($now = time()) < $endat) { |
|
| 530 | + while (($now = time()) < $endat) { |
|
| 531 | 531 | // how long are we waiting for changes |
| 532 | - $this->waitingTime = $now-$started; |
|
| 532 | + $this->waitingTime = $now - $started; |
|
| 533 | 533 | |
| 534 | 534 | $nextInterval = $interval; |
| 535 | 535 | // we should not block longer than the lifetime |
@@ -554,18 +554,18 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | // more than 60 secs to go? |
| 556 | 556 | if (($now + 60) < $endat) { |
| 557 | - ZPush::GetTopCollector()->AnnounceInformation(sprintf("Forced timeout after %ds", ($now-$started)), true); |
|
| 558 | - throw new StatusException(sprintf("SyncCollections->CheckForChanges(): Timeout forced after %ss from %ss due to other process", ($now-$started), $lifetime), self::OBSOLETE_CONNECTION); |
|
| 557 | + ZPush::GetTopCollector()->AnnounceInformation(sprintf("Forced timeout after %ds", ($now - $started)), true); |
|
| 558 | + throw new StatusException(sprintf("SyncCollections->CheckForChanges(): Timeout forced after %ss from %ss due to other process", ($now - $started), $lifetime), self::OBSOLETE_CONNECTION); |
|
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // Use changes sink if available |
| 563 | 563 | if ($changesSink) { |
| 564 | - ZPush::GetTopCollector()->AnnounceInformation(sprintf("Sink %d/%ds on %s", ($now-$started), $lifetime, $checkClasses)); |
|
| 564 | + ZPush::GetTopCollector()->AnnounceInformation(sprintf("Sink %d/%ds on %s", ($now - $started), $lifetime, $checkClasses)); |
|
| 565 | 565 | $notifications = ZPush::GetBackend()->ChangesSink($nextInterval); |
| 566 | 566 | |
| 567 | 567 | // how long are we waiting for changes |
| 568 | - $this->waitingTime = time()-$started; |
|
| 568 | + $this->waitingTime = time() - $started; |
|
| 569 | 569 | |
| 570 | 570 | $validNotifications = false; |
| 571 | 571 | foreach ($notifications as $backendFolderId) { |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | if ($this->CountChange($folderid)) { |
| 587 | 587 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s'", $folderid)); |
| 588 | 588 | $validNotifications = true; |
| 589 | - $this->waitingTime = time()-$started; |
|
| 589 | + $this->waitingTime = time() - $started; |
|
| 590 | 590 | } |
| 591 | 591 | else { |
| 592 | 592 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s', but it is not relevant", $folderid)); |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | } |
| 599 | 599 | // use polling mechanism |
| 600 | 600 | else { |
| 601 | - ZPush::GetTopCollector()->AnnounceInformation(sprintf("Polling %d/%ds on %s", ($now-$started), $lifetime, $checkClasses)); |
|
| 601 | + ZPush::GetTopCollector()->AnnounceInformation(sprintf("Polling %d/%ds on %s", ($now - $started), $lifetime, $checkClasses)); |
|
| 602 | 602 | if ($this->CountChanges($onlyPingable)) { |
| 603 | 603 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Found changes polling")); |
| 604 | 604 | return true; |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | if ($exporter !== false && isset($this->addparms[$folderid]["state"])) { |
| 729 | 729 | $exporter->Config($this->addparms[$folderid]["state"]); |
| 730 | 730 | $ret = $exporter->InitializeExporter($changesMem); |
| 731 | - while(is_array($exporter->Synchronize())); |
|
| 731 | + while (is_array($exporter->Synchronize())); |
|
| 732 | 732 | |
| 733 | 733 | if ($ret !== false) |
| 734 | 734 | $changecount = $changesMem->GetChangeCount(); |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | // start over if exporter can not be configured atm |
| 744 | - if ($changecount === false ) |
|
| 744 | + if ($changecount === false) |
|
| 745 | 745 | ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter."); |
| 746 | 746 | } |
| 747 | 747 | return ($changecount > 0); |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @return |
| 888 | 888 | */ |
| 889 | 889 | private function invalidateFolderStat($spa) { |
| 890 | - if($spa->HasFolderStat()) { |
|
| 890 | + if ($spa->HasFolderStat()) { |
|
| 891 | 891 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->invalidateFolderStat(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId())); |
| 892 | 892 | $spa->DelFolderStat(); |
| 893 | 893 | $this->SaveCollection($spa); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | // truncate messages longer than 10 KB |
| 60 | 60 | $messagesize = strlen($message); |
| 61 | 61 | if ($truncate && $messagesize > 10240) |
| 62 | - $message = substr($message, 0, 10240) . sprintf(" <log message with %d bytes truncated>", $messagesize); |
|
| 62 | + $message = substr($message, 0, 10240).sprintf(" <log message with %d bytes truncated>", $messagesize); |
|
| 63 | 63 | |
| 64 | 64 | self::$lastLogs[$loglevel] = $message; |
| 65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | if ($loglevel & LOGLEVEL_WBXMLSTACK) { |
| 75 | - self::$wbxmlDebug .= $message . PHP_EOL; |
|
| 75 | + self::$wbxmlDebug .= $message.PHP_EOL; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return string/false returns false if there was no message logged in that level |
| 96 | 96 | */ |
| 97 | 97 | static public function GetLastMessage($loglevel) { |
| 98 | - return (isset(self::$lastLogs[$loglevel]))?self::$lastLogs[$loglevel]:false; |
|
| 98 | + return (isset(self::$lastLogs[$loglevel])) ?self::$lastLogs[$loglevel] : false; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -173,19 +173,19 @@ discard block |
||
| 173 | 173 | case E_NOTICE: |
| 174 | 174 | case E_WARNING: |
| 175 | 175 | // TODO check if there is a better way to avoid these messages |
| 176 | - if (stripos($errfile,'interprocessdata') !== false && stripos($errstr,'shm_get_var()') !== false) |
|
| 176 | + if (stripos($errfile, 'interprocessdata') !== false && stripos($errstr, 'shm_get_var()') !== false) |
|
| 177 | 177 | break; |
| 178 | 178 | ZLog::Write(LOGLEVEL_WARN, "$errfile:$errline $errstr ($errno)"); |
| 179 | 179 | break; |
| 180 | 180 | |
| 181 | 181 | default: |
| 182 | 182 | $bt = debug_backtrace(); |
| 183 | - ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ". (count($bt)-1) . " steps"); |
|
| 184 | - for($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) { |
|
| 183 | + ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ".(count($bt) - 1)." steps"); |
|
| 184 | + for ($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) { |
|
| 185 | 185 | $file = $line = "unknown"; |
| 186 | 186 | if (isset($bt[$i]['file'])) $file = $bt[$i]['file']; |
| 187 | 187 | if (isset($bt[$i]['line'])) $line = $bt[$i]['line']; |
| 188 | - ZLog::Write(LOGLEVEL_ERROR, "trace: $i:". $file . ":" . $line. " - " . ((isset($bt[$i]['class']))? $bt[$i]['class'] . $bt[$i]['type']:""). $bt[$i]['function']. "()"); |
|
| 188 | + ZLog::Write(LOGLEVEL_ERROR, "trace: $i:".$file.":".$line." - ".((isset($bt[$i]['class'])) ? $bt[$i]['class'].$bt[$i]['type'] : "").$bt[$i]['function']."()"); |
|
| 189 | 189 | } |
| 190 | 190 | //throw new Exception("An error occurred."); |
| 191 | 191 | break; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $error = error_get_last(); |
| 206 | 206 | |
| 207 | - if( $error !== null) { |
|
| 207 | + if ($error !== null) { |
|
| 208 | 208 | $errno = $error["type"]; |
| 209 | 209 | $errfile = $error["file"]; |
| 210 | 210 | $errline = $error["line"]; |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function Decode(&$decoder) { |
| 71 | 71 | WBXMLDecoder::ResetInWhile("decodeMain"); |
| 72 | - while(WBXMLDecoder::InWhile("decodeMain")) { |
|
| 72 | + while (WBXMLDecoder::InWhile("decodeMain")) { |
|
| 73 | 73 | $entity = $decoder->getElement(); |
| 74 | 74 | |
| 75 | - if($entity[EN_TYPE] == EN_TYPE_STARTTAG) { |
|
| 76 | - if(! ($entity[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
| 75 | + if ($entity[EN_TYPE] == EN_TYPE_STARTTAG) { |
|
| 76 | + if (!($entity[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
| 77 | 77 | $map = $this->mapping[$entity[EN_TAG]]; |
| 78 | 78 | if (isset($map[self::STREAMER_ARRAY])) { |
| 79 | 79 | $this->{$map[self::STREAMER_VAR]} = array(); |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
| 82 | 82 | $this->{$map[self::STREAMER_VAR]} = "1"; |
| 83 | 83 | } |
| 84 | - else if(!isset($map[self::STREAMER_TYPE])) { |
|
| 84 | + else if (!isset($map[self::STREAMER_TYPE])) { |
|
| 85 | 85 | $this->{$map[self::STREAMER_VAR]} = ""; |
| 86 | 86 | } |
| 87 | - else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) { |
|
| 87 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
|
| 88 | 88 | $this->{$map[self::STREAMER_VAR]} = ""; |
| 89 | 89 | } |
| 90 | 90 | continue; |
| 91 | 91 | } |
| 92 | 92 | // Found a start tag |
| 93 | - if(!isset($this->mapping[$entity[EN_TAG]])) { |
|
| 93 | + if (!isset($this->mapping[$entity[EN_TAG]])) { |
|
| 94 | 94 | // This tag shouldn't be here, abort |
| 95 | 95 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Tag '%s' unexpected in type XML type '%s'", $entity[EN_TAG], get_class($this))); |
| 96 | 96 | return false; |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | $map = $this->mapping[$entity[EN_TAG]]; |
| 100 | 100 | |
| 101 | 101 | // Handle an array |
| 102 | - if(isset($map[self::STREAMER_ARRAY])) { |
|
| 102 | + if (isset($map[self::STREAMER_ARRAY])) { |
|
| 103 | 103 | WBXMLDecoder::ResetInWhile("decodeArray"); |
| 104 | - while(WBXMLDecoder::InWhile("decodeArray")) { |
|
| 104 | + while (WBXMLDecoder::InWhile("decodeArray")) { |
|
| 105 | 105 | //do not get start tag for an array without a container |
| 106 | 106 | if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) { |
| 107 | - if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) |
|
| 107 | + if (!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) |
|
| 108 | 108 | break; |
| 109 | 109 | } |
| 110 | - if(isset($map[self::STREAMER_TYPE])) { |
|
| 110 | + if (isset($map[self::STREAMER_TYPE])) { |
|
| 111 | 111 | $decoded = new $map[self::STREAMER_TYPE]; |
| 112 | 112 | |
| 113 | 113 | $decoded->Decode($decoder); |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | $decoded = $decoder->getElementContent(); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if(!isset($this->{$map[self::STREAMER_VAR]})) |
|
| 119 | + if (!isset($this->{$map[self::STREAMER_VAR]})) |
|
| 120 | 120 | $this->{$map[self::STREAMER_VAR]} = array($decoded); |
| 121 | 121 | else |
| 122 | 122 | array_push($this->{$map[self::STREAMER_VAR]}, $decoded); |
| 123 | 123 | |
| 124 | - if(!$decoder->getElementEndTag()) //end tag of a container element |
|
| 124 | + if (!$decoder->getElementEndTag()) //end tag of a container element |
|
| 125 | 125 | return false; |
| 126 | 126 | |
| 127 | 127 | if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER) { |
@@ -139,43 +139,43 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | //do not get end tag for an array without a container |
| 141 | 141 | if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) { |
| 142 | - if(!$decoder->getElementEndTag()) //end tag of container |
|
| 142 | + if (!$decoder->getElementEndTag()) //end tag of container |
|
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | else { // Handle single value |
| 147 | - if(isset($map[self::STREAMER_TYPE])) { |
|
| 147 | + if (isset($map[self::STREAMER_TYPE])) { |
|
| 148 | 148 | // Complex type, decode recursively |
| 149 | - if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
|
| 149 | + if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
|
| 150 | 150 | $decoded = $this->parseDate($decoder->getElementContent()); |
| 151 | - if(!$decoder->getElementEndTag()) |
|
| 151 | + if (!$decoder->getElementEndTag()) |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
| 154 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
| 155 | 155 | $decoded = hex2bin($decoder->getElementContent()); |
| 156 | - if(!$decoder->getElementEndTag()) |
|
| 156 | + if (!$decoder->getElementEndTag()) |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | // explode comma or semicolon strings into arrays |
| 160 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED) { |
|
| 161 | - $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; "; |
|
| 160 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED) { |
|
| 161 | + $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED) ? ", " : "; "; |
|
| 162 | 162 | $decoded = explode($glue, $decoder->getElementContent()); |
| 163 | - if(!$decoder->getElementEndTag()) |
|
| 163 | + if (!$decoder->getElementEndTag()) |
|
| 164 | 164 | return false; |
| 165 | 165 | } |
| 166 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
| 166 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
| 167 | 167 | $decoded = StringStreamWrapper::Open($decoder->getElementContent()); |
| 168 | - if(!$decoder->getElementEndTag()) |
|
| 168 | + if (!$decoder->getElementEndTag()) |
|
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | 171 | else { |
| 172 | 172 | $subdecoder = new $map[self::STREAMER_TYPE](); |
| 173 | - if($subdecoder->Decode($decoder) === false) |
|
| 173 | + if ($subdecoder->Decode($decoder) === false) |
|
| 174 | 174 | return false; |
| 175 | 175 | |
| 176 | 176 | $decoded = $subdecoder; |
| 177 | 177 | |
| 178 | - if(!$decoder->getElementEndTag()) { |
|
| 178 | + if (!$decoder->getElementEndTag()) { |
|
| 179 | 179 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("No end tag for '%s'", $entity[EN_TAG])); |
| 180 | 180 | return false; |
| 181 | 181 | } |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | // Simple type, just get content |
| 186 | 186 | $decoded = $decoder->getElementContent(); |
| 187 | 187 | |
| 188 | - if($decoded === false) { |
|
| 188 | + if ($decoded === false) { |
|
| 189 | 189 | // the tag is declared to have content, but no content is available. |
| 190 | 190 | // set an empty content |
| 191 | 191 | $decoded = ""; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if(!$decoder->getElementEndTag()) { |
|
| 194 | + if (!$decoder->getElementEndTag()) { |
|
| 195 | 195 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Unable to get end tag for '%s'", $entity[EN_TAG])); |
| 196 | 196 | return false; |
| 197 | 197 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | - else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
| 204 | + else if ($entity[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
| 205 | 205 | $decoder->ungetElement($entity); |
| 206 | 206 | break; |
| 207 | 207 | } |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | public function Encode(&$encoder) { |
| 223 | 223 | // A return value if anything was streamed. We need for empty tags. |
| 224 | 224 | $streamed = false; |
| 225 | - foreach($this->mapping as $tag => $map) { |
|
| 226 | - if(isset($this->{$map[self::STREAMER_VAR]})) { |
|
| 225 | + foreach ($this->mapping as $tag => $map) { |
|
| 226 | + if (isset($this->{$map[self::STREAMER_VAR]})) { |
|
| 227 | 227 | // Variable is available |
| 228 | - if(is_object($this->{$map[self::STREAMER_VAR]})) { |
|
| 228 | + if (is_object($this->{$map[self::STREAMER_VAR]})) { |
|
| 229 | 229 | // Subobjects can do their own encoding |
| 230 | 230 | if ($this->{$map[self::STREAMER_VAR]} instanceof Streamer) { |
| 231 | 231 | $encoder->startTag($tag); |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this))); |
| 240 | 240 | } |
| 241 | 241 | // Array of objects |
| 242 | - else if(isset($map[self::STREAMER_ARRAY])) { |
|
| 242 | + else if (isset($map[self::STREAMER_ARRAY])) { |
|
| 243 | 243 | if (empty($this->{$map[self::STREAMER_VAR]}) && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
| 244 | 244 | $encoder->startTag($tag, false, true); |
| 245 | 245 | } |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | $encoder->startTag($tag); |
| 251 | 251 | |
| 252 | 252 | foreach ($this->{$map[self::STREAMER_VAR]} as $element) { |
| 253 | - if(is_object($element)) { |
|
| 253 | + if (is_object($element)) { |
|
| 254 | 254 | $encoder->startTag($map[self::STREAMER_ARRAY]); // Outputs object container (eg Attachment) |
| 255 | 255 | $element->Encode($encoder); |
| 256 | 256 | $encoder->endTag(); |
| 257 | 257 | } |
| 258 | 258 | else { |
| 259 | - if(strlen($element) == 0) |
|
| 259 | + if (strlen($element) == 0) |
|
| 260 | 260 | // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true); |
| 261 | 261 | ; |
| 262 | 262 | else { |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) |
|
| 271 | + if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) |
|
| 272 | 272 | $encoder->endTag(); |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | else { |
| 276 | - if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) { |
|
| 276 | + if (isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) { |
|
| 277 | 277 | continue; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Simple type |
| 289 | - if(!isset($map[self::STREAMER_TYPE]) && strlen($this->{$map[self::STREAMER_VAR]}) == 0) { |
|
| 289 | + if (!isset($map[self::STREAMER_TYPE]) && strlen($this->{$map[self::STREAMER_VAR]}) == 0) { |
|
| 290 | 290 | // send empty tags |
| 291 | 291 | if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) |
| 292 | 292 | $encoder->startTag($tag, false, true); |
@@ -296,23 +296,23 @@ discard block |
||
| 296 | 296 | } else |
| 297 | 297 | $encoder->startTag($tag); |
| 298 | 298 | |
| 299 | - if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) { |
|
| 300 | - if($this->{$map[self::STREAMER_VAR]} != 0) // don't output 1-1-1970 |
|
| 299 | + if (isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) { |
|
| 300 | + if ($this->{$map[self::STREAMER_VAR]} != 0) // don't output 1-1-1970 |
|
| 301 | 301 | $encoder->content($this->formatDate($this->{$map[self::STREAMER_VAR]}, $map[self::STREAMER_TYPE])); |
| 302 | 302 | } |
| 303 | - else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
| 303 | + else if (isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
| 304 | 304 | $encoder->content(strtoupper(bin2hex($this->{$map[self::STREAMER_VAR]}))); |
| 305 | 305 | } |
| 306 | - else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
| 306 | + else if (isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
| 307 | 307 | $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, false); |
| 308 | 308 | } |
| 309 | - else if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) { |
|
| 309 | + else if (isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) { |
|
| 310 | 310 | $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, true); |
| 311 | 311 | } |
| 312 | 312 | // implode comma or semicolon arrays into a string |
| 313 | - else if(isset($map[self::STREAMER_TYPE]) && is_array($this->{$map[self::STREAMER_VAR]}) && |
|
| 313 | + else if (isset($map[self::STREAMER_TYPE]) && is_array($this->{$map[self::STREAMER_VAR]}) && |
|
| 314 | 314 | ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED)) { |
| 315 | - $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; "; |
|
| 315 | + $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED) ? ", " : "; "; |
|
| 316 | 316 | $encoder->content(implode($glue, $this->{$map[self::STREAMER_VAR]})); |
| 317 | 317 | } |
| 318 | 318 | else { |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | // Output our own content |
| 327 | - if(isset($this->content)) |
|
| 327 | + if (isset($this->content)) |
|
| 328 | 328 | $encoder->content($this->content); |
| 329 | 329 | |
| 330 | 330 | return $streamed; |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | public function StripData($flags = 0) { |
| 340 | 340 | foreach ($this->mapping as $k=>$v) { |
| 341 | 341 | if (isset($this->{$v[self::STREAMER_VAR]})) { |
| 342 | - if (is_object($this->{$v[self::STREAMER_VAR]}) && method_exists($this->{$v[self::STREAMER_VAR]}, "StripData") ) { |
|
| 342 | + if (is_object($this->{$v[self::STREAMER_VAR]}) && method_exists($this->{$v[self::STREAMER_VAR]}, "StripData")) { |
|
| 343 | 343 | $this->{$v[self::STREAMER_VAR]}->StripData($flags); |
| 344 | 344 | } |
| 345 | 345 | else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->{$v[self::STREAMER_VAR]})) { |
| 346 | 346 | foreach ($this->{$v[self::STREAMER_VAR]} as $element) { |
| 347 | - if (is_object($element) && method_exists($element, "StripData") ) { |
|
| 347 | + if (is_object($element) && method_exists($element, "StripData")) { |
|
| 348 | 348 | $element->StripData($flags); |
| 349 | 349 | } |
| 350 | 350 | elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) { |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @return void |
| 419 | 419 | */ |
| 420 | 420 | public function jsonDeserialize($stdObj) { |
| 421 | - foreach($stdObj->data as $k => $v) { |
|
| 421 | + foreach ($stdObj->data as $k => $v) { |
|
| 422 | 422 | if (is_object($v) && isset($v->gsSyncStateClass)) { |
| 423 | 423 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Streamer->jsonDeserialize(): top class '%s'", $v->gsSyncStateClass)); |
| 424 | 424 | $this->$k = new $v->gsSyncStateClass; |
@@ -448,9 +448,9 @@ discard block |
||
| 448 | 448 | * @return string |
| 449 | 449 | */ |
| 450 | 450 | private function formatDate($ts, $type) { |
| 451 | - if($type == self::STREAMER_TYPE_DATE) |
|
| 451 | + if ($type == self::STREAMER_TYPE_DATE) |
|
| 452 | 452 | return gmstrftime("%Y%m%dT%H%M%SZ", $ts); |
| 453 | - else if($type == self::STREAMER_TYPE_DATE_DASHES) |
|
| 453 | + else if ($type == self::STREAMER_TYPE_DATE_DASHES) |
|
| 454 | 454 | return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
| 455 | 455 | // fallback to dashes (should never be reached) |
| 456 | 456 | return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | * @return long |
| 466 | 466 | */ |
| 467 | 467 | function parseDate($ts) { |
| 468 | - if(preg_match("/(\d{4})[^0-9]*(\d{2})[^0-9]*(\d{2})(T(\d{2})[^0-9]*(\d{2})[^0-9]*(\d{2})(.\d+)?Z){0,1}$/", $ts, $matches)) { |
|
| 469 | - if ($matches[1] >= 2038){ |
|
| 468 | + if (preg_match("/(\d{4})[^0-9]*(\d{2})[^0-9]*(\d{2})(T(\d{2})[^0-9]*(\d{2})[^0-9]*(\d{2})(.\d+)?Z){0,1}$/", $ts, $matches)) { |
|
| 469 | + if ($matches[1] >= 2038) { |
|
| 470 | 470 | $matches[1] = 2038; |
| 471 | 471 | $matches[2] = 1; |
| 472 | 472 | $matches[3] = 18; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @return boolean |
| 127 | 127 | */ |
| 128 | 128 | public function ProcessLoopDetectionAddStatus($folderid, $status) { |
| 129 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionAddStatus: '%s' with status %d", $folderid?$folderid:'hierarchy', $status)); |
|
| 129 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionAddStatus: '%s' with status %d", $folderid ? $folderid : 'hierarchy', $status)); |
|
| 130 | 130 | // generate entry if not already there |
| 131 | 131 | self::GetProcessEntry(); |
| 132 | 132 | |
@@ -181,14 +181,14 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | $lookback = self::$start - 600; // look at the last 5 min |
| 183 | 183 | foreach ($this->getProcessStack() as $se) { |
| 184 | - if ($se['time'] > $lookback && $se['time'] < (self::$start-1)) { |
|
| 184 | + if ($se['time'] > $lookback && $se['time'] < (self::$start - 1)) { |
|
| 185 | 185 | // look for sync command |
| 186 | 186 | if (isset($se['stat']) && ($se['cc'] == ZPush::COMMAND_SYNC || $se['cc'] == ZPush::COMMAND_PING)) { |
| 187 | - foreach($se['stat'] as $key => $value) { |
|
| 187 | + foreach ($se['stat'] as $key => $value) { |
|
| 188 | 188 | // we only care about hierarchy errors of this folder |
| 189 | 189 | if ($se['cc'] == ZPush::COMMAND_SYNC) { |
| 190 | 190 | if ($value == SYNC_STATUS_FOLDERHIERARCHYCHANGED) { |
| 191 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised(): seen Sync command with Exception or folderid '%s' and code '%s'", $key, $value )); |
|
| 191 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised(): seen Sync command with Exception or folderid '%s' and code '%s'", $key, $value)); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | if (!isset($loopingFolders[$key])) { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | } |
| 215 | 215 | // Sync is executed, but a foldersync should be executed (hierarchy errors) |
| 216 | 216 | if (isset($data[ZPush::COMMAND_SYNC][SYNC_STATUS_FOLDERHIERARCHYCHANGED]) && |
| 217 | - $data[ZPush::COMMAND_SYNC][SYNC_STATUS_FOLDERHIERARCHYCHANGED] > 3 ) { |
|
| 217 | + $data[ZPush::COMMAND_SYNC][SYNC_STATUS_FOLDERHIERARCHYCHANGED] > 3) { |
|
| 218 | 218 | ZLog::Write(LOGLEVEL_INFO, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised(): Sync(with error)/Ping loop of folderid '%s' detected.", $fid)); |
| 219 | 219 | return true; |
| 220 | 220 | } |
@@ -248,19 +248,19 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | $lookback = self::$start - 600; // look at the last 5 min |
| 250 | 250 | foreach ($this->getProcessStack() as $se) { |
| 251 | - if ($se['time'] > $lookback && $se['time'] < (self::$start-1)) { |
|
| 251 | + if ($se['time'] > $lookback && $se['time'] < (self::$start - 1)) { |
|
| 252 | 252 | // look for sync command |
| 253 | 253 | if (isset($se['stat']) && ($se['cc'] == ZPush::COMMAND_SYNC || $se['cc'] == ZPush::COMMAND_PING)) { |
| 254 | - foreach($se['stat'] as $key => $value) { |
|
| 254 | + foreach ($se['stat'] as $key => $value) { |
|
| 255 | 255 | // don't count PING with changes on a folder or sync with success |
| 256 | 256 | if (($se['cc'] == ZPush::COMMAND_PING && $value == SYNC_PINGSTATUS_CHANGES) || |
| 257 | - ($se['cc'] == ZPush::COMMAND_SYNC && $value == SYNC_STATUS_SUCCESS) ) { |
|
| 257 | + ($se['cc'] == ZPush::COMMAND_SYNC && $value == SYNC_STATUS_SUCCESS)) { |
|
| 258 | 258 | continue; |
| 259 | 259 | } |
| 260 | 260 | if (!isset($seenFailed[$key])) |
| 261 | 261 | $seenFailed[$key] = 0; |
| 262 | 262 | $seenFailed[$key]++; |
| 263 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen command with Exception or folderid '%s' and code '%s'", $key, $value )); |
|
| 263 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen command with Exception or folderid '%s' and code '%s'", $key, $value)); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | // look for FolderSync command with previous failed commands |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | $filtered = array(); |
| 283 | 283 | foreach ($seenFailed as $k => $count) { |
| 284 | - if ($count>1) |
|
| 284 | + if ($count > 1) |
|
| 285 | 285 | $filtered[] = $k; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $errors = false; |
| 308 | 308 | if (count($stack) > 1) { |
| 309 | 309 | $se = $stack[0]; |
| 310 | - if (!isset($se['end']) && $se['cc'] != ZPush::COMMAND_PING && !isset($se['push']) ) { |
|
| 310 | + if (!isset($se['end']) && $se['cc'] != ZPush::COMMAND_PING && !isset($se['push'])) { |
|
| 311 | 311 | // there is no end time |
| 312 | 312 | ZLog::Write(LOGLEVEL_ERROR, sprintf("LoopDetection->ProcessLoopDetectionPreviousConnectionFailed(): Command '%s' at %s with pid '%d' terminated unexpectedly or is still running.", Utils::GetCommandFromCode($se['cc']), Utils::GetFormattedTime($se['time']), $se['pid'])); |
| 313 | 313 | ZLog::Write(LOGLEVEL_ERROR, "Please check your logs for this PID and errors like PHP-Fatals or Apache segmentation faults and report your results to the grommunio dev team."); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | $ok = false; |
| 351 | 351 | $tryCount = 1; |
| 352 | - while(! $ok && $tryCount < 5) { |
|
| 352 | + while (!$ok && $tryCount < 5) { |
|
| 353 | 353 | list($stack, $stackRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, self::INTERPROCESSLD, true); |
| 354 | 354 | |
| 355 | 355 | // insert/update current process entry |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $nstack = array_slice($nstack, -10, 10); |
| 375 | 375 | |
| 376 | 376 | // update loop data |
| 377 | - $ok = $this->setDeviceUserData($this->type, $nstack, parent::$devid, parent::$user, self::INTERPROCESSLD, $doCas="replace", $stackRaw); |
|
| 377 | + $ok = $this->setDeviceUserData($this->type, $nstack, parent::$devid, parent::$user, self::INTERPROCESSLD, $doCas = "replace", $stackRaw); |
|
| 378 | 378 | if (!$ok) { |
| 379 | 379 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->updateProcessStack(): CAS failed on try %d!", $tryCount)); |
| 380 | 380 | usleep(100000); |
@@ -422,19 +422,19 @@ discard block |
||
| 422 | 422 | return false; |
| 423 | 423 | |
| 424 | 424 | $ok = false; |
| 425 | - $brokenkey = self::BROKENMSGS ."-". $folderid; |
|
| 425 | + $brokenkey = self::BROKENMSGS."-".$folderid; |
|
| 426 | 426 | |
| 427 | 427 | // initialize params |
| 428 | 428 | $this->initializeParams(); |
| 429 | 429 | $tryCount = 1; |
| 430 | - while(! $ok && $tryCount < 5) { |
|
| 430 | + while (!$ok && $tryCount < 5) { |
|
| 431 | 431 | list($brokenmsgs, $brokenmsgsRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $brokenkey, true); |
| 432 | 432 | |
| 433 | 433 | $brokenmsgs[$id] = array('uuid' => $this->broken_message_uuid, 'counter' => $this->broken_message_counter); |
| 434 | 434 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->SetBrokenMessage('%s', '%s'): tracking broken message", $folderid, $id)); |
| 435 | 435 | |
| 436 | 436 | // update data |
| 437 | - $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas="replace", $brokenmsgsRaw); |
|
| 437 | + $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas = "replace", $brokenmsgsRaw); |
|
| 438 | 438 | if (!$ok) { |
| 439 | 439 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->SetBrokenMessage(): CAS failed on try %d!", $tryCount)); |
| 440 | 440 | usleep(100000); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) |
| 460 | 460 | return array(); |
| 461 | 461 | |
| 462 | - $brokenkey = self::BROKENMSGS ."-". $folderid; |
|
| 462 | + $brokenkey = self::BROKENMSGS."-".$folderid; |
|
| 463 | 463 | $removeIds = array(); |
| 464 | 464 | $okIds = array(); |
| 465 | 465 | |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | $ok = false; |
| 470 | 470 | $tryCount = 1; |
| 471 | - while(! $ok && $tryCount < 5) { |
|
| 471 | + while (!$ok && $tryCount < 5) { |
|
| 472 | 472 | list($brokenmsgs, $brokenmsgsRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $brokenkey, true); |
| 473 | 473 | |
| 474 | 474 | if (empty($brokenmsgs)) { |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | // remove data |
| 493 | - foreach (array_merge($okIds,$removeIds) as $id) { |
|
| 493 | + foreach (array_merge($okIds, $removeIds) as $id) { |
|
| 494 | 494 | unset($brokenmsgs[$id]); |
| 495 | 495 | } |
| 496 | 496 | |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | else { |
| 503 | 503 | // update data |
| 504 | - $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas="replace", $brokenmsgsRaw); |
|
| 504 | + $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas = "replace", $brokenmsgsRaw); |
|
| 505 | 505 | if (!$ok) { |
| 506 | 506 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->GetSyncedButBeforeIgnoredMessages(): CAS failed on try %d!", $tryCount)); |
| 507 | 507 | usleep(100000); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | $ok = false; |
| 536 | 536 | $tryCount = 1; |
| 537 | - while(! $ok && $tryCount < 5) { |
|
| 537 | + while (!$ok && $tryCount < 5) { |
|
| 538 | 538 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
| 539 | 539 | |
| 540 | 540 | if (!isset($current["uuid"])) { |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $current["usage"] = $counter; |
| 552 | 552 | |
| 553 | 553 | // update loop data |
| 554 | - $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
|
| 554 | + $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas = "replace", $currentRaw); |
|
| 555 | 555 | if (!$ok) { |
| 556 | 556 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->SetSyncStateUsage(): CAS failed on try %d!", $tryCount)); |
| 557 | 557 | usleep(100000); |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | ($current["count"] == $counter && $current["queued"] > 0) || |
| 596 | 596 | (isset($current["usage"]) && $current["usage"] >= $counter) |
| 597 | 597 | )) { |
| 598 | - $usage = isset($current["usage"]) ? sprintf(" - counter %d already expired",$current["usage"]) : ""; |
|
| 599 | - ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed". $usage); |
|
| 598 | + $usage = isset($current["usage"]) ? sprintf(" - counter %d already expired", $current["usage"]) : ""; |
|
| 599 | + ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed".$usage); |
|
| 600 | 600 | $obsolete = true; |
| 601 | 601 | } |
| 602 | 602 | } |
@@ -657,20 +657,20 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | $ok = false; |
| 659 | 659 | $tryCount = 1; |
| 660 | - while(! $ok && $tryCount < 5) { |
|
| 660 | + while (!$ok && $tryCount < 5) { |
|
| 661 | 661 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
| 662 | 662 | |
| 663 | 663 | // completely new/unknown UUID |
| 664 | 664 | if (empty($current)) |
| 665 | - $current = array("uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages); |
|
| 665 | + $current = array("uuid" => $uuid, "count" => $counter - 1, "queued" => $queuedMessages); |
|
| 666 | 666 | |
| 667 | 667 | // old UUID in cache - the device requested a new state!! |
| 668 | - if (isset($current['uuid']) && $current['uuid'] != $uuid ) { |
|
| 668 | + if (isset($current['uuid']) && $current['uuid'] != $uuid) { |
|
| 669 | 669 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed for folder"); |
| 670 | 670 | |
| 671 | 671 | // some devices (iPhones) may request new UUIDs after broken items were sent several times |
| 672 | 672 | if (isset($current['queued']) && $current['queued'] > 0 && |
| 673 | - (isset($current['maxCount']) && $current['count']+1 < $current['maxCount'] || $counter == 1)) { |
|
| 673 | + (isset($current['maxCount']) && $current['count'] + 1 < $current['maxCount'] || $counter == 1)) { |
|
| 674 | 674 | |
| 675 | 675 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed and while items where sent to device - forcing loop mode"); |
| 676 | 676 | $loop = true; // force loop mode |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | $current['loopcount'] = 1; |
| 758 | 758 | // the MaxCount is the max number of messages exported before |
| 759 | 759 | $current['maxCount'] = $counter + (($maxItems < $queuedMessages) ? $maxItems : $queuedMessages); |
| 760 | - $loop = true; // loop mode!! |
|
| 760 | + $loop = true; // loop mode!! |
|
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | else if ($queuedMessages == 0) { |
@@ -781,16 +781,16 @@ discard block |
||
| 781 | 781 | $this->ignore_messageid = $current['potential']; |
| 782 | 782 | } |
| 783 | 783 | $current['maxCount'] = $counter + (($maxItems < $queuedMessages) ? $maxItems : $queuedMessages); |
| 784 | - $loop = true; // loop mode!! |
|
| 784 | + $loop = true; // loop mode!! |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | } |
| 789 | 789 | if (isset($current['loopcount'])) |
| 790 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored'])?$current['ignored']:'false'))); |
|
| 790 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored']) ? $current['ignored'] : 'false'))); |
|
| 791 | 791 | |
| 792 | 792 | // update loop data |
| 793 | - $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
|
| 793 | + $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas = "replace", $currentRaw); |
|
| 794 | 794 | if (!$ok) { |
| 795 | 795 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->Detect(): CAS failed on try %d!", $tryCount)); |
| 796 | 796 | usleep(100000); |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | $changedData = false; |
| 845 | 845 | $ok = false; |
| 846 | 846 | $tryCount = 1; |
| 847 | - while(! $ok && $tryCount < 5) { |
|
| 847 | + while (!$ok && $tryCount < 5) { |
|
| 848 | 848 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
| 849 | 849 | |
| 850 | 850 | // we found our broken message! |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | $changedData = true; |
| 855 | 855 | |
| 856 | 856 | // check if this message was broken before - here we know that it still is and remove it from the tracking |
| 857 | - $brokenkey = self::BROKENMSGS ."-". $folderid; |
|
| 857 | + $brokenkey = self::BROKENMSGS."-".$folderid; |
|
| 858 | 858 | // TODO: this is currently not supported here! It's in a different structure now! |
| 859 | 859 | // if (isset($loopdata[self::$devid][self::$user][$brokenkey]) && isset($loopdata[self::$devid][self::$user][$brokenkey][$messageid])) { |
| 860 | 860 | // ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IgnoreNextMessage(): previously broken message '%s' is still broken and will not be tracked anymore", $messageid)); |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | break; |
| 885 | 885 | } |
| 886 | 886 | // update loop data |
| 887 | - $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
|
| 887 | + $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas = "replace", $currentRaw); |
|
| 888 | 888 | if (!$ok) { |
| 889 | 889 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->Detect(): CAS failed on try %d!", $tryCount)); |
| 890 | 890 | usleep(100000); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $this->preserved = array(); |
| 38 | 38 | // static vars come from the parent class |
| 39 | - $this->latest = array( "pid" => self::$pid, |
|
| 39 | + $this->latest = array("pid" => self::$pid, |
|
| 40 | 40 | "ip" => Request::GetRemoteAddr(), |
| 41 | 41 | "user" => self::$user, |
| 42 | 42 | "start" => self::$start, |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $time = time(); |
| 79 | 79 | if ($stop === true) $time = 0; |
| 80 | 80 | |
| 81 | - if (! $this->setData($time, self::ENABLEDAT)) |
|
| 81 | + if (!$this->setData($time, self::ENABLEDAT)) |
|
| 82 | 82 | return false; |
| 83 | 83 | |
| 84 | 84 | return $wasEnabled; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function ClearLatest($all = false) { |
| 144 | 144 | // it's ok when doing this every 10 sec |
| 145 | - if ($all == false && time() % 10 != 0 ) |
|
| 145 | + if ($all == false && time() % 10 != 0) |
|
| 146 | 146 | return true; |
| 147 | 147 | |
| 148 | 148 | if ($all == true) { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $time = time(); |
| 216 | 216 | if ($this->checkEnabledTime + self::ENABLED_CACHETIME < $time) { |
| 217 | 217 | $isEnabled = ($this->hasData(self::ENABLEDAT)) ? $this->getData(self::ENABLEDAT) : false; |
| 218 | - $this->enabled = ($isEnabled !== false && ($isEnabled +300) > $time); |
|
| 218 | + $this->enabled = ($isEnabled !== false && ($isEnabled + 300) > $time); |
|
| 219 | 219 | $this->checkEnabledTime = $time; |
| 220 | 220 | } |
| 221 | 221 | return $this->enabled; |