@@ -10,7 +10,7 @@ |
||
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"); |
@@ -11,8 +11,7 @@ |
||
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 | 13 | define("GROMMUNIOSYNC_VERSION", $branch .'-'. $version); |
14 | - } |
|
15 | - else { |
|
14 | + } else { |
|
16 | 15 | define("GROMMUNIOSYNC_VERSION", "GIT"); |
17 | 16 | } |
18 | 17 | } |
@@ -28,14 +28,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | if ($this->log_to_user_file === false) { |
31 | 31 | if (in_array(strtolower($this->GetDevid()), ['','validate'])) { |
32 | 32 | $this->setLogToUserFile(preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetAuthUser())) . '.log'); |
33 | - } |
|
34 | - else { |
|
33 | + } else { |
|
35 | 34 | $this->setLogToUserFile( |
36 | 35 | preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetAuthUser())) .'-'. |
37 | 36 | (($this->GetAuthUser() != $this->GetUser()) ? preg_replace('/[^a-z0-9]/', '_', strtolower($this->GetUser())) .'-' : '') . |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | // when the users differ, we need to log both |
73 | 72 | if (strcasecmp($this->GetAuthUser(), $this->GetUser()) == 0) { |
74 | 73 | $log .= ' ['. $this->GetUser() .']'; |
75 | - } |
|
76 | - else { |
|
74 | + } else { |
|
77 | 75 | $log .= ' ['. $this->GetAuthUser() . Request::IMPERSONATE_DELIM . $this->GetUser() .']'; |
78 | 76 | } |
79 | 77 | } |
@@ -114,7 +114,7 @@ discard block |
||
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 |
||
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; |
@@ -259,8 +259,7 @@ discard block |
||
259 | 259 | $this->unauthMessageCache = array(); |
260 | 260 | } |
261 | 261 | $this->WriteForUser($loglevel, $message); |
262 | - } |
|
263 | - else { |
|
262 | + } else { |
|
264 | 263 | $this->unauthMessageCache[] = array($loglevel, $message); |
265 | 264 | } |
266 | 265 | } |
@@ -299,10 +298,11 @@ discard block |
||
299 | 298 | * @return string |
300 | 299 | */ |
301 | 300 | protected function GetLogLevelString($loglevel, $pad = false) { |
302 | - if ($pad) |
|
303 | - $s = " "; |
|
304 | - else |
|
305 | - $s = ""; |
|
301 | + if ($pad) { |
|
302 | + $s = " "; |
|
303 | + } else { |
|
304 | + $s = ""; |
|
305 | + } |
|
306 | 306 | switch($loglevel) { |
307 | 307 | case LOGLEVEL_OFF: return ""; break; |
308 | 308 | case LOGLEVEL_FATAL: return "[FATAL]"; break; |
@@ -104,17 +104,17 @@ discard block |
||
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 |
||
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 |
||
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); |
@@ -79,9 +79,15 @@ discard block |
||
79 | 79 | public function __construct($program_name = null, $host = null, $port = null) { |
80 | 80 | parent::__construct(); |
81 | 81 | |
82 | - if (is_null($program_name)) $program_name = LOG_SYSLOG_PROGRAM; |
|
83 | - if (is_null($host)) $host = LOG_SYSLOG_HOST; |
|
84 | - if (is_null($port)) $port = LOG_SYSLOG_PORT; |
|
82 | + if (is_null($program_name)) { |
|
83 | + $program_name = LOG_SYSLOG_PROGRAM; |
|
84 | + } |
|
85 | + if (is_null($host)) { |
|
86 | + $host = LOG_SYSLOG_HOST; |
|
87 | + } |
|
88 | + if (is_null($port)) { |
|
89 | + $port = LOG_SYSLOG_PORT; |
|
90 | + } |
|
85 | 91 | |
86 | 92 | $this->SetProgramName($program_name); |
87 | 93 | $this->SetHost($host); |
@@ -153,8 +159,7 @@ discard block |
||
153 | 159 | // when the users differ, we need to log both |
154 | 160 | if (strcasecmp($this->GetAuthUser(), $this->GetUser()) == 0) { |
155 | 161 | $log .= ' ['. $this->GetUser() .']'; |
156 | - } |
|
157 | - else { |
|
162 | + } else { |
|
158 | 163 | $log .= ' ['. $this->GetAuthUser() . Request::IMPERSONATE_DELIM . $this->GetUser() .']'; |
159 | 164 | } |
160 | 165 | if ($loglevel >= LOGLEVEL_DEVICEID) { |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * @access public |
265 | 265 | * @return int |
266 | 266 | */ |
267 | - public function GetChangeCount() { |
|
267 | + public function GetChangeCount() { |
|
268 | 268 | if ($this->exporter) |
269 | 269 | return mapi_exportchanges_getchangecount($this->exporter); |
270 | 270 | else |
@@ -15,7 +15,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -47,13 +47,11 @@ discard block |
||
47 | 47 | try { |
48 | 48 | if($folderid) { |
49 | 49 | $entryid = mapi_msgstore_entryidfromsourcekey($store, $folderid); |
50 | - } |
|
51 | - else { |
|
50 | + } else { |
|
52 | 51 | $storeprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID, PR_IPM_PUBLIC_FOLDERS_ENTRYID)); |
53 | 52 | if (ZPush::GetBackend()->GetImpersonatedUser() == 'system') { |
54 | 53 | $entryid = $storeprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID]; |
55 | - } |
|
56 | - else { |
|
54 | + } else { |
|
57 | 55 | $entryid = $storeprops[PR_IPM_SUBTREE_ENTRYID]; |
58 | 56 | } |
59 | 57 | } |
@@ -70,16 +68,13 @@ discard block |
||
70 | 68 | if ($folder) { |
71 | 69 | if ($folderid) { |
72 | 70 | $this->exporter = mapi_openproperty($folder, PR_CONTENTS_SYNCHRONIZER, IID_IExchangeExportChanges, 0 , 0); |
73 | - } |
|
74 | - else { |
|
71 | + } else { |
|
75 | 72 | $this->exporter = mapi_openproperty($folder, PR_HIERARCHY_SYNCHRONIZER, IID_IExchangeExportChanges, 0 , 0); |
76 | 73 | } |
77 | - } |
|
78 | - else { |
|
74 | + } else { |
|
79 | 75 | $this->exporter = false; |
80 | 76 | } |
81 | - } |
|
82 | - catch (MAPIException $me) { |
|
77 | + } catch (MAPIException $me) { |
|
83 | 78 | $this->exporter = false; |
84 | 79 | // We return the general error SYNC_FSSTATUS_CODEUNKNOWN (12) which is also SYNC_STATUS_FOLDERHIERARCHYCHANGED (12) |
85 | 80 | // if this happened while doing content sync, the mobile will try to resync the folderhierarchy |
@@ -102,8 +97,9 @@ discard block |
||
102 | 97 | $this->flags = $flags; |
103 | 98 | |
104 | 99 | // this should never happen |
105 | - if ($this->exporter === false || is_array($state)) |
|
106 | - throw new StatusException("ExportChangesICS->Config(): Error, exporter not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR); |
|
100 | + if ($this->exporter === false || is_array($state)) { |
|
101 | + throw new StatusException("ExportChangesICS->Config(): Error, exporter not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR); |
|
102 | + } |
|
107 | 103 | |
108 | 104 | // change exporterflags if we are doing a ContentExport |
109 | 105 | if($this->folderid) { |
@@ -113,8 +109,9 @@ discard block |
||
113 | 109 | // we check the change ID of the syncstate (0 at initial sync) |
114 | 110 | // On subsequent syncs, we do want to receive delete events. |
115 | 111 | if(strlen($state) == 0 || bin2hex(substr($state,4,4)) == "00000000") { |
116 | - if (!($this->flags & BACKEND_DISCARD_DATA)) |
|
117 | - ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesICS->Config(): syncing initial data"); |
|
112 | + if (!($this->flags & BACKEND_DISCARD_DATA)) { |
|
113 | + ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesICS->Config(): syncing initial data"); |
|
114 | + } |
|
118 | 115 | $this->exporterflags |= SYNC_NO_SOFT_DELETIONS | SYNC_NO_DELETIONS; |
119 | 116 | } |
120 | 117 | } |
@@ -126,11 +123,13 @@ discard block |
||
126 | 123 | |
127 | 124 | // Put the state information in a stream that can be used by ICS |
128 | 125 | $stream = mapi_stream_create(); |
129 | - if(strlen($state) == 0) |
|
130 | - $state = hex2bin("0000000000000000"); |
|
126 | + if(strlen($state) == 0) { |
|
127 | + $state = hex2bin("0000000000000000"); |
|
128 | + } |
|
131 | 129 | |
132 | - if (!($this->flags & BACKEND_DISCARD_DATA)) |
|
133 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->Config() initialized with state: 0x%s", bin2hex($state))); |
|
130 | + if (!($this->flags & BACKEND_DISCARD_DATA)) { |
|
131 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->Config() initialized with state: 0x%s", bin2hex($state))); |
|
132 | + } |
|
134 | 133 | |
135 | 134 | mapi_stream_write($stream, $state); |
136 | 135 | $this->statestream = $stream; |
@@ -183,8 +182,9 @@ discard block |
||
183 | 182 | |
184 | 183 | // this should never happen! |
185 | 184 | if($this->exporter === false || !isset($this->statestream) || !isset($this->flags) || !isset($this->exporterflags) || |
186 | - ($this->folderid && !isset($this->contentParameters)) ) |
|
187 | - throw new StatusException("ExportChangesICS->InitializeExporter(): Error, exporter or essential data not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR); |
|
185 | + ($this->folderid && !isset($this->contentParameters)) ) { |
|
186 | + throw new StatusException("ExportChangesICS->InitializeExporter(): Error, exporter or essential data not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | // PHP wrapper |
190 | 190 | $phpwrapper = new PHPWrapper($this->session, $this->store, $importer, $this->folderid); |
@@ -196,22 +196,24 @@ discard block |
||
196 | 196 | // ICS c++ wrapper |
197 | 197 | $mapiimporter = mapi_wrap_importcontentschanges($phpwrapper); |
198 | 198 | $includeprops = false; |
199 | - } |
|
200 | - else { |
|
199 | + } else { |
|
201 | 200 | $mapiimporter = mapi_wrap_importhierarchychanges($phpwrapper); |
202 | 201 | $includeprops = array(PR_SOURCE_KEY, PR_DISPLAY_NAME); |
203 | 202 | } |
204 | 203 | |
205 | - if (!$mapiimporter) |
|
206 | - throw new StatusException(sprintf("ExportChangesICS->InitializeExporter(): Error, mapi_wrap_import_*_changes() failed: 0x%X", mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN); |
|
204 | + if (!$mapiimporter) { |
|
205 | + throw new StatusException(sprintf("ExportChangesICS->InitializeExporter(): Error, mapi_wrap_import_*_changes() failed: 0x%X", mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | $ret = mapi_exportchanges_config($this->exporter, $this->statestream, $this->exporterflags, $mapiimporter, $this->restriction, $includeprops, false, 1); |
209 | - if(!$ret) |
|
210 | - throw new StatusException(sprintf("ExportChangesICS->InitializeExporter(): Error, mapi_exportchanges_config() failed: 0x%X", mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN); |
|
209 | + if(!$ret) { |
|
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 | 213 | $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')); |
|
214 | + if($changes || !($this->flags & BACKEND_DISCARD_DATA)) { |
|
215 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->InitializeExporter() successfully. %d changes ready to sync for '%s'.", $changes, ($this->folderid)?bin2hex($this->folderid) : 'hierarchy')); |
|
216 | + } |
|
215 | 217 | |
216 | 218 | return $ret; |
217 | 219 | } |
@@ -238,21 +240,24 @@ discard block |
||
238 | 240 | */ |
239 | 241 | public function GetState() { |
240 | 242 | $error = false; |
241 | - if(!isset($this->statestream) || $this->exporter === false) |
|
242 | - $error = true; |
|
243 | + if(!isset($this->statestream) || $this->exporter === false) { |
|
244 | + $error = true; |
|
245 | + } |
|
243 | 246 | |
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); |
|
247 | + if($error === true || mapi_exportchanges_updatestate($this->exporter, $this->statestream) != true ) { |
|
248 | + 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); |
|
249 | + } |
|
246 | 250 | |
247 | 251 | mapi_stream_seek($this->statestream, 0, STREAM_SEEK_SET); |
248 | 252 | |
249 | 253 | $state = ""; |
250 | 254 | while(true) { |
251 | 255 | $data = mapi_stream_read($this->statestream, 4096); |
252 | - if(strlen($data)) |
|
253 | - $state .= $data; |
|
254 | - else |
|
255 | - break; |
|
256 | + if(strlen($data)) { |
|
257 | + $state .= $data; |
|
258 | + } else { |
|
259 | + break; |
|
260 | + } |
|
256 | 261 | } |
257 | 262 | |
258 | 263 | return $state; |
@@ -265,10 +270,11 @@ discard block |
||
265 | 270 | * @return int |
266 | 271 | */ |
267 | 272 | public function GetChangeCount() { |
268 | - if ($this->exporter) |
|
269 | - return mapi_exportchanges_getchangecount($this->exporter); |
|
270 | - else |
|
271 | - return 0; |
|
273 | + if ($this->exporter) { |
|
274 | + return mapi_exportchanges_getchangecount($this->exporter); |
|
275 | + } else { |
|
276 | + return 0; |
|
277 | + } |
|
272 | 278 | } |
273 | 279 | |
274 | 280 | /** |
@@ -899,11 +899,11 @@ discard block |
||
899 | 899 | $items = $meetingrequest->findCalendarItems($goid); |
900 | 900 | |
901 | 901 | if (is_array($items)) { |
902 | - $newitem = mapi_msgstore_openentry($this->store, $items[0]); |
|
903 | - $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY)); |
|
904 | - $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); |
|
905 | - $calFolderId = bin2hex($newprops[PR_PARENT_SOURCE_KEY]); |
|
906 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): found other calendar entryid", $requestid, $folderid, $response)); |
|
902 | + $newitem = mapi_msgstore_openentry($this->store, $items[0]); |
|
903 | + $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY)); |
|
904 | + $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); |
|
905 | + $calFolderId = bin2hex($newprops[PR_PARENT_SOURCE_KEY]); |
|
906 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): found other calendar entryid", $requestid, $folderid, $response)); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | if ($requestid == $calendarid) |
@@ -1319,12 +1319,12 @@ discard block |
||
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | /** |
1322 | - * Terminates a search for a given PID |
|
1323 | - * |
|
1324 | - * @param int $pid |
|
1325 | - * |
|
1326 | - * @return boolean |
|
1327 | - */ |
|
1322 | + * Terminates a search for a given PID |
|
1323 | + * |
|
1324 | + * @param int $pid |
|
1325 | + * |
|
1326 | + * @return boolean |
|
1327 | + */ |
|
1328 | 1328 | public function TerminateSearch($pid) { |
1329 | 1329 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->TerminateSearch(): terminating search for pid %d", $pid)); |
1330 | 1330 | if (!isset($this->store) || $this->store === false) { |
@@ -1829,7 +1829,6 @@ discard block |
||
1829 | 1829 | * @param string $type the state type |
1830 | 1830 | * @param string $key (opt) |
1831 | 1831 | * @param string $counter state counter |
1832 | - |
|
1833 | 1832 | * |
1834 | 1833 | * @access private |
1835 | 1834 | * @return MAPIMessage |
@@ -2021,7 +2020,7 @@ discard block |
||
2021 | 2020 | // During PING requests the operations store has to be switched constantly |
2022 | 2021 | // the cache prevents the same store opened several times |
2023 | 2022 | if (isset($this->storeCache[$user])) |
2024 | - return $this->storeCache[$user]; |
|
2023 | + return $this->storeCache[$user]; |
|
2025 | 2024 | |
2026 | 2025 | $entryid = false; |
2027 | 2026 | $return_public = false; |
@@ -2352,14 +2351,14 @@ discard block |
||
2352 | 2351 | } |
2353 | 2352 | } |
2354 | 2353 | |
2355 | - /** |
|
2356 | - * Function will create a search folder in FINDER_ROOT folder |
|
2357 | - * if folder exists then it will open it |
|
2358 | - * |
|
2359 | - * @see createSearchFolder($store, $openIfExists = true) function in the webaccess |
|
2360 | - * |
|
2361 | - * @return mapiFolderObject $folder created search folder |
|
2362 | - */ |
|
2354 | + /** |
|
2355 | + * Function will create a search folder in FINDER_ROOT folder |
|
2356 | + * if folder exists then it will open it |
|
2357 | + * |
|
2358 | + * @see createSearchFolder($store, $openIfExists = true) function in the webaccess |
|
2359 | + * |
|
2360 | + * @return mapiFolderObject $folder created search folder |
|
2361 | + */ |
|
2363 | 2362 | private function getSearchFolder() { |
2364 | 2363 | // create new or open existing search folder |
2365 | 2364 | $searchFolderRoot = $this->getSearchFoldersRoot($this->store); |
@@ -2377,14 +2376,14 @@ discard block |
||
2377 | 2376 | return false; |
2378 | 2377 | } |
2379 | 2378 | |
2380 | - /** |
|
2381 | - * Function will open FINDER_ROOT folder in root container |
|
2382 | - * public folder's don't have FINDER_ROOT folder |
|
2383 | - * |
|
2384 | - * @see getSearchFoldersRoot($store) function in the webaccess |
|
2385 | - * |
|
2386 | - * @return mapiFolderObject root folder for search folders |
|
2387 | - */ |
|
2379 | + /** |
|
2380 | + * Function will open FINDER_ROOT folder in root container |
|
2381 | + * public folder's don't have FINDER_ROOT folder |
|
2382 | + * |
|
2383 | + * @see getSearchFoldersRoot($store) function in the webaccess |
|
2384 | + * |
|
2385 | + * @return mapiFolderObject root folder for search folders |
|
2386 | + */ |
|
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)); |
@@ -143,10 +143,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -134,8 +134,7 @@ discard block |
||
134 | 134 | if ($this->impersonateUser !== false) { |
135 | 135 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->Logon(): Impersonation active - authenticating: '%s' - impersonating '%s'", $this->mainUser, $this->impersonateUser)); |
136 | 136 | $defaultUser = $this->impersonateUser; |
137 | - } |
|
138 | - else { |
|
137 | + } else { |
|
139 | 138 | $defaultUser = $this->mainUser; |
140 | 139 | } |
141 | 140 | |
@@ -149,8 +148,7 @@ discard block |
||
149 | 148 | $zpush_version = 'Grommunio-Sync_' . @constant('GROMMUNIOSYNC_VERSION'); |
150 | 149 | $user_agent = ($deviceId) ? ZPush::GetDeviceManager()->GetUserAgent() : "unknown"; |
151 | 150 | $this->session = @mapi_logon_zarafa($this->mainUser, $pass, MAPI_SERVER, null, null, 0, $zpush_version, $user_agent); |
152 | - } |
|
153 | - else { |
|
151 | + } else { |
|
154 | 152 | $this->session = @mapi_logon_zarafa($this->mainUser, $pass, MAPI_SERVER, null, null, 0); |
155 | 153 | } |
156 | 154 | $this->notifications = true; |
@@ -163,11 +161,11 @@ discard block |
||
163 | 161 | |
164 | 162 | if (mapi_last_hresult()) { |
165 | 163 | ZLog::Write(LOGLEVEL_ERROR, sprintf("Grommunio->Logon(): login failed with error code: 0x%X", mapi_last_hresult())); |
166 | - if (mapi_last_hresult() == MAPI_E_NETWORK_ERROR) |
|
167 | - throw new ServiceUnavailableException("Error connecting to KC (login)"); |
|
164 | + if (mapi_last_hresult() == MAPI_E_NETWORK_ERROR) { |
|
165 | + throw new ServiceUnavailableException("Error connecting to KC (login)"); |
|
166 | + } |
|
168 | 167 | } |
169 | - } |
|
170 | - catch (MAPIException $ex) { |
|
168 | + } catch (MAPIException $ex) { |
|
171 | 169 | throw new AuthenticationRequiredException($ex->getDisplayMessage()); |
172 | 170 | } |
173 | 171 | |
@@ -186,11 +184,13 @@ discard block |
||
186 | 184 | $this->defaultstore = $this->openMessageStore($defaultUser); |
187 | 185 | } |
188 | 186 | |
189 | - if (mapi_last_hresult() == MAPI_E_FAILONEPROVIDER) |
|
190 | - throw new ServiceUnavailableException("Error connecting to KC (open store)"); |
|
187 | + if (mapi_last_hresult() == MAPI_E_FAILONEPROVIDER) { |
|
188 | + throw new ServiceUnavailableException("Error connecting to KC (open store)"); |
|
189 | + } |
|
191 | 190 | |
192 | - if($this->defaultstore === false) |
|
193 | - throw new AuthenticationRequiredException(sprintf("Grommunio->Logon(): User '%s' has no default store", $defaultUser)); |
|
191 | + if($this->defaultstore === false) { |
|
192 | + throw new AuthenticationRequiredException(sprintf("Grommunio->Logon(): User '%s' has no default store", $defaultUser)); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | $this->store = $this->defaultstore; |
196 | 196 | $this->storeName = $defaultUser; |
@@ -229,8 +229,9 @@ discard block |
||
229 | 229 | public function Setup($store, $checkACLonly = false, $folderid = false) { |
230 | 230 | list($user, $domain) = Utils::SplitDomainUser($store); |
231 | 231 | |
232 | - if (!isset($this->mainUser)) |
|
233 | - return false; |
|
232 | + if (!isset($this->mainUser)) { |
|
233 | + return false; |
|
234 | + } |
|
234 | 235 | |
235 | 236 | $mainUser = $this->mainUser; |
236 | 237 | // when impersonating we need to check against the impersonated user |
@@ -238,8 +239,9 @@ discard block |
||
238 | 239 | $mainUser = $this->impersonateUser; |
239 | 240 | } |
240 | 241 | |
241 | - if ($user === false) |
|
242 | - $user = $mainUser; |
|
242 | + if ($user === false) { |
|
243 | + $user = $mainUser; |
|
244 | + } |
|
243 | 245 | |
244 | 246 | // This is a special case. A user will get his entire folder structure by the foldersync by default. |
245 | 247 | // The ACL check is executed when an additional folder is going to be sent to the mobile. |
@@ -263,8 +265,7 @@ discard block |
||
263 | 265 | $storeProps = mapi_getprops($userstore, array(PR_IPM_SUBTREE_ENTRYID)); |
264 | 266 | $rights = $this->HasSecretaryACLs($userstore, '', $storeProps[PR_IPM_SUBTREE_ENTRYID]); |
265 | 267 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->Setup(): Checking for secretary ACLs on root folder of impersonated store '%s': '%s'", $user, Utils::PrintAsString($rights))); |
266 | - } |
|
267 | - else { |
|
268 | + } else { |
|
268 | 269 | $zarafauserinfo = @nsp_getuserinfo($this->mainUser); |
269 | 270 | $rights = (isset($zarafauserinfo['admin']) && $zarafauserinfo['admin'])?true:false; |
270 | 271 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->Setup(): Checking for admin ACLs on store '%s': '%s'", $user, Utils::PrintAsString($rights))); |
@@ -329,8 +330,7 @@ discard block |
||
329 | 330 | // for SYSTEM user open the public folders |
330 | 331 | if (strtoupper($this->storeName) == "SYSTEM") { |
331 | 332 | $rootfolder = mapi_msgstore_openentry($this->store, $storeProps[PR_IPM_PUBLIC_FOLDERS_ENTRYID]); |
332 | - } |
|
333 | - else { |
|
333 | + } else { |
|
334 | 334 | $rootfolder = mapi_msgstore_openentry($this->store); |
335 | 335 | } |
336 | 336 | |
@@ -352,8 +352,7 @@ discard block |
||
352 | 352 | $folder = $mapiprovider->GetFolder($row); |
353 | 353 | if ($folder) { |
354 | 354 | $folders[] = $folder; |
355 | - } |
|
356 | - else { |
|
355 | + } else { |
|
357 | 356 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetHierarchy(): ignoring folder '%s' as MAPIProvider->GetFolder() did not return a SyncFolder object", (isset($row[PR_DISPLAY_NAME]) ? $row[PR_DISPLAY_NAME] : "unknown"))); |
358 | 357 | } |
359 | 358 | } |
@@ -389,9 +388,9 @@ discard block |
||
389 | 388 | return false; |
390 | 389 | } |
391 | 390 | return new ImportChangesICS($this->session, $this->store, hex2bin($folderid)); |
391 | + } else { |
|
392 | + return new ImportChangesICS($this->session, $this->store); |
|
392 | 393 | } |
393 | - else |
|
394 | - return new ImportChangesICS($this->session, $this->store); |
|
395 | 394 | } |
396 | 395 | |
397 | 396 | /** |
@@ -412,9 +411,9 @@ discard block |
||
412 | 411 | return false; |
413 | 412 | } |
414 | 413 | return new ExportChangesICS($this->session, $this->store, hex2bin($folderid)); |
414 | + } else { |
|
415 | + return new ExportChangesICS($this->session, $this->store); |
|
415 | 416 | } |
416 | - else |
|
417 | - return new ExportChangesICS($this->session, $this->store); |
|
418 | 417 | } |
419 | 418 | |
420 | 419 | /** |
@@ -449,11 +448,13 @@ discard block |
||
449 | 448 | |
450 | 449 | // Open the outbox and create the message there |
451 | 450 | $storeprops = mapi_getprops($this->defaultstore, array($sendMailProps["outboxentryid"], $sendMailProps["ipmsentmailentryid"])); |
452 | - if(isset($storeprops[$sendMailProps["outboxentryid"]])) |
|
453 | - $outbox = mapi_msgstore_openentry($this->defaultstore, $storeprops[$sendMailProps["outboxentryid"]]); |
|
451 | + if(isset($storeprops[$sendMailProps["outboxentryid"]])) { |
|
452 | + $outbox = mapi_msgstore_openentry($this->defaultstore, $storeprops[$sendMailProps["outboxentryid"]]); |
|
453 | + } |
|
454 | 454 | |
455 | - if(!$outbox) |
|
456 | - throw new StatusException(sprintf("Grommunio->SendMail(): No Outbox found or unable to create message: 0x%X", mapi_last_hresult()), SYNC_COMMONSTATUS_SERVERERROR); |
|
455 | + if(!$outbox) { |
|
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 | 459 | $mapimessage = mapi_folder_createmessage($outbox); |
459 | 460 | |
@@ -510,12 +511,14 @@ discard block |
||
510 | 511 | if(isset($sm->source->itemid) && $sm->source->itemid) { |
511 | 512 | // answering an email in a public/shared folder |
512 | 513 | // 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 | - if (!$this->Setup(ZPush::GetAdditionalSyncFolderStore($sm->source->folderid))) |
|
514 | - throw new StatusException(sprintf("Grommunio->SendMail() could not Setup() the backend for folder id '%s'", $sm->source->folderid), SYNC_COMMONSTATUS_SERVERERROR); |
|
514 | + if (!$this->Setup(ZPush::GetAdditionalSyncFolderStore($sm->source->folderid))) { |
|
515 | + throw new StatusException(sprintf("Grommunio->SendMail() could not Setup() the backend for folder id '%s'", $sm->source->folderid), SYNC_COMMONSTATUS_SERVERERROR); |
|
516 | + } |
|
515 | 517 | |
516 | 518 | $entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($sm->source->folderid), hex2bin($sm->source->itemid)); |
517 | - if ($entryid) |
|
518 | - $fwmessage = mapi_msgstore_openentry($this->store, $entryid); |
|
519 | + if ($entryid) { |
|
520 | + $fwmessage = mapi_msgstore_openentry($this->store, $entryid); |
|
521 | + } |
|
519 | 522 | |
520 | 523 | if (isset($fwmessage) && $fwmessage) { |
521 | 524 | // update icon and last_verb when forwarding or replying message |
@@ -525,8 +528,7 @@ discard block |
||
525 | 528 | PR_ICON_INDEX => 262, |
526 | 529 | PR_LAST_VERB_EXECUTED => 104, |
527 | 530 | ); |
528 | - } |
|
529 | - elseif ($sm->replyflag) { |
|
531 | + } elseif ($sm->replyflag) { |
|
530 | 532 | $updateProps = array( |
531 | 533 | PR_ICON_INDEX => 261, |
532 | 534 | PR_LAST_VERB_EXECUTED => 102, |
@@ -586,8 +588,7 @@ discard block |
||
586 | 588 | $mapiprops[$sendMailProps["html"]] = $bodyHtml."<br><br>".$fwbodyHtml; |
587 | 589 | } |
588 | 590 | } |
589 | - } |
|
590 | - else { |
|
591 | + } else { |
|
591 | 592 | // no fwmessage could be opened and we need it because we do not replace mime |
592 | 593 | if (!isset($sm->replacemime) || $sm->replacemime == false) { |
593 | 594 | throw new StatusException(sprintf("Grommunio->SendMail(): Could not open message id '%s' in folder id '%s' to be replied/forwarded: 0x%X", $sm->source->itemid, $sm->source->folderid, mapi_last_hresult()), SYNC_COMMONSTATUS_ITEMNOTFOUND); |
@@ -631,21 +632,22 @@ discard block |
||
631 | 632 | if (! $folderid) { |
632 | 633 | $entryid = hex2bin($id); |
633 | 634 | $sk = $id; |
634 | - } |
|
635 | - else { |
|
635 | + } else { |
|
636 | 636 | // id might be in the new longid format, so we have to split it here |
637 | 637 | list($fsk, $sk) = Utils::SplitMessageId($id); |
638 | 638 | // get the entry id of the message |
639 | 639 | $entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($sk)); |
640 | 640 | |
641 | 641 | } |
642 | - if(!$entryid) |
|
643 | - throw new StatusException(sprintf("Grommunio->Fetch('%s','%s'): Error getting entryid: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND); |
|
642 | + if(!$entryid) { |
|
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 | 646 | // open the message |
646 | 647 | $message = mapi_msgstore_openentry($this->store, $entryid); |
647 | - if(!$message) |
|
648 | - throw new StatusException(sprintf("Grommunio->Fetch('%s','%s'): Error, unable to open message: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND); |
|
648 | + if(!$message) { |
|
649 | + throw new StatusException(sprintf("Grommunio->Fetch('%s','%s'): Error, unable to open message: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND); |
|
650 | + } |
|
649 | 651 | |
650 | 652 | // convert the mapi message into a SyncObject and return it |
651 | 653 | $mapiprovider = new MAPIProvider($this->session, $this->store); |
@@ -691,8 +693,9 @@ discard block |
||
691 | 693 | public function GetAttachmentData($attname) { |
692 | 694 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->GetAttachmentData('%s')", $attname)); |
693 | 695 | |
694 | - if(!strpos($attname, ":")) |
|
695 | - throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, attachment requested for non-existing item", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); |
|
696 | + if(!strpos($attname, ":")) { |
|
697 | + throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, attachment requested for non-existing item", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); |
|
698 | + } |
|
696 | 699 | |
697 | 700 | list($id, $attachnum, $parentEntryid) = explode(":", $attname); |
698 | 701 | if (isset($parentEntryid)) { |
@@ -701,13 +704,15 @@ discard block |
||
701 | 704 | |
702 | 705 | $entryid = hex2bin($id); |
703 | 706 | $message = mapi_msgstore_openentry($this->store, $entryid); |
704 | - if(!$message) |
|
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); |
|
707 | + if(!$message) { |
|
708 | + 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); |
|
709 | + } |
|
706 | 710 | |
707 | 711 | MAPIUtils::ParseSmime($this->session, $this->defaultstore, $this->getAddressbook(), $message); |
708 | 712 | $attach = mapi_message_openattach($message, $attachnum); |
709 | - if(!$attach) |
|
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); |
|
713 | + if(!$attach) { |
|
714 | + 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); |
|
715 | + } |
|
711 | 716 | |
712 | 717 | // get necessary attachment props |
713 | 718 | $attprops = mapi_getprops($attach, array(PR_ATTACH_MIME_TAG, PR_ATTACH_MIME_TAG_W, PR_ATTACH_METHOD)); |
@@ -719,19 +724,21 @@ discard block |
||
719 | 724 | $stream = mapi_inetmapi_imtoinet($this->session, $addrbook, $embMessage, array('use_tnef' => -1)); |
720 | 725 | // set the default contenttype for this kind of messages |
721 | 726 | $attachment->contenttype = "message/rfc822"; |
727 | + } else { |
|
728 | + $stream = mapi_openproperty($attach, PR_ATTACH_DATA_BIN, IID_IStream, 0, 0); |
|
722 | 729 | } |
723 | - else |
|
724 | - $stream = mapi_openproperty($attach, PR_ATTACH_DATA_BIN, IID_IStream, 0, 0); |
|
725 | 730 | |
726 | - if(!$stream) |
|
727 | - throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, unable to open attachment data stream: 0x%X", $attname, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); |
|
731 | + if(!$stream) { |
|
732 | + throw new StatusException(sprintf("Grommunio->GetAttachmentData('%s'): Error, unable to open attachment data stream: 0x%X", $attname, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); |
|
733 | + } |
|
728 | 734 | |
729 | 735 | // put the mapi stream into a wrapper to get a standard stream |
730 | 736 | $attachment->data = MAPIStreamWrapper::Open($stream); |
731 | - if (isset($attprops[PR_ATTACH_MIME_TAG])) |
|
732 | - $attachment->contenttype = $attprops[PR_ATTACH_MIME_TAG]; |
|
733 | - elseif (isset($attprops[PR_ATTACH_MIME_TAG_W])) |
|
734 | - $attachment->contenttype = $attprops[PR_ATTACH_MIME_TAG_W]; |
|
737 | + if (isset($attprops[PR_ATTACH_MIME_TAG])) { |
|
738 | + $attachment->contenttype = $attprops[PR_ATTACH_MIME_TAG]; |
|
739 | + } elseif (isset($attprops[PR_ATTACH_MIME_TAG_W])) { |
|
740 | + $attachment->contenttype = $attprops[PR_ATTACH_MIME_TAG_W]; |
|
741 | + } |
|
735 | 742 | //TODO default contenttype |
736 | 743 | return $attachment; |
737 | 744 | } |
@@ -751,23 +758,27 @@ discard block |
||
751 | 758 | */ |
752 | 759 | public function EmptyFolder($folderid, $includeSubfolders = true) { |
753 | 760 | $folderentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid)); |
754 | - if (!$folderentryid) |
|
755 | - throw new StatusException(sprintf("Grommunio->EmptyFolder('%s','%s'): Error, unable to open folder (no entry id)", $folderid, Utils::PrintAsString($includeSubfolders)), SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
|
761 | + if (!$folderentryid) { |
|
762 | + throw new StatusException(sprintf("Grommunio->EmptyFolder('%s','%s'): Error, unable to open folder (no entry id)", $folderid, Utils::PrintAsString($includeSubfolders)), SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
|
763 | + } |
|
756 | 764 | $folder = mapi_msgstore_openentry($this->store, $folderentryid); |
757 | 765 | |
758 | - if (!$folder) |
|
759 | - throw new StatusException(sprintf("Grommunio->EmptyFolder('%s','%s'): Error, unable to open parent folder (open entry)", $folderid, Utils::PrintAsString($includeSubfolders)), SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
|
766 | + if (!$folder) { |
|
767 | + throw new StatusException(sprintf("Grommunio->EmptyFolder('%s','%s'): Error, unable to open parent folder (open entry)", $folderid, Utils::PrintAsString($includeSubfolders)), SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
|
768 | + } |
|
760 | 769 | |
761 | 770 | $flags = 0; |
762 | - if ($includeSubfolders) |
|
763 | - $flags = DEL_ASSOCIATED; |
|
771 | + if ($includeSubfolders) { |
|
772 | + $flags = DEL_ASSOCIATED; |
|
773 | + } |
|
764 | 774 | |
765 | 775 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->EmptyFolder('%s','%s'): emptying folder",$folderid, Utils::PrintAsString($includeSubfolders))); |
766 | 776 | |
767 | 777 | // empty folder! |
768 | 778 | mapi_folder_emptyfolder($folder, $flags); |
769 | - if (mapi_last_hresult()) |
|
770 | - throw new StatusException(sprintf("Grommunio->EmptyFolder('%s','%s'): Error, mapi_folder_emptyfolder() failed: 0x%X", $folderid, Utils::PrintAsString($includeSubfolders), mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
|
779 | + if (mapi_last_hresult()) { |
|
780 | + throw new StatusException(sprintf("Grommunio->EmptyFolder('%s','%s'): Error, mapi_folder_emptyfolder() failed: 0x%X", $folderid, Utils::PrintAsString($includeSubfolders), mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_SERVERERROR); |
|
781 | + } |
|
771 | 782 | |
772 | 783 | return true; |
773 | 784 | } |
@@ -788,12 +799,14 @@ discard block |
||
788 | 799 | // Use standard meeting response code to process meeting request |
789 | 800 | list($fid, $requestid) = Utils::SplitMessageId($requestid); |
790 | 801 | $reqentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($requestid)); |
791 | - if (!$reqentryid) |
|
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); |
|
802 | + if (!$reqentryid) { |
|
803 | + 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); |
|
804 | + } |
|
793 | 805 | |
794 | 806 | $mapimessage = mapi_msgstore_openentry($this->store, $reqentryid); |
795 | - if(!$mapimessage) |
|
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); |
|
807 | + if(!$mapimessage) { |
|
808 | + 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); |
|
809 | + } |
|
797 | 810 | |
798 | 811 | // ios sends calendar item in MeetingResponse |
799 | 812 | // @see https://jira.z-hub.io/browse/ZP-1524 |
@@ -834,11 +847,13 @@ discard block |
||
834 | 847 | |
835 | 848 | $meetingrequest = new Meetingrequest($this->store, $mapimessage, $this->session); |
836 | 849 | |
837 | - if(!$meetingrequest->isMeetingRequest()) |
|
838 | - throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error, attempt to respond to non-meeting request", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); |
|
850 | + if(!$meetingrequest->isMeetingRequest()) { |
|
851 | + throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error, attempt to respond to non-meeting request", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); |
|
852 | + } |
|
839 | 853 | |
840 | - if($meetingrequest->isLocalOrganiser()) |
|
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); |
|
854 | + if($meetingrequest->isLocalOrganiser()) { |
|
855 | + 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); |
|
856 | + } |
|
842 | 857 | |
843 | 858 | // Process the meeting response. We don't have to send the actual meeting response |
844 | 859 | // e-mail, because the device will send it itself. This seems not to be the case |
@@ -906,8 +921,9 @@ discard block |
||
906 | 921 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): found other calendar entryid", $requestid, $folderid, $response)); |
907 | 922 | } |
908 | 923 | |
909 | - if ($requestid == $calendarid) |
|
910 | - throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error finding the accepted meeting response in the calendar", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); |
|
924 | + if ($requestid == $calendarid) { |
|
925 | + throw new StatusException(sprintf("Grommunio->MeetingResponse('%s','%s', '%s'): Error finding the accepted meeting response in the calendar", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); |
|
926 | + } |
|
911 | 927 | } |
912 | 928 | |
913 | 929 | // delete meeting request from Inbox |
@@ -971,8 +987,9 @@ discard block |
||
971 | 987 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->ChangesSinkInitialize(): folderid '%s'", $folderid)); |
972 | 988 | |
973 | 989 | $entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid)); |
974 | - if (!$entryid) |
|
975 | - return false; |
|
990 | + if (!$entryid) { |
|
991 | + return false; |
|
992 | + } |
|
976 | 993 | |
977 | 994 | // add entryid to the monitored folders |
978 | 995 | $this->changesSinkFolders[$entryid] = $folderid; |
@@ -1000,8 +1017,9 @@ discard block |
||
1000 | 1017 | $hierarchyNotifications = array(); |
1001 | 1018 | $sinkresult = @mapi_sink_timedwait($this->changesSink, $timeout * 1000); |
1002 | 1019 | |
1003 | - if (!is_array($sinkresult)) |
|
1004 | - throw new StatusException("Grommunio->ChangesSink(): Sink returned invalid notification, aborting", SyncCollections::OBSOLETE_CONNECTION); |
|
1020 | + if (!is_array($sinkresult)) { |
|
1021 | + throw new StatusException("Grommunio->ChangesSink(): Sink returned invalid notification, aborting", SyncCollections::OBSOLETE_CONNECTION); |
|
1022 | + } |
|
1005 | 1023 | |
1006 | 1024 | // reverse array so that the changes on folders are before changes on messages and |
1007 | 1025 | // it's possible to filter such notifications |
@@ -1116,8 +1134,7 @@ discard block |
||
1116 | 1134 | } |
1117 | 1135 | $response->recipientcount++; |
1118 | 1136 | $response->recipient[] = $entry; |
1119 | - } |
|
1120 | - elseif (is_int($recipient)) { |
|
1137 | + } elseif (is_int($recipient)) { |
|
1121 | 1138 | $response->status = $recipient; |
1122 | 1139 | } |
1123 | 1140 | } |
@@ -1170,22 +1187,27 @@ discard block |
||
1170 | 1187 | //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT |
1171 | 1188 | $addrbook = $this->getAddressbook(); |
1172 | 1189 | // FIXME: create a function to get the adressbook contentstable |
1173 | - if ($addrbook) |
|
1174 | - $ab_entryid = mapi_ab_getdefaultdir($addrbook); |
|
1175 | - if ($ab_entryid) |
|
1176 | - $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid); |
|
1177 | - if ($ab_dir) |
|
1178 | - $table = mapi_folder_getcontentstable($ab_dir); |
|
1190 | + if ($addrbook) { |
|
1191 | + $ab_entryid = mapi_ab_getdefaultdir($addrbook); |
|
1192 | + } |
|
1193 | + if ($ab_entryid) { |
|
1194 | + $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid); |
|
1195 | + } |
|
1196 | + if ($ab_dir) { |
|
1197 | + $table = mapi_folder_getcontentstable($ab_dir); |
|
1198 | + } |
|
1179 | 1199 | |
1180 | - if (!$table) |
|
1181 | - throw new StatusException(sprintf("Grommunio->GetGALSearchResults(): could not open addressbook: 0x%X", mapi_last_hresult()), SYNC_SEARCHSTATUS_STORE_CONNECTIONFAILED); |
|
1200 | + if (!$table) { |
|
1201 | + throw new StatusException(sprintf("Grommunio->GetGALSearchResults(): could not open addressbook: 0x%X", mapi_last_hresult()), SYNC_SEARCHSTATUS_STORE_CONNECTIONFAILED); |
|
1202 | + } |
|
1182 | 1203 | |
1183 | 1204 | $restriction = MAPIUtils::GetSearchRestriction(u2w($searchquery)); |
1184 | 1205 | mapi_table_restrict($table, $restriction); |
1185 | 1206 | mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND)); |
1186 | 1207 | |
1187 | - if (mapi_last_hresult()) |
|
1188 | - throw new StatusException(sprintf("Grommunio->GetGALSearchResults(): could not apply restriction: 0x%X", mapi_last_hresult()), SYNC_SEARCHSTATUS_STORE_TOOCOMPLEX); |
|
1208 | + if (mapi_last_hresult()) { |
|
1209 | + throw new StatusException(sprintf("Grommunio->GetGALSearchResults(): could not apply restriction: 0x%X", mapi_last_hresult()), SYNC_SEARCHSTATUS_STORE_TOOCOMPLEX); |
|
1210 | + } |
|
1189 | 1211 | |
1190 | 1212 | //range for the search results, default symbian range end is 50, wm 99, |
1191 | 1213 | //so we'll use that of nokia |
@@ -1203,8 +1225,9 @@ discard block |
||
1203 | 1225 | //do not return more results as requested in range |
1204 | 1226 | $querylimit = (($rangeend + 1) < $querycnt) ? ($rangeend + 1) : $querycnt; |
1205 | 1227 | |
1206 | - if ($querycnt > 0) |
|
1207 | - $abentries = mapi_table_queryrows($table, array(PR_ENTRYID, PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION, PR_EMS_AB_THUMBNAIL_PHOTO), $rangestart, $querylimit); |
|
1228 | + if ($querycnt > 0) { |
|
1229 | + $abentries = mapi_table_queryrows($table, array(PR_ENTRYID, PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION, PR_EMS_AB_THUMBNAIL_PHOTO), $rangestart, $querylimit); |
|
1230 | + } |
|
1208 | 1231 | |
1209 | 1232 | for ($i = 0; $i < $querylimit; $i++) { |
1210 | 1233 | if (!isset($abentries[$i][PR_SMTP_ADDRESS])) { |
@@ -1214,8 +1237,9 @@ discard block |
||
1214 | 1237 | |
1215 | 1238 | $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_DISPLAY_NAME]); |
1216 | 1239 | |
1217 | - if (strlen(trim($items[$i][SYNC_GAL_DISPLAYNAME])) == 0) |
|
1218 | - $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_ACCOUNT]); |
|
1240 | + if (strlen(trim($items[$i][SYNC_GAL_DISPLAYNAME])) == 0) { |
|
1241 | + $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_ACCOUNT]); |
|
1242 | + } |
|
1219 | 1243 | |
1220 | 1244 | $items[$i][SYNC_GAL_ALIAS] = w2u($abentries[$i][PR_ACCOUNT]); |
1221 | 1245 | //it's not possible not get first and last name of an user |
@@ -1223,32 +1247,42 @@ discard block |
||
1223 | 1247 | //to displayname and leave firstname unset |
1224 | 1248 | //this was changed in Zarafa 6.40, so we try to get first and |
1225 | 1249 | //last name and fall back to the old behaviour if these values are not set |
1226 | - if (isset($abentries[$i][PR_GIVEN_NAME])) |
|
1227 | - $items[$i][SYNC_GAL_FIRSTNAME] = w2u($abentries[$i][PR_GIVEN_NAME]); |
|
1228 | - if (isset($abentries[$i][PR_SURNAME])) |
|
1229 | - $items[$i][SYNC_GAL_LASTNAME] = w2u($abentries[$i][PR_SURNAME]); |
|
1250 | + if (isset($abentries[$i][PR_GIVEN_NAME])) { |
|
1251 | + $items[$i][SYNC_GAL_FIRSTNAME] = w2u($abentries[$i][PR_GIVEN_NAME]); |
|
1252 | + } |
|
1253 | + if (isset($abentries[$i][PR_SURNAME])) { |
|
1254 | + $items[$i][SYNC_GAL_LASTNAME] = w2u($abentries[$i][PR_SURNAME]); |
|
1255 | + } |
|
1230 | 1256 | |
1231 | - if (!isset($items[$i][SYNC_GAL_LASTNAME])) $items[$i][SYNC_GAL_LASTNAME] = $items[$i][SYNC_GAL_DISPLAYNAME]; |
|
1257 | + if (!isset($items[$i][SYNC_GAL_LASTNAME])) { |
|
1258 | + $items[$i][SYNC_GAL_LASTNAME] = $items[$i][SYNC_GAL_DISPLAYNAME]; |
|
1259 | + } |
|
1232 | 1260 | |
1233 | 1261 | $items[$i][SYNC_GAL_EMAILADDRESS] = w2u($abentries[$i][PR_SMTP_ADDRESS]); |
1234 | 1262 | //check if an user has an office number or it might produce warnings in the log |
1235 | - if (isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER])) |
|
1236 | - $items[$i][SYNC_GAL_PHONE] = w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]); |
|
1263 | + if (isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER])) { |
|
1264 | + $items[$i][SYNC_GAL_PHONE] = w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]); |
|
1265 | + } |
|
1237 | 1266 | //check if an user has a mobile number or it might produce warnings in the log |
1238 | - if (isset($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER])) |
|
1239 | - $items[$i][SYNC_GAL_MOBILEPHONE] = w2u($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER]); |
|
1267 | + if (isset($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER])) { |
|
1268 | + $items[$i][SYNC_GAL_MOBILEPHONE] = w2u($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER]); |
|
1269 | + } |
|
1240 | 1270 | //check if an user has a home number or it might produce warnings in the log |
1241 | - if (isset($abentries[$i][PR_HOME_TELEPHONE_NUMBER])) |
|
1242 | - $items[$i][SYNC_GAL_HOMEPHONE] = w2u($abentries[$i][PR_HOME_TELEPHONE_NUMBER]); |
|
1271 | + if (isset($abentries[$i][PR_HOME_TELEPHONE_NUMBER])) { |
|
1272 | + $items[$i][SYNC_GAL_HOMEPHONE] = w2u($abentries[$i][PR_HOME_TELEPHONE_NUMBER]); |
|
1273 | + } |
|
1243 | 1274 | |
1244 | - if (isset($abentries[$i][PR_COMPANY_NAME])) |
|
1245 | - $items[$i][SYNC_GAL_COMPANY] = w2u($abentries[$i][PR_COMPANY_NAME]); |
|
1275 | + if (isset($abentries[$i][PR_COMPANY_NAME])) { |
|
1276 | + $items[$i][SYNC_GAL_COMPANY] = w2u($abentries[$i][PR_COMPANY_NAME]); |
|
1277 | + } |
|
1246 | 1278 | |
1247 | - if (isset($abentries[$i][PR_TITLE])) |
|
1248 | - $items[$i][SYNC_GAL_TITLE] = w2u($abentries[$i][PR_TITLE]); |
|
1279 | + if (isset($abentries[$i][PR_TITLE])) { |
|
1280 | + $items[$i][SYNC_GAL_TITLE] = w2u($abentries[$i][PR_TITLE]); |
|
1281 | + } |
|
1249 | 1282 | |
1250 | - if (isset($abentries[$i][PR_OFFICE_LOCATION])) |
|
1251 | - $items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]); |
|
1283 | + if (isset($abentries[$i][PR_OFFICE_LOCATION])) { |
|
1284 | + $items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]); |
|
1285 | + } |
|
1252 | 1286 | |
1253 | 1287 | if ($searchpicture !== false && isset($abentries[$i][PR_EMS_AB_THUMBNAIL_PHOTO])) { |
1254 | 1288 | $items[$i][SYNC_GAL_PICTURE] = StringStreamWrapper::Open($abentries[$i][PR_EMS_AB_THUMBNAIL_PHOTO]); |
@@ -1297,8 +1331,10 @@ discard block |
||
1297 | 1331 | // do the search and wait for all the results available |
1298 | 1332 | while (time() - $searchStart < SEARCH_WAIT) { |
1299 | 1333 | $searchcriteria = mapi_folder_getsearchcriteria($searchFolder); |
1300 | - if(($searchcriteria["searchstate"] & SEARCH_REBUILD) == 0) |
|
1301 | - break; // Search is done |
|
1334 | + if(($searchcriteria["searchstate"] & SEARCH_REBUILD) == 0) { |
|
1335 | + break; |
|
1336 | + } |
|
1337 | + // Search is done |
|
1302 | 1338 | sleep(1); |
1303 | 1339 | } |
1304 | 1340 | |
@@ -1393,8 +1429,7 @@ discard block |
||
1393 | 1429 | // setup the correct store |
1394 | 1430 | if ($this->Setup($store, false, $folderid)) { |
1395 | 1431 | return $this->store; |
1396 | - } |
|
1397 | - else { |
|
1432 | + } else { |
|
1398 | 1433 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->GetMAPIStoreForFolderId('%s', '%s'): store is not available", $store, $folderid)); |
1399 | 1434 | return false; |
1400 | 1435 | } |
@@ -1505,8 +1540,7 @@ discard block |
||
1505 | 1540 | |
1506 | 1541 | if (isset($this->folderStatCache[$user][$folderid])) { |
1507 | 1542 | return $this->folderStatCache[$user][$folderid]; |
1508 | - } |
|
1509 | - else { |
|
1543 | + } else { |
|
1510 | 1544 | // a timestamp that changes once per hour is returned in case there is no data found for this folder. It will be synchronized only once per hour. |
1511 | 1545 | return gmdate("Y-m-d-H"); |
1512 | 1546 | } |
@@ -1581,8 +1615,7 @@ discard block |
||
1581 | 1615 | if (isset($stateMessageProps[PR_LAST_MODIFICATION_TIME])) { |
1582 | 1616 | return $stateMessageProps[PR_LAST_MODIFICATION_TIME]; |
1583 | 1617 | } |
1584 | - } |
|
1585 | - catch (StateNotFoundException $e) { } |
|
1618 | + } catch (StateNotFoundException $e) { } |
|
1586 | 1619 | return "0"; |
1587 | 1620 | } |
1588 | 1621 | |
@@ -1779,8 +1812,7 @@ discard block |
||
1779 | 1812 | if ($devid) { |
1780 | 1813 | $this->setDeviceUserData($this->userDeviceData, bin2hex($hierarchyRows[0][PR_ENTRYID]), $devid, $this->mainUser, "statefolder"); |
1781 | 1814 | } |
1782 | - } |
|
1783 | - elseif ($rowCnt == 0) { |
|
1815 | + } elseif ($rowCnt == 0) { |
|
1784 | 1816 | // legacy code: create the hidden state folder and the device subfolder |
1785 | 1817 | // this should happen when the user configures the device (autodiscover or first sync if no autodiscover) |
1786 | 1818 | |
@@ -1792,12 +1824,10 @@ discard block |
||
1792 | 1824 | if ($rowCnt == 1) { |
1793 | 1825 | $hierarchyRows = mapi_table_queryrows($hierarchy, [PR_ENTRYID], 0, 1); |
1794 | 1826 | $stateFolder = mapi_msgstore_openentry($this->store, $hierarchyRows[0][PR_ENTRYID]); |
1795 | - } |
|
1796 | - elseif ($rowCnt == 0) { |
|
1827 | + } elseif ($rowCnt == 0) { |
|
1797 | 1828 | $stateFolder = mapi_folder_createfolder($rootfolder, STORE_STATE_FOLDER, ""); |
1798 | 1829 | mapi_setprops($stateFolder, array(PR_ATTR_HIDDEN => true)); |
1799 | - } |
|
1800 | - else { |
|
1830 | + } else { |
|
1801 | 1831 | // TODO: handle this |
1802 | 1832 | } |
1803 | 1833 | if (isset($stateFolder) && $stateFolder) { |
@@ -1806,12 +1836,10 @@ discard block |
||
1806 | 1836 | $this->stateFolder = mapi_msgstore_openentry($this->store, $devStateFolderProps[PR_ENTRYID]); |
1807 | 1837 | mapi_setprops($this->stateFolder, array(PR_ATTR_HIDDEN => true)); |
1808 | 1838 | // we don't cache the entryid in redis, because this will happen on the next request anyway |
1809 | - } |
|
1810 | - else { |
|
1839 | + } else { |
|
1811 | 1840 | // TODO: unable to create state folder - throw exception |
1812 | 1841 | } |
1813 | - } |
|
1814 | - else { |
|
1842 | + } else { |
|
1815 | 1843 | // This case is rather unlikely that there would be several |
1816 | 1844 | // hidden folders having PR_DISPLAY_NAME the same as device id. |
1817 | 1845 | |
@@ -1852,8 +1880,7 @@ discard block |
||
1852 | 1880 | if ($rowCnt == 1) { |
1853 | 1881 | $stateFolderRows = mapi_table_queryrows($stateFolderContents, [PR_ENTRYID], 0, 1); |
1854 | 1882 | return mapi_msgstore_openentry($this->store, $stateFolderRows[0][PR_ENTRYID]); |
1855 | - } |
|
1856 | - elseif($rowCnt > 1) { |
|
1883 | + } elseif($rowCnt > 1) { |
|
1857 | 1884 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->getStateMessage(): Found several (%d) states for '%s'", $rowCnt, $messageName)); |
1858 | 1885 | } |
1859 | 1886 | } |
@@ -1880,8 +1907,7 @@ discard block |
||
1880 | 1907 | } |
1881 | 1908 | try { |
1882 | 1909 | $stateMessage = $this->getStateMessage($devid, $type, $key, $counter); |
1883 | - } |
|
1884 | - catch (StateNotFoundException $e) { |
|
1910 | + } catch (StateNotFoundException $e) { |
|
1885 | 1911 | // if message is not available, try to create a new one |
1886 | 1912 | $stateMessage = mapi_folder_createmessage($this->stateFolder, MAPI_ASSOCIATED); |
1887 | 1913 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->setStateMessage(): mapi_folder_createmessage 0x%08X", mapi_last_hresult())); |
@@ -1999,8 +2025,7 @@ discard block |
||
1999 | 2025 | if (mapi_last_hresult()) { |
2000 | 2026 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->adviseStoreToSink(): failed to advised store '%s' with code 0x%X. Polling will be performed.", $store, mapi_last_hresult())); |
2001 | 2027 | return false; |
2002 | - } |
|
2003 | - else { |
|
2028 | + } else { |
|
2004 | 2029 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->adviseStoreToSink(): advised store '%s'", $store)); |
2005 | 2030 | $this->changesSinkStores[] = $store; |
2006 | 2031 | } |
@@ -2020,14 +2045,16 @@ discard block |
||
2020 | 2045 | private function openMessageStore($user) { |
2021 | 2046 | // During PING requests the operations store has to be switched constantly |
2022 | 2047 | // the cache prevents the same store opened several times |
2023 | - if (isset($this->storeCache[$user])) |
|
2024 | - return $this->storeCache[$user]; |
|
2048 | + if (isset($this->storeCache[$user])) { |
|
2049 | + return $this->storeCache[$user]; |
|
2050 | + } |
|
2025 | 2051 | |
2026 | 2052 | $entryid = false; |
2027 | 2053 | $return_public = false; |
2028 | 2054 | |
2029 | - if (strtoupper($user) == 'SYSTEM') |
|
2030 | - $return_public = true; |
|
2055 | + if (strtoupper($user) == 'SYSTEM') { |
|
2056 | + $return_public = true; |
|
2057 | + } |
|
2031 | 2058 | |
2032 | 2059 | // loop through the storestable if authenticated user of public folder |
2033 | 2060 | if ($user == $this->mainUser || $return_public === true) { |
@@ -2049,9 +2076,9 @@ discard block |
||
2049 | 2076 | } |
2050 | 2077 | } |
2051 | 2078 | } |
2079 | + } else { |
|
2080 | + $entryid = @mapi_msgstore_createentryid($this->defaultstore, $user); |
|
2052 | 2081 | } |
2053 | - else |
|
2054 | - $entryid = @mapi_msgstore_createentryid($this->defaultstore, $user); |
|
2055 | 2082 | |
2056 | 2083 | if($entryid) { |
2057 | 2084 | $store = @mapi_openmsgstore($this->session, $entryid); |
@@ -2062,13 +2089,13 @@ discard block |
||
2062 | 2089 | } |
2063 | 2090 | |
2064 | 2091 | // add this store to the cache |
2065 | - if (!isset($this->storeCache[$user])) |
|
2066 | - $this->storeCache[$user] = $store; |
|
2092 | + if (!isset($this->storeCache[$user])) { |
|
2093 | + $this->storeCache[$user] = $store; |
|
2094 | + } |
|
2067 | 2095 | |
2068 | 2096 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->openMessageStore('%s'): Found '%s' store: '%s'", $user, (($return_public)?'PUBLIC':'DEFAULT'),$store)); |
2069 | 2097 | return $store; |
2070 | - } |
|
2071 | - else { |
|
2098 | + } else { |
|
2072 | 2099 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->openMessageStore('%s'): No store found for this user", $user)); |
2073 | 2100 | return false; |
2074 | 2101 | } |
@@ -2124,8 +2151,7 @@ discard block |
||
2124 | 2151 | //if oof state is set it must be set of oof and get otherwise |
2125 | 2152 | if (isset($oof->oofstate)) { |
2126 | 2153 | $this->settingsOofSet($oof); |
2127 | - } |
|
2128 | - else { |
|
2154 | + } else { |
|
2129 | 2155 | $this->settingsOofGet($oof); |
2130 | 2156 | } |
2131 | 2157 | } |
@@ -2163,26 +2189,22 @@ discard block |
||
2163 | 2189 | @mapi_setprops($this->defaultstore, array(PR_EC_OUTOFOFFICE => false)); |
2164 | 2190 | @mapi_deleteprops($this->defaultstore, array(PR_EC_OUTOFOFFICE_FROM, PR_EC_OUTOFOFFICE_UNTIL)); |
2165 | 2191 | ZLog::Write(LOGLEVEL_INFO, "Grommunio->settingsOofGet(): Out of office is set but the from and until are in the past. Disabling out of office."); |
2166 | - } |
|
2167 | - elseif ($oofprops[PR_EC_OUTOFOFFICE_FROM] < $oofprops[PR_EC_OUTOFOFFICE_UNTIL]) { |
|
2192 | + } elseif ($oofprops[PR_EC_OUTOFOFFICE_FROM] < $oofprops[PR_EC_OUTOFOFFICE_UNTIL]) { |
|
2168 | 2193 | $oof->oofstate = SYNC_SETTINGSOOF_TIMEBASED; |
2169 | 2194 | $oof->starttime = $oofprops[PR_EC_OUTOFOFFICE_FROM]; |
2170 | 2195 | $oof->endtime = $oofprops[PR_EC_OUTOFOFFICE_UNTIL]; |
2171 | - } |
|
2172 | - else { |
|
2196 | + } else { |
|
2173 | 2197 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->settingsOofGet(): Time based out of office set but end time ('%s') is before startime ('%s').", |
2174 | 2198 | date("Y-m-d H:i:s", $oofprops[PR_EC_OUTOFOFFICE_FROM]), date("Y-m-d H:i:s", $oofprops[PR_EC_OUTOFOFFICE_UNTIL]))); |
2175 | 2199 | $oof->Status = SYNC_SETTINGSSTATUS_PROTOCOLLERROR; |
2176 | 2200 | } |
2177 | - } |
|
2178 | - elseif ($oof->oofstate == SYNC_SETTINGSOOF_GLOBAL && (isset($oofprops[PR_EC_OUTOFOFFICE_FROM]) || isset($oofprops[PR_EC_OUTOFOFFICE_UNTIL]))) { |
|
2201 | + } elseif ($oof->oofstate == SYNC_SETTINGSOOF_GLOBAL && (isset($oofprops[PR_EC_OUTOFOFFICE_FROM]) || isset($oofprops[PR_EC_OUTOFOFFICE_UNTIL]))) { |
|
2179 | 2202 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->settingsOofGet(): Time based out of office set but either start time ('%s') or end time ('%s') is missing.", |
2180 | 2203 | (isset($oofprops[PR_EC_OUTOFOFFICE_FROM]) ? date("Y-m-d H:i:s", $oofprops[PR_EC_OUTOFOFFICE_FROM]) : 'empty'), |
2181 | 2204 | (isset($oofprops[PR_EC_OUTOFOFFICE_UNTIL]) ? date("Y-m-d H:i:s", $oofprops[PR_EC_OUTOFOFFICE_UNTIL]) : 'empty'))); |
2182 | 2205 | $oof->Status = SYNC_SETTINGSSTATUS_PROTOCOLLERROR; |
2183 | 2206 | } |
2184 | - } |
|
2185 | - else { |
|
2207 | + } else { |
|
2186 | 2208 | ZLog::Write(LOGLEVEL_WARN, "Grommunio->Unable to get out of office information"); |
2187 | 2209 | } |
2188 | 2210 | |
@@ -2213,16 +2235,13 @@ discard block |
||
2213 | 2235 | if(isset($oof->starttime) && isset($oof->endtime)) { |
2214 | 2236 | $props[PR_EC_OUTOFOFFICE_FROM] = $oof->starttime; |
2215 | 2237 | $props[PR_EC_OUTOFOFFICE_UNTIL] = $oof->endtime; |
2216 | - } |
|
2217 | - elseif (isset($oof->starttime) || isset($oof->endtime)) { |
|
2238 | + } elseif (isset($oof->starttime) || isset($oof->endtime)) { |
|
2218 | 2239 | $oof->Status = SYNC_SETTINGSSTATUS_PROTOCOLLERROR; |
2219 | 2240 | } |
2220 | - } |
|
2221 | - else { |
|
2241 | + } else { |
|
2222 | 2242 | $deleteProps = array(PR_EC_OUTOFOFFICE_FROM, PR_EC_OUTOFOFFICE_UNTIL); |
2223 | 2243 | } |
2224 | - } |
|
2225 | - elseif($oof->oofstate == SYNC_SETTINGSOOF_DISABLED) { |
|
2244 | + } elseif($oof->oofstate == SYNC_SETTINGSOOF_DISABLED) { |
|
2226 | 2245 | $props[PR_EC_OUTOFOFFICE] = false; |
2227 | 2246 | $deleteProps = array(PR_EC_OUTOFOFFICE_FROM, PR_EC_OUTOFOFFICE_UNTIL); |
2228 | 2247 | } |
@@ -2266,8 +2285,7 @@ discard block |
||
2266 | 2285 | $emailaddresses->primarysmtpaddress = $user["primary_email"]; |
2267 | 2286 | $account->emailaddresses = $emailaddresses; |
2268 | 2287 | $userinformation->accounts[] = $account; |
2269 | - } |
|
2270 | - else { |
|
2288 | + } else { |
|
2271 | 2289 | $userinformation->emailaddresses[] = $user["primary_email"]; |
2272 | 2290 | } |
2273 | 2291 | return true; |
@@ -2519,10 +2537,12 @@ discard block |
||
2519 | 2537 | $addrbook = $this->getAddressbook(); |
2520 | 2538 | // FIXME: create a function to get the adressbook contentstable |
2521 | 2539 | $ab_entryid = mapi_ab_getdefaultdir($addrbook); |
2522 | - if ($ab_entryid) |
|
2523 | - $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid); |
|
2524 | - if ($ab_dir) |
|
2525 | - $table = mapi_folder_getcontentstable($ab_dir); |
|
2540 | + if ($ab_entryid) { |
|
2541 | + $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid); |
|
2542 | + } |
|
2543 | + if ($ab_dir) { |
|
2544 | + $table = mapi_folder_getcontentstable($ab_dir); |
|
2545 | + } |
|
2526 | 2546 | |
2527 | 2547 | if (!$table) { |
2528 | 2548 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->resolveRecipientGAL(): Unable to open addressbook:0x%X", mapi_last_hresult())); |
@@ -2539,12 +2559,10 @@ discard block |
||
2539 | 2559 | // some devices request 0 ambiguous recipients |
2540 | 2560 | if ($querycnt == 1 && $maxAmbiguousRecipients == 0) { |
2541 | 2561 | $rowsToQuery = 1; |
2542 | - } |
|
2543 | - elseif ($querycnt > 1 && $maxAmbiguousRecipients == 0) { |
|
2562 | + } elseif ($querycnt > 1 && $maxAmbiguousRecipients == 0) { |
|
2544 | 2563 | ZLog::Write(LOGLEVEL_INFO, sprintf("Grommunio->resolveRecipientGAL(): GAL search found %d recipients but the device hasn't requested ambiguous recipients", $querycnt)); |
2545 | 2564 | return $recipientGal; |
2546 | - } |
|
2547 | - elseif ($querycnt > 1 && $maxAmbiguousRecipients == 1) { |
|
2565 | + } elseif ($querycnt > 1 && $maxAmbiguousRecipients == 1) { |
|
2548 | 2566 | $rowsToQuery = $querycnt; |
2549 | 2567 | } |
2550 | 2568 | // get the certificate every time because caching the certificate is less expensive than opening addressbook entry again |
@@ -2565,21 +2583,18 @@ discard block |
||
2565 | 2583 | ZLog::Write(LOGLEVEL_WBXML, sprintf("Grommunio->resolveRecipientGAL(): distlist's '%s' member: '%s'", $to, $distListMembers[$j][PR_DISPLAY_NAME])); |
2566 | 2584 | $recipientGal[] = $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_GAL, $to, $distListMembers[$j], $nrDistListMembers); |
2567 | 2585 | } |
2568 | - } |
|
2569 | - else { |
|
2586 | + } else { |
|
2570 | 2587 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->resolveRecipientGAL(): '%s' is a dist list, but return it as is.", $to)); |
2571 | 2588 | $recipientGal[] = $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_GAL, $abentries[$i][PR_SMTP_ADDRESS], $abentries[$i]); |
2572 | 2589 | } |
2573 | - } |
|
2574 | - elseif ($abentries[$i][PR_OBJECT_TYPE] == MAPI_MAILUSER) { |
|
2590 | + } elseif ($abentries[$i][PR_OBJECT_TYPE] == MAPI_MAILUSER) { |
|
2575 | 2591 | $recipientGal[] = $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_GAL, $abentries[$i][PR_SMTP_ADDRESS], $abentries[$i]); |
2576 | 2592 | } |
2577 | 2593 | } |
2578 | 2594 | |
2579 | 2595 | ZLog::Write(LOGLEVEL_WBXML, "Grommunio->resolveRecipientGAL(): Found a recipient in GAL"); |
2580 | 2596 | return $recipientGal; |
2581 | - } |
|
2582 | - else { |
|
2597 | + } else { |
|
2583 | 2598 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->resolveRecipientGAL(): No recipient found for: '%s' in GAL", $to)); |
2584 | 2599 | return SYNC_RESOLVERECIPSSTATUS_RESPONSE_UNRESOLVEDRECIP; |
2585 | 2600 | } |
@@ -2655,8 +2670,7 @@ discard block |
||
2655 | 2670 | break; |
2656 | 2671 | } |
2657 | 2672 | } |
2658 | - } |
|
2659 | - else { |
|
2673 | + } else { |
|
2660 | 2674 | ZLog::Write(LOGLEVEL_WARN, sprintf("Grommunio->resolveRecipientContact(): Unable to open public store: 0x%X", $result)); |
2661 | 2675 | } |
2662 | 2676 | |
@@ -2711,18 +2725,15 @@ discard block |
||
2711 | 2725 | |
2712 | 2726 | if ($type == SYNC_RESOLVERECIPIENTS_TYPE_GAL) { |
2713 | 2727 | $certificateProp = PR_EMS_AB_TAGGED_X509_CERT; |
2714 | - } |
|
2715 | - elseif ($type == SYNC_RESOLVERECIPIENTS_TYPE_CONTACT) { |
|
2728 | + } elseif ($type == SYNC_RESOLVERECIPIENTS_TYPE_CONTACT) { |
|
2716 | 2729 | $certificateProp = PR_USER_X509_CERTIFICATE; |
2717 | - } |
|
2718 | - else { |
|
2730 | + } else { |
|
2719 | 2731 | $certificateProp = null; |
2720 | 2732 | } |
2721 | 2733 | |
2722 | 2734 | if (isset($recipientProperties[$certificateProp]) && is_array($recipientProperties[$certificateProp]) && !empty($recipientProperties[$certificateProp])) { |
2723 | 2735 | $certificates = $this->getCertificates($recipientProperties[$certificateProp], $recipientCount); |
2724 | - } |
|
2725 | - else { |
|
2736 | + } else { |
|
2726 | 2737 | $certificates = $this->getCertificates(false); |
2727 | 2738 | ZLog::Write(LOGLEVEL_INFO, sprintf("Grommunio->createResolveRecipient(): No certificate found for '%s' (requested email address: '%s')", $recipientProperties[PR_DISPLAY_NAME], $email)); |
2728 | 2739 | } |
@@ -2854,8 +2865,7 @@ discard block |
||
2854 | 2865 | $deviceIdDisabled = ( ($deviceId !==null) && in_array($deviceId, array_map('strtolower', $enabledFeatures[PR_EC_DISABLED_FEATURES])) )? true : false; |
2855 | 2866 | if ($mobileDisabled) { |
2856 | 2867 | throw new FatalException("User is disabled for grommunio-sync."); |
2857 | - } |
|
2858 | - elseif ($deviceIdDisabled) { |
|
2868 | + } elseif ($deviceIdDisabled) { |
|
2859 | 2869 | throw new FatalException(sprintf("User has deviceId %s disabled for usage with grommunio-sync.", $deviceId)); |
2860 | 2870 | } |
2861 | 2871 | } |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | public static function GetEmailRestriction($timestamp) { |
26 | 26 | // ATTENTION: ON CHANGING THIS RESTRICTION, MAPIUtils::IsInEmailSyncInterval() also needs to be changed |
27 | 27 | $restriction = array ( RES_PROPERTY, |
28 | - array ( RELOP => RELOP_GE, |
|
28 | + array ( RELOP => RELOP_GE, |
|
29 | 29 | ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, |
30 | 30 | VALUE => $timestamp |
31 | - ) |
|
32 | - ); |
|
31 | + ) |
|
32 | + ); |
|
33 | 33 | |
34 | 34 | return $restriction; |
35 | 35 | } |
@@ -56,80 +56,80 @@ discard block |
||
56 | 56 | |
57 | 57 | // ATTENTION: ON CHANGING THIS RESTRICTION, MAPIUtils::IsInCalendarSyncInterval() also needs to be changed |
58 | 58 | $restriction = Array(RES_OR, |
59 | - Array( |
|
60 | - // OR |
|
61 | - // item.end > window.start && item.start < window.end |
|
62 | - Array(RES_AND, |
|
63 | - Array( |
|
64 | - Array(RES_PROPERTY, |
|
65 | - Array(RELOP => RELOP_LE, |
|
66 | - ULPROPTAG => $props["starttime"], |
|
67 | - VALUE => $end |
|
68 | - ) |
|
69 | - ), |
|
70 | - Array(RES_PROPERTY, |
|
71 | - Array(RELOP => RELOP_GE, |
|
72 | - ULPROPTAG => $props["endtime"], |
|
73 | - VALUE => $start |
|
74 | - ) |
|
75 | - ) |
|
76 | - ) |
|
77 | - ), |
|
78 | - // OR |
|
79 | - Array(RES_OR, |
|
80 | - Array( |
|
81 | - // OR |
|
82 | - // (EXIST(recurrence_enddate_property) && item[isRecurring] == true && recurrence_enddate_property >= start) |
|
83 | - Array(RES_AND, |
|
84 | - Array( |
|
85 | - Array(RES_EXIST, |
|
86 | - Array(ULPROPTAG => $props["recurrenceend"], |
|
87 | - ) |
|
88 | - ), |
|
89 | - Array(RES_PROPERTY, |
|
90 | - Array(RELOP => RELOP_EQ, |
|
91 | - ULPROPTAG => $props["isrecurring"], |
|
92 | - VALUE => true |
|
93 | - ) |
|
94 | - ), |
|
95 | - Array(RES_PROPERTY, |
|
96 | - Array(RELOP => RELOP_GE, |
|
97 | - ULPROPTAG => $props["recurrenceend"], |
|
98 | - VALUE => $start |
|
99 | - ) |
|
100 | - ) |
|
101 | - ) |
|
102 | - ), |
|
103 | - // OR |
|
104 | - // (!EXIST(recurrence_enddate_property) && item[isRecurring] == true && item[start] <= end) |
|
105 | - Array(RES_AND, |
|
106 | - Array( |
|
107 | - Array(RES_NOT, |
|
108 | - Array( |
|
109 | - Array(RES_EXIST, |
|
110 | - Array(ULPROPTAG => $props["recurrenceend"] |
|
111 | - ) |
|
112 | - ) |
|
113 | - ) |
|
114 | - ), |
|
115 | - Array(RES_PROPERTY, |
|
116 | - Array(RELOP => RELOP_LE, |
|
117 | - ULPROPTAG => $props["starttime"], |
|
118 | - VALUE => $end |
|
119 | - ) |
|
120 | - ), |
|
121 | - Array(RES_PROPERTY, |
|
122 | - Array(RELOP => RELOP_EQ, |
|
123 | - ULPROPTAG => $props["isrecurring"], |
|
124 | - VALUE => true |
|
125 | - ) |
|
126 | - ) |
|
127 | - ) |
|
128 | - ) |
|
129 | - ) |
|
130 | - ) // EXISTS OR |
|
131 | - ) |
|
132 | - ); // global OR |
|
59 | + Array( |
|
60 | + // OR |
|
61 | + // item.end > window.start && item.start < window.end |
|
62 | + Array(RES_AND, |
|
63 | + Array( |
|
64 | + Array(RES_PROPERTY, |
|
65 | + Array(RELOP => RELOP_LE, |
|
66 | + ULPROPTAG => $props["starttime"], |
|
67 | + VALUE => $end |
|
68 | + ) |
|
69 | + ), |
|
70 | + Array(RES_PROPERTY, |
|
71 | + Array(RELOP => RELOP_GE, |
|
72 | + ULPROPTAG => $props["endtime"], |
|
73 | + VALUE => $start |
|
74 | + ) |
|
75 | + ) |
|
76 | + ) |
|
77 | + ), |
|
78 | + // OR |
|
79 | + Array(RES_OR, |
|
80 | + Array( |
|
81 | + // OR |
|
82 | + // (EXIST(recurrence_enddate_property) && item[isRecurring] == true && recurrence_enddate_property >= start) |
|
83 | + Array(RES_AND, |
|
84 | + Array( |
|
85 | + Array(RES_EXIST, |
|
86 | + Array(ULPROPTAG => $props["recurrenceend"], |
|
87 | + ) |
|
88 | + ), |
|
89 | + Array(RES_PROPERTY, |
|
90 | + Array(RELOP => RELOP_EQ, |
|
91 | + ULPROPTAG => $props["isrecurring"], |
|
92 | + VALUE => true |
|
93 | + ) |
|
94 | + ), |
|
95 | + Array(RES_PROPERTY, |
|
96 | + Array(RELOP => RELOP_GE, |
|
97 | + ULPROPTAG => $props["recurrenceend"], |
|
98 | + VALUE => $start |
|
99 | + ) |
|
100 | + ) |
|
101 | + ) |
|
102 | + ), |
|
103 | + // OR |
|
104 | + // (!EXIST(recurrence_enddate_property) && item[isRecurring] == true && item[start] <= end) |
|
105 | + Array(RES_AND, |
|
106 | + Array( |
|
107 | + Array(RES_NOT, |
|
108 | + Array( |
|
109 | + Array(RES_EXIST, |
|
110 | + Array(ULPROPTAG => $props["recurrenceend"] |
|
111 | + ) |
|
112 | + ) |
|
113 | + ) |
|
114 | + ), |
|
115 | + Array(RES_PROPERTY, |
|
116 | + Array(RELOP => RELOP_LE, |
|
117 | + ULPROPTAG => $props["starttime"], |
|
118 | + VALUE => $end |
|
119 | + ) |
|
120 | + ), |
|
121 | + Array(RES_PROPERTY, |
|
122 | + Array(RELOP => RELOP_EQ, |
|
123 | + ULPROPTAG => $props["isrecurring"], |
|
124 | + VALUE => true |
|
125 | + ) |
|
126 | + ) |
|
127 | + ) |
|
128 | + ) |
|
129 | + ) |
|
130 | + ) // EXISTS OR |
|
131 | + ) |
|
132 | + ); // global OR |
|
133 | 133 | |
134 | 134 | return $restriction; |
135 | 135 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | //(!EXIST(recurrence_enddate_property) && item[isRecurring] == true && item[start] <= end) |
326 | 326 | !isset($p[$props["recurrenceend"]]) && $p[$props["isrecurring"]] == true && $p[$props["starttime"]] <= $end |
327 | 327 | ) |
328 | - ) { |
|
328 | + ) { |
|
329 | 329 | ZLog::Write(LOGLEVEL_DEBUG, "MAPIUtils->IsInCalendarSyncInterval: Message is in the synchronization interval"); |
330 | 330 | return true; |
331 | 331 | } |
@@ -24,8 +24,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -377,8 +377,7 @@ discard block |
||
377 | 377 | if ($ret == MAPI_E_NOT_FOUND) { |
378 | 378 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("MAPIUtils->readPropStream: property 0x%08X not found. It is either empty or not set. It will be ignored.", $prop)); |
379 | 379 | return ""; |
380 | - } |
|
381 | - elseif ($ret) { |
|
380 | + } elseif ($ret) { |
|
382 | 381 | ZLog::Write(LOGLEVEL_ERROR, "MAPIUtils->readPropStream error opening stream: 0x%08X", $ret); |
383 | 382 | return ""; |
384 | 383 | } |
@@ -386,8 +385,9 @@ discard block |
||
386 | 385 | $string = ""; |
387 | 386 | while(1) { |
388 | 387 | $data = mapi_stream_read($stream, 1024); |
389 | - if(strlen($data) == 0) |
|
390 | - break; |
|
388 | + if(strlen($data) == 0) { |
|
389 | + break; |
|
390 | + } |
|
391 | 391 | $string .= $data; |
392 | 392 | } |
393 | 393 | |
@@ -480,75 +480,85 @@ discard block |
||
480 | 480 | */ |
481 | 481 | public static function GetNativeBodyType($messageprops) { |
482 | 482 | //check if the properties are set and get the error code if needed |
483 | - if (!isset($messageprops[PR_BODY])) $messageprops[PR_BODY] = self::GetError(PR_BODY, $messageprops); |
|
484 | - if (!isset($messageprops[PR_RTF_COMPRESSED])) $messageprops[PR_RTF_COMPRESSED] = self::GetError(PR_RTF_COMPRESSED, $messageprops); |
|
485 | - if (!isset($messageprops[PR_HTML])) $messageprops[PR_HTML] = self::GetError(PR_HTML, $messageprops); |
|
486 | - if (!isset($messageprops[PR_RTF_IN_SYNC])) $messageprops[PR_RTF_IN_SYNC] = self::GetError(PR_RTF_IN_SYNC, $messageprops); |
|
483 | + if (!isset($messageprops[PR_BODY])) { |
|
484 | + $messageprops[PR_BODY] = self::GetError(PR_BODY, $messageprops); |
|
485 | + } |
|
486 | + if (!isset($messageprops[PR_RTF_COMPRESSED])) { |
|
487 | + $messageprops[PR_RTF_COMPRESSED] = self::GetError(PR_RTF_COMPRESSED, $messageprops); |
|
488 | + } |
|
489 | + if (!isset($messageprops[PR_HTML])) { |
|
490 | + $messageprops[PR_HTML] = self::GetError(PR_HTML, $messageprops); |
|
491 | + } |
|
492 | + if (!isset($messageprops[PR_RTF_IN_SYNC])) { |
|
493 | + $messageprops[PR_RTF_IN_SYNC] = self::GetError(PR_RTF_IN_SYNC, $messageprops); |
|
494 | + } |
|
487 | 495 | |
488 | 496 | if ( // 1 |
489 | 497 | ($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) && |
490 | 498 | ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) && |
491 | - ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) |
|
492 | - return SYNC_BODYPREFERENCE_PLAIN; |
|
493 | - elseif ( // 2 |
|
499 | + ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) { |
|
500 | + return SYNC_BODYPREFERENCE_PLAIN; |
|
501 | + } elseif ( // 2 |
|
494 | 502 | ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
495 | 503 | ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) && |
496 | - ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) |
|
497 | - return SYNC_BODYPREFERENCE_PLAIN; |
|
498 | - elseif ( // 3 |
|
504 | + ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) { |
|
505 | + return SYNC_BODYPREFERENCE_PLAIN; |
|
506 | + } elseif ( // 3 |
|
499 | 507 | ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
500 | 508 | ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
501 | - ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) |
|
502 | - return SYNC_BODYPREFERENCE_RTF; |
|
503 | - elseif ( // 4 |
|
509 | + ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) { |
|
510 | + return SYNC_BODYPREFERENCE_RTF; |
|
511 | + } elseif ( // 4 |
|
504 | 512 | ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
505 | 513 | ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
506 | 514 | ($messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) && |
507 | - ($messageprops[PR_RTF_IN_SYNC])) |
|
508 | - return SYNC_BODYPREFERENCE_RTF; |
|
509 | - elseif ( // 5 |
|
515 | + ($messageprops[PR_RTF_IN_SYNC])) { |
|
516 | + return SYNC_BODYPREFERENCE_RTF; |
|
517 | + } elseif ( // 5 |
|
510 | 518 | ($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
511 | 519 | ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
512 | 520 | ($messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) && |
513 | - (!$messageprops[PR_RTF_IN_SYNC])) |
|
514 | - return SYNC_BODYPREFERENCE_HTML; |
|
515 | - elseif ( // 6 |
|
521 | + (!$messageprops[PR_RTF_IN_SYNC])) { |
|
522 | + return SYNC_BODYPREFERENCE_HTML; |
|
523 | + } elseif ( // 6 |
|
516 | 524 | ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
517 | 525 | ($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) && |
518 | - ($messageprops[PR_RTF_IN_SYNC])) |
|
519 | - return SYNC_BODYPREFERENCE_RTF; |
|
520 | - elseif ( // 7 |
|
526 | + ($messageprops[PR_RTF_IN_SYNC])) { |
|
527 | + return SYNC_BODYPREFERENCE_RTF; |
|
528 | + } elseif ( // 7 |
|
521 | 529 | ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
522 | 530 | ($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) && |
523 | - (!$messageprops[PR_RTF_IN_SYNC])) |
|
524 | - return SYNC_BODYPREFERENCE_HTML; |
|
525 | - elseif ( // 8 |
|
531 | + (!$messageprops[PR_RTF_IN_SYNC])) { |
|
532 | + return SYNC_BODYPREFERENCE_HTML; |
|
533 | + } elseif ( // 8 |
|
526 | 534 | ($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
527 | 535 | ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
528 | - ($messageprops[PR_RTF_IN_SYNC])) |
|
529 | - return SYNC_BODYPREFERENCE_RTF; |
|
530 | - elseif ( // 9.1 |
|
536 | + ($messageprops[PR_RTF_IN_SYNC])) { |
|
537 | + return SYNC_BODYPREFERENCE_RTF; |
|
538 | + } elseif ( // 9.1 |
|
531 | 539 | ($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
532 | 540 | ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
533 | - (!$messageprops[PR_RTF_IN_SYNC])) |
|
534 | - return SYNC_BODYPREFERENCE_PLAIN; |
|
535 | - elseif ( // 9.2 |
|
541 | + (!$messageprops[PR_RTF_IN_SYNC])) { |
|
542 | + return SYNC_BODYPREFERENCE_PLAIN; |
|
543 | + } elseif ( // 9.2 |
|
536 | 544 | ($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) && |
537 | 545 | ($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) && |
538 | - ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) |
|
539 | - return SYNC_BODYPREFERENCE_RTF; |
|
540 | - elseif ( // 9.3 |
|
546 | + ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) { |
|
547 | + return SYNC_BODYPREFERENCE_RTF; |
|
548 | + } elseif ( // 9.3 |
|
541 | 549 | ($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) && |
542 | 550 | ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) && |
543 | - ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) |
|
544 | - return SYNC_BODYPREFERENCE_PLAIN; |
|
545 | - elseif ( // 9.4 |
|
551 | + ($messageprops[PR_HTML] == MAPI_E_NOT_FOUND)) { |
|
552 | + return SYNC_BODYPREFERENCE_PLAIN; |
|
553 | + } elseif ( // 9.4 |
|
546 | 554 | ($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) && |
547 | 555 | ($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) && |
548 | - ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND)) |
|
549 | - return SYNC_BODYPREFERENCE_HTML; |
|
550 | - else // 10 |
|
556 | + ($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND)) { |
|
557 | + return SYNC_BODYPREFERENCE_HTML; |
|
558 | + } else { |
|
559 | + // 10 |
|
551 | 560 | return SYNC_BODYPREFERENCE_PLAIN; |
561 | + } |
|
552 | 562 | } |
553 | 563 | |
554 | 564 | /** |
@@ -656,8 +666,7 @@ discard block |
||
656 | 666 | if ($eid1['length'] < $eid1['min_length'] || $eid1['id'] != $eid2['id']) { |
657 | 667 | return false; |
658 | 668 | } |
659 | - } |
|
660 | - elseif ($eid1['length'] < $eid1['min_length'] || $eid1['uniqueId'] != $eid2['uniqueId']) { |
|
669 | + } elseif ($eid1['length'] < $eid1['min_length'] || $eid1['uniqueId'] != $eid2['uniqueId']) { |
|
661 | 670 | return false; |
662 | 671 | } |
663 | 672 | |
@@ -795,8 +804,7 @@ discard block |
||
795 | 804 | if (substr($entryId, $len - ($offset + 2), $len - $offset) == '00') { |
796 | 805 | $padding .= '00'; |
797 | 806 | $offset += 2; |
798 | - } |
|
799 | - else { |
|
807 | + } else { |
|
800 | 808 | // if non-null character found then break the loop |
801 | 809 | break; |
802 | 810 | } |
@@ -48,7 +48,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | $parentsourcekey = $props[PR_PARENT_SOURCE_KEY]; |
90 | 90 | $entryid = mapi_msgstore_entryidfromsourcekey($this->store, $parentsourcekey, $sourcekey); |
91 | 91 | |
92 | - if(!$entryid) |
|
93 | - return SYNC_E_IGNORE; |
|
92 | + if(!$entryid) { |
|
93 | + return SYNC_E_IGNORE; |
|
94 | + } |
|
94 | 95 | |
95 | 96 | $mapimessage = mapi_msgstore_openentry($this->store, $entryid); |
96 | 97 | try { |
@@ -103,19 +104,16 @@ discard block |
||
103 | 104 | if ($message->SupportsPrivateStripping()) { |
104 | 105 | ZLog::Write(LOGLEVEL_DEBUG, "PHPWrapper->ImportMessageChange(): stripping data of private message from a shared folder"); |
105 | 106 | $message->StripData(Streamer::STRIP_PRIVATE_DATA); |
106 | - } |
|
107 | - else { |
|
107 | + } else { |
|
108 | 108 | ZLog::Write(LOGLEVEL_DEBUG, "PHPWrapper->ImportMessageChange(): ignoring private message from a shared folder"); |
109 | 109 | return SYNC_E_IGNORE; |
110 | 110 | } |
111 | 111 | } |
112 | - } |
|
113 | - catch (SyncObjectBrokenException $mbe) { |
|
112 | + } catch (SyncObjectBrokenException $mbe) { |
|
114 | 113 | $brokenSO = $mbe->GetSyncObject(); |
115 | 114 | if (!$brokenSO) { |
116 | 115 | ZLog::Write(LOGLEVEL_ERROR, sprintf("PHPWrapper->ImportMessageChange(): Caught SyncObjectBrokenException but broken SyncObject available")); |
117 | - } |
|
118 | - else { |
|
116 | + } else { |
|
119 | 117 | if (!isset($brokenSO->id)) { |
120 | 118 | $brokenSO->id = "Unknown ID"; |
121 | 119 | ZLog::Write(LOGLEVEL_ERROR, sprintf("PHPWrapper->ImportMessageChange(): Caught SyncObjectBrokenException but no ID of object set")); |
@@ -128,8 +126,11 @@ discard block |
||
128 | 126 | |
129 | 127 | |
130 | 128 | // substitute the MAPI SYNC_NEW_MESSAGE flag by a grommunio-sync proprietary flag |
131 | - if ($flags == SYNC_NEW_MESSAGE) $message->flags = SYNC_NEWMESSAGE; |
|
132 | - else $message->flags = $flags; |
|
129 | + if ($flags == SYNC_NEW_MESSAGE) { |
|
130 | + $message->flags = SYNC_NEWMESSAGE; |
|
131 | + } else { |
|
132 | + $message->flags = $flags; |
|
133 | + } |
|
133 | 134 | |
134 | 135 | $this->importer->ImportMessageChange($this->prefix.bin2hex($sourcekey), $message); |
135 | 136 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageChange(): change for: '%s'", $this->prefix.bin2hex($sourcekey))); |
@@ -196,8 +197,9 @@ discard block |
||
196 | 197 | $folder = $this->mapiprovider->GetFolder($props); |
197 | 198 | |
198 | 199 | // do not import folder if there is something "wrong" with it |
199 | - if ($folder === false) |
|
200 | - return 0; |
|
200 | + if ($folder === false) { |
|
201 | + return 0; |
|
202 | + } |
|
201 | 203 | |
202 | 204 | $this->importer->ImportFolderChange($folder); |
203 | 205 | return 0; |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | |
375 | 375 | |
376 | 376 | /** |
377 | - * Returns the MAPI to AS mapping for email todo flags |
|
378 | - * |
|
379 | - * @return array |
|
380 | - */ |
|
377 | + * Returns the MAPI to AS mapping for email todo flags |
|
378 | + * |
|
379 | + * @return array |
|
380 | + */ |
|
381 | 381 | public static function GetMailFlagsMapping() { |
382 | 382 | return array ( |
383 | 383 | "flagstatus" => PR_FLAG_STATUS, |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | |
399 | 399 | |
400 | 400 | /** |
401 | - * Returns email todo flags' specific MAPI properties |
|
402 | - * |
|
403 | - * @access public |
|
404 | - * |
|
405 | - * @return array |
|
406 | - */ |
|
401 | + * Returns email todo flags' specific MAPI properties |
|
402 | + * |
|
403 | + * @access public |
|
404 | + * |
|
405 | + * @return array |
|
406 | + */ |
|
407 | 407 | public static function GetMailFlagsProperties() { |
408 | 408 | return array( |
409 | 409 | "todoitemsflags" => PR_TODO_ITEM_FLAGS, |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | |
420 | 420 | |
421 | 421 | /** |
422 | - * Returns the MAPI to AS mapping for notes |
|
423 | - * |
|
424 | - * @access public |
|
425 | - * |
|
426 | - * @return array |
|
427 | - */ |
|
422 | + * Returns the MAPI to AS mapping for notes |
|
423 | + * |
|
424 | + * @access public |
|
425 | + * |
|
426 | + * @return array |
|
427 | + */ |
|
428 | 428 | public static function GetNoteMapping() { |
429 | 429 | return array( |
430 | 430 | "categories" => "PT_MV_STRING8:PS_PUBLIC_STRINGS:Keywords", |
@@ -438,12 +438,12 @@ discard block |
||
438 | 438 | |
439 | 439 | |
440 | 440 | /** |
441 | - * Returns note specific MAPI properties |
|
442 | - * |
|
443 | - * @access public |
|
444 | - * |
|
445 | - * @return array |
|
446 | - */ |
|
441 | + * Returns note specific MAPI properties |
|
442 | + * |
|
443 | + * @access public |
|
444 | + * |
|
445 | + * @return array |
|
446 | + */ |
|
447 | 447 | public static function GetNoteProperties() { |
448 | 448 | return array( |
449 | 449 | "body" => PR_BODY, |
@@ -456,12 +456,12 @@ discard block |
||
456 | 456 | |
457 | 457 | |
458 | 458 | /** |
459 | - * Returns properties for sending an email |
|
460 | - * |
|
461 | - * @access public |
|
462 | - * |
|
463 | - * @return array |
|
464 | - */ |
|
459 | + * Returns properties for sending an email |
|
460 | + * |
|
461 | + * @access public |
|
462 | + * |
|
463 | + * @return array |
|
464 | + */ |
|
465 | 465 | public static function GetSendMailProperties() { |
466 | 466 | return array( |
467 | 467 | "outboxentryid" => PR_IPM_OUTBOX_ENTRYID, |
@@ -17,7 +17,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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", |