Passed
Branch master (ff9d34)
by Mike
09:14
created
version.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     $branch = trim(exec("hash git 2>/dev/null && cd $path >/dev/null 2>&1 && git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e \"s/* \(.*\)/\\1/\""));
11 11
     $version = exec("hash git 2>/dev/null && cd $path >/dev/null 2>&1 && git describe  --always 2>/dev/null");
12 12
     if ($branch && $version) {
13
-        define("GROMMUNIOSYNC_VERSION", $branch .'-'. $version);
13
+        define("GROMMUNIOSYNC_VERSION", $branch.'-'.$version);
14 14
     }
15 15
     else {
16 16
         define("GROMMUNIOSYNC_VERSION", "GIT");
Please login to merge, or discard this patch.
lib/log/filelog.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
      */
29 29
     private function getLogToUserFile() {
30 30
         if ($this->log_to_user_file === false) {
31
-            if (in_array(strtolower($this->GetDevid()), ['','validate'])) {
32
-                $this->setLogToUserFile(preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetAuthUser())) . '.log');
31
+            if (in_array(strtolower($this->GetDevid()), ['', 'validate'])) {
32
+                $this->setLogToUserFile(preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetAuthUser())).'.log');
33 33
             }
34 34
             else {
35 35
                 $this->setLogToUserFile(
36
-                        preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetAuthUser())) .'-'.
37
-                        (($this->GetAuthUser() != $this->GetUser()) ? preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetUser())) .'-' : '') .
38
-                        preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetDevid())) .
36
+                        preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetAuthUser())).'-'.
37
+                        (($this->GetAuthUser() != $this->GetUser()) ? preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetUser())).'-' : '').
38
+                        preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetDevid())).
39 39
                         '.log'
40 40
                         );
41 41
             }
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
      * @return string
67 67
      */
68 68
     public function BuildLogString($loglevel, $message, $includeUserDevice = true) {
69
-        $log = Utils::GetFormattedTime() .' ['. str_pad($this->GetPid(),5," ",STR_PAD_LEFT) .'] '. $this->GetLogLevelString($loglevel, $loglevel >= LOGLEVEL_INFO);
69
+        $log = Utils::GetFormattedTime().' ['.str_pad($this->GetPid(), 5, " ", STR_PAD_LEFT).'] '.$this->GetLogLevelString($loglevel, $loglevel >= LOGLEVEL_INFO);
70 70
 
71 71
         if ($includeUserDevice) {
72 72
             // when the users differ, we need to log both
73 73
             if (strcasecmp($this->GetAuthUser(), $this->GetUser()) == 0) {
74
-                $log .= ' ['. $this->GetUser() .']';
74
+                $log .= ' ['.$this->GetUser().']';
75 75
             }
76 76
             else {
77
-                $log .= ' ['. $this->GetAuthUser() . Request::IMPERSONATE_DELIM . $this->GetUser() .']';
77
+                $log .= ' ['.$this->GetAuthUser().Request::IMPERSONATE_DELIM.$this->GetUser().']';
78 78
             }
79 79
         }
80 80
         if ($includeUserDevice && (LOGLEVEL >= LOGLEVEL_DEVICEID || (LOGUSERLEVEL >= LOGLEVEL_DEVICEID && $this->IsAuthUserInSpecialLogUsers()))) {
81
-            $log .= ' ['. $this->GetDevid() .']';
81
+            $log .= ' ['.$this->GetDevid().']';
82 82
         }
83
-        $log .= ' ' . $message;
83
+        $log .= ' '.$message;
84 84
         return $log;
85 85
     }
86 86
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @return void
99 99
      */
100 100
     protected function Write($loglevel, $message) {
101
-        $data = $this->BuildLogString($loglevel, $message) . PHP_EOL;
101
+        $data = $this->BuildLogString($loglevel, $message).PHP_EOL;
102 102
         @file_put_contents(LOGFILE, $data, FILE_APPEND);
103 103
     }
104 104
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
      * @return void
112 112
      */
113 113
     public function WriteForUser($loglevel, $message) {
114
-        $data = $this->BuildLogString($loglevel, $message, false) . PHP_EOL;
115
-        @file_put_contents(LOGFILEDIR . $this->getLogToUserFile(), $data, FILE_APPEND);
114
+        $data = $this->BuildLogString($loglevel, $message, false).PHP_EOL;
115
+        @file_put_contents(LOGFILEDIR.$this->getLogToUserFile(), $data, FILE_APPEND);
116 116
     }
117 117
 
118 118
     /**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      * @return void
124 124
      */
125 125
     protected function afterLog($loglevel, $message) {
126
-        if ($loglevel & (LOGLEVEL_FATAL | LOGLEVEL_ERROR | LOGLEVEL_WARN)) {
127
-            $data = $this->BuildLogString($loglevel, $message) . PHP_EOL;
126
+        if ($loglevel & (LOGLEVEL_FATAL|LOGLEVEL_ERROR|LOGLEVEL_WARN)) {
127
+            $data = $this->BuildLogString($loglevel, $message).PHP_EOL;
128 128
             @file_put_contents(LOGERRORFILE, $data, FILE_APPEND);
129 129
         }
130 130
     }
Please login to merge, or discard this patch.
lib/log/log.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         if ($this->isAuthUserInSpecialLogUsers) {
115 115
             return true;
116 116
         }
117
-        if($this->IsUserInSpecialLogUsers($this->GetAuthUser())){
117
+        if ($this->IsUserInSpecialLogUsers($this->GetAuthUser())) {
118 118
             $this->isAuthUserInSpecialLogUsers = true;
119 119
             return true;
120 120
         }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             $s = " ";
304 304
         else
305 305
             $s = "";
306
-        switch($loglevel) {
306
+        switch ($loglevel) {
307 307
             case LOGLEVEL_OFF:          return ""; break;
308 308
             case LOGLEVEL_FATAL:        return "[FATAL]"; break;
309 309
             case LOGLEVEL_ERROR:        return "[ERROR]"; break;
Please login to merge, or discard this patch.
lib/log/syslog.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
             if (!isset($trace['file'])) {
105 105
                 continue;
106 106
             }
107
-            if (strpos($trace['file'], REAL_BASE_PATH . 'backend/') !== false) {
107
+            if (strpos($trace['file'], REAL_BASE_PATH.'backend/') !== false) {
108 108
                 preg_match('/\/backend\/([a-zA-Z]*)/', $trace['file'], $match);
109 109
                 if (isset($match[1])) {
110
-                    return $this->GetProgramName() . '/' . $match[1];
110
+                    return $this->GetProgramName().'/'.$match[1];
111 111
                 }
112 112
             } elseif (basename($trace['file'], '.php') != 'zlog') {
113
-                return $this->GetProgramName() . '/core';
113
+                return $this->GetProgramName().'/core';
114 114
             }
115 115
         }
116 116
 
117
-        return $this->GetProgramName() . '/core';
117
+        return $this->GetProgramName().'/core';
118 118
     }
119 119
 
120 120
     /**
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
         $log = $this->GetLogLevelString($loglevel); // Never pad syslog log because syslog log are usually read with a software.
153 153
         // when the users differ, we need to log both
154 154
         if (strcasecmp($this->GetAuthUser(), $this->GetUser()) == 0) {
155
-            $log .= ' ['. $this->GetUser() .']';
155
+            $log .= ' ['.$this->GetUser().']';
156 156
         }
157 157
         else {
158
-            $log .= ' ['. $this->GetAuthUser() . Request::IMPERSONATE_DELIM . $this->GetUser() .']';
158
+            $log .= ' ['.$this->GetAuthUser().Request::IMPERSONATE_DELIM.$this->GetUser().']';
159 159
         }
160 160
         if ($loglevel >= LOGLEVEL_DEVICEID) {
161
-            $log .= '['. $this->GetDevid() .']';
161
+            $log .= '['.$this->GetDevid().']';
162 162
         }
163
-        $log .= ' ' . $message;
163
+        $log .= ' '.$message;
164 164
         return $log;
165 165
     }
166 166
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             $pri = ($facility * 8) + $loglevel; // multiplying the Facility number by 8 + adding the level
185 185
             $data = $this->BuildLogString($loglevel, $message);
186 186
             if (strlen(trim($data)) > 0) {
187
-                $syslog_message = "<{$pri}>" . date('M d H:i:s ') . '[' . $this->GetProgramName() . ']: ' . $data;
187
+                $syslog_message = "<{$pri}>".date('M d H:i:s ').'['.$this->GetProgramName().']: '.$data;
188 188
                 socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, $this->GetHost(), $this->GetPort());
189 189
             }
190 190
             socket_close($sock);
Please login to merge, or discard this patch.
lib/grommunio/exporter.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * that the ImportProxies are used.
16 16
  */
17 17
 
18
-class ExportChangesICS implements IExportChanges{
18
+class ExportChangesICS implements IExportChanges {
19 19
     private $folderid;
20 20
     private $store;
21 21
     private $session;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $this->restriction = false;
46 46
 
47 47
         try {
48
-            if($folderid) {
48
+            if ($folderid) {
49 49
                 $entryid = mapi_msgstore_entryidfromsourcekey($store, $folderid);
50 50
             }
51 51
             else {
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
             // Get the actual ICS exporter
70 70
             if ($folder) {
71 71
                 if ($folderid) {
72
-                    $this->exporter = mapi_openproperty($folder, PR_CONTENTS_SYNCHRONIZER, IID_IExchangeExportChanges, 0 , 0);
72
+                    $this->exporter = mapi_openproperty($folder, PR_CONTENTS_SYNCHRONIZER, IID_IExchangeExportChanges, 0, 0);
73 73
                 }
74 74
                 else {
75
-                    $this->exporter = mapi_openproperty($folder, PR_HIERARCHY_SYNCHRONIZER, IID_IExchangeExportChanges, 0 , 0);
75
+                    $this->exporter = mapi_openproperty($folder, PR_HIERARCHY_SYNCHRONIZER, IID_IExchangeExportChanges, 0, 0);
76 76
                 }
77 77
             }
78 78
             else {
@@ -106,27 +106,27 @@  discard block
 block discarded – undo
106 106
             throw new StatusException("ExportChangesICS->Config(): Error, exporter not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR);
107 107
 
108 108
         // change exporterflags if we are doing a ContentExport
109
-        if($this->folderid) {
110
-            $this->exporterflags |= SYNC_NORMAL | SYNC_READ_STATE;
109
+        if ($this->folderid) {
110
+            $this->exporterflags |= SYNC_NORMAL|SYNC_READ_STATE;
111 111
 
112 112
             // Initial sync, we don't want deleted items. If the initial sync is chunked
113 113
             // we check the change ID of the syncstate (0 at initial sync)
114 114
             // On subsequent syncs, we do want to receive delete events.
115
-            if(strlen($state) == 0 || bin2hex(substr($state,4,4)) == "00000000") {
115
+            if (strlen($state) == 0 || bin2hex(substr($state, 4, 4)) == "00000000") {
116 116
                 if (!($this->flags & BACKEND_DISCARD_DATA))
117 117
                     ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesICS->Config(): syncing initial data");
118
-                $this->exporterflags |= SYNC_NO_SOFT_DELETIONS | SYNC_NO_DELETIONS;
118
+                $this->exporterflags |= SYNC_NO_SOFT_DELETIONS|SYNC_NO_DELETIONS;
119 119
             }
120 120
         }
121 121
 
122
-        if($this->flags & BACKEND_DISCARD_DATA) {
122
+        if ($this->flags & BACKEND_DISCARD_DATA) {
123 123
             $this->exporterflags |= SYNC_CATCHUP;
124 124
             $this->exporterflags |= SYNC_STATE_READONLY;
125 125
         }
126 126
 
127 127
         // Put the state information in a stream that can be used by ICS
128 128
         $stream = mapi_stream_create();
129
-        if(strlen($state) == 0)
129
+        if (strlen($state) == 0)
130 130
             $state = hex2bin("0000000000000000");
131 131
 
132 132
         if (!($this->flags & BACKEND_DISCARD_DATA))
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
      * @return boolean
146 146
      * @throws StatusException
147 147
      */
148
-    public function ConfigContentParameters($contentparameters){
148
+    public function ConfigContentParameters($contentparameters) {
149 149
         $filtertype = $contentparameters->GetFilterType();
150
-        switch($contentparameters->GetContentClass()) {
150
+        switch ($contentparameters->GetContentClass()) {
151 151
             case "Email":
152 152
                 $this->restriction = ($filtertype || !Utils::CheckMapiExtVersion('7')) ? MAPIUtils::GetEmailRestriction(Utils::GetCutOffDate($filtertype)) : false;
153 153
                 break;
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
         // pass it to ICS
183 183
 
184 184
         // this should never happen!
185
-        if($this->exporter === false || !isset($this->statestream) || !isset($this->flags) || !isset($this->exporterflags) ||
186
-            ($this->folderid && !isset($this->contentParameters)) )
185
+        if ($this->exporter === false || !isset($this->statestream) || !isset($this->flags) || !isset($this->exporterflags) ||
186
+            ($this->folderid && !isset($this->contentParameters)))
187 187
             throw new StatusException("ExportChangesICS->InitializeExporter(): Error, exporter or essential data not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR);
188 188
 
189 189
         // PHP wrapper
190 190
         $phpwrapper = new PHPWrapper($this->session, $this->store, $importer, $this->folderid);
191 191
 
192 192
         // with a folderid we are going to get content
193
-        if($this->folderid) {
193
+        if ($this->folderid) {
194 194
             $phpwrapper->ConfigContentParameters($this->contentParameters);
195 195
 
196 196
             // ICS c++ wrapper
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
             throw new StatusException(sprintf("ExportChangesICS->InitializeExporter(): Error, mapi_wrap_import_*_changes() failed: 0x%X", mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN);
207 207
 
208 208
         $ret = mapi_exportchanges_config($this->exporter, $this->statestream, $this->exporterflags, $mapiimporter, $this->restriction, $includeprops, false, 1);
209
-        if(!$ret)
209
+        if (!$ret)
210 210
             throw new StatusException(sprintf("ExportChangesICS->InitializeExporter(): Error, mapi_exportchanges_config() failed: 0x%X", mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN);
211 211
 
212 212
         $changes = mapi_exportchanges_getchangecount($this->exporter);
213
-        if($changes || !($this->flags & BACKEND_DISCARD_DATA))
214
-            ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->InitializeExporter() successfully. %d changes ready to sync for '%s'.", $changes, ($this->folderid)?bin2hex($this->folderid) : 'hierarchy'));
213
+        if ($changes || !($this->flags & BACKEND_DISCARD_DATA))
214
+            ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->InitializeExporter() successfully. %d changes ready to sync for '%s'.", $changes, ($this->folderid) ?bin2hex($this->folderid) : 'hierarchy'));
215 215
 
216 216
         return $ret;
217 217
     }
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function GetState() {
240 240
         $error = false;
241
-        if(!isset($this->statestream) || $this->exporter === false)
241
+        if (!isset($this->statestream) || $this->exporter === false)
242 242
             $error = true;
243 243
 
244
-        if($error === true || mapi_exportchanges_updatestate($this->exporter, $this->statestream) != true )
245
-            throw new StatusException(sprintf("ExportChangesICS->GetState(): Error, state not available or unable to update: 0x%X", mapi_last_hresult()), (($this->folderid)?SYNC_STATUS_FOLDERHIERARCHYCHANGED:SYNC_FSSTATUS_CODEUNKNOWN), null, LOGLEVEL_WARN);
244
+        if ($error === true || mapi_exportchanges_updatestate($this->exporter, $this->statestream) != true)
245
+            throw new StatusException(sprintf("ExportChangesICS->GetState(): Error, state not available or unable to update: 0x%X", mapi_last_hresult()), (($this->folderid) ?SYNC_STATUS_FOLDERHIERARCHYCHANGED:SYNC_FSSTATUS_CODEUNKNOWN), null, LOGLEVEL_WARN);
246 246
 
247 247
         mapi_stream_seek($this->statestream, 0, STREAM_SEEK_SET);
248 248
 
249 249
         $state = "";
250
-        while(true) {
250
+        while (true) {
251 251
             $data = mapi_stream_read($this->statestream, 4096);
252
-            if(strlen($data))
252
+            if (strlen($data))
253 253
                 $state .= $data;
254 254
             else
255 255
                 break;
Please login to merge, or discard this patch.
lib/grommunio/grommunio.php 1 patch
Spacing   +92 added lines, -93 removed lines patch added patch discarded remove patch
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 
144 144
         try {
145 145
             // check if notifications are available in php-mapi
146
-            if(function_exists('mapi_feature') && mapi_feature('LOGONFLAGS')) {
146
+            if (function_exists('mapi_feature') && mapi_feature('LOGONFLAGS')) {
147 147
                 // send grommunio-sync version and user agent to ZCP - ZP-589
148 148
                 if (Utils::CheckMapiExtVersion('7.2.0')) {
149
-                    $zpush_version = 'Grommunio-Sync_' . @constant('GROMMUNIOSYNC_VERSION');
149
+                    $zpush_version = 'Grommunio-Sync_'.@constant('GROMMUNIOSYNC_VERSION');
150 150
                     $user_agent = ($deviceId) ? ZPush::GetDeviceManager()->GetUserAgent() : "unknown";
151 151
                     $this->session = @mapi_logon_zarafa($this->mainUser, $pass, MAPI_SERVER, null, null, 0, $zpush_version, $user_agent);
152 152
                 }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             throw new AuthenticationRequiredException($ex->getDisplayMessage());
172 172
         }
173 173
 
174
-        if(!$this->session) {
174
+        if (!$this->session) {
175 175
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->Logon(): logon failed for user '%s'", $this->mainUser));
176 176
             $this->defaultstore = false;
177 177
             return false;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         if (mapi_last_hresult() == MAPI_E_FAILONEPROVIDER)
190 190
             throw new ServiceUnavailableException("Error connecting to KC (open store)");
191 191
 
192
-        if($this->defaultstore === false)
192
+        if ($this->defaultstore === false)
193 193
             throw new AuthenticationRequiredException(sprintf("Grommunio->Logon(): User '%s' has no default store", $defaultUser));
194 194
 
195 195
         $this->store = $this->defaultstore;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                         }
267 267
                         else {
268 268
                             $zarafauserinfo = @nsp_getuserinfo($this->mainUser);
269
-                            $rights = (isset($zarafauserinfo['admin']) && $zarafauserinfo['admin'])?true:false;
269
+                            $rights = (isset($zarafauserinfo['admin']) && $zarafauserinfo['admin']) ?true:false;
270 270
                             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->Setup(): Checking for admin ACLs on store '%s': '%s'", $user, Utils::PrintAsString($rights)));
271 271
                         }
272 272
                     }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
         $rootfolderprops = mapi_getprops($rootfolder, array(PR_SOURCE_KEY));
338 338
 
339
-        $hierarchy =  mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
339
+        $hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
340 340
         $rows = mapi_table_queryallrows($hierarchy, array(PR_DISPLAY_NAME, PR_PARENT_ENTRYID, PR_ENTRYID, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_CONTAINER_CLASS, PR_ATTR_HIDDEN, PR_EXTENDED_FOLDER_FLAGS, PR_FOLDER_TYPE));
341 341
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetHierarchy(): fetched %d folders from MAPI", count($rows)));
342 342
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function GetImporter($folderid = false) {
384 384
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetImporter() folderid: '%s'", Utils::PrintAsString($folderid)));
385
-        if($folderid !== false) {
385
+        if ($folderid !== false) {
386 386
             // check if the user of the current store has permissions to import to this folderid
387 387
             if ($this->storeName != $this->mainUser && !$this->hasSecretaryACLs($this->store, $folderid)) {
388 388
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetImporter(): missing permissions on folderid: '%s'.", Utils::PrintAsString($folderid)));
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      * @throws StatusException
406 406
      */
407 407
     public function GetExporter($folderid = false) {
408
-        if($folderid !== false) {
408
+        if ($folderid !== false) {
409 409
             // check if the user of the current store has permissions to export from this folderid
410 410
             if ($this->storeName != $this->mainUser && !$this->hasSecretaryACLs($this->store, $folderid)) {
411 411
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetExporter(): missing permissions on folderid: '%s'.", Utils::PrintAsString($folderid)));
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->SendMail(): RFC822: %d bytes  forward-id: '%s' reply-id: '%s' parent-id: '%s' SaveInSent: '%s' ReplaceMIME: '%s'",
440 440
                                             $mimeLength, Utils::PrintAsString($sm->forwardflag), Utils::PrintAsString($sm->replyflag),
441 441
                                             Utils::PrintAsString((isset($sm->source->folderid) ? $sm->source->folderid : false)),
442
-                                            Utils::PrintAsString(($sm->saveinsent)), Utils::PrintAsString(isset($sm->replacemime)) ));
442
+                                            Utils::PrintAsString(($sm->saveinsent)), Utils::PrintAsString(isset($sm->replacemime))));
443 443
         if ($mimeLength == 0) {
444 444
             throw new StatusException("Grommunio->SendMail(): empty mail data", SYNC_COMMONSTATUS_MAILSUBMISSIONFAILED);
445 445
         }
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
 
450 450
         // Open the outbox and create the message there
451 451
         $storeprops = mapi_getprops($this->defaultstore, array($sendMailProps["outboxentryid"], $sendMailProps["ipmsentmailentryid"]));
452
-        if(isset($storeprops[$sendMailProps["outboxentryid"]]))
452
+        if (isset($storeprops[$sendMailProps["outboxentryid"]]))
453 453
             $outbox = mapi_msgstore_openentry($this->defaultstore, $storeprops[$sendMailProps["outboxentryid"]]);
454 454
 
455
-        if(!$outbox)
455
+        if (!$outbox)
456 456
             throw new StatusException(sprintf("Grommunio->SendMail(): No Outbox found or unable to create message: 0x%X", mapi_last_hresult()), SYNC_COMMONSTATUS_SERVERERROR);
457 457
 
458 458
         $mapimessage = mapi_folder_createmessage($outbox);
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
         // which results in spooler not being able to send the message.
505 505
         // @see http://jira.zarafa.com/browse/ZP-85
506 506
         mapi_deleteprops($mapimessage,
507
-            array(  $sendMailProps["sentrepresentingname"], $sendMailProps["sentrepresentingemail"], $sendMailProps["representingentryid"],
507
+            array($sendMailProps["sentrepresentingname"], $sendMailProps["sentrepresentingemail"], $sendMailProps["representingentryid"],
508 508
                     $sendMailProps["sentrepresentingaddt"], $sendMailProps["sentrepresentinsrchk"]));
509 509
 
510
-        if(isset($sm->source->itemid) && $sm->source->itemid) {
510
+        if (isset($sm->source->itemid) && $sm->source->itemid) {
511 511
             // answering an email in a public/shared folder
512 512
             // TODO as the store is setup, we should actually user $this->store instead of $this->defaultstore - nevertheless we need to make sure this store is able to send mail (has an outbox)
513 513
             if (!$this->Setup(ZPush::GetAdditionalSyncFolderStore($sm->source->folderid)))
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
                         $bodyHtml = MAPIUtils::readPropStream($mapimessage, PR_HTML);
549 549
                     }
550 550
                     $cpid = mapi_getprops($fwmessage, array($sendMailProps["internetcpid"]));
551
-                    if($sm->forwardflag) {
551
+                    if ($sm->forwardflag) {
552 552
                         // attach the original attachments to the outgoing message
553 553
                         $this->copyAttachments($mapimessage, $fwmessage);
554 554
                     }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
      */
629 629
     public function Fetch($folderid, $id, $contentparameters) {
630 630
         // SEARCH fetches with folderid == false and PR_ENTRYID as ID
631
-        if (! $folderid) {
631
+        if (!$folderid) {
632 632
             $entryid = hex2bin($id);
633 633
             $sk = $id;
634 634
         }
@@ -639,12 +639,12 @@  discard block
 block discarded – undo
639 639
             $entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($sk));
640 640
 
641 641
         }
642
-        if(!$entryid)
642
+        if (!$entryid)
643 643
             throw new StatusException(sprintf("Grommunio->Fetch('%s','%s'): Error getting entryid: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
644 644
 
645 645
         // open the message
646 646
         $message = mapi_msgstore_openentry($this->store, $entryid);
647
-        if(!$message)
647
+        if (!$message)
648 648
             throw new StatusException(sprintf("Grommunio->Fetch('%s','%s'): Error, unable to open message: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
649 649
 
650 650
         // convert the mapi message into a SyncObject and return it
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     public function GetAttachmentData($attname) {
692 692
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetAttachmentData('%s')", $attname));
693 693
 
694
-        if(!strpos($attname, ":"))
694
+        if (!strpos($attname, ":"))
695 695
             throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, attachment requested for non-existing item", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
696 696
 
697 697
         list($id, $attachnum, $parentEntryid) = explode(":", $attname);
@@ -701,12 +701,12 @@  discard block
 block discarded – undo
701 701
 
702 702
         $entryid = hex2bin($id);
703 703
         $message = mapi_msgstore_openentry($this->store, $entryid);
704
-        if(!$message)
704
+        if (!$message)
705 705
             throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, unable to open item for attachment data for id '%s' with: 0x%X", $attname, $id, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
706 706
 
707 707
         MAPIUtils::ParseSmime($this->session, $this->defaultstore, $this->getAddressbook(), $message);
708 708
         $attach = mapi_message_openattach($message, $attachnum);
709
-        if(!$attach)
709
+        if (!$attach)
710 710
             throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, unable to open attachment number '%s' with: 0x%X", $attname, $attachnum, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
711 711
 
712 712
         // get necessary attachment props
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
         else
724 724
             $stream = mapi_openproperty($attach, PR_ATTACH_DATA_BIN, IID_IStream, 0, 0);
725 725
 
726
-        if(!$stream)
726
+        if (!$stream)
727 727
             throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, unable to open attachment data stream: 0x%X", $attname, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
728 728
 
729 729
         // put the mapi stream into a wrapper to get a standard stream
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         if ($includeSubfolders)
763 763
             $flags = DEL_ASSOCIATED;
764 764
 
765
-        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->EmptyFolder('%s','%s'): emptying folder",$folderid, Utils::PrintAsString($includeSubfolders)));
765
+        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->EmptyFolder('%s','%s'): emptying folder", $folderid, Utils::PrintAsString($includeSubfolders)));
766 766
 
767 767
         // empty folder!
768 768
         mapi_folder_emptyfolder($folder, $flags);
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
             throw new StatusException(sprintf("Grommunio->MeetingResponse('%s', '%s', '%s'): Error, unable to entryid of the message 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ);
793 793
 
794 794
         $mapimessage = mapi_msgstore_openentry($this->store, $reqentryid);
795
-        if(!$mapimessage)
795
+        if (!$mapimessage)
796 796
             throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error, unable to open request message for response 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ);
797 797
 
798 798
         // ios sends calendar item in MeetingResponse
@@ -834,10 +834,10 @@  discard block
 block discarded – undo
834 834
 
835 835
         $meetingrequest = new Meetingrequest($this->store, $mapimessage, $this->session);
836 836
 
837
-        if(!$meetingrequest->isMeetingRequest())
837
+        if (!$meetingrequest->isMeetingRequest())
838 838
             throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error, attempt to respond to non-meeting request", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ);
839 839
 
840
-        if($meetingrequest->isLocalOrganiser())
840
+        if ($meetingrequest->isLocalOrganiser())
841 841
             throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error, attempt to response to meeting request that we organized", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ);
842 842
 
843 843
         // Process the meeting response. We don't have to send the actual meeting response
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
                 $sendresponse = true;
855 855
             }
856 856
         }
857
-        switch($response) {
857
+        switch ($response) {
858 858
             case 1:     // accept
859 859
             default:
860 860
                 $entryid = $meetingrequest->doAccept(false, $sendresponse, false, false, false, false, true); // last true is the $userAction
@@ -922,10 +922,10 @@  discard block
 block discarded – undo
922 922
         if ($calFolderId) {
923 923
             $shortFolderId = ZPush::GetDeviceManager()->GetFolderIdForBackendId($calFolderId);
924 924
             if ($calFolderId != $shortFolderId) {
925
-                $prefix = $shortFolderId . ':';
925
+                $prefix = $shortFolderId.':';
926 926
             }
927 927
         }
928
-        return $prefix . $calendarid;
928
+        return $prefix.$calendarid;
929 929
     }
930 930
 
931 931
     /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 
946 946
         $this->changesSink = @mapi_sink_create();
947 947
 
948
-        if (! $this->changesSink || mapi_last_hresult()) {
948
+        if (!$this->changesSink || mapi_last_hresult()) {
949 949
             ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->HasChangesSink(): sink could not be created with  0x%X", mapi_last_hresult()));
950 950
             return false;
951 951
         }
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
         }
1281 1281
         // if no folder was required then search in the entire store
1282 1282
         else {
1283
-            $tmp = mapi_getprops($this->store, array(PR_ENTRYID,PR_DISPLAY_NAME,PR_IPM_SUBTREE_ENTRYID));
1283
+            $tmp = mapi_getprops($this->store, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_IPM_SUBTREE_ENTRYID));
1284 1284
             $searchFolders[] = $tmp[PR_IPM_SUBTREE_ENTRYID];
1285 1285
         }
1286 1286
         $items = array();
@@ -1297,15 +1297,14 @@  discard block
 block discarded – undo
1297 1297
         // do the search and wait for all the results available
1298 1298
         while (time() - $searchStart < SEARCH_WAIT) {
1299 1299
             $searchcriteria = mapi_folder_getsearchcriteria($searchFolder);
1300
-            if(($searchcriteria["searchstate"] & SEARCH_REBUILD) == 0)
1300
+            if (($searchcriteria["searchstate"] & SEARCH_REBUILD) == 0)
1301 1301
                 break; // Search is done
1302 1302
             sleep(1);
1303 1303
         }
1304 1304
 
1305 1305
         // if the search range is set limit the result to it, otherwise return all found messages
1306 1306
         $rows = (is_array($searchRange) && isset($searchRange[0], $searchRange[1])) ?
1307
-            mapi_table_queryrows($table, array(PR_ENTRYID), $searchRange[0], $searchRange[1] - $searchRange[0] + 1) :
1308
-            mapi_table_queryrows($table, array(PR_ENTRYID), 0, SEARCH_MAXRESULTS);
1307
+            mapi_table_queryrows($table, array(PR_ENTRYID), $searchRange[0], $searchRange[1] - $searchRange[0] + 1) : mapi_table_queryrows($table, array(PR_ENTRYID), 0, SEARCH_MAXRESULTS);
1309 1308
 
1310 1309
         $cnt = count($rows);
1311 1310
         $items['searchtotal'] = $cnt;
@@ -1339,7 +1338,7 @@  discard block
 block discarded – undo
1339 1338
         }
1340 1339
 
1341 1340
         $finderfolder = mapi_msgstore_openentry($this->store, $storeProps[PR_FINDER_ENTRYID]);
1342
-        if(mapi_last_hresult() != NOERROR) {
1341
+        if (mapi_last_hresult() != NOERROR) {
1343 1342
             ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->TerminateSearch(): Unable to open search folder (0x%X)", mapi_last_hresult()));
1344 1343
             return false;
1345 1344
         }
@@ -1356,7 +1355,7 @@  discard block
 block discarded – undo
1356 1355
             TBL_BATCH);
1357 1356
 
1358 1357
         $folders = mapi_table_queryallrows($hierarchytable, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_LAST_MODIFICATION_TIME));
1359
-        foreach($folders as $folder) {
1358
+        foreach ($folders as $folder) {
1360 1359
             mapi_folder_deletefolder($finderfolder, $folder[PR_ENTRYID]);
1361 1360
         }
1362 1361
         return true;
@@ -1485,20 +1484,20 @@  discard block
 block discarded – undo
1485 1484
             // get the store
1486 1485
             $userstore = $this->openMessageStore($user);
1487 1486
             $rootfolder = mapi_msgstore_openentry($userstore);
1488
-            $hierarchy =  mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
1487
+            $hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
1489 1488
             $rows = mapi_table_queryallrows($hierarchy, array(PR_SOURCE_KEY, PR_LOCAL_COMMIT_TIME_MAX, PR_CONTENT_COUNT, PR_CONTENT_UNREAD, PR_DELETED_MSG_COUNT));
1490 1489
 
1491 1490
             if (count($rows) == 0) {
1492 1491
                 ZLog::Write(LOGLEVEL_INFO, sprintf("Grommunio->GetFolderStat(): could not access folder statistics for user '%s'. Probably missing 'read' permissions on the root folder! Folders of this store will be synchronized ONCE per hour only!", $user));
1493 1492
             }
1494 1493
 
1495
-            foreach($rows as $folder) {
1496
-                $commit_time = isset($folder[PR_LOCAL_COMMIT_TIME_MAX])? $folder[PR_LOCAL_COMMIT_TIME_MAX] : "0000000000";
1497
-                $content_count = isset($folder[PR_CONTENT_COUNT])? $folder[PR_CONTENT_COUNT] : -1;
1498
-                $content_unread = isset($folder[PR_CONTENT_UNREAD])? $folder[PR_CONTENT_UNREAD] : -1;
1499
-                $content_deleted = isset($folder[PR_DELETED_MSG_COUNT])? $folder[PR_DELETED_MSG_COUNT] : -1;
1494
+            foreach ($rows as $folder) {
1495
+                $commit_time = isset($folder[PR_LOCAL_COMMIT_TIME_MAX]) ? $folder[PR_LOCAL_COMMIT_TIME_MAX] : "0000000000";
1496
+                $content_count = isset($folder[PR_CONTENT_COUNT]) ? $folder[PR_CONTENT_COUNT] : -1;
1497
+                $content_unread = isset($folder[PR_CONTENT_UNREAD]) ? $folder[PR_CONTENT_UNREAD] : -1;
1498
+                $content_deleted = isset($folder[PR_DELETED_MSG_COUNT]) ? $folder[PR_DELETED_MSG_COUNT] : -1;
1500 1499
 
1501
-                $this->folderStatCache[$user][bin2hex($folder[PR_SOURCE_KEY])] = $commit_time ."/". $content_count ."/". $content_unread ."/". $content_deleted;
1500
+                $this->folderStatCache[$user][bin2hex($folder[PR_SOURCE_KEY])] = $commit_time."/".$content_count."/".$content_unread."/".$content_deleted;
1502 1501
             }
1503 1502
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetFolderStat() fetched status information of %d folders for store '%s'", count($this->folderStatCache[$user]), $user));
1504 1503
         }
@@ -1523,22 +1522,22 @@  discard block
 block discarded – undo
1523 1522
         $userStoreInfo = new UserStoreInfo();
1524 1523
 
1525 1524
         $rootfolder = mapi_msgstore_openentry($this->store);
1526
-        $hierarchy =  mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
1525
+        $hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
1527 1526
         // Do not take hidden and system folders into account
1528 1527
         // TODO make this restriction generic and use for hierarchy?
1529 1528
         $restrict = array(RES_AND, array(
1530
-                            array(  RES_PROPERTY,
1531
-                                array(  RELOP => RELOP_NE,
1529
+                            array(RES_PROPERTY,
1530
+                                array(RELOP => RELOP_NE,
1532 1531
                                         ULPROPTAG => PR_ATTR_HIDDEN,
1533 1532
                                         VALUE => true),
1534 1533
                             ),
1535
-                            array(  RES_PROPERTY,
1536
-                                array(  RELOP => RELOP_EQ,
1534
+                            array(RES_PROPERTY,
1535
+                                array(RELOP => RELOP_EQ,
1537 1536
                                         ULPROPTAG => PR_FOLDER_TYPE,
1538 1537
                                         VALUE => FOLDER_GENERIC),
1539 1538
                             ),
1540
-                            array(  RES_EXIST,
1541
-                                array(  ULPROPTAG => PR_CONTAINER_CLASS),
1539
+                            array(RES_EXIST,
1540
+                                array(ULPROPTAG => PR_CONTAINER_CLASS),
1542 1541
                             ),
1543 1542
                         ));
1544 1543
         mapi_table_restrict($hierarchy, $restrict);
@@ -1665,7 +1664,7 @@  discard block
 block discarded – undo
1665 1664
                 $devid));
1666 1665
             }
1667 1666
         }
1668
-        $messageName = rtrim((($key !== false) ? $key."-" : "") . (($type !== "") ? $type : ""), "-");
1667
+        $messageName = rtrim((($key !== false) ? $key."-" : "").(($type !== "") ? $type : ""), "-");
1669 1668
         $restriction = $this->getStateMessageRestriction($messageName, $counter, $thisCounterOnly);
1670 1669
         $stateFolderContents = mapi_folder_getcontentstable($this->stateFolder, MAPI_ASSOCIATED);
1671 1670
         if ($stateFolderContents) {
@@ -1675,7 +1674,7 @@  discard block
 block discarded – undo
1675 1674
             if ($rowCnt > 0) {
1676 1675
                 $rows = mapi_table_queryallrows($stateFolderContents, [PR_ENTRYID]);
1677 1676
                 $entryids = [];
1678
-                foreach($rows as $row) {
1677
+                foreach ($rows as $row) {
1679 1678
                     $entryids[] = $row[PR_ENTRYID];
1680 1679
                 }
1681 1680
                 mapi_folder_deletemessages($this->stateFolder, $entryids, DELETE_HARD_DELETE);
@@ -1694,7 +1693,7 @@  discard block
 block discarded – undo
1694 1693
      */
1695 1694
     public function LinkUserDevice($username, $devid) {
1696 1695
         $device = [$devid => time()];
1697
-        $this->setDeviceUserData($this->type, $device, $username, -1, $subkey=-1, $doCas="merge");
1696
+        $this->setDeviceUserData($this->type, $device, $username, -1, $subkey = -1, $doCas = "merge");
1698 1697
         return false;
1699 1698
     }
1700 1699
 
@@ -1843,7 +1842,7 @@  discard block
 block discarded – undo
1843 1842
                 $devid));
1844 1843
             }
1845 1844
         }
1846
-        $messageName = rtrim((($key !== false) ? $key."-" : "") . (($type !== "") ? $type : ""), "-");
1845
+        $messageName = rtrim((($key !== false) ? $key."-" : "").(($type !== "") ? $type : ""), "-");
1847 1846
         $restriction = $this->getStateMessageRestriction($messageName, $counter, true);
1848 1847
         $stateFolderContents = mapi_folder_getcontentstable($this->stateFolder, MAPI_ASSOCIATED);
1849 1848
         if ($stateFolderContents) {
@@ -1853,7 +1852,7 @@  discard block
 block discarded – undo
1853 1852
                 $stateFolderRows = mapi_table_queryrows($stateFolderContents, [PR_ENTRYID], 0, 1);
1854 1853
                 return mapi_msgstore_openentry($this->store, $stateFolderRows[0][PR_ENTRYID]);
1855 1854
             }
1856
-            elseif($rowCnt > 1) {
1855
+            elseif ($rowCnt > 1) {
1857 1856
                 ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->getStateMessage(): Found several (%d) states for '%s'", $rowCnt, $messageName));
1858 1857
             }
1859 1858
         }
@@ -1886,17 +1885,17 @@  discard block
 block discarded – undo
1886 1885
             $stateMessage = mapi_folder_createmessage($this->stateFolder, MAPI_ASSOCIATED);
1887 1886
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->setStateMessage(): mapi_folder_createmessage 0x%08X", mapi_last_hresult()));
1888 1887
 
1889
-            $messageName = rtrim((($key !== false) ? $key."-" : "") . (($type !== "") ? $type : ""), "-");
1888
+            $messageName = rtrim((($key !== false) ? $key."-" : "").(($type !== "") ? $type : ""), "-");
1890 1889
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->setStateMessage(): creating new state message '%s-%d'", $messageName, is_int($counter) ? $counter : 0));
1891 1890
             mapi_setprops($stateMessage, [PR_DISPLAY_NAME => $messageName, PR_MESSAGE_CLASS => 'IPM.Note.GrommunioState']);
1892 1891
         }
1893 1892
         if (isset($stateMessage)) {
1894
-            $jsonEncodedState = is_object($state) || is_array($state) ? json_encode($state, JSON_INVALID_UTF8_IGNORE | JSON_UNESCAPED_UNICODE) : $state;
1893
+            $jsonEncodedState = is_object($state) || is_array($state) ? json_encode($state, JSON_INVALID_UTF8_IGNORE|JSON_UNESCAPED_UNICODE) : $state;
1895 1894
 
1896 1895
             $encodedState = base64_encode($jsonEncodedState);
1897 1896
             $encodedStateLength = strlen($encodedState);
1898 1897
             mapi_setprops($stateMessage, [PR_LAST_VERB_EXECUTED => is_int($counter) ? $counter : 0]);
1899
-            $stream = mapi_openproperty($stateMessage, PR_BODY, IID_IStream, STGM_DIRECT, MAPI_CREATE | MAPI_MODIFY);
1898
+            $stream = mapi_openproperty($stateMessage, PR_BODY, IID_IStream, STGM_DIRECT, MAPI_CREATE|MAPI_MODIFY);
1900 1899
             mapi_stream_setsize($stream, $encodedStateLength);
1901 1900
             mapi_stream_write($stream, $encodedState);
1902 1901
             mapi_stream_commit($stream);
@@ -1917,14 +1916,14 @@  discard block
 block discarded – undo
1917 1916
      */
1918 1917
     private function getStateFolderRestriction($folderName) {
1919 1918
         return [RES_AND, [
1920
-            [   RES_PROPERTY,
1921
-                [   RELOP => RELOP_EQ,
1919
+            [RES_PROPERTY,
1920
+                [RELOP => RELOP_EQ,
1922 1921
                     ULPROPTAG => PR_DISPLAY_NAME,
1923 1922
                     VALUE => $folderName
1924 1923
                 ],
1925 1924
             ],
1926
-            [   RES_PROPERTY,
1927
-                [   RELOP => RELOP_EQ,
1925
+            [RES_PROPERTY,
1926
+                [RELOP => RELOP_EQ,
1928 1927
                     ULPROPTAG => PR_ATTR_HIDDEN,
1929 1928
                     VALUE => true
1930 1929
                 ],
@@ -1944,20 +1943,20 @@  discard block
 block discarded – undo
1944 1943
      */
1945 1944
     private function getStateMessageRestriction($messageName, $counter, $thisCounterOnly = false) {
1946 1945
         return [RES_AND, [
1947
-            [   RES_PROPERTY,
1948
-                [   RELOP => RELOP_EQ,
1946
+            [RES_PROPERTY,
1947
+                [RELOP => RELOP_EQ,
1949 1948
                     ULPROPTAG => PR_DISPLAY_NAME,
1950 1949
                     VALUE => $messageName
1951 1950
                 ],
1952 1951
             ],
1953
-            [   RES_PROPERTY,
1954
-                [   RELOP => RELOP_EQ,
1952
+            [RES_PROPERTY,
1953
+                [RELOP => RELOP_EQ,
1955 1954
                     ULPROPTAG => PR_MESSAGE_CLASS,
1956 1955
                     VALUE => 'IPM.Note.GrommunioState'
1957 1956
                 ],
1958 1957
             ],
1959
-            [   RES_PROPERTY,
1960
-                [   RELOP => $thisCounterOnly ? RELOP_EQ : RELOP_LT,
1958
+            [RES_PROPERTY,
1959
+                [RELOP => $thisCounterOnly ? RELOP_EQ : RELOP_LT,
1961 1960
                     ULPROPTAG => PR_LAST_VERB_EXECUTED,
1962 1961
                     VALUE => $counter
1963 1962
                 ],
@@ -1978,7 +1977,7 @@  discard block
 block discarded – undo
1978 1977
      */
1979 1978
     private function getHierarchyHash() {
1980 1979
         $rootfolder = mapi_msgstore_openentry($this->defaultstore);
1981
-        $hierarchy =  mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
1980
+        $hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
1982 1981
         return md5(serialize(mapi_table_queryallrows($hierarchy, array(PR_DISPLAY_NAME, PR_PARENT_ENTRYID))));
1983 1982
     }
1984 1983
 
@@ -1994,7 +1993,7 @@  discard block
 block discarded – undo
1994 1993
     private function adviseStoreToSink($store) {
1995 1994
         // check if we already advised the store
1996 1995
         if (!in_array($store, $this->changesSinkStores)) {
1997
-            mapi_msgstore_advise($store, null, fnevObjectModified | fnevObjectCreated | fnevObjectMoved | fnevObjectDeleted, $this->changesSink);
1996
+            mapi_msgstore_advise($store, null, fnevObjectModified|fnevObjectCreated|fnevObjectMoved|fnevObjectDeleted, $this->changesSink);
1998 1997
 
1999 1998
             if (mapi_last_hresult()) {
2000 1999
                 ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->adviseStoreToSink(): failed to advised store '%s' with code 0x%X. Polling will be performed.", $store, mapi_last_hresult()));
@@ -2035,11 +2034,11 @@  discard block
 block discarded – undo
2035 2034
             $storestables = mapi_getmsgstorestable($this->session);
2036 2035
             $result = mapi_last_hresult();
2037 2036
 
2038
-            if ($result == NOERROR){
2037
+            if ($result == NOERROR) {
2039 2038
                 $rows = mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_DEFAULT_STORE, PR_MDB_PROVIDER));
2040 2039
 
2041
-                foreach($rows as $row) {
2042
-                    if(!$return_public && isset($row[PR_DEFAULT_STORE]) && $row[PR_DEFAULT_STORE] == true) {
2040
+                foreach ($rows as $row) {
2041
+                    if (!$return_public && isset($row[PR_DEFAULT_STORE]) && $row[PR_DEFAULT_STORE] == true) {
2043 2042
                         $entryid = $row[PR_ENTRYID];
2044 2043
                         break;
2045 2044
                     }
@@ -2053,7 +2052,7 @@  discard block
 block discarded – undo
2053 2052
         else
2054 2053
             $entryid = @mapi_msgstore_createentryid($this->defaultstore, $user);
2055 2054
 
2056
-        if($entryid) {
2055
+        if ($entryid) {
2057 2056
             $store = @mapi_openmsgstore($this->session, $entryid);
2058 2057
 
2059 2058
             if (!$store) {
@@ -2065,7 +2064,7 @@  discard block
 block discarded – undo
2065 2064
             if (!isset($this->storeCache[$user]))
2066 2065
                 $this->storeCache[$user] = $store;
2067 2066
 
2068
-            ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->openMessageStore('%s'): Found '%s' store: '%s'", $user, (($return_public)?'PUBLIC':'DEFAULT'),$store));
2067
+            ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->openMessageStore('%s'): Found '%s' store: '%s'", $user, (($return_public) ? 'PUBLIC' : 'DEFAULT'), $store));
2069 2068
             return $store;
2070 2069
         }
2071 2070
         else {
@@ -2106,7 +2105,7 @@  discard block
 block discarded – undo
2106 2105
             ($props[PR_RIGHTS] & ecRightsDeleteOwned) &&
2107 2106
             ($props[PR_RIGHTS] & ecRightsEditAny) &&
2108 2107
             ($props[PR_RIGHTS] & ecRightsDeleteAny) &&
2109
-            ($props[PR_RIGHTS] & ecRightsFolderVisible) ) {
2108
+            ($props[PR_RIGHTS] & ecRightsFolderVisible)) {
2110 2109
             return true;
2111 2110
         }
2112 2111
         return false;
@@ -2210,7 +2209,7 @@  discard block
 block discarded – undo
2210 2209
                 }
2211 2210
             }
2212 2211
             if ($oof->oofstate == SYNC_SETTINGSOOF_TIMEBASED) {
2213
-                if(isset($oof->starttime) && isset($oof->endtime)) {
2212
+                if (isset($oof->starttime) && isset($oof->endtime)) {
2214 2213
                     $props[PR_EC_OUTOFOFFICE_FROM] = $oof->starttime;
2215 2214
                     $props[PR_EC_OUTOFOFFICE_UNTIL] = $oof->endtime;
2216 2215
                 }
@@ -2222,7 +2221,7 @@  discard block
 block discarded – undo
2222 2221
                 $deleteProps = array(PR_EC_OUTOFOFFICE_FROM, PR_EC_OUTOFOFFICE_UNTIL);
2223 2222
             }
2224 2223
         }
2225
-        elseif($oof->oofstate == SYNC_SETTINGSOOF_DISABLED) {
2224
+        elseif ($oof->oofstate == SYNC_SETTINGSOOF_DISABLED) {
2226 2225
             $props[PR_EC_OUTOFOFFICE] = false;
2227 2226
             $deleteProps = array(PR_EC_OUTOFOFFICE_FROM, PR_EC_OUTOFOFFICE_UNTIL);
2228 2227
         }
@@ -2309,7 +2308,7 @@  discard block
 block discarded – undo
2309 2308
      * @return void
2310 2309
      */
2311 2310
     private function getImportanceAndPriority($xPriority, &$mapiprops, $sendMailProps) {
2312
-        switch($xPriority) {
2311
+        switch ($xPriority) {
2313 2312
             case 1:
2314 2313
             case 2:
2315 2314
                 $priority = PRIO_URGENT;
@@ -2342,8 +2341,8 @@  discard block
 block discarded – undo
2342 2341
         $attachtable = mapi_message_getattachmenttable($fromMessage);
2343 2342
         $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
2344 2343
 
2345
-        foreach($rows as $row) {
2346
-            if(isset($row[PR_ATTACH_NUM])) {
2344
+        foreach ($rows as $row) {
2345
+            if (isset($row[PR_ATTACH_NUM])) {
2347 2346
                 $attach = mapi_message_openattach($fromMessage, $row[PR_ATTACH_NUM]);
2348 2347
                 $newattach = mapi_message_createattach($toMessage);
2349 2348
                 mapi_copyto($attach, array(), array(), $newattach, 0);
@@ -2363,7 +2362,7 @@  discard block
 block discarded – undo
2363 2362
     private function getSearchFolder() {
2364 2363
         // create new or open existing search folder
2365 2364
         $searchFolderRoot = $this->getSearchFoldersRoot($this->store);
2366
-        if($searchFolderRoot === false) {
2365
+        if ($searchFolderRoot === false) {
2367 2366
             // error in finding search root folder
2368 2367
             // or store doesn't support search folders
2369 2368
             return false;
@@ -2371,7 +2370,7 @@  discard block
 block discarded – undo
2371 2370
 
2372 2371
         $searchFolder = $this->createSearchFolder($searchFolderRoot);
2373 2372
 
2374
-        if($searchFolder !== false && mapi_last_hresult() == NOERROR) {
2373
+        if ($searchFolder !== false && mapi_last_hresult() == NOERROR) {
2375 2374
             return $searchFolder;
2376 2375
         }
2377 2376
         return false;
@@ -2388,14 +2387,14 @@  discard block
 block discarded – undo
2388 2387
     private function getSearchFoldersRoot() {
2389 2388
         // check if we can create search folders
2390 2389
         $storeProps = mapi_getprops($this->store, array(PR_STORE_SUPPORT_MASK, PR_FINDER_ENTRYID));
2391
-        if(($storeProps[PR_STORE_SUPPORT_MASK] & STORE_SEARCH_OK) != STORE_SEARCH_OK) {
2390
+        if (($storeProps[PR_STORE_SUPPORT_MASK] & STORE_SEARCH_OK) != STORE_SEARCH_OK) {
2392 2391
             ZLog::Write(LOGLEVEL_WARN, "Grommunio->getSearchFoldersRoot(): Store doesn't support search folders. Public store doesn't have FINDER_ROOT folder");
2393 2392
             return false;
2394 2393
         }
2395 2394
 
2396 2395
         // open search folders root
2397 2396
         $searchRootFolder = mapi_msgstore_openentry($this->store, $storeProps[PR_FINDER_ENTRYID]);
2398
-        if(mapi_last_hresult() != NOERROR) {
2397
+        if (mapi_last_hresult() != NOERROR) {
2399 2398
             ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->getSearchFoldersRoot(): Unable to open search folder (0x%X)", mapi_last_hresult()));
2400 2399
             return false;
2401 2400
         }
@@ -2445,17 +2444,17 @@  discard block
 block discarded – undo
2445 2444
         $searchGreater = strtotime($cpo->GetSearchValueGreater());
2446 2445
         $searchLess = strtotime($cpo->GetSearchValueLess());
2447 2446
 
2448
-        if (version_compare(phpversion(),'5.3.4') < 0) {
2447
+        if (version_compare(phpversion(), '5.3.4') < 0) {
2449 2448
             ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->getSearchRestriction(): Your system's PHP version (%s) might not correctly process unicode strings. Search containing such characters might not return correct results. It is recommended to update to at least PHP 5.3.4. See ZP-541 for more information.", phpversion()));
2450 2449
         }
2451 2450
         // split the search on whitespache and look for every word
2452 2451
         $searchText = preg_split("/\W+/u", $searchText);
2453 2452
         $searchProps = array(PR_BODY, PR_SUBJECT, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SENDER_NAME, PR_SENDER_EMAIL_ADDRESS, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS);
2454 2453
         $resAnd = array();
2455
-        foreach($searchText as $term) {
2454
+        foreach ($searchText as $term) {
2456 2455
             $resOr = array();
2457 2456
 
2458
-            foreach($searchProps as $property) {
2457
+            foreach ($searchProps as $property) {
2459 2458
                 array_push($resOr,
2460 2459
                     array(RES_CONTENT,
2461 2460
                         array(
@@ -2617,7 +2616,7 @@  discard block
 block discarded – undo
2617 2616
         $contactfolder = mapi_msgstore_openentry($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID]);
2618 2617
         $subfolders = MAPIUtils::GetSubfoldersForType($contactfolder, "IPF.Contact");
2619 2618
         if ($subfolders !== false) {
2620
-            foreach($subfolders as $folder) {
2619
+            foreach ($subfolders as $folder) {
2621 2620
                 $contacts = $this->getContactsFromFolder($this->defaultstore, $folder[PR_ENTRYID], $to);
2622 2621
                 if ($contacts !== false) {
2623 2622
                     ZLog::Write(LOGLEVEL_WBXML, sprintf("Grommunio->resolveRecipientContact(): Found %d contacts in contacts' subfolder.", count($contacts)));
@@ -2632,9 +2631,9 @@  discard block
 block discarded – undo
2632 2631
         $storestables = mapi_getmsgstorestable($this->session);
2633 2632
         $result = mapi_last_hresult();
2634 2633
 
2635
-        if ($result == NOERROR){
2634
+        if ($result == NOERROR) {
2636 2635
             $rows = mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_DEFAULT_STORE, PR_MDB_PROVIDER));
2637
-            foreach($rows as $row) {
2636
+            foreach ($rows as $row) {
2638 2637
                 if (isset($row[PR_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
2639 2638
                     // TODO refactor public store
2640 2639
                     $publicstore = mapi_openmsgstore($this->session, $row[PR_ENTRYID]);
@@ -2642,7 +2641,7 @@  discard block
 block discarded – undo
2642 2641
 
2643 2642
                     $subfolders = MAPIUtils::GetSubfoldersForType($publicfolder, "IPF.Contact");
2644 2643
                     if ($subfolders !== false) {
2645
-                        foreach($subfolders as $folder) {
2644
+                        foreach ($subfolders as $folder) {
2646 2645
                             $contacts = $this->getContactsFromFolder($publicstore, $folder[PR_ENTRYID], $to);
2647 2646
                             if ($contacts !== false) {
2648 2647
                                 ZLog::Write(LOGLEVEL_WBXML, sprintf("Grommunio->resolveRecipientContact(): Found %d contacts in public contacts folder.", count($contacts)));
@@ -2685,7 +2684,7 @@  discard block
 block discarded – undo
2685 2684
             return $cert;
2686 2685
         }
2687 2686
         $cert->status = SYNC_RESOLVERECIPSSTATUS_SUCCESS;
2688
-        $cert->certificatecount = count ($certificates);
2687
+        $cert->certificatecount = count($certificates);
2689 2688
         $cert->recipientcount = $recipientCount;
2690 2689
         $cert->certificate = array();
2691 2690
         foreach ($certificates as $certificate) {
@@ -2851,7 +2850,7 @@  discard block
 block discarded – undo
2851 2850
             $mobileDisabled = in_array(self::MOBILE_ENABLED, $enabledFeatures[PR_EC_DISABLED_FEATURES]);
2852 2851
             $deviceId = Request::GetDeviceID();
2853 2852
             // Checks for deviceId present in zarafaDisabledFeatures LDAP array attribute. Check is performed case insensitive.
2854
-            $deviceIdDisabled = ( ($deviceId !==null) && in_array($deviceId, array_map('strtolower', $enabledFeatures[PR_EC_DISABLED_FEATURES])) )? true : false;
2853
+            $deviceIdDisabled = (($deviceId !== null) && in_array($deviceId, array_map('strtolower', $enabledFeatures[PR_EC_DISABLED_FEATURES]))) ? true : false;
2855 2854
             if ($mobileDisabled) {
2856 2855
                 throw new FatalException("User is disabled for grommunio-sync.");
2857 2856
             }
Please login to merge, or discard this patch.
lib/grommunio/mapiutils.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public static function GetEmailRestriction($timestamp) {
26 26
         // ATTENTION: ON CHANGING THIS RESTRICTION, MAPIUtils::IsInEmailSyncInterval() also needs to be changed
27
-        $restriction = array ( RES_PROPERTY,
28
-                          array (   RELOP => RELOP_GE,
27
+        $restriction = array(RES_PROPERTY,
28
+                          array(RELOP => RELOP_GE,
29 29
                                     ULPROPTAG => PR_MESSAGE_DELIVERY_TIME,
30 30
                                     VALUE => $timestamp
31 31
                           )
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                                )
130 130
                          ) // EXISTS OR
131 131
                    )
132
-             );        // global OR
132
+             ); // global OR
133 133
 
134 134
         return $restriction;
135 135
     }
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
      * @return array
143 143
      */
144 144
     public static function GetContactPicRestriction() {
145
-        return array ( RES_PROPERTY,
146
-                        array (
145
+        return array(RES_PROPERTY,
146
+                        array(
147 147
                             RELOP => RELOP_EQ,
148 148
                             ULPROPTAG => mapi_prop_tag(PT_BOOLEAN, 0x7FFF),
149 149
                             VALUE => true
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
                     array(
166 166
                         array(RES_OR,
167 167
                             array(
168
-                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => PR_DISPLAY_NAME, VALUE => $query)),
169
-                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => PR_ACCOUNT, VALUE => $query)),
170
-                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => PR_SMTP_ADDRESS, VALUE => $query)),
168
+                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING|FL_IGNORECASE, ULPROPTAG => PR_DISPLAY_NAME, VALUE => $query)),
169
+                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING|FL_IGNORECASE, ULPROPTAG => PR_ACCOUNT, VALUE => $query)),
170
+                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING|FL_IGNORECASE, ULPROPTAG => PR_SMTP_ADDRESS, VALUE => $query)),
171 171
                             ), // RES_OR
172 172
                         ),
173 173
                         array(RES_OR,
174
-                            array (
174
+                            array(
175 175
                                 array(
176 176
                                         RES_PROPERTY,
177 177
                                         array(RELOP => RELOP_EQ, ULPROPTAG => PR_OBJECT_TYPE, VALUE => MAPI_MAILUSER)
@@ -202,20 +202,20 @@  discard block
 block discarded – undo
202 202
 
203 203
         return array(RES_OR,
204 204
                     array(
205
-                        array(  RES_PROPERTY,
206
-                                array(  RELOP => RELOP_EQ,
205
+                        array(RES_PROPERTY,
206
+                                array(RELOP => RELOP_EQ,
207 207
                                         ULPROPTAG => $props['emailaddress1'],
208 208
                                         VALUE => array($props['emailaddress1'] => $email),
209 209
                                 ),
210 210
                         ),
211
-                        array(  RES_PROPERTY,
212
-                                array(  RELOP => RELOP_EQ,
211
+                        array(RES_PROPERTY,
212
+                                array(RELOP => RELOP_EQ,
213 213
                                         ULPROPTAG => $props['emailaddress2'],
214 214
                                         VALUE => array($props['emailaddress2'] => $email),
215 215
                                 ),
216 216
                         ),
217
-                        array(  RES_PROPERTY,
218
-                                array(  RELOP => RELOP_EQ,
217
+                        array(RES_PROPERTY,
218
+                                array(RELOP => RELOP_EQ,
219 219
                                         ULPROPTAG => $props['emailaddress3'],
220 220
                                         VALUE => array($props['emailaddress3'] => $email),
221 221
                                 ),
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
      * @return array
234 234
      */
235 235
     public static function GetFolderTypeRestriction($foldertype) {
236
-        return array(   RES_PROPERTY,
237
-                        array(  RELOP => RELOP_EQ,
236
+        return array(RES_PROPERTY,
237
+                        array(RELOP => RELOP_EQ,
238 238
                                 ULPROPTAG => PR_CONTAINER_CLASS,
239 239
                                 VALUE => array(PR_CONTAINER_CLASS => $foldertype)
240 240
                         ),
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
         }
385 385
         $data = "";
386 386
         $string = "";
387
-        while(1) {
387
+        while (1) {
388 388
             $data = mapi_stream_read($stream, 1024);
389
-            if(strlen($data) == 0)
389
+            if (strlen($data) == 0)
390 390
                 break;
391 391
             $string .= $data;
392 392
         }
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
     }
463 463
 
464 464
     public static function GetSignedAttachmentRestriction() {
465
-        return array(  RES_PROPERTY,
466
-            array(  RELOP => RELOP_EQ,
465
+        return array(RES_PROPERTY,
466
+            array(RELOP => RELOP_EQ,
467 467
                 ULPROPTAG => PR_ATTACH_MIME_TAG,
468 468
                 VALUE => array(PR_ATTACH_MIME_TAG => 'multipart/signed')
469 469
             ),
@@ -486,66 +486,66 @@  discard block
 block discarded – undo
486 486
         if (!isset($messageprops[PR_RTF_IN_SYNC]))      $messageprops[PR_RTF_IN_SYNC]       = self::GetError(PR_RTF_IN_SYNC, $messageprops);
487 487
 
488 488
         if ( // 1
489
-                ($messageprops[PR_BODY]             == MAPI_E_NOT_FOUND) &&
490
-                ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_FOUND) &&
491
-                ($messageprops[PR_HTML]             == MAPI_E_NOT_FOUND))
489
+                ($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) &&
490
+                ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) &&
491
+                ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
492 492
                     return SYNC_BODYPREFERENCE_PLAIN;
493 493
                 elseif ( // 2
494
-                        ($messageprops[PR_BODY]             == MAPI_E_NOT_ENOUGH_MEMORY) &&
495
-                        ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_FOUND) &&
496
-                        ($messageprops[PR_HTML]             == MAPI_E_NOT_FOUND))
494
+                        ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
495
+                        ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) &&
496
+                        ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
497 497
                         return SYNC_BODYPREFERENCE_PLAIN;
498 498
                 elseif ( // 3
499
-                        ($messageprops[PR_BODY]             == MAPI_E_NOT_ENOUGH_MEMORY) &&
500
-                        ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_ENOUGH_MEMORY) &&
501
-                        ($messageprops[PR_HTML]             == MAPI_E_NOT_FOUND))
499
+                        ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
500
+                        ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
501
+                        ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
502 502
                         return SYNC_BODYPREFERENCE_RTF;
503 503
                 elseif ( // 4
504
-                        ($messageprops[PR_BODY]             == MAPI_E_NOT_ENOUGH_MEMORY) &&
505
-                        ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_ENOUGH_MEMORY) &&
506
-                        ($messageprops[PR_HTML]             == MAPI_E_NOT_ENOUGH_MEMORY) &&
504
+                        ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
505
+                        ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
506
+                        ($messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
507 507
                         ($messageprops[PR_RTF_IN_SYNC]))
508 508
                         return SYNC_BODYPREFERENCE_RTF;
509 509
                 elseif ( // 5
510
-                        ($messageprops[PR_BODY]             == MAPI_E_NOT_ENOUGH_MEMORY) &&
511
-                        ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_ENOUGH_MEMORY) &&
512
-                        ($messageprops[PR_HTML]             == MAPI_E_NOT_ENOUGH_MEMORY) &&
510
+                        ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
511
+                        ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
512
+                        ($messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
513 513
                         (!$messageprops[PR_RTF_IN_SYNC]))
514 514
                         return SYNC_BODYPREFERENCE_HTML;
515 515
                 elseif ( // 6
516
-                        ($messageprops[PR_RTF_COMPRESSED]   != MAPI_E_NOT_FOUND   || $messageprops[PR_RTF_COMPRESSED]  == MAPI_E_NOT_ENOUGH_MEMORY) &&
517
-                        ($messageprops[PR_HTML]             != MAPI_E_NOT_FOUND   || $messageprops[PR_HTML]            == MAPI_E_NOT_ENOUGH_MEMORY) &&
516
+                        ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
517
+                        ($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
518 518
                         ($messageprops[PR_RTF_IN_SYNC]))
519 519
                         return SYNC_BODYPREFERENCE_RTF;
520 520
                 elseif ( // 7
521
-                        ($messageprops[PR_RTF_COMPRESSED]   != MAPI_E_NOT_FOUND   || $messageprops[PR_RTF_COMPRESSED]  == MAPI_E_NOT_ENOUGH_MEMORY) &&
522
-                        ($messageprops[PR_HTML]             != MAPI_E_NOT_FOUND   || $messageprops[PR_HTML]            == MAPI_E_NOT_ENOUGH_MEMORY) &&
521
+                        ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
522
+                        ($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
523 523
                         (!$messageprops[PR_RTF_IN_SYNC]))
524 524
                         return SYNC_BODYPREFERENCE_HTML;
525 525
                 elseif ( // 8
526
-                        ($messageprops[PR_BODY]             != MAPI_E_NOT_FOUND   || $messageprops[PR_BODY]            == MAPI_E_NOT_ENOUGH_MEMORY) &&
527
-                        ($messageprops[PR_RTF_COMPRESSED]   != MAPI_E_NOT_FOUND   || $messageprops[PR_RTF_COMPRESSED]  == MAPI_E_NOT_ENOUGH_MEMORY) &&
526
+                        ($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
527
+                        ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
528 528
                         ($messageprops[PR_RTF_IN_SYNC]))
529 529
                         return SYNC_BODYPREFERENCE_RTF;
530 530
                 elseif ( // 9.1
531
-                        ($messageprops[PR_BODY]             != MAPI_E_NOT_FOUND   || $messageprops[PR_BODY]            == MAPI_E_NOT_ENOUGH_MEMORY) &&
532
-                        ($messageprops[PR_RTF_COMPRESSED]   != MAPI_E_NOT_FOUND   || $messageprops[PR_RTF_COMPRESSED]  == MAPI_E_NOT_ENOUGH_MEMORY) &&
531
+                        ($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
532
+                        ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
533 533
                         (!$messageprops[PR_RTF_IN_SYNC]))
534 534
                         return SYNC_BODYPREFERENCE_PLAIN;
535 535
                 elseif ( // 9.2
536
-                        ($messageprops[PR_RTF_COMPRESSED]   != MAPI_E_NOT_FOUND   || $messageprops[PR_RTF_COMPRESSED]  == MAPI_E_NOT_ENOUGH_MEMORY) &&
537
-                        ($messageprops[PR_BODY]             == MAPI_E_NOT_FOUND) &&
538
-                        ($messageprops[PR_HTML]             == MAPI_E_NOT_FOUND))
536
+                        ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
537
+                        ($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) &&
538
+                        ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
539 539
                         return SYNC_BODYPREFERENCE_RTF;
540 540
                 elseif ( // 9.3
541
-                        ($messageprops[PR_BODY]             != MAPI_E_NOT_FOUND   || $messageprops[PR_BODY]            == MAPI_E_NOT_ENOUGH_MEMORY) &&
542
-                        ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_FOUND) &&
543
-                        ($messageprops[PR_HTML]             == MAPI_E_NOT_FOUND))
541
+                        ($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
542
+                        ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) &&
543
+                        ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
544 544
                         return SYNC_BODYPREFERENCE_PLAIN;
545 545
                 elseif ( // 9.4
546
-                        ($messageprops[PR_HTML]             != MAPI_E_NOT_FOUND   || $messageprops[PR_HTML]            == MAPI_E_NOT_ENOUGH_MEMORY) &&
547
-                        ($messageprops[PR_BODY]             == MAPI_E_NOT_FOUND) &&
548
-                        ($messageprops[PR_RTF_COMPRESSED]   == MAPI_E_NOT_FOUND))
546
+                        ($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
547
+                        ($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) &&
548
+                        ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND))
549 549
                         return SYNC_BODYPREFERENCE_HTML;
550 550
                 else // 10
551 551
                     return SYNC_BODYPREFERENCE_PLAIN;
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
      */
564 564
     public static function GetError($tag, $messageprops) {
565 565
         $prBodyError = mapi_prop_tag(PT_ERROR, mapi_prop_id($tag));
566
-        if(isset($messageprops[$prBodyError]) && mapi_is_error($messageprops[$prBodyError])) {
567
-            if($messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_32BIT ||
566
+        if (isset($messageprops[$prBodyError]) && mapi_is_error($messageprops[$prBodyError])) {
567
+            if ($messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_32BIT ||
568 568
                     $messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_64BIT) {
569 569
                         return MAPI_E_NOT_ENOUGH_MEMORY;
570 570
                     }
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
             $rows = mapi_table_queryallrows($attachTable, array(PR_ATTACH_MIME_TAG, PR_ATTACH_NUM));
595 595
             $attnum = false;
596 596
 
597
-            foreach($rows as $row) {
597
+            foreach ($rows as $row) {
598 598
                 if (isset($row[PR_ATTACH_MIME_TAG]) && $row[PR_ATTACH_MIME_TAG] == 'multipart/signed') {
599 599
                     $attnum = $row[PR_ATTACH_NUM];
600 600
                 }
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
                 PR_SENT_REPRESENTING_ENTRYID => $props[PR_SENT_REPRESENTING_ENTRYID],
618 618
                 PR_SENT_REPRESENTING_SEARCH_KEY => $props[PR_SENT_REPRESENTING_SEARCH_KEY],
619 619
                 // mark the message as read if the main message has read flag
620
-                PR_MESSAGE_FLAGS => $read ? $mprops[PR_MESSAGE_FLAGS] | MSGFLAG_READ : $mprops[PR_MESSAGE_FLAGS],
620
+                PR_MESSAGE_FLAGS => $read ? $mprops[PR_MESSAGE_FLAGS]|MSGFLAG_READ : $mprops[PR_MESSAGE_FLAGS],
621 621
             ));
622 622
         }
623 623
         // TODO check if we need to do this for encrypted (and signed?) message as well
@@ -689,13 +689,13 @@  discard block
 block discarded – undo
689 689
         $entryId = strtoupper($entryid);
690 690
 
691 691
         $res = array(
692
-            'abFlags'   => '',  // BYTE[4],  4 bytes,  8 hex characters
693
-            'guid'      => '',  // GUID,    16 bytes, 32 hex characters
694
-            'version'   => '',  // ULONG,    4 bytes,  8 hex characters
695
-            'type'      => '',  // ULONG,    4 bytes,  8 hex characters
696
-            'id'        => '',  // ULONG,    4 bytes,  8 hex characters
697
-            'server'    => '',  // CHAR,    variable length
698
-            'padding'   => '',  // TCHAR[3], 4 bytes,  8 hex characters (upto 4 bytes)
692
+            'abFlags'   => '', // BYTE[4],  4 bytes,  8 hex characters
693
+            'guid'      => '', // GUID,    16 bytes, 32 hex characters
694
+            'version'   => '', // ULONG,    4 bytes,  8 hex characters
695
+            'type'      => '', // ULONG,    4 bytes,  8 hex characters
696
+            'id'        => '', // ULONG,    4 bytes,  8 hex characters
697
+            'server'    => '', // CHAR,    variable length
698
+            'padding'   => '', // TCHAR[3], 4 bytes,  8 hex characters (upto 4 bytes)
699 699
         );
700 700
 
701 701
         $res['length'] = strlen($entryId);
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
         $entryId = substr($entryId, 0, strlen($entryId) - strlen($res['padding']));
707 707
 
708 708
         $res['abFlags'] = substr($entryId, $offset, 8);
709
-        $offset =+ 8;
709
+        $offset = + 8;
710 710
 
711 711
         $res['guid'] = substr($entryId, $offset, 32);
712 712
         $offset += 32;
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
         $entryId = strtoupper($entryid);
741 741
 
742 742
         $res = array(
743
-            'abFlags'   => '',  // BYTE[4],  4 bytes,  8 hex characters
744
-            'guid'      => '',  // GUID,    16 bytes, 32 hex characters
745
-            'version'   => '',  // ULONG,    4 bytes,  8 hex characters
746
-            'type'      => '',  // ULONG,    4 bytes,  8 hex characters
747
-            'uniqueId'  => '',  // ULONG,   16 bytes,  32 hex characters
748
-            'server'    => '',  // CHAR,    variable length
749
-            'padding'   => '',  // TCHAR[3], 4 bytes,  8 hex characters (upto 4 bytes)
743
+            'abFlags'   => '', // BYTE[4],  4 bytes,  8 hex characters
744
+            'guid'      => '', // GUID,    16 bytes, 32 hex characters
745
+            'version'   => '', // ULONG,    4 bytes,  8 hex characters
746
+            'type'      => '', // ULONG,    4 bytes,  8 hex characters
747
+            'uniqueId'  => '', // ULONG,   16 bytes,  32 hex characters
748
+            'server'    => '', // CHAR,    variable length
749
+            'padding'   => '', // TCHAR[3], 4 bytes,  8 hex characters (upto 4 bytes)
750 750
         );
751 751
 
752 752
         $res['length'] = strlen($entryId);
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
         $entryId = substr($entryId, 0, strlen($entryId) - strlen($res['padding']));
758 758
 
759 759
         $res['abFlags'] = substr($entryId, $offset, 8);
760
-        $offset =+ 8;
760
+        $offset = + 8;
761 761
 
762 762
         $res['guid'] = substr($entryId, $offset, 32);
763 763
         $offset += 32;
Please login to merge, or discard this patch.
lib/grommunio/mapiphpwrapper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             $folderidHex = bin2hex($folderid);
49 49
             $folderid = ZPush::GetDeviceManager()->GetFolderIdForBackendId($folderidHex);
50 50
             if ($folderid != $folderidHex) {
51
-                $this->prefix = $folderid . ':';
51
+                $this->prefix = $folderid.':';
52 52
             }
53 53
         }
54 54
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $parentsourcekey = $props[PR_PARENT_SOURCE_KEY];
90 90
         $entryid = mapi_msgstore_entryidfromsourcekey($this->store, $parentsourcekey, $sourcekey);
91 91
 
92
-        if(!$entryid)
92
+        if (!$entryid)
93 93
             return SYNC_E_IGNORE;
94 94
 
95 95
         $mapimessage = mapi_msgstore_openentry($this->store, $entryid);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         $amount = count($sourcekeys);
152 152
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageDeletion(): Received %d remove requests from ICS", $amount));
153 153
 
154
-        foreach($sourcekeys as $sourcekey) {
154
+        foreach ($sourcekeys as $sourcekey) {
155 155
             // TODO if we would know that ICS is removing the message because it's outside the sync interval, we could send a $asSoftDelete = true to the importer. Could they pass that via $flags?
156 156
             $this->importer->ImportMessageDeletion($this->prefix.bin2hex($sourcekey));
157 157
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageDeletion(): delete for :'%s'", $this->prefix.bin2hex($sourcekey)));
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @return
168 168
      */
169 169
     public function ImportPerUserReadStateChange($readstates) {
170
-        foreach($readstates as $readstate) {
170
+        foreach ($readstates as $readstate) {
171 171
             $this->importer->ImportMessageReadFlag($this->prefix.bin2hex($readstate["sourcekey"]), $readstate["flags"] & MSGFLAG_READ);
172 172
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportPerUserReadStateChange(): read for :'%s'", $this->prefix.bin2hex($readstate["sourcekey"])));
173 173
         }
Please login to merge, or discard this patch.
lib/grommunio/mapimapping.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      * @return array
18 18
      */
19 19
     public static function GetContactMapping() {
20
-        return array (
20
+        return array(
21 21
             "anniversary"           => PR_WEDDING_ANNIVERSARY,
22 22
             "assistantname"         => PR_ASSISTANT,
23 23
             "assistnamephonenumber" => PR_ASSISTANT_TELEPHONE_NUMBER,
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * @return array
94 94
      */
95 95
     public static function GetContactProperties() {
96
-        return array (
96
+        return array(
97 97
             "haspic"                => "PT_BOOLEAN:PSETID_Address:0x8015",
98 98
             "emailaddress1"         => "PT_STRING8:PSETID_Address:0x8083",
99 99
             "emailaddressdname1"    => "PT_STRING8:PSETID_Address:0x8080",
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * @return array
135 135
      */
136 136
     public static function GetEmailMapping() {
137
-        return array (
137
+        return array(
138 138
             // from
139 139
             "datereceived"          => PR_MESSAGE_DELIVERY_TIME,
140 140
             "displayname"           => PR_SUBJECT,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @return array
165 165
      */
166 166
     public static function GetEmailProperties() {
167
-        return array (
167
+        return array(
168 168
             // Override 'From' to show "Full Name <[email protected]>"
169 169
             "representingname"      => PR_SENT_REPRESENTING_NAME,
170 170
             "representingentryid"   => PR_SENT_REPRESENTING_ENTRYID,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      * @return array
188 188
      */
189 189
     public static function GetMeetingRequestMapping() {
190
-        return array (
190
+        return array(
191 191
             "responserequested"     => PR_RESPONSE_REQUESTED,
192 192
             // timezone
193 193
             "alldayevent"           => "PT_BOOLEAN:PSETID_Appointment:0x8215",
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 
207 207
     public static function GetMeetingRequestProperties() {
208
-        return array (
208
+        return array(
209 209
             "goidtag"               => "PT_BINARY:PSETID_Meeting:0x3",
210 210
             "timezonetag"           => "PT_BINARY:PSETID_Appointment:0x8233",
211 211
             "recReplTime"           => "PT_SYSTIME:PSETID_Appointment:0x8228",
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      * @return array
258 258
      */
259 259
     public static function GetAppointmentMapping() {
260
-        return array (
260
+        return array(
261 261
             "alldayevent"           => "PT_BOOLEAN:PSETID_Appointment:0x8215",
262 262
             "body"                  => PR_BODY,
263 263
             "busystatus"            => "PT_LONG:PSETID_Appointment:0x8205",
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
             "flagdueby"             => "PT_SYSTIME:PSETID_Common:0x8560",
312 312
             "icon"                  => PR_ICON_INDEX,
313 313
             "mrwassent"             => "PT_BOOLEAN:PSETID_Appointment:0x8229",
314
-            "endtime"               => "PT_SYSTIME:PSETID_Appointment:0x820e",//this is here for calendar restriction, tnef and ical
315
-            "starttime"             => "PT_SYSTIME:PSETID_Appointment:0x820d",//this is here for calendar restriction, tnef and ical
314
+            "endtime"               => "PT_SYSTIME:PSETID_Appointment:0x820e", //this is here for calendar restriction, tnef and ical
315
+            "starttime"             => "PT_SYSTIME:PSETID_Appointment:0x820d", //this is here for calendar restriction, tnef and ical
316 316
             "clipstart"             => "PT_SYSTIME:PSETID_Appointment:0x8235", //ical only
317 317
             "recurrencetype"        => "PT_LONG:PSETID_Appointment:0x8231",
318 318
             "body"                  => PR_BODY,
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      * @return array
330 330
      */
331 331
     public static function GetTaskMapping() {
332
-        return array (
332
+        return array(
333 333
             "body"                  => PR_BODY,
334 334
             "categories"            => "PT_MV_STRING8:PS_PUBLIC_STRINGS:Keywords",
335 335
             "complete"              => "PT_BOOLEAN:PSETID_Task:0x811C",
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
      * @return array
361 361
      */
362 362
     public static function GetTaskProperties() {
363
-        return array (
363
+        return array(
364 364
             "isrecurringtag"        => "PT_BOOLEAN:PSETID_Task:0x8126",
365 365
             "recurringstate"        => "PT_BINARY:PSETID_Task:0x8116",
366 366
             "deadoccur"             => "PT_BOOLEAN:PSETID_Task:0x8109",
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     * @return array
380 380
     */
381 381
     public static function GetMailFlagsMapping() {
382
-        return array (
382
+        return array(
383 383
             "flagstatus"            => PR_FLAG_STATUS,
384 384
             "flagtype"              => "PT_STRING8:PSETID_Common:0x8530",
385 385
             "datecompleted"         => "PT_SYSTIME:PSETID_Common:0x810F",
Please login to merge, or discard this patch.