Completed
Push — master ( 3e1f76...0e9327 )
by Klaus
234:48 queued 208:11
created
mail/inc/class.mail_zpush.inc.php 2 patches
Spacing   +343 added lines, -344 removed lines patch added patch discarded remove patch
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
 		$this->backend = $backend;
91 91
 		if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
92 92
 		{
93
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
93
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
94 94
 			// globals preferences add appname varname value
95
-			$GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user');
95
+			$GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user');
96 96
 			// save prefs
97 97
 			$GLOBALS['egw']->preferences->save_repository(true);
98 98
 		}
99
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
99
+		if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
100 100
 
101 101
 		if (is_null(self::$profileID))
102 102
 		{
103
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
104
-			self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID');
105
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
103
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
104
+			self::$profileID = & Api\Cache::getSession('mail', 'activeSyncProfileID');
105
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
106 106
 		}
107 107
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
108 108
 		{
109
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
109
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
110 110
 			if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G')
111 111
 			{
112 112
 				self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is)
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'];
117 117
 			}
118 118
 		}
119
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
119
+		if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
120 120
 
121 121
 		// verify we are on an existing profile, if not running in setup (settings can not be static according to interface!)
122 122
 		if (!isset($GLOBALS['egw_setup']))
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 			try {
125 125
 				Mail\Account::read(self::$profileID);
126 126
 			}
127
-			catch(Exception $e) {
127
+			catch (Exception $e) {
128 128
 				unset($e);
129 129
 				self::$profileID = Mail\Account::get_default_acc_id();
130 130
 			}
131 131
 		}
132
-		if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
132
+		if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
133 133
 		//$this->debugLevel=0;
134 134
 	}
135 135
 
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 			$this->__construct($this->backend);
243 243
 
244 244
 			try {
245
-				$this->_connect(0,true);
245
+				$this->_connect(0, true);
246 246
 				$this->_disconnect();
247 247
 
248 248
 				if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>');
249 249
 				if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>');
250 250
 			}
251
-			catch(Exception $e) {
251
+			catch (Exception $e) {
252 252
 				$errors[] = lang('Can not open IMAP connection').': '.$e->getMessage();
253 253
 			}
254 254
 			if ($errors)
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param int $account integer id of account to use
267 267
 	 * @todo support different accounts
268 268
 	 */
269
-	private function _connect($account=0)
269
+	private function _connect($account = 0)
270 270
 	{
271 271
 		if (!$account) $account = self::$profileID ? self::$profileID : 0;
272 272
 		if ($this->mail && $this->account != $account) $this->_disconnect();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			$this->account = $account;
280 280
 			// todo: tell mail which account to use
281 281
 			//error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID));
282
-			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
282
+			$this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
283 283
 			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
284 284
 		}
285 285
 		else
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 			//error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID);
288 288
 			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
289 289
 		}
290
-		$this->mail->openConnection(self::$profileID,false);
290
+		$this->mail->openConnection(self::$profileID, false);
291 291
 
292 292
 		$this->_wasteID = $this->mail->getTrashFolder(false);
293 293
 		//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 */
303 303
 	private function _disconnect()
304 304
 	{
305
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__);
305
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__);
306 306
 		if ($this->mail) $this->mail->closeConnection();
307 307
 
308 308
 		unset($this->mail);
@@ -318,24 +318,24 @@  discard block
 block discarded – undo
318 318
 	public function GetFolderList()
319 319
 	{
320 320
 		$folderlist = array();
321
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
321
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__);
322 322
 		/*foreach($available_accounts as $account)*/ $account = 0;
323 323
 		{
324 324
 			$this->_connect($account);
325
-			if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true);
326
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders));
325
+			if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true);
326
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders));
327 327
 
328 328
 			foreach ($this->folders as $folder => $folderObj) {
329
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder);
329
+				if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder);
330 330
 				$folderlist[] = $f = array(
331
-					'id'     => $this->createID($account,$folder),
331
+					'id'     => $this->createID($account, $folder),
332 332
 					'mod'    => $folderObj->shortDisplayName,
333
-					'parent' => $this->getParentID($account,$folder),
333
+					'parent' => $this->getParentID($account, $folder),
334 334
 				);
335
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f));
335
+				if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f));
336 336
 			}
337 337
 		}
338
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist));
338
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist));
339 339
 
340 340
 		return $folderlist;
341 341
 	}
@@ -384,58 +384,58 @@  discard block
 block discarded – undo
384 384
 		$ClientSideMeetingRequest = false;
385 385
 		$allowSendingInvitations = 'sendifnocalnotif';
386 386
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
387
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend')
387
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend')
388 388
 		{
389 389
 			$allowSendingInvitations = false;
390 390
 		}
391 391
 		elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
392
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend')
392
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend')
393 393
 		{
394 394
 			$allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'];
395 395
 		}
396
-		$smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new'));
396
+		$smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new'));
397 397
 
398
-   		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : ""));
399
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
398
+   		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.(isset($smartdata->mime) ? $smartdata->mime : "")."task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : ""));
399
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
400 400
 		//error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata));
401 401
 
402 402
 		// initialize our Mail
403
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
403
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
404 404
 		$activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID);
405 405
 		// use the standardIdentity
406
-		$activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID);
406
+		$activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID);
407 407
 
408
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile));
408
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile));
409 409
 
410 410
 		// initialize the new Api\Mailer object for sending
411 411
 		$mailObject = new Api\Mailer(self::$profileID);
412
-		$this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime);
412
+		$this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime);
413 413
 		// Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8
414
-		$mailObject->Sender  = $activeMailProfile['ident_email'];
415
-		$mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false));
414
+		$mailObject->Sender = $activeMailProfile['ident_email'];
415
+		$mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false));
416 416
 		$mailObject->addHeader('X-Mailer', 'mail-Activesync');
417 417
 
418 418
 
419 419
 		// prepare addressee list; moved the adding of addresses to the mailobject down
420 420
 		// to
421 421
 
422
-		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
422
+		foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
423 423
 			if (!$addressObject->valid) continue;
424
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) );
424
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject));
425 425
 			//$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
426 426
 			$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
427 427
 		}
428 428
 		// CC
429
-		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
429
+		foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
430 430
 			if (!$addressObject->valid) continue;
431
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) );
431
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject));
432 432
 			//$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
433 433
 			$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
434 434
 		}
435 435
 		// BCC
436
-		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
436
+		foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
437 437
 			if (!$addressObject->valid) continue;
438
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) );
438
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject));
439 439
 			//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
440 440
 			$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
441 441
 		}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		$use_orgbody = false;
445 445
 
446 446
 		$k = 'Content-Type';
447
-		$ContentType =$mailObject->getHeader('Content-Type');
447
+		$ContentType = $mailObject->getHeader('Content-Type');
448 448
 		//error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k.  " = ".trim($ContentType));
449 449
 		// if the message is a multipart message, then we should use the sent body
450 450
 		if (preg_match("/multipart/i", $ContentType)) {
@@ -464,43 +464,43 @@  discard block
 block discarded – undo
464 464
 			$k == "Content-Type" && preg_match("/multipart/i", $ContentType))) {
465 465
 			$use_orgbody = true;
466 466
 		}
467
-		$Body =  $AltBody = "";
467
+		$Body = $AltBody = "";
468 468
 		// get body of the transmitted message
469 469
 		// if this is a simple message, no structure at all
470 470
 		if (preg_match("/text/i", $ContentType))
471 471
 		{
472
-			$simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain');
472
+			$simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain');
473 473
 			$bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain');
474
-			$body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null);
475
-			if  ($simpleBodyType == "text/plain")
474
+			$body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null);
475
+			if ($simpleBodyType == "text/plain")
476 476
 			{
477 477
 				$Body = $body;
478 478
 				$AltBody = "<pre>".nl2br($body)."</pre>";
479
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody');
479
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody');
480 480
 			}
481 481
 			else
482 482
 			{
483 483
 				$AltBody = $body;
484
-				$Body =  trim(Api\Mail\Html::convertHTMLToText($body));
485
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body');
484
+				$Body = trim(Api\Mail\Html::convertHTMLToText($body));
485
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body');
486 486
 			}
487 487
 		}
488 488
 		else
489 489
 		{
490 490
 			// if this is a structured message
491 491
 			// prefer plain over html
492
-			$Body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
492
+			$Body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]",
493 493
 				($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null);
494
-			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
494
+			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]",
495 495
 				($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null);
496 496
 		}
497
-		if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
498
-		if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
497
+		if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body);
498
+		if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody);
499 499
 		//error_log(__METHOD__.__LINE__.array2string($mailObject));
500 500
 		// if this is a multipart message with a boundary, we must use the original body
501 501
 		//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject));
502 502
         if ($use_orgbody) {
503
-    	    ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
503
+    	    ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
504 504
  			// if it is a ClientSideMeetingRequest, we report it as send at all times
505 505
 			if (($cal_body = $mailObject->findBody('calendar')) &&
506 506
 				($cSMRMethod = $cal_body->getContentTypeParameter('method')))
@@ -509,21 +509,21 @@  discard block
 block discarded – undo
509 509
 				{
510 510
 					$organizer = calendar_ical::getIcalOrganizer($cal_body->getContents());
511 511
 				}
512
-				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
512
+				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
513 513
 				$ClientSideMeetingRequest = true;
514 514
 			}
515 515
         }
516 516
 		// now handle the addressee list
517 517
 		$toCount = 0;
518 518
 		//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
519
-		foreach((array)$toMailAddr as $address) {
520
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
521
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
519
+		foreach ((array)$toMailAddr as $address) {
520
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
521
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
522 522
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' &&
523 523
 					calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST',
524 524
 						$organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : ''))
525 525
 				{
526
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app");
526
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app");
527 527
 					continue;
528 528
 				}
529 529
 				$mailObject->AddAddress($emailAddress, $addressObject->personal);
@@ -531,29 +531,29 @@  discard block
 block discarded – undo
531 531
 			}
532 532
 		}
533 533
 		$ccCount = 0;
534
-		foreach((array)$ccMailAddr as $address) {
535
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
536
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
534
+		foreach ((array)$ccMailAddr as $address) {
535
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
536
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
537 537
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
538 538
 				$mailObject->AddCC($emailAddress, $addressObject->personal);
539 539
 				$ccCount++;
540 540
 			}
541 541
 		}
542 542
 		$bccCount = 0;
543
-		foreach((array)$bccMailAddr as $address) {
544
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
545
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
543
+		foreach ((array)$bccMailAddr as $address) {
544
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
545
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
546 546
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
547 547
 				$mailObject->AddBCC($emailAddress, $addressObject->personal);
548 548
 				$bccCount++;
549 549
 			}
550 550
 		}
551 551
 		// typical organizer reply will end here with nothing send --> return true, because we suppressed the send above
552
-		if ($toCount+$ccCount+$bccCount == 0)
552
+		if ($toCount + $ccCount + $bccCount == 0)
553 553
 		{
554 554
 			return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to
555 555
 		}
556
-		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true;
556
+		if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true;
557 557
 		// as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail
558 558
 /*
559 559
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body);
@@ -561,29 +561,29 @@  discard block
 block discarded – undo
561 561
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body (modified):'.$body);
562 562
 */
563 563
 		// add signature!! -----------------------------------------------------------------
564
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile));
564
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile));
565 565
 		try
566 566
 		{
567 567
 			$acc = Mail\Account::read($this->mail->icServer->ImapServerId);
568 568
 			//error_log(__METHOD__.__LINE__.array2string($acc));
569
-			$_signature = Mail\Account::read_identity($acc['ident_id'],true);
569
+			$_signature = Mail\Account::read_identity($acc['ident_id'], true);
570 570
 		}
571 571
 		catch (Exception $e)
572 572
 		{
573
-			$_signature=array();
573
+			$_signature = array();
574 574
 		}
575 575
 		$signature = $_signature['ident_signature'];
576 576
 		if ((isset($preferencesArray['disableRulerForSignatureSeparation']) &&
577 577
 			$preferencesArray['disableRulerForSignatureSeparation']) ||
578
-			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='')
578
+			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '')
579 579
 		{
580 580
 			$disableRuler = true;
581 581
 		}
582 582
 		$beforePlain = $beforeHtml = "";
583
-		$beforeHtml = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
584
-		$beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
585
-		$sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
586
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
583
+		$beforeHtml = ($disableRuler ? '&nbsp;<br>' : '&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
584
+		$beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
585
+		$sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
586
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText);
587 587
 		$sigTextHtml = $beforeHtml.$sigText;
588 588
 		$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText);
589 589
 		$isreply = $isforward = false;
@@ -595,26 +595,26 @@  discard block
 block discarded – undo
595 595
 		{
596 596
 			// now get on, and fetch the original mail
597 597
 			$uid = $smartdata->source->itemid;
598
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
598
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
599 599
 			$this->splitID($smartdata->source->folderid, $account, $folder);
600 600
 
601 601
 			$this->mail->reopen($folder);
602 602
 			$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
603
-			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
604
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
605
-		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
603
+			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
604
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
605
+		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
606 606
 				// may be html
607
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
607
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
608 608
 				$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
609 609
 				$isreply = true;
610 610
 			}
611 611
 			// plain text Message part
612
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
612
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
613 613
 			// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
614
-			$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
615
-			$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
616
-			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
617
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
614
+			$bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display');
615
+			$bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
616
+			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) {
617
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
618 618
 				$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
619 619
 				$isreply = true;
620 620
 			}
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 			{
623 623
 				$isreply = true;
624 624
 				$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
625
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
625
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
626 626
 			}
627 627
 		}
628 628
 
629 629
 		// how to forward and other prefs
630
-		$preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail'];
630
+		$preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail'];
631 631
 
632 632
 		// forward -------------------------------------------------------------------------
633 633
 		if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) &&
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 		{
638 638
 			//force the default for the forwarding -> asmail
639 639
 			if (is_array($preferencesArray)) {
640
-				if (!array_key_exists('message_forwarding',$preferencesArray)
640
+				if (!array_key_exists('message_forwarding', $preferencesArray)
641 641
 					|| !isset($preferencesArray['message_forwarding'])
642 642
 					|| empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail';
643 643
 			} else {
@@ -645,18 +645,18 @@  discard block
 block discarded – undo
645 645
 			}
646 646
 			// construct the uid of the message out of the itemid - seems to be the uid, no construction needed
647 647
 			$uid = $smartdata->source->itemid;
648
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
648
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
649 649
 			$this->splitID($smartdata->source->folderid, $account, $folder);
650 650
 
651 651
 			$this->mail->reopen($folder);
652 652
             // receive entire mail (header + body)
653 653
 			// get message headers for specified message
654
-			$headers	= $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
654
+			$headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
655 655
 			// build a new mime message, forward entire old mail as file
656 656
 			if ($preferencesArray['message_forwarding'] == 'asmail')
657 657
 			{
658
-				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder);
659
-				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder);
658
+				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder);
659
+				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder);
660 660
 				$mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822');
661 661
 				$AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml;
662 662
 				$Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain;
@@ -666,50 +666,50 @@  discard block
 block discarded – undo
666 666
 			{
667 667
 				// now get on, and fetch the original mail
668 668
 				$uid = $smartdata->source->itemid;
669
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
669
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
670 670
 				$this->splitID($smartdata->source->folderid, $account, $folder);
671 671
 
672 672
 				$this->mail->reopen($folder);
673 673
 				$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
674
-				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
675
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
676
-				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
674
+				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
675
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
676
+				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
677 677
 					// may be html
678
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
678
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
679 679
 					$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
680 680
 					$isforward = true;
681 681
 				}
682 682
 				// plain text Message part
683
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
683
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
684 684
 				// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
685
-				$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
686
-				$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
687
-				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
688
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
685
+				$bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display');
686
+				$bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
687
+				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) {
688
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
689 689
 					$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
690 690
 					$isforward = true;
691 691
 				}
692 692
 				if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody))
693 693
 				{
694 694
 					$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
695
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
695
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
696 696
 					$isforward = true;
697 697
 				}
698 698
 				// get all the attachments and add them too.
699 699
 				// start handle Attachments
700 700
 				//												$_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName=''
701
-				$attachments = $this->mail->getMessageAttachments($uid, null,          null,								true,						false,				 true			, $folder);
701
+				$attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder);
702 702
 				$attachmentNames = false;
703
-				if (is_array($attachments) && count($attachments)>0)
703
+				if (is_array($attachments) && count($attachments) > 0)
704 704
 				{
705
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
706
-					foreach((array)$attachments as $key => $attachment)
705
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
706
+					foreach ((array)$attachments as $key => $attachment)
707 707
 					{
708
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
708
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
709 709
 						$attachmentNames .= $attachment['name']."\n";
710
-						$attachmentData	= $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder);
710
+						$attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder);
711 711
 						/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']);
712
-						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x);
712
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x);
713 713
 					}
714 714
 				}
715 715
 			}
@@ -723,36 +723,36 @@  discard block
 block discarded – undo
723 723
 		// now set the body
724 724
 		if ($AltBody && ($html_body = $mailObject->findBody('html')))
725 725
 		{
726
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
727
-			$html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
726
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody);
727
+			$html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
728 728
 		}
729 729
 		if ($Body && ($text_body = $mailObject->findBody('plain')))
730 730
 		{
731
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
732
-			$text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
731
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body);
732
+			$text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
733 733
 		}
734 734
 		//advanced debugging
735 735
 		// Horde SMTP Class uses utf-8 by default.
736 736
         //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
737
-		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
737
+		if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
738 738
 
739 739
 		// set a higher timeout for big messages
740 740
 		@set_time_limit(120);
741
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....');
741
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....');
742 742
 		// send
743 743
 		$send = true;
744 744
 		try {
745 745
 			$mailObject->Send();
746 746
 		}
747
-		catch(Exception $e) {
748
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage());
747
+		catch (Exception $e) {
748
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage());
749 749
 			$send = false;
750 750
 		}
751 751
 
752
-		if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true)
752
+		if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true)
753 753
 		{
754 754
 			$uid = $smartdata->source->itemid;
755
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
755
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
756 756
 			$this->splitID($smartdata->source->folderid, $account, $folder);
757 757
 			//error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid);
758 758
 			$this->mail->reopen($folder);
@@ -760,89 +760,89 @@  discard block
 block discarded – undo
760 760
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
761 761
 			if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder))
762 762
 			{
763
-				$this->mail->deleteMessages(array($uid),$folder);
763
+				$this->mail->deleteMessages(array($uid), $folder);
764 764
 			} else {
765
-				$this->mail->flagMessages("answered", array($uid),$folder);
766
-				if ($smartdata_task== "forward")
765
+				$this->mail->flagMessages("answered", array($uid), $folder);
766
+				if ($smartdata_task == "forward")
767 767
 				{
768
-					$this->mail->flagMessages("forwarded", array($uid),$folder);
768
+					$this->mail->flagMessages("forwarded", array($uid), $folder);
769 769
 				}
770 770
 			}
771 771
 		}
772 772
 
773
-		$asf = ($send ? true:false); // initalize accordingly
774
-		if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */  $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only')
773
+		$asf = ($send ? true : false); // initalize accordingly
774
+		if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */  $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only')
775 775
 		{
776 776
 			$asf = false;
777 777
 			$sentFolder = $this->mail->getSentFolder();
778 778
 			if ($this->_sentID) {
779 779
 				$folderArray[] = $this->_sentID;
780 780
 			}
781
-			else if(isset($sentFolder) && $sentFolder != 'none')
781
+			else if (isset($sentFolder) && $sentFolder != 'none')
782 782
 			{
783 783
 				$folderArray[] = $sentFolder;
784 784
 			}
785 785
 			// No Sent folder set, try defaults
786 786
 			else
787 787
 			{
788
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set");
788
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set");
789 789
 				// we dont try guessing
790 790
 				$asf = true;
791 791
 			}
792 792
 			if (count($folderArray) > 0) {
793
-				foreach((array)$bccMailAddr as $address) {
794
-					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
795
-						$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
793
+				foreach ((array)$bccMailAddr as $address) {
794
+					foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
795
+						$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
796 796
 						$mailAddr[] = array($emailAddress, $addressObject->personal);
797 797
 					}
798 798
 				}
799
-				$BCCmail='';
800
-				if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
801
-				foreach($folderArray as $folderName) {
802
-					if($this->mail->isSentFolder($folderName)) {
799
+				$BCCmail = '';
800
+				if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr);
801
+				foreach ($folderArray as $folderName) {
802
+					if ($this->mail->isSentFolder($folderName)) {
803 803
 						$flags = '\\Seen';
804
-					} elseif($this->mail->isDraftFolder($folderName)) {
804
+					} elseif ($this->mail->isDraftFolder($folderName)) {
805 805
 						$flags = '\\Draft';
806 806
 					} else {
807 807
 						$flags = '';
808 808
 					}
809 809
 					$asf = true;
810 810
 					//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer));
811
-					$this->mail->openConnection(self::$profileID,false);
811
+					$this->mail->openConnection(self::$profileID, false);
812 812
 					if ($this->mail->folderExists($folderName)) {
813 813
 						try
814 814
 						{
815
-							$this->mail->appendMessage($folderName,$mailObject->getRaw(), null,
815
+							$this->mail->appendMessage($folderName, $mailObject->getRaw(), null,
816 816
 									$flags);
817 817
 						}
818 818
 						catch (Api\Exception\WrongUserinput $e)
819 819
 						{
820 820
 							//$asf = false;
821
-							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage()));
821
+							ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage()));
822 822
 						}
823 823
 					}
824 824
 					else
825 825
 					{
826 826
 						//$asf = false;
827
-						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName));
827
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName));
828 828
 					}
829
-			        ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed"));
829
+			        ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed"));
830 830
 				}
831 831
 				//$this->mail->closeConnection();
832 832
 			}
833 833
 		}
834 834
 
835
-		$this->debugLevel=0;
835
+		$this->debugLevel = 0;
836 836
 
837 837
 		if ($send && $asf)
838 838
 		{
839
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully');
839
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully');
840 840
 			return true;
841 841
 		}
842 842
 		else
843 843
 		{
844
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":""));
845
-			return ($ClientSideMeetingRequest ? true : 120);   //MAIL Submission failed, see MS-ASCMD
844
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : ""));
845
+			return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD
846 846
 		}
847 847
 	}
848 848
 
@@ -860,43 +860,43 @@  discard block
 block discarded – undo
860 860
 	public function GetMessage($folderid, $id, $contentparameters)
861 861
 	{
862 862
 		//$this->debugLevel=4;
863
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters));
863
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters));
864 864
 		$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
865 865
 		$mimesupport = $contentparameters->GetMimeSupport();
866
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport));
866
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport));
867 867
 		$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */
868 868
 
869 869
 		// fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0
870 870
 		if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]);
871 871
 
872 872
 		//$this->debugLevel=4;
873
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
874
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
873
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
874
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
875 875
 		$account = $_folderName = $xid = null;
876
-		$this->splitID($folderid,$account,$_folderName,$xid);
876
+		$this->splitID($folderid, $account, $_folderName, $xid);
877 877
 		$this->mail->reopen($_folderName);
878
-		$messages = $this->fetchMessages($folderid, NULL, $id, true);	// true: return all headers
878
+		$messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers
879 879
 		$headers = $messages[$id];
880
-		if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
880
+		if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers));
881 881
 		// StatMessage should reopen the folder in question, so we dont need folderids in the following statements.
882 882
 		if ($headers)
883 883
 		{
884
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers));
884
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers));
885 885
 			// initialize the object
886 886
 			$output = new SyncMail();
887 887
 			//$rawHeaders = $this->mail->getMessageRawHeader($id);
888 888
 			// simple style
889 889
 			// start AS12 Stuff (bodypreference === false) case = old behaviour
890
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
890
+			if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers));
891 891
 
892 892
 			if ($bodypreference === false) {
893
-				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
894
-				$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
893
+				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName);
894
+				$raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
895 895
 				//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
896
-				if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
896
+				if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
897 897
 				// remove all other html
898 898
 				$body = strip_tags($raw_body);
899
-				if(strlen($body) > $truncsize) {
899
+				if (strlen($body) > $truncsize) {
900 900
 					$body = Utils::Utf8_truncate($body, $truncsize);
901 901
 					$output->bodytruncated = 1;
902 902
 				}
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			else // style with bodypreferences
911 911
 			{
912 912
 				//Select body type preference
913
-				$bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN;
913
+				$bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN;
914 914
 				if ($bodypreference !== false) {
915 915
 					// bodypreference can occur multiple times
916 916
 					// usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference);
@@ -924,12 +924,12 @@  discard block
 block discarded – undo
924 924
 					}
925 925
 */
926 926
 				}
927
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType));
927
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType));
928 928
 				// set the protocoll class
929 929
 				$output->asbody = new SyncBaseBody();
930 930
 
931 931
 				// return full mime-message without any (charset) conversation directly as stream
932
-				if ($bpReturnType==SYNC_BODYPREFERENCE_MIME)
932
+				if ($bpReturnType == SYNC_BODYPREFERENCE_MIME)
933 933
 				{
934 934
 					//SYNC_BODYPREFERENCE_MIME
935 935
 					$output->asbody->type = SYNC_BODYPREFERENCE_MIME;
@@ -938,58 +938,58 @@  discard block
 block discarded – undo
938 938
 					fseek($stream, 0, SEEK_SET);
939 939
 					$output->asbody->data = $stream;
940 940
 					$output->asbody->estimatedDataSize = $fstat['size'];
941
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]");
941
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]");
942 942
 				}
943 943
 				else
944 944
 				{
945 945
 					// fetch the body (try to gather data only once)
946
-					$css ='';
947
-					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
948
-					if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
949
-					$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
950
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
951
-					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
946
+					$css = '';
947
+					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName);
948
+					if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
949
+					$body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
950
+					if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body);
951
+					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
952 952
 						// may be html
953
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
953
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
954 954
 						$css = $this->mail->getStyles($bodyStruct);
955
-						$output->nativebodytype=2;
955
+						$output->nativebodytype = 2;
956 956
 					} else {
957 957
 						// plain text Message
958
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
959
-						$output->nativebodytype=1;
960
-						$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
961
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
962
-						$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
963
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
958
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
959
+						$output->nativebodytype = 1;
960
+						$bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text');
961
+						if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
962
+						$body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
963
+						if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body);
964 964
 					}
965 965
 					// whatever format decode (using the correct encoding)
966
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
966
+					if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body);
967 967
 					//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
968 968
 					// prepare plaintextbody
969
-					$plainBody='';
969
+					$plainBody = '';
970 970
 					if ($output->nativebodytype == 2)
971 971
 					{
972
-						$bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
973
-						if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1)
972
+						$bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text');
973
+						if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1)
974 974
 						{
975 975
 							$plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML
976 976
 						}
977 977
 						else
978 978
 						{
979
-							$plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false);
979
+							$plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false);
980 980
 						}
981 981
 					}
982 982
 					//if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body);
983
-					$plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body));
983
+					$plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body));
984 984
 					// remove all other html
985
-					$plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody);
985
+					$plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody);
986 986
 					$plainBody = strip_tags($plainBody);
987
-					if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
987
+					if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody);
988 988
 					//$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that?
989 989
 
990
-					if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML
990
+					if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML
991 991
 					{
992
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
992
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
993 993
 						// Send HTML if requested and native type was html
994 994
 						$output->asbody->type = 2;
995 995
 						$htmlbody = '<html>'.
@@ -999,23 +999,23 @@  discard block
 block discarded – undo
999 999
 							$css.
1000 1000
 							'</head>'.
1001 1001
 							'<body>';
1002
-						if ($output->nativebodytype==2)
1002
+						if ($output->nativebodytype == 2)
1003 1003
 						{
1004
-							if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style');
1004
+							if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style');
1005 1005
 							// as we fetch html, and body is HTML, we may not need to handle this
1006 1006
 							$htmlbody .= $body;
1007 1007
 						}
1008 1008
 						else
1009 1009
 						{
1010 1010
 							// html requested but got only plaintext, so fake html
1011
-							$htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody)));
1011
+							$htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody)));
1012 1012
 						}
1013 1013
 						$htmlbody .= '</body>'.
1014 1014
 								'</html>';
1015 1015
 
1016
-						if(isset($truncsize) && strlen($htmlbody) > $truncsize)
1016
+						if (isset($truncsize) && strlen($htmlbody) > $truncsize)
1017 1017
 						{
1018
-							$htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize);
1018
+							$htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize);
1019 1019
 							$output->asbody->truncated = 1;
1020 1020
 						}
1021 1021
 						// output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested.
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 					else
1027 1027
 					{
1028 1028
 						// Send Plaintext as Fallback or if original body is plainttext
1029
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1029
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1030 1030
 						/* we use plainBody (set above) instead
1031 1031
 						$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
1032 1032
 						$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 						*/
1037 1037
 						$output->asbody->type = 1;
1038 1038
 						$output->nativebodytype = 1;
1039
-						if(isset($truncsize) &&
1039
+						if (isset($truncsize) &&
1040 1040
 							strlen($plainBody) > $truncsize)
1041 1041
 						{
1042 1042
 							$plainBody = Utils::Utf8_truncate($plainBody, $truncsize);
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 				}
1056 1056
 			}
1057 1057
 			// end AS12 Stuff
1058
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']);
1058
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']);
1059 1059
 			$output->read = $headers["flags"];
1060 1060
 
1061 1061
 			$output->flag = new SyncMailFlags();
@@ -1075,9 +1075,8 @@  discard block
 block discarded – undo
1075 1075
 				$output->lastverexecuted = AS_FORWARD;
1076 1076
 			}
1077 1077
 			$output->subject = $headers['subject'];
1078
-			$output->importance = $headers['priority'] > 3 ? 0 :
1079
-				($headers['priority'] < 3 ? 2 : 1) ;
1080
-			$output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true);
1078
+			$output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1);
1079
+			$output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true);
1081 1080
 			$output->to = $headers['to_address'];
1082 1081
 			if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name']
1083 1082
 			$output->from = $headers['sender_address'];
@@ -1085,8 +1084,8 @@  discard block
 block discarded – undo
1085 1084
 			if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address'];
1086 1085
 
1087 1086
 			$output->messageclass = "IPM.Note";
1088
-			if (stripos($headers['mimetype'],'multipart')!== false &&
1089
-				stripos($headers['mimetype'],'signed')!== false)
1087
+			if (stripos($headers['mimetype'], 'multipart') !== false &&
1088
+				stripos($headers['mimetype'], 'signed') !== false)
1090 1089
 			{
1091 1090
 				$output->messageclass = "IPM.Note.SMIME.MultipartSigned";
1092 1091
 			}
@@ -1095,20 +1094,20 @@  discard block
 block discarded – undo
1095 1094
 			}
1096 1095
 
1097 1096
 			// start handle Attachments (include text/calendar multipart alternative)
1098
-			$attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName);
1097
+			$attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName);
1099 1098
 			// Attachments should not needed for MIME messages, so skip this part if bpReturnType==4
1100
-			if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0)
1099
+			if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0)
1101 1100
 			{
1102
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments));
1101
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments));
1103 1102
 				//error_log(__METHOD__.__LINE__.array2string($attachments));
1104 1103
 				foreach ($attachments as $key => $attach)
1105 1104
 				{
1106
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1105
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1107 1106
 
1108 1107
 					// pass meeting requests to calendar plugin
1109 1108
 					if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
1110 1109
 						isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
1111
-						($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) &&
1110
+						($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) &&
1112 1111
 						($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment'])))
1113 1112
 					{
1114 1113
 						//overwrite the globalobjId from calendar object, as: if you delete the mail, that is
@@ -1118,7 +1117,7 @@  discard block
 block discarded – undo
1118 1117
 						$output->messageclass = "IPM.Schedule.Meeting.Request";
1119 1118
 						//$output->messageclass = "IPM.Schedule.Meeting";
1120 1119
 						unset($attachment);
1121
-						continue;	// do NOT add attachment as attachment
1120
+						continue; // do NOT add attachment as attachment
1122 1121
 					}
1123 1122
 					if (Request::GetProtocolVersion() >= 12.0) {
1124 1123
 						$attachment = new SyncBaseAttachment();
@@ -1126,33 +1125,33 @@  discard block
 block discarded – undo
1126 1125
 							$output->asattachments = array();
1127 1126
 						$attachment->estimatedDataSize = $attach['size'];
1128 1127
 						$attachment->method = 1;
1129
-						$attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID'];
1128
+						$attachment->filereference = $folderid.":".$id.":".$attach['partID'];
1130 1129
 					} else {
1131 1130
 						$attachment = new SyncAttachment();
1132 1131
 						if (!isset($output->attachments) || !is_array($output->attachments))
1133 1132
 							$output->attachments = array();
1134 1133
 						$attachment->attsize = $attach['size'];
1135 1134
 						$attachment->attmethod = 1;
1136
-						$attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key;
1135
+						$attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key;
1137 1136
 					}
1138 1137
 
1139 1138
 					$attachment->displayname = $attach['name'];
1140 1139
 					//error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']);
1141 1140
 
1142
-					$attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : "";
1141
+					$attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : "";
1143 1142
 					//$attachment->isinline=0; // if not inline, do not use isinline
1144
-					if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' )
1143
+					if (!empty($attach['cid']) && $attach['cid'] <> 'NIL')
1145 1144
 					{
1146 1145
 						if ($bpReturnType != 4 && $attach['disposition'] == 'inline')
1147 1146
 						{
1148 1147
 							$attachment->isinline = true;
1149 1148
 						}
1150 1149
 						if (Request::GetProtocolVersion() >= 12.0) {
1151
-							$attachment->method=1;
1152
-							$attachment->contentid= str_replace(array("<",">"), "",$attach['cid']);
1150
+							$attachment->method = 1;
1151
+							$attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']);
1153 1152
 						} else {
1154
-							$attachment->attmethod=6;
1155
-							$attachment->attoid = str_replace(array("<",">"), "",$attach['cid']);
1153
+							$attachment->attmethod = 6;
1154
+							$attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']);
1156 1155
 						}
1157 1156
 						//	ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."'  ".$attachment->contentid);
1158 1157
 						$attachment->contenttype = trim($attach['mimeType']);
@@ -1173,7 +1172,7 @@  discard block
 block discarded – undo
1173 1172
             // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1174 1173
             $output->internetcpid = INTERNET_CPID_UTF8;
1175 1174
 
1176
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1175
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output));
1177 1176
 //$this->debugLevel=0;
1178 1177
 			return $output;
1179 1178
 		}
@@ -1196,30 +1195,30 @@  discard block
 block discarded – undo
1196 1195
 	{
1197 1196
 		if (!class_exists('calendar_zpush'))
1198 1197
 		{
1199
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!");
1198
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!");
1200 1199
 			return null;
1201 1200
 		}
1202 1201
 		if (!($stat = $this->StatMessage($folderid, $requestid)))
1203 1202
 		{
1204
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)");
1203
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)");
1205 1204
 			return false;
1206 1205
 		}
1207 1206
 		$ret = false;
1208
-		foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach)
1207
+		foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach)
1209 1208
 		{
1210 1209
 			if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
1211
-				($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false)))
1210
+				($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false)))
1212 1211
 			{
1213
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')");
1212
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')");
1214 1213
 
1215 1214
 				// calling backend again with iCal attachment, to let calendar add the event
1216 1215
 				$ret = $this->backend->MeetingResponse($attachment['attachment'],
1217
-					$this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']),
1216
+					$this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']),
1218 1217
 					$response);
1219 1218
 				break;
1220 1219
 			}
1221 1220
 		}
1222
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret));
1221
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret));
1223 1222
 		return $ret;
1224 1223
 	}
1225 1224
 
@@ -1233,9 +1232,9 @@  discard block
 block discarded – undo
1233 1232
      * @param string $attname - should contain (folder)id
1234 1233
 	 * @return SyncItemOperationsAttachment-object
1235 1234
 	 */
1236
-	function GetAttachmentData($fid,$attname) {
1237
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1238
-		return $this->_GetAttachmentData($fid,$attname);
1235
+	function GetAttachmentData($fid, $attname) {
1236
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')");
1237
+		return $this->_GetAttachmentData($fid, $attname);
1239 1238
 	}
1240 1239
 
1241 1240
 	/**
@@ -1248,9 +1247,9 @@  discard block
 block discarded – undo
1248 1247
      * @param string $attname - should contain (folder)id
1249 1248
 	 * @return SyncItemOperationsAttachment-object
1250 1249
 	 */
1251
-	function ItemOperationsGetAttachmentData($fid,$attname) {
1252
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1253
-		return $this->_GetAttachmentData($fid,$attname);
1250
+	function ItemOperationsGetAttachmentData($fid, $attname) {
1251
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')");
1252
+		return $this->_GetAttachmentData($fid, $attname);
1254 1253
 	}
1255 1254
 
1256 1255
 	/**
@@ -1262,23 +1261,23 @@  discard block
 block discarded – undo
1262 1261
      * @param string $attname - should contain (folder)id
1263 1262
 	 * @return SyncItemOperationsAttachment-object
1264 1263
 	 */
1265
-	private function _GetAttachmentData($fid,$attname)
1264
+	private function _GetAttachmentData($fid, $attname)
1266 1265
 	{
1267
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace());
1266
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace());
1268 1267
 		//error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')");
1269 1268
 		list($folderid, $id, $part) = explode(":", $attname);
1270 1269
 
1271 1270
 		$this->splitID($folderid, $account, $folder);
1272 1271
 
1273
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1272
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1274 1273
 
1275 1274
 		$this->mail->reopen($folder);
1276
-		$attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder);
1275
+		$attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder);
1277 1276
 		$SIOattachment = new SyncItemOperationsAttachment();
1278
-		fseek($attachment['attachment'], 0, SEEK_SET);	// z-push requires stream seeked to start
1277
+		fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start
1279 1278
 		$SIOattachment->data = $attachment['attachment'];
1280 1279
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']);
1281
-		if (isset($attachment['type']) )
1280
+		if (isset($attachment['type']))
1282 1281
 			$SIOattachment->contenttype = $attachment['type'];
1283 1282
 
1284 1283
 		unset($attachment);
@@ -1321,17 +1320,17 @@  discard block
 block discarded – undo
1321 1320
 	 */
1322 1321
 	function ChangeMessage($folderid, $id, $message, $contentParameters)
1323 1322
 	{
1324
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters));
1323
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters));
1325 1324
 		//unset($folderid, $id, $message, $contentParameters);
1326 1325
 		$account = $folder = null;
1327 1326
 		$this->splitID($folderid, $account, $folder);
1328 1327
 		if (isset($message->flag)) {
1329 1328
 			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) {
1330
-				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder);
1331
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1329
+				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder);
1330
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv);
1332 1331
 			} else {
1333
-				$rv = $this->mail->flagMessages("unflagged", $id,$folder);
1334
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv);
1332
+				$rv = $this->mail->flagMessages("unflagged", $id, $folder);
1333
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv);
1335 1334
 			}
1336 1335
 		}
1337 1336
 		return $this->StatMessage($folderid, $id);
@@ -1353,23 +1352,23 @@  discard block
 block discarded – undo
1353 1352
 	 */
1354 1353
 	public function MoveMessage($folderid, $id, $newfolderid, $contentParameters)
1355 1354
 	{
1356
-		unset($contentParameters);	// not used, but required by function signature
1355
+		unset($contentParameters); // not used, but required by function signature
1357 1356
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid'  id: '$id'  dfid: '$newfolderid' )");
1358 1357
 		$account = $srcFolder = $destFolder = null;
1359 1358
 		$this->splitID($folderid, $account, $srcFolder);
1360 1359
 		$this->splitID($newfolderid, $account, $destFolder);
1361 1360
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder'  id: '$id'  DestFolder: '$destFolder' )");
1362
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1361
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1363 1362
 		$this->mail->reopen($destFolder);
1364 1363
 		$status = $this->mail->getFolderStatus($destFolder);
1365 1364
 		$uidNext = $status['uidnext'];
1366 1365
 		$this->mail->reopen($srcFolder);
1367 1366
 
1368 1367
 		// move message
1369
-		$rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true);
1370
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine
1368
+		$rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true);
1369
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine
1371 1370
 		// return the new id "as string"
1372
-		return ($rv===true ? $uidNext : $rv[$id]) . "";
1371
+		return ($rv === true ? $uidNext : $rv[$id])."";
1373 1372
 	}
1374 1373
 
1375 1374
 	/**
@@ -1377,7 +1376,7 @@  discard block
 block discarded – undo
1377 1376
 	 *
1378 1377
 	 *  @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks
1379 1378
 	 */
1380
-	public function GetMessageList($folderid, $cutoffdate=NULL)
1379
+	public function GetMessageList($folderid, $cutoffdate = NULL)
1381 1380
 	{
1382 1381
 		if ($cutoffdate > 0)
1383 1382
 		{
@@ -1390,8 +1389,8 @@  discard block
 block discarded – undo
1390 1389
 			{
1391 1390
 				$maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange'];
1392 1391
 			}
1393
-			$cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null);
1394
-			if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
1392
+			$cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null);
1393
+			if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
1395 1394
 		}
1396 1395
 		return $this->fetchMessages($folderid, $cutoffdate);
1397 1396
 	}
@@ -1409,11 +1408,11 @@  discard block
 block discarded – undo
1409 1408
 	 * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject"
1410 1409
 	 * @return array uid => array StatMessage($folderid, $_id)
1411 1410
 	 */
1412
-	private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false)
1411
+	private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false)
1413 1412
 	{
1414 1413
 		static $headers = array();
1415 1414
 
1416
-		if ($this->debugLevel>1) $gstarttime = microtime (true);
1415
+		if ($this->debugLevel > 1) $gstarttime = microtime(true);
1417 1416
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
1418 1417
 		$rv_messages = array();
1419 1418
 		// if the message is still available within the class, we use it instead of fetching it again
@@ -1424,64 +1423,64 @@  discard block
 block discarded – undo
1424 1423
 		}
1425 1424
 		else
1426 1425
 		{
1427
-			$headers = array();	// clear cache to not use too much memory
1426
+			$headers = array(); // clear cache to not use too much memory
1428 1427
 
1429
-			if ($this->debugLevel>1) $starttime = microtime (true);
1428
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1430 1429
 			$this->_connect($this->account);
1431
-			if ($this->debugLevel>1)
1430
+			if ($this->debugLevel > 1)
1432 1431
 			{
1433 1432
 				$endtime = microtime(true) - $starttime;
1434
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account);
1433
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account);
1435 1434
 			}
1436 1435
 			$messagelist = $_filter = array();
1437 1436
 			// if not connected, any further action must fail
1438
-			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1439
-			if ($this->debugLevel>1) $starttime = microtime (true);
1437
+			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate));
1438
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1440 1439
 			$account = $_folderName = $id = null;
1441
-			$this->splitID($folderid,$account,$_folderName,$id);
1442
-			if ($this->debugLevel>1)
1440
+			$this->splitID($folderid, $account, $_folderName, $id);
1441
+			if ($this->debugLevel > 1)
1443 1442
 			{
1444 1443
 				$endtime = microtime(true) - $starttime;
1445
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid);
1444
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid);
1446 1445
 			}
1447
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1448
-			if ($this->debugLevel>1) $starttime = microtime (true);
1449
-			$_numberOfMessages = (empty($cutoffdate)?250:99999);
1450
-			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id);
1451
-			if ($this->debugLevel>1)
1446
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1447
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1448
+			$_numberOfMessages = (empty($cutoffdate) ? 250 : 99999);
1449
+			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id);
1450
+			if ($this->debugLevel > 1)
1452 1451
 			{
1453 1452
 				$endtime = microtime(true) - $starttime;
1454
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1453
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1455 1454
 			}
1456 1455
 		}
1457
-		if ($_id == NULL && $this->debugLevel>1)  ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1456
+		if ($_id == NULL && $this->debugLevel > 1)  ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header']));
1458 1457
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages));
1459 1458
 		$messagelist = array();
1460
-		if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist;
1459
+		if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist;
1461 1460
 		//if ($_returnModHash) $messageFolderHash = array();
1462 1461
 		foreach ((array)$rv_messages['header'] as $k => $vars)
1463 1462
 		{
1464
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1463
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1465 1464
 			$headers[$vars['uid']] = $vars;
1466
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1465
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1467 1466
 			if (!empty($vars['deleted'])) continue; // cut of deleted messages
1468 1467
 			if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it
1469
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1468
+			if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1470 1469
 			$mess = $return_all_headers ? $vars : array();
1471 1470
 			$mess["mod"] = self::doFlagsMod($vars).$vars['date'];
1472 1471
 			$mess["id"] = $vars['uid'];
1473 1472
 			// 'seen' aka 'read' is the only flag we want to know about
1474 1473
 			$mess["flags"] = 0;
1475 1474
 			// outlook supports additional flags, set them to 0
1476
-			if($vars["seen"]) $mess["flags"] = 1;
1477
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1475
+			if ($vars["seen"]) $mess["flags"] = 1;
1476
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess));
1478 1477
 			$messagelist[$vars['uid']] = $mess;
1479 1478
 			unset($mess);
1480 1479
 		}
1481
-		if ($this->debugLevel>1)
1480
+		if ($this->debugLevel > 1)
1482 1481
 		{
1483 1482
 			$endtime = microtime(true) - $gstarttime;
1484
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1483
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1485 1484
 		}
1486 1485
 		return $messagelist;
1487 1486
 	}
@@ -1532,32 +1531,32 @@  discard block
 block discarded – undo
1532 1531
 	public function getSearchResultsMailbox($_searchquery)
1533 1532
 	{
1534 1533
 		//$this->debugLevel=1;
1535
-		$searchquery=$_searchquery->GetDataArray();
1534
+		$searchquery = $_searchquery->GetDataArray();
1536 1535
 		if (!is_array($searchquery)) return array();
1537
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1536
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery));
1538 1537
 
1539 1538
 		if (isset($searchquery['searchrebuildresults'])) {
1540 1539
 			$rebuildresults = $searchquery['searchrebuildresults'];
1541 1540
 		} else {
1542 1541
 			$rebuildresults = false;
1543 1542
 		}
1544
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1543
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']');
1545 1544
 
1546 1545
 		if (isset($searchquery['deeptraversal'])) {
1547 1546
 			$deeptraversal = $searchquery['deeptraversal'];
1548 1547
 		} else {
1549 1548
 			$deeptraversal = false;
1550 1549
 		}
1551
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1550
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']');
1552 1551
 
1553 1552
 		if (isset($searchquery['searchrange'])) {
1554
-			$range = explode("-",$_searchquery->GetSearchRange());
1555
-			$start =$range[0] + 1;
1553
+			$range = explode("-", $_searchquery->GetSearchRange());
1554
+			$start = $range[0] + 1;
1556 1555
 			$limit = $range[1] - $range[0] + 1;
1557 1556
 		} else {
1558 1557
 			$range = false;
1559 1558
 		}
1560
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1559
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']');
1561 1560
 
1562 1561
 		//foreach($searchquery['query'] as $k => $value) {
1563 1562
 		//	$query = $value;
@@ -1580,15 +1579,15 @@  discard block
 block discarded – undo
1580 1579
 		}
1581 1580
 		if (!$folderid)
1582 1581
 		{
1583
-			$_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX');
1584
-			$folderid = $this->createID($account=0,$_folderName);
1582
+			$_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX');
1583
+			$folderid = $this->createID($account = 0, $_folderName);
1585 1584
 		}
1586
-		$rv = $this->splitID($folderid,$account,$_folderName,$id);
1587
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName);
1585
+		$rv = $this->splitID($folderid, $account, $_folderName, $id);
1586
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName);
1588 1587
 		$this->_connect($account);
1589 1588
 		// this should not be needed ???
1590
-		Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible)
1591
-		$_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'),
1589
+		Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible)
1590
+		$_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'),
1592 1591
 						 'string'=> $searchText,
1593 1592
 						 'status'=>'any'
1594 1593
 						);
@@ -1603,22 +1602,22 @@  discard block
 block discarded – undo
1603 1602
 		 * 		[searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE
1604 1603
 		 */
1605 1604
 			$_filter['range'] = "BETWEEN";
1606
-			list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']);
1607
-			list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']);
1608
-			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts'));
1609
-			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts'));
1605
+			list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']);
1606
+			list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']);
1607
+			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts'));
1608
+			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts'));
1610 1609
 		}
1611 1610
 		//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
1612
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1613
-		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL);
1611
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1612
+		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL);
1614 1613
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages));
1615
-		$list=array();
1614
+		$list = array();
1616 1615
 
1617 1616
 		$cnt = count($rv_messages['header']);
1618 1617
 		//$list['status'] = 1;
1619 1618
 		$list['searchtotal'] = $cnt;
1620 1619
 		$list["range"] = $_searchquery->GetSearchRange();
1621
-		foreach((array)$rv_messages['header'] as $i => $vars)
1620
+		foreach ((array)$rv_messages['header'] as $i => $vars)
1622 1621
 		{
1623 1622
 			$list[] = array(
1624 1623
 				"class" => "Email",
@@ -1638,20 +1637,20 @@  discard block
 block discarded – undo
1638 1637
 	 * @param string $folder
1639 1638
 	 * @return string
1640 1639
 	 */
1641
-	private function getParentID($account,$folder)
1640
+	private function getParentID($account, $folder)
1642 1641
 	{
1643 1642
 		$this->_connect($account);
1644
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1643
+		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false);
1645 1644
 
1646 1645
 		$mailFolder = $this->folders[$folder];
1647 1646
 		if (!isset($mailFolder)) return false;
1648
-		$delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter());
1649
-		$parent = explode($delimiter,$folder);
1647
+		$delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter());
1648
+		$parent = explode($delimiter, $folder);
1650 1649
 		array_pop($parent);
1651
-		$parent = implode($delimiter,$parent);
1650
+		$parent = implode($delimiter, $parent);
1652 1651
 
1653 1652
 		$id = $parent ? $this->createID($account, $parent) : '0';
1654
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
1653
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id");
1655 1654
 		return $id;
1656 1655
 	}
1657 1656
 
@@ -1671,48 +1670,48 @@  discard block
 block discarded – undo
1671 1670
 			$account = $folder = null;
1672 1671
 			$this->splitID($id, $account, $folder);
1673 1672
 		}
1674
-		catch(Exception $e) {
1675
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage());
1676
-			return $folderObj=false;
1673
+		catch (Exception $e) {
1674
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage());
1675
+			return $folderObj = false;
1677 1676
 		}
1678 1677
 		$this->_connect($account);
1679
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1678
+		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false);
1680 1679
 
1681 1680
 		$mailFolder = $this->folders[$folder];
1682
-		if (!isset($mailFolder)) return $folderObj=false;
1681
+		if (!isset($mailFolder)) return $folderObj = false;
1683 1682
 
1684 1683
 		$folderObj = new SyncFolder();
1685 1684
 		$folderObj->serverid = $id;
1686
-		$folderObj->parentid = $this->getParentID($account,$folder);
1685
+		$folderObj->parentid = $this->getParentID($account, $folder);
1687 1686
 		$folderObj->displayname = $mailFolder->shortDisplayName;
1688
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
1687
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
1689 1688
 		// get folder-type
1690
-		foreach($this->folders as $inbox => $mailFolder) break;
1689
+		foreach ($this->folders as $inbox => $mailFolder) break;
1691 1690
 		if ($folder == $inbox)
1692 1691
 		{
1693 1692
 			$folderObj->type = SYNC_FOLDER_TYPE_INBOX;
1694 1693
 		}
1695
-		elseif($this->mail->isDraftFolder($folder, false, true))
1694
+		elseif ($this->mail->isDraftFolder($folder, false, true))
1696 1695
 		{
1697 1696
 			//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft');
1698 1697
 			$folderObj->type = SYNC_FOLDER_TYPE_DRAFTS;
1699 1698
 			$folderObj->parentid = 0; // required by devices
1700 1699
 		}
1701
-		elseif($this->mail->isTrashFolder($folder, false, true))
1700
+		elseif ($this->mail->isTrashFolder($folder, false, true))
1702 1701
 		{
1703 1702
 			$folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET;
1704 1703
 			$this->_wasteID = $folder;
1705 1704
 			//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID);
1706 1705
 			$folderObj->parentid = 0; // required by devices
1707 1706
 		}
1708
-		elseif($this->mail->isSentFolder($folder, false, true))
1707
+		elseif ($this->mail->isSentFolder($folder, false, true))
1709 1708
 		{
1710 1709
 			$folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL;
1711 1710
 			$folderObj->parentid = 0; // required by devices
1712 1711
 			$this->_sentID = $folder;
1713 1712
 			//error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID);
1714 1713
 		}
1715
-		elseif($this->mail->isOutbox($folder, false, true))
1714
+		elseif ($this->mail->isOutbox($folder, false, true))
1716 1715
 		{
1717 1716
 			//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox');
1718 1717
 			$folderObj->type = SYNC_FOLDER_TYPE_OUTBOX;
@@ -1724,7 +1723,7 @@  discard block
 block discarded – undo
1724 1723
 			$folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL;
1725 1724
 		}
1726 1725
 
1727
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
1726
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
1728 1727
 		return $folderObj;
1729 1728
 	}
1730 1729
 
@@ -1772,18 +1771,18 @@  discard block
 block discarded – undo
1772 1771
 
1773 1772
 		if ($type != 'mail') return false;
1774 1773
 
1775
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1774
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1776 1775
 
1777 1776
         $this->mail->reopen($folder);
1778 1777
 
1779
-		if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true)))
1778
+		if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true)))
1780 1779
 		{
1781
-            ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder ");
1780
+            ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder ");
1782 1781
             return false;
1783 1782
         }
1784
-		$syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1783
+		$syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1785 1784
 
1786
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
1785
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
1787 1786
 		return array();
1788 1787
 	}
1789 1788
 
@@ -1796,8 +1795,8 @@  discard block
 block discarded – undo
1796 1795
 	function GetWasteBasket()
1797 1796
 	{
1798 1797
 		$this->_connect($this->account);
1799
-		$id = $this->createID($account=0, $this->_wasteID);
1800
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID");
1798
+		$id = $this->createID($account = 0, $this->_wasteID);
1799
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID");
1801 1800
 		return $id;
1802 1801
 	}
1803 1802
 
@@ -1818,7 +1817,7 @@  discard block
 block discarded – undo
1818 1817
      */
1819 1818
     public function DeleteMessage($folderid, $id, $contentParameters)
1820 1819
 	{
1821
-		unset($contentParameters);	// not used, but required by function signature
1820
+		unset($contentParameters); // not used, but required by function signature
1822 1821
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid'  id: '$id' )");
1823 1822
 		/*
1824 1823
 		$this->imap_reopenFolder($folderid);
@@ -1829,7 +1828,7 @@  discard block
 block discarded – undo
1829 1828
 		// we may have to split folderid
1830 1829
 		$account = $folder = null;
1831 1830
 		$this->splitID($folderid, $account, $folder);
1832
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder);
1831
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder);
1833 1832
 		$_messageUID = (array)$id;
1834 1833
 
1835 1834
 		$this->_connect($this->account);
@@ -1841,9 +1840,9 @@  discard block
 block discarded – undo
1841 1840
 		catch (Api\Exception $e)
1842 1841
 		{
1843 1842
 			$error = $e->getMessage();
1844
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1843
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1845 1844
 			// if the server thinks the message does not exist report deletion as success
1846
-			if (stripos($error,'[NONEXISTENT]')!==false) return true;
1845
+			if (stripos($error, '[NONEXISTENT]') !== false) return true;
1847 1846
 			return false;
1848 1847
 		}
1849 1848
 
@@ -1877,15 +1876,15 @@  discard block
 block discarded – undo
1877 1876
      */
1878 1877
     public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1879 1878
 	{
1880
-		unset($contentParameters);	// not used, but required by function signature
1879
+		unset($contentParameters); // not used, but required by function signature
1881 1880
 		// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid'  id: '$id'  flags: '$flags' )");
1882 1881
 		$account = $folder = null;
1883 1882
 		$this->splitID($folderid, $account, $folder);
1884 1883
 
1885 1884
 		$_messageUID = (array)$id;
1886 1885
 		$this->_connect($this->account);
1887
-		$rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder);
1888
-		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv);
1886
+		$rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder);
1887
+		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv);
1889 1888
 
1890 1889
 		return $rv;
1891 1890
 	}
@@ -1902,7 +1901,7 @@  discard block
 block discarded – undo
1902 1901
 	 */
1903 1902
 	public function ChangeFolder($id, $oldid, $displayname, $type)
1904 1903
 	{
1905
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!");
1904
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!");
1906 1905
 		return false;
1907 1906
 	}
1908 1907
 
@@ -1917,7 +1916,7 @@  discard block
 block discarded – undo
1917 1916
 	 */
1918 1917
 	public function DeleteFolder($parentid, $id)
1919 1918
 	{
1920
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$parentid', '$id') NOT supported!");
1919
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$parentid', '$id') NOT supported!");
1921 1920
 		return false;
1922 1921
 	}
1923 1922
 
@@ -1937,8 +1936,8 @@  discard block
 block discarded – undo
1937 1936
 		$this->_connect($this->account);
1938 1937
 		$account = $folder = null;
1939 1938
 		$this->splitID($folderid, $account, $folder);
1940
-		$rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder);
1941
-		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1939
+		$rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder);
1940
+		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv);
1942 1941
 
1943 1942
 		return $rv;
1944 1943
 	}
@@ -1952,17 +1951,17 @@  discard block
 block discarded – undo
1952 1951
 	 * @return string
1953 1952
 	 * @throws Api\Exception\WrongParameter
1954 1953
 	 */
1955
-	private function createID($account,$folder,$id=0)
1954
+	private function createID($account, $folder, $id = 0)
1956 1955
 	{
1957 1956
 		if (!is_numeric($folder))
1958 1957
 		{
1959 1958
 			// convert string $folder in numeric id
1960
-			$folder = $this->folder2hash($account,$f=$folder);
1959
+			$folder = $this->folder2hash($account, $f = $folder);
1961 1960
 		}
1962 1961
 
1963 1962
 		$str = $this->backend->createID($account, $folder, $id);
1964 1963
 
1965
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
1964
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
1966 1965
 
1967 1966
 		return $str;
1968 1967
 	}
@@ -1976,14 +1975,14 @@  discard block
 block discarded – undo
1976 1975
 	 * @param int &$id=null
1977 1976
 	 * @throws Api\Exception\WrongParameter
1978 1977
 	 */
1979
-	private function splitID($str,&$account,&$folder,&$id=null)
1978
+	private function splitID($str, &$account, &$folder, &$id = null)
1980 1979
 	{
1981 1980
 		$this->backend->splitID($str, $account, $folder, $id);
1982 1981
 
1983 1982
 		// convert numeric folder-id back to folder name
1984
-		$folder = $this->hash2folder($account,$f=$folder);
1983
+		$folder = $this->hash2folder($account, $f = $folder);
1985 1984
 
1986
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
1985
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$id)");
1987 1986
 	}
1988 1987
 
1989 1988
 	/**
@@ -2000,9 +1999,9 @@  discard block
 block discarded – undo
2000 1999
 	 * @param string $folder
2001 2000
 	 * @return int
2002 2001
 	 */
2003
-	private function folder2hash($account,$folder)
2002
+	private function folder2hash($account, $folder)
2004 2003
 	{
2005
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2004
+		if (!isset($this->folderHashes)) $this->readFolderHashes();
2006 2005
 
2007 2006
 		if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false)
2008 2007
 		{
@@ -2023,9 +2022,9 @@  discard block
 block discarded – undo
2023 2022
 	 * @param int $index
2024 2023
 	 * @return string NULL if not used so far
2025 2024
 	 */
2026
-	private function hash2folder($account,$index)
2025
+	private function hash2folder($account, $index)
2027 2026
 	{
2028
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2027
+		if (!isset($this->folderHashes)) $this->readFolderHashes();
2029 2028
 
2030 2029
 		return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null;
2031 2030
 	}
@@ -2062,9 +2061,9 @@  discard block
 block discarded – undo
2062 2061
 			if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) &&
2063 2062
 				($hashes = file_get_contents($file)))
2064 2063
 			{
2065
-				$this->folderHashes = json_decode($hashes,true);
2064
+				$this->folderHashes = json_decode($hashes, true);
2066 2065
 				// fallback in case hashes have been serialized instead of being json-encoded
2067
-				if (json_last_error()!=JSON_ERROR_NONE)
2066
+				if (json_last_error() != JSON_ERROR_NONE)
2068 2067
 				{
2069 2068
 					//error_log(__METHOD__.__LINE__." error decoding with json");
2070 2069
 					$this->folderHashes = unserialize($hashes);
@@ -2110,9 +2109,9 @@  discard block
 block discarded – undo
2110 2109
 	 * @param boolean $old =false true: return old / pre-15 hash-file
2111 2110
 	 * @throws Api\Exception\AssertionFailed
2112 2111
 	 */
2113
-	private function hashFile($old=false)
2112
+	private function hashFile($old = false)
2114 2113
 	{
2115
-		if (!($dev_id=Request::GetDeviceID()))
2114
+		if (!($dev_id = Request::GetDeviceID()))
2116 2115
 		{
2117 2116
 			throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!");
2118 2117
 		}
Please login to merge, or discard this patch.
Braces   +593 added lines, -174 removed lines patch added patch discarded remove patch
@@ -84,29 +84,47 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function __construct(activesync_backend $backend)
86 86
 	{
87
-		if ($GLOBALS['egw_setup']) return;
87
+		if ($GLOBALS['egw_setup'])
88
+		{
89
+			return;
90
+		}
88 91
 
89 92
 		//$this->debugLevel=2;
90 93
 		$this->backend = $backend;
91 94
 		if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
92 95
 		{
93
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
96
+			if ($this->debugLevel>1)
97
+			{
98
+				error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
99
+			}
94 100
 			// globals preferences add appname varname value
95 101
 			$GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user');
96 102
 			// save prefs
97 103
 			$GLOBALS['egw']->preferences->save_repository(true);
98 104
 		}
99
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
105
+		if ($this->debugLevel>1)
106
+		{
107
+			error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
108
+		}
100 109
 
101 110
 		if (is_null(self::$profileID))
102 111
 		{
103
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
112
+			if ($this->debugLevel>1)
113
+			{
114
+				error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
115
+			}
104 116
 			self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID');
105
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
117
+			if ($this->debugLevel>1)
118
+			{
119
+				error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
120
+			}
106 121
 		}
107 122
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
108 123
 		{
109
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
124
+			if ($this->debugLevel>1)
125
+			{
126
+				error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
127
+			}
110 128
 			if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G')
111 129
 			{
112 130
 				self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is)
@@ -116,7 +134,10 @@  discard block
 block discarded – undo
116 134
 				self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'];
117 135
 			}
118 136
 		}
119
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
137
+		if ($this->debugLevel>1)
138
+		{
139
+			error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
140
+		}
120 141
 
121 142
 		// verify we are on an existing profile, if not running in setup (settings can not be static according to interface!)
122 143
 		if (!isset($GLOBALS['egw_setup']))
@@ -129,7 +150,10 @@  discard block
 block discarded – undo
129 150
 				self::$profileID = Mail\Account::get_default_acc_id();
130 151
 			}
131 152
 		}
132
-		if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
153
+		if ($this->debugLevel>0)
154
+		{
155
+			error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
156
+		}
133 157
 		//$this->debugLevel=0;
134 158
 	}
135 159
 
@@ -245,8 +269,14 @@  discard block
 block discarded – undo
245 269
 				$this->_connect(0,true);
246 270
 				$this->_disconnect();
247 271
 
248
-				if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>');
249
-				if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>');
272
+				if (!$this->_wasteID)
273
+				{
274
+					$errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>');
275
+				}
276
+				if (!$this->_sentID)
277
+				{
278
+					$errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>');
279
+				}
250 280
 			}
251 281
 			catch(Exception $e) {
252 282
 				$errors[] = lang('Can not open IMAP connection').': '.$e->getMessage();
@@ -268,8 +298,14 @@  discard block
 block discarded – undo
268 298
 	 */
269 299
 	private function _connect($account=0)
270 300
 	{
271
-		if (!$account) $account = self::$profileID ? self::$profileID : 0;
272
-		if ($this->mail && $this->account != $account) $this->_disconnect();
301
+		if (!$account)
302
+		{
303
+			$account = self::$profileID ? self::$profileID : 0;
304
+		}
305
+		if ($this->mail && $this->account != $account)
306
+		{
307
+			$this->_disconnect();
308
+		}
273 309
 
274 310
 		$this->_wasteID = false;
275 311
 		$this->_sentID = false;
@@ -280,12 +316,18 @@  discard block
 block discarded – undo
280 316
 			// todo: tell mail which account to use
281 317
 			//error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID));
282 318
 			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
283
-			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
319
+			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId))
320
+			{
321
+				self::$profileID = $this->mail->icServer->ImapServerId;
322
+			}
284 323
 		}
285 324
 		else
286 325
 		{
287 326
 			//error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID);
288
-			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
327
+			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId))
328
+			{
329
+				self::$profileID = $this->mail->icServer->ImapServerId;
330
+			}
289 331
 		}
290 332
 		$this->mail->openConnection(self::$profileID,false);
291 333
 
@@ -302,8 +344,14 @@  discard block
 block discarded – undo
302 344
 	 */
303 345
 	private function _disconnect()
304 346
 	{
305
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__);
306
-		if ($this->mail) $this->mail->closeConnection();
347
+		if ($this->debugLevel>0)
348
+		{
349
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__);
350
+		}
351
+		if ($this->mail)
352
+		{
353
+			$this->mail->closeConnection();
354
+		}
307 355
 
308 356
 		unset($this->mail);
309 357
 		unset($this->account);
@@ -318,24 +366,43 @@  discard block
 block discarded – undo
318 366
 	public function GetFolderList()
319 367
 	{
320 368
 		$folderlist = array();
321
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
369
+		if ($this->debugLevel>0)
370
+		{
371
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
372
+		}
322 373
 		/*foreach($available_accounts as $account)*/ $account = 0;
323 374
 		{
324 375
 			$this->_connect($account);
325
-			if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true);
326
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders));
376
+			if (!isset($this->folders))
377
+			{
378
+				$this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true);
379
+			}
380
+			if ($this->debugLevel>1)
381
+			{
382
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders));
383
+			}
327 384
 
328
-			foreach ($this->folders as $folder => $folderObj) {
329
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder);
385
+			foreach ($this->folders as $folder => $folderObj)
386
+			{
387
+				if ($this->debugLevel>1)
388
+				{
389
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder);
390
+				}
330 391
 				$folderlist[] = $f = array(
331 392
 					'id'     => $this->createID($account,$folder),
332 393
 					'mod'    => $folderObj->shortDisplayName,
333 394
 					'parent' => $this->getParentID($account,$folder),
334 395
 				);
335
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f));
396
+				if ($this->debugLevel>1)
397
+				{
398
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f));
399
+				}
336 400
 			}
337 401
 		}
338
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist));
402
+		if ($this->debugLevel>0)
403
+		{
404
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist));
405
+		}
339 406
 
340 407
 		return $folderlist;
341 408
 	}
@@ -396,11 +463,17 @@  discard block
 block discarded – undo
396 463
 		$smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new'));
397 464
 
398 465
    		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : ""));
399
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
466
+		if ($this->debugLevel>0)
467
+		{
468
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
469
+		}
400 470
 		//error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata));
401 471
 
402 472
 		// initialize our Mail
403
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
473
+		if (!isset($this->mail))
474
+		{
475
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
476
+		}
404 477
 		$activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID);
405 478
 		// use the standardIdentity
406 479
 		$activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID);
@@ -419,22 +492,34 @@  discard block
 block discarded – undo
419 492
 		// prepare addressee list; moved the adding of addresses to the mailobject down
420 493
 		// to
421 494
 
422
-		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
423
-			if (!$addressObject->valid) continue;
495
+		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject)
496
+		{
497
+			if (!$addressObject->valid)
498
+			{
499
+				continue;
500
+			}
424 501
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) );
425 502
 			//$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
426 503
 			$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
427 504
 		}
428 505
 		// CC
429
-		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
430
-			if (!$addressObject->valid) continue;
506
+		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject)
507
+		{
508
+			if (!$addressObject->valid)
509
+			{
510
+				continue;
511
+			}
431 512
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) );
432 513
 			//$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
433 514
 			$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
434 515
 		}
435 516
 		// BCC
436
-		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
437
-			if (!$addressObject->valid) continue;
517
+		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject)
518
+		{
519
+			if (!$addressObject->valid)
520
+			{
521
+				continue;
522
+			}
438 523
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) );
439 524
 			//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
440 525
 			$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
@@ -447,12 +532,14 @@  discard block
 block discarded – undo
447 532
 		$ContentType =$mailObject->getHeader('Content-Type');
448 533
 		//error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k.  " = ".trim($ContentType));
449 534
 		// if the message is a multipart message, then we should use the sent body
450
-		if (preg_match("/multipart/i", $ContentType)) {
535
+		if (preg_match("/multipart/i", $ContentType))
536
+		{
451 537
 			$use_orgbody = true;
452 538
 		}
453 539
 
454 540
 		// save the original content-type header for the body part when forwarding
455
-		if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) {
541
+		if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody)
542
+		{
456 543
 			//continue; // ignore
457 544
 		}
458 545
 		// horde/egw_ mailer does everything as utf-8, the following should not be needed
@@ -461,7 +548,8 @@  discard block
 block discarded – undo
461 548
 		// if the message is a multipart message, then we should use the sent body
462 549
 		if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') &&
463 550
 			((isset($smartdata->replacemime) && $smartdata->replacemime == true) ||
464
-			$k == "Content-Type" && preg_match("/multipart/i", $ContentType))) {
551
+			$k == "Content-Type" && preg_match("/multipart/i", $ContentType)))
552
+		{
465 553
 			$use_orgbody = true;
466 554
 		}
467 555
 		$Body =  $AltBody = "";
@@ -494,12 +582,19 @@  discard block
 block discarded – undo
494 582
 			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
495 583
 				($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null);
496 584
 		}
497
-		if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
498
-		if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
585
+		if ($this->debugLevel>1 && $Body)
586
+		{
587
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
588
+		}
589
+		if ($this->debugLevel>1 && $AltBody)
590
+		{
591
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
592
+		}
499 593
 		//error_log(__METHOD__.__LINE__.array2string($mailObject));
500 594
 		// if this is a multipart message with a boundary, we must use the original body
501 595
 		//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject));
502
-        if ($use_orgbody) {
596
+        if ($use_orgbody)
597
+        {
503 598
     	    ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
504 599
  			// if it is a ClientSideMeetingRequest, we report it as send at all times
505 600
 			if (($cal_body = $mailObject->findBody('calendar')) &&
@@ -509,15 +604,20 @@  discard block
 block discarded – undo
509 604
 				{
510 605
 					$organizer = calendar_ical::getIcalOrganizer($cal_body->getContents());
511 606
 				}
512
-				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
607
+				if ($this->debugLevel)
608
+				{
609
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
610
+				}
513 611
 				$ClientSideMeetingRequest = true;
514 612
 			}
515 613
         }
516 614
 		// now handle the addressee list
517 615
 		$toCount = 0;
518 616
 		//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
519
-		foreach((array)$toMailAddr as $address) {
520
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
617
+		foreach((array)$toMailAddr as $address)
618
+		{
619
+			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
620
+			{
521 621
 				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
522 622
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' &&
523 623
 					calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST',
@@ -531,19 +631,29 @@  discard block
 block discarded – undo
531 631
 			}
532 632
 		}
533 633
 		$ccCount = 0;
534
-		foreach((array)$ccMailAddr as $address) {
535
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
634
+		foreach((array)$ccMailAddr as $address)
635
+		{
636
+			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
637
+			{
536 638
 				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
537
-				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
639
+				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress))
640
+				{
641
+					continue;
642
+				}
538 643
 				$mailObject->AddCC($emailAddress, $addressObject->personal);
539 644
 				$ccCount++;
540 645
 			}
541 646
 		}
542 647
 		$bccCount = 0;
543
-		foreach((array)$bccMailAddr as $address) {
544
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
648
+		foreach((array)$bccMailAddr as $address)
649
+		{
650
+			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
651
+			{
545 652
 				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
546
-				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
653
+				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress))
654
+				{
655
+					continue;
656
+				}
547 657
 				$mailObject->AddBCC($emailAddress, $addressObject->personal);
548 658
 				$bccCount++;
549 659
 			}
@@ -553,7 +663,10 @@  discard block
 block discarded – undo
553 663
 		{
554 664
 			return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to
555 665
 		}
556
-		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true;
666
+		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false)
667
+		{
668
+			return true;
669
+		}
557 670
 		// as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail
558 671
 /*
559 672
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body);
@@ -583,7 +696,10 @@  discard block
 block discarded – undo
583 696
 		$beforeHtml = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
584 697
 		$beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
585 698
 		$sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
586
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
699
+		if ($this->debugLevel>0)
700
+		{
701
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
702
+		}
587 703
 		$sigTextHtml = $beforeHtml.$sigText;
588 704
 		$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText);
589 705
 		$isreply = $isforward = false;
@@ -601,10 +717,17 @@  discard block
 block discarded – undo
601 717
 			$this->mail->reopen($folder);
602 718
 			$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
603 719
 			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
604
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
605
-		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
720
+			if ($this->debugLevel>3)
721
+			{
722
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
723
+			}
724
+		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html'))
725
+		    {
606 726
 				// may be html
607
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
727
+				if ($this->debugLevel>0)
728
+				{
729
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
730
+				}
608 731
 				$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
609 732
 				$isreply = true;
610 733
 			}
@@ -613,8 +736,12 @@  discard block
 block discarded – undo
613 736
 			// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
614 737
 			$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
615 738
 			$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
616
-			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
617
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
739
+			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain'))
740
+			{
741
+				if ($this->debugLevel>0)
742
+				{
743
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
744
+				}
618 745
 				$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
619 746
 				$isreply = true;
620 747
 			}
@@ -622,7 +749,10 @@  discard block
 block discarded – undo
622 749
 			{
623 750
 				$isreply = true;
624 751
 				$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
625
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
752
+				if ($this->debugLevel>0)
753
+				{
754
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
755
+				}
626 756
 			}
627 757
 		}
628 758
 
@@ -636,11 +766,17 @@  discard block
 block discarded – undo
636 766
 			(isset($smartdata->replacemime) && $smartdata->replacemime == false)))
637 767
 		{
638 768
 			//force the default for the forwarding -> asmail
639
-			if (is_array($preferencesArray)) {
769
+			if (is_array($preferencesArray))
770
+			{
640 771
 				if (!array_key_exists('message_forwarding',$preferencesArray)
641 772
 					|| !isset($preferencesArray['message_forwarding'])
642
-					|| empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail';
643
-			} else {
773
+					|| empty($preferencesArray['message_forwarding']))
774
+				{
775
+					$preferencesArray['message_forwarding'] = 'asmail';
776
+				}
777
+			}
778
+			else
779
+			{
644 780
 				$preferencesArray['message_forwarding'] = 'asmail';
645 781
 			}
646 782
 			// construct the uid of the message out of the itemid - seems to be the uid, no construction needed
@@ -672,27 +808,44 @@  discard block
 block discarded – undo
672 808
 				$this->mail->reopen($folder);
673 809
 				$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
674 810
 				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
675
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
676
-				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
811
+				if ($this->debugLevel>0)
812
+				{
813
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
814
+				}
815
+				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html'))
816
+				{
677 817
 					// may be html
678
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
818
+					if ($this->debugLevel>0)
819
+					{
820
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
821
+					}
679 822
 					$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
680 823
 					$isforward = true;
681 824
 				}
682 825
 				// plain text Message part
683
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
826
+				if ($this->debugLevel>0)
827
+				{
828
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
829
+				}
684 830
 				// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
685 831
 				$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
686 832
 				$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
687
-				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
688
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
833
+				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain'))
834
+				{
835
+					if ($this->debugLevel>0)
836
+					{
837
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
838
+					}
689 839
 					$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
690 840
 					$isforward = true;
691 841
 				}
692 842
 				if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody))
693 843
 				{
694 844
 					$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
695
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
845
+					if ($this->debugLevel>0)
846
+					{
847
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
848
+					}
696 849
 					$isforward = true;
697 850
 				}
698 851
 				// get all the attachments and add them too.
@@ -705,7 +858,10 @@  discard block
 block discarded – undo
705 858
 					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
706 859
 					foreach((array)$attachments as $key => $attachment)
707 860
 					{
708
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
861
+						if ($this->debugLevel>0)
862
+						{
863
+							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
864
+						}
709 865
 						$attachmentNames .= $attachment['name']."\n";
710 866
 						$attachmentData	= $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder);
711 867
 						/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']);
@@ -723,18 +879,27 @@  discard block
 block discarded – undo
723 879
 		// now set the body
724 880
 		if ($AltBody && ($html_body = $mailObject->findBody('html')))
725 881
 		{
726
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
882
+			if ($this->debugLevel>1)
883
+			{
884
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
885
+			}
727 886
 			$html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
728 887
 		}
729 888
 		if ($Body && ($text_body = $mailObject->findBody('plain')))
730 889
 		{
731
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
890
+			if ($this->debugLevel>1)
891
+			{
892
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
893
+			}
732 894
 			$text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
733 895
 		}
734 896
 		//advanced debugging
735 897
 		// Horde SMTP Class uses utf-8 by default.
736 898
         //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
737
-		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
899
+		if ($this->debugLevel>2)
900
+		{
901
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
902
+		}
738 903
 
739 904
 		// set a higher timeout for big messages
740 905
 		@set_time_limit(120);
@@ -761,7 +926,9 @@  discard block
 block discarded – undo
761 926
 			if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder))
762 927
 			{
763 928
 				$this->mail->deleteMessages(array($uid),$folder);
764
-			} else {
929
+			}
930
+			else
931
+			{
765 932
 				$this->mail->flagMessages("answered", array($uid),$folder);
766 933
 				if ($smartdata_task== "forward")
767 934
 				{
@@ -775,7 +942,8 @@  discard block
 block discarded – undo
775 942
 		{
776 943
 			$asf = false;
777 944
 			$sentFolder = $this->mail->getSentFolder();
778
-			if ($this->_sentID) {
945
+			if ($this->_sentID)
946
+			{
779 947
 				$folderArray[] = $this->_sentID;
780 948
 			}
781 949
 			else if(isset($sentFolder) && $sentFolder != 'none')
@@ -789,27 +957,40 @@  discard block
 block discarded – undo
789 957
 				// we dont try guessing
790 958
 				$asf = true;
791 959
 			}
792
-			if (count($folderArray) > 0) {
793
-				foreach((array)$bccMailAddr as $address) {
794
-					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
960
+			if (count($folderArray) > 0)
961
+			{
962
+				foreach((array)$bccMailAddr as $address)
963
+				{
964
+					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
965
+					{
795 966
 						$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
796 967
 						$mailAddr[] = array($emailAddress, $addressObject->personal);
797 968
 					}
798 969
 				}
799 970
 				$BCCmail='';
800
-				if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
801
-				foreach($folderArray as $folderName) {
802
-					if($this->mail->isSentFolder($folderName)) {
971
+				if (count($mailAddr)>0)
972
+				{
973
+					$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
974
+				}
975
+				foreach($folderArray as $folderName)
976
+				{
977
+					if($this->mail->isSentFolder($folderName))
978
+					{
803 979
 						$flags = '\\Seen';
804
-					} elseif($this->mail->isDraftFolder($folderName)) {
980
+					}
981
+					elseif($this->mail->isDraftFolder($folderName))
982
+					{
805 983
 						$flags = '\\Draft';
806
-					} else {
984
+					}
985
+					else
986
+					{
807 987
 						$flags = '';
808 988
 					}
809 989
 					$asf = true;
810 990
 					//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer));
811 991
 					$this->mail->openConnection(self::$profileID,false);
812
-					if ($this->mail->folderExists($folderName)) {
992
+					if ($this->mail->folderExists($folderName))
993
+					{
813 994
 						try
814 995
 						{
815 996
 							$this->mail->appendMessage($folderName,$mailObject->getRaw(), null,
@@ -867,17 +1048,26 @@  discard block
 block discarded – undo
867 1048
 		$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */
868 1049
 
869 1050
 		// fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0
870
-		if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]);
1051
+		if (!$mimesupport && ($key = array_search('4', $bodypreference)))
1052
+		{
1053
+			unset($bodypreference[$key]);
1054
+		}
871 1055
 
872 1056
 		//$this->debugLevel=4;
873
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1057
+		if (!isset($this->mail))
1058
+		{
1059
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1060
+		}
874 1061
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
875 1062
 		$account = $_folderName = $xid = null;
876 1063
 		$this->splitID($folderid,$account,$_folderName,$xid);
877 1064
 		$this->mail->reopen($_folderName);
878 1065
 		$messages = $this->fetchMessages($folderid, NULL, $id, true);	// true: return all headers
879 1066
 		$headers = $messages[$id];
880
-		if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
1067
+		if ($this->debugLevel>3)
1068
+		{
1069
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
1070
+		}
881 1071
 		// StatMessage should reopen the folder in question, so we dont need folderids in the following statements.
882 1072
 		if ($headers)
883 1073
 		{
@@ -887,16 +1077,25 @@  discard block
 block discarded – undo
887 1077
 			//$rawHeaders = $this->mail->getMessageRawHeader($id);
888 1078
 			// simple style
889 1079
 			// start AS12 Stuff (bodypreference === false) case = old behaviour
890
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
1080
+			if ($this->debugLevel>0)
1081
+			{
1082
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
1083
+			}
891 1084
 
892
-			if ($bodypreference === false) {
1085
+			if ($bodypreference === false)
1086
+			{
893 1087
 				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
894 1088
 				$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
895 1089
 				//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
896
-				if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
1090
+				if (stripos($raw_body,'<style')!==false)
1091
+				{
1092
+					$body = preg_replace("/<style.*?<\/style>/is", "", $raw_body);
1093
+				}
1094
+				// in case there is only a html part
897 1095
 				// remove all other html
898 1096
 				$body = strip_tags($raw_body);
899
-				if(strlen($body) > $truncsize) {
1097
+				if(strlen($body) > $truncsize)
1098
+				{
900 1099
 					$body = Utils::Utf8_truncate($body, $truncsize);
901 1100
 					$output->bodytruncated = 1;
902 1101
 				}
@@ -911,7 +1110,8 @@  discard block
 block discarded – undo
911 1110
 			{
912 1111
 				//Select body type preference
913 1112
 				$bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN;
914
-				if ($bodypreference !== false) {
1113
+				if ($bodypreference !== false)
1114
+				{
915 1115
 					// bodypreference can occur multiple times
916 1116
 					// usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference);
917 1117
 					$bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference);
@@ -945,25 +1145,49 @@  discard block
 block discarded – undo
945 1145
 					// fetch the body (try to gather data only once)
946 1146
 					$css ='';
947 1147
 					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
948
-					if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
1148
+					if ($this->debugLevel>2)
1149
+					{
1150
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
1151
+					}
949 1152
 					$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
950
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
951
-					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
1153
+					if ($this->debugLevel>3)
1154
+					{
1155
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
1156
+					}
1157
+					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html'))
1158
+					{
952 1159
 						// may be html
953
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
1160
+						if ($this->debugLevel>0)
1161
+						{
1162
+							ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
1163
+						}
954 1164
 						$css = $this->mail->getStyles($bodyStruct);
955 1165
 						$output->nativebodytype=2;
956
-					} else {
1166
+					}
1167
+					else
1168
+					{
957 1169
 						// plain text Message
958
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
1170
+						if ($this->debugLevel>0)
1171
+						{
1172
+							ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
1173
+						}
959 1174
 						$output->nativebodytype=1;
960 1175
 						$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
961
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
1176
+						if ($this->debugLevel>3)
1177
+						{
1178
+							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
1179
+						}
962 1180
 						$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
963
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
1181
+						if ($this->debugLevel>3)
1182
+						{
1183
+							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
1184
+						}
964 1185
 					}
965 1186
 					// whatever format decode (using the correct encoding)
966
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
1187
+					if ($this->debugLevel>3)
1188
+					{
1189
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
1190
+					}
967 1191
 					//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
968 1192
 					// prepare plaintextbody
969 1193
 					$plainBody='';
@@ -984,12 +1208,18 @@  discard block
 block discarded – undo
984 1208
 					// remove all other html
985 1209
 					$plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody);
986 1210
 					$plainBody = strip_tags($plainBody);
987
-					if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
1211
+					if ($this->debugLevel>3 && $output->nativebodytype==1)
1212
+					{
1213
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
1214
+					}
988 1215
 					//$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that?
989 1216
 
990
-					if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML
1217
+					if ($bpReturnType==2)
1218
+					{
1219
+						//SYNC_BODYPREFERENCE_HTML
991 1220
 					{
992 1221
 						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
1222
+					}
993 1223
 						// Send HTML if requested and native type was html
994 1224
 						$output->asbody->type = 2;
995 1225
 						$htmlbody = '<html>'.
@@ -1001,7 +1231,10 @@  discard block
 block discarded – undo
1001 1231
 							'<body>';
1002 1232
 						if ($output->nativebodytype==2)
1003 1233
 						{
1004
-							if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style');
1234
+							if ($css)
1235
+							{
1236
+								Api\Mail\Html::replaceTagsCompletley($body,'style');
1237
+							}
1005 1238
 							// as we fetch html, and body is HTML, we may not need to handle this
1006 1239
 							$htmlbody .= $body;
1007 1240
 						}
@@ -1026,7 +1259,10 @@  discard block
 block discarded – undo
1026 1259
 					else
1027 1260
 					{
1028 1261
 						// Send Plaintext as Fallback or if original body is plainttext
1029
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1262
+						if ($this->debugLevel>0)
1263
+						{
1264
+							ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1265
+						}
1030 1266
 						/* we use plainBody (set above) instead
1031 1267
 						$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
1032 1268
 						$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
@@ -1063,7 +1299,9 @@  discard block
 block discarded – undo
1063 1299
 			{
1064 1300
 				$output->flag->flagstatus = 2;
1065 1301
 				//$output->flag->flagtype = "Flag for Follow up";
1066
-			} else {
1302
+			}
1303
+			else
1304
+			{
1067 1305
 				$output->flag->flagstatus = 0;
1068 1306
 			}
1069 1307
 			if ($headers['answered'])
@@ -1079,10 +1317,20 @@  discard block
 block discarded – undo
1079 1317
 				($headers['priority'] < 3 ? 2 : 1) ;
1080 1318
 			$output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true);
1081 1319
 			$output->to = $headers['to_address'];
1082
-			if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name']
1320
+			if ($headers['to'])
1321
+			{
1322
+				$output->displayto = $headers['to_address'];
1323
+			}
1324
+			//$headers['FETCHED_HEADER']['to_name']
1083 1325
 			$output->from = $headers['sender_address'];
1084
-			if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses'];
1085
-			if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address'];
1326
+			if (isset($headers['cc_addresses']) && $headers['cc_addresses'])
1327
+			{
1328
+				$output->cc = $headers['cc_addresses'];
1329
+			}
1330
+			if (isset($headers['reply_to_address']) && $headers['reply_to_address'])
1331
+			{
1332
+				$output->reply_to = $headers['reply_to_address'];
1333
+			}
1086 1334
 
1087 1335
 			$output->messageclass = "IPM.Note";
1088 1336
 			if (stripos($headers['mimetype'],'multipart')!== false &&
@@ -1090,7 +1338,8 @@  discard block
 block discarded – undo
1090 1338
 			{
1091 1339
 				$output->messageclass = "IPM.Note.SMIME.MultipartSigned";
1092 1340
 			}
1093
-			if (Request::GetProtocolVersion() >= 12.0) {
1341
+			if (Request::GetProtocolVersion() >= 12.0)
1342
+			{
1094 1343
 				$output->contentclass = "urn:content-classes:message";
1095 1344
 			}
1096 1345
 
@@ -1103,7 +1352,10 @@  discard block
 block discarded – undo
1103 1352
 				//error_log(__METHOD__.__LINE__.array2string($attachments));
1104 1353
 				foreach ($attachments as $key => $attach)
1105 1354
 				{
1106
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1355
+					if ($this->debugLevel>0)
1356
+					{
1357
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1358
+					}
1107 1359
 
1108 1360
 					// pass meeting requests to calendar plugin
1109 1361
 					if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
@@ -1120,17 +1372,24 @@  discard block
 block discarded – undo
1120 1372
 						unset($attachment);
1121 1373
 						continue;	// do NOT add attachment as attachment
1122 1374
 					}
1123
-					if (Request::GetProtocolVersion() >= 12.0) {
1375
+					if (Request::GetProtocolVersion() >= 12.0)
1376
+					{
1124 1377
 						$attachment = new SyncBaseAttachment();
1125 1378
 						if (!isset($output->asattachments) || !is_array($output->asattachments))
1126
-							$output->asattachments = array();
1379
+						{
1380
+													$output->asattachments = array();
1381
+						}
1127 1382
 						$attachment->estimatedDataSize = $attach['size'];
1128 1383
 						$attachment->method = 1;
1129 1384
 						$attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID'];
1130
-					} else {
1385
+					}
1386
+					else
1387
+					{
1131 1388
 						$attachment = new SyncAttachment();
1132 1389
 						if (!isset($output->attachments) || !is_array($output->attachments))
1133
-							$output->attachments = array();
1390
+						{
1391
+													$output->attachments = array();
1392
+						}
1134 1393
 						$attachment->attsize = $attach['size'];
1135 1394
 						$attachment->attmethod = 1;
1136 1395
 						$attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key;
@@ -1147,10 +1406,13 @@  discard block
 block discarded – undo
1147 1406
 						{
1148 1407
 							$attachment->isinline = true;
1149 1408
 						}
1150
-						if (Request::GetProtocolVersion() >= 12.0) {
1409
+						if (Request::GetProtocolVersion() >= 12.0)
1410
+						{
1151 1411
 							$attachment->method=1;
1152 1412
 							$attachment->contentid= str_replace(array("<",">"), "",$attach['cid']);
1153
-						} else {
1413
+						}
1414
+						else
1415
+						{
1154 1416
 							$attachment->attmethod=6;
1155 1417
 							$attachment->attoid = str_replace(array("<",">"), "",$attach['cid']);
1156 1418
 						}
@@ -1158,9 +1420,12 @@  discard block
 block discarded – undo
1158 1420
 						$attachment->contenttype = trim($attach['mimeType']);
1159 1421
 						//	ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-type']."'  ".$attachment->contentid);
1160 1422
 					}
1161
-					if (Request::GetProtocolVersion() >= 12.0) {
1423
+					if (Request::GetProtocolVersion() >= 12.0)
1424
+					{
1162 1425
 						array_push($output->asattachments, $attachment);
1163
-					} else {
1426
+					}
1427
+					else
1428
+					{
1164 1429
 						array_push($output->attachments, $attachment);
1165 1430
 					}
1166 1431
 					unset($attachment);
@@ -1173,8 +1438,11 @@  discard block
 block discarded – undo
1173 1438
             // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1174 1439
             $output->internetcpid = INTERNET_CPID_UTF8;
1175 1440
 
1176
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1177
-//$this->debugLevel=0;
1441
+			if ($this->debugLevel>3)
1442
+			{
1443
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1444
+			}
1445
+			//$this->debugLevel=0;
1178 1446
 			return $output;
1179 1447
 		}
1180 1448
 //$this->debugLevel=0;
@@ -1233,7 +1501,8 @@  discard block
 block discarded – undo
1233 1501
      * @param string $attname - should contain (folder)id
1234 1502
 	 * @return SyncItemOperationsAttachment-object
1235 1503
 	 */
1236
-	function GetAttachmentData($fid,$attname) {
1504
+	function GetAttachmentData($fid,$attname)
1505
+	{
1237 1506
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1238 1507
 		return $this->_GetAttachmentData($fid,$attname);
1239 1508
 	}
@@ -1248,7 +1517,8 @@  discard block
 block discarded – undo
1248 1517
      * @param string $attname - should contain (folder)id
1249 1518
 	 * @return SyncItemOperationsAttachment-object
1250 1519
 	 */
1251
-	function ItemOperationsGetAttachmentData($fid,$attname) {
1520
+	function ItemOperationsGetAttachmentData($fid,$attname)
1521
+	{
1252 1522
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1253 1523
 		return $this->_GetAttachmentData($fid,$attname);
1254 1524
 	}
@@ -1270,7 +1540,10 @@  discard block
 block discarded – undo
1270 1540
 
1271 1541
 		$this->splitID($folderid, $account, $folder);
1272 1542
 
1273
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1543
+		if (!isset($this->mail))
1544
+		{
1545
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1546
+		}
1274 1547
 
1275 1548
 		$this->mail->reopen($folder);
1276 1549
 		$attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder);
@@ -1279,7 +1552,9 @@  discard block
 block discarded – undo
1279 1552
 		$SIOattachment->data = $attachment['attachment'];
1280 1553
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']);
1281 1554
 		if (isset($attachment['type']) )
1282
-			$SIOattachment->contenttype = $attachment['type'];
1555
+		{
1556
+					$SIOattachment->contenttype = $attachment['type'];
1557
+		}
1283 1558
 
1284 1559
 		unset($attachment);
1285 1560
 
@@ -1325,11 +1600,15 @@  discard block
 block discarded – undo
1325 1600
 		//unset($folderid, $id, $message, $contentParameters);
1326 1601
 		$account = $folder = null;
1327 1602
 		$this->splitID($folderid, $account, $folder);
1328
-		if (isset($message->flag)) {
1329
-			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) {
1603
+		if (isset($message->flag))
1604
+		{
1605
+			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2)
1606
+			{
1330 1607
 				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder);
1331 1608
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1332
-			} else {
1609
+			}
1610
+			else
1611
+			{
1333 1612
 				$rv = $this->mail->flagMessages("unflagged", $id,$folder);
1334 1613
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv);
1335 1614
 			}
@@ -1359,7 +1638,10 @@  discard block
 block discarded – undo
1359 1638
 		$this->splitID($folderid, $account, $srcFolder);
1360 1639
 		$this->splitID($newfolderid, $account, $destFolder);
1361 1640
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder'  id: '$id'  DestFolder: '$destFolder' )");
1362
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1641
+		if (!isset($this->mail))
1642
+		{
1643
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1644
+		}
1363 1645
 		$this->mail->reopen($destFolder);
1364 1646
 		$status = $this->mail->getFolderStatus($destFolder);
1365 1647
 		$uidNext = $status['uidnext'];
@@ -1391,7 +1673,10 @@  discard block
 block discarded – undo
1391 1673
 				$maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange'];
1392 1674
 			}
1393 1675
 			$cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null);
1394
-			if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
1676
+			if (is_numeric($maximumSyncRangeInDays))
1677
+			{
1678
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
1679
+			}
1395 1680
 		}
1396 1681
 		return $this->fetchMessages($folderid, $cutoffdate);
1397 1682
 	}
@@ -1413,7 +1698,10 @@  discard block
 block discarded – undo
1413 1698
 	{
1414 1699
 		static $headers = array();
1415 1700
 
1416
-		if ($this->debugLevel>1) $gstarttime = microtime (true);
1701
+		if ($this->debugLevel>1)
1702
+		{
1703
+			$gstarttime = microtime (true);
1704
+		}
1417 1705
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
1418 1706
 		$rv_messages = array();
1419 1707
 		// if the message is still available within the class, we use it instead of fetching it again
@@ -1426,7 +1714,10 @@  discard block
 block discarded – undo
1426 1714
 		{
1427 1715
 			$headers = array();	// clear cache to not use too much memory
1428 1716
 
1429
-			if ($this->debugLevel>1) $starttime = microtime (true);
1717
+			if ($this->debugLevel>1)
1718
+			{
1719
+				$starttime = microtime (true);
1720
+			}
1430 1721
 			$this->_connect($this->account);
1431 1722
 			if ($this->debugLevel>1)
1432 1723
 			{
@@ -1435,8 +1726,14 @@  discard block
 block discarded – undo
1435 1726
 			}
1436 1727
 			$messagelist = $_filter = array();
1437 1728
 			// if not connected, any further action must fail
1438
-			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1439
-			if ($this->debugLevel>1) $starttime = microtime (true);
1729
+			if (!empty($cutoffdate))
1730
+			{
1731
+				$_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1732
+			}
1733
+			if ($this->debugLevel>1)
1734
+			{
1735
+				$starttime = microtime (true);
1736
+			}
1440 1737
 			$account = $_folderName = $id = null;
1441 1738
 			$this->splitID($folderid,$account,$_folderName,$id);
1442 1739
 			if ($this->debugLevel>1)
@@ -1444,8 +1741,14 @@  discard block
 block discarded – undo
1444 1741
 				$endtime = microtime(true) - $starttime;
1445 1742
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid);
1446 1743
 			}
1447
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1448
-			if ($this->debugLevel>1) $starttime = microtime (true);
1744
+			if ($this->debugLevel>1)
1745
+			{
1746
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1747
+			}
1748
+			if ($this->debugLevel>1)
1749
+			{
1750
+				$starttime = microtime (true);
1751
+			}
1449 1752
 			$_numberOfMessages = (empty($cutoffdate)?250:99999);
1450 1753
 			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id);
1451 1754
 			if ($this->debugLevel>1)
@@ -1454,27 +1757,56 @@  discard block
 block discarded – undo
1454 1757
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1455 1758
 			}
1456 1759
 		}
1457
-		if ($_id == NULL && $this->debugLevel>1)  ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1760
+		if ($_id == NULL && $this->debugLevel>1)
1761
+		{
1762
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1763
+		}
1458 1764
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages));
1459 1765
 		$messagelist = array();
1460
-		if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist;
1766
+		if (!isset($rv_messages['header'])||empty($rv_messages['header']))
1767
+		{
1768
+			return $messagelist;
1769
+		}
1461 1770
 		//if ($_returnModHash) $messageFolderHash = array();
1462 1771
 		foreach ((array)$rv_messages['header'] as $k => $vars)
1463 1772
 		{
1464
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1773
+			if ($this->debugLevel>3)
1774
+			{
1775
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1776
+			}
1465 1777
 			$headers[$vars['uid']] = $vars;
1466
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1467
-			if (!empty($vars['deleted'])) continue; // cut of deleted messages
1468
-			if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it
1469
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1778
+			if ($this->debugLevel>3)
1779
+			{
1780
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1781
+			}
1782
+			if (!empty($vars['deleted']))
1783
+			{
1784
+				continue;
1785
+			}
1786
+			// cut of deleted messages
1787
+			if ($cutoffdate && $vars['date'] < $cutoffdate)
1788
+			{
1789
+				continue;
1790
+			}
1791
+			// message is out of range for cutoffdate, ignore it
1792
+			if ($this->debugLevel>0)
1793
+			{
1794
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1795
+			}
1470 1796
 			$mess = $return_all_headers ? $vars : array();
1471 1797
 			$mess["mod"] = self::doFlagsMod($vars).$vars['date'];
1472 1798
 			$mess["id"] = $vars['uid'];
1473 1799
 			// 'seen' aka 'read' is the only flag we want to know about
1474 1800
 			$mess["flags"] = 0;
1475 1801
 			// outlook supports additional flags, set them to 0
1476
-			if($vars["seen"]) $mess["flags"] = 1;
1477
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1802
+			if($vars["seen"])
1803
+			{
1804
+				$mess["flags"] = 1;
1805
+			}
1806
+			if ($this->debugLevel>3)
1807
+			{
1808
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1809
+			}
1478 1810
 			$messagelist[$vars['uid']] = $mess;
1479 1811
 			unset($mess);
1480 1812
 		}
@@ -1499,9 +1831,18 @@  discard block
 block discarded – undo
1499 1831
 	static function doFlagsMod($headerFlags)
1500 1832
 	{
1501 1833
 		$flags = 'nnn';
1502
-		if ($headerFlags['flagged']) $flags[0] = 'f';
1503
-		if ($headerFlags['answered']) $flags[1] = 'a';
1504
-		if ($headerFlags['forwarded']) $flags[2] = 'f';
1834
+		if ($headerFlags['flagged'])
1835
+		{
1836
+			$flags[0] = 'f';
1837
+		}
1838
+		if ($headerFlags['answered'])
1839
+		{
1840
+			$flags[1] = 'a';
1841
+		}
1842
+		if ($headerFlags['forwarded'])
1843
+		{
1844
+			$flags[2] = 'f';
1845
+		}
1505 1846
 		//ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags));
1506 1847
 		return $flags;
1507 1848
 	}
@@ -1533,31 +1874,55 @@  discard block
 block discarded – undo
1533 1874
 	{
1534 1875
 		//$this->debugLevel=1;
1535 1876
 		$searchquery=$_searchquery->GetDataArray();
1536
-		if (!is_array($searchquery)) return array();
1537
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1877
+		if (!is_array($searchquery))
1878
+		{
1879
+			return array();
1880
+		}
1881
+		if ($this->debugLevel>0)
1882
+		{
1883
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1884
+		}
1538 1885
 
1539
-		if (isset($searchquery['searchrebuildresults'])) {
1886
+		if (isset($searchquery['searchrebuildresults']))
1887
+		{
1540 1888
 			$rebuildresults = $searchquery['searchrebuildresults'];
1541
-		} else {
1889
+		}
1890
+		else
1891
+		{
1542 1892
 			$rebuildresults = false;
1543 1893
 		}
1544
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1894
+		if ($this->debugLevel>0)
1895
+		{
1896
+			ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1897
+		}
1545 1898
 
1546
-		if (isset($searchquery['deeptraversal'])) {
1899
+		if (isset($searchquery['deeptraversal']))
1900
+		{
1547 1901
 			$deeptraversal = $searchquery['deeptraversal'];
1548
-		} else {
1902
+		}
1903
+		else
1904
+		{
1549 1905
 			$deeptraversal = false;
1550 1906
 		}
1551
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1907
+		if ($this->debugLevel>0)
1908
+		{
1909
+			ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1910
+		}
1552 1911
 
1553
-		if (isset($searchquery['searchrange'])) {
1912
+		if (isset($searchquery['searchrange']))
1913
+		{
1554 1914
 			$range = explode("-",$_searchquery->GetSearchRange());
1555 1915
 			$start =$range[0] + 1;
1556 1916
 			$limit = $range[1] - $range[0] + 1;
1557
-		} else {
1917
+		}
1918
+		else
1919
+		{
1558 1920
 			$range = false;
1559 1921
 		}
1560
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1922
+		if ($this->debugLevel>0)
1923
+		{
1924
+			ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1925
+		}
1561 1926
 
1562 1927
 		//foreach($searchquery['query'] as $k => $value) {
1563 1928
 		//	$query = $value;
@@ -1609,7 +1974,10 @@  discard block
 block discarded – undo
1609 1974
 			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts'));
1610 1975
 		}
1611 1976
 		//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
1612
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1977
+		if ($this->debugLevel>1)
1978
+		{
1979
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1980
+		}
1613 1981
 		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL);
1614 1982
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages));
1615 1983
 		$list=array();
@@ -1641,17 +2009,26 @@  discard block
 block discarded – undo
1641 2009
 	private function getParentID($account,$folder)
1642 2010
 	{
1643 2011
 		$this->_connect($account);
1644
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
2012
+		if (!isset($this->folders))
2013
+		{
2014
+			$this->folders = $this->mail->getFolderObjects(true,false);
2015
+		}
1645 2016
 
1646 2017
 		$mailFolder = $this->folders[$folder];
1647
-		if (!isset($mailFolder)) return false;
2018
+		if (!isset($mailFolder))
2019
+		{
2020
+			return false;
2021
+		}
1648 2022
 		$delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter());
1649 2023
 		$parent = explode($delimiter,$folder);
1650 2024
 		array_pop($parent);
1651 2025
 		$parent = implode($delimiter,$parent);
1652 2026
 
1653 2027
 		$id = $parent ? $this->createID($account, $parent) : '0';
1654
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
2028
+		if ($this->debugLevel>1)
2029
+		{
2030
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
2031
+		}
1655 2032
 		return $id;
1656 2033
 	}
1657 2034
 
@@ -1665,7 +2042,10 @@  discard block
 block discarded – undo
1665 2042
 	{
1666 2043
 		static $last_id = null;
1667 2044
 		static $folderObj = null;
1668
-		if (isset($last_id) && $last_id === $id) return $folderObj;
2045
+		if (isset($last_id) && $last_id === $id)
2046
+		{
2047
+			return $folderObj;
2048
+		}
1669 2049
 
1670 2050
 		try {
1671 2051
 			$account = $folder = null;
@@ -1676,18 +2056,30 @@  discard block
 block discarded – undo
1676 2056
 			return $folderObj=false;
1677 2057
 		}
1678 2058
 		$this->_connect($account);
1679
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
2059
+		if (!isset($this->folders))
2060
+		{
2061
+			$this->folders = $this->mail->getFolderObjects(true,false);
2062
+		}
1680 2063
 
1681 2064
 		$mailFolder = $this->folders[$folder];
1682
-		if (!isset($mailFolder)) return $folderObj=false;
2065
+		if (!isset($mailFolder))
2066
+		{
2067
+			return $folderObj=false;
2068
+		}
1683 2069
 
1684 2070
 		$folderObj = new SyncFolder();
1685 2071
 		$folderObj->serverid = $id;
1686 2072
 		$folderObj->parentid = $this->getParentID($account,$folder);
1687 2073
 		$folderObj->displayname = $mailFolder->shortDisplayName;
1688
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
2074
+		if ($this->debugLevel>1)
2075
+		{
2076
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
2077
+		}
1689 2078
 		// get folder-type
1690
-		foreach($this->folders as $inbox => $mailFolder) break;
2079
+		foreach($this->folders as $inbox => $mailFolder)
2080
+		{
2081
+			break;
2082
+		}
1691 2083
 		if ($folder == $inbox)
1692 2084
 		{
1693 2085
 			$folderObj->type = SYNC_FOLDER_TYPE_INBOX;
@@ -1724,7 +2116,10 @@  discard block
 block discarded – undo
1724 2116
 			$folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL;
1725 2117
 		}
1726 2118
 
1727
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
2119
+		if ($this->debugLevel>1)
2120
+		{
2121
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
2122
+		}
1728 2123
 		return $folderObj;
1729 2124
 	}
1730 2125
 
@@ -1768,11 +2163,20 @@  discard block
 block discarded – undo
1768 2163
 	{
1769 2164
 		$account = $folder = null;
1770 2165
 		$this->splitID($folderid, $account, $folder);
1771
-		if (is_numeric($account)) $type = 'mail';
2166
+		if (is_numeric($account))
2167
+		{
2168
+			$type = 'mail';
2169
+		}
1772 2170
 
1773
-		if ($type != 'mail') return false;
2171
+		if ($type != 'mail')
2172
+		{
2173
+			return false;
2174
+		}
1774 2175
 
1775
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
2176
+		if (!isset($this->mail))
2177
+		{
2178
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
2179
+		}
1776 2180
 
1777 2181
         $this->mail->reopen($folder);
1778 2182
 
@@ -1817,7 +2221,7 @@  discard block
 block discarded – undo
1817 2221
      * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1818 2222
      */
1819 2223
     public function DeleteMessage($folderid, $id, $contentParameters)
1820
-	{
2224
+    {
1821 2225
 		unset($contentParameters);	// not used, but required by function signature
1822 2226
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid'  id: '$id' )");
1823 2227
 		/*
@@ -1843,7 +2247,10 @@  discard block
 block discarded – undo
1843 2247
 			$error = $e->getMessage();
1844 2248
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1845 2249
 			// if the server thinks the message does not exist report deletion as success
1846
-			if (stripos($error,'[NONEXISTENT]')!==false) return true;
2250
+			if (stripos($error,'[NONEXISTENT]')!==false)
2251
+			{
2252
+				return true;
2253
+			}
1847 2254
 			return false;
1848 2255
 		}
1849 2256
 
@@ -1876,7 +2283,7 @@  discard block
 block discarded – undo
1876 2283
      * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1877 2284
      */
1878 2285
     public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1879
-	{
2286
+    {
1880 2287
 		unset($contentParameters);	// not used, but required by function signature
1881 2288
 		// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid'  id: '$id'  flags: '$flags' )");
1882 2289
 		$account = $folder = null;
@@ -1962,7 +2369,10 @@  discard block
 block discarded – undo
1962 2369
 
1963 2370
 		$str = $this->backend->createID($account, $folder, $id);
1964 2371
 
1965
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
2372
+		if ($this->debugLevel>1)
2373
+		{
2374
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
2375
+		}
1966 2376
 
1967 2377
 		return $str;
1968 2378
 	}
@@ -1983,7 +2393,10 @@  discard block
 block discarded – undo
1983 2393
 		// convert numeric folder-id back to folder name
1984 2394
 		$folder = $this->hash2folder($account,$f=$folder);
1985 2395
 
1986
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
2396
+		if ($this->debugLevel>1)
2397
+		{
2398
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
2399
+		}
1987 2400
 	}
1988 2401
 
1989 2402
 	/**
@@ -2002,7 +2415,10 @@  discard block
 block discarded – undo
2002 2415
 	 */
2003 2416
 	private function folder2hash($account,$folder)
2004 2417
 	{
2005
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2418
+		if(!isset($this->folderHashes))
2419
+		{
2420
+			$this->readFolderHashes();
2421
+		}
2006 2422
 
2007 2423
 		if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false)
2008 2424
 		{
@@ -2025,7 +2441,10 @@  discard block
 block discarded – undo
2025 2441
 	 */
2026 2442
 	private function hash2folder($account,$index)
2027 2443
 	{
2028
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2444
+		if(!isset($this->folderHashes))
2445
+		{
2446
+			$this->readFolderHashes();
2447
+		}
2029 2448
 
2030 2449
 		return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null;
2031 2450
 	}
Please login to merge, or discard this patch.