Completed
Push — master ( 0e83ef...caafb0 )
by Klaus
42:35 queued 19:54
created
api/src/Mail.php 1 patch
Braces   +1771 added lines, -523 removed lines patch added patch discarded remove patch
@@ -199,7 +199,10 @@  discard block
 block discarded – undo
199 199
 	public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null)
200 200
 	{
201 201
 		//$_restoreSession=false;
202
-		if (is_null($_reuseCache)) $_reuseCache = $_restoreSession;
202
+		if (is_null($_reuseCache))
203
+		{
204
+			$_reuseCache = $_restoreSession;
205
+		}
203 206
 		//error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.'/'.Mail\Account::get_default_acc_id().' for user:'.$GLOBALS['egw_info']['user']['account_lid'].' called from:'.function_backtrace());
204 207
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject));
205 208
 		self::$profileDefunct = Cache::getCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),5*1);
@@ -230,9 +233,15 @@  discard block
 block discarded – undo
230 233
 			{
231 234
 				$profileID = Mail\Account::get_default_acc_id();
232 235
 			}
233
-			if ($profileID!=$_profileID) $_restoreSession==false;
236
+			if ($profileID!=$_profileID)
237
+			{
238
+				$_restoreSession==false;
239
+			}
234 240
 			$_profileID=$profileID;
235
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace());
241
+			if (self::$debug)
242
+			{
243
+				error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace());
244
+			}
236 245
 		}
237 246
 		// no validation or restoreSession for old ImapServer Object, just fetch it and return it
238 247
 		if ($_oldImapServerObject===true)
@@ -271,7 +280,8 @@  discard block
 block discarded – undo
271 280
 				// TODO: merge mailprefs into userprefs, for easy treatment
272 281
 				self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
273 282
 				self::$instances[$_profileID]->htmlOptions  = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
274
-			} catch (\Exception $e)
283
+			}
284
+			catch (\Exception $e)
275 285
 			{
276 286
 				$newprofileID = Mail\Account::get_default_acc_id();
277 287
 				// try loading the default profile for the user
@@ -289,9 +299,15 @@  discard block
 block discarded – undo
289 299
 			self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate );
290 300
 		}
291 301
 		self::$instances[$_profileID]->profileID = $_profileID;
292
-		if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna;
302
+		if (!isset(self::$instances[$_profileID]->idna2))
303
+		{
304
+			self::$instances[$_profileID]->idna2 = new Horde_Idna;
305
+		}
293 306
 		//if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID);
294
-		if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
307
+		if (is_null(self::$mailConfig))
308
+		{
309
+			self::$mailConfig = Config::read('mail');
310
+		}
295 311
 		return self::$instances[$_profileID];
296 312
 	}
297 313
 
@@ -316,14 +332,20 @@  discard block
 block discarded – undo
316 332
 			}
317 333
 			catch (\Exception $e)
318 334
 			{
319
-				if ($_profileID != Mail\Account::get_default_acc_id()) $_profileID = Mail\Account::get_default_acc_id();
335
+				if ($_profileID != Mail\Account::get_default_acc_id())
336
+				{
337
+					$_profileID = Mail\Account::get_default_acc_id();
338
+				}
320 339
 				error_log(__METHOD__.__LINE__.' '.$e->getMessage());
321 340
 				return false;
322 341
 			}
323 342
 		}
324 343
 		if ($oldProfileID != $_profileID)
325 344
 		{
326
-			if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID;
345
+			if ($oldProfileID && $_profileID==0)
346
+			{
347
+				$_profileID = $oldProfileID;
348
+			}
327 349
 			$GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user');
328 350
 			// save prefs
329 351
 			$GLOBALS['egw']->preferences->save_repository(true);
@@ -353,11 +375,17 @@  discard block
 block discarded – undo
353 375
 				{
354 376
 					return $_acc_id;
355 377
 				}
356
-				if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!");
378
+				if (self::$debug)
379
+				{
380
+					error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!");
381
+				}
357 382
 			}
358 383
 			catch (\Exception $e) {
359 384
 				unset($e);
360
-				if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!");
385
+				if (self::$debug)
386
+				{
387
+					error_log(__METHOD__."($_acc_id) account NOT found!");
388
+				}
361 389
 			}
362 390
 		}
363 391
 		// no account specified or specified account not found or not valid
@@ -366,11 +394,17 @@  discard block
 block discarded – undo
366 394
 		{
367 395
 			if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap())
368 396
 			{
369
-				if (self::$debug && $_acc_id) error_log(__METHOD__."($_acc_id) using $acc_id instead");
397
+				if (self::$debug && $_acc_id)
398
+				{
399
+					error_log(__METHOD__."($_acc_id) using $acc_id instead");
400
+				}
370 401
 				return $acc_id;
371 402
 			}
372 403
 		}
373
-		if (self::$debug) error_log(__METHOD__."($_acc_id) NO valid account found!");
404
+		if (self::$debug)
405
+		{
406
+			error_log(__METHOD__."($_acc_id) NO valid account found!");
407
+		}
374 408
 		return 0;
375 409
 	}
376 410
 
@@ -386,10 +420,19 @@  discard block
 block discarded – undo
386 420
 	 */
387 421
 	private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null)
388 422
 	{
389
-		if (is_null($_reuseCache)) $_reuseCache = $_restoreSession;
390
-		if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset;
423
+		if (is_null($_reuseCache))
424
+		{
425
+			$_reuseCache = $_restoreSession;
426
+		}
427
+		if (!empty($_displayCharset))
428
+		{
429
+			self::$displayCharset = $_displayCharset;
430
+		}
391 431
 		// not nummeric, we assume we only want an empty class object
392
-		if (!is_numeric($_profileID)) return true;
432
+		if (!is_numeric($_profileID))
433
+		{
434
+			return true;
435
+		}
393 436
 		if ($_restoreSession)
394 437
 		{
395 438
 			//error_log(__METHOD__." Session restore ".function_backtrace());
@@ -404,7 +447,10 @@  discard block
 block discarded – undo
404 447
 			$firstMessage = $this->sessionData['previewMessage'];
405 448
 			$this->sessionData = array();
406 449
 		}
407
-		if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache);
450
+		if (!$_reuseCache)
451
+		{
452
+			$this->forcePrefReload($_profileID,!$_reuseCache);
453
+		}
408 454
 		try
409 455
 		{
410 456
 			$this->profileID = self::validateProfileID($_profileID);
@@ -428,7 +474,10 @@  discard block
 block discarded – undo
428 474
 			$_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId;
429 475
 		}
430 476
 
431
-		if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
477
+		if (is_null(self::$mailConfig))
478
+		{
479
+			self::$mailConfig = Config::read('mail');
480
+		}
432 481
 	}
433 482
 
434 483
 	/**
@@ -457,7 +506,10 @@  discard block
 block discarded – undo
457 506
 		// unset the mail_preferences session object, to force the reload/rebuild
458 507
 		Cache::setSession('mail','mail_preferences',serialize(array()));
459 508
 		Cache::setSession('emailadmin','session_data',serialize(array()));
460
-		if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id);
509
+		if ($_resetFolderObjects)
510
+		{
511
+			self::resetFolderObjectCache($_profile_id);
512
+		}
461 513
 	}
462 514
 
463 515
 	/**
@@ -467,7 +519,10 @@  discard block
 block discarded – undo
467 519
 	{
468 520
 		$this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1);
469 521
 		self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
470
-		if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID];
522
+		if (!empty(self::$activeFolderCache[$this->profileID]))
523
+		{
524
+			$this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID];
525
+		}
471 526
 	}
472 527
 
473 528
 	/**
@@ -476,7 +531,10 @@  discard block
 block discarded – undo
476 531
 	function saveSessionData()
477 532
 	{
478 533
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData)));
479
-		if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox'];
534
+		if (!empty($this->sessionData['mailbox']))
535
+		{
536
+			self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox'];
537
+		}
480 538
 		if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache))
481 539
 		{
482 540
 			Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10);
@@ -497,8 +555,14 @@  discard block
 block discarded – undo
497 555
 	 */
498 556
 	static function unsetCachedObjects($_profileID=null)
499 557
 	{
500
-		if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id();
501
-		if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id'];
558
+		if (is_null($_profileID))
559
+		{
560
+			$_profileID = Mail\Account::get_default_acc_id();
561
+		}
562
+		if (is_array($_profileID) && $_profileID['account_id'])
563
+		{
564
+			$account_id = $_profileID['account_id'];
565
+		}
502 566
 		//error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace());
503 567
 		if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false)))
504 568
 		{
@@ -531,7 +595,10 @@  discard block
 block discarded – undo
531 595
 				Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1);
532 596
 			}
533 597
 
534
-			if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]);
598
+			if (isset(self::$instances[$_profileID]))
599
+			{
600
+				unset(self::$instances[$_profileID]);
601
+			}
535 602
 		}
536 603
 		if (is_array($_profileID) && $_profileID['location'] == 'clear_cache')
537 604
 		{
@@ -560,7 +627,10 @@  discard block
 block discarded – undo
560 627
 	static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null)
561 628
 	{
562 629
 		//error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id));
563
-		if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
630
+		if (is_null($account_id))
631
+		{
632
+			$account_id = $GLOBALS['egw_info']['user']['account_id'];
633
+		}
564 634
 		if (is_array($_ImapServerId))
565 635
 		{
566 636
 			// called via hook
@@ -599,7 +669,10 @@  discard block
 block discarded – undo
599 669
 	static function resetFolderObjectCache($_ImapServerId=null,$account_id=null)
600 670
 	{
601 671
 		//error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace());
602
-		if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
672
+		if (is_null($account_id))
673
+		{
674
+			$account_id = $GLOBALS['egw_info']['user']['account_id'];
675
+		}
603 676
 		// on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId
604 677
 		// or treat it as not given. we try that path
605 678
 		if (is_null($_ImapServerId)||is_array($_ImapServerId))
@@ -673,10 +746,14 @@  discard block
 block discarded – undo
673 746
 
674 747
 		$userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']);
675 748
 
676
-		foreach($identities as $ik => $ident) {
749
+		foreach($identities as $ik => $ident)
750
+		{
677 751
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
678 752
 			$identity = Mail\Account::read_identity($ik);
679
-			if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
753
+			if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']]))
754
+			{
755
+				$userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
756
+			}
680 757
 		}
681 758
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses));
682 759
 		return $userEMailAdresses;
@@ -694,13 +771,20 @@  discard block
 block discarded – undo
694 771
 		foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name)
695 772
 		{
696 773
 			$acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null));
697
-			if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
774
+			if (!$resolve_placeholders)
775
+			{
776
+				$userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
777
+			}
698 778
 
699
-			foreach(Mail\Account::identities($acc) as $ik => $ident) {
779
+			foreach(Mail\Account::identities($acc) as $ik => $ident)
780
+			{
700 781
 				//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
701 782
 				$identity = Mail\Account::read_identity($ik,$resolve_placeholders);
702 783
 				//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
703
-				if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']);
784
+				if (!isset($userEMailAdresses[$identity['ident_id']]))
785
+				{
786
+					$userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']);
787
+				}
704 788
 			}
705 789
 		}
706 790
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses));
@@ -720,12 +804,16 @@  discard block
 block discarded – undo
720 804
 			$account = Mail\Account::read($account);
721 805
 		}
722 806
 		$userEMailAdresses = array();
723
-		foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) {
807
+		foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident)
808
+		{
724 809
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
725 810
 			$identity = Mail\Account::read_identity($ik,true,null,$account);
726 811
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
727 812
 			// standardIdentity has ident_id==acc_id (as it is done within account->identities)
728
-			if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id'];
813
+			if (empty($identity['ident_id']))
814
+			{
815
+				$identity['ident_id'] = $identity['acc_id'];
816
+			}
729 817
 			if (!isset($userEMailAdresses[$identity['ident_id']]))
730 818
 			{
731 819
 				$userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$identity['acc_id'],
@@ -768,15 +856,25 @@  discard block
 block discarded – undo
768 856
 		// account select box
769 857
 		$selectedID = $this->profileID;
770 858
 		$allAccountData = Mail\Account::search($only_current_user=true, false, null);
771
-		if ($allAccountData) {
859
+		if ($allAccountData)
860
+		{
772 861
 			$rememberFirst=$selectedFound=null;
773 862
 			foreach ($allAccountData as $tmpkey => $icServers)
774 863
 			{
775
-				if (is_null($rememberFirst)) $rememberFirst = $tmpkey;
776
-				if ($tmpkey == $selectedID) $selectedFound=true;
864
+				if (is_null($rememberFirst))
865
+				{
866
+					$rememberFirst = $tmpkey;
867
+				}
868
+				if ($tmpkey == $selectedID)
869
+				{
870
+					$selectedFound=true;
871
+				}
777 872
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host));
778 873
 				$host = $icServers->acc_imap_host;
779
-				if (empty($host)) continue;
874
+				if (empty($host))
875
+				{
876
+					continue;
877
+				}
780 878
 				$identities[$icServers->acc_id] = $icServers['ident_realname'].' '.$icServers['ident_org'].' <'.$icServers['ident_email'].'>';
781 879
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id]));
782 880
 			}
@@ -836,7 +934,10 @@  discard block
 block discarded – undo
836 934
 	 */
837 935
 	function reopen($_foldername)
838 936
 	{
839
-		if (self::$debugTimes) $starttime = microtime (true);
937
+		if (self::$debugTimes)
938
+		{
939
+			$starttime = microtime (true);
940
+		}
840 941
 
841 942
 		//error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace());
842 943
 		// TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of
@@ -846,12 +947,16 @@  discard block
 block discarded – undo
846 947
 		//{
847 948
 			//error_log( __METHOD__.' ('.__LINE__.') '." $_foldername ".function_backtrace());
848 949
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Connected with icServer for Profile:'.$this->profileID.'?'.print_r($this->icServer->_connected,true));
849
-			if ($this->folderIsSelectable($_foldername)) {
950
+			if ($this->folderIsSelectable($_foldername))
951
+			{
850 952
 				$this->icServer->openMailbox($_foldername);
851 953
 			}
852 954
 			$folderOpened = $_foldername;
853 955
 		//}
854
-		if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') ');
956
+		if (self::$debugTimes)
957
+		{
958
+			self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') ');
959
+		}
855 960
 	}
856 961
 
857 962
 
@@ -866,13 +971,22 @@  discard block
 block discarded – undo
866 971
 	{
867 972
 		//error_log( "-------------------------->open connection ".function_backtrace());
868 973
 		//error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer));
869
-		if (self::$debugTimes) $starttime = microtime (true);
974
+		if (self::$debugTimes)
975
+		{
976
+			$starttime = microtime (true);
977
+		}
870 978
 		$mailbox=null;
871 979
 		try
872 980
 		{
873
-			if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox'];
874
-			if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox();
875
-/*
981
+			if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox']))
982
+			{
983
+				$mailbox = $this->sessionData['mailbox'];
984
+			}
985
+			if (empty($mailbox))
986
+			{
987
+				$mailbox = $this->icServer->getCurrentMailbox();
988
+			}
989
+			/*
876 990
 			if (isset(Mail\Imap::$supports_keywords[$_icServerID]))
877 991
 			{
878 992
 				$this->icServer->openMailbox($mailbox);
@@ -897,7 +1011,10 @@  discard block
 block discarded – undo
897 1011
 			error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage());
898 1012
 			throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage());
899 1013
 		}
900
-		if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') ');
1014
+		if (self::$debugTimes)
1015
+		{
1016
+			self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') ');
1017
+		}
901 1018
 	}
902 1019
 
903 1020
 	/**
@@ -909,7 +1026,10 @@  discard block
 block discarded – undo
909 1026
 	function getQuotaRoot()
910 1027
 	{
911 1028
 		static $quota;
912
-		if (isset($quota)) return $quota;
1029
+		if (isset($quota))
1030
+		{
1031
+			return $quota;
1032
+		}
913 1033
 		if (isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID]))
914 1034
 		{
915 1035
 			// something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request
@@ -918,7 +1038,8 @@  discard block
 block discarded – undo
918 1038
 		try
919 1039
 		{
920 1040
 			$this->icServer->getCurrentMailbox();
921
-			if(!$this->icServer->hasCapability('QUOTA')) {
1041
+			if(!$this->icServer->hasCapability('QUOTA'))
1042
+			{
922 1043
 				$quota = false;
923 1044
 				return false;
924 1045
 			}
@@ -936,12 +1057,15 @@  discard block
 block discarded – undo
936 1057
 			}
937 1058
 		}
938 1059
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota));
939
-		if(is_array($quota)) {
1060
+		if(is_array($quota))
1061
+		{
940 1062
 			$quota = array(
941 1063
 				'usage'	=> $quota['USED'],
942 1064
 				'limit'	=> $quota['QMAX'],
943 1065
 			);
944
-		} else {
1066
+		}
1067
+		else
1068
+		{
945 1069
 			$quota = false;
946 1070
 		}
947 1071
 		return $quota;
@@ -957,7 +1081,11 @@  discard block
 block discarded – undo
957 1081
 	static function getTimeOut($_use='IMAP')
958 1082
 	{
959 1083
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
960
-		if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value
1084
+		if (empty($timeout))
1085
+		{
1086
+			$timeout = ($_use=='SIEVE'?10:20);
1087
+		}
1088
+		// this is the default value
961 1089
 		return $timeout;
962 1090
 	}
963 1091
 
@@ -975,9 +1103,13 @@  discard block
 block discarded – undo
975 1103
 		$foldersNameSpace = array();
976 1104
 		$delimiter = $this->getHierarchyDelimiter();
977 1105
 		// TODO: cache by $this->icServer->ImapServerId
978
-		if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray();
1106
+		if (is_null($nameSpace))
1107
+		{
1108
+			$nameSpace = $this->icServer->getNameSpaceArray();
1109
+		}
979 1110
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace));
980
-		if (is_array($nameSpace)) {
1111
+		if (is_array($nameSpace))
1112
+		{
981 1113
 			foreach($nameSpace as $type => $singleNameSpaceArray)
982 1114
 			{
983 1115
 				foreach ($singleNameSpaceArray as $singleNameSpace)
@@ -994,7 +1126,9 @@  discard block
 block discarded – undo
994 1126
 						$_foldersNameSpace['prefix_present'] = 'forced';
995 1127
 						// uw-imap server with mailbox prefix or dovecot maybe
996 1128
 						$_foldersNameSpace['prefix'] = 'mail';
997
-					} else {
1129
+					}
1130
+					else
1131
+					{
998 1132
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
999 1133
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
1000 1134
 					}
@@ -1021,7 +1155,10 @@  discard block
 block discarded – undo
1021 1155
 		foreach($nameSpace as &$singleNameSpace)
1022 1156
 		{
1023 1157
 			//if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix'];
1024
-			if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix'];
1158
+			if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix'])
1159
+			{
1160
+				return $singleNameSpace['prefix'];
1161
+			}
1025 1162
 		}
1026 1163
 		return "";
1027 1164
 	}
@@ -1035,8 +1172,14 @@  discard block
 block discarded – undo
1035 1172
 	function getHierarchyDelimiter($_useCache=true)
1036 1173
 	{
1037 1174
 		static $HierarchyDelimiter = null;
1038
-		if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1039
-		if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
1175
+		if (is_null($HierarchyDelimiter))
1176
+		{
1177
+			$HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1178
+		}
1179
+		if ($_useCache===false)
1180
+		{
1181
+			unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
1182
+		}
1040 1183
 		if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId]))
1041 1184
 		{
1042 1185
 			return $HierarchyDelimiter[$this->icServer->ImapServerId];
@@ -1070,14 +1213,19 @@  discard block
 block discarded – undo
1070 1213
 	{
1071 1214
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected);
1072 1215
 		static $_specialUseFolders = null;
1073
-		if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1216
+		if (is_null($_specialUseFolders)||empty($_specialUseFolders))
1217
+		{
1218
+			$_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1219
+		}
1074 1220
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash));
1075 1221
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent));
1076 1222
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft));
1077 1223
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template));
1078 1224
 		self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
1079 1225
 		if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId]))
1080
-			return $_specialUseFolders[$this->icServer->ImapServerId];
1226
+		{
1227
+					return $_specialUseFolders[$this->icServer->ImapServerId];
1228
+		}
1081 1229
 		$_specialUseFolders[$this->icServer->ImapServerId]=array();
1082 1230
 		//if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]))
1083 1231
 			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash';
@@ -1105,7 +1253,8 @@  discard block
 block discarded – undo
1105 1253
 	function folderIsSelectable($folderToSelect)
1106 1254
 	{
1107 1255
 		$retval = true;
1108
-		if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) {
1256
+		if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true)))
1257
+		{
1109 1258
 			if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false)
1110 1259
 			{
1111 1260
 				$retval = false;
@@ -1158,7 +1307,10 @@  discard block
 block discarded – undo
1158 1307
 	 */
1159 1308
 	function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true)
1160 1309
 	{
1161
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly");
1310
+		if (self::$debug)
1311
+		{
1312
+			error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly");
1313
+		}
1162 1314
 		if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID])))
1163 1315
 		{
1164 1316
 			// something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request
@@ -1170,7 +1322,10 @@  discard block
 block discarded – undo
1170 1322
 		{
1171 1323
 			$folderInfoCache = $folderBasicInfo[$this->profileID];
1172 1324
 		}
1173
-		if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName];
1325
+		if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly)
1326
+		{
1327
+			return $folderInfoCache[$_folderName];
1328
+		}
1174 1329
 		$retValue = array();
1175 1330
 		$retValue['subscribed'] = false;
1176 1331
 /*
@@ -1199,7 +1354,10 @@  discard block
 block discarded – undo
1199 1354
 			if (is_array($ret))
1200 1355
 			{
1201 1356
 				$retkeys = array_keys($ret);
1202
-				if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]];
1357
+				if ($retkeys[0]==$_folderName)
1358
+				{
1359
+					$folderInfoCache[$_folderName] = $ret[$retkeys[0]];
1360
+				}
1203 1361
 			}
1204 1362
 			else
1205 1363
 			{
@@ -1208,7 +1366,8 @@  discard block
 block discarded – undo
1208 1366
 		}
1209 1367
 		$folderInfo = $folderInfoCache[$_folderName];
1210 1368
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace());
1211
-		if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) {
1369
+		if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo))
1370
+		{
1212 1371
 			try
1213 1372
 			{
1214 1373
 				$folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache);
@@ -1243,7 +1402,8 @@  discard block
 block discarded – undo
1243 1402
 		$retValue['shortName']		= array_pop($shortNameParts);
1244 1403
 		$retValue['displayName']	= $_folderName;
1245 1404
 		$retValue['shortDisplayName']	= $retValue['shortName'];
1246
-		if(strtoupper($retValue['shortName']) == 'INBOX') {
1405
+		if(strtoupper($retValue['shortName']) == 'INBOX')
1406
+		{
1247 1407
 			$retValue['displayName']	= lang('INBOX');
1248 1408
 			$retValue['shortDisplayName']	= lang('INBOX');
1249 1409
 		}
@@ -1252,7 +1412,10 @@  discard block
 block discarded – undo
1252 1412
 		{
1253 1413
 			$retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']);
1254 1414
 		}
1255
-		if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue;
1415
+		if ($folderInfo)
1416
+		{
1417
+			$folderBasicInfo[$this->profileID][$_folderName]=$retValue;
1418
+		}
1256 1419
 		//error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes']));
1257 1420
 		if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false))
1258 1421
 		{
@@ -1264,24 +1427,34 @@  discard block
 block discarded – undo
1264 1427
 		static $subscribedFolders = null;
1265 1428
 		static $nameSpace = null;
1266 1429
 		static $prefix = null;
1267
-		if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces();
1430
+		if (is_null($nameSpace) || empty($nameSpace[$this->profileID]))
1431
+		{
1432
+			$nameSpace[$this->profileID] = $this->_getNameSpaces();
1433
+		}
1268 1434
 		if (!empty($nameSpace[$this->profileID]))
1269 1435
 		{
1270 1436
 			$nsNoPersonal=array();
1271 1437
 			foreach($nameSpace[$this->profileID] as &$ns)
1272 1438
 			{
1273
-				if ($ns['type']!='personal') $nsNoPersonal[]=$ns;
1439
+				if ($ns['type']!='personal')
1440
+				{
1441
+					$nsNoPersonal[]=$ns;
1442
+				}
1274 1443
 			}
1275 1444
 			$nameSpace[$this->profileID]=$nsNoPersonal;
1276 1445
 		}
1277
-		if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName);
1446
+		if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName]))
1447
+		{
1448
+			$prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName);
1449
+		}
1278 1450
 
1279 1451
 		if ($fetchSubscribedInfo && is_null($subscribedFolders) || empty($subscribedFolders[$this->profileID]))
1280 1452
 		{
1281 1453
 			$subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes();
1282 1454
 		}
1283 1455
 
1284
-		if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) {
1456
+		if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID]))
1457
+		{
1285 1458
 			$retValue['subscribed'] = true;
1286 1459
 		}
1287 1460
 
@@ -1300,8 +1473,7 @@  discard block
 block discarded – undo
1300 1473
 				(isset($this->mailPreferences['trustServersUnseenInfo']) &&
1301 1474
 				$this->mailPreferences['trustServersUnseenInfo']==2 &&
1302 1475
 				$prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false)
1303
-			)
1304
-			{
1476
+			) {
1305 1477
 				//error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']);
1306 1478
 				// we filter for the combined status of unseen and undeleted, as this is what we show in list
1307 1479
 				try
@@ -1312,13 +1484,19 @@  discard block
 block discarded – undo
1312 1484
 				}
1313 1485
 				catch (\Exception $ee)
1314 1486
 				{
1315
-					if (self::$debug) error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested.");
1487
+					if (self::$debug)
1488
+					{
1489
+						error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested.");
1490
+					}
1316 1491
 				}
1317 1492
 			}
1318 1493
 		}
1319 1494
 		catch (\Exception $e)
1320 1495
 		{
1321
-			if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true));
1496
+			if (self::$debug)
1497
+			{
1498
+				error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true));
1499
+			}
1322 1500
 		}
1323 1501
 
1324 1502
 		return $retValue;
@@ -1343,8 +1521,14 @@  discard block
 block discarded – undo
1343 1521
 	function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false)
1344 1522
 	{
1345 1523
 		//self::$debug=true;
1346
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace());
1347
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly");
1524
+		if (self::$debug)
1525
+		{
1526
+			error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace());
1527
+		}
1528
+		if (self::$debug)
1529
+		{
1530
+			error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly");
1531
+		}
1348 1532
 		$reverse = (bool)$_reverse;
1349 1533
 		// get the list of messages to fetch
1350 1534
 		$this->reopen($_folderName);
@@ -1365,21 +1549,34 @@  discard block
 block discarded – undo
1365 1549
 				//$_filter['range'] ="$start:$end";
1366 1550
 				//$_filter['range'] ="$_startMessage:*";
1367 1551
 			}
1368
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid");
1369
-			if (self::$debug||self::$debugTimes) $starttime = microtime (true);
1552
+			if (self::$debug)
1553
+			{
1554
+				error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid");
1555
+			}
1556
+			if (self::$debug||self::$debugTimes)
1557
+			{
1558
+				$starttime = microtime (true);
1559
+			}
1370 1560
 			//see this example below for a 12 week datefilter (since)
1371 1561
 			//$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12)));
1372 1562
 			$_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult);
1373 1563
 			$sortResult = $_sortResult['match']->ids;
1374 1564
 			//$modseq = $_sortResult['modseq'];
1375 1565
 			//error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq);
1376
-			if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') ');
1566
+			if (self::$debug||self::$debugTimes)
1567
+			{
1568
+				self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') ');
1569
+			}
1377 1570
 
1378
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1571
+			if (self::$debug)
1572
+			{
1573
+				error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1574
+			}
1379 1575
 			#$this->icServer->setDebug(false);
1380 1576
 			#print "</pre>";
1381 1577
 			// nothing found
1382
-			if(!is_array($sortResult) || empty($sortResult)) {
1578
+			if(!is_array($sortResult) || empty($sortResult))
1579
+			{
1383 1580
 				$retValue = array();
1384 1581
 				$retValue['info']['total']	= 0;
1385 1582
 				$retValue['info']['first']	= 0;
@@ -1391,7 +1588,8 @@  discard block
 block discarded – undo
1391 1588
 			#_debug_array($sortResult);
1392 1589
 			#_debug_array(array_slice($sortResult, -5, -2));
1393 1590
 			//error_log("REVERSE: $reverse");
1394
-			if($reverse === true) {
1591
+			if($reverse === true)
1592
+			{
1395 1593
 				if  ($_startMessage<=$total)
1396 1594
 				{
1397 1595
 					$startMessage = $_startMessage-1;
@@ -1403,7 +1601,10 @@  discard block
 block discarded – undo
1403 1601
 					{
1404 1602
 						$numberOfMessages = $total%$_numberOfMessages;
1405 1603
 						//$numberOfMessages = abs($_startMessage-$total-1);
1406
-						if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages;
1604
+						if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages)
1605
+						{
1606
+							$_numberOfMessages = $numberOfMessages;
1607
+						}
1407 1608
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total);
1408 1609
 					}
1409 1610
 					$startMessage=($total-$_numberOfMessages)-1;
@@ -1417,19 +1618,36 @@  discard block
 block discarded – undo
1417 1618
 					//$retValue['info']['first'] = $startMessage;
1418 1619
 					//$retValue['info']['last'] = $total;
1419 1620
 				}
1420
-				if($startMessage > 0) {
1421
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult));
1621
+				if($startMessage > 0)
1622
+				{
1623
+					if (self::$debug)
1624
+					{
1625
+						error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult));
1626
+					}
1422 1627
 					$sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage);
1423
-				} else {
1424
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult));
1628
+				}
1629
+				else
1630
+				{
1631
+					if (self::$debug)
1632
+					{
1633
+						error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult));
1634
+					}
1425 1635
 					$sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1)));
1426 1636
 				}
1427 1637
 				$sortResult = array_reverse($sortResult);
1428
-			} else {
1429
-				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult));
1638
+			}
1639
+			else
1640
+			{
1641
+				if (self::$debug)
1642
+				{
1643
+					error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult));
1644
+				}
1430 1645
 				$sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages);
1431 1646
 			}
1432
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1647
+			if (self::$debug)
1648
+			{
1649
+				error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1650
+			}
1433 1651
 		}
1434 1652
 		else
1435 1653
 		{
@@ -1438,7 +1656,10 @@  discard block
 block discarded – undo
1438 1656
 
1439 1657
 
1440 1658
 		// fetch the data for the selected messages
1441
-		if (self::$debug||self::$debugTimes) $starttime = microtime(true);
1659
+		if (self::$debug||self::$debugTimes)
1660
+		{
1661
+			$starttime = microtime(true);
1662
+		}
1442 1663
 		try
1443 1664
 		{
1444 1665
 			$uidsToFetch = new Horde_Imap_Client_Ids();
@@ -1462,7 +1683,10 @@  discard block
 block discarded – undo
1462 1683
 			$fquery->flags();
1463 1684
 			$fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time
1464 1685
 			// if $_fetchPreviews is activated fetch part of the messages too
1465
-			if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0));
1686
+			if ($_fetchPreviews)
1687
+			{
1688
+				$fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0));
1689
+			}
1466 1690
 			$headersNew = $this->icServer->fetch($_folderName, $fquery, array(
1467 1691
 				'ids' => $uidsToFetch,
1468 1692
 			));
@@ -1485,14 +1709,20 @@  discard block
 block discarded – undo
1485 1709
 
1486 1710
 		$cnt = 0;
1487 1711
 
1488
-		foreach((array)$sortResult as $uid) {
1712
+		foreach((array)$sortResult as $uid)
1713
+		{
1489 1714
 			$sortOrder[$uid] = $cnt++;
1490 1715
 		}
1491 1716
 
1492 1717
 		$count = 0;
1493
-		if (is_object($headersNew)) {
1494
-			if (self::$debug||self::$debugTimes) $starttime = microtime(true);
1495
-			foreach($headersNew->ids() as $id) {
1718
+		if (is_object($headersNew))
1719
+		{
1720
+			if (self::$debug||self::$debugTimes)
1721
+			{
1722
+				$starttime = microtime(true);
1723
+			}
1724
+			foreach($headersNew->ids() as $id)
1725
+			{
1496 1726
 				$_headerObject = $headersNew->get($id);
1497 1727
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject));
1498 1728
 				$headerObject = array();
@@ -1505,7 +1735,10 @@  discard block
 block discarded – undo
1505 1735
 				// Get already cached headers, 'fetchHeaders' is a label matchimg above
1506 1736
 				$headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray();
1507 1737
 				// Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com
1508
-				if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray();
1738
+				if (empty($headerForPrio))
1739
+				{
1740
+					$headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray();
1741
+				}
1509 1742
 				//fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns
1510 1743
 				//nothing worthwhile (as it does for googlemail accounts, when preview is switched on
1511 1744
 				if ($_fetchPreviews)
@@ -1516,12 +1749,16 @@  discard block
 block discarded – undo
1516 1749
 					if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio['']))
1517 1750
 					{
1518 1751
 						$length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL);
1519
-						if ($length===false) $length = strlen($bodyPreview);
1752
+						if ($length===false)
1753
+						{
1754
+							$length = strlen($bodyPreview);
1755
+						}
1520 1756
 						$headerForPrio =  Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray();
1521 1757
 					}
1522 1758
 				}
1523 1759
 				$headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER);
1524
-				if (self::$debug) {
1760
+				if (self::$debug)
1761
+				{
1525 1762
 					error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(),'Y-m-d H:i:s'));
1526 1763
 					error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio));
1527 1764
 				}
@@ -1531,11 +1768,16 @@  discard block
 block discarded – undo
1531 1768
 					$total--;
1532 1769
 					continue;
1533 1770
 				}
1534
-				if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) {
1771
+				if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) )
1772
+				{
1535 1773
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO']));
1536
-				} else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) {
1774
+				}
1775
+				else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) )
1776
+				{
1537 1777
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO']));
1538
-				} else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) {
1778
+				}
1779
+				else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) )
1780
+				{
1539 1781
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO']));
1540 1782
 				} /*else $sent_not = "";*/
1541 1783
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject));
@@ -1566,7 +1808,11 @@  discard block
 block discarded – undo
1566 1808
 						$rfcAddr = self::parseAddressList($ad); // does some fixing of known problems too
1567 1809
 						foreach ($rfcAddr as $_rfcAddr)
1568 1810
 						{
1569
-							if (!$_rfcAddr->valid)	continue; // skip. not a valid address
1811
+							if (!$_rfcAddr->valid)
1812
+							{
1813
+								continue;
1814
+							}
1815
+							// skip. not a valid address
1570 1816
 							$address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal);
1571 1817
 						}
1572 1818
 					}
@@ -1582,7 +1828,10 @@  discard block
 block discarded – undo
1582 1828
 				{
1583 1829
 					// $bodyPreview is populated at the beginning of the loop, as it may be
1584 1830
 					// needed to parse the Headers of the Message
1585
-					if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg();
1831
+					if (empty($bodyPreview))
1832
+					{
1833
+						$bodyPreview = $_headerObject->getFullMsg();
1834
+					}
1586 1835
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview));
1587 1836
 					$base = Horde_Mime_Part::parseMessage($bodyPreview);
1588 1837
 					foreach($base->partIterator() as $part)
@@ -1595,7 +1844,8 @@  discard block
 block discarded – undo
1595 1844
 												'encode' => Horde_Mime_Part::ENCODE_BINARY,	// otherwise we cant recode charset
1596 1845
 											)), $charset, 'utf-8');
1597 1846
 							$headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews))));
1598
-						} elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart')
1847
+						}
1848
+						elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart')
1599 1849
 						{
1600 1850
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($part));
1601 1851
 						}
@@ -1611,7 +1861,10 @@  discard block
 block discarded – undo
1611 1861
 				$messageMimeType='';
1612 1862
 				foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type)
1613 1863
 				{
1614
-					if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type;
1864
+					if ($mime_id==0 || $messageMimeType==='')
1865
+					{
1866
+						$messageMimeType = $mime_type;
1867
+					}
1615 1868
 					$part = $mailStructureObject->getPart($mime_id);
1616 1869
 					$partdisposition = $part->getDisposition();
1617 1870
 					$partPrimaryType = $part->getPrimaryType();
@@ -1621,7 +1874,8 @@  discard block
 block discarded – undo
1621 1874
 					// bodypreview could be found (multipart/....)
1622 1875
 					if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') &&
1623 1876
 						((intval($mime_id) === 1) || !$mime_id) &&
1624
-						($partdisposition !== 'attachment')) {
1877
+						($partdisposition !== 'attachment'))
1878
+					{
1625 1879
 							$_structure=$part;
1626 1880
 							$this->fetchPartContents($uid, $_structure, false,true);
1627 1881
 							$headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews))));
@@ -1643,10 +1897,19 @@  discard block
 block discarded – undo
1643 1897
 					if ($mime_type=='message/rfc822')
1644 1898
 					{
1645 1899
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap()));
1646
-						foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;}
1900
+						foreach($part->contentTypeMap() as $sub_id => $sub_type)
1901
+						{
1902
+if ($sub_id != $mime_id)
1903
+						{
1904
+							$skipParts[$sub_id] = $sub_type;
1905
+						}
1906
+						}
1647 1907
 					}
1648 1908
 					//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts));
1649
-					if (array_key_exists($mime_id,$skipParts)) continue;
1909
+					if (array_key_exists($mime_id,$skipParts))
1910
+					{
1911
+						continue;
1912
+					}
1650 1913
 					if ($partdisposition=='attachment' ||
1651 1914
 						($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs
1652 1915
 						($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) ||
@@ -1657,7 +1920,10 @@  discard block
 block discarded – undo
1657 1920
 						$headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid;
1658 1921
 						$headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid;
1659 1922
 						$headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id;
1660
-						if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName();
1923
+						if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))
1924
+						{
1925
+							$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName();
1926
+						}
1661 1927
 						if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') ||
1662 1928
 							$headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef')
1663 1929
 						{
@@ -1671,18 +1937,27 @@  discard block
 block discarded – undo
1671 1937
 				//error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (plain):'.array2string($mailStructureObject->findBody('plain')));
1672 1938
 				//error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (html):'.array2string($mailStructureObject->findBody('html')));
1673 1939
 				//if($count == 0) error_log(__METHOD__.array2string($headerObject));
1674
-				if (empty($headerObject['UID'])) continue;
1940
+				if (empty($headerObject['UID']))
1941
+				{
1942
+					continue;
1943
+				}
1675 1944
 				//$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']);
1676 1945
 				// make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime
1677
-				if(substr($headerObject['DATE'],-2) === 'UT') {
1946
+				if(substr($headerObject['DATE'],-2) === 'UT')
1947
+				{
1678 1948
 					$headerObject['DATE'] .= 'C';
1679 1949
 				}
1680
-				if(substr($headerObject['INTERNALDATE'],-2) === 'UT') {
1950
+				if(substr($headerObject['INTERNALDATE'],-2) === 'UT')
1951
+				{
1681 1952
 					$headerObject['INTERNALDATE'] .= 'C';
1682 1953
 				}
1683 1954
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#');
1684 1955
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']);
1685
-				if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;}
1956
+				if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS']))
1957
+				{
1958
+					foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;
1959
+				}
1960
+				}
1686 1961
 				$retValue['header'][$sortOrder[$uid]]['subject']	= $this->decode_subject($headerObject['SUBJECT']);
1687 1962
 				$retValue['header'][$sortOrder[$uid]]['size'] 		= $headerObject['SIZE'];
1688 1963
 				$retValue['header'][$sortOrder[$uid]]['date']		= self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true);
@@ -1693,22 +1968,31 @@  discard block
 block discarded – undo
1693 1968
 				$retValue['header'][$sortOrder[$uid]]['bodypreview']		= $headerObject['BODYPREVIEW'];
1694 1969
 				$retValue['header'][$sortOrder[$uid]]['priority']		= ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3);
1695 1970
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]]));
1696
-				if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO'];
1697
-				if (is_array($headerObject['FLAGS'])) {
1971
+				if (isset($headerObject['DISPOSITION-NOTIFICATION-TO']))
1972
+				{
1973
+					$retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO'];
1974
+				}
1975
+				if (is_array($headerObject['FLAGS']))
1976
+				{
1698 1977
 					$retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject));
1699 1978
 				}
1700 1979
 				//error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from')));
1701
-				if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) {
1980
+				if(is_array($headerObject['FROM']) && $headerObject['FROM'][0])
1981
+				{
1702 1982
 					$retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true);
1703 1983
 				}
1704
-				if(is_array($headerObject['TO']) && $headerObject['TO'][0]) {
1984
+				if(is_array($headerObject['TO']) && $headerObject['TO'][0])
1985
+				{
1705 1986
 					$retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true);
1706 1987
 					if (count($headerObject['TO'])>1)
1707 1988
 					{
1708 1989
 						$ki=0;
1709 1990
 						foreach($headerObject['TO'] as $k => $add)
1710 1991
 						{
1711
-							if ($k==0) continue;
1992
+							if ($k==0)
1993
+							{
1994
+								continue;
1995
+							}
1712 1996
 							//error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add));
1713 1997
 							$retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true);
1714 1998
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki]));
@@ -1716,7 +2000,8 @@  discard block
 block discarded – undo
1716 2000
 						}
1717 2001
 					}
1718 2002
 				}
1719
-				if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) {
2003
+				if(is_array($headerObject['CC']) && count($headerObject['CC'])>0)
2004
+				{
1720 2005
 					$ki=0;
1721 2006
 					foreach($headerObject['CC'] as $k => $add)
1722 2007
 					{
@@ -1730,27 +2015,41 @@  discard block
 block discarded – undo
1730 2015
 
1731 2016
 				$count++;
1732 2017
 			}
1733
-			if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') ');
2018
+			if (self::$debug||self::$debugTimes)
2019
+			{
2020
+				self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') ');
2021
+			}
1734 2022
 			//self::$debug=false;
1735 2023
 			// sort the messages to the requested displayorder
1736
-			if(is_array($retValue['header'])) {
2024
+			if(is_array($retValue['header']))
2025
+			{
1737 2026
 				$countMessages = $total;
1738
-				if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages'];
2027
+				if (isset($_filter['range']))
2028
+				{
2029
+					$countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages'];
2030
+				}
1739 2031
 				ksort($retValue['header']);
1740 2032
 				$retValue['info']['total']	= $total;
1741 2033
 				//if ($_startMessage>$total) $_startMessage = $total-($count-1);
1742 2034
 				$retValue['info']['first']	= $_startMessage;
1743 2035
 				$retValue['info']['last']	= $_startMessage + $count - 1 ;
1744 2036
 				return $retValue;
1745
-			} else {
2037
+			}
2038
+			else
2039
+			{
1746 2040
 				$retValue = array();
1747 2041
 				$retValue['info']['total']	= 0;
1748 2042
 				$retValue['info']['first']	= 0;
1749 2043
 				$retValue['info']['last']	= 0;
1750 2044
 				return $retValue;
1751 2045
 			}
1752
-		} else {
1753
-			if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE));
2046
+		}
2047
+		else
2048
+		{
2049
+			if ($headersNew == null && empty($_thisUIDOnly))
2050
+			{
2051
+				error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE));
2052
+			}
1754 2053
 			$retValue = array();
1755 2054
 			$retValue['info']['total']  = 0;
1756 2055
 			$retValue['info']['first']  = 0;
@@ -1767,7 +2066,10 @@  discard block
 block discarded – undo
1767 2066
 	 */
1768 2067
 	static function prepareFlagsArray($headerObject)
1769 2068
 	{
1770
-		if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']);
2069
+		if (is_array($headerObject['FLAGS']))
2070
+		{
2071
+			$headerFlags = array_map('strtolower',$headerObject['FLAGS']);
2072
+		}
1771 2073
 		$retValue = array();
1772 2074
 		$retValue['recent']		= in_array('\\recent', $headerFlags);
1773 2075
 		$retValue['flagged']	= in_array('\\flagged', $headerFlags);
@@ -1818,25 +2120,44 @@  discard block
 block discarded – undo
1818 2120
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter));
1819 2121
 		$try2useCache = true;
1820 2122
 		static $eMailListContainsDeletedMessages = null;
1821
-		if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2123
+		if (is_null($eMailListContainsDeletedMessages))
2124
+		{
2125
+			$eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2126
+		}
1822 2127
 		// this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED
1823 2128
 		if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false)))
1824 2129
 		{
1825
-			if (self::$debugTimes) $starttime = microtime(true);
1826
-			if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2130
+			if (self::$debugTimes)
2131
+			{
2132
+				$starttime = microtime(true);
2133
+			}
2134
+			if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName]))
2135
+			{
2136
+				$eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2137
+			}
1827 2138
 			$five=true;
1828 2139
 			$deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five,false);
1829
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages));
2140
+			if (self::$debug)
2141
+			{
2142
+				error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages));
2143
+			}
1830 2144
 			$eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count'];
1831 2145
 			Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1);
1832
-			if (self::$debugTimes) self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') ');			//error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']);
2146
+			if (self::$debugTimes)
2147
+			{
2148
+				self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') ');
2149
+			}
2150
+			//error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']);
1833 2151
 		}
1834 2152
 		$try2useCache = false;
1835 2153
 		//self::$supportsORinQuery[$this->profileID]=true;
1836 2154
 		if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID]))
1837 2155
 		{
1838 2156
 			self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
1839
-			if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true;
2157
+			if (!isset(self::$supportsORinQuery[$this->profileID]))
2158
+			{
2159
+				self::$supportsORinQuery[$this->profileID]=true;
2160
+			}
1840 2161
 		}
1841 2162
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]);
1842 2163
 		$filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]);
@@ -1847,15 +2168,26 @@  discard block
 block discarded – undo
1847 2168
 		}
1848 2169
 		//_debug_array($filter);
1849 2170
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability()));
1850
-		if($this->icServer->hasCapability('SORT')) {
2171
+		if($this->icServer->hasCapability('SORT'))
2172
+		{
1851 2173
 			// when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client
1852 2174
 			// thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if
1853 2175
 			// there is no messing with the dates)
1854 2176
 			//if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE';
1855
-			if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse");
2177
+			if (self::$debug)
2178
+			{
2179
+				error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse");
2180
+			}
1856 2181
 			$sortOrder = $this->_getSortString($_sort, $_reverse);
1857
-			if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already
1858
-			if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter));
2182
+			if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder))
2183
+			{
2184
+				$_reverse=false;
2185
+			}
2186
+			// as we reversed the result already
2187
+			if (self::$debug)
2188
+			{
2189
+				error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter));
2190
+			}
1859 2191
 			try
1860 2192
 			{
1861 2193
 				$sortResult = $this->icServer->search($_folderName, $filter, array(
@@ -1867,7 +2199,10 @@  discard block
 block discarded – undo
1867 2199
 				//error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage());
1868 2200
 				$resultByUid = false;
1869 2201
 				$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE);
1870
-				if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
2202
+				if ($_reverse)
2203
+				{
2204
+					array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
2205
+				}
1871 2206
 				try
1872 2207
 				{
1873 2208
 					$sortResult = $this->icServer->search($_folderName, $filter, array(
@@ -1879,9 +2214,17 @@  discard block
 block discarded – undo
1879 2214
 					$sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'];
1880 2215
 				}
1881 2216
 			}
1882
-			if (self::$debug) error_log(__METHOD__.print_r($sortResult,true));
1883
-		} else {
1884
-			if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability");
2217
+			if (self::$debug)
2218
+			{
2219
+				error_log(__METHOD__.print_r($sortResult,true));
2220
+			}
2221
+		}
2222
+		else
2223
+		{
2224
+			if (self::$debug)
2225
+			{
2226
+				error_log(__METHOD__." Mailserver has NO SORT Capability");
2227
+			}
1885 2228
 			//$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE);
1886 2229
 			//if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
1887 2230
 			try
@@ -1895,7 +2238,10 @@  discard block
 block discarded – undo
1895 2238
 				// possible error OR Query. But Horde gives no detailed Info :-(
1896 2239
 				self::$supportsORinQuery[$this->profileID]=false;
1897 2240
 				Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10);
1898
-				if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message);
2241
+				if (self::$debug)
2242
+				{
2243
+					error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message);
2244
+				}
1899 2245
 				$filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]);
1900 2246
 				try
1901 2247
 				{
@@ -1906,11 +2252,15 @@  discard block
 block discarded – undo
1906 2252
 				{
1907 2253
 				}
1908 2254
 			}
1909
-			if(is_array($sortResult['match'])) {
2255
+			if(is_array($sortResult['match']))
2256
+			{
1910 2257
 					// not sure that this is going so succeed as $sortResult['match'] is a hordeObject
1911 2258
 					sort($sortResult['match'], SORT_NUMERIC);
1912 2259
 			}
1913
-			if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true));
2260
+			if (self::$debug)
2261
+			{
2262
+				error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true));
2263
+			}
1914 2264
 		}
1915 2265
 		if ($setSession)
1916 2266
 		{
@@ -1939,7 +2289,8 @@  discard block
 block discarded – undo
1939 2289
 		$_reverse=false;
1940 2290
 		if (is_numeric($_sort))
1941 2291
 		{
1942
-			switch($_sort) {
2292
+			switch($_sort)
2293
+			{
1943 2294
 				case 2:
1944 2295
 					$retValue = array(Horde_Imap_Client::SORT_FROM);
1945 2296
 					break;
@@ -1961,7 +2312,8 @@  discard block
 block discarded – undo
1961 2312
 		}
1962 2313
 		else
1963 2314
 		{
1964
-			switch(strtoupper($_sort)) {
2315
+			switch(strtoupper($_sort))
2316
+			{
1965 2317
 				case 'FROMADDRESS':
1966 2318
 					$retValue = array(Horde_Imap_Client::SORT_FROM);
1967 2319
 					break;
@@ -1987,7 +2339,10 @@  discard block
 block discarded – undo
1987 2339
 					break;
1988 2340
 			}
1989 2341
 		}
1990
-		if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE);
2342
+		if ($_reverse)
2343
+		{
2344
+			array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE);
2345
+		}
1991 2346
 		//error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue);
1992 2347
 		return $retValue;
1993 2348
 	}
@@ -2006,7 +2361,10 @@  discard block
 block discarded – undo
2006 2361
 		$imapFilter->charset('UTF-8');
2007 2362
 
2008 2363
 		//_debug_array($_criterias);
2009
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
2364
+		if (self::$debug)
2365
+		{
2366
+			error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
2367
+		}
2010 2368
 		if((!is_array($_criterias) || $_criterias['status']=='any') &&
2011 2369
 			(!isset($_criterias['string']) || empty($_criterias['string'])) &&
2012 2370
 			(!isset($_criterias['range'])|| empty($_criterias['range']) ||
@@ -2021,11 +2379,13 @@  discard block
 block discarded – undo
2021 2379
 		// statusQuery MUST be placed first, as search for subject/mailbody and such is
2022 2380
 		// depending on charset. flagSearch is not BUT messes the charset if called afterwards
2023 2381
 		$statusQueryValid = false;
2024
-		foreach((array)$_criterias['status'] as $k => $criteria) {
2382
+		foreach((array)$_criterias['status'] as $k => $criteria)
2383
+		{
2025 2384
 			$imapStatusFilter = new Horde_Imap_Client_Search_Query();
2026 2385
 			$imapStatusFilter->charset('UTF-8');
2027 2386
 			$criteria = strtoupper($criteria);
2028
-			switch ($criteria) {
2387
+			switch ($criteria)
2388
+			{
2029 2389
 				case 'ANSWERED':
2030 2390
 				case 'DELETED':
2031 2391
 				case 'FLAGGED':
@@ -2108,9 +2468,11 @@  discard block
 block discarded – undo
2108 2468
 		$imapSearchFilter = new Horde_Imap_Client_Search_Query();
2109 2469
 		$imapSearchFilter->charset('UTF-8');
2110 2470
 
2111
-		if(!empty($_criterias['string'])) {
2471
+		if(!empty($_criterias['string']))
2472
+		{
2112 2473
 			$criteria = strtoupper($_criterias['type']);
2113
-			switch ($criteria) {
2474
+			switch ($criteria)
2475
+			{
2114 2476
 				case 'BYDATE':
2115 2477
 				case 'QUICK':
2116 2478
 				case 'QUICKWITHCC':
@@ -2118,9 +2480,12 @@  discard block
 block discarded – undo
2118 2480
 					//$imapSearchFilter->charset('UTF-8');
2119 2481
 					$imapFilter2 = new Horde_Imap_Client_Search_Query();
2120 2482
 					$imapFilter2->charset('UTF-8');
2121
-					if($this->isSentFolder($_folder)) {
2483
+					if($this->isSentFolder($_folder))
2484
+					{
2122 2485
 						$imapFilter2->headerText('TO', $_criterias['string'], $not=false);
2123
-					} else {
2486
+					}
2487
+					else
2488
+					{
2124 2489
 						$imapFilter2->headerText('FROM', $_criterias['string'], $not=false);
2125 2490
 					}
2126 2491
 					if ($_supportsOrInQuery)
@@ -2151,7 +2516,10 @@  discard block
 block discarded – undo
2151 2516
 											'GB'=>1024*1000*1000,'G'=>1024*1000*1000,
2152 2517
 											'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000);
2153 2518
 						$numberinBytes=(float)$_criterias['string'];
2154
-						if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit];
2519
+						if (isset($multipleBy[$unit]))
2520
+						{
2521
+							$numberinBytes=(float)$_criterias['string']*$multipleBy[$unit];
2522
+						}
2155 2523
 						//error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes);
2156 2524
 						$_criterias['string']=$numberinBytes;
2157 2525
 					}
@@ -2188,8 +2556,14 @@  discard block
 block discarded – undo
2188 2556
 					break;
2189 2557
 			}
2190 2558
 		}
2191
-		if ($statusQueryValid && !$queryValid) $queryValid=true;
2192
-		if ($queryValid) $imapFilter->andSearch($imapSearchFilter);
2559
+		if ($statusQueryValid && !$queryValid)
2560
+		{
2561
+			$queryValid=true;
2562
+		}
2563
+		if ($queryValid)
2564
+		{
2565
+			$imapFilter->andSearch($imapSearchFilter);
2566
+		}
2193 2567
 
2194 2568
 		if (isset($_criterias['range']) && !empty($_criterias['range']))
2195 2569
 		{
@@ -2204,7 +2578,8 @@  discard block
 block discarded – undo
2204 2578
 				unset($_criterias['before']);
2205 2579
 				$criteria=$_criterias['range']='ON';
2206 2580
 			}
2207
-			switch ($criteria) {
2581
+			switch ($criteria)
2582
+			{
2208 2583
 				case 'BETWEEN':
2209 2584
 					//try to be smart about missing
2210 2585
 					//enddate
@@ -2240,8 +2615,14 @@  discard block
 block discarded – undo
2240 2615
 					$rangeValid = true;
2241 2616
 					break;
2242 2617
 			}
2243
-			if ($rangeValid && !$queryValid) $queryValid=true;
2244
-			if ($rangeValid) $imapFilter->andSearch($imapRangeFilter);
2618
+			if ($rangeValid && !$queryValid)
2619
+			{
2620
+				$queryValid=true;
2621
+			}
2622
+			if ($rangeValid)
2623
+			{
2624
+				$imapFilter->andSearch($imapRangeFilter);
2625
+			}
2245 2626
 		}
2246 2627
 		if (self::$debug)
2247 2628
 		{
@@ -2249,10 +2630,13 @@  discard block
 block discarded – undo
2249 2630
 			$query_str = $imapFilter->build();
2250 2631
 			//error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
2251 2632
 		}
2252
-		if($queryValid==false) {
2633
+		if($queryValid==false)
2634
+		{
2253 2635
 			$imapFilter->flag('DELETED', $set=false);
2254 2636
 			return $imapFilter;
2255
-		} else {
2637
+		}
2638
+		else
2639
+		{
2256 2640
 			return $imapFilter;
2257 2641
 		}
2258 2642
 	}
@@ -2309,7 +2693,10 @@  discard block
 block discarded – undo
2309 2693
 					}
2310 2694
 					$stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal);
2311 2695
 				}
2312
-				if (!empty($stringA)) $_string = implode(',',$stringA);
2696
+				if (!empty($stringA))
2697
+				{
2698
+					$_string = implode(',',$stringA);
2699
+				}
2313 2700
 			}
2314 2701
 			if ($_tryIDNConversion==='FORCE')
2315 2702
 			{
@@ -2334,7 +2721,10 @@  discard block
 block discarded – undo
2334 2721
 		{
2335 2722
 			return 'No Subject';
2336 2723
 		}
2337
-		if ($decode) $_string = self::decode_header($_string);
2724
+		if ($decode)
2725
+		{
2726
+			$_string = self::decode_header($_string);
2727
+		}
2338 2728
 		// make sure its utf-8
2339 2729
 		$test = @json_encode($_string);
2340 2730
 		if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0)
@@ -2372,7 +2762,8 @@  discard block
 block discarded – undo
2372 2762
 	 * @param string _parent the parent foldername
2373 2763
 	 * @return ISO-8859-1 / UTF7-IMAP encoded string
2374 2764
 	 */
2375
-	function _encodeFolderName($_folderName) {
2765
+	function _encodeFolderName($_folderName)
2766
+	{
2376 2767
 		return Translation::convert($_folderName, self::$displayCharset, 'ISO-8859-1');
2377 2768
 		#return Translation::convert($_folderName, self::$displayCharset, 'UTF7-IMAP');
2378 2769
 	}
@@ -2388,21 +2779,36 @@  discard block
 block discarded – undo
2388 2779
 	 */
2389 2780
 	function createFolder($_parent, $_folderName, &$_error)
2390 2781
 	{
2391
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace());
2782
+		if (self::$debug)
2783
+		{
2784
+			error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace());
2785
+		}
2392 2786
 		$parent		= $_parent;//$this->_encodeFolderName($_parent);
2393 2787
 		$folderName	= $_folderName;//$this->_encodeFolderName($_folderName);
2394 2788
 
2395
-		if(empty($parent)) {
2789
+		if(empty($parent))
2790
+		{
2396 2791
 			$newFolderName = $folderName;
2397
-		} else {
2792
+		}
2793
+		else
2794
+		{
2398 2795
 			$HierarchyDelimiter = $this->getHierarchyDelimiter();
2399 2796
 			$newFolderName = $parent . $HierarchyDelimiter . $folderName;
2400 2797
 		}
2401
-		if (empty($newFolderName)) return false;
2402
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName);
2798
+		if (empty($newFolderName))
2799
+		{
2800
+			return false;
2801
+		}
2802
+		if (self::$debug)
2803
+		{
2804
+			error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName);
2805
+		}
2403 2806
 		if ($this->folderExists($newFolderName,true))
2404 2807
 		{
2405
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists.");
2808
+			if (self::$debug)
2809
+			{
2810
+				error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists.");
2811
+			}
2406 2812
 			return $newFolderName;
2407 2813
 		}
2408 2814
 		try
@@ -2450,13 +2856,19 @@  discard block
 block discarded – undo
2450 2856
 		$parent		= $_parent;//$this->_encodeFolderName($_parent);
2451 2857
 		$folderName	= $_folderName;//$this->_encodeFolderName($_folderName);
2452 2858
 
2453
-		if(empty($parent)) {
2859
+		if(empty($parent))
2860
+		{
2454 2861
 			$newFolderName = $folderName;
2455
-		} else {
2862
+		}
2863
+		else
2864
+		{
2456 2865
 			$HierarchyDelimiter = $this->getHierarchyDelimiter();
2457 2866
 			$newFolderName = $parent . $HierarchyDelimiter . $folderName;
2458 2867
 		}
2459
-		if (self::$debug) error_log("create folder: $newFolderName");
2868
+		if (self::$debug)
2869
+		{
2870
+			error_log("create folder: $newFolderName");
2871
+		}
2460 2872
 		try
2461 2873
 		{
2462 2874
 			$this->icServer->renameMailbox($oldFolderName, $newFolderName);
@@ -2530,8 +2942,14 @@  discard block
 block discarded – undo
2530 2942
 	 */
2531 2943
 	function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true)
2532 2944
 	{
2533
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible");
2534
-		if (self::$debugTimes) $starttime = microtime (true);
2945
+		if (self::$debug)
2946
+		{
2947
+			error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible");
2948
+		}
2949
+		if (self::$debugTimes)
2950
+		{
2951
+			$starttime = microtime (true);
2952
+		}
2535 2953
 		static $folders2return;
2536 2954
 		//$_subscribedOnly=false;
2537 2955
 		// always use static on single request if info is available;
@@ -2539,23 +2957,35 @@  discard block
 block discarded – undo
2539 2957
 		// set $_useCacheIfPossible to false !
2540 2958
 		if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
2541 2959
 		{
2542
-			if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') ');
2960
+			if (self::$debugTimes)
2961
+			{
2962
+				self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') ');
2963
+			}
2543 2964
 			return $folders2return[$this->icServer->ImapServerId];
2544 2965
 		}
2545 2966
 
2546 2967
 		if ($_subscribedOnly && $_getCounters===false)
2547 2968
 		{
2548
-			if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2969
+			if (is_null($folders2return))
2970
+			{
2971
+				$folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2972
+			}
2549 2973
 			if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
2550 2974
 			{
2551 2975
 				//error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId]));
2552
-				if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') ');
2976
+				if (self::$debugTimes)
2977
+				{
2978
+					self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') ');
2979
+				}
2553 2980
 				return $folders2return[$this->icServer->ImapServerId];
2554 2981
 			}
2555 2982
 		}
2556 2983
 		// use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId]
2557 2984
 		static $folderBasicInfo;
2558
-		if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2985
+		if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId]))
2986
+		{
2987
+			$folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2988
+		}
2559 2989
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId])));
2560 2990
 
2561 2991
 		$delimiter = $this->getHierarchyDelimiter();
@@ -2568,7 +2998,8 @@  discard block
 block discarded – undo
2568 2998
 		$inboxData->shortFolderName	= 'INBOX';
2569 2999
 		$inboxData->shortDisplayName	= lang('INBOX');
2570 3000
 		$inboxData->subscribed = true;
2571
-		if($_getCounters == true) {
3001
+		if($_getCounters == true)
3002
+		{
2572 3003
 			$inboxData->counter = $this->getMailBoxCounters('INBOX');
2573 3004
 		}
2574 3005
 		// force unsubscribed by preference showAllFoldersInFolderPane
@@ -2587,12 +3018,14 @@  discard block
 block discarded – undo
2587 3018
 		//error_log(__METHOD__.__LINE__.array2string($nameSpace));
2588 3019
 		if (is_array($nameSpace))
2589 3020
 		{
2590
-			foreach($nameSpace as $k => $singleNameSpace) {
3021
+			foreach($nameSpace as $k => $singleNameSpace)
3022
+			{
2591 3023
 				$type = $singleNameSpace['type'];
2592 3024
 				// the following line (assumption that for the same namespace the delimiter should be equal) may be wrong
2593 3025
 				$foldersNameSpace[$type]['delimiter']  = $singleNameSpace['delimiter'];
2594 3026
 
2595
-				if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) {
3027
+				if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false)
3028
+				{
2596 3029
 					// fetch and sort the subscribed folders
2597 3030
 					// we alway fetch the subscribed, as this provides the only way to tell
2598 3031
 					// if a folder is subscribed or not
@@ -2643,8 +3076,12 @@  discard block
 block discarded – undo
2643 3076
 							}
2644 3077
 						}
2645 3078
 						//error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($foldersNameSpace[$type]['subscribed']));
2646
-						if (!is_array($foldersNameSpace[$type]['all'])) $foldersNameSpace[$type]['all'] = array();
2647
-						if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) {
3079
+						if (!is_array($foldersNameSpace[$type]['all']))
3080
+						{
3081
+							$foldersNameSpace[$type]['all'] = array();
3082
+						}
3083
+						if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed']))
3084
+						{
2648 3085
 							continue;
2649 3086
 						}
2650 3087
 
@@ -2674,7 +3111,8 @@  discard block
 block discarded – undo
2674 3111
 					}
2675 3112
 
2676 3113
 					//error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($allMailboxesExt));
2677
-					foreach ($allMailboxesExt as $mbx) {
3114
+					foreach ($allMailboxesExt as $mbx)
3115
+					{
2678 3116
 						if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]))
2679 3117
 						{
2680 3118
 							$folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array(
@@ -2697,20 +3135,33 @@  discard block
 block discarded – undo
2697 3135
 						if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])||
2698 3136
 							isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])||
2699 3137
 							(substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)]))
2700
-						) continue;
3138
+						)
3139
+						{
3140
+							continue;
3141
+						}
2701 3142
 
2702 3143
 						//echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>";
2703 3144
 						$allMailBoxesExtSorted[$mbx['MAILBOX']] = $mbx;
2704 3145
 					}
2705
-					if (is_array($allMailBoxesExtSorted)) ksort($allMailBoxesExtSorted);
3146
+					if (is_array($allMailBoxesExtSorted))
3147
+					{
3148
+						ksort($allMailBoxesExtSorted);
3149
+					}
2706 3150
 					//_debug_array(array_keys($allMailBoxesExtSorted));
2707 3151
 					$allMailboxes = array();
2708
-					foreach ((array)$allMailBoxesExtSorted as $mbx) {
2709
-						if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX'];
3152
+					foreach ((array)$allMailBoxesExtSorted as $mbx)
3153
+					{
3154
+						if (!in_array($mbx['MAILBOX'],$allMailboxes))
3155
+						{
3156
+							$allMailboxes[] = $mbx['MAILBOX'];
3157
+						}
2710 3158
 						//echo "Result:";_debug_array($allMailboxes);
2711 3159
 					}
2712 3160
 					$foldersNameSpace[$type]['all'] = $allMailboxes;
2713
-					if (is_array($foldersNameSpace[$type]['all'])) sort($foldersNameSpace[$type]['all']);
3161
+					if (is_array($foldersNameSpace[$type]['all']))
3162
+					{
3163
+						sort($foldersNameSpace[$type]['all']);
3164
+					}
2714 3165
 				}
2715 3166
 			}
2716 3167
 		}
@@ -2719,24 +3170,50 @@  discard block
 block discarded – undo
2719 3170
 		//echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
2720 3171
 		$autoFolderObjects = $folders = array();
2721 3172
 		$autofolder_exists = array();
2722
-		foreach( array('personal', 'others', 'shared') as $type) {
2723
-			if(isset($foldersNameSpace[$type])) {
2724
-				if($_subscribedOnly) {
2725
-					if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed'];
2726
-				} else {
2727
-					if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all'];
2728
-				}
2729
-				foreach((array)$listOfFolders as $folderName) {
3173
+		foreach( array('personal', 'others', 'shared') as $type)
3174
+		{
3175
+			if(isset($foldersNameSpace[$type]))
3176
+			{
3177
+				if($_subscribedOnly)
3178
+				{
3179
+					if( !empty($foldersNameSpace[$type]['subscribed']) )
3180
+					{
3181
+						$listOfFolders = $foldersNameSpace[$type]['subscribed'];
3182
+					}
3183
+				}
3184
+				else
3185
+				{
3186
+					if( !empty($foldersNameSpace[$type]['all']))
3187
+					{
3188
+						$listOfFolders = $foldersNameSpace[$type]['all'];
3189
+					}
3190
+				}
3191
+				foreach((array)$listOfFolders as $folderName)
3192
+				{
2730 3193
 					//echo "<br>FolderToCheck:$folderName<br>";
2731 3194
 					//error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName);
2732
-					if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go.
2733
-					if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) {
3195
+					if ($_subscribedOnly && empty($foldersNameSpace[$type]['all']))
3196
+					{
3197
+						continue;
3198
+					}
3199
+					//when subscribedonly, we fetch all folders in one go.
3200
+					if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all'])))
3201
+					{
2734 3202
 						#echo "$folderName failed to be here <br>";
2735 3203
 						continue;
2736 3204
 					}
2737
-					if (isset($folders[$folderName])) continue;
2738
-					if (isset($autoFolderObjects[$folderName])) continue;
2739
-					if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter'];
3205
+					if (isset($folders[$folderName]))
3206
+					{
3207
+						continue;
3208
+					}
3209
+					if (isset($autoFolderObjects[$folderName]))
3210
+					{
3211
+						continue;
3212
+					}
3213
+					if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter'])
3214
+					{
3215
+						$delimiter = $foldersNameSpace[$type]['delimiter'];
3216
+					}
2740 3217
 					$folderParts = explode($delimiter, $folderName);
2741 3218
 					$shortName = array_pop($folderParts);
2742 3219
 
@@ -2744,17 +3221,20 @@  discard block
 block discarded – undo
2744 3221
 					$folderObject->delimiter	= $delimiter;
2745 3222
 					$folderObject->folderName	= $folderName;
2746 3223
 					$folderObject->shortFolderName	= $shortName;
2747
-					if(!$_subscribedOnly) {
3224
+					if(!$_subscribedOnly)
3225
+					{
2748 3226
 						#echo $folderName."->".$type."<br>";
2749 3227
 						#_debug_array($foldersNameSpace[$type]['subscribed']);
2750 3228
 						$folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']);
2751 3229
 					}
2752 3230
 
2753
-					if($_getCounters == true) {
3231
+					if($_getCounters == true)
3232
+					{
2754 3233
 						//error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName);
2755 3234
 						$folderObject->counter = $this->getMailBoxCounters($folderName);
2756 3235
 					}
2757
-					if(strtoupper($folderName) == 'INBOX') {
3236
+					if(strtoupper($folderName) == 'INBOX')
3237
+					{
2758 3238
 						$folderName = 'INBOX';
2759 3239
 						$folderObject->folderName	= 'INBOX';
2760 3240
 						$folderObject->shortFolderName	= 'INBOX';
@@ -2762,24 +3242,34 @@  discard block
 block discarded – undo
2762 3242
 						$folderObject->shortDisplayName = lang('INBOX');
2763 3243
 						$folderObject->subscribed	= true;
2764 3244
 					// translate the automatic Folders (Sent, Drafts, ...) like the INBOX
2765
-					} elseif (in_array($shortName,self::$autoFolders)) {
3245
+					}
3246
+					elseif (in_array($shortName,self::$autoFolders))
3247
+					{
2766 3248
 						$tmpfolderparts = explode($delimiter,$folderObject->folderName);
2767 3249
 						array_pop($tmpfolderparts);
2768 3250
 						$folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName);
2769 3251
 						$folderObject->shortDisplayName = lang($shortName);
2770 3252
 						unset($tmpfolderparts);
2771
-					} else {
3253
+					}
3254
+					else
3255
+					{
2772 3256
 						$folderObject->displayName = $folderObject->folderName;
2773 3257
 						$folderObject->shortDisplayName = $shortName;
2774 3258
 					}
2775 3259
 					//$folderName = $folderName;
2776
-					if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) {
3260
+					if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false)
3261
+					{
2777 3262
 						$autoFolderObjects[$folderName] = $folderObject;
2778
-					} else {
3263
+					}
3264
+					else
3265
+					{
2779 3266
 						$folders[$folderName] = $folderObject;
2780 3267
 					}
2781 3268
 					//error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName);
2782
-					if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders ();
3269
+					if (!isset(self::$specialUseFolders))
3270
+					{
3271
+						$this->getSpecialUseFolders ();
3272
+					}
2783 3273
 					if (isset(self::$specialUseFolders[$folderName]))
2784 3274
 					{
2785 3275
 						$autofolder_exists[$folderName] = self::$specialUseFolders[$folderName];
@@ -2787,7 +3277,8 @@  discard block
 block discarded – undo
2787 3277
 				}
2788 3278
 			}
2789 3279
 		}
2790
-		if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) {
3280
+		if (is_array($autoFolderObjects) && !empty($autoFolderObjects))
3281
+		{
2791 3282
 			uasort($autoFolderObjects,array($this,"sortByAutoFolderPos"));
2792 3283
 		}
2793 3284
 		// check if some standard folders are missing and need to be created
@@ -2796,7 +3287,10 @@  discard block
 block discarded – undo
2796 3287
 			// if new folders have been created, re-read folders ignoring the cache
2797 3288
 			return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false);	// false = do NOT use cache
2798 3289
 		}
2799
-		if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName"));
3290
+		if (is_array($folders))
3291
+		{
3292
+			uasort($folders,array($this,"sortByDisplayName"));
3293
+		}
2800 3294
 		//$folders2return = array_merge($autoFolderObjects,$folders);
2801 3295
 		//_debug_array($folders2return); #exit;
2802 3296
 		$folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders);
@@ -2808,7 +3302,10 @@  discard block
 block discarded – undo
2808 3302
 			Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1);
2809 3303
 		}
2810 3304
 		Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1);
2811
-		if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') ');
3305
+		if (self::$debugTimes)
3306
+		{
3307
+			self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') ');
3308
+		}
2812 3309
 		return $folders2return[$this->icServer->ImapServerId];
2813 3310
 	}
2814 3311
 
@@ -2836,31 +3333,44 @@  discard block
 block discarded – undo
2836 3333
 
2837 3334
 		$folders = $nameSpace =  array();
2838 3335
 		$nameSpaceTmp = $this->_getNameSpaces();
2839
-		foreach($nameSpaceTmp as $k => $singleNameSpace) {
3336
+		foreach($nameSpaceTmp as $k => $singleNameSpace)
3337
+		{
2840 3338
 			$nameSpace[$singleNameSpace['type']]=$singleNameSpace;
2841 3339
 		}
2842 3340
 		unset($nameSpaceTmp);
2843 3341
 
2844 3342
 		//error_log(__METHOD__.__LINE__.array2string($nameSpace));
2845 3343
 		// Get special use folders
2846
-		if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders
3344
+		if (!isset(self::$specialUseFolders))
3345
+		{
3346
+			$this->getSpecialUseFolders ();
3347
+		}
3348
+		// Set self::$specialUseFolders
2847 3349
 		// topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace
2848
-		if ($_onlyTopLevel) // top level leaves
3350
+		if ($_onlyTopLevel)
3351
+		{
3352
+			// top level leaves
2849 3353
 		{
2850 3354
 			// Get top mailboxes of icServer
2851 3355
 			$topFolders = $this->icServer->getMailboxes("", 2, true);
3356
+		}
2852 3357
 			// Trigger examination of namespace to retrieve
2853 3358
 			// folders located in other and shared; needed only for some servers
2854
-			if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
3359
+			if (is_null(self::$mailConfig))
3360
+			{
3361
+				self::$mailConfig = Config::read('mail');
3362
+			}
2855 3363
 			if (self::$mailConfig['examineNamespace'])
2856 3364
 			{
2857 3365
 				$prefixes=array();
2858 3366
 				if (is_array($nameSpace))
2859 3367
 				{
2860
-					foreach($nameSpace as $k => $singleNameSpace) {
3368
+					foreach($nameSpace as $k => $singleNameSpace)
3369
+					{
2861 3370
 						$type = $singleNameSpace['type'];
2862 3371
 
2863
-						if(is_array($singleNameSpace) && $singleNameSpace['prefix']){
3372
+						if(is_array($singleNameSpace) && $singleNameSpace['prefix'])
3373
+						{
2864 3374
 							$prefixes[$type] = $singleNameSpace['prefix'];
2865 3375
 							//regard extra care for nameSpacequeries when configured AND respect $_search
2866 3376
 							$result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true);
@@ -2936,7 +3446,10 @@  discard block
 block discarded – undo
2936 3446
 							$nFolders [$path] = $folder;
2937 3447
 						}
2938 3448
 					}
2939
-					if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder'));
3449
+					if (is_array($aFolders))
3450
+					{
3451
+						uasort ($aFolders, array($this,'sortByAutofolder'));
3452
+					}
2940 3453
 					//ksort($aFolders);
2941 3454
 
2942 3455
 					// Sort none auto folders base on mailbox name
@@ -2946,12 +3459,17 @@  discard block
 block discarded – undo
2946 3459
 				}
2947 3460
 				else
2948 3461
 				{
2949
-					if (is_array($subFolders)) ksort($subFolders);
3462
+					if (is_array($subFolders))
3463
+					{
3464
+						ksort($subFolders);
3465
+					}
2950 3466
 				}
2951 3467
 				$folders = array_merge($folders,(array)$mainFolder, (array)$subFolders);
2952 3468
 			}
2953 3469
 		}
2954
-		elseif ($_nodePath) // single node
3470
+		elseif ($_nodePath)
3471
+		{
3472
+			// single node
2955 3473
 		{
2956 3474
 			switch ($_search)
2957 3475
 			{
@@ -2959,6 +3477,7 @@  discard block
 block discarded – undo
2959 3477
 				case 0:
2960 3478
 				case 2:
2961 3479
 					$path = $_nodePath.''.$delimiter;
3480
+		}
2962 3481
 					break;
2963 3482
 				// Node itself
2964 3483
 				// shouldn't contain next level delimiter
@@ -2977,11 +3496,14 @@  discard block
 block discarded – undo
2977 3496
 
2978 3497
 			uasort($folders,array($this,'sortByMailbox'));//ksort($folders);
2979 3498
 		}
2980
-		elseif(!$_nodePath) // all
3499
+		elseif(!$_nodePath)
3500
+		{
3501
+			// all
2981 3502
 		{
2982 3503
 			if ($_subscribedOnly)
2983 3504
 			{
2984 3505
 				$folders = $this->icServer->listSubscribedMailboxes('', 0, true);
3506
+		}
2985 3507
 			}
2986 3508
 			else
2987 3509
 			{
@@ -2993,7 +3515,10 @@  discard block
 block discarded – undo
2993 3515
 		{
2994 3516
 			// SORTING FOLDERS
2995 3517
 			//self::$debugTimes=true;
2996
-			if (self::$debugTimes) $starttime = microtime (true);
3518
+			if (self::$debugTimes)
3519
+			{
3520
+				$starttime = microtime (true);
3521
+			}
2997 3522
 			// Merge of all auto folders and specialusefolders
2998 3523
 			$autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders))));
2999 3524
 			uasort($folders,array($this,'sortByMailbox'));//ksort($folders);
@@ -3003,73 +3528,103 @@  discard block
 block discarded – undo
3003 3528
 			$isGoogleMail=false;
3004 3529
 			foreach($autoFoldersTmp as $afk=>$aF)
3005 3530
 			{
3006
-				if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false);
3531
+				if (!isset($mySpecialUseFolders[$aF]) && $aF)
3532
+				{
3533
+					$mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false);
3534
+				}
3007 3535
 				//error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3008 3536
 			}
3009 3537
 			//error_log(array2string($mySpecialUseFolders));
3010
-			foreach ($tmpFolders as $k => $f) {
3538
+			foreach ($tmpFolders as $k => $f)
3539
+			{
3011 3540
 				$sorted=false;
3012
-				if (strtoupper(substr($k,0,5))=='INBOX') {
3013
-					if (strtoupper($k)=='INBOX') {
3541
+				if (strtoupper(substr($k,0,5))=='INBOX')
3542
+				{
3543
+					if (strtoupper($k)=='INBOX')
3544
+					{
3014 3545
 						//error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k);
3015 3546
 						$inboxFolderObject[$k]=$f;
3016 3547
 						unset($folders[$k]);
3017 3548
 						$sorted=true;
3018
-					} else {
3549
+					}
3550
+					else
3551
+					{
3019 3552
 						$isAutoFolder=false;
3020 3553
 						foreach($autoFoldersTmp as $afk=>$aF)
3021 3554
 						{
3022 3555
 							//error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3023 3556
 							if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
3024 3557
 								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder
3025
-								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder
3558
+								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false))
3559
+							{
3560
+								// k is parent of an autofolder
3026 3561
 							{
3027 3562
 								//error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]);
3028 3563
 								$isAutoFolder=true;
3564
+							}
3029 3565
 								$autoFolderObjects[$k]=$f;
3030 3566
 								break;
3031 3567
 							}
3032 3568
 						}
3033
-						if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f;
3569
+						if ($isAutoFolder==false)
3570
+						{
3571
+							$inboxSubFolderObjects[$k]=$f;
3572
+						}
3034 3573
 						unset($folders[$k]);
3035 3574
 						$sorted=true;
3036 3575
 					}
3037
-				} elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') {
3576
+				}
3577
+				elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]')
3578
+				{
3038 3579
 					$isGoogleMail=true;
3039
-					if (strtoupper($k)=='[GOOGLE MAIL]') {
3580
+					if (strtoupper($k)=='[GOOGLE MAIL]')
3581
+					{
3040 3582
 						$googleMailFolderObject[$k]=$f;
3041 3583
 						unset($folders[$k]);
3042 3584
 						$sorted=true;
3043
-					} else {
3585
+					}
3586
+					else
3587
+					{
3044 3588
 						$isAutoFolder=false;
3045 3589
 						foreach($autoFoldersTmp as $afk=>$aF)
3046 3590
 						{
3047 3591
 							//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3048 3592
 							if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
3049 3593
 								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder
3050
-								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder
3594
+								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false))
3595
+							{
3596
+								// k is parent of an autofolder
3051 3597
 							{
3052 3598
 								//error_log($k.'->'.$mySpecialUseFolders[$aF]);
3053 3599
 								$isAutoFolder=true;
3600
+							}
3054 3601
 								$googleAutoFolderObjects[$k]=$f;
3055 3602
 								break;
3056 3603
 							}
3057 3604
 						}
3058
-						if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f;
3605
+						if ($isAutoFolder==false)
3606
+						{
3607
+							$googleSubFolderObjects[$k]=$f;
3608
+						}
3059 3609
 						unset($folders[$k]);
3060 3610
 						$sorted=true;
3061 3611
 					}
3062
-				} else {
3612
+				}
3613
+				else
3614
+				{
3063 3615
 					$isAutoFolder=false;
3064 3616
 					foreach($autoFoldersTmp as $afk=>$aF)
3065 3617
 					{
3066 3618
 						//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3067 3619
 						if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
3068 3620
 								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder
3069
-								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder
3621
+								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false))
3622
+						{
3623
+							// k is parent of an autofolder
3070 3624
 						{
3071 3625
 							//error_log($k.'->'.$mySpecialUseFolders[$aF]);
3072 3626
 							$isAutoFolder=true;
3627
+						}
3073 3628
 							$autoFolderObjects[$k]=$f;
3074 3629
 							unset($folders[$k]);
3075 3630
 							$sorted=true;
@@ -3085,7 +3640,8 @@  discard block
 block discarded – undo
3085 3640
 						if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix'])
3086 3641
 						{
3087 3642
 							if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']||
3088
-								substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) {
3643
+								substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1))
3644
+							{
3089 3645
 								//error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k);
3090 3646
 								$typeFolderObject[$type][$k]=$f;
3091 3647
 								unset($folders[$k]);
@@ -3112,9 +3668,12 @@  discard block
 block discarded – undo
3112 3668
 				}
3113 3669
 			}
3114 3670
 			//error_log(__METHOD__.__LINE__.array2string($autoFolderObjects));
3115
-			if (!$isGoogleMail) {
3671
+			if (!$isGoogleMail)
3672
+			{
3116 3673
 				$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']);
3117
-			} else {
3674
+			}
3675
+			else
3676
+			{
3118 3677
 				// avoid calling sortByAutoFolder as it is not regarding subfolders
3119 3678
 				$gAutoFolderObjectsTmp = $googleAutoFolderObjects;
3120 3679
 				unset($googleAutoFolderObjects);
@@ -3131,7 +3690,10 @@  discard block
 block discarded – undo
3131 3690
 				}
3132 3691
 				$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']);
3133 3692
 			}
3134
-			if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:');
3693
+			if (self::$debugTimes)
3694
+			{
3695
+				self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:');
3696
+			}
3135 3697
 			//self::$debugTimes=false;
3136 3698
 		}
3137 3699
 		// Get counter information and add them to each fetched folders array
@@ -3181,7 +3743,13 @@  discard block
 block discarded – undo
3181 3743
 		$rv = false;
3182 3744
 		foreach ($haystack as $k => $v)
3183 3745
 		{
3184
-			foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;}
3746
+			foreach($v as &$sv)
3747
+			{
3748
+if (trim($sv)==trim($needle))
3749
+			{
3750
+				return $k;
3751
+			}
3752
+			}
3185 3753
 		}
3186 3754
 		return $rv;
3187 3755
 	}
@@ -3208,7 +3776,10 @@  discard block
 block discarded – undo
3208 3776
 	 */
3209 3777
 	static function pathToFolderData ($_path, $_hDelimiter)
3210 3778
 	{
3211
-		if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path;
3779
+		if (!strpos($_path, self::DELIMITER))
3780
+		{
3781
+			$_path = self::DELIMITER.$_path;
3782
+		}
3212 3783
 		list(,$path) = explode(self::DELIMITER, $_path);
3213 3784
 		$path_chain = $parts = explode($_hDelimiter, $path);
3214 3785
 		$name = array_pop($parts);
@@ -3237,7 +3808,10 @@  discard block
 block discarded – undo
3237 3808
 		$b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']);
3238 3809
 		$pos1 = array_search(trim($a['name']),self::$autoFolders);
3239 3810
 		$pos2 = array_search(trim($b['name']),self::$autoFolders);
3240
-		if ($pos1 == $pos2) return 0;
3811
+		if ($pos1 == $pos2)
3812
+		{
3813
+			return 0;
3814
+		}
3241 3815
 		return ($pos1 < $pos2) ? -1 : 1;
3242 3816
 	}
3243 3817
 
@@ -3268,7 +3842,10 @@  discard block
 block discarded – undo
3268 3842
 		// 0, 1 und -1
3269 3843
 		$pos1 = array_search(trim($a->shortFolderName),self::$autoFolders);
3270 3844
 		$pos2 = array_search(trim($b->shortFolderName),self::$autoFolders);
3271
-		if ($pos1 == $pos2) return 0;
3845
+		if ($pos1 == $pos2)
3846
+		{
3847
+			return 0;
3848
+		}
3272 3849
 		return ($pos1 < $pos2) ? -1 : 1;
3273 3850
 	}
3274 3851
 
@@ -3289,11 +3866,18 @@  discard block
 block discarded – undo
3289 3866
 		}
3290 3867
 		catch (\Exception $e)
3291 3868
 		{
3292
-			if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage());
3869
+			if (self::$debug)
3870
+			{
3871
+				error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage());
3872
+			}
3293 3873
 			return false;
3294 3874
 		}
3295
-		if(is_array($folderStatus)) {
3296
-			if ($_returnObject===false) return $folderStatus;
3875
+		if(is_array($folderStatus))
3876
+		{
3877
+			if ($_returnObject===false)
3878
+			{
3879
+				return $folderStatus;
3880
+			}
3297 3881
 			$status =  new \stdClass;
3298 3882
 			$status->messages   = $folderStatus['MESSAGES'];
3299 3883
 			$status->unseen     = $folderStatus['UNSEEN'];
@@ -3320,7 +3904,8 @@  discard block
 block discarded – undo
3320 3904
 	{
3321 3905
 		#echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>";
3322 3906
 		$maxreclevel=25;
3323
-		if ($reclevel > $maxreclevel) {
3907
+		if ($reclevel > $maxreclevel)
3908
+		{
3324 3909
 			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
3325 3910
 			return array();
3326 3911
 		}
@@ -3334,7 +3919,8 @@  discard block
 block discarded – undo
3334 3919
 //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter));
3335 3920
 //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx));
3336 3921
 		// Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /))
3337
-		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) {
3922
+		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
3923
+		{
3338 3924
 			// if there are children fetch them
3339 3925
 			//echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>";
3340 3926
 
@@ -3342,7 +3928,8 @@  discard block
 block discarded – undo
3342 3928
 			//$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false);
3343 3929
 			//_debug_array($buff);
3344 3930
 			$allMailboxes = array();
3345
-			foreach ($buff as $mbxname) {
3931
+			foreach ($buff as $mbxname)
3932
+			{
3346 3933
 //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname));
3347 3934
 				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
3348 3935
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
@@ -3351,9 +3938,14 @@  discard block
 block discarded – undo
3351 3938
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
3352 3939
 				}
3353 3940
 			}
3354
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
3941
+			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
3942
+			{
3943
+				$allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
3944
+			}
3355 3945
 			return $allMailboxes;
3356
-		} else {
3946
+		}
3947
+		else
3948
+		{
3357 3949
 			return array($_mailbox);
3358 3950
 		}
3359 3951
 	}
@@ -3377,14 +3969,21 @@  discard block
 block discarded – undo
3377 3969
 			'Outbox'   => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'),
3378 3970
 			'Archive'   => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'),
3379 3971
 		);
3380
-		if ($_type == 'Templates') $_type = 'Template';	// for some reason self::$autofolders uses 'Templates'!
3972
+		if ($_type == 'Templates')
3973
+		{
3974
+			$_type = 'Template';
3975
+		}
3976
+		// for some reason self::$autofolders uses 'Templates'!
3381 3977
 		$created = false;
3382 3978
 		if (!isset($types[$_type]))
3383 3979
 		{
3384 3980
 			error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__);
3385 3981
 			return false;
3386 3982
 		}
3387
-		if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders();
3983
+		if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders))
3984
+		{
3985
+			self::$specialUseFolders = $this->getSpecialUseFolders();
3986
+		}
3388 3987
 
3389 3988
 		//highest precedence
3390 3989
 		try
@@ -3394,25 +3993,39 @@  discard block
 block discarded – undo
3394 3993
 		catch (\Exception $e)
3395 3994
 		{
3396 3995
 			// we know that outbox is not supported, but we use this here, as we autocreate expected SpecialUseFolders in this function
3397
-			if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage());
3996
+			if ($_type != 'Outbox')
3997
+			{
3998
+				error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage());
3999
+			}
3398 4000
 			$_folderName = false;
3399 4001
 		}
3400 4002
 		// do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist
3401
-		if ($_type == 'Archive') {
3402
-			if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) {
4003
+		if ($_type == 'Archive')
4004
+		{
4005
+			if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true))
4006
+			{
3403 4007
 				return false;
3404
-			} else {
4008
+			}
4009
+			else
4010
+			{
3405 4011
 				return $_folderName;
3406 4012
 			}
3407 4013
 
3408 4014
 		}
3409 4015
 		// does the folder exist??? (is configured/preset, but non-existent)
3410
-		if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) {
4016
+		if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true))
4017
+		{
3411 4018
 			try
3412 4019
 			{
3413 4020
 				$error = null;
3414
-				if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true;
3415
-				if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4021
+				if (($_folderName = $this->createFolder('', $_folderName, $error)))
4022
+				{
4023
+					$created = true;
4024
+				}
4025
+				if ($error)
4026
+				{
4027
+					error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4028
+				}
3416 4029
 			}
3417 4030
 			catch(Exception $e)
3418 4031
 			{
@@ -3421,9 +4034,16 @@  discard block
 block discarded – undo
3421 4034
 			}
3422 4035
 		}
3423 4036
 		// not sure yet if false is the correct behavior on none
3424
-		if ($_folderName =='none') return 'none' ; //false;
4037
+		if ($_folderName =='none')
4038
+		{
4039
+			return 'none' ;
4040
+		}
4041
+		//false;
3425 4042
 		//no (valid) folder found yet; try specialUseFolders
3426
-		if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f;
4043
+		if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders)))
4044
+		{
4045
+			$_folderName = $f;
4046
+		}
3427 4047
 		//no specialUseFolder; try some Defaults
3428 4048
 		if (empty($_folderName) && isset($types[$_type]))
3429 4049
 		{
@@ -3449,7 +4069,10 @@  discard block
 block discarded – undo
3449 4069
 					$error = null;
3450 4070
 					$this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error);
3451 4071
 					$_folderName = $prefix.$types[$_type]['autoFolderName'];
3452
-					if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4072
+					if ($error)
4073
+					{
4074
+						error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4075
+					}
3453 4076
 				}
3454 4077
 				catch(Exception $e)
3455 4078
 				{
@@ -3551,17 +4174,22 @@  discard block
 block discarded – undo
3551 4174
 	function isSentFolder($_folderName, $_checkexistance=TRUE)
3552 4175
 	{
3553 4176
 		$sentFolder = $this->getSentFolder($_checkexistance);
3554
-		if(empty($sentFolder)) {
4177
+		if(empty($sentFolder))
4178
+		{
3555 4179
 			return false;
3556 4180
 		}
3557 4181
 		// does the folder exist???
3558
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4182
+		if ($_checkexistance && !$this->folderExists($_folderName))
4183
+		{
3559 4184
 			return false;
3560 4185
 		}
3561 4186
 
3562
-		if(false !== stripos($_folderName, $sentFolder)) {
4187
+		if(false !== stripos($_folderName, $sentFolder))
4188
+		{
3563 4189
 			return true;
3564
-		} else {
4190
+		}
4191
+		else
4192
+		{
3565 4193
 			return false;
3566 4194
 		}
3567 4195
 	}
@@ -3574,15 +4202,20 @@  discard block
 block discarded – undo
3574 4202
 	 */
3575 4203
 	function isOutbox($_folderName, $_checkexistance=TRUE)
3576 4204
 	{
3577
-		if (stripos($_folderName, 'Outbox')===false) {
4205
+		if (stripos($_folderName, 'Outbox')===false)
4206
+		{
3578 4207
 			return false;
3579 4208
 		}
3580 4209
 		// does the folder exist???
3581
-		if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) {
4210
+		if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName))
4211
+		{
3582 4212
 			$outboxFolder = $this->getOutboxFolder($_checkexistance);
3583
-			if(false !== stripos($_folderName, $outboxFolder)) {
4213
+			if(false !== stripos($_folderName, $outboxFolder))
4214
+			{
3584 4215
 				return true;
3585
-			} else {
4216
+			}
4217
+			else
4218
+			{
3586 4219
 				return false;
3587 4220
 			}
3588 4221
 		}
@@ -3598,17 +4231,25 @@  discard block
 block discarded – undo
3598 4231
 	function isDraftFolder($_folderName, $_checkexistance=TRUE)
3599 4232
 	{
3600 4233
 		$draftFolder = $this->getDraftFolder($_checkexistance);
3601
-		if(empty($draftFolder)) {
4234
+		if(empty($draftFolder))
4235
+		{
3602 4236
 			return false;
3603 4237
 		}
3604 4238
 		// does the folder exist???
3605
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4239
+		if ($_checkexistance && !$this->folderExists($_folderName))
4240
+		{
3606 4241
 			return false;
3607 4242
 		}
3608
-		if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8;
3609
-		if(false !== stripos($_folderName, $draftFolder)) {
4243
+		if (is_a($_folderName,"Horde_Imap_Client_Mailbox"))
4244
+		{
4245
+			$_folderName = $_folderName->utf8;
4246
+		}
4247
+		if(false !== stripos($_folderName, $draftFolder))
4248
+		{
3610 4249
 			return true;
3611
-		} else {
4250
+		}
4251
+		else
4252
+		{
3612 4253
 			return false;
3613 4254
 		}
3614 4255
 	}
@@ -3622,17 +4263,22 @@  discard block
 block discarded – undo
3622 4263
 	function isTrashFolder($_folderName, $_checkexistance=TRUE)
3623 4264
 	{
3624 4265
 		$trashFolder = $this->getTrashFolder($_checkexistance);
3625
-		if(empty($trashFolder)) {
4266
+		if(empty($trashFolder))
4267
+		{
3626 4268
 			return false;
3627 4269
 		}
3628 4270
 		// does the folder exist???
3629
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4271
+		if ($_checkexistance && !$this->folderExists($_folderName))
4272
+		{
3630 4273
 			return false;
3631 4274
 		}
3632 4275
 
3633
-		if(false !== stripos($_folderName, $trashFolder)) {
4276
+		if(false !== stripos($_folderName, $trashFolder))
4277
+		{
3634 4278
 			return true;
3635
-		} else {
4279
+		}
4280
+		else
4281
+		{
3636 4282
 			return false;
3637 4283
 		}
3638 4284
 	}
@@ -3646,17 +4292,22 @@  discard block
 block discarded – undo
3646 4292
 	function isTemplateFolder($_folderName, $_checkexistance=TRUE)
3647 4293
 	{
3648 4294
 		$templateFolder = $this->getTemplateFolder($_checkexistance);
3649
-		if(empty($templateFolder)) {
4295
+		if(empty($templateFolder))
4296
+		{
3650 4297
 			return false;
3651 4298
 		}
3652 4299
 		// does the folder exist???
3653
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4300
+		if ($_checkexistance && !$this->folderExists($_folderName))
4301
+		{
3654 4302
 			return false;
3655 4303
 		}
3656 4304
 
3657
-		if(false !== stripos($_folderName, $templateFolder)) {
4305
+		if(false !== stripos($_folderName, $templateFolder))
4306
+		{
3658 4307
 			return true;
3659
-		} else {
4308
+		}
4309
+		else
4310
+		{
3660 4311
 			return false;
3661 4312
 		}
3662 4313
 	}
@@ -3674,15 +4325,27 @@  discard block
 block discarded – undo
3674 4325
 		if (empty($_folder))
3675 4326
 		{
3676 4327
 			// this error is more or less without significance, unless we force the check
3677
-			if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace());
4328
+			if ($_forceCheck===true)
4329
+			{
4330
+				error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace());
4331
+			}
3678 4332
 			return false;
3679 4333
 		}
3680 4334
 		// when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder
3681
-		if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true;
3682
-		if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder =  $_folder->utf8;
4335
+		if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false)
4336
+		{
4337
+			return true;
4338
+		}
4339
+		if (is_a($_folder,"Horde_Imap_Client_Mailbox"))
4340
+		{
4341
+			$_folder =  $_folder->utf8;
4342
+		}
3683 4343
 		// reduce traffic within the Instance per User; Expire every 5 hours
3684 4344
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace());
3685
-		if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5);
4345
+		if (is_null($folderInfo))
4346
+		{
4347
+			$folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5);
4348
+		}
3686 4349
 		//error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo));
3687 4350
 		if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false)
3688 4351
 		{
@@ -3700,7 +4363,8 @@  discard block
 block discarded – undo
3700 4363
 
3701 4364
 		// does the folder exist???
3702 4365
 		//error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server'));
3703
-		if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) {
4366
+		if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder]))
4367
+		{
3704 4368
 			//error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID);
3705 4369
 			//return false;
3706 4370
 			//try to connect
@@ -3741,9 +4405,12 @@  discard block
 block discarded – undo
3741 4405
 
3742 4406
 		$this->icServer->openMailbox($folderName);
3743 4407
 
3744
-		if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") {
4408
+		if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash")
4409
+		{
3745 4410
 			$this->deleteMessages('all',$folderName,'remove_immediately');
3746
-		} else {
4411
+		}
4412
+		else
4413
+		{
3747 4414
 			$this->icServer->expunge($folderName);
3748 4415
 		}
3749 4416
 	}
@@ -3762,10 +4429,16 @@  discard block
 block discarded – undo
3762 4429
 	{
3763 4430
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod);
3764 4431
 		$oldMailbox = '';
3765
-		if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox'];
4432
+		if (is_null($_folder) || empty($_folder))
4433
+		{
4434
+			$_folder = $this->sessionData['mailbox'];
4435
+		}
3766 4436
 		if (empty($_messageUID))
3767 4437
 		{
3768
-			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4438
+			if (self::$debug)
4439
+			{
4440
+				error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4441
+			}
3769 4442
 			return false;
3770 4443
 		}
3771 4444
 		elseif ($_messageUID==='all')
@@ -3775,32 +4448,48 @@  discard block
 block discarded – undo
3775 4448
 		else
3776 4449
 		{
3777 4450
 			$uidsToDelete = new Horde_Imap_Client_Ids();
3778
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4451
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4452
+			{
4453
+				$_messageUID = (array)$_messageUID;
4454
+			}
3779 4455
 			$uidsToDelete->add($_messageUID);
3780 4456
 		}
3781 4457
 		$deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method
3782
-		if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions  = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted");
4458
+		if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately")))
4459
+		{
4460
+			$deleteOptions  = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted");
4461
+		}
3783 4462
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
3784 4463
 		$trashFolder    = $this->getTrashFolder();
3785 4464
 		$draftFolder	= $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder'];
3786 4465
 		$templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder'];
3787 4466
 		if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") ||
3788
-		   (strtolower($_folder) == strtolower($draftFolder))) {
4467
+		   (strtolower($_folder) == strtolower($draftFolder)))
4468
+		{
3789 4469
 			$deleteOptions = "remove_immediately";
3790 4470
 		}
3791
-		if($this->icServer->getCurrentMailbox() != $_folder) {
4471
+		if($this->icServer->getCurrentMailbox() != $_folder)
4472
+		{
3792 4473
 			$oldMailbox = $this->icServer->getCurrentMailbox();
3793 4474
 			$this->icServer->openMailbox($_folder);
3794 4475
 		}
3795 4476
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
3796 4477
 		$updateCache = false;
3797
-		switch($deleteOptions) {
4478
+		switch($deleteOptions)
4479
+		{
3798 4480
 			case "move_to_trash":
3799 4481
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3800 4482
 				$updateCache = true;
3801
-				if(!empty($trashFolder)) {
3802
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID));
3803
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
4483
+				if(!empty($trashFolder))
4484
+				{
4485
+					if (self::$debug)
4486
+					{
4487
+						error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID));
4488
+					}
4489
+					if (self::$debug)
4490
+					{
4491
+						error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
4492
+					}
3804 4493
 					// copy messages
3805 4494
 					try
3806 4495
 					{
@@ -3816,7 +4505,10 @@  discard block
 block discarded – undo
3816 4505
 			case "mark_as_deleted":
3817 4506
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3818 4507
 				// mark messages as deleted
3819
-				if (is_null($_messageUID)) $_messageUID='all';
4508
+				if (is_null($_messageUID))
4509
+				{
4510
+					$_messageUID='all';
4511
+				}
3820 4512
 				foreach((array)$_messageUID as $key =>$uid)
3821 4513
 				{
3822 4514
 					//flag messages, that are flagged for deletion as seen too
@@ -3824,7 +4516,10 @@  discard block
 block discarded – undo
3824 4516
 					$flags = $this->getFlags($uid);
3825 4517
 					$this->flagMessages('delete', $uid, $_folder);
3826 4518
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags));
3827
-					if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid;
4519
+					if (strpos( array2string($flags),'Deleted')!==false)
4520
+					{
4521
+						$undelete[] = $uid;
4522
+					}
3828 4523
 					unset($flags);
3829 4524
 				}
3830 4525
 				foreach((array)$undelete as $key =>$uid)
@@ -3836,7 +4531,10 @@  discard block
 block discarded – undo
3836 4531
 			case "remove_immediately":
3837 4532
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3838 4533
 				$updateCache = true;
3839
-				if (is_null($_messageUID)) $_messageUID='all';
4534
+				if (is_null($_messageUID))
4535
+				{
4536
+					$_messageUID='all';
4537
+				}
3840 4538
 				if (is_object($_messageUID))
3841 4539
 				{
3842 4540
 					$this->flagMessages('delete', $_messageUID, $_folder);
@@ -3853,7 +4551,8 @@  discard block
 block discarded – undo
3853 4551
 				$this->icServer->expunge($_folder);
3854 4552
 				break;
3855 4553
 		}
3856
-		if($oldMailbox != '') {
4554
+		if($oldMailbox != '')
4555
+		{
3857 4556
 			$this->icServer->openMailbox($oldMailbox);
3858 4557
 		}
3859 4558
 
@@ -3867,11 +4566,15 @@  discard block
 block discarded – undo
3867 4566
 	 *
3868 4567
 	 * @return null/array flags
3869 4568
 	 */
3870
-	function getFlags ($_messageUID) {
4569
+	function getFlags ($_messageUID)
4570
+	{
3871 4571
 		try
3872 4572
 		{
3873 4573
 			$uidsToFetch = new Horde_Imap_Client_Ids();
3874
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4574
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4575
+			{
4576
+				$_messageUID = (array)$_messageUID;
4577
+			}
3875 4578
 			$uidsToFetch->add($_messageUID);
3876 4579
 			$_folderName = $this->icServer->getCurrentMailbox();
3877 4580
 			$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -3879,8 +4582,10 @@  discard block
 block discarded – undo
3879 4582
 			$headersNew = $this->icServer->fetch($_folderName, $fquery, array(
3880 4583
 				'ids' => $uidsToFetch,
3881 4584
 			));
3882
-			if (is_object($headersNew)) {
3883
-				foreach($headersNew->ids() as $id) {
4585
+			if (is_object($headersNew))
4586
+			{
4587
+				foreach($headersNew->ids() as $id)
4588
+				{
3884 4589
 					$_headerObject = $headersNew->get($id);
3885 4590
 					$flags = $_headerObject->getFlags();
3886 4591
 				}
@@ -3905,10 +4610,16 @@  discard block
 block discarded – undo
3905 4610
 	 */
3906 4611
 	function getNotifyFlags ($_messageUID, $flags=null)
3907 4612
 	{
3908
-		if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags));
4613
+		if (self::$debug)
4614
+		{
4615
+			error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags));
4616
+		}
3909 4617
 		try
3910 4618
 		{
3911
-			if($flags===null) $flags =  $this->getFlags($_messageUID);
4619
+			if($flags===null)
4620
+			{
4621
+				$flags =  $this->getFlags($_messageUID);
4622
+			}
3912 4623
 		}
3913 4624
 		catch (\Exception $e)
3914 4625
 		{
@@ -3916,10 +4627,14 @@  discard block
 block discarded – undo
3916 4627
 		}
3917 4628
 
3918 4629
 		if ( stripos( array2string($flags),'MDNSent')!==false)
3919
-			return true;
4630
+		{
4631
+					return true;
4632
+		}
3920 4633
 
3921 4634
 		if ( stripos( array2string($flags),'MDNnotSent')!==false)
3922
-			return false;
4635
+		{
4636
+					return false;
4637
+		}
3923 4638
 
3924 4639
 		return null;
3925 4640
 	}
@@ -3940,7 +4655,10 @@  discard block
 block discarded – undo
3940 4655
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']);
3941 4656
 		if (empty($_messageUID))
3942 4657
 		{
3943
-			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4658
+			if (self::$debug)
4659
+			{
4660
+				error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4661
+			}
3944 4662
 			return false;
3945 4663
 		}
3946 4664
 		$this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox']));
@@ -3948,7 +4666,10 @@  discard block
 block discarded – undo
3948 4666
 		if (is_array($_messageUID)&& count($_messageUID)>50)
3949 4667
 		{
3950 4668
 			$count = $this->getMailBoxCounters($folder,true);
3951
-			if ($count->messages == count($_messageUID)) $_messageUID='all';
4669
+			if ($count->messages == count($_messageUID))
4670
+			{
4671
+				$_messageUID='all';
4672
+			}
3952 4673
 		}
3953 4674
 
3954 4675
 		if ($_messageUID==='all')
@@ -3957,7 +4678,10 @@  discard block
 block discarded – undo
3957 4678
 		}
3958 4679
 		else
3959 4680
 		{
3960
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4681
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4682
+			{
4683
+				$_messageUID = (array)$_messageUID;
4684
+			}
3961 4685
 			$messageUIDs = array_chunk($_messageUID,50,true);
3962 4686
 		}
3963 4687
 		try
@@ -3973,7 +4697,8 @@  discard block
 block discarded – undo
3973 4697
 					$uidsToModify = new Horde_Imap_Client_Ids();
3974 4698
 					$uidsToModify->add($uids);
3975 4699
 				}
3976
-				switch($_flag) {
4700
+				switch($_flag)
4701
+				{
3977 4702
 					case "delete":
3978 4703
 						$ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify));
3979 4704
 						break;
@@ -4059,7 +4784,10 @@  discard block
 block discarded – undo
4059 4784
 		{
4060 4785
 			error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage());
4061 4786
 		}
4062
-		if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8;
4787
+		if ($folder instanceof Horde_Imap_Client_Mailbox)
4788
+		{
4789
+			$_folder = $folder->utf8;
4790
+		}
4063 4791
 		//error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#');
4064 4792
 		self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0;
4065 4793
 
@@ -4088,7 +4816,10 @@  discard block
 block discarded – undo
4088 4816
 		//$deleteOptions  = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"];
4089 4817
 		if (empty($_messageUID))
4090 4818
 		{
4091
-			if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID));
4819
+			if (self::$debug)
4820
+			{
4821
+				error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID));
4822
+			}
4092 4823
 			return false;
4093 4824
 		}
4094 4825
 		elseif ($_messageUID==='all')
@@ -4100,7 +4831,10 @@  discard block
 block discarded – undo
4100 4831
 		{
4101 4832
 			//error_log(__METHOD__." Message(s): ".implode(',',$_messageUID));
4102 4833
 			$uidsToMove = new Horde_Imap_Client_Ids();
4103
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4834
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4835
+			{
4836
+				$_messageUID = (array)$_messageUID;
4837
+			}
4104 4838
 			$uidsToMove->add($_messageUID);
4105 4839
 		}
4106 4840
 		$sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']);
@@ -4122,12 +4856,14 @@  discard block
 block discarded – undo
4122 4856
 
4123 4857
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew));
4124 4858
 
4125
-			if (is_object($headersNew)) {
4859
+			if (is_object($headersNew))
4860
+			{
4126 4861
 				$c=0;
4127 4862
 				$retUid = new Horde_Imap_Client_Ids();
4128 4863
 				// we copy chunks of 5 to avoid too much memory and/or server stress
4129 4864
 				// some servers seem not to allow/support the appendig of multiple messages. so we are down to one
4130
-				foreach($headersNew as &$_headerObject) {
4865
+				foreach($headersNew as &$_headerObject)
4866
+				{
4131 4867
 					$c++;
4132 4868
 					$flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message
4133 4869
 					$date = $_headerObject->getImapDate();
@@ -4211,7 +4947,11 @@  discard block
 block discarded – undo
4211 4947
 	{
4212 4948
 		try {
4213 4949
 			$date = new DateTime($_date);	// parse date & time including timezone (throws exception, if not parsable)
4214
-			if ($convert2usertime) $date->setUser();	// convert to user-time
4950
+			if ($convert2usertime)
4951
+			{
4952
+				$date->setUser();
4953
+			}
4954
+			// convert to user-time
4215 4955
 			$date2return = $date->format($format);
4216 4956
 		}
4217 4957
 		catch(\Exception $e)
@@ -4243,9 +4983,15 @@  discard block
 block discarded – undo
4243 4983
 	static function htmlentities($_string, $_charset=false)
4244 4984
 	{
4245 4985
 		//setting the charset (if not given)
4246
-		if ($_charset===false) $_charset = self::$displayCharset;
4986
+		if ($_charset===false)
4987
+		{
4988
+			$_charset = self::$displayCharset;
4989
+		}
4247 4990
 		$string = @htmlentities($_string, ENT_QUOTES, $_charset, false);
4248
-		if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false);
4991
+		if (empty($string) && !empty($_string))
4992
+		{
4993
+			$string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false);
4994
+		}
4249 4995
 		return $string;
4250 4996
 	}
4251 4997
 
@@ -4265,18 +5011,41 @@  discard block
 block discarded – undo
4265 5011
 		$_html = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>','</td></font>','<br><td>','<tr></tr>','<o:p></o:p>','<o:p>','</o:p>'),
4266 5012
 							 array('&amp;',    '<BR>',           '<BR>',             '<BR>',             '</font></td>','<td>',    '',         '',           '',  ''),$_html);
4267 5013
 		//$_html = str_replace(array('&amp;amp;'),array('&amp;'),$_html);
4268
-		if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags
4269
-		if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head
5014
+		if (stripos($_html,'style')!==false)
5015
+		{
5016
+			Mail\Html::replaceTagsCompletley($_html,'style');
5017
+		}
5018
+		// clean out empty or pagewide style definitions / left over tags
5019
+		if (stripos($_html,'head')!==false)
5020
+		{
5021
+			Mail\Html::replaceTagsCompletley($_html,'head');
5022
+		}
5023
+		// Strip out stuff in head
4270 5024
 		//if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs
4271 5025
 		//if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
4272 5026
 		//error_log(__METHOD__.' ('.__LINE__.') '.$_html);
4273 5027
 
4274
-		if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
5028
+		if (get_magic_quotes_gpc() === 1)
5029
+		{
5030
+			$_html = stripslashes($_html);
5031
+		}
4275 5032
 		// Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards
4276
-		if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype');
4277
-		if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
4278
-		if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false);
4279
-		if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR');
5033
+		if (stripos($_html,'!doctype')!==false)
5034
+		{
5035
+			Mail\Html::replaceTagsCompletley($_html,'!doctype');
5036
+		}
5037
+		if (stripos($_html,'?xml:namespace')!==false)
5038
+		{
5039
+			Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
5040
+		}
5041
+		if (stripos($_html,'?xml version')!==false)
5042
+		{
5043
+			Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false);
5044
+		}
5045
+		if (strpos($_html,'!CURSOR')!==false)
5046
+		{
5047
+			Mail\Html::replaceTagsCompletley($_html,'!CURSOR');
5048
+		}
4280 5049
 		// htmLawed filter only the 'body'
4281 5050
 		//preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches);
4282 5051
 		//if ($matches[2])
@@ -4315,8 +5084,10 @@  discard block
 block discarded – undo
4315 5084
 		//$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1
4316 5085
 		$CharsetFound=false;
4317 5086
 		//echo "#".$_mimePartObject->encoding.'#<br>';
4318
-		if(is_array($_mimePartObject->parameters)) {
4319
-			if(isset($_mimePartObject->parameters['CHARSET'])) {
5087
+		if(is_array($_mimePartObject->parameters))
5088
+		{
5089
+			if(isset($_mimePartObject->parameters['CHARSET']))
5090
+			{
4320 5091
 				$charSet = $_mimePartObject->parameters['CHARSET'];
4321 5092
 				$CharsetFound=true;
4322 5093
 			}
@@ -4337,7 +5108,10 @@  discard block
 block discarded – undo
4337 5108
 	function decodeMimePart($_mimeMessage, $_encoding, $_charset = '')
4338 5109
 	{
4339 5110
 		// decode the part
4340
-		if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true));
5111
+		if (self::$debug)
5112
+		{
5113
+			error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true));
5114
+		}
4341 5115
 		switch (strtoupper($_encoding))
4342 5116
 		{
4343 5117
 			case 'BASE64':
@@ -4377,13 +5151,19 @@  discard block
 block discarded – undo
4377 5151
 		// sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that
4378 5152
 		// as attachment AND as abstracted ical information (we use our notification style here).
4379 5153
 		$partText = $partCalendar = $partHTML = null;
4380
-		if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure));
5154
+		if (self::$debug)
5155
+		{
5156
+			_debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure));
5157
+		}
4381 5158
 		//error_log(__METHOD__.' ('.__LINE__.') ');
4382 5159
 		$ignore_first_part = true;
4383 5160
 		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
4384 5161
 		{
4385 5162
 			//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part);
4386
-			if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5163
+			if (self::$debug)
5164
+			{
5165
+				echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5166
+			}
4387 5167
 
4388 5168
 			if ($ignore_first_part)
4389 5169
 			{
@@ -4399,11 +5179,17 @@  discard block
 block discarded – undo
4399 5179
 					switch($mimePart->getSubType())
4400 5180
 					{
4401 5181
 						case 'plain':
4402
-							if ($mimePart->getBytes() > 0) $partText = $mimePart;
5182
+							if ($mimePart->getBytes() > 0)
5183
+							{
5184
+								$partText = $mimePart;
5185
+							}
4403 5186
 							break;
4404 5187
 
4405 5188
 						case 'html':
4406
-							if ($mimePart->getBytes() > 0)  $partHTML = $mimePart;
5189
+							if ($mimePart->getBytes() > 0)
5190
+							{
5191
+								$partHTML = $mimePart;
5192
+							}
4407 5193
 							break;
4408 5194
 					}
4409 5195
 					break;
@@ -4416,7 +5202,10 @@  discard block
 block discarded – undo
4416 5202
 							if (count($mimePart->getParts()) > 1)
4417 5203
 							{
4418 5204
 								// in a multipart alternative we treat the multipart/related as html part
4419
-								if (self::$debug) error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts");
5205
+								if (self::$debug)
5206
+								{
5207
+									error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts");
5208
+								}
4420 5209
 								$partHTML = $mimePart;
4421 5210
 								break 3; // GET OUT OF LOOP, will be processed according to type
4422 5211
 							}
@@ -4497,9 +5286,15 @@  discard block
 block discarded – undo
4497 5286
 	 */
4498 5287
 	function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array())
4499 5288
 	{
4500
-		if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>";
5289
+		if (self::$debug)
5290
+		{
5291
+			echo __METHOD__."$_uid, $_htmlMode<br>";
5292
+		}
4501 5293
 		$bodyPart = array();
4502
-		if (self::$debug) _debug_array($_structure);
5294
+		if (self::$debug)
5295
+		{
5296
+			_debug_array($_structure);
5297
+		}
4503 5298
 
4504 5299
 		$ignore_first_part = true;
4505 5300
 		//$skipParts = array();
@@ -4507,7 +5302,10 @@  discard block
 block discarded – undo
4507 5302
 		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
4508 5303
 		{
4509 5304
 			//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type");
4510
-			if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5305
+			if (self::$debug)
5306
+			{
5307
+				echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5308
+			}
4511 5309
 			if ($ignore_first_part)
4512 5310
 			{
4513 5311
 				$ignore_first_part = false;
@@ -4525,7 +5323,10 @@  discard block
 block discarded – undo
4525 5323
 			switch($part->getPrimaryType())
4526 5324
 			{
4527 5325
 				case 'multipart':
4528
-					if ($part->getDisposition() == 'attachment') continue;
5326
+					if ($part->getDisposition() == 'attachment')
5327
+					{
5328
+						continue;
5329
+					}
4529 5330
 					switch($part->getSubType())
4530 5331
 					{
4531 5332
 						case 'alternative':
@@ -4590,7 +5391,9 @@  discard block
 block discarded – undo
4590 5391
 					if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment')
4591 5392
 					{
4592 5393
 						$skipParts[$mime_id.'.0'] = $mime_type;
4593
-						foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;}
5394
+						foreach($part->contentTypeMap() as $sub_id => $sub_type)
5395
+						{
5396
+$skipParts[$sub_id] = $sub_type;}
4594 5397
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts));
4595 5398
 						//break 2;
4596 5399
 					}
@@ -4633,7 +5436,10 @@  discard block
 block discarded – undo
4633 5436
 	 */
4634 5437
 	function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true)
4635 5438
 	{
4636
-		if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)");
5439
+		if (self::$debug)
5440
+		{
5441
+			error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)");
5442
+		}
4637 5443
 
4638 5444
 		if (empty($_folder))
4639 5445
 		{
@@ -4642,7 +5448,10 @@  discard block
 block discarded – undo
4642 5448
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']);
4643 5449
 		// querying contents of body part
4644 5450
 		$uidsToFetch = new Horde_Imap_Client_Ids();
4645
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
5451
+		if (!(is_object($_uid) || is_array($_uid)))
5452
+		{
5453
+			$_uid = (array)$_uid;
5454
+		}
4646 5455
 		$uidsToFetch->add($_uid);
4647 5456
 
4648 5457
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -4650,9 +5459,12 @@  discard block
 block discarded – undo
4650 5459
 			'peek' => $_preserveSeen,
4651 5460
 			'decode' => true,	// try decode on server, does NOT neccessary work
4652 5461
 		);
4653
-		if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder)))
5462
+		if ($_tryDecodingServerside===false)
5463
+		{
5464
+			// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder)))
4654 5465
 		{
4655 5466
 			$_tryDecodingServerside=false;
5467
+		}
4656 5468
 			$fetchParams = array(
4657 5469
 				'peek' => $_preserveSeen,
4658 5470
 			);
@@ -4694,7 +5506,10 @@  discard block
 block discarded – undo
4694 5506
 	{
4695 5507
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace());
4696 5508
 		$bodyPart = array();
4697
-		if (self::$debug) _debug_array(array($_structure,function_backtrace()));
5509
+		if (self::$debug)
5510
+		{
5511
+			_debug_array(array($_structure,function_backtrace()));
5512
+		}
4698 5513
 
4699 5514
 		if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text')))
4700 5515
 		{
@@ -4744,8 +5559,12 @@  discard block
 block discarded – undo
4744 5559
 	 */
4745 5560
 	function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '')
4746 5561
 	{
4747
-		if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
4748
-		if($_htmlOptions != '') {
5562
+		if (self::$debug)
5563
+		{
5564
+			echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
5565
+		}
5566
+		if($_htmlOptions != '')
5567
+		{
4749 5568
 			$this->htmlOptions = $_htmlOptions;
4750 5569
 		}
4751 5570
 		if (empty($_folder))
@@ -4834,7 +5653,9 @@  discard block
 block discarded – undo
4834 5653
 						default:
4835 5654
 							$bodyPart = array($this->getTextPart($_uid, $_structure, $this->htmlOptions, $_preserveSeen));
4836 5655
 					}
4837
-				} else {
5656
+				}
5657
+				else
5658
+				{
4838 5659
 					// what if the structure->disposition is attachment ,...
4839 5660
 				}
4840 5661
 				return self::normalizeBodyParts($bodyPart);
@@ -4845,13 +5666,18 @@  discard block
 block discarded – undo
4845 5666
 				{
4846 5667
 					case 'rfc822':
4847 5668
 						$newStructure = $_structure->getParts();
4848
-						if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);}
5669
+						if (self::$debug)
5670
+						{
5671
+echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);}
4849 5672
 						return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder));
4850 5673
 				}
4851 5674
 				break;
4852 5675
 
4853 5676
 			default:
4854
-				if (self::$debug) _debug_array($_structure);
5677
+				if (self::$debug)
5678
+				{
5679
+					_debug_array($_structure);
5680
+				}
4855 5681
 				return array(
4856 5682
 					array(
4857 5683
 						'body'		=> lang('The mimeparser can not parse this message.').$_structure->getType(),
@@ -4875,9 +5701,12 @@  discard block
 block discarded – undo
4875 5701
 		{
4876 5702
 			foreach($_bodyParts as $singleBodyPart)
4877 5703
 			{
4878
-				if (!isset($singleBodyPart['body'])) {
5704
+				if (!isset($singleBodyPart['body']))
5705
+				{
4879 5706
 					$buff = self::normalizeBodyParts($singleBodyPart);
4880
-					foreach ((array)$buff as $val) { $body2return[] = $val;}
5707
+					foreach ((array)$buff as $val)
5708
+					{
5709
+$body2return[] = $val;}
4881 5710
 					continue;
4882 5711
 				}
4883 5712
 				$body2return[] = $singleBodyPart;
@@ -4903,13 +5732,20 @@  discard block
 block discarded – undo
4903 5732
 		$message='';
4904 5733
 		for($i=0; $i<count($bodyParts); $i++)
4905 5734
 		{
4906
-			if (!isset($bodyParts[$i]['body'])) {
5735
+			if (!isset($bodyParts[$i]['body']))
5736
+			{
4907 5737
 				$bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy);
4908 5738
 				$message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body'];
4909 5739
 				continue;
4910 5740
 			}
4911
-			if (isset($bodyParts[$i]['error'])) continue;
4912
-			if (empty($bodyParts[$i]['body'])) continue;
5741
+			if (isset($bodyParts[$i]['error']))
5742
+			{
5743
+				continue;
5744
+			}
5745
+			if (empty($bodyParts[$i]['body']))
5746
+			{
5747
+				continue;
5748
+			}
4913 5749
 			// some characterreplacements, as they fail to translate
4914 5750
 			$sar = array(
4915 5751
 				'@(\x84|\x93|\x94)@',
@@ -4936,13 +5772,17 @@  discard block
 block discarded – undo
4936 5772
 				$bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']);
4937 5773
 			}
4938 5774
 
4939
-			if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']);
5775
+			if ($bodyParts[$i]['charSet']===false)
5776
+			{
5777
+				$bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']);
5778
+			}
4940 5779
 			// add line breaks to $bodyParts
4941 5780
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']);
4942 5781
 			$newBody  = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
4943 5782
 			//error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody);
4944 5783
 			$mailClass->activeMimeType = 'text/plain';
4945
-			if ($bodyParts[$i]['mimeType'] == 'text/html') {
5784
+			if ($bodyParts[$i]['mimeType'] == 'text/html')
5785
+			{
4946 5786
 				$mailClass->activeMimeType = $bodyParts[$i]['mimeType'];
4947 5787
 				if (!$preserveHTML)
4948 5788
 				{
@@ -4988,15 +5828,28 @@  discard block
 block discarded – undo
4988 5828
 						// as we switched off HTMLaweds tidy functionality
4989 5829
 						$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
4990 5830
 						$newBody = $htmLawed->run($newBody,self::$htmLawed_config);
4991
-						if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
5831
+						if ($hasOther && $preserveHTML)
5832
+						{
5833
+							$newBody = $matches[1]. $newBody. $matches[3];
5834
+						}
4992 5835
 						$alreadyHtmlLawed=true;
4993 5836
 					}
4994 5837
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody);
4995
-					if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true);
5838
+					if ($preserveHTML==false)
5839
+					{
5840
+						$newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true);
5841
+					}
4996 5842
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody);
4997
-					if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n
5843
+					if ($preserveHTML==false)
5844
+					{
5845
+						$newBody = nl2br($newBody);
5846
+					}
5847
+					// we need this, as htmLawed removes \r\n
4998 5848
 					/*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted
4999
-					if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody);
5849
+					if ($preserveHTML==false)
5850
+					{
5851
+						$newBody = str_replace("<br />","\r\n",$newBody);
5852
+					}
5000 5853
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody);
5001 5854
 				}
5002 5855
 				$message .= $newBody;
@@ -5033,12 +5886,12 @@  discard block
 block discarded – undo
5033 5886
 				  substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith
5034 5887
 				 )
5035 5888
 				)
5036
-			   )
5037
-			{
5889
+			   ) {
5038 5890
 				$s=explode(" ", $line);
5039 5891
 				$line = "";
5040 5892
 				$linecnt = 0;
5041
-				foreach ($s as &$v) {
5893
+				foreach ($s as &$v)
5894
+				{
5042 5895
 					$cnt = strlen($v);
5043 5896
 					// only break long words within the wordboundaries,
5044 5897
 					// but it may destroy links, so we check for href and dont do it if we find one
@@ -5048,14 +5901,20 @@  discard block
 block discarded – undo
5048 5901
 						$v=wordwrap($v, $allowedLength, $cut, true);
5049 5902
 					}
5050 5903
 					// the rest should be broken at the start of the new word that exceeds the limit
5051
-					if ($linecnt+$cnt > $allowedLength) {
5904
+					if ($linecnt+$cnt > $allowedLength)
5905
+					{
5052 5906
 						$v=$cut.$v;
5053 5907
 						#$linecnt = 0;
5054 5908
 						$linecnt =strlen($v)-strlen($cut);
5055
-					} else {
5909
+					}
5910
+					else
5911
+					{
5056 5912
 						$linecnt += $cnt;
5057 5913
 					}
5058
-					if (strlen($v)) $line .= (strlen($line) ? " " : "").$v;
5914
+					if (strlen($v))
5915
+					{
5916
+						$line .= (strlen($line) ? " " : "").$v;
5917
+					}
5059 5918
 				}
5060 5919
 			}
5061 5920
 			$newStr .= $line . "\n";
@@ -5076,11 +5935,18 @@  discard block
 block discarded – undo
5076 5935
 	function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false)
5077 5936
 	{
5078 5937
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace());
5079
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5938
+		if (empty($_folder))
5939
+		{
5940
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5941
+		}
5080 5942
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder");
5081
-		if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) {
5943
+		if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false)
5944
+		{
5082 5945
 			$uidsToFetch = new Horde_Imap_Client_Ids();
5083
-			if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
5946
+			if (!(is_object($_uid) || is_array($_uid)))
5947
+			{
5948
+				$_uid = (array)$_uid;
5949
+			}
5084 5950
 			$uidsToFetch->add($_uid);
5085 5951
 
5086 5952
 			$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5090,8 +5956,10 @@  discard block
 block discarded – undo
5090 5956
 			$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5091 5957
 				'ids' => $uidsToFetch,
5092 5958
 			));
5093
-			if (is_object($headersNew)) {
5094
-				foreach($headersNew as &$_headerObject) {
5959
+			if (is_object($headersNew))
5960
+			{
5961
+				foreach($headersNew as &$_headerObject)
5962
+				{
5095 5963
 					$env = $_headerObject->getEnvelope();
5096 5964
 					//_debug_array($envFields->singleFields());
5097 5965
 					$singleFields = $envFields->singleFields();
@@ -5108,7 +5976,10 @@  discard block
 block discarded – undo
5108 5976
 								//error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses));
5109 5977
 								$envelope[$v]=$env->$v->addresses;
5110 5978
 								$address = array();
5111
-								if (!is_array($envelope[$v])) break;
5979
+								if (!is_array($envelope[$v]))
5980
+								{
5981
+									break;
5982
+								}
5112 5983
 								foreach ($envelope[$v] as $k => $ad)
5113 5984
 								{
5114 5985
 									if (stripos($ad,'@')===false)
@@ -5145,7 +6016,9 @@  discard block
 block discarded – undo
5145 6016
 				}
5146 6017
 			}
5147 6018
 			return $envelope;
5148
-		} else {
6019
+		}
6020
+		else
6021
+		{
5149 6022
 
5150 6023
 			$headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder);
5151 6024
 
@@ -5156,19 +6029,43 @@  discard block
 block discarded – undo
5156 6029
 				'SUBJECT'	=> ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']),
5157 6030
 				'MESSAGE_ID'	=> $headers['MESSAGE-ID']
5158 6031
 			);
5159
-			if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO'];
5160
-			if (isset($headers['REFERENCES'])) $newData['REFERENCES'] = $headers['REFERENCES'];
5161
-			if (isset($headers['THREAD-TOPIC'])) $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC'];
5162
-			if (isset($headers['THREAD-INDEX'])) $newData['THREAD-INDEX'] = $headers['THREAD-INDEX'];
5163
-			if (isset($headers['LIST-ID'])) $newData['LIST-ID'] = $headers['LIST-ID'];
5164
-			if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE'];
6032
+			if (isset($headers['IN-REPLY-TO']))
6033
+			{
6034
+				$newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO'];
6035
+			}
6036
+			if (isset($headers['REFERENCES']))
6037
+			{
6038
+				$newData['REFERENCES'] = $headers['REFERENCES'];
6039
+			}
6040
+			if (isset($headers['THREAD-TOPIC']))
6041
+			{
6042
+				$newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC'];
6043
+			}
6044
+			if (isset($headers['THREAD-INDEX']))
6045
+			{
6046
+				$newData['THREAD-INDEX'] = $headers['THREAD-INDEX'];
6047
+			}
6048
+			if (isset($headers['LIST-ID']))
6049
+			{
6050
+				$newData['LIST-ID'] = $headers['LIST-ID'];
6051
+			}
6052
+			if (isset($headers['SIZE']))
6053
+			{
6054
+				$newData['SIZE'] = $headers['SIZE'];
6055
+			}
5165 6056
 			//_debug_array($newData);
5166 6057
 			$recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO');
5167
-			foreach($recepientList as $recepientType) {
5168
-				if(isset($headers[$recepientType])) {
5169
-					if ($decode) $headers[$recepientType] =  self::decode_header($headers[$recepientType],true);
6058
+			foreach($recepientList as $recepientType)
6059
+			{
6060
+				if(isset($headers[$recepientType]))
6061
+				{
6062
+					if ($decode)
6063
+					{
6064
+						$headers[$recepientType] =  self::decode_header($headers[$recepientType],true);
6065
+					}
5170 6066
 					//error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType]));
5171
-					foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) {
6067
+					foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress)
6068
+					{
5172 6069
 						$addressData = array(
5173 6070
 							'PERSONAL_NAME'		=> $singleAddress->personal ? $singleAddress->personal : 'NIL',
5174 6071
 							'AT_DOMAIN_LIST'	=> $singleAddress->adl ? $singleAddress->adl : 'NIL',
@@ -5176,17 +6073,25 @@  discard block
 block discarded – undo
5176 6073
 							'HOST_NAME'		=> $singleAddress->host ? $singleAddress->host : 'NIL',
5177 6074
 							'EMAIL'			=> $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox,
5178 6075
 						);
5179
-						if($addressData['PERSONAL_NAME'] != 'NIL') {
6076
+						if($addressData['PERSONAL_NAME'] != 'NIL')
6077
+						{
5180 6078
 							$addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal);
5181
-						} else {
6079
+						}
6080
+						else
6081
+						{
5182 6082
 							$addressData['RFC822_EMAIL'] = 'NIL';
5183 6083
 						}
5184 6084
 						$newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData;
5185 6085
 					}
5186
-				} else {
5187
-					if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') {
6086
+				}
6087
+				else
6088
+				{
6089
+					if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO')
6090
+					{
5188 6091
 						$newData[$recepientType] = $newData['FROM'];
5189
-					} else {
6092
+					}
6093
+					else
6094
+					{
5190 6095
 						$newData[$recepientType] = array();
5191 6096
 					}
5192 6097
 				}
@@ -5209,9 +6114,15 @@  discard block
 block discarded – undo
5209 6114
 	function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='')
5210 6115
 	{
5211 6116
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder);
5212
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6117
+		if (empty($_folder))
6118
+		{
6119
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6120
+		}
5213 6121
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5214
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
6122
+		if (!(is_object($_uid) || is_array($_uid)))
6123
+		{
6124
+			$_uid = (array)$_uid;
6125
+		}
5215 6126
 		$uidsToFetch->add($_uid);
5216 6127
 
5217 6128
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5229,7 +6140,8 @@  discard block
 block discarded – undo
5229 6140
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5230 6141
 			'ids' => $uidsToFetch,
5231 6142
 		));
5232
-		if (is_object($headersNew)) {
6143
+		if (is_object($headersNew))
6144
+		{
5233 6145
 			foreach($headersNew as $_fetchObject)
5234 6146
 			{
5235 6147
 				$headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
@@ -5251,11 +6163,17 @@  discard block
 block discarded – undo
5251 6163
 			}
5252 6164
 			if ($decode === 'object')
5253 6165
 			{
5254
-				if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
6166
+				if (is_object($headers))
6167
+				{
6168
+					$headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
6169
+				}
5255 6170
 				return $headers;
5256 6171
 			}
5257 6172
 			$retValue = is_object($headers) ? $headers->toArray():array();
5258
-			if ($size) $retValue['size'] = $size;
6173
+			if ($size)
6174
+			{
6175
+				$retValue['size'] = $size;
6176
+			}
5259 6177
 		}
5260 6178
 		$retValue = array_change_key_case($retValue,CASE_UPPER);
5261 6179
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue));
@@ -5287,10 +6205,16 @@  discard block
 block discarded – undo
5287 6205
 	function getMessageRawHeader($_uid, $_partID = '', $_folder = '')
5288 6206
 	{
5289 6207
 		static $rawHeaders;
5290
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6208
+		if (empty($_folder))
6209
+		{
6210
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6211
+		}
5291 6212
 		//error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder");
5292 6213
 
5293
-		if (is_null($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
6214
+		if (is_null($rawHeaders)||!is_array($rawHeaders))
6215
+		{
6216
+			$rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
6217
+		}
5294 6218
 		if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
5295 6219
 		{
5296 6220
 			//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder");
@@ -5298,7 +6222,10 @@  discard block
 block discarded – undo
5298 6222
 		}
5299 6223
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5300 6224
 		$uid = $_uid;
5301
-		if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid;
6225
+		if (!(is_object($_uid) || is_array($_uid)))
6226
+		{
6227
+			$uid = (array)$_uid;
6228
+		}
5302 6229
 		$uidsToFetch->add($uid);
5303 6230
 
5304 6231
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5314,8 +6241,10 @@  discard block
 block discarded – undo
5314 6241
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5315 6242
 			'ids' => $uidsToFetch,
5316 6243
 		));
5317
-		if (is_object($headersNew)) {
5318
-			foreach($headersNew as &$_headerObject) {
6244
+		if (is_object($headersNew))
6245
+		{
6246
+			foreach($headersNew as &$_headerObject)
6247
+			{
5319 6248
 				$retValue = $_headerObject->getHeaderText();
5320 6249
 				if ($_partID != '')
5321 6250
 				{
@@ -5343,22 +6272,33 @@  discard block
 block discarded – undo
5343 6272
 	static function &getStyles($_bodyParts)
5344 6273
 	{
5345 6274
 		$style = '';
5346
-		if (empty($_bodyParts)) return "";
5347
-		foreach((array)$_bodyParts as $singleBodyPart) {
5348
-			if (!isset($singleBodyPart['body'])) {
6275
+		if (empty($_bodyParts))
6276
+		{
6277
+			return "";
6278
+		}
6279
+		foreach((array)$_bodyParts as $singleBodyPart)
6280
+		{
6281
+			if (!isset($singleBodyPart['body']))
6282
+			{
5349 6283
 				$singleBodyPart['body'] = self::getStyles($singleBodyPart);
5350 6284
 				$style .= $singleBodyPart['body'];
5351 6285
 				continue;
5352 6286
 			}
5353 6287
 
5354
-			if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']);
6288
+			if ($singleBodyPart['charSet']===false)
6289
+			{
6290
+				$singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']);
6291
+			}
5355 6292
 			$singleBodyPart['body'] = Translation::convert(
5356 6293
 				$singleBodyPart['body'],
5357 6294
 				strtolower($singleBodyPart['charSet'])
5358 6295
 			);
5359 6296
 			$ct = 0;
5360 6297
 			$newStyle=array();
5361
-			if (stripos($singleBodyPart['body'],'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle);
6298
+			if (stripos($singleBodyPart['body'],'<style')!==false)
6299
+			{
6300
+				$ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle);
6301
+			}
5362 6302
 			if ($ct>0)
5363 6303
 			{
5364 6304
 				//error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle));
@@ -5390,7 +6330,11 @@  discard block
 block discarded – undo
5390 6330
 		// CSS Security
5391 6331
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
5392 6332
 		$css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style);
5393
-		if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included
6333
+		if (stripos($css,'script')!==false)
6334
+		{
6335
+			Mail\Html::replaceTagsCompletley($css,'script');
6336
+		}
6337
+		// Strip out script that may be included
5394 6338
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
5395 6339
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
5396 6340
 		$css = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
@@ -5411,8 +6355,14 @@  discard block
 block discarded – undo
5411 6355
 	{
5412 6356
 		//TODO: caching einbauen static!
5413 6357
 		static $rawBody;
5414
-		if (is_null($rawBody)) $rawBody = array();
5415
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6358
+		if (is_null($rawBody))
6359
+		{
6360
+			$rawBody = array();
6361
+		}
6362
+		if (empty($_folder))
6363
+		{
6364
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6365
+		}
5416 6366
 		if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
5417 6367
 		{
5418 6368
 			//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder");
@@ -5421,7 +6371,10 @@  discard block
 block discarded – undo
5421 6371
 
5422 6372
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5423 6373
 		$uid = $_uid;
5424
-		if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid;
6374
+		if (!(is_object($_uid) || is_array($_uid)))
6375
+		{
6376
+			$uid = (array)$_uid;
6377
+		}
5425 6378
 		$uidsToFetch->add($uid);
5426 6379
 
5427 6380
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5434,8 +6387,10 @@  discard block
 block discarded – undo
5434 6387
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5435 6388
 			'ids' => $uidsToFetch,
5436 6389
 		));
5437
-		if (is_object($headersNew)) {
5438
-			foreach($headersNew as &$_headerObject) {
6390
+		if (is_object($headersNew))
6391
+		{
6392
+			foreach($headersNew as &$_headerObject)
6393
+			{
5439 6394
 				$body = $_headerObject->getFullMsg();
5440 6395
 				if ($_partID != '')
5441 6396
 				{
@@ -5468,14 +6423,20 @@  discard block
 block discarded – undo
5468 6423
 	 */
5469 6424
 	function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false)
5470 6425
 	{
5471
-		if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID");
6426
+		if (self::$debug)
6427
+		{
6428
+			error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID");
6429
+		}
5472 6430
 
5473 6431
 		if (empty($_folder))
5474 6432
 		{
5475 6433
 			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5476 6434
 		}
5477 6435
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5478
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
6436
+		if (!(is_object($_uid) || is_array($_uid)))
6437
+		{
6438
+			$_uid = (array)$_uid;
6439
+		}
5479 6440
 		$uidsToFetch->add($_uid);
5480 6441
 		try
5481 6442
 		{
@@ -5484,7 +6445,10 @@  discard block
 block discarded – undo
5484 6445
 	//		$fquery->envelope();
5485 6446
 	//		$fquery->size();
5486 6447
 			$_fquery->structure();
5487
-			if ($_partID) $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen));
6448
+			if ($_partID)
6449
+			{
6450
+				$_fquery->bodyPart($_partID, array('peek' => $_preserveSeen));
6451
+			}
5488 6452
 
5489 6453
 			$mail = $this->icServer->fetch($_folder, $_fquery, array(
5490 6454
 				'ids' => $uidsToFetch,
@@ -5515,16 +6479,28 @@  discard block
 block discarded – undo
5515 6479
 	 */
5516 6480
 	function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='')
5517 6481
 	{
5518
-		if (self::$debug) error_log( __METHOD__.":$_uid, $_partID");
5519
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6482
+		if (self::$debug)
6483
+		{
6484
+			error_log( __METHOD__.":$_uid, $_partID");
6485
+		}
6486
+		if (empty($_folder))
6487
+		{
6488
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6489
+		}
5520 6490
 		$attachments = array();
5521 6491
 		if (!isset($_structure))
5522 6492
 		{
5523 6493
 			$_structure = $this->getStructure($_uid, $_partID,$_folder,true);
5524 6494
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true));
5525 6495
 		}
5526
-		if (!$_structure || !$_structure->contentTypeMap()) return array();
5527
-		if (!empty($_partID)) $_structure = $_structure->getPart($_partID);
6496
+		if (!$_structure || !$_structure->contentTypeMap())
6497
+		{
6498
+			return array();
6499
+		}
6500
+		if (!empty($_partID))
6501
+		{
6502
+			$_structure = $_structure->getPart($_partID);
6503
+		}
5528 6504
 		$skipParts = array();
5529 6505
 		$tnefParts = array();
5530 6506
 		$skip = 0;
@@ -5553,7 +6529,13 @@  discard block
 block discarded – undo
5553 6529
 			if ($mime_type=='message/rfc822' && $_partID!=$mime_id)
5554 6530
 			{
5555 6531
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap()));
5556
-				foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;}
6532
+				foreach($part->contentTypeMap() as $sub_id => $sub_type)
6533
+				{
6534
+if ($sub_id != $mime_id)
6535
+				{
6536
+					$skipParts[$sub_id] = $sub_type;
6537
+				}
6538
+				}
5557 6539
 			}
5558 6540
 			if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')
5559 6541
 			{
@@ -5564,7 +6546,10 @@  discard block
 block discarded – undo
5564 6546
 				$partDisposition='attachment';
5565 6547
 			}
5566 6548
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts));
5567
-			if (array_key_exists($mime_id,$skipParts)) continue;
6549
+			if (array_key_exists($mime_id,$skipParts))
6550
+			{
6551
+				continue;
6552
+			}
5568 6553
 
5569 6554
 			if ($partDisposition == 'attachment' ||
5570 6555
 				(($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') ||
@@ -5575,23 +6560,41 @@  discard block
 block discarded – undo
5575 6560
 			{
5576 6561
 				// if type is message/rfc822 and _partID is given, and MimeID equals partID
5577 6562
 				// we attempt to fetch "ourselves"
5578
-				if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue;
6563
+				if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message')
6564
+				{
6565
+					continue;
6566
+				}
5579 6567
 				$attachment = $part->getAllDispositionParameters();
5580 6568
 				$attachment['disposition'] = $part->getDisposition();
5581 6569
 				$attachment['mimeType'] = $mime_type;
5582 6570
 				$attachment['uid'] = $_uid;
5583 6571
 				$attachment['partID'] = $mime_id;
5584
-				if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName();
6572
+				if (!isset($attachment['name'])||empty($attachment['name']))
6573
+				{
6574
+					$attachment['name'] = $part->getName();
6575
+				}
5585 6576
 				if ($fetchTextCalendar)
5586 6577
 				{
5587 6578
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters()));
5588 6579
 					$method = $part->getContentTypeParameter('method');
5589
-					if ($method) $attachment['method'] = $method;
5590
-					if (!isset($attachment['name'])) $attachment['name'] = 'event.ics';
6580
+					if ($method)
6581
+					{
6582
+						$attachment['method'] = $method;
6583
+					}
6584
+					if (!isset($attachment['name']))
6585
+					{
6586
+						$attachment['name'] = 'event.ics';
6587
+					}
5591 6588
 				}
5592 6589
 				$attachment['size'] = $part->getBytes();
5593
-				if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5594
-				if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type);
6590
+				if (($cid = $part->getContentId()))
6591
+				{
6592
+					$attachment['cid'] = $cid;
6593
+				}
6594
+				if (empty($attachment['name']))
6595
+				{
6596
+					$attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type);
6597
+				}
5595 6598
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment));
5596 6599
 				//typical winmail.dat attachment is
5597 6600
 				//Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat)
@@ -5627,14 +6630,26 @@  discard block
 block discarded – undo
5627 6630
 						$attachment['uid'] = $tnp['uid'];
5628 6631
 						$attachment['partID'] = $tnp['partID'];
5629 6632
 						$attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id;
5630
-						if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName();
6633
+						if (!isset($attachment['name'])||empty($attachment['name']))
6634
+						{
6635
+							$attachment['name'] = $part->getName();
6636
+						}
5631 6637
 						$attachment['size'] = $part->getBytes();
5632
-						if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5633
-						if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6638
+						if (($cid = $part->getContentId()))
6639
+						{
6640
+							$attachment['cid'] = $cid;
6641
+						}
6642
+						if (empty($attachment['name']))
6643
+						{
6644
+							$attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6645
+						}
5634 6646
 						$attachments[] = $attachment;
5635 6647
 					}
5636 6648
 				}
5637
-				if ($tnefResolved===false) $attachments[]=$tnp;
6649
+				if ($tnefResolved===false)
6650
+				{
6651
+					$attachments[]=$tnp;
6652
+				}
5638 6653
 			}
5639 6654
 		}
5640 6655
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
@@ -5738,8 +6753,14 @@  discard block
 block discarded – undo
5738 6753
 
5739 6754
 				$attachment = $part->getAllDispositionParameters();
5740 6755
 				$attachment['mimeType'] = $part->getType();
5741
-				if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5742
-				if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
6756
+				if (!isset($attachment['filename'])||empty($attachment['filename']))
6757
+				{
6758
+					$attachment['filename'] = $part->getName();
6759
+				}
6760
+				if (($cid = $part->getContentId()))
6761
+				{
6762
+					$attachment['cid'] = $cid;
6763
+				}
5743 6764
 				if (empty($attachment['filename']))
5744 6765
 				{
5745 6766
 					$attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?
@@ -5751,7 +6772,10 @@  discard block
 block discarded – undo
5751 6772
 				$attachments[$_uid.'@'.$_partID.'@'.$mime_id] = $attachment;
5752 6773
 			}
5753 6774
 		}
5754
-		if (!is_array($attachments)) return false;
6775
+		if (!is_array($attachments))
6776
+		{
6777
+			return false;
6778
+		}
5755 6779
 		return $attachments;
5756 6780
 	}
5757 6781
 
@@ -5770,10 +6794,16 @@  discard block
 block discarded – undo
5770 6794
 	function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null)
5771 6795
 	{
5772 6796
 		//error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace());
5773
-		if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6797
+		if (!isset($_folder))
6798
+		{
6799
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6800
+		}
5774 6801
 
5775 6802
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5776
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
6803
+		if (!(is_object($_uid) || is_array($_uid)))
6804
+		{
6805
+			$_uid = (array)$_uid;
6806
+		}
5777 6807
 		$uidsToFetch->add($_uid);
5778 6808
 
5779 6809
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5782,8 +6812,10 @@  discard block
 block discarded – undo
5782 6812
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5783 6813
 			'ids' => $uidsToFetch,
5784 6814
 		));
5785
-		if (is_object($headersNew)) {
5786
-			foreach($headersNew as $id=>$_headerObject) {
6815
+		if (is_object($headersNew))
6816
+		{
6817
+			foreach($headersNew as $id=>$_headerObject)
6818
+			{
5787 6819
 				$body = $_headerObject->getFullMsg();
5788 6820
 				if ($_partID != '')
5789 6821
 				{
@@ -5797,7 +6829,10 @@  discard block
 block discarded – undo
5797 6829
 					}
5798 6830
 					// if $partDisposition is empty, we assume attachment, and hope that the function
5799 6831
 					// itself is only triggered to fetch attachments
5800
-					if (empty($partDisposition)) $partDisposition='attachment';
6832
+					if (empty($partDisposition))
6833
+					{
6834
+						$partDisposition='attachment';
6835
+					}
5801 6836
 					if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar')))
5802 6837
 					{
5803 6838
 						//$headerObject=$part->getAllDispositionParameters();//not used anywhere around here
@@ -5806,13 +6841,19 @@  discard block
 block discarded – undo
5806 6841
 						$charset = $part->getContentTypeParameter('charset');
5807 6842
 						//$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" );
5808 6843
 						$this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime);
5809
-						if ($_returnPart) return $part;
6844
+						if ($_returnPart)
6845
+						{
6846
+							return $part;
6847
+						}
5810 6848
 					}
5811 6849
 				}
5812 6850
 			}
5813 6851
 		}
5814 6852
 		$ext = MimeMagic::mime2ext($structure_mime);
5815
-		if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext;
6853
+		if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false)
6854
+		{
6855
+			$filename = trim($filename).'.'.$ext;
6856
+		}
5816 6857
 		if (!$part)
5817 6858
 		{
5818 6859
 			throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder");
@@ -5828,7 +6869,10 @@  discard block
 block discarded – undo
5828 6869
 		);
5829 6870
 
5830 6871
 		// try guessing the mimetype, if we get the application/octet-stream
5831
-		if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']);
6872
+		if (strtolower($attachmentData['type']) == 'application/octet-stream')
6873
+		{
6874
+			$attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']);
6875
+		}
5832 6876
 		# if the attachment holds a winmail number and is a winmail.dat then we have to handle that.
5833 6877
 		if ( $filename == 'winmail.dat' && $_winmail_nr)
5834 6878
 		{
@@ -5851,9 +6895,18 @@  discard block
 block discarded – undo
5851 6895
 					if ($_winmail_nr == $wantedPart.'@'.$mime_id)
5852 6896
 					{
5853 6897
 						//error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment));
5854
-						if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5855
-						if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5856
-						if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6898
+						if (!isset($attachment['filename'])||empty($attachment['filename']))
6899
+						{
6900
+							$attachment['filename'] = $part->getName();
6901
+						}
6902
+						if (($cid = $part->getContentId()))
6903
+						{
6904
+							$attachment['cid'] = $cid;
6905
+						}
6906
+						if (empty($attachment['filename']))
6907
+						{
6908
+							$attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6909
+						}
5857 6910
 						$wmattach = $attachment;
5858 6911
 						$wmattach['attachment'] = $part->getContents(array('stream'=>$_stream));
5859 6912
 
@@ -5863,7 +6916,10 @@  discard block
 block discarded – undo
5863 6916
 			if ($tnefResolved)
5864 6917
 			{
5865 6918
 				$ext = MimeMagic::mime2ext($wmattach['mimeType']);
5866
-				if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext;
6919
+				if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false)
6920
+				{
6921
+					$wmattach['filename'] = trim($wmattach['filename']).'.'.$ext;
6922
+				}
5867 6923
 				$attachmentData = array(
5868 6924
 					'type'       => $wmattach['mimeType'],
5869 6925
 					'filename'   => $wmattach['filename'],
@@ -5893,7 +6949,10 @@  discard block
 block discarded – undo
5893 6949
 		static $uid=null, $part=null, $structure=null;
5894 6950
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part");
5895 6951
 
5896
-		if(empty($_cid)) return false;
6952
+		if(empty($_cid))
6953
+		{
6954
+			return false;
6955
+		}
5897 6956
 
5898 6957
 		if ($_uid != $uid || $_part != $part)
5899 6958
 		{
@@ -5918,13 +6977,19 @@  discard block
 block discarded – undo
5918 6977
 					$attachment = $part;
5919 6978
 				}
5920 6979
 				// everything else we only consider after we checked all
5921
-				if (!isset($attachment)) $attachment = $part;
6980
+				if (!isset($attachment))
6981
+				{
6982
+					$attachment = $part;
6983
+				}
5922 6984
 				// do we want content fetched, can be done later, if not needed
5923 6985
 				if (isset($_stream))
5924 6986
 				{
5925 6987
 					$this->fetchPartContents($_uid, $attachment, $_stream);
5926 6988
 				}
5927
-				if (isset($attachment)) break;
6989
+				if (isset($attachment))
6990
+				{
6991
+					break;
6992
+				}
5928 6993
 			}
5929 6994
 		}
5930 6995
 		// set name as filename, if not set
@@ -5955,10 +7020,17 @@  discard block
 block discarded – undo
5955 7020
 	 */
5956 7021
 	public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null)
5957 7022
 	{
5958
-		if (is_null($part)) return null;//new Horde_Mime_Part;
7023
+		if (is_null($part))
7024
+		{
7025
+			return null;
7026
+		}
7027
+		//new Horde_Mime_Part;
5959 7028
 		$encoding = null;
5960 7029
 		$fetchAsBinary = true;
5961
-		if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false;
7030
+		if ($_mimetype && strtolower($_mimetype)=='message/rfc822')
7031
+		{
7032
+			$fetchAsBinary = false;
7033
+		}
5962 7034
 		// we need to set content on structure to decode transfer encoding
5963 7035
 		$part->setContents(
5964 7036
 			$this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary),
@@ -5995,7 +7067,10 @@  discard block
 block discarded – undo
5995 7067
 		// the recent flag is the default enforced here ; as we assume the _flags is always set,
5996 7068
 		// we default it to hordes default (Recent) (, other wise we should not pass the parameter
5997 7069
 		// for flags at all)
5998
-		if (empty($_flags)) $_flags = '\\Recent';
7070
+		if (empty($_flags))
7071
+		{
7072
+			$_flags = '\\Recent';
7073
+		}
5999 7074
 		//if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags);
6000 7075
 		//if (!is_array($_flags)) $_flags = (array) $_flags;
6001 7076
 		try
@@ -6012,18 +7087,27 @@  discard block
 block discarded – undo
6012 7087
 		}
6013 7088
 		catch (\Exception $e)
6014 7089
 		{
6015
-			if (self::$debug) error_log("Could not append Message: ".$e->getMessage());
7090
+			if (self::$debug)
7091
+			{
7092
+				error_log("Could not append Message: ".$e->getMessage());
7093
+			}
6016 7094
 			throw new Exception\WrongUserinput(lang("Could not append Message:").' '.$e->getMessage().': '.$e->details);
6017 7095
 			//return false;
6018 7096
 		}
6019 7097
 		//error_log(__METHOD__.' ('.__LINE__.') '.' appended UID:'.$messageid);
6020 7098
 		//$messageid = true; // for debug reasons only
6021
-		if ($messageid === true || empty($messageid)) // try to figure out the message uid
7099
+		if ($messageid === true || empty($messageid))
7100
+		{
7101
+			// try to figure out the message uid
6022 7102
 		{
6023 7103
 			$list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false);
7104
+		}
6024 7105
 			if ($list)
6025 7106
 			{
6026
-				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list));
7107
+				if (self::$debug)
7108
+				{
7109
+					error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list));
7110
+				}
6027 7111
 				$messageid = $list['header'][0]['uid'];
6028 7112
 			}
6029 7113
 		}
@@ -6064,7 +7148,10 @@  discard block
 block discarded – undo
6064 7148
 	{
6065 7149
 			//echo __METHOD__." called for $uid,$partid <br>";
6066 7150
 			$headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox);
6067
-			if (empty($headers)) return false;
7151
+			if (empty($headers))
7152
+			{
7153
+				return false;
7154
+			}
6068 7155
 			// dont force retrieval of the textpart, let mailClass preferences decide
6069 7156
 			$bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox);
6070 7157
 			// if we do not want HTML but there is no TextRepresentation with the message itself, try converting
@@ -6082,15 +7169,30 @@  discard block
 block discarded – undo
6082 7169
 			//error_log(array2string($bodyParts));
6083 7170
 			$attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array();
6084 7171
 
6085
-			if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO'];
6086
-			elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM'];
6087
-			elseif (isset($headers['SENDER'])) $mailaddress = $headers['SENDER'];
6088
-			if (isset($headers['CC'])) $mailaddress .= ','.$headers['CC'];
7172
+			if ($mailClass->isSentFolder($mailbox))
7173
+			{
7174
+				$mailaddress = $headers['TO'];
7175
+			}
7176
+			elseif (isset($headers['FROM']))
7177
+			{
7178
+				$mailaddress = $headers['FROM'];
7179
+			}
7180
+			elseif (isset($headers['SENDER']))
7181
+			{
7182
+				$mailaddress = $headers['SENDER'];
7183
+			}
7184
+			if (isset($headers['CC']))
7185
+			{
7186
+				$mailaddress .= ','.$headers['CC'];
7187
+			}
6089 7188
 			//_debug_array(array($headers,$mailaddress));
6090 7189
 			$subject = $headers['SUBJECT'];
6091 7190
 
6092 7191
 			$message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML);
6093
-			if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>';
7192
+			if ($preserveHTML && $mailClass->activeMimeType == 'text/plain')
7193
+			{
7194
+				$message = '<pre>'.$message.'</pre>';
7195
+			}
6094 7196
 			$headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : '');
6095 7197
 			$message = $headdata.$message;
6096 7198
 			//echo __METHOD__.'<br>';
@@ -6141,7 +7243,8 @@  discard block
 block discarded – undo
6141 7243
 							$attachments[$num]['attachment'] = $c->getContents();
6142 7244
 						}
6143 7245
 						// no attempt to convert, if we dont know about the charset
6144
-						if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) {
7246
+						if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset']))
7247
+						{
6145 7248
 							// we do not try guessing the charset, if it is not set
6146 7249
 							//if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']);
6147 7250
 							Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']);
@@ -6162,7 +7265,10 @@  discard block
 block discarded – undo
6162 7265
 						unset($attachments[$num]['attachment']);
6163 7266
 					}
6164 7267
 				}
6165
-				if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages);
7268
+				if (is_array($attachedMessages))
7269
+				{
7270
+					$attachments = array_merge($attachments,$attachedMessages);
7271
+				}
6166 7272
 			}
6167 7273
 			return array(
6168 7274
 					'mailaddress'=>$mailaddress,
@@ -6184,10 +7290,17 @@  discard block
 block discarded – undo
6184 7290
 	{
6185 7291
 		$c = 0;
6186 7292
 		// use the standardIdentity
6187
-		foreach($_identities as $key => $acc) {
6188
-			if ($c==0) $identity = $acc;
7293
+		foreach($_identities as $key => $acc)
7294
+		{
7295
+			if ($c==0)
7296
+			{
7297
+				$identity = $acc;
7298
+			}
6189 7299
 			//error_log(__METHOD__.__LINE__." $key == $_profile_id ");
6190
-			if ($key==$_profile_id) $identity = $acc;
7300
+			if ($key==$_profile_id)
7301
+			{
7302
+				$identity = $acc;
7303
+			}
6191 7304
 			$c++;
6192 7305
 		}
6193 7306
 		return $identity;
@@ -6203,20 +7316,53 @@  discard block
 block discarded – undo
6203 7316
 	{
6204 7317
 		$headdata = null;
6205 7318
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace());
6206
-		if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n");
6207
-		if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n");
6208
-		if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n");
6209
-		if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n");
6210
-		if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n");
6211
-		if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n");
6212
-		if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n");
6213
-		if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n");
6214
-		if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n");
7319
+		if ($header['SUBJECT'])
7320
+		{
7321
+			$headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n");
7322
+		}
7323
+		if ($header['FROM'])
7324
+		{
7325
+			$headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n");
7326
+		}
7327
+		if ($header['SENDER'])
7328
+		{
7329
+			$headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n");
7330
+		}
7331
+		if ($header['TO'])
7332
+		{
7333
+			$headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n");
7334
+		}
7335
+		if ($header['CC'])
7336
+		{
7337
+			$headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n");
7338
+		}
7339
+		if ($header['BCC'])
7340
+		{
7341
+			$headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n");
7342
+		}
7343
+		if ($header['DATE'])
7344
+		{
7345
+			$headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n");
7346
+		}
7347
+		if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal')
7348
+		{
7349
+			$headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n");
7350
+		}
7351
+		if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal')
7352
+		{
7353
+			$headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n");
7354
+		}
6215 7355
 		//if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\
6216 7356
 		if (!empty($headdata))
6217 7357
 		{
6218
-			if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
6219
-			if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata;
7358
+			if (!empty($headline) && $headline != 'SUPPRESS')
7359
+			{
7360
+				$headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
7361
+			}
7362
+			if (empty($headline))
7363
+			{
7364
+				$headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata;
7365
+			}
6220 7366
 			$headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'');
6221 7367
 		}
6222 7368
 		else
@@ -6250,12 +7396,15 @@  discard block
 block discarded – undo
6250 7396
 		$returnAddr ='';
6251 7397
 		if (is_array($rfcAddressArray))
6252 7398
 		{
6253
-			foreach((array)$rfcAddressArray as $addressData) {
7399
+			foreach((array)$rfcAddressArray as $addressData)
7400
+			{
6254 7401
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData));
6255
-				if($addressData['MAILBOX_NAME'] == 'NIL') {
7402
+				if($addressData['MAILBOX_NAME'] == 'NIL')
7403
+				{
6256 7404
 					continue;
6257 7405
 				}
6258
-				if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') {
7406
+				if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients')
7407
+				{
6259 7408
 					continue;
6260 7409
 				}
6261 7410
 				if ($addressData['RFC822_EMAIL'])
@@ -6269,7 +7418,10 @@  discard block
 block discarded – undo
6269 7418
 				}
6270 7419
 				$addressObject = $addressObjectA[0];
6271 7420
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject));
6272
-				if (!$addressObject->valid) continue;
7421
+				if (!$addressObject->valid)
7422
+				{
7423
+					continue;
7424
+				}
6273 7425
 				//$mb =(string)$addressObject->mailbox;
6274 7426
 				//$h = (string)$addressObject->host;
6275 7427
 				//$p = (string)$addressObject->personal;
@@ -6286,7 +7438,10 @@  discard block
 block discarded – undo
6286 7438
 			// do not mess with strings, return them untouched /* ToDo: validate string as Address */
6287 7439
 			$rfcAddressArray = self::decode_header($rfcAddressArray,true);
6288 7440
 			$rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray);
6289
-			if (is_string($rfcAddressArray)) return $rfcAddressArray;
7441
+			if (is_string($rfcAddressArray))
7442
+			{
7443
+				return $rfcAddressArray;
7444
+			}
6290 7445
 		}
6291 7446
 		return $returnAddr;
6292 7447
 	}
@@ -6303,10 +7458,19 @@  discard block
 block discarded – undo
6303 7458
 	{
6304 7459
 		$mergeobj = new Contacts\Merge();
6305 7460
 
6306
-		if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html');
7461
+		if (empty($mimetype))
7462
+		{
7463
+			$mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html');
7464
+		}
6307 7465
 		$rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset);
6308
-		if (empty($rv) && !empty($content) && !empty($err)) $rv = $content;
6309
-		if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err));
7466
+		if (empty($rv) && !empty($content) && !empty($err))
7467
+		{
7468
+			$rv = $content;
7469
+		}
7470
+		if (!empty($err) && !empty($content) && !empty($ids))
7471
+		{
7472
+			error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err));
7473
+		}
6310 7474
 		return $rv;
6311 7475
 	}
6312 7476
 
@@ -6343,13 +7507,15 @@  discard block
 block discarded – undo
6343 7507
 			settype($bytes, 'integer');
6344 7508
 			$bytes /= 10;
6345 7509
 		}
6346
-		else
6347
-			settype($bytes, 'integer');
7510
+		else {
7511
+					settype($bytes, 'integer');
7512
+		}
6348 7513
 
6349 7514
 		return $bytes . ' ' . $type ;
6350 7515
 	}
6351 7516
 
6352
-	static function detect_qp(&$sting) {
7517
+	static function detect_qp(&$sting)
7518
+	{
6353 7519
 		$needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/';
6354 7520
 		return preg_match("$needle",$string);
6355 7521
 	}
@@ -6366,9 +7532,15 @@  discard block
 block discarded – undo
6366 7532
 	 */
6367 7533
 	static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='')
6368 7534
 	{
6369
-		if (is_null($_endtime)) $_endtime = microtime(true);
7535
+		if (is_null($_endtime))
7536
+		{
7537
+			$_endtime = microtime(true);
7538
+		}
6370 7539
 		$usagetime = microtime(true) - $_starttime;
6371
-		if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:''));
7540
+		if (self::$debugTimes)
7541
+		{
7542
+			error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:''));
7543
+		}
6372 7544
 	}
6373 7545
 
6374 7546
 	/**
@@ -6383,7 +7555,10 @@  discard block
 block discarded – undo
6383 7555
 	 */
6384 7556
 	static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822')
6385 7557
 	{
6386
-		if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file'];
7558
+		if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data')
7559
+		{
7560
+			return $_formData['file'];
7561
+		}
6387 7562
 
6388 7563
 		//error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType);
6389 7564
 		$importfailed = $tmpFileName = false;
@@ -6432,8 +7607,15 @@  discard block
 block discarded – undo
6432 7607
 			{
6433 7608
 				$buff = explode('.',$_formData['name']);
6434 7609
 				$suffix = '';
6435
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
6436
-				if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix);
7610
+				if (is_array($buff))
7611
+				{
7612
+					$suffix = array_pop($buff);
7613
+				}
7614
+				// take the last extension to check with ext2mime
7615
+				if (!empty($suffix))
7616
+				{
7617
+					$sfxMimeType = MimeMagic::ext2mime($suffix);
7618
+				}
6437 7619
 				if (!empty($suffix) && !empty($sfxMimeType) &&
6438 7620
 					(strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType)))
6439 7621
 				{
@@ -6481,7 +7663,9 @@  discard block
 block discarded – undo
6481 7663
 			{
6482 7664
 				rename($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName);
6483 7665
 			}
6484
-		} else {
7666
+		}
7667
+		else
7668
+		{
6485 7669
 			//error_log("Import of message ".$_formData['file']." failes to meet basic restrictions");
6486 7670
 			$importfailed = true;
6487 7671
 			$alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']);
@@ -6527,21 +7711,32 @@  discard block
 block discarded – undo
6527 7711
 				if (substr($url, 0, 5) !== 'data:')
6528 7712
 				{
6529 7713
 					$filename = basename($url);
6530
-					if (($directory = dirname($url)) == '.') $directory = '';
7714
+					if (($directory = dirname($url)) == '.')
7715
+					{
7716
+						$directory = '';
7717
+					}
6531 7718
 					$ext = pathinfo($filename, PATHINFO_EXTENSION);
6532 7719
 					$mimeType  = MimeMagic::ext2mime($ext);
6533
-					if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
7720
+					if ( strlen($directory) > 1 && substr($directory,-1) != '/')
7721
+					{
7722
+$directory .= '/'; }
6534 7723
 					$myUrl = $directory.$filename;
6535
-					if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs)
7724
+					if ($myUrl[0]=='/')
7725
+					{
7726
+						// local path -> we only allow path's that are available via http/https (or vfs)
6536 7727
 					{
6537 7728
 						$basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']);
6538 7729
 					}
7730
+					}
6539 7731
 					// use vfs instead of url containing webdav.php
6540 7732
 					// ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign
6541 7733
 					// webdav.php urls as vfs
6542
-					if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it.
7734
+					if (strpos($myUrl,'/webdav.php') !== false)
7735
+					{
7736
+						// we have a webdav link, so we build a vfs/sqlfs link of it.
6543 7737
 					{
6544 7738
 						Vfs::load_wrapper('vfs');
7739
+					}
6545 7740
 						list(,$myUrl) = explode('/webdav.php',$myUrl,2);
6546 7741
 						$basedir = 'vfs://default';
6547 7742
 						$needTempFile = false;
@@ -6570,8 +7765,13 @@  discard block
 block discarded – undo
6570 7765
 						}
6571 7766
 					}
6572 7767
 
6573
-					if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; }
6574
-					if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl));
7768
+					if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/')
7769
+					{
7770
+$basedir .= '/'; }
7771
+					if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http")
7772
+					{
7773
+						$data = file_get_contents($basedir.urldecode($myUrl));
7774
+					}
6575 7775
 				}
6576 7776
 				if (substr($url,0,strlen('data:'))=='data:')
6577 7777
 				{
@@ -6672,7 +7872,10 @@  discard block
 block discarded – undo
6672 7872
 				$_folder = $this->getSentFolder();
6673 7873
 			}
6674 7874
 			$delimiter = $this->getHierarchyDelimiter();
6675
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
7875
+			if($_folder=='INBOX'.$delimiter)
7876
+			{
7877
+				$_folder='INBOX';
7878
+			}
6676 7879
 			if ($importfailed === false)
6677 7880
 			{
6678 7881
 				$Subject = $mailObject->getHeader('Subject');
@@ -6701,7 +7904,9 @@  discard block
 block discarded – undo
6701 7904
 					//error_log(__METHOD__.' ('.__LINE__.') '.' Id To Merge:'.$val);
6702 7905
 					if (/*$GLOBALS['egw_info']['flags']['currentapp'] == 'addressbook' &&*/
6703 7906
 						count($SendAndMergeTocontacts) > 1 && $val &&
6704
-						(is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) // do the merge
7907
+						(is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)))
7908
+					{
7909
+						// do the merge
6705 7910
 					{
6706 7911
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject));
6707 7912
 
@@ -6710,6 +7915,7 @@  discard block
 block discarded – undo
6710 7915
 						{
6711 7916
 							//error_log('ID ' . $val . ' ' .$type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset));
6712 7917
 							$merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset);
7918
+					}
6713 7919
 							$mailObject->addAddress($merged,'',$type);
6714 7920
 							if($type == 'to')
6715 7921
 							{
@@ -6741,9 +7947,15 @@  discard block
 block discarded – undo
6741 7947
 						$mailObject->clearCustomHeaders();
6742 7948
 						$mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset));
6743 7949
 						//error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType);
6744
-						if($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7950
+						if($text_body)
7951
+						{
7952
+							$text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7953
+						}
6745 7954
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e));
6746
-						if($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7955
+						if($html_body)
7956
+						{
7957
+							$html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7958
+						}
6747 7959
 
6748 7960
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject));
6749 7961
 						// set a higher timeout for big messages
@@ -6758,9 +7970,12 @@  discard block
 block discarded – undo
6758 7970
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo));
6759 7971
 						}
6760 7972
 					}
6761
-					elseif (!$k)	// 1. entry, further entries will fail for apps other then addressbook
7973
+					elseif (!$k)
7974
+					{
7975
+						// 1. entry, further entries will fail for apps other then addressbook
6762 7976
 					{
6763 7977
 						$openAsDraft = true;
7978
+					}
6764 7979
 						$mailObject->removeHeader('Message-ID');
6765 7980
 						$mailObject->removeHeader('Date');
6766 7981
 						$mailObject->clearCustomHeaders();
@@ -6775,9 +7990,12 @@  discard block
 block discarded – undo
6775 7990
 
6776 7991
 						// No addresses from placeholders?  Treat it as just a contact ID
6777 7992
 						if (count($mailObject->getAddresses('to',true)) == 0 &&
6778
-							is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge
7993
+							is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))
7994
+						{
7995
+							// do the merge
6779 7996
 						{
6780 7997
 							$contact = $bo_merge->contacts->read($val);
7998
+						}
6781 7999
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact));
6782 8000
 							$email = ($contact['email'] ? $contact['email'] : $contact['email_home']);
6783 8001
 							$nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']);
@@ -6788,9 +8006,15 @@  discard block
 block discarded – undo
6788 8006
 						}
6789 8007
 						$mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset));
6790 8008
 						//error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType);
6791
-						if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8009
+						if (!empty($Body))
8010
+						{
8011
+							$text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8012
+						}
6792 8013
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e));
6793
-						if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8014
+						if (!empty($AltBody))
8015
+						{
8016
+							$html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8017
+						}
6794 8018
 						$_folder = $this->getDraftFolder();
6795 8019
 					}
6796 8020
 					if ($sendOK || $openAsDraft)
@@ -6798,11 +8022,15 @@  discard block
 block discarded – undo
6798 8022
 						if ($this->folderExists($_folder,true))
6799 8023
 						{
6800 8024
 						    if($this->isSentFolder($_folder))
6801
-							{
8025
+						    {
6802 8026
 						        $flags = '\\Seen';
6803
-						    } elseif($this->isDraftFolder($_folder)) {
8027
+						    }
8028
+						    elseif($this->isDraftFolder($_folder))
8029
+						    {
6804 8030
 						        $flags = '\\Draft';
6805
-						    } else {
8031
+						    }
8032
+						    else
8033
+						    {
6806 8034
 						        $flags = '';
6807 8035
 						    }
6808 8036
 							$savefailed = false;
@@ -6836,7 +8064,10 @@  discard block
 block discarded – undo
6836 8064
 						}
6837 8065
 						else
6838 8066
 						{
6839
-							if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
8067
+							if (!$openComposeWindow)
8068
+							{
8069
+								$processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
8070
+							}
6840 8071
 						}
6841 8072
 					}
6842 8073
 					if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow))
@@ -6884,7 +8115,10 @@  discard block
 block discarded – undo
6884 8115
 				$tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmpFileName);
6885 8116
 				break;
6886 8117
 		}
6887
-		if (!isset($message)) $message = fopen($tmpFileName, 'r');
8118
+		if (!isset($message))
8119
+		{
8120
+			$message = fopen($tmpFileName, 'r');
8121
+		}
6888 8122
 
6889 8123
 		if (!$message)
6890 8124
 		{
@@ -6915,7 +8149,10 @@  discard block
 block discarded – undo
6915 8149
 				(fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192));
6916 8150
 
6917 8151
 			$length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL);
6918
-			if ($length===false) $length = strlen($start);
8152
+			if ($length===false)
8153
+			{
8154
+				$length = strlen($start);
8155
+			}
6919 8156
 			$headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length));
6920 8157
 
6921 8158
 			foreach($headers->toArray(array('nowrap' => true)) as $header => $value)
@@ -6944,7 +8181,10 @@  discard block
 block discarded – undo
6944 8181
 		}
6945 8182
 		else
6946 8183
 		{
6947
-			if (($type = gettype($message)) == 'object') $type = get_class ($message);
8184
+			if (($type = gettype($message)) == 'object')
8185
+			{
8186
+				$type = get_class ($message);
8187
+			}
6948 8188
 			throw new Exception\WrongParameter('Wrong parameter type for message: '.$type);
6949 8189
 		}
6950 8190
 	}
@@ -6968,7 +8208,9 @@  discard block
 block discarded – undo
6968 8208
 			$matches = array();
6969 8209
 			preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches);
6970 8210
 			//error_log(__METHOD__.__LINE__.array2string($matches));
6971
-			foreach ($matches[0] as &$match) {$match = trim($match,', ');}
8211
+			foreach ($matches[0] as &$match)
8212
+			{
8213
+$match = trim($match,', ');}
6972 8214
 			$addresses = implode(',',$matches[0]);
6973 8215
 			//error_log(__METHOD__.__LINE__.array2string($addresses));
6974 8216
 			$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
@@ -6999,7 +8241,10 @@  discard block
 block discarded – undo
6999 8241
 			}
7000 8242
 			else
7001 8243
 			{
7002
-				if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal;
8244
+				if ($previousFailed && $remember)
8245
+				{
8246
+					$adr->personal = $remember. ' ' . $adr->personal;
8247
+				}
7003 8248
 				$remember = '';
7004 8249
 				$previousFailed=false;
7005 8250
 				//error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal");
@@ -7021,7 +8266,10 @@  discard block
 block discarded – undo
7021 8266
 	{
7022 8267
 		$acc = Mail\Account::read($this->profileID);
7023 8268
 		$identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc);
7024
-		if (self::$debug) error_log(__METHOD__.__LINE__.array2string($identity));
8269
+		if (self::$debug)
8270
+		{
8271
+			error_log(__METHOD__.__LINE__.array2string($identity));
8272
+		}
7025 8273
 		$headers = $this->getMessageHeader($uid, '', 'object', true, $_folder);
7026 8274
 
7027 8275
 		$mdn = new Horde_Mime_Mdn($headers);
Please login to merge, or discard this patch.
mail/inc/class.mail_ui.inc.php 1 patch
Braces   +925 added lines, -257 removed lines patch added patch discarded remove patch
@@ -127,9 +127,15 @@  discard block
 block discarded – undo
127 127
 	function __construct($run_constructor=true)
128 128
 	{
129 129
 		$this->mail_tree = new mail_tree($this);
130
-		if (!$run_constructor) return;
130
+		if (!$run_constructor)
131
+		{
132
+			return;
133
+		}
131 134
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
135
+		if (Mail::$debugTimes)
136
+		{
137
+			$starttime = microtime (true);
138
+		}
133 139
 		// no autohide of the sidebox, as we use it for folderlist now.
134 140
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 141
 
@@ -140,13 +146,19 @@  discard block
 block discarded – undo
140 146
 		if ($_GET["resetConnection"])
141 147
 		{
142 148
 			unset($_GET["resetConnection"]);
143
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
149
+			if (Mail::$debug)
150
+			{
151
+				error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
152
+			}
144 153
 			Mail::unsetCachedObjects(self::$icServerID);
145 154
 		}
146 155
 
147 156
 		try {
148 157
 			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
149
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
158
+			if (Mail::$debug)
159
+			{
160
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
161
+			}
150 162
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 163
 
152 164
 			// RegEx to minimize extra openConnection
@@ -167,9 +179,15 @@  discard block
 block discarded – undo
167 179
 				$response->call('egw.message',$e->getMessage(),'error');
168 180
 			}
169 181
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
182
+			if ($_GET['menuaction'] != 'mail.mail_ui.index')
183
+			{
184
+				self::callWizard($e->getMessage(),true,'error',false);
185
+			}
186
+		}
187
+		if (Mail::$debugTimes)
188
+		{
189
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171 190
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
173 191
 	}
174 192
 
175 193
 	/**
@@ -229,16 +247,28 @@  discard block
 block discarded – undo
229 247
 	 */
230 248
 	function changeProfile($_icServerID,$unsetCache=false)
231 249
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
250
+		if (Mail::$debugTimes)
251
+		{
252
+			$starttime = microtime (true);
253
+		}
233 254
 		if (self::$icServerID != $_icServerID)
234 255
 		{
235 256
 			self::$icServerID = $_icServerID;
236 257
 		}
237
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
258
+		if (Mail::$debug)
259
+		{
260
+			error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
261
+		}
238 262
 
239
-		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
263
+		if ($unsetCache)
264
+		{
265
+			Mail::unsetCachedObjects(self::$icServerID);
266
+		}
240 267
 		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
241
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
268
+		if (Mail::$debug)
269
+		{
270
+			error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
271
+		}
242 272
 		// no icServer Object: something failed big time
243 273
 		if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
244 274
 		{
@@ -248,14 +278,23 @@  discard block
 block discarded – undo
248 278
 
249 279
 		// save session varchar
250 280
 		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
251
-		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252
-		if (true) $oldicServerID = self::$icServerID;
281
+		if ($oldicServerID <> self::$icServerID)
282
+		{
283
+			$this->mail_bo->openConnection(self::$icServerID);
284
+		}
285
+		if (true)
286
+		{
287
+			$oldicServerID = self::$icServerID;
288
+		}
253 289
 		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
254 290
 		{
255 291
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 292
 		}
257 293
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
294
+		if (Mail::$debugTimes)
295
+		{
296
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
297
+		}
259 298
 	}
260 299
 
261 300
 	/**
@@ -296,7 +335,8 @@  discard block
 block discarded – undo
296 335
 		// got subscribed or unsubscribed by the user
297 336
 		try {
298 337
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
299
-		} catch (Exception $ex) {
338
+		}
339
+		catch (Exception $ex) {
300 340
 			Framework::message($ex->getMessage());
301 341
 		}
302 342
 
@@ -330,9 +370,18 @@  discard block
 block discarded – undo
330 370
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 371
 						if ($node)
332 372
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
334
-							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335
-							if ($value['value']) $cont[] = $path;
373
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value'])
374
+							{
375
+								$to_unsubscribe []= $node;
376
+							}
377
+							if (is_array($subscribed) && !$subscribed[$node] && $value['value'])
378
+							{
379
+								$to_subscribe [] = $node;
380
+							}
381
+							if ($value['value'])
382
+							{
383
+								$cont[] = $path;
384
+							}
336 385
 						}
337 386
 
338 387
 					}
@@ -421,7 +470,10 @@  discard block
 block discarded – undo
421 470
 		//error_log(__METHOD__.__LINE__.array2string($content));
422 471
 		try	{
423 472
 				//error_log(__METHOD__.__LINE__.function_backtrace());
424
-				if (Mail::$debugTimes) $starttime = microtime (true);
473
+				if (Mail::$debugTimes)
474
+				{
475
+					$starttime = microtime (true);
476
+				}
425 477
 				$this->mail_bo->restoreSessionData();
426 478
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
427 479
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -450,7 +502,10 @@  discard block
 block discarded – undo
450 502
 							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
451 503
 						);
452 504
 					}
453
-					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
505
+					if (Api\Header\UserAgent::mobile())
506
+					{
507
+						$content[self::$nm_index]['header_row'] = 'mail.index.header_right';
508
+					}
454 509
 				}
455 510
 
456 511
 				// These must always be set, even if $content is an array
@@ -474,13 +529,16 @@  discard block
 block discarded – undo
474 529
 				}
475 530
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
476 531
 				$quota = false;//$this->mail_bo->getQuotaRoot();
477
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
532
+				if($quota !== false && $quota['limit'] != 'NOT SET')
533
+				{
478 534
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
479 535
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
480 536
 					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
481 537
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
482 538
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
483
-				} else {
539
+				}
540
+				else
541
+				{
484 542
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
485 543
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
486 544
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -488,7 +546,8 @@  discard block
 block discarded – undo
488 546
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
489 547
 				$vacation = false;//$this->gatherVacation();
490 548
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
491
-				if($vacation) {
549
+				if($vacation)
550
+				{
492 551
 					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
493 552
 					{
494 553
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
@@ -522,19 +581,31 @@  discard block
 block discarded – undo
522 581
 					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
523 582
 					foreach($keywords as &$k)
524 583
 					{
525
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
584
+						if (array_key_exists($k,$this->statusTypes))
585
+						{
586
+							unset($this->statusTypes[$k]);
587
+						}
526 588
 					}
527 589
 				}
528 590
 
529
-				if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
530
-				if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
591
+				if (!isset($content[self::$nm_index]['foldertree']))
592
+				{
593
+					$content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
594
+				}
595
+				if (!isset($content[self::$nm_index]['selectedFolder']))
596
+				{
597
+					$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
598
+				}
531 599
 
532 600
 				$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
533 601
 
534 602
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
535 603
 				{
536 604
 					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
537
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
605
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
606
+					{
607
+						Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
608
+					}
538 609
 				}
539 610
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
540 611
 				{
@@ -556,10 +627,16 @@  discard block
 block discarded – undo
556 627
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
557 628
 
558 629
 				// sending preview toolbar actions
559
-				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
630
+				if ($content['mailSplitter'])
631
+				{
632
+					$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
633
+				}
560 634
 
561 635
 				// We need to send toolbar actions to client-side because view template needs them
562
-				if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions();
636
+				if (Api\Header\UserAgent::mobile())
637
+				{
638
+					$sel_options['toolbar'] = $this->get_toolbar_actions();
639
+				}
563 640
 
564 641
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
565 642
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
@@ -567,7 +644,10 @@  discard block
 block discarded – undo
567 644
 					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
568 645
 				}
569 646
 				$readonlys = $preserv = array();
570
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
647
+				if (Mail::$debugTimes)
648
+				{
649
+					Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
650
+				}
571 651
 		}
572 652
 		catch (Exception $e)
573 653
 		{
@@ -580,13 +660,19 @@  discard block
 block discarded – undo
580 660
 			}
581 661
 			$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
582 662
 			$readonlys = $preserv = array();
583
-			if (empty($content)) $content=array();
663
+			if (empty($content))
664
+			{
665
+				$content=array();
666
+			}
584 667
 
585 668
 			self::callWizard($e->getMessage().$e->getMessage().($e->details?', '.$e->details:''),false, 'error',false);
586 669
 			//return false;
587 670
 		}
588 671
 		// Check preview pane is enabled, then show spliter
589
-		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
672
+		if ($this->mail_bo->mailPreferences['previewPane'])
673
+		{
674
+			$etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
675
+		}
590 676
 
591 677
 		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
592 678
 	}
@@ -825,12 +911,18 @@  discard block
 block discarded – undo
825 911
 	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
826 912
 	{
827 913
 		$nodeID = $_GET['id'];
828
-		if (!is_null($_nodeID)) $nodeID = $_nodeID;
914
+		if (!is_null($_nodeID))
915
+		{
916
+			$nodeID = $_nodeID;
917
+		}
829 918
 		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
830 919
 		$fetchCounters = !is_null($_nodeID);
831 920
 		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
832 921
 
833
-		if (!empty($_folderName)) $fetchCounters = true;
922
+		if (!empty($_folderName))
923
+		{
924
+			$fetchCounters = true;
925
+		}
834 926
 
835 927
 		// Check if it is called for refresh root
836 928
 		// then we need to reinitialized the index tree
@@ -842,7 +934,10 @@  discard block
 block discarded – undo
842 934
 		{
843 935
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
844 936
 		}
845
-		if (!is_null($_nodeID)) return $data;
937
+		if (!is_null($_nodeID))
938
+		{
939
+			return $data;
940
+		}
846 941
 		Etemplate\Widget\Tree::send_quote_json($data);
847 942
 	}
848 943
 
@@ -908,7 +1003,10 @@  discard block
 block discarded – undo
908 1003
 				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
909 1004
 			}
910 1005
 		}
911
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
1006
+		if (!is_array($lastFoldersUsedForMoveCont))
1007
+		{
1008
+			$lastFoldersUsedForMoveCont=array();
1009
+		}
912 1010
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
913 1011
 		{
914 1012
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
@@ -924,9 +1022,12 @@  discard block
 block discarded – undo
924 1022
 						$moveaction .= $lastFolderUsedForMoveCont;
925 1023
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
926 1024
 						//error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey);
927
-						if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1025
+						if ($this->mail_bo->folderExists($i))
1026
+						{
1027
+							// only 10 entries per mailaccount.Control this on setting the buffered folders
928 1028
 						{
929 1029
 							$fS['profileID'] = $this->mail_bo->profileID;
1030
+						}
930 1031
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
931 1032
 							$fS['shortDisplayName'] = $i;
932 1033
 							$moveactions[$moveaction] = $fS;
@@ -946,9 +1047,12 @@  discard block
 block discarded – undo
946 1047
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
947 1048
 				{
948 1049
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
949
-					if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1050
+					if (!empty($lastFolderUsedForMoveCont))
1051
+					{
1052
+						// only 10 entries per mailaccount.Control this on setting the buffered folders
950 1053
 					{
951 1054
 						$moveaction = 'move_'.$lastFolderUsedForMoveCont;
1055
+					}
952 1056
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
953 1057
 						$fS = array();
954 1058
 						$fS['profileID'] = $pid;
@@ -1051,7 +1155,9 @@  discard block
 block discarded – undo
1051 1155
 				'children' => $children,
1052 1156
 			);
1053 1157
 
1054
-		} else {
1158
+		}
1159
+		else
1160
+		{
1055 1161
 			$group++;
1056 1162
 		}
1057 1163
 
@@ -1327,7 +1433,10 @@  discard block
 block discarded – undo
1327 1433
 					$rows=array();
1328 1434
 					return 0;
1329 1435
 				}
1330
-				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1436
+				if (empty($folderName))
1437
+				{
1438
+					$query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1439
+				}
1331 1440
 			}
1332 1441
 		}
1333 1442
 		if (!isset($mail_ui))
@@ -1342,15 +1451,24 @@  discard block
 block discarded – undo
1342 1451
 				$rows=array();
1343 1452
 				return 0;
1344 1453
 			}
1345
-			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1454
+			if (empty($query['selectedFolder']))
1455
+			{
1456
+				$query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1457
+			}
1346 1458
 		}
1347 1459
 		//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
1348 1460
 		//Mail::$debugTimes=true;
1349
-		if (Mail::$debugTimes) $starttime = microtime(true);
1461
+		if (Mail::$debugTimes)
1462
+		{
1463
+			$starttime = microtime(true);
1464
+		}
1350 1465
 		//$query['search'] is the phrase in the searchbox
1351 1466
 
1352 1467
 		$mail_ui->mail_bo->restoreSessionData();
1353
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1468
+		if (isset($query['selectedFolder']))
1469
+		{
1470
+			$mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1471
+		}
1354 1472
 		$mail_ui->mail_bo->saveSessionData();
1355 1473
 
1356 1474
 		$sRToFetch = null;
@@ -1361,7 +1479,10 @@  discard block
 block discarded – undo
1361 1479
 			unset($app);
1362 1480
 		}
1363 1481
 		//save selected Folder to sessionData (mailbox)->currentFolder
1364
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1482
+		if (isset($query['selectedFolder']))
1483
+		{
1484
+			$mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1485
+		}
1365 1486
 		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1366 1487
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1367 1488
 		{
@@ -1394,8 +1515,16 @@  discard block
 block discarded – undo
1394 1515
 			}
1395 1516
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1396 1517
 			$cutoffdate = $cutoffdate2 = null;
1397
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1398
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1518
+			if ($query['startdate'])
1519
+			{
1520
+				$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
1521
+			}
1522
+			//SINCE, enddate
1523
+			if ($query['enddate'])
1524
+			{
1525
+				$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
1526
+			}
1527
+			//BEFORE, startdate
1399 1528
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1400 1529
 			$filter = array(
1401 1530
 				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -1404,15 +1533,24 @@  discard block
 block discarded – undo
1404 1533
 				'status' => 'any',
1405 1534
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1406 1535
 			);
1407
-			if ($query['enddate']||$query['startdate']) {
1536
+			if ($query['enddate']||$query['startdate'])
1537
+			{
1408 1538
 				$filter['range'] = "BETWEEN";
1409
-				if ($cutoffdate) {
1539
+				if ($cutoffdate)
1540
+				{
1410 1541
 					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1411
-					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1542
+					if (empty($cutoffdate2))
1543
+					{
1544
+						$filter['range'] = "SINCE";
1545
+					}
1412 1546
 				}
1413
-				if ($cutoffdate2) {
1547
+				if ($cutoffdate2)
1548
+				{
1414 1549
 					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1415
-					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1550
+					if (empty($cutoffdate))
1551
+					{
1552
+						$filter['range'] = "BEFORE";
1553
+					}
1416 1554
 				}
1417 1555
 			}
1418 1556
 		}
@@ -1464,7 +1602,10 @@  discard block
 block discarded – undo
1464 1602
 				$rowsFetched['messages'] = $_sR['count'];
1465 1603
 				$ids = $_sR['match']->ids;
1466 1604
 				// if $sR is false, something failed fundamentally
1467
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1605
+				if($reverse === true)
1606
+				{
1607
+					$ids = ($ids===false?array():array_reverse((array)$ids));
1608
+				}
1468 1609
 				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1469 1610
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1470 1611
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
@@ -1530,7 +1671,10 @@  discard block
 block discarded – undo
1530 1671
 				}
1531 1672
 				else
1532 1673
 				{
1533
-					if (!empty($v)) $sortResult['header'][] = array('uid'=>$v);
1674
+					if (!empty($v))
1675
+					{
1676
+						$sortResult['header'][] = array('uid'=>$v);
1677
+					}
1534 1678
 				}
1535 1679
 			}
1536 1680
 		}
@@ -1539,15 +1683,24 @@  discard block
 block discarded – undo
1539 1683
 			$sortResult = $sortResultwH;
1540 1684
 		}
1541 1685
 		$rowsFetched['rowsFetched'] = count($sortResult['header']);
1542
-		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1686
+		if (empty($rowsFetched['messages']))
1687
+		{
1688
+			$rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1689
+		}
1543 1690
 
1544 1691
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1545 1692
 		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1546
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1693
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE')
1694
+		{
1695
+			unset($cols[0]);
1696
+		}
1547 1697
 		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1548 1698
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1549 1699
 
1550
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1700
+		if (Mail::$debugTimes)
1701
+		{
1702
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1703
+		}
1551 1704
 		return $rowsFetched['messages'];
1552 1705
 	}
1553 1706
 
@@ -1649,7 +1802,10 @@  discard block
 block discarded – undo
1649 1802
 					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1650 1803
 					break;
1651 1804
 				default:
1652
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1805
+					if (isset($actions[$act]))
1806
+					{
1807
+						$actionsenabled[$act]=$actions[$act];
1808
+					}
1653 1809
 			}
1654 1810
 		}
1655 1811
 		unset($actionsenabled['drag_mail']);
@@ -1671,7 +1827,10 @@  discard block
 block discarded – undo
1671 1827
 	 */
1672 1828
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1673 1829
 	{
1674
-		if (Mail::$debugTimes) $starttime = microtime(true);
1830
+		if (Mail::$debugTimes)
1831
+		{
1832
+			$starttime = microtime(true);
1833
+		}
1675 1834
 		$rv = array();
1676 1835
 		$i=0;
1677 1836
 		foreach((array)$_headers as $header)
@@ -1684,17 +1843,50 @@  discard block
 block discarded – undo
1684 1843
 			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1685 1844
 
1686 1845
 			$flags = "";
1687
-			if(!empty($header['recent'])) $flags .= "R";
1688
-			if(!empty($header['flagged'])) $flags .= "F";
1689
-			if(!empty($header['answered'])) $flags .= "A";
1690
-			if(!empty($header['forwarded'])) $flags .= "W";
1691
-			if(!empty($header['deleted'])) $flags .= "D";
1692
-			if(!empty($header['seen'])) $flags .= "S";
1693
-			if(!empty($header['label1'])) $flags .= "1";
1694
-			if(!empty($header['label2'])) $flags .= "2";
1695
-			if(!empty($header['label3'])) $flags .= "3";
1696
-			if(!empty($header['label4'])) $flags .= "4";
1697
-			if(!empty($header['label5'])) $flags .= "5";
1846
+			if(!empty($header['recent']))
1847
+			{
1848
+				$flags .= "R";
1849
+			}
1850
+			if(!empty($header['flagged']))
1851
+			{
1852
+				$flags .= "F";
1853
+			}
1854
+			if(!empty($header['answered']))
1855
+			{
1856
+				$flags .= "A";
1857
+			}
1858
+			if(!empty($header['forwarded']))
1859
+			{
1860
+				$flags .= "W";
1861
+			}
1862
+			if(!empty($header['deleted']))
1863
+			{
1864
+				$flags .= "D";
1865
+			}
1866
+			if(!empty($header['seen']))
1867
+			{
1868
+				$flags .= "S";
1869
+			}
1870
+			if(!empty($header['label1']))
1871
+			{
1872
+				$flags .= "1";
1873
+			}
1874
+			if(!empty($header['label2']))
1875
+			{
1876
+				$flags .= "2";
1877
+			}
1878
+			if(!empty($header['label3']))
1879
+			{
1880
+				$flags .= "3";
1881
+			}
1882
+			if(!empty($header['label4']))
1883
+			{
1884
+				$flags .= "4";
1885
+			}
1886
+			if(!empty($header['label5']))
1887
+			{
1888
+				$flags .= "5";
1889
+			}
1698 1890
 
1699 1891
 			$data["status"] = "<span class=\"status_img\"></span>";
1700 1892
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
@@ -1702,41 +1894,53 @@  discard block
 block discarded – undo
1702 1894
 			// the css for this row
1703 1895
 			$is_recent=false;
1704 1896
 			$css_styles = array("mail");
1705
-			if ($header['deleted']) {
1897
+			if ($header['deleted'])
1898
+			{
1706 1899
 				$css_styles[] = 'deleted';
1707 1900
 			}
1708
-			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1901
+			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded']))
1902
+			{
1709 1903
 				$css_styles[] = 'recent';
1710 1904
 				$is_recent=true;
1711 1905
 			}
1712
-			if ($header['priority'] < 3) {
1906
+			if ($header['priority'] < 3)
1907
+			{
1713 1908
 				$css_styles[] = 'prio_high';
1714 1909
 			}
1715
-			if ($header['flagged']) {
1910
+			if ($header['flagged'])
1911
+			{
1716 1912
 				$css_styles[] = 'flagged';
1717 1913
 			}
1718
-			if (!$header['seen']) {
1914
+			if (!$header['seen'])
1915
+			{
1719 1916
 				$css_styles[] = 'unseen'; // different status image for recent // solved via css !important
1720 1917
 			}
1721
-			if ($header['answered']) {
1918
+			if ($header['answered'])
1919
+			{
1722 1920
 				$css_styles[] = 'replied';
1723 1921
 			}
1724
-			if ($header['forwarded']) {
1922
+			if ($header['forwarded'])
1923
+			{
1725 1924
 				$css_styles[] = 'forwarded';
1726 1925
 			}
1727
-			if ($header['label1']) {
1926
+			if ($header['label1'])
1927
+			{
1728 1928
 				$css_styles[] = 'labelone';
1729 1929
 			}
1730
-			if ($header['label2']) {
1930
+			if ($header['label2'])
1931
+			{
1731 1932
 				$css_styles[] = 'labeltwo';
1732 1933
 			}
1733
-			if ($header['label3']) {
1934
+			if ($header['label3'])
1935
+			{
1734 1936
 				$css_styles[] = 'labelthree';
1735 1937
 			}
1736
-			if ($header['label4']) {
1938
+			if ($header['label4'])
1939
+			{
1737 1940
 				$css_styles[] = 'labelfour';
1738 1941
 			}
1739
-			if ($header['label5']) {
1942
+			if ($header['label5'])
1943
+			{
1740 1944
 				$css_styles[] = 'labelfive';
1741 1945
 			}
1742 1946
 
@@ -1753,10 +1957,13 @@  discard block
 block discarded – undo
1753 1957
 				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1754 1958
 				// curly brackets get messed up by the template!
1755 1959
 
1756
-				if (!empty($header['subject'])) {
1960
+				if (!empty($header['subject']))
1961
+				{
1757 1962
 					// make the subject shorter if it is to long
1758 1963
 					$subject = $header['subject'];
1759
-				} else {
1964
+				}
1965
+				else
1966
+				{
1760 1967
 					$subject = '('. lang('no subject') .')';
1761 1968
 				}
1762 1969
 
@@ -1798,15 +2005,22 @@  discard block
 block discarded – undo
1798 2005
 					}
1799 2006
 
1800 2007
 					$attachmentFlag = $image;
1801
-				} else {
2008
+				}
2009
+				else
2010
+				{
1802 2011
 					$attachmentFlag ='&nbsp;';
1803 2012
 				}
1804 2013
 				// show priority flag
1805
-				if ($header['priority'] < 3) {
2014
+				if ($header['priority'] < 3)
2015
+				{
1806 2016
 					 $image = Api\Html::image('mail','prio_high');
1807
-				} elseif ($header['priority'] > 3) {
2017
+				}
2018
+				elseif ($header['priority'] > 3)
2019
+				{
1808 2020
 					$image = Api\Html::image('mail','prio_low');
1809
-				} else {
2021
+				}
2022
+				else
2023
+				{
1810 2024
 					$image = '';
1811 2025
 				}
1812 2026
 				// show a flag for flagged messages
@@ -1848,26 +2062,53 @@  discard block
 block discarded – undo
1848 2062
 			}
1849 2063
 
1850 2064
 			if (in_array("size", $cols))
1851
-				$data["size"] = $header['size']; /// size
2065
+			{
2066
+							$data["size"] = $header['size'];
2067
+			}
2068
+			/// size
1852 2069
 
1853 2070
 			$data["class"] = implode(' ', $css_styles);
1854 2071
 			//translate style-classes back to flags
1855 2072
 			$data['flags'] = Array();
1856
-			if ($header['seen']) $data["flags"]['read'] = 'read';
1857
-			foreach ($css_styles as &$flag) {
2073
+			if ($header['seen'])
2074
+			{
2075
+				$data["flags"]['read'] = 'read';
2076
+			}
2077
+			foreach ($css_styles as &$flag)
2078
+			{
1858 2079
 				if ($flag!='mail')
1859 2080
 				{
1860
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1861
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1862
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1863
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1864
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1865
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1866
-					else $data["flags"][$flag] = $flag;
2081
+					if ($flag=='labelone')
2082
+					{
2083
+$data["flags"]['label1'] = 'label1';}
2084
+					elseif ($flag=='labeltwo')
2085
+					{
2086
+$data["flags"]['label2'] = 'label2';}
2087
+					elseif ($flag=='labelthree')
2088
+					{
2089
+$data["flags"]['label3'] = 'label3';}
2090
+					elseif ($flag=='labelfour')
2091
+					{
2092
+$data["flags"]['label4'] = 'label4';}
2093
+					elseif ($flag=='labelfive')
2094
+					{
2095
+$data["flags"]['label5'] = 'label5';}
2096
+					elseif ($flag=='unseen')
2097
+					{
2098
+unset($data["flags"]['read']);}
2099
+					else {
2100
+						$data["flags"][$flag] = $flag;
2101
+					}
1867 2102
 				}
1868 2103
 			}
1869
-			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1870
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2104
+			if ($header['disposition-notification-to'])
2105
+			{
2106
+				$data['dispositionnotificationto'] = $header['disposition-notification-to'];
2107
+			}
2108
+			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto']))
2109
+			{
2110
+				unset($data['dispositionnotificationto']);
2111
+			}
1871 2112
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1872 2113
 			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1873 2114
 			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
@@ -1877,7 +2118,10 @@  discard block
 block discarded – undo
1877 2118
 			$rv[] = $data;
1878 2119
 			//error_log(__METHOD__.__LINE__.array2string($data));
1879 2120
 		}
1880
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2121
+		if (Mail::$debugTimes)
2122
+		{
2123
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2124
+		}
1881 2125
 
1882 2126
 		// ToDo: call this ONLY if labels change
1883 2127
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1892,8 +2136,14 @@  discard block
 block discarded – undo
1892 2136
 	 */
1893 2137
 	function displayHeader()
1894 2138
 	{
1895
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1896
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2139
+		if(isset($_GET['id']))
2140
+		{
2141
+			$rowID	= $_GET['id'];
2142
+		}
2143
+		if(isset($_GET['part']))
2144
+		{
2145
+			$partID = $_GET['part'];
2146
+		}
1897 2147
 
1898 2148
 		$hA = self::splitRowID($rowID);
1899 2149
 		$uid = $hA['msgUID'];
@@ -1917,7 +2167,8 @@  discard block
 block discarded – undo
1917 2167
 		$rawheaders 	= "";
1918 2168
 		// create it new, with good line breaks
1919 2169
 		reset($newRawHeaders);
1920
-		while(list($key,$value) = @each($newRawHeaders)) {
2170
+		while(list($key,$value) = @each($newRawHeaders))
2171
+		{
1921 2172
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1922 2173
 		}
1923 2174
 
@@ -1940,12 +2191,24 @@  discard block
 block discarded – undo
1940 2191
 	 */
1941 2192
 	function displayMessage($_requesteddata = null)
1942 2193
 	{
1943
-		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2194
+		if (is_null($_requesteddata))
2195
+		{
2196
+			$_requesteddata = $_GET;
2197
+		}
1944 2198
 
1945 2199
 		$preventRedirect=false;
1946
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1947
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1948
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2200
+		if(isset($_requesteddata['id']))
2201
+		{
2202
+			$rowID	= $_requesteddata['id'];
2203
+		}
2204
+		if(isset($_requesteddata['part']))
2205
+		{
2206
+			$partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2207
+		}
2208
+		if(isset($_requesteddata['mode']))
2209
+		{
2210
+			$preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2211
+		}
1949 2212
 
1950 2213
 		$hA = self::splitRowID($rowID);
1951 2214
 		$uid = $hA['msgUID'];
@@ -1958,8 +2221,14 @@  discard block
 block discarded – undo
1958 2221
 			$this->changeProfile($icServerID);
1959 2222
 		}
1960 2223
 		$htmlOptions = $this->mail_bo->htmlOptions;
1961
-		if (!empty($_requesteddata['tryastext'])) $htmlOptions  = "only_if_no_text";
1962
-		if (!empty($_requesteddata['tryashtml'])) $htmlOptions  = "always_display";
2224
+		if (!empty($_requesteddata['tryastext']))
2225
+		{
2226
+			$htmlOptions  = "only_if_no_text";
2227
+		}
2228
+		if (!empty($_requesteddata['tryashtml']))
2229
+		{
2230
+			$htmlOptions  = "always_display";
2231
+		}
1963 2232
 
1964 2233
 		//error_log(__METHOD__.__LINE__.array2string($hA));
1965 2234
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
@@ -1983,14 +2252,20 @@  discard block
 block discarded – undo
1983 2252
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1984 2253
 			Framework::message($e->getMessage(), 'error');
1985 2254
 		}
1986
-		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2255
+		if (!empty($uid))
2256
+		{
2257
+			$this->mail_bo->getFlags($uid);
2258
+		}
1987 2259
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1988 2260
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1989 2261
 		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1990 2262
 		$fetchEmbeddedImages = false;
1991 2263
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1992 2264
 		// we do NOT want to see those, that are embedded in the list of attachments
1993
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2265
+		if ($htmlOptions !='always_display')
2266
+		{
2267
+			$fetchEmbeddedImages = true;
2268
+		}
1994 2269
 		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1995 2270
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
1996 2271
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
@@ -2006,11 +2281,17 @@  discard block
 block discarded – undo
2006 2281
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2007 2282
 
2008 2283
 		// Set up data for taglist widget(s)
2009
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2284
+		if ($envelope['FROM']==$envelope['SENDER'])
2285
+		{
2286
+			unset($envelope['SENDER']);
2287
+		}
2010 2288
 		$sel_options = array();
2011 2289
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2012 2290
 		{
2013
-			if (!isset($envelope[$field])) continue;
2291
+			if (!isset($envelope[$field]))
2292
+			{
2293
+				continue;
2294
+			}
2014 2295
 			foreach($envelope[$field] as $field_data)
2015 2296
 			{
2016 2297
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
@@ -2024,7 +2305,10 @@  discard block
 block discarded – undo
2024 2305
 		}
2025 2306
 		$actionsenabled = $this->getDisplayToolbarActions();
2026 2307
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2027
-		if (empty($subject)) $subject = lang('no subject');
2308
+		if (empty($subject))
2309
+		{
2310
+			$subject = lang('no subject');
2311
+		}
2028 2312
 		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2029 2313
 		// Send mail ID so we can use it for actions
2030 2314
 		$content['mail_id'] = $rowID;
@@ -2035,8 +2319,14 @@  discard block
 block discarded – undo
2035 2319
 		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2036 2320
 		$content['mail_displaysubject'] = $subject;
2037 2321
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2038
-		if (!empty($partID)) $linkData['_partID']=$partID;
2039
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2322
+		if (!empty($partID))
2323
+		{
2324
+			$linkData['_partID']=$partID;
2325
+		}
2326
+		if ($htmlOptions != $this->mail_bo->htmlOptions)
2327
+		{
2328
+			$linkData['_htmloptions']=$htmlOptions;
2329
+		}
2040 2330
 		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2041 2331
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2042 2332
 		$content['mail_id']=$rowID;
@@ -2104,7 +2394,8 @@  discard block
 block discarded – undo
2104 2394
 	{
2105 2395
 		$attachmentHTMLBlock='';
2106 2396
 		$attachmentHTML = array();
2107
-		if (is_array($attachments) && count($attachments) > 0) {
2397
+		if (is_array($attachments) && count($attachments) > 0)
2398
+		{
2108 2399
 			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2109 2400
 			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2110 2401
 
@@ -2114,7 +2405,10 @@  discard block
 block discarded – undo
2114 2405
 				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2115 2406
 				//error_log(array2string($value));
2116 2407
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2117
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2408
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM'))
2409
+				{
2410
+					$value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2411
+				}
2118 2412
 				$attachmentHTML[$key]['type']=$value['mimeType'];
2119 2413
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2120 2414
 				$hA = self::splitRowID($rowID);
@@ -2157,8 +2451,15 @@  discard block
 block discarded – undo
2157 2451
 						$sfxMimeType = $value['mimeType'];
2158 2452
 						$buff = explode('.',$value['name']);
2159 2453
 						$suffix = '';
2160
-						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2161
-						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2454
+						if (is_array($buff))
2455
+						{
2456
+							$suffix = array_pop($buff);
2457
+						}
2458
+						// take the last extension to check with ext2mime
2459
+						if (!empty($suffix))
2460
+						{
2461
+							$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2462
+						}
2162 2463
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2163 2464
 						{
2164 2465
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2327,9 +2628,12 @@  discard block
 block discarded – undo
2327 2628
 	function quotaDisplay($_usage, $_limit)
2328 2629
 	{
2329 2630
 
2330
-		if($_limit == 0) {
2631
+		if($_limit == 0)
2632
+		{
2331 2633
 			$quotaPercent=100;
2332
-		} else {
2634
+		}
2635
+		else
2636
+		{
2333 2637
 			$quotaPercent=round(($_usage*100)/$_limit);
2334 2638
 		}
2335 2639
 
@@ -2337,22 +2641,33 @@  discard block
 block discarded – undo
2337 2641
 		$quotaUsage=Mail::show_readable_size($_usage*1024);
2338 2642
 
2339 2643
 
2340
-		if($quotaPercent > 90 && $_limit>0) {
2644
+		if($quotaPercent > 90 && $_limit>0)
2645
+		{
2341 2646
 			$quotaBG='mail-index_QuotaRed';
2342
-		} elseif($quotaPercent > 80 && $_limit>0) {
2647
+		}
2648
+		elseif($quotaPercent > 80 && $_limit>0)
2649
+		{
2343 2650
 			$quotaBG='mail-index_QuotaYellow';
2344
-		} else {
2651
+		}
2652
+		else
2653
+		{
2345 2654
 			$quotaBG='mail-index_QuotaGreen';
2346 2655
 		}
2347 2656
 
2348
-		if($_limit > 0) {
2657
+		if($_limit > 0)
2658
+		{
2349 2659
 			$quotaText = $quotaUsage .'/'.$quotaLimit;
2350
-		} else {
2660
+		}
2661
+		else
2662
+		{
2351 2663
 			$quotaText = $quotaUsage;
2352 2664
 		}
2353 2665
 
2354
-		if($quotaPercent > 50) {
2355
-		} else {
2666
+		if($quotaPercent > 50)
2667
+		{
2668
+		}
2669
+		else
2670
+		{
2356 2671
 		}
2357 2672
 		$quota['class'] = $quotaBG;
2358 2673
 		$quota['text'] = lang('Quota: %1',$quotaText);
@@ -2370,7 +2685,10 @@  discard block
 block discarded – undo
2370 2685
 		$uid	= $_GET['uid'];
2371 2686
 		$cid	= base64_decode($_GET['cid']);
2372 2687
 		$partID = urldecode($_GET['partID']);
2373
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2688
+		if (!empty($_GET['mailbox']))
2689
+		{
2690
+			$mailbox  = base64_decode($_GET['mailbox']);
2691
+		}
2374 2692
 
2375 2693
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2376 2694
 		$this->mail_bo->reopen($mailbox);
@@ -2402,7 +2720,10 @@  discard block
 block discarded – undo
2402 2720
 
2403 2721
 	function getAttachment()
2404 2722
 	{
2405
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2723
+		if(isset($_GET['id']))
2724
+		{
2725
+			$rowID	= $_GET['id'];
2726
+		}
2406 2727
 
2407 2728
 		$hA = self::splitRowID($rowID);
2408 2729
 		$uid = $hA['msgUID'];
@@ -2435,10 +2756,20 @@  discard block
 block discarded – undo
2435 2756
 				$sfxMimeType = $attachment['type'];
2436 2757
 				$buff = explode('.',$attachment['filename']);
2437 2758
 				$suffix = '';
2438
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2439
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2759
+				if (is_array($buff))
2760
+				{
2761
+					$suffix = array_pop($buff);
2762
+				}
2763
+				// take the last extension to check with ext2mime
2764
+				if (!empty($suffix))
2765
+				{
2766
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2767
+				}
2440 2768
 				$attachment['type'] = $sfxMimeType;
2441
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2769
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2770
+				{
2771
+					$attachment['type'] = strtoupper($sfxMimeType);
2772
+				}
2442 2773
 			}
2443 2774
 			//error_log(__METHOD__.print_r($attachment,true));
2444 2775
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2447,7 +2778,10 @@  discard block
 block discarded – undo
2447 2778
 				$calendar_ical = new calendar_ical();
2448 2779
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2449 2780
 				//error_log(__METHOD__.array2string($eventid));
2450
-				if (!$eventid) $eventid = -1;
2781
+				if (!$eventid)
2782
+				{
2783
+					$eventid = -1;
2784
+				}
2451 2785
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2452 2786
 				//error_log(__METHOD__.$event);
2453 2787
 				if ((int)$event > 0)
@@ -2473,7 +2807,10 @@  discard block
 block discarded – undo
2473 2807
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2474 2808
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2475 2809
 				}
2476
-				if (!$contact) $contact = null;
2810
+				if (!$contact)
2811
+				{
2812
+					$contact = null;
2813
+				}
2477 2814
 				// if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO))
2478 2815
 				if ($contact || count($vcard)>2)
2479 2816
 				{
@@ -2507,9 +2844,18 @@  discard block
 block discarded – undo
2507 2844
 	function saveMessage()
2508 2845
 	{
2509 2846
 		$display = false;
2510
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2511
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2512
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2847
+		if(isset($_GET['id']))
2848
+		{
2849
+			$rowID	= $_GET['id'];
2850
+		}
2851
+		if(isset($_GET['part']))
2852
+		{
2853
+			$partID = $_GET['part'];
2854
+		}
2855
+		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager'))
2856
+		{
2857
+			$display	= $_GET['location'];
2858
+		}
2513 2859
 
2514 2860
 		$hA = self::splitRowID($rowID);
2515 2861
 		$uid = $hA['msgUID'];
@@ -2598,7 +2944,10 @@  discard block
 block discarded – undo
2598 2944
 			{
2599 2945
 				$succeeded = true;
2600 2946
 			}
2601
-			if ($fp) fclose($fp);
2947
+			if ($fp)
2948
+			{
2949
+				fclose($fp);
2950
+			}
2602 2951
 			if ($succeeded)
2603 2952
 			{
2604 2953
 				unset($headers['SUBJECT']);//already in filename
@@ -2648,7 +2997,8 @@  discard block
 block discarded – undo
2648 2997
 		 *
2649 2998
 		 * @return array an array of parameters
2650 2999
 		 */
2651
-		$getParams = function ($id) {
3000
+		$getParams = function ($id)
3001
+		{
2652 3002
 			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2653 3003
 			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2654 3004
 			$hA = mail_ui::splitRowID($lId);
@@ -2684,7 +3034,10 @@  discard block
 block discarded – undo
2684 3034
 		{
2685 3035
 			$params = $getParams($id);
2686 3036
 			// when downloading a single file, name is not set
2687
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
3037
+			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload)
3038
+			{
3039
+				$params['name'] = $_GET['name'];
3040
+			}
2688 3041
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2689 3042
 			{
2690 3043
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2697,7 +3050,10 @@  discard block
 block discarded – undo
2697 3050
 				// Try to find the right content for file id
2698 3051
 				foreach ($attachments as $key => $val)
2699 3052
 				{
2700
-					if ($key == $params['is_winmail']) $attachment = $val;
3053
+					if ($key == $params['is_winmail'])
3054
+					{
3055
+						$attachment = $val;
3056
+					}
2701 3057
 				}
2702 3058
 			}
2703 3059
 			else
@@ -2744,7 +3100,10 @@  discard block
 block discarded – undo
2744 3100
 	{
2745 3101
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2746 3102
 		// First, get all attachment IDs
2747
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
3103
+		if(isset($_GET['id']))
3104
+		{
3105
+			$message_id	= $_GET['id'];
3106
+		}
2748 3107
 		//error_log(__METHOD__.__LINE__.$message_id);
2749 3108
 		$rememberServerID = $this->mail_bo->profileID;
2750 3109
 		if(!is_numeric($message_id))
@@ -2771,7 +3130,10 @@  discard block
 block discarded – undo
2771 3130
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2772 3131
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2773 3132
 		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2774
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
3133
+		if(Vfs::is_dir($temp_path))
3134
+		{
3135
+			Vfs::remove ($temp_path);
3136
+		}
2775 3137
 
2776 3138
 		// Add subject to path, so it gets used as the file name
2777 3139
 		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
@@ -2796,7 +3158,10 @@  discard block
 block discarded – undo
2796 3158
 				foreach ($tnefAttachments as $key => $val)
2797 3159
 				{
2798 3160
 					error_log(__METHOD__.' winmail = '.$key);
2799
-					if ($key == $file['is_winmail']) $attachment = $val;
3161
+					if ($key == $file['is_winmail'])
3162
+					{
3163
+						$attachment = $val;
3164
+					}
2800 3165
 				}
2801 3166
 			}
2802 3167
 			else
@@ -2804,7 +3169,10 @@  discard block
 block discarded – undo
2804 3169
 				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2805 3170
 			}
2806 3171
 			$success=true;
2807
-			if (empty($file['filename'])) $file['filename'] = $file['name'];
3172
+			if (empty($file['filename']))
3173
+			{
3174
+				$file['filename'] = $file['name'];
3175
+			}
2808 3176
 			if(in_array($path.$file['filename'], $file_list))
2809 3177
 			{
2810 3178
 				$dupe_count[$path.$file['filename']]++;
@@ -2818,8 +3186,14 @@  discard block
 block discarded – undo
2818 3186
 				$success=false;
2819 3187
 				Framework::message("Unable to zip {$file['filename']}",'error');
2820 3188
 			}
2821
-			if ($success) $file_list[] = $path.$file['filename'];
2822
-			if ($fp) fclose($fp);
3189
+			if ($success)
3190
+			{
3191
+				$file_list[] = $path.$file['filename'];
3192
+			}
3193
+			if ($fp)
3194
+			{
3195
+				fclose($fp);
3196
+			}
2823 3197
 		}
2824 3198
 		$this->mail_bo->closeConnection();
2825 3199
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2846,7 +3220,10 @@  discard block
 block discarded – undo
2846 3220
 		$this->uid = $uid;
2847 3221
 		$this->partID = $partID;
2848 3222
 		$bufferHtmlOptions = $this->mail_bo->htmlOptions;
2849
-		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
3223
+		if (empty($htmlOptions))
3224
+		{
3225
+			$htmlOptions = $this->mail_bo->htmlOptions;
3226
+		}
2850 3227
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2851 3228
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2852 3229
 		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
@@ -2910,10 +3287,16 @@  discard block
 block discarded – undo
2910 3287
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2911 3288
 
2912 3289
 		$EndBody = '</td></tr></table></div>';
2913
-		if ($fullPageTags) $EndBody .= "</body></html>";
2914
-		if ($print)	{
3290
+		if ($fullPageTags)
3291
+		{
3292
+			$EndBody .= "</body></html>";
3293
+		}
3294
+		if ($print)
3295
+		{
2915 3296
 			print $BeginBody. $body .$EndBody;
2916
-		} else {
3297
+		}
3298
+		else
3299
+		{
2917 3300
 			return $BeginBody. $body .$EndBody;
2918 3301
 		}
2919 3302
 	}
@@ -2929,9 +3312,14 @@  discard block
 block discarded – undo
2929 3312
 		$body = '';
2930 3313
 
2931 3314
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2932
-		if (empty($bodyParts)) return "";
2933
-		foreach((array)$bodyParts as $singleBodyPart) {
2934
-			if (!isset($singleBodyPart['body'])) {
3315
+		if (empty($bodyParts))
3316
+		{
3317
+			return "";
3318
+		}
3319
+		foreach((array)$bodyParts as $singleBodyPart)
3320
+		{
3321
+			if (!isset($singleBodyPart['body']))
3322
+			{
2935 3323
 				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2936 3324
 				$body .= $singleBodyPart['body'];
2937 3325
 				continue;
@@ -2942,7 +3330,8 @@  discard block
 block discarded – undo
2942 3330
 				$body .= '';
2943 3331
 				continue;
2944 3332
 			}
2945
-			if(!empty($body)) {
3333
+			if(!empty($body))
3334
+			{
2946 3335
 				$body .= '<hr style="border:dotted 1px silver;">';
2947 3336
 			}
2948 3337
 			//error_log($singleBodyPart['body']);
@@ -2980,16 +3369,25 @@  discard block
 block discarded – undo
2980 3369
 				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2981 3370
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2982 3371
 				// if empty and charset is utf8 try sanitizing the string in question
2983
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3372
+				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8')
3373
+				{
3374
+					$newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3375
+				}
2984 3376
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2985
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3377
+				if (empty($newBody))
3378
+				{
3379
+					$newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3380
+				}
2986 3381
 
2987 3382
 				// search http[s] links and make them as links available again
2988 3383
 				// to understand what's going on here, have a look at
2989 3384
 				// http://www.php.net/manual/en/function.preg-replace.php
2990 3385
 
2991 3386
 				// create links for websites
2992
-				if ($modifyURI) $newBody = Api\Html::activate_links($newBody);
3387
+				if ($modifyURI)
3388
+				{
3389
+					$newBody = Api\Html::activate_links($newBody);
3390
+				}
2993 3391
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2994 3392
 				// redirect links for websites if you use no cookies
2995 3393
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -3031,10 +3429,13 @@  discard block
 block discarded – undo
3031 3429
 					{
3032 3430
 						$newBody = $cleaned;
3033 3431
 					}
3034
-					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3432
+					if (!$preserveHTML)
3433
+					{
3434
+						// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3035 3435
 					{
3036 3436
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3037 3437
 						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3438
+					}
3038 3439
 						if ($matches[2])
3039 3440
 						{
3040 3441
 							$hasOther = true;
@@ -3056,7 +3457,10 @@  discard block
 block discarded – undo
3056 3457
 					// as we switched off HTMLaweds tidy functionality
3057 3458
 					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3058 3459
 					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3059
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3460
+					if ($hasOther && $preserveHTML)
3461
+					{
3462
+						$newBody = $matches[1]. $newBody. $matches[3];
3463
+					}
3060 3464
 					$alreadyHtmlLawed=true;
3061 3465
 				}
3062 3466
 				// do the cleanup, set for the use of purifier
@@ -3161,7 +3565,10 @@  discard block
 block discarded – undo
3161 3565
 		*/
3162 3566
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3163 3567
 		{
3164
-			if (!$_type)	return false;
3568
+			if (!$_type)
3569
+			{
3570
+				return false;
3571
+			}
3165 3572
 			$CID = '';
3166 3573
 			// Build up matches according to selected type
3167 3574
 			switch ($_type)
@@ -3204,9 +3611,12 @@  discard block
 block discarded – undo
3204 3611
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
3205 3612
 
3206 3613
 							// only use data uri for "smaller" images, as otherwise the first display of the mail takes to long
3207
-							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)	// msie=8 allows max 32k data uris
3614
+							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)
3615
+							{
3616
+								// msie=8 allows max 32k data uris
3208 3617
 							{
3209 3618
 								$bo->fetchPartContents($_uid, $attachment);
3619
+							}
3210 3620
 								$cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents());
3211 3621
 							}
3212 3622
 							else
@@ -3278,7 +3688,10 @@  discard block
 block discarded – undo
3278 3688
 			}
3279 3689
 			$destination = $content['FOLDER'][0];
3280 3690
 
3281
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3691
+			if (stripos($destination,self::$delimiter)!==false)
3692
+			{
3693
+				list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3694
+			}
3282 3695
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3283 3696
 			{
3284 3697
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3303,14 +3716,26 @@  discard block
 block discarded – undo
3303 3716
 			if (!$importFailed)
3304 3717
 			{
3305 3718
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3306
-				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3719
+				if ($width > 0 && $height > 0)
3720
+				{
3721
+					Api\Json\Response::get()->call('resizeTo', $width, $height);
3722
+				}
3307 3723
 				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3308 3724
 				return;
3309 3725
 			}
3310 3726
 		}
3311
-		if (!is_array($content)) $content = array();
3312
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3313
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3727
+		if (!is_array($content))
3728
+		{
3729
+			$content = array();
3730
+		}
3731
+		if (empty($content['FOLDER']))
3732
+		{
3733
+			$content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3734
+		}
3735
+		if (!empty($content['FOLDER']))
3736
+		{
3737
+			$sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3738
+		}
3314 3739
 
3315 3740
 		$etpl = new Etemplate('mail.importMessage');
3316 3741
 		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
@@ -3330,7 +3755,10 @@  discard block
 block discarded – undo
3330 3755
 	{
3331 3756
 		$importfailed = false;
3332 3757
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
3333
-		if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name'];
3758
+		if (empty($_formData['file']))
3759
+		{
3760
+			$_formData['file'] = $_formData['tmp_name'];
3761
+		}
3334 3762
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3335 3763
 		try
3336 3764
 		{
@@ -3361,10 +3789,14 @@  discard block
 block discarded – undo
3361 3789
 				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3362 3790
 			}
3363 3791
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3364
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3792
+			if($_folder=='INBOX'.$delimiter)
3793
+			{
3794
+				$_folder='INBOX';
3795
+			}
3365 3796
 			if ($importfailed === false)
3366 3797
 			{
3367
-				if ($this->mail_bo->folderExists($_folder,true)) {
3798
+				if ($this->mail_bo->folderExists($_folder,true))
3799
+				{
3368 3800
 					try
3369 3801
 					{
3370 3802
 						$messageUid = $this->mail_bo->appendMessage($_folder,
@@ -3425,7 +3857,10 @@  discard block
 block discarded – undo
3425 3857
 	 */
3426 3858
 	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3427 3859
 	{
3428
-		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3860
+		if (empty($formData))
3861
+		{
3862
+			if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3863
+		}
3429 3864
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
3430 3865
 		$draftFolder = $this->mail_bo->getDraftFolder(false);
3431 3866
 		$importID = Mail::getRandomString();
@@ -3439,15 +3874,26 @@  discard block
 block discarded – undo
3439 3874
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3440 3875
 		{
3441 3876
 			$buff = explode('/',$formData['file']);
3442
-			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3877
+			if (is_array($buff))
3878
+			{
3879
+				$formData['name'] = array_pop($buff);
3880
+			}
3881
+			// take the last part as name
3443 3882
 		}
3444 3883
 		// type should be set to meet the requirements of checkFileBasics
3445 3884
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3446 3885
 		{
3447 3886
 			$buff = explode('.',$formData['file']);
3448 3887
 			$suffix = '';
3449
-			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3450
-			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3888
+			if (is_array($buff))
3889
+			{
3890
+				$suffix = array_pop($buff);
3891
+			}
3892
+			// take the last extension to check with ext2mime
3893
+			if (!empty($suffix))
3894
+			{
3895
+				$formData['type'] = Api\MimeMagic::ext2mime($suffix);
3896
+			}
3451 3897
 		}
3452 3898
 		// size should be set to meet the requirements of checkFileBasics
3453 3899
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3490,17 +3936,35 @@  discard block
 block discarded – undo
3490 3936
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3491 3937
 	{
3492 3938
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3493
-		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3494
-		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3495
-		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3496
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3497
-		if (empty($_messageID)) return "";
3939
+		if (!$_messageID && !empty($_GET['_messageID']))
3940
+		{
3941
+			$_messageID = $_GET['_messageID'];
3942
+		}
3943
+		if (!$_partID && !empty($_GET['_partID']))
3944
+		{
3945
+			$_partID = $_GET['_partID'];
3946
+		}
3947
+		if (!$_htmloptions && !empty($_GET['_htmloptions']))
3948
+		{
3949
+			$_htmloptions = $_GET['_htmloptions'];
3950
+		}
3951
+		if(Mail::$debug)
3952
+		{
3953
+			error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3954
+		}
3955
+		if (empty($_messageID))
3956
+		{
3957
+			return "";
3958
+		}
3498 3959
 		$uidA = self::splitRowID($_messageID);
3499 3960
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
3500 3961
 		$messageID = $uidA['msgUID'];
3501 3962
 		$icServerID = $uidA['profileID'];
3502 3963
 		//something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled
3503
-		if (empty($messageID)) return "";
3964
+		if (empty($messageID))
3965
+		{
3966
+			return "";
3967
+		}
3504 3968
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
3505 3969
 		{
3506 3970
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3533,7 +3997,11 @@  discard block
 block discarded – undo
3533 3997
 				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3534 3998
 				if (is_numeric($profileID))
3535 3999
 				{
3536
-					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
4000
+					if ($profileID != $this->mail_bo->profileID)
4001
+					{
4002
+						continue;
4003
+					}
4004
+					// only current connection
3537 4005
 					if ($folderName)
3538 4006
 					{
3539 4007
 						try
@@ -3544,7 +4012,10 @@  discard block
 block discarded – undo
3544 4012
 						{
3545 4013
 							continue;
3546 4014
 						}
3547
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
4015
+						if (in_array($fS['shortDisplayName'],Mail::$autoFolders))
4016
+						{
4017
+							$fS['shortDisplayName']=lang($fS['shortDisplayName']);
4018
+						}
3548 4019
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3549 4020
 						if ($fS['unseen'])
3550 4021
 						{
@@ -3585,7 +4056,11 @@  discard block
 block discarded – undo
3585 4056
 			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3586 4057
 			if (is_numeric($profileID))
3587 4058
 			{
3588
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4059
+				if ($profileID != $this->mail_bo->profileID)
4060
+				{
4061
+					return;
4062
+				}
4063
+				// only current connection
3589 4064
 				$del = $this->mail_bo->getHierarchyDelimiter(false);
3590 4065
 				//$del = $prefix = '';
3591 4066
 				//$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -3625,7 +4100,10 @@  discard block
 block discarded – undo
3625 4100
 				$nA = explode($del,$_newName);
3626 4101
 
3627 4102
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3628
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4103
+				if (!!empty($parentFolderName))
4104
+				{
4105
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4106
+				}
3629 4107
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3630 4108
 
3631 4109
 				$this->mail_bo->reopen('INBOX');
@@ -3646,9 +4124,15 @@  discard block
 block discarded – undo
3646 4124
 							$errorMessage .= $error;
3647 4125
 						}
3648 4126
 					}
3649
-					if ($c==count($nA)) $created=true;
4127
+					if ($c==count($nA))
4128
+					{
4129
+						$created=true;
4130
+					}
4131
+				}
4132
+				if (!empty($parentName))
4133
+				{
4134
+					$this->mail_bo->reopen($parentName);
3650 4135
 				}
3651
-				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3652 4136
 			}
3653 4137
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3654 4138
 			if ($created===true)
@@ -3684,7 +4168,10 @@  discard block
 block discarded – undo
3684 4168
 	 */
3685 4169
 	function ajax_renameFolder($_folderName, $_newName)
3686 4170
 	{
3687
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4171
+		if (Mail::$debug)
4172
+		{
4173
+			error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4174
+		}
3688 4175
 		if ($_folderName)
3689 4176
 		{
3690 4177
 			Api\Translation::add_app('mail');
@@ -3696,7 +4183,11 @@  discard block
 block discarded – undo
3696 4183
 			$hasChildren = false;
3697 4184
 			if (is_numeric($profileID))
3698 4185
 			{
3699
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4186
+				if ($profileID != $this->mail_bo->profileID)
4187
+				{
4188
+					return;
4189
+				}
4190
+				// only current connection
3700 4191
 				$pA = explode($del,$folderName);
3701 4192
 				array_pop($pA);
3702 4193
 				$parentFolder = implode($del,$pA);
@@ -3837,8 +4328,15 @@  discard block
 block discarded – undo
3837 4328
 		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3838 4329
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3839 4330
 		// that we get what we request
3840
-		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3841
-		if ($profileID != $this->mail_bo->profileID) return; // only current connection
4331
+		if ($_subscribedOnly != $oldPrefForSubscribedOnly)
4332
+		{
4333
+			$this->mail_bo->resetFolderObjectCache($profileID);
4334
+		}
4335
+		if ($profileID != $this->mail_bo->profileID)
4336
+		{
4337
+			return;
4338
+		}
4339
+		// only current connection
3842 4340
 		if (!empty($folderName))
3843 4341
 		{
3844 4342
 			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
@@ -3913,7 +4411,10 @@  discard block
 block discarded – undo
3913 4411
 	 */
3914 4412
 	function ajax_MoveFolder($_folderName, $_target)
3915 4413
 	{
3916
-		if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4414
+		if (Mail::$debug)
4415
+		{
4416
+			error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4417
+		}
3917 4418
 		if ($_folderName)
3918 4419
 		{
3919 4420
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
@@ -3924,7 +4425,11 @@  discard block
 block discarded – undo
3924 4425
 			$hasChildren = false;
3925 4426
 			if (is_numeric($profileID))
3926 4427
 			{
3927
-				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
4428
+				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID)
4429
+				{
4430
+					return;
4431
+				}
4432
+				// only current connection
3928 4433
 				$pA = explode($del,$folderName);
3929 4434
 				$namePart = array_pop($pA);
3930 4435
 				$_newName = $namePart;
@@ -3935,10 +4440,13 @@  discard block
 block discarded – undo
3935 4440
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3936 4441
 					(($oldParentFolder != $parentFolder &&
3937 4442
 					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3938
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4443
+					strpos($parentFolder,$folderName)===false))))
4444
+				{
4445
+					// indicates that we move the older up the tree within its own branch
3939 4446
 				{
3940 4447
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3941 4448
 					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4449
+				}
3942 4450
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3943 4451
 					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3944 4452
 					{
@@ -4021,8 +4529,14 @@  discard block
 block discarded – undo
4021 4529
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4022 4530
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4023 4531
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4024
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4025
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4532
+				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false)
4533
+				{
4534
+					unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4535
+				}
4536
+				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false)
4537
+				{
4538
+					unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4539
+				}
4026 4540
 
4027 4541
 				// Send full info back in the response
4028 4542
 				foreach($refreshData as $folder => &$name)
@@ -4058,7 +4572,11 @@  discard block
 block discarded – undo
4058 4572
 			$hasChildren = false;
4059 4573
 			if (is_numeric($profileID))
4060 4574
 			{
4061
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4575
+				if ($profileID != $this->mail_bo->profileID)
4576
+				{
4577
+					return;
4578
+				}
4579
+				// only current connection
4062 4580
 				$pA = explode($del,$folderName);
4063 4581
 				array_pop($pA);
4064 4582
 				if (strtoupper($folderName)!= 'INBOX')
@@ -4084,7 +4602,9 @@  discard block
 block discarded – undo
4084 4602
 						}
4085 4603
 						krsort($ftD,SORT_NUMERIC);//sort per level
4086 4604
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4087
-						foreach($ftD as $k => $lc)//collection per level
4605
+						foreach($ftD as $k => $lc)
4606
+						{
4607
+							//collection per level
4088 4608
 						{
4089 4609
 							foreach($lc as $f)//folders contained in that level
4090 4610
 							{
@@ -4092,8 +4612,12 @@  discard block
 block discarded – undo
4092 4612
 								{
4093 4613
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4094 4614
 									$this->mail_bo->deleteFolder($f);
4615
+						}
4095 4616
 									$success = true;
4096
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4617
+									if ($f==$folderName)
4618
+									{
4619
+										$oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4620
+									}
4097 4621
 								}
4098 4622
 								catch (Exception $e)
4099 4623
 								{
@@ -4123,7 +4647,10 @@  discard block
 block discarded – undo
4123 4647
 					$msg = lang("refused to delete folder INBOX");
4124 4648
 				}
4125 4649
 			}
4126
-			if ($_return) return $success;
4650
+			if ($_return)
4651
+			{
4652
+				return $success;
4653
+			}
4127 4654
 			$response = Api\Json\Response::get();
4128 4655
 			if ($success)
4129 4656
 			{
@@ -4210,24 +4737,35 @@  discard block
 block discarded – undo
4210 4737
 				// Create mail app object
4211 4738
 				$mail = new mail_ui();
4212 4739
 
4213
-				if (empty($icServerID)) $icServerID = $mail->Mail->profileID;
4214
-				if ($icServerID != $mail->Mail->profileID) return;
4740
+				if (empty($icServerID))
4741
+				{
4742
+					$icServerID = $mail->Mail->profileID;
4743
+				}
4744
+				if ($icServerID != $mail->Mail->profileID)
4745
+				{
4746
+					return;
4747
+				}
4215 4748
 
4216 4749
 				$vacation = $mail->gatherVacation($cachedVacations);
4217
-			} catch (Exception $e) {
4750
+			}
4751
+			catch (Exception $e) {
4218 4752
 				$vacation=false;
4219 4753
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4220 4754
 				unset($e);
4221 4755
 			}
4222 4756
 		}
4223 4757
 
4224
-		if($vacation) {
4758
+		if($vacation)
4759
+		{
4225 4760
 			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4226 4761
 			{
4227 4762
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4228 4763
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4229 4764
 				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4230
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4765
+				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())
4766
+				{
4767
+					$refreshData = '';
4768
+				}
4231 4769
 			}
4232 4770
 		}
4233 4771
 		if ($vacation==false)
@@ -4249,11 +4787,17 @@  discard block
 block discarded – undo
4249 4787
 	function ajax_refreshFilters($icServerID=null)
4250 4788
 	{
4251 4789
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4252
-		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4790
+		if (empty($icServerID))
4791
+		{
4792
+			$icServerID = $this->mail_bo->profileID;
4793
+		}
4253 4794
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4254 4795
 		{
4255 4796
 			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4256
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4797
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4798
+			{
4799
+				Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4800
+			}
4257 4801
 		}
4258 4802
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4259 4803
 		{
@@ -4275,7 +4819,10 @@  discard block
 block discarded – undo
4275 4819
 			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4276 4820
 			foreach($keywords as &$k)
4277 4821
 			{
4278
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4822
+				if (array_key_exists($k,$this->statusTypes))
4823
+				{
4824
+					unset($this->statusTypes[$k]);
4825
+				}
4279 4826
 			}
4280 4827
 		}
4281 4828
 
@@ -4295,7 +4842,10 @@  discard block
 block discarded – undo
4295 4842
 	{
4296 4843
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4297 4844
 		Api\Translation::add_app('mail');
4298
-		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
4845
+		if (is_null($icServerID))
4846
+		{
4847
+			$icServerID = $this->mail_bo->profileID;
4848
+		}
4299 4849
 		$rememberServerID = $this->mail_bo->profileID;
4300 4850
 		try
4301 4851
 		{
@@ -4305,19 +4855,23 @@  discard block
 block discarded – undo
4305 4855
 				$this->changeProfile($icServerID);
4306 4856
 			}
4307 4857
 			$quota = $this->mail_bo->getQuotaRoot();
4308
-		} catch (Exception $e) {
4858
+		}
4859
+		catch (Exception $e) {
4309 4860
 			$quota['limit'] = 'NOT SET';
4310 4861
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4311 4862
 			unset($e);
4312 4863
 		}
4313 4864
 
4314
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4865
+		if($quota !== false && $quota['limit'] != 'NOT SET')
4866
+		{
4315 4867
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4316 4868
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4317 4869
 			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4318 4870
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4319 4871
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4320
-		} else {
4872
+		}
4873
+		else
4874
+		{
4321 4875
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
4322 4876
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
4323 4877
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -4328,7 +4882,8 @@  discard block
 block discarded – undo
4328 4882
 			{
4329 4883
 				//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
4330 4884
 				$this->changeProfile($rememberServerID);
4331
-			} catch (Exception $e) {
4885
+			}
4886
+			catch (Exception $e) {
4332 4887
 				//error_log(__METHOD__.__LINE__." ".$e->getMessage());
4333 4888
 				unset($e);
4334 4889
 			}
@@ -4356,7 +4911,8 @@  discard block
 block discarded – undo
4356 4911
 			$this->changeProfile($icServerID);
4357 4912
 		}
4358 4913
 		$junkFolder = $this->mail_bo->getJunkFolder();
4359
-		if(!empty($junkFolder)) {
4914
+		if(!empty($junkFolder))
4915
+		{
4360 4916
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4361 4917
 			{
4362 4918
 				// Lock the tree if the active folder is junk folder
@@ -4406,7 +4962,8 @@  discard block
 block discarded – undo
4406 4962
 			$this->changeProfile($icServerID);
4407 4963
 		}
4408 4964
 		$trashFolder = $this->mail_bo->getTrashFolder();
4409
-		if(!empty($trashFolder)) {
4965
+		if(!empty($trashFolder))
4966
+		{
4410 4967
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4411 4968
 			{
4412 4969
 				// Lock the tree if the active folder is Trash folder
@@ -4452,7 +5009,10 @@  discard block
 block discarded – undo
4452 5009
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4453 5010
 		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4454 5011
 
4455
-		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
5012
+		if (empty($folderName))
5013
+		{
5014
+			$folderName = $this->mail_bo->sessionData['mailbox'];
5015
+		}
4456 5016
 		if ($this->mail_bo->folderExists($folderName))
4457 5017
 		{
4458 5018
 			$rememberServerID = $this->mail_bo->profileID;
@@ -4461,7 +5021,8 @@  discard block
 block discarded – undo
4461 5021
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4462 5022
 				$this->changeProfile($icServerID);
4463 5023
 			}
4464
-			if(!empty($_folderName)) {
5024
+			if(!empty($_folderName))
5025
+			{
4465 5026
 				$this->mail_bo->compressFolder($folderName);
4466 5027
 			}
4467 5028
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4483,7 +5044,10 @@  discard block
 block discarded – undo
4483 5044
 	 */
4484 5045
 	function ajax_sendMDN($_messageList)
4485 5046
 	{
4486
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
5047
+		if(Mail::$debug)
5048
+		{
5049
+			error_log(__METHOD__."->".array2string($_messageList));
5050
+		}
4487 5051
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4488 5052
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4489 5053
 		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
@@ -4500,7 +5064,10 @@  discard block
 block discarded – undo
4500 5064
 	 */
4501 5065
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4502 5066
 	{
4503
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5067
+		if(Mail::$debug)
5068
+		{
5069
+			error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5070
+		}
4504 5071
 		Api\Translation::add_app('mail');
4505 5072
 		$alreadyFlagged=false;
4506 5073
 		$flag2check='';
@@ -4521,12 +5088,23 @@  discard block
 block discarded – undo
4521 5088
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4522 5089
 						{
4523 5090
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4524
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5091
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5092
+							{
5093
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5094
+							}
4525 5095
 						}
4526 5096
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4527 5097
 						$cutoffdate = $cutoffdate2 = null;
4528
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4529
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5098
+						if ($query['startdate'])
5099
+						{
5100
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5101
+						}
5102
+						//SINCE, enddate
5103
+						if ($query['enddate'])
5104
+						{
5105
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5106
+						}
5107
+						//BEFORE, startdate
4530 5108
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4531 5109
 						$filter = array(
4532 5110
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4535,15 +5113,24 @@  discard block
 block discarded – undo
4535 5113
 							'status' => 'any',//this is a status change. status will be manipulated later on
4536 5114
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4537 5115
 						);
4538
-						if ($query['enddate']||$query['startdate']) {
5116
+						if ($query['enddate']||$query['startdate'])
5117
+						{
4539 5118
 							$filter['range'] = "BETWEEN";
4540
-							if ($cutoffdate) {
5119
+							if ($cutoffdate)
5120
+							{
4541 5121
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4542
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5122
+								if (empty($cutoffdate2))
5123
+								{
5124
+									$filter['range'] = "SINCE";
5125
+								}
4543 5126
 							}
4544
-							if ($cutoffdate2) {
5127
+							if ($cutoffdate2)
5128
+							{
4545 5129
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4546
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5130
+								if (empty($cutoffdate))
5131
+								{
5132
+									$filter['range'] = "BEFORE";
5133
+								}
4547 5134
 							}
4548 5135
 						}
4549 5136
 						$filter2toggle = $filter;
@@ -4590,13 +5177,19 @@  discard block
 block discarded – undo
4590 5177
 						if (count($messageListForToggle)>0)
4591 5178
 						{
4592 5179
 							$flag2set = (strtolower($_flag));
4593
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5180
+							if(Mail::$debug)
5181
+							{
5182
+								error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5183
+							}
4594 5184
 							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4595 5185
 						}
4596 5186
 						if (count($messageList)>0)
4597 5187
 						{
4598 5188
 							$flag2set = 'un'.$_flag;
4599
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5189
+							if(Mail::$debug)
5190
+							{
5191
+								error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5192
+							}
4600 5193
 							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4601 5194
 						}
4602 5195
 						$alreadyFlagged=true;
@@ -4612,7 +5205,10 @@  discard block
 block discarded – undo
4612 5205
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4613 5206
 							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4614 5207
 						}
4615
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5208
+						if(Mail::$debug)
5209
+						{
5210
+							error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5211
+						}
4616 5212
 						$_sR = $this->mail_bo->getSortedList(
4617 5213
 							$folder,
4618 5214
 							$sort=0,
@@ -4627,7 +5223,10 @@  discard block
 block discarded – undo
4627 5223
 					}
4628 5224
 					else
4629 5225
 					{
4630
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5226
+						if(Mail::$debug)
5227
+						{
5228
+							error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5229
+						}
4631 5230
 						$alreadyFlagged=true;
4632 5231
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4633 5232
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -4647,13 +5246,19 @@  discard block
 block discarded – undo
4647 5246
 					$hA = self::splitRowID($rowID);
4648 5247
 					$messageList[] = $hA['msgUID'];
4649 5248
 				}
4650
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5249
+				if(Mail::$debug)
5250
+				{
5251
+					error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5252
+				}
4651 5253
 				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4652 5254
 			}
4653 5255
 		}
4654 5256
 		else
4655 5257
 		{
4656
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5258
+			if(Mail::$debug)
5259
+			{
5260
+				error_log(__METHOD__."-> No messages selected.");
5261
+			}
4657 5262
 		}
4658 5263
 
4659 5264
 		if ($_sendJsonResponse)
@@ -4690,7 +5295,10 @@  discard block
 block discarded – undo
4690 5295
 	 */
4691 5296
 	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4692 5297
 	{
4693
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5298
+		if(Mail::$debug)
5299
+		{
5300
+			error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5301
+		}
4694 5302
 		$error = null;
4695 5303
 		$filtered =  false;
4696 5304
 		if ($_messageList=='all' || !empty($_messageList['msg']))
@@ -4709,12 +5317,23 @@  discard block
 block discarded – undo
4709 5317
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4710 5318
 						{
4711 5319
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4712
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5320
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5321
+							{
5322
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5323
+							}
4713 5324
 						}
4714 5325
 						$filtered =  true;
4715 5326
 						$cutoffdate = $cutoffdate2 = null;
4716
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4717
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5327
+						if ($query['startdate'])
5328
+						{
5329
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5330
+						}
5331
+						//SINCE, enddate
5332
+						if ($query['enddate'])
5333
+						{
5334
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5335
+						}
5336
+						//BEFORE, startdate
4718 5337
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4719 5338
 						$filter = array(
4720 5339
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4723,15 +5342,24 @@  discard block
 block discarded – undo
4723 5342
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4724 5343
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4725 5344
 						);
4726
-						if ($query['enddate']||$query['startdate']) {
5345
+						if ($query['enddate']||$query['startdate'])
5346
+						{
4727 5347
 							$filter['range'] = "BETWEEN";
4728
-							if ($cutoffdate) {
5348
+							if ($cutoffdate)
5349
+							{
4729 5350
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4730
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5351
+								if (empty($cutoffdate2))
5352
+								{
5353
+									$filter['range'] = "SINCE";
5354
+								}
4731 5355
 							}
4732
-							if ($cutoffdate2) {
5356
+							if ($cutoffdate2)
5357
+							{
4733 5358
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4734
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5359
+								if (empty($cutoffdate))
5360
+								{
5361
+									$filter['range'] = "BEFORE";
5362
+								}
4735 5363
 							}
4736 5364
 						}
4737 5365
 					}
@@ -4798,7 +5426,10 @@  discard block
 block discarded – undo
4798 5426
 		}
4799 5427
 		else
4800 5428
 		{
4801
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5429
+			if(Mail::$debug)
5430
+			{
5431
+				error_log(__METHOD__."-> No messages selected.");
5432
+			}
4802 5433
 		}
4803 5434
 	}
4804 5435
 
@@ -4814,11 +5445,17 @@  discard block
 block discarded – undo
4814 5445
 	 */
4815 5446
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4816 5447
 	{
4817
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5448
+		if(Mail::$debug)
5449
+		{
5450
+			error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5451
+		}
4818 5452
 		Api\Translation::add_app('mail');
4819 5453
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4820 5454
 		// only copy or move are supported as method
4821
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5455
+		if (!($_copyOrMove=='copy' || $_copyOrMove=='move'))
5456
+		{
5457
+			$_copyOrMove='copy';
5458
+		}
4822 5459
 		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4823 5460
 		// check if move2archive was called with the correct archiveFolder
4824 5461
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
@@ -4841,8 +5478,13 @@  discard block
 block discarded – undo
4841 5478
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4842 5479
 				foreach( $keys as &$f)
4843 5480
 				{
4844
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4845
-					else break;
5481
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9)
5482
+					{
5483
+						unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5484
+					}
5485
+					else {
5486
+						break;
5487
+					}
4846 5488
 				}
4847 5489
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4848 5490
 			}
@@ -4869,12 +5511,23 @@  discard block
 block discarded – undo
4869 5511
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4870 5512
 						{
4871 5513
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4872
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5514
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5515
+							{
5516
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5517
+							}
4873 5518
 						}
4874 5519
 						$filtered = true;
4875 5520
 						$cutoffdate = $cutoffdate2 = null;
4876
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4877
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5521
+						if ($query['startdate'])
5522
+						{
5523
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5524
+						}
5525
+						//SINCE, enddate
5526
+						if ($query['enddate'])
5527
+						{
5528
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5529
+						}
5530
+						//BEFORE, startdate
4878 5531
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4879 5532
 						$filter = array(
4880 5533
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4883,15 +5536,24 @@  discard block
 block discarded – undo
4883 5536
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4884 5537
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4885 5538
 						);
4886
-						if ($query['enddate']||$query['startdate']) {
5539
+						if ($query['enddate']||$query['startdate'])
5540
+						{
4887 5541
 							$filter['range'] = "BETWEEN";
4888
-							if ($cutoffdate) {
5542
+							if ($cutoffdate)
5543
+							{
4889 5544
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4890
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5545
+								if (empty($cutoffdate2))
5546
+								{
5547
+									$filter['range'] = "SINCE";
5548
+								}
4891 5549
 							}
4892
-							if ($cutoffdate2) {
5550
+							if ($cutoffdate2)
5551
+							{
4893 5552
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4894
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5553
+								if (empty($cutoffdate))
5554
+								{
5555
+									$filter['range'] = "BEFORE";
5556
+								}
4895 5557
 							}
4896 5558
 						}
4897 5559
 					}
@@ -4947,7 +5609,10 @@  discard block
 block discarded – undo
4947 5609
 						$hA = self::splitRowID($rowID);
4948 5610
 
4949 5611
 						// If folder changes, stop and move what we've got
4950
-						if($hA['folder'] != $folder) break;
5612
+						if($hA['folder'] != $folder)
5613
+						{
5614
+							break;
5615
+						}
4951 5616
 
4952 5617
 						array_shift($_messageList['msg']);
4953 5618
 						$messageList[] = $hA['msgUID'];
@@ -5002,7 +5667,10 @@  discard block
 block discarded – undo
5002 5667
 		}
5003 5668
 		else
5004 5669
 		{
5005
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5670
+			if(Mail::$debug)
5671
+			{
5672
+				error_log(__METHOD__."-> No messages selected.");
5673
+			}
5006 5674
 		}
5007 5675
 	}
5008 5676
 
Please login to merge, or discard this patch.