Completed
Push — 16.1 ( 576c99...284df1 )
by Hadi
91:00 queued 74:05
created
mail/inc/class.mail_compose.inc.php 1 patch
Braces   +807 added lines, -270 removed lines patch added patch discarded remove patch
@@ -82,7 +82,10 @@  discard block
 block discarded – undo
82 82
 		{
83 83
 			$this->mailPreferences['message_forwarding'] = 'asmail';
84 84
 		}
85
-		if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail');
85
+		if (is_null(Mail::$mailConfig))
86
+		{
87
+			Mail::$mailConfig = Api\Config::read('mail');
88
+		}
86 89
 
87 90
 		$this->mailPreferences  =& $this->mail_bo->mailPreferences;
88 91
 	}
@@ -96,11 +99,21 @@  discard block
 block discarded – undo
96 99
 	{
97 100
 		if ($this->mail_bo->profileID!=$_icServerID)
98 101
 		{
99
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID);
102
+			if (Mail::$debug)
103
+			{
104
+				error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID);
105
+			}
100 106
 			$this->mail_bo = Mail::getInstance(false,$_icServerID);
101
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
107
+			if (Mail::$debug)
108
+			{
109
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
110
+			}
102 111
 			// no icServer Object: something failed big time
103
-			if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
112
+			if (!isset($this->mail_bo->icServer))
113
+			{
114
+				exit;
115
+			}
116
+			// ToDo: Exception or the dialog for setting up a server config
104 117
 			$this->mail_bo->openConnection($this->mail_bo->profileID);
105 118
 			$this->mailPreferences  =& $this->mail_bo->mailPreferences;
106 119
 		}
@@ -242,7 +255,8 @@  discard block
 block discarded – undo
242 255
 		{
243 256
 			foreach (array_keys($actions) as $key)
244 257
 			{
245
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
258
+				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' )))
259
+				{
246 260
 					$actions[$key]['toolbarDefault'] = false;
247 261
 				}
248 262
 			}
@@ -268,7 +282,10 @@  discard block
 block discarded – undo
268 282
 	 */
269 283
 	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
270 284
 	{
271
-		if ($msg) Framework::message($msg);
285
+		if ($msg)
286
+		{
287
+			Framework::message($msg);
288
+		}
272 289
 
273 290
 		if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
274 291
 		{
@@ -289,8 +306,14 @@  discard block
 block discarded – undo
289 306
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
290 307
 		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
291 308
 		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
292
-		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
293
-		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
309
+		if (isset($_GET['reply_id']))
310
+		{
311
+			$replyID = $_GET['reply_id'];
312
+		}
313
+		if (!$replyID && isset($_GET['id']))
314
+		{
315
+			$replyID = $_GET['id'];
316
+		}
294 317
 
295 318
 		// Process different places we can use as a start for composing an email
296 319
 		$actionToProcess = 'compose';
@@ -357,7 +380,10 @@  discard block
 block discarded – undo
357 380
 			$suppressSigOnTop = true;
358 381
 			foreach ($_content['uploadForCompose'] as $i => &$upload)
359 382
 			{
360
-				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
383
+				if (!isset($upload['file']))
384
+				{
385
+					$upload['file'] = $upload['tmp_name'];
386
+				}
361 387
 				try
362 388
 				{
363 389
 					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
@@ -391,9 +417,15 @@  discard block
 block discarded – undo
391 417
 				$remove=false;
392 418
 				foreach(array_keys($toDelete) as $k)
393 419
 				{
394
-					if ($att['tmp_name']==$k) $remove=true;
420
+					if ($att['tmp_name']==$k)
421
+					{
422
+						$remove=true;
423
+					}
424
+				}
425
+				if (!$remove)
426
+				{
427
+					$_content['attachments'][] = $att;
395 428
 				}
396
-				if (!$remove) $_content['attachments'][] = $att;
397 429
 			}
398 430
 		}
399 431
 		// someone clicked something like send, or saveAsDraft
@@ -408,8 +440,7 @@  discard block
 block discarded – undo
408 440
 		//error_log(__METHOD__.__LINE__.array2string($_content));
409 441
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
410 442
 			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
411
-		)
412
-		{
443
+		) {
413 444
 			$this->changeProfile($_content['serverID']);
414 445
 			$composeProfile = $this->mail_bo->profileID;
415 446
 		}
@@ -489,7 +520,10 @@  discard block
 block discarded – undo
489 520
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
490 521
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
491 522
 							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
492
-							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
523
+							if (!empty($fhA['folder']))
524
+							{
525
+								$workingFolder = $fhA['folder'];
526
+							}
493 527
 						}
494 528
 					}
495 529
 					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
@@ -540,7 +574,10 @@  discard block
 block discarded – undo
540 574
 			}
541 575
 		}
542 576
 
543
-		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
577
+		if ($activeProfile != $composeProfile)
578
+		{
579
+			$this->changeProfile($activeProfile);
580
+		}
544 581
 		$insertSigOnTop = false;
545 582
 		$content = (is_array($_content)?$_content:array());
546 583
 		if ($_contentHasMimeType)
@@ -569,7 +606,10 @@  discard block
 block discarded – undo
569 606
 				{
570 607
 					foreach ($contentArr as $k =>&$elem)
571 608
 					{
572
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
609
+						if (stripos($elem,'<pre>')!==false)
610
+						{
611
+							$elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
612
+						}
573 613
 					}
574 614
 					$content['mail_htmltext'] = implode('',$contentArr);
575 615
 				}
@@ -611,8 +651,7 @@  discard block
 block discarded – undo
611 651
 		if ( !empty($content['body']) &&
612 652
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
613 653
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
614
-		)
615
-		{
654
+		) {
616 655
 			$buttonClicked = true;
617 656
 			$suppressSigOnTop = true;
618 657
 			if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount'])
@@ -628,7 +667,10 @@  discard block
 block discarded – undo
628 667
 				else
629 668
 				{
630 669
 					$newSig = $this->mail_bo->getDefaultIdentity();
631
-					if ($newSig === false) $newSig = -2;
670
+					if ($newSig === false)
671
+					{
672
+						$newSig = -2;
673
+					}
632 674
 				}
633 675
 			}
634 676
 			$_oldSig = $composeCache['mailidentity'];
@@ -636,7 +678,10 @@  discard block
 block discarded – undo
636 678
 
637 679
 			if ($_oldSig != $_signatureid)
638 680
 			{
639
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
681
+				if($this->_debug)
682
+				{
683
+					error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
684
+				}
640 685
 				// prepare signatures, the selected sig may be used on top of the body
641 686
 				try
642 687
 				{
@@ -666,7 +711,10 @@  discard block
 block discarded – undo
666 711
 				{
667 712
 					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
668 713
 					$sigText = $this->convertHTMLToText($sigText,true,true);
669
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
714
+					if($this->_debug)
715
+					{
716
+						error_log(__METHOD__." Old signature:".$oldSigText);
717
+					}
670 718
 				}
671 719
 
672 720
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -682,7 +730,11 @@  discard block
 block discarded – undo
682 730
 				{
683 731
 					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
684 732
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
685
-					if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags
733
+					if (stripos($content['body'],'style')!==false)
734
+					{
735
+						Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true);
736
+					}
737
+					// clean out empty or pagewide style definitions / left over tags
686 738
 				}
687 739
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
688 740
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -727,8 +779,14 @@  discard block
 block discarded – undo
727 779
 
728 780
 				if ($found === false)
729 781
 				{
730
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
731
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
782
+					if($this->_debug)
783
+					{
784
+						error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
785
+					}
786
+					if($this->_debug)
787
+					{
788
+						error_log(__METHOD__." Compare content:".$content['body']);
789
+					}
732 790
 				}
733 791
 				else
734 792
 				{
@@ -746,7 +804,10 @@  discard block
 block discarded – undo
746 804
 		$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
747 805
 
748 806
 		// do not double insert a signature on a server roundtrip
749
-		if ($buttonClicked) $suppressSigOnTop = true;
807
+		if ($buttonClicked)
808
+		{
809
+			$suppressSigOnTop = true;
810
+		}
750 811
 		if ($isFirstLoad)
751 812
 		{
752 813
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
@@ -785,7 +846,8 @@  discard block
 block discarded – undo
785 846
 							}
786 847
 						}
787 848
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
788
-						foreach(array('subject','body','mimetype') as $name) {
849
+						foreach(array('subject','body','mimetype') as $name)
850
+						{
789 851
 							$sName = $name;
790 852
 							if ($name=='mimetype'&&$res[$name])
791 853
 							{
@@ -794,7 +856,10 @@  discard block
 block discarded – undo
794 856
 							}
795 857
 							else
796 858
 							{
797
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
859
+								if ($res[$name])
860
+								{
861
+									$content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
862
+								}
798 863
 							}
799 864
 						}
800 865
 					}
@@ -805,7 +870,8 @@  discard block
 block discarded – undo
805 870
 			{
806 871
 				$alreadyProcessed=array();
807 872
 				//_debug_array($_REQUEST);
808
-				if ($_REQUEST['preset']['mailto']) {
873
+				if ($_REQUEST['preset']['mailto'])
874
+				{
809 875
 					// handle mailto strings such as
810 876
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
811 877
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
@@ -813,10 +879,12 @@  discard block
 block discarded – undo
813 879
 					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
814 880
 					// check if there is more than the to address
815 881
 					$mailtoArray = explode('?',$tmp_send_to,2);
816
-					if ($mailtoArray[1]) {
882
+					if ($mailtoArray[1])
883
+					{
817 884
 						// check if there are more than one requests
818 885
 						$addRequests = explode('&',$mailtoArray[1]);
819
-						foreach ($addRequests as $key => $reqval) {
886
+						foreach ($addRequests as $key => $reqval)
887
+						{
820 888
 							// the additional requests should have a =, to separate key from value.
821 889
 							$keyValuePair = explode('=',$reqval,2);
822 890
 							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
@@ -825,17 +893,24 @@  discard block
 block discarded – undo
825 893
 					$content['to']=$mailtoArray[0];
826 894
 					$alreadyProcessed['to']='to';
827 895
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
828
-					foreach(array('cc','bcc','subject','body') as $name) {
896
+					foreach(array('cc','bcc','subject','body') as $name)
897
+					{
829 898
 						$alreadyProcessed[$name]=$name;
830
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
899
+						if ($_REQUEST[$name])
900
+						{
901
+							$content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
902
+						}
831 903
 					}
832 904
 				}
833 905
 
834
-				if ($_REQUEST['preset']['mailtocontactbyid']) {
835
-					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
906
+				if ($_REQUEST['preset']['mailtocontactbyid'])
907
+				{
908
+					if ($GLOBALS['egw_info']['user']['apps']['addressbook'])
909
+					{
836 910
 						$contacts_obj = new Api\Contacts();
837 911
 						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
838
-						if (method_exists($contacts_obj,'search')) {
912
+						if (method_exists($contacts_obj,'search'))
913
+						{
839 914
 
840 915
 							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
841 916
 							foreach ((array)$addressArray as $id => $addressID)
@@ -850,7 +925,10 @@  discard block
 block discarded – undo
850 925
 							{
851 926
 								$_searchCond = array('contact_id'=>$addressArray);
852 927
 								//error_log(__METHOD__.__LINE__.$_searchString);
853
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
928
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
929
+								{
930
+									$showAccounts=false;
931
+								}
854 932
 								$filter = ($showAccounts?array():array('account_id' => null));
855 933
 								$filter['cols_to_search']=array('n_fn','email','email_home');
856 934
 								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
@@ -873,21 +951,28 @@  discard block
 block discarded – undo
873 951
 									unset($accounts);
874 952
 								}
875 953
 							}
876
-							if(is_array($contacts)) {
954
+							if(is_array($contacts))
955
+							{
877 956
 								$mailtoArray = array();
878 957
 								$primary = $addressbookprefs['distributionListPreferredMail'];
879
-								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
958
+								if ($primary != 'email' && $primary != 'email_home')
959
+								{
960
+									$primary = 'email';
961
+								}
880 962
 								$secondary = ($primary == 'email'?'email_home':'email');
881 963
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
882
-								foreach($contacts as $contact) {
964
+								foreach($contacts as $contact)
965
+								{
883 966
 									$innerCounter=0;
884
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
967
+									foreach(array($contact[$primary],$contact[$secondary]) as $email)
968
+									{
885 969
 										// use pref distributionListPreferredMail for the primary address
886 970
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
887 971
 										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
888 972
 										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
889 973
 										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
890
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
974
+										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false)
975
+										{
891 976
 											$i++;
892 977
 											$innerCounter++;
893 978
 											$mailtoArray[$i] = $completeMailString;
@@ -979,7 +1064,10 @@  discard block
 block discarded – undo
979 1064
 							}
980 1065
 						}
981 1066
 					}
982
-					if(!empty($remember)) $content = array_merge($content,$remember);
1067
+					if(!empty($remember))
1068
+					{
1069
+						$content = array_merge($content,$remember);
1070
+					}
983 1071
 				}
984 1072
 				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
985 1073
 				{
@@ -989,9 +1077,15 @@  discard block
 block discarded – undo
989 1077
 						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
990 1078
 					}
991 1079
 					//skip if already processed by "preset Routines"
992
-					if ($alreadyProcessed[$name]) continue;
1080
+					if ($alreadyProcessed[$name])
1081
+					{
1082
+						continue;
1083
+					}
993 1084
 					//error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]);
994
-					if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name];
1085
+					if ($_REQUEST['preset'][$name])
1086
+					{
1087
+						$content[$name] = $_REQUEST['preset'][$name];
1088
+					}
995 1089
 				}
996 1090
 			}
997 1091
 			// is the to address set already?
@@ -999,7 +1093,10 @@  discard block
 block discarded – undo
999 1093
 			{
1000 1094
 				$content['to'] = base64_decode($_REQUEST['send_to']);
1001 1095
 				// first check if there is a questionmark or ampersand
1002
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1096
+				if (strpos($content['to'],'?')!== false)
1097
+				{
1098
+					list($content['to'],$rest) = explode('?',$content['to'],2);
1099
+				}
1003 1100
 				$content['to'] = html_entity_decode($content['to']);
1004 1101
 				if (($at_pos = strpos($content['to'],'@')) !== false)
1005 1102
 				{
@@ -1012,9 +1109,15 @@  discard block
 block discarded – undo
1012 1109
 						$content['to'] = $email;
1013 1110
 					}
1014 1111
 				}
1015
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1112
+				if (strpos($content['to'],'%40')!== false)
1113
+				{
1114
+					$content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1115
+				}
1016 1116
 				$rarr = array(Api\Html::purify($rest));
1017
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1117
+				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false)
1118
+				{
1119
+					$rarr = explode('&',$rest);
1120
+				}
1018 1121
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1019 1122
 				$karr = array();
1020 1123
 				foreach ($rarr as &$rval)
@@ -1030,9 +1133,15 @@  discard block
 block discarded – undo
1030 1133
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1031 1134
 				foreach(array('cc','bcc','subject','body') as $name)
1032 1135
 				{
1033
-					if ($karr[$name]) $content[$name] = $karr[$name];
1136
+					if ($karr[$name])
1137
+					{
1138
+						$content[$name] = $karr[$name];
1139
+					}
1140
+				}
1141
+				if (!empty($_REQUEST['subject']))
1142
+				{
1143
+					$content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1034 1144
 				}
1035
-				if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1036 1145
 			}
1037 1146
 		}
1038 1147
 		//error_log(__METHOD__.__LINE__.array2string($content));
@@ -1050,7 +1159,10 @@  discard block
 block discarded – undo
1050 1159
 				$_content['mimeType'] = $content['mimeType']  = 'html';
1051 1160
 				$content['body'] = "<pre>".$content['body']."</pre>";
1052 1161
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1053
-				if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1162
+				if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1163
+				{
1164
+					$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1165
+				}
1054 1166
 			}
1055 1167
 		}
1056 1168
 		else
@@ -1070,7 +1182,10 @@  discard block
 block discarded – undo
1070 1182
 					$_content['mimeType'] = $content['mimeType']  = 'html';
1071 1183
 					$content['body'] = "<pre>".$content['body']."</pre>";
1072 1184
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1073
-					if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1185
+					if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1186
+					{
1187
+						$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1188
+					}
1074 1189
 				}
1075 1190
 			}
1076 1191
 		}
@@ -1110,24 +1225,33 @@  discard block
 block discarded – undo
1110 1225
 			$disableRuler = true;
1111 1226
 		}
1112 1227
 		$font_span = $font_part = '';
1113
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1228
+		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/)
1229
+		{
1114 1230
 			// User preferences for style
1115 1231
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1116 1232
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1117 1233
 			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1118 1234
 			$font_span = $font_part.'&#8203;</span>';
1119
-			if (empty($font) && empty($font_size)) $font_span = '';
1235
+			if (empty($font) && empty($font_size))
1236
+			{
1237
+				$font_span = '';
1238
+			}
1120 1239
 		}
1121 1240
 		// the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span
1122
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1241
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false)
1242
+		{
1243
+			$font_span = '';
1244
+		}
1123 1245
 		//remove possible html header stuff
1124
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1246
+		if (stripos($content['body'],'<html><head></head><body>')!==false)
1247
+		{
1248
+			$content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1249
+		}
1125 1250
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1126 1251
 		$blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul');
1127 1252
 		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1128 1253
 			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1129
-		)
1130
-		{
1254
+		) {
1131 1255
 			// ON tOP OR BELOW? pREF CAN TELL
1132 1256
 			/*
1133 1257
 				Signature behavior preference changed. New default, if not set -> 0
@@ -1142,14 +1266,23 @@  discard block
 block discarded – undo
1142 1266
 				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1143 1267
 				foreach($blockElements as $e)
1144 1268
 				{
1145
-					if ($sigTextStartsWithBlockElement) break;
1146
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1269
+					if ($sigTextStartsWithBlockElement)
1270
+					{
1271
+						break;
1272
+					}
1273
+					if (stripos(trim($sigText),'<'.$e)===0)
1274
+					{
1275
+						$sigTextStartsWithBlockElement = true;
1276
+					}
1147 1277
 				}
1148 1278
 			}
1149
-			if($content['mimeType'] == 'html') {
1279
+			if($content['mimeType'] == 'html')
1280
+			{
1150 1281
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1151 1282
 				$inbetween = '';
1152
-			} else {
1283
+			}
1284
+			else
1285
+			{
1153 1286
 				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1154 1287
 				$inbetween = "\r\n";
1155 1288
 			}
@@ -1183,7 +1316,10 @@  discard block
 block discarded – undo
1183 1316
 		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1184 1317
 		{
1185 1318
 			// do NOT add SMTP only accounts as identities
1186
-			if (!$account->is_imap(false)) continue;
1319
+			if (!$account->is_imap(false))
1320
+			{
1321
+				continue;
1322
+			}
1187 1323
 
1188 1324
 			foreach($account->identities($acc_id) as $ident_id => $identity)
1189 1325
 			{
@@ -1196,16 +1332,24 @@  discard block
 block discarded – undo
1196 1332
 		//$content['bcc'] = array('[email protected]','[email protected]');
1197 1333
 		// address stuff like from, to, cc, replyto
1198 1334
 		$destinationRows = 0;
1199
-		foreach(self::$destinations as $destination) {
1335
+		foreach(self::$destinations as $destination)
1336
+		{
1200 1337
 			if (!is_array($content[$destination]))
1201 1338
 			{
1202
-				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
1339
+				if (!empty($content[$destination]))
1340
+				{
1341
+					$content[$destination] = (array)$content[$destination];
1342
+				}
1203 1343
 			}
1204 1344
 			$addr_content = $content[strtolower($destination)];
1205 1345
 			// we clear the given address array and rebuild it
1206 1346
 			unset($content[strtolower($destination)]);
1207
-			foreach((array)$addr_content as $key => $value) {
1208
-				if ($value=="NIL@NIL") continue;
1347
+			foreach((array)$addr_content as $key => $value)
1348
+			{
1349
+				if ($value=="NIL@NIL")
1350
+				{
1351
+					continue;
1352
+				}
1209 1353
 				if ($destination=='replyto' && str_replace('"','',$value) ==
1210 1354
 					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1211 1355
 				{
@@ -1215,8 +1359,12 @@  discard block
 block discarded – undo
1215 1359
 				}
1216 1360
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1217 1361
 				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1218
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1219
-					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1362
+				foreach(Mail::parseAddressList($value) as $addressObject)
1363
+				{
1364
+					if ($addressObject->host == '.SYNTAX-ERROR.')
1365
+					{
1366
+						continue;
1367
+					}
1220 1368
 					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1221 1369
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1222 1370
 					$content[strtolower($destination)][]=$address;
@@ -1227,11 +1375,20 @@  discard block
 block discarded – undo
1227 1375
 		if ($_content)
1228 1376
 		{
1229 1377
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1230
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1378
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content))
1379
+			{
1380
+				unset($_content['mailidentity']);
1381
+			}
1231 1382
 			$content = array_merge($content,$_content);
1232 1383
 
1233
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1234
-			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1384
+			if (!empty($content['folder']))
1385
+			{
1386
+				$sel_options['folder']=$this->ajax_searchFolder(0,true);
1387
+			}
1388
+			if (empty($content['mailaccount']))
1389
+			{
1390
+				$content['mailaccount'] = $this->mail_bo->profileID;
1391
+			}
1235 1392
 		}
1236 1393
 		else
1237 1394
 		{
@@ -1274,11 +1431,17 @@  discard block
 block discarded – undo
1274 1431
 		//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
1275 1432
 		$preserv['is_html'] = $content['is_html'];
1276 1433
 		$preserv['is_plain'] = $content['is_plain'];
1277
-		if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
1434
+		if (isset($content['mimeType']))
1435
+		{
1436
+			$preserv['mimeType'] = $content['mimeType'];
1437
+		}
1278 1438
 		$sel_options['mimeType'] = self::$mimeTypes;
1279 1439
 		$sel_options['priority'] = self::$priorities;
1280 1440
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1281
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1441
+		if (!isset($content['priority']) || empty($content['priority']))
1442
+		{
1443
+			$content['priority']=3;
1444
+		}
1282 1445
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1283 1446
 		$etpl = new Etemplate('mail.compose');
1284 1447
 
@@ -1325,9 +1488,12 @@  discard block
 block discarded – undo
1325 1488
 		$preserv['list-id'] = $content['list-id'];
1326 1489
 		$preserv['mode'] = $content['mode'];
1327 1490
 		// convert it back to checkbox expectations
1328
-		if($content['mimeType'] == 'html') {
1491
+		if($content['mimeType'] == 'html')
1492
+		{
1329 1493
 			$content['mimeType']=1;
1330
-		} else {
1494
+		}
1495
+		else
1496
+		{
1331 1497
 			$content['mimeType']=0;
1332 1498
 		}
1333 1499
 		// set the current selected mailaccount as param for folderselection
@@ -1352,7 +1518,10 @@  discard block
 block discarded – undo
1352 1518
 		// Resolve distribution list before send content to client
1353 1519
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1354 1520
 		{
1355
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1521
+			if (is_array($content[$f]))
1522
+			{
1523
+				$content[$f]= self::resolveEmailAddressList ($content[$f]);
1524
+			}
1356 1525
 		}
1357 1526
 
1358 1527
 		$content['to'] = self::resolveEmailAddressList($content['to']);
@@ -1400,7 +1569,10 @@  discard block
 block discarded – undo
1400 1569
 				case 'composefromdraft':
1401 1570
 				case 'composeasnew':
1402 1571
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1403
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1572
+					if ($from =='composefromdraft')
1573
+					{
1574
+						$content['mode'] = 'composefromdraft';
1575
+					}
1404 1576
 					$content['processedmail_id'] = $mail_id;
1405 1577
 
1406 1578
 					$_focusElement = 'body';
@@ -1448,7 +1620,10 @@  discard block
 block discarded – undo
1448 1620
 			$document_merge = new $merge_class();
1449 1621
 			$this->mail_bo->openConnection();
1450 1622
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1451
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1623
+			if (!is_array($merge_ids))
1624
+			{
1625
+				$merge_ids = explode(',',$merge_ids);
1626
+			}
1452 1627
 			try
1453 1628
 			{
1454 1629
 				$merged_mail_id = '';
@@ -1479,7 +1654,10 @@  discard block
 block discarded – undo
1479 1654
 				{
1480 1655
 					$success = implode(', ',$results['success']);
1481 1656
 					$fail = implode(', ', $results['failed']);
1482
-					if($success) Framework::message($success, 'success');
1657
+					if($success)
1658
+					{
1659
+						Framework::message($success, 'success');
1660
+					}
1483 1661
 					Framework::window_close($fail);
1484 1662
 				}
1485 1663
 			}
@@ -1511,17 +1689,25 @@  discard block
 block discarded – undo
1511 1689
 	{
1512 1690
 		$stripalltags = true;
1513 1691
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1514
-		if (!$sourceishtml) $stripalltags=false;
1692
+		if (!$sourceishtml)
1693
+		{
1694
+			$stripalltags=false;
1695
+		}
1515 1696
 		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1516 1697
 	}
1517 1698
 
1518 1699
 	function generateRFC822Address($_addressObject)
1519 1700
 	{
1520
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1701
+		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host)
1702
+		{
1521 1703
 			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1522
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1704
+		}
1705
+		elseif($_addressObject->mailbox && $_addressObject->host)
1706
+		{
1523 1707
 			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1524
-		} else {
1708
+		}
1709
+		else
1710
+		{
1525 1711
 			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1526 1712
 		}
1527 1713
 	}
@@ -1555,16 +1741,28 @@  discard block
 block discarded – undo
1555 1741
 		//if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC'];
1556 1742
 
1557 1743
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1558
-		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1559
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1744
+		if (!empty($addHeadInfo['X-MAILFOLDER']))
1745
+		{
1746
+			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val )
1747
+			{
1560 1748
 				$fval=$val;
1561 1749
 				$icServerID = $mail_bo->icServer->ImapServerId;
1562
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1563
-				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1564
-				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1750
+				if (stripos($val,'::')!==false)
1751
+				{
1752
+					list($icServerID,$fval) = explode('::',$val,2);
1753
+				}
1754
+				if ($icServerID != $mail_bo->icServer->ImapServerId)
1755
+				{
1756
+					continue;
1757
+				}
1758
+				if ($mail_bo->folderExists($fval))
1759
+				{
1760
+					$this->sessionData['folder'][] = $val;
1761
+				}
1565 1762
 			}
1566 1763
 		}
1567
-		if (!empty($addHeadInfo['X-MAILIDENTITY'])) {
1764
+		if (!empty($addHeadInfo['X-MAILIDENTITY']))
1765
+		{
1568 1766
 			// with the new system it would be the identity
1569 1767
 			try
1570 1768
 			{
@@ -1580,7 +1778,8 @@  discard block
 block discarded – undo
1580 1778
 			$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
1581 1779
 		}
1582 1780
 		*/
1583
-		if (!empty($addHeadInfo['X-MAILACCOUNT'])) {
1781
+		if (!empty($addHeadInfo['X-MAILACCOUNT']))
1782
+		{
1584 1783
 			// with the new system it would the identity is the account id
1585 1784
 			try
1586 1785
 			{
@@ -1595,27 +1794,38 @@  discard block
 block discarded – undo
1595 1794
 			}
1596 1795
 		}
1597 1796
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1598
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1797
+		if ($mail_bo->isDraftFolder($_folder))
1798
+		{
1799
+			$this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);
1800
+		}
1801
+		//array('uid'=>$_uid,'folder'=>$_folder);
1599 1802
 		$this->sessionData['uid'] = $_uid;
1600 1803
 		$this->sessionData['messageFolder'] = $_folder;
1601 1804
 		$this->sessionData['isDraft'] = true;
1602 1805
 		$foundAddresses = array();
1603
-		foreach((array)$headers['CC'] as $val) {
1806
+		foreach((array)$headers['CC'] as $val)
1807
+		{
1604 1808
 			$rfcAddr=Mail::parseAddressList($val);
1605 1809
 			$_rfcAddr = $rfcAddr[0];
1606
-			if (!$_rfcAddr->valid) continue;
1607
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1810
+			if (!$_rfcAddr->valid)
1811
+			{
1812
+				continue;
1813
+			}
1814
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1815
+			{
1608 1816
 				continue;
1609 1817
 			}
1610 1818
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1611
-			if(!$foundAddresses[$keyemail]) {
1819
+			if(!$foundAddresses[$keyemail])
1820
+			{
1612 1821
 				$address = $this->mail_bo->decode_header($val,true);
1613 1822
 				$this->sessionData['cc'][] = $val;
1614 1823
 				$foundAddresses[$keyemail] = true;
1615 1824
 			}
1616 1825
 		}
1617 1826
 
1618
-		foreach((array)$headers['TO'] as $val) {
1827
+		foreach((array)$headers['TO'] as $val)
1828
+		{
1619 1829
 			if(!is_array($val))
1620 1830
 			{
1621 1831
 				$this->sessionData['to'][] = $val;
@@ -1623,42 +1833,59 @@  discard block
 block discarded – undo
1623 1833
 			}
1624 1834
 			$rfcAddr=Mail::parseAddressList($val);
1625 1835
 			$_rfcAddr = $rfcAddr[0];
1626
-			if (!$_rfcAddr->valid) continue;
1627
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1836
+			if (!$_rfcAddr->valid)
1837
+			{
1838
+				continue;
1839
+			}
1840
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1841
+			{
1628 1842
 				continue;
1629 1843
 			}
1630 1844
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1631
-			if(!$foundAddresses[$keyemail]) {
1845
+			if(!$foundAddresses[$keyemail])
1846
+			{
1632 1847
 				$address = $this->mail_bo->decode_header($val,true);
1633 1848
 				$this->sessionData['to'][] = $val;
1634 1849
 				$foundAddresses[$keyemail] = true;
1635 1850
 			}
1636 1851
 		}
1637 1852
 
1638
-		foreach((array)$headers['REPLY-TO'] as $val) {
1853
+		foreach((array)$headers['REPLY-TO'] as $val)
1854
+		{
1639 1855
 			$rfcAddr=Mail::parseAddressList($val);
1640 1856
 			$_rfcAddr = $rfcAddr[0];
1641
-			if (!$_rfcAddr->valid) continue;
1642
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1857
+			if (!$_rfcAddr->valid)
1858
+			{
1859
+				continue;
1860
+			}
1861
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1862
+			{
1643 1863
 				continue;
1644 1864
 			}
1645 1865
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1646
-			if(!$foundAddresses[$keyemail]) {
1866
+			if(!$foundAddresses[$keyemail])
1867
+			{
1647 1868
 				$address = $this->mail_bo->decode_header($val,true);
1648 1869
 				$this->sessionData['replyto'][] = $val;
1649 1870
 				$foundAddresses[$keyemail] = true;
1650 1871
 			}
1651 1872
 		}
1652 1873
 
1653
-		foreach((array)$headers['BCC'] as $val) {
1874
+		foreach((array)$headers['BCC'] as $val)
1875
+		{
1654 1876
 			$rfcAddr=Mail::parseAddressList($val);
1655 1877
 			$_rfcAddr = $rfcAddr[0];
1656
-			if (!$_rfcAddr->valid) continue;
1657
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1878
+			if (!$_rfcAddr->valid)
1879
+			{
1880
+				continue;
1881
+			}
1882
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1883
+			{
1658 1884
 				continue;
1659 1885
 			}
1660 1886
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1661
-			if(!$foundAddresses[$keyemail]) {
1887
+			if(!$foundAddresses[$keyemail])
1888
+			{
1662 1889
 				$address = $this->mail_bo->decode_header($val,true);
1663 1890
 				$this->sessionData['bcc'][] = $val;
1664 1891
 				$foundAddresses[$keyemail] = true;
@@ -1672,32 +1899,46 @@  discard block
 block discarded – undo
1672 1899
 		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1673 1900
 		//_debug_array($bodyParts);
1674 1901
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1675
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1902
+		if($bodyParts['0']['mimeType'] == 'text/html')
1903
+		{
1676 1904
 			$this->sessionData['mimeType'] 	= 'html';
1677 1905
 
1678
-			for($i=0; $i<count($bodyParts); $i++) {
1679
-				if($i>0) {
1906
+			for($i=0; $i<count($bodyParts); $i++)
1907
+			{
1908
+				if($i>0)
1909
+				{
1680 1910
 					$this->sessionData['body'] .= '<hr>';
1681 1911
 				}
1682
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1912
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
1913
+				{
1683 1914
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1684 1915
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1685 1916
 				}
1686
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1917
+				if ($bodyParts[$i]['charSet']===false)
1918
+				{
1919
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1920
+				}
1687 1921
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1688 1922
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1689 1923
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1690 1924
 			}
1691 1925
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1692 1926
 
1693
-		} else {
1927
+		}
1928
+		else
1929
+		{
1694 1930
 			$this->sessionData['mimeType']	= 'plain';
1695 1931
 
1696
-			for($i=0; $i<count($bodyParts); $i++) {
1697
-				if($i>0) {
1932
+			for($i=0; $i<count($bodyParts); $i++)
1933
+			{
1934
+				if($i>0)
1935
+				{
1698 1936
 					$this->sessionData['body'] .= "<hr>";
1699 1937
 				}
1700
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1938
+				if ($bodyParts[$i]['charSet']===false)
1939
+				{
1940
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1941
+				}
1701 1942
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1702 1943
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1703 1944
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
@@ -1705,8 +1946,10 @@  discard block
 block discarded – undo
1705 1946
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1706 1947
 		}
1707 1948
 
1708
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1709
-			foreach($attachments as $attachment) {
1949
+		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1950
+		{
1951
+			foreach($attachments as $attachment)
1952
+			{
1710 1953
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1711 1954
 				$cid = $attachment['cid'];
1712 1955
 				$match=null;
@@ -1729,7 +1972,8 @@  discard block
 block discarded – undo
1729 1972
 
1730 1973
 	function getErrorInfo()
1731 1974
 	{
1732
-		if(isset($this->errorInfo)) {
1975
+		if(isset($this->errorInfo))
1976
+		{
1733 1977
 			$errorInfo = $this->errorInfo;
1734 1978
 			unset($this->errorInfo);
1735 1979
 			return $errorInfo;
@@ -1744,7 +1988,8 @@  discard block
 block discarded – undo
1744 1988
 			$modebuff = $this->mailPreferences['message_forwarding'];
1745 1989
 			$this->mailPreferences['message_forwarding'] = $_mode;
1746 1990
 		}
1747
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1991
+		if  ($this->mailPreferences['message_forwarding'] == 'inline')
1992
+		{
1748 1993
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1749 1994
 		}
1750 1995
 		$mail_bo    = $this->mail_bo;
@@ -1761,12 +2006,16 @@  discard block
 block discarded – undo
1761 2006
 		//$this->sessionData['sourceFolder']=$_folder;
1762 2007
 		//$this->sessionData['forwardFlag']='forwarded';
1763 2008
 		//$this->sessionData['forwardedUID']=$_uid;
1764
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
2009
+		if  ($this->mailPreferences['message_forwarding'] == 'asmail')
2010
+		{
1765 2011
 			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1766 2012
 			if($headers['SIZE'])
1767
-				$size				= $headers['SIZE'];
1768
-			else
1769
-				$size				= lang('unknown');
2013
+			{
2014
+							$size				= $headers['SIZE'];
2015
+			}
2016
+			else {
2017
+							$size				= lang('unknown');
2018
+			}
1770 2019
 
1771 2020
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1772 2021
 				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
@@ -1777,9 +2026,11 @@  discard block
 block discarded – undo
1777 2026
 			unset($this->sessionData['in-reply-to']);
1778 2027
 			unset($this->sessionData['to']);
1779 2028
 			unset($this->sessionData['cc']);
1780
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
2029
+			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false)))
2030
+			{
1781 2031
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1782
-				foreach($attachments as $attachment) {
2032
+				foreach($attachments as $attachment)
2033
+				{
1783 2034
 					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1784 2035
 					{
1785 2036
 						$this->addMessageAttachment($_uid, $attachment['partID'],
@@ -1835,7 +2086,10 @@  discard block
 block discarded – undo
1835 2086
 			{
1836 2087
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1837 2088
 					strtolower($_formData['type'])== strtolower($attach['type']) &&
1838
-					stripos($_formData['file'],'vfs://') !== false) return;
2089
+					stripos($_formData['file'],'vfs://') !== false)
2090
+				{
2091
+					return;
2092
+				}
1839 2093
 			}
1840 2094
 		}
1841 2095
 		if ($attachfailed === false)
@@ -1847,7 +2101,10 @@  discard block
 block discarded – undo
1847 2101
 				'tmp_name'	=> $tmpFileName,
1848 2102
 				'size'	=> $_formData['size']
1849 2103
 			);
1850
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
2104
+			if (!is_array($_content['attachments']))
2105
+			{
2106
+				$_content['attachments']=array();
2107
+			}
1851 2108
 			$_content['attachments'][] = $buffer;
1852 2109
 			unset($buffer);
1853 2110
 		}
@@ -1878,7 +2135,10 @@  discard block
 block discarded – undo
1878 2135
 		{
1879 2136
 			foreach($request->preserv['attachments'] as $attachment)
1880 2137
 			{
1881
-				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2138
+				if ($_GET['tmpname'] === $attachment['tmp_name'])
2139
+				{
2140
+					break;
2141
+				}
1882 2142
 			}
1883 2143
 		}
1884 2144
 		if (!$request || $_GET['tmpname'] !== $attachment['tmp_name'])
@@ -1912,10 +2172,20 @@  discard block
 block discarded – undo
1912 2172
 				$sfxMimeType = $attachment['type'];
1913 2173
 				$buff = explode('.',$attachment['tmp_name']);
1914 2174
 				$suffix = '';
1915
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1916
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2175
+				if (is_array($buff))
2176
+				{
2177
+					$suffix = array_pop($buff);
2178
+				}
2179
+				// take the last extension to check with ext2mime
2180
+				if (!empty($suffix))
2181
+				{
2182
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2183
+				}
1917 2184
 				$attachment['type'] = $sfxMimeType;
1918
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2185
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2186
+				{
2187
+					$attachment['type'] = strtoupper($sfxMimeType);
2188
+				}
1919 2189
 			}
1920 2190
 			//error_log(__METHOD__.print_r($attachment,true));
1921 2191
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -1924,7 +2194,10 @@  discard block
 block discarded – undo
1924 2194
 				$calendar_ical = new calendar_ical();
1925 2195
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1926 2196
 				//error_log(__METHOD__.array2string($eventid));
1927
-				if (!$eventid) $eventid = -1;
2197
+				if (!$eventid)
2198
+				{
2199
+					$eventid = -1;
2200
+				}
1928 2201
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1929 2202
 				//error_log(__METHOD__.$event);
1930 2203
 				if ((int)$event > 0)
@@ -1950,7 +2223,10 @@  discard block
 block discarded – undo
1950 2223
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1951 2224
 					$contact = $addressbook_vcal->find_contact($vcard,false);
1952 2225
 				}
1953
-				if (!$contact) $contact = null;
2226
+				if (!$contact)
2227
+				{
2228
+					$contact = null;
2229
+				}
1954 2230
 				// 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))
1955 2231
 				if ($contact || count($vcard)>2)
1956 2232
 				{
@@ -1981,7 +2257,8 @@  discard block
 block discarded – undo
1981 2257
 	 * @param string haystack
1982 2258
 	 * @return boolean
1983 2259
 	 */
1984
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2260
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack)
2261
+	{
1985 2262
 		foreach (array_keys($arrayToTestAgainst) as $k)
1986 2263
 		{
1987 2264
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
@@ -2038,21 +2315,34 @@  discard block
 block discarded – undo
2038 2315
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
2039 2316
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
2040 2317
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
2041
-		if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2042
-		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2318
+		if ($headers['THREAD-INDEX'])
2319
+		{
2320
+			$this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2321
+		}
2322
+		if ($headers['LIST-ID'])
2323
+		{
2324
+			$this->sessionData['list-id'] = $headers['LIST-ID'];
2325
+		}
2043 2326
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2044 2327
 		// check for Reply-To: header and use if available
2045
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2046
-			foreach($headers['REPLY-TO'] as $val) {
2047
-				if(!$foundAddresses[$val]) {
2328
+		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM']))
2329
+		{
2330
+			foreach($headers['REPLY-TO'] as $val)
2331
+			{
2332
+				if(!$foundAddresses[$val])
2333
+				{
2048 2334
 					$oldTo[] = $val;
2049 2335
 					$foundAddresses[$val] = true;
2050 2336
 				}
2051 2337
 			}
2052 2338
 			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2053
-		} else {
2054
-			foreach($headers['FROM'] as $val) {
2055
-				if(!$foundAddresses[$val]) {
2339
+		}
2340
+		else
2341
+		{
2342
+			foreach($headers['FROM'] as $val)
2343
+			{
2344
+				if(!$foundAddresses[$val])
2345
+				{
2056 2346
 					$oldTo[] = $val;
2057 2347
 					$foundAddresses[$val] = true;
2058 2348
 				}
@@ -2060,18 +2350,23 @@  discard block
 block discarded – undo
2060 2350
 			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2061 2351
 		}
2062 2352
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2063
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2353
+		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) )
2354
+		{
2064 2355
 			$this->sessionData['to'] = $oldTo;
2065 2356
 		}
2066 2357
 
2067
-		if($_mode == 'all') {
2358
+		if($_mode == 'all')
2359
+		{
2068 2360
 			// reply to any address which is cc, but not to my self
2069 2361
 			#if($headers->cc) {
2070
-				foreach($headers['CC'] as $val) {
2071
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2362
+				foreach($headers['CC'] as $val)
2363
+				{
2364
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2365
+					{
2072 2366
 						continue;
2073 2367
 					}
2074
-					if(!$foundAddresses[$val]) {
2368
+					if(!$foundAddresses[$val])
2369
+					{
2075 2370
 						$this->sessionData['cc'][] = $val;
2076 2371
 						$foundAddresses[$val] = true;
2077 2372
 					}
@@ -2080,11 +2375,14 @@  discard block
 block discarded – undo
2080 2375
 
2081 2376
 			// reply to any address which is to, but not to my self
2082 2377
 			#if($headers->to) {
2083
-				foreach($headers['TO'] as $val) {
2084
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2378
+				foreach($headers['TO'] as $val)
2379
+				{
2380
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2381
+					{
2085 2382
 						continue;
2086 2383
 					}
2087
-					if(!$foundAddresses[$val]) {
2384
+					if(!$foundAddresses[$val])
2385
+					{
2088 2386
 						$this->sessionData['to'][] = $val;
2089 2387
 						$foundAddresses[$val] = true;
2090 2388
 					}
@@ -2092,12 +2390,15 @@  discard block
 block discarded – undo
2092 2390
 			#}
2093 2391
 
2094 2392
 			#if($headers->from) {
2095
-				foreach($headers['FROM'] as $val) {
2096
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2393
+				foreach($headers['FROM'] as $val)
2394
+				{
2395
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2396
+					{
2097 2397
 						continue;
2098 2398
 					}
2099 2399
 					//error_log(__METHOD__.__LINE__.' '.$val);
2100
-					if(!$foundAddresses[$val]) {
2400
+					if(!$foundAddresses[$val])
2401
+					{
2101 2402
 						$this->sessionData['to'][] = $val;
2102 2403
 						$foundAddresses[$val] = true;
2103 2404
 					}
@@ -2106,9 +2407,12 @@  discard block
 block discarded – undo
2106 2407
 		}
2107 2408
 
2108 2409
 		// check for Re: in subject header
2109
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2410
+		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:")
2411
+		{
2110 2412
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2111
-		} else {
2413
+		}
2414
+		else
2415
+		{
2112 2416
 			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2113 2417
 		}
2114 2418
 
@@ -2122,7 +2426,8 @@  discard block
 block discarded – undo
2122 2426
 
2123 2427
 		$toAddressA = array();
2124 2428
 		$toAddress = '';
2125
-		foreach ($headers['TO'] as $mailheader) {
2429
+		foreach ($headers['TO'] as $mailheader)
2430
+		{
2126 2431
 			$toAddressA[] =  $mailheader;
2127 2432
 		}
2128 2433
 		if (count($toAddressA)>0)
@@ -2132,7 +2437,8 @@  discard block
 block discarded – undo
2132 2437
 		}
2133 2438
 		$ccAddressA = array();
2134 2439
 		$ccAddress = '';
2135
-		foreach ($headers['CC'] as $mailheader) {
2440
+		foreach ($headers['CC'] as $mailheader)
2441
+		{
2136 2442
 			$ccAddressA[] =  $mailheader;
2137 2443
 		}
2138 2444
 		if (count($ccAddressA)>0)
@@ -2140,25 +2446,35 @@  discard block
 block discarded – undo
2140 2446
 			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2141 2447
 			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2142 2448
 		}
2143
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2449
+		if($bodyParts['0']['mimeType'] == 'text/html')
2450
+		{
2144 2451
 			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2145 2452
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2146 2453
 				$toAddress.$ccAddress.
2147 2454
 				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2148 2455
 				'----------------------------------------------------------'."</div>";
2149 2456
 			$this->sessionData['mimeType'] 	= 'html';
2150
-			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2457
+			if (!empty($styles))
2458
+			{
2459
+				$this->sessionData['body'] .= $styles;
2460
+			}
2151 2461
 			$this->sessionData['body']	.= '<blockquote type="cite">';
2152 2462
 
2153
-			for($i=0; $i<count($bodyParts); $i++) {
2154
-				if($i>0) {
2463
+			for($i=0; $i<count($bodyParts); $i++)
2464
+			{
2465
+				if($i>0)
2466
+				{
2155 2467
 					$this->sessionData['body'] .= '<hr>';
2156 2468
 				}
2157
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2469
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2470
+				{
2158 2471
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2159 2472
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2160 2473
 				}
2161
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2474
+				if ($bodyParts[$i]['charSet']===false)
2475
+				{
2476
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2477
+				}
2162 2478
 
2163 2479
 				$_htmlConfig = Mail::$htmLawed_config;
2164 2480
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2170,7 +2486,9 @@  discard block
 block discarded – undo
2170 2486
 
2171 2487
 			$this->sessionData['body']	.= '</blockquote><br>';
2172 2488
 			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2173
-		} else {
2489
+		}
2490
+		else
2491
+		{
2174 2492
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2175 2493
 			// take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs)
2176 2494
             $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
@@ -2180,8 +2498,10 @@  discard block
 block discarded – undo
2180 2498
                 '-------------------------------------------------'."\r\n \r\n ";
2181 2499
 			$this->sessionData['mimeType']	= 'plain';
2182 2500
 
2183
-			for($i=0; $i<count($bodyParts); $i++) {
2184
-				if($i>0) {
2501
+			for($i=0; $i<count($bodyParts); $i++)
2502
+			{
2503
+				if($i>0)
2504
+				{
2185 2505
 					$this->sessionData['body'] .= "<hr>";
2186 2506
 				}
2187 2507
 
@@ -2192,7 +2512,8 @@  discard block
 block discarded – undo
2192 2512
 				$this->sessionData['body'] .= "\r\n";
2193 2513
 				$hasSignature = false;
2194 2514
 				// create body new, with good line breaks and indention
2195
-				foreach(explode("\n",$newBody) as $value) {
2515
+				foreach(explode("\n",$newBody) as $value)
2516
+				{
2196 2517
 					// the explode is removing the character
2197 2518
 					//$value .= 'ee';
2198 2519
 
@@ -2203,8 +2524,12 @@  discard block
 block discarded – undo
2203 2524
 						continue;
2204 2525
 					}
2205 2526
 
2206
-					if ($hasSignature)	continue;
2207
-					if (trim($value) != '') {
2527
+					if ($hasSignature)
2528
+					{
2529
+						continue;
2530
+					}
2531
+					if (trim($value) != '')
2532
+					{
2208 2533
 						#if ($value != "\r") $value .= "\n";
2209 2534
 					}
2210 2535
 					$numberOfChars = strspn(trim($value), ">");
@@ -2212,9 +2537,12 @@  discard block
 block discarded – undo
2212 2537
 
2213 2538
 					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2214 2539
 
2215
-					if($bodyAppend[0] == '>') {
2540
+					if($bodyAppend[0] == '>')
2541
+					{
2216 2542
 						$bodyAppend = '>'. $bodyAppend;
2217
-					} else {
2543
+					}
2544
+					else
2545
+					{
2218 2546
 						$bodyAppend = '> '. $bodyAppend;
2219 2547
 					}
2220 2548
 
@@ -2263,9 +2591,12 @@  discard block
 block discarded – undo
2263 2591
 
2264 2592
 	static function _getHostName()
2265 2593
 	{
2266
-		if (isset($_SERVER['SERVER_NAME'])) {
2594
+		if (isset($_SERVER['SERVER_NAME']))
2595
+		{
2267 2596
 			$result = $_SERVER['SERVER_NAME'];
2268
-		} else {
2597
+		}
2598
+		else
2599
+		{
2269 2600
 			$result = 'localhost.localdomain';
2270 2601
 		}
2271 2602
 		return $result;
@@ -2303,11 +2634,16 @@  discard block
 block discarded – undo
2303 2634
 
2304 2635
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2305 2636
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2306
-		if(!empty($_formData['in-reply-to'])) {
2307
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2637
+		if(!empty($_formData['in-reply-to']))
2638
+		{
2639
+			if (stripos($_formData['in-reply-to'],'<')===false)
2640
+			{
2641
+				$_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2642
+			}
2308 2643
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2309 2644
 		}
2310
-		if(!empty($_formData['references'])) {
2645
+		if(!empty($_formData['references']))
2646
+		{
2311 2647
 			if (stripos($_formData['references'],'<')===false)
2312 2648
 			{
2313 2649
 				$_formData['references']='<'.trim($_formData['references']).'>';
@@ -2315,28 +2651,38 @@  discard block
 block discarded – undo
2315 2651
 			$_mailObject->addHeader('References', $_formData['references']);
2316 2652
 		}
2317 2653
 
2318
-		if(!empty($_formData['thread-index'])) {
2654
+		if(!empty($_formData['thread-index']))
2655
+		{
2319 2656
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2320 2657
 		}
2321
-		if(!empty($_formData['list-id'])) {
2658
+		if(!empty($_formData['list-id']))
2659
+		{
2322 2660
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2323 2661
 		}
2324
-		if($_formData['disposition']=='on') {
2662
+		if($_formData['disposition']=='on')
2663
+		{
2325 2664
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2326 2665
 		}
2327 2666
 
2328 2667
 		// Expand any mailing lists
2329 2668
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2330 2669
 		{
2331
-			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2670
+			if ($field != 'replyto')
2671
+			{
2672
+				$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2673
+			}
2332 2674
 
2333
-			if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field);
2675
+			if ($_formData[$field])
2676
+			{
2677
+				$_mailObject->addAddress($_formData[$field], '', $field);
2678
+			}
2334 2679
 		}
2335 2680
 
2336 2681
 		$_mailObject->addHeader('Subject', $_formData['subject']);
2337 2682
 
2338 2683
 		// this should never happen since we come from the edit dialog
2339
-		if (Mail::detect_qp($_formData['body'])) {
2684
+		if (Mail::detect_qp($_formData['body']))
2685
+		{
2340 2686
 			$_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']);
2341 2687
 			$_formData['body'] = quoted_printable_decode($_formData['body']);
2342 2688
 		}
@@ -2389,7 +2735,10 @@  discard block
 block discarded – undo
2389 2735
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true));
2390 2736
 			}
2391 2737
 			// convert URL Images to inline images - if possible
2392
-			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2738
+			if (!$_autosaving)
2739
+			{
2740
+				$inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2741
+			}
2393 2742
 			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2394 2743
 			{
2395 2744
 				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@@ -2404,10 +2753,14 @@  discard block
 block discarded – undo
2404 2753
 		{
2405 2754
 			$body = $this->convertHTMLToText($_formData['body'],false);
2406 2755
 
2407
-			if ($attachment_links) $body .= $attachment_links;
2756
+			if ($attachment_links)
2757
+			{
2758
+				$body .= $attachment_links;
2759
+			}
2408 2760
 
2409 2761
 			#$_mailObject->Body = $_formData['body'];
2410
-			if(!empty($signature)) {
2762
+			if(!empty($signature))
2763
+			{
2411 2764
 				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2412 2765
 					$this->convertHTMLToText($signature,true,true);
2413 2766
 			}
@@ -2418,10 +2771,12 @@  discard block
 block discarded – undo
2418 2771
 		{
2419 2772
 			$connection_opened = false;
2420 2773
 			$tnfattachments = null;
2421
-			foreach((array)$_formData['attachments'] as $attachment) {
2774
+			foreach((array)$_formData['attachments'] as $attachment)
2775
+			{
2422 2776
 				if(is_array($attachment))
2423 2777
 				{
2424
-					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2778
+					if (!empty($attachment['uid']) && !empty($attachment['folder']))
2779
+					{
2425 2780
 						/* Example:
2426 2781
 						Array([0] => Array(
2427 2782
 						[uid] => 21178
@@ -2437,14 +2792,18 @@  discard block
 block discarded – undo
2437 2792
 							$connection_opened = true;
2438 2793
 						}
2439 2794
 						$mail_bo->reopen($attachment['folder']);
2440
-						switch(strtoupper($attachment['type'])) {
2795
+						switch(strtoupper($attachment['type']))
2796
+						{
2441 2797
 							case 'MESSAGE/RFC':
2442 2798
 							case 'MESSAGE/RFC822':
2443 2799
 								$rawBody='';
2444
-								if (isset($attachment['partID'])) {
2800
+								if (isset($attachment['partID']))
2801
+								{
2445 2802
 									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2446 2803
 									$rawBody=$eml['attachment'];
2447
-								} else {
2804
+								}
2805
+								else
2806
+								{
2448 2807
 									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2449 2808
 								}
2450 2809
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
@@ -2453,7 +2812,10 @@  discard block
 block discarded – undo
2453 2812
 								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2454 2813
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2455 2814
 								{
2456
-									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2815
+									if (!is_array($tnfattachments))
2816
+									{
2817
+										$tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2818
+									}
2457 2819
 									foreach ($tnfattachments as $k)
2458 2820
 									{
2459 2821
 										if ($k['name'] == $attachment['name'])
@@ -2488,7 +2850,10 @@  discard block
 block discarded – undo
2488 2850
 					}
2489 2851
 				}
2490 2852
 			}
2491
-			if ($connection_opened) $mail_bo->closeConnection();
2853
+			if ($connection_opened)
2854
+			{
2855
+				$mail_bo->closeConnection();
2856
+			}
2492 2857
 		}
2493 2858
 		return is_array($inline_images)?$inline_images:array();
2494 2859
 	}
@@ -2508,13 +2873,20 @@  discard block
 block discarded – undo
2508 2873
 	 */
2509 2874
 	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2510 2875
 	{
2511
-		if ($filemode == Vfs\Sharing::ATTACH) return '';
2876
+		if ($filemode == Vfs\Sharing::ATTACH)
2877
+		{
2878
+			return '';
2879
+		}
2512 2880
 
2513 2881
 		$links = array();
2514 2882
 		foreach($attachments as $attachment)
2515 2883
 		{
2516 2884
 			$path = $attachment['file'];
2517
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2885
+			if (empty($path))
2886
+			{
2887
+				continue;
2888
+			}
2889
+			// we only care about file attachments, not forwarded messages or parts
2518 2890
 			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2519 2891
 			{
2520 2892
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
@@ -2617,13 +2989,19 @@  discard block
 block discarded – undo
2617 2989
 								$success = false;
2618 2990
 								error_log(__METHOD__.__LINE__.$msg);
2619 2991
 							}
2620
-						} else {
2992
+						}
2993
+						else
2994
+						{
2621 2995
 							error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former');
2622 2996
 						}
2623
-					} else {
2997
+					}
2998
+					else
2999
+					{
2624 3000
 						error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)");
2625 3001
 					}
2626
-				} else {
3002
+				}
3003
+				else
3004
+				{
2627 3005
 					error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)");
2628 3006
 				}
2629 3007
 			}
@@ -2639,7 +3017,10 @@  discard block
 block discarded – undo
2639 3017
 			$success = false;
2640 3018
 		}
2641 3019
 
2642
-		if ($success) $msg = lang('Message saved successfully.');
3020
+		if ($success)
3021
+		{
3022
+			$msg = lang('Message saved successfully.');
3023
+		}
2643 3024
 
2644 3025
 		// Include new information to json respose, because we need them in client-side callback
2645 3026
 		$response->data(array(
@@ -2663,7 +3044,10 @@  discard block
 block discarded – undo
2663 3044
 		{
2664 3045
 			if(is_int($address))
2665 3046
 			{
2666
-				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
3047
+				if (!isset($contacts_obs))
3048
+				{
3049
+					$contacts_obj = new Api\Contacts();
3050
+				}
2667 3051
 				// List was selected, expand to addresses
2668 3052
 				unset($_emailAddressList[$ak]);
2669 3053
 				$list = $contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address));
@@ -2678,7 +3062,10 @@  discard block
 block discarded – undo
2678 3062
 		{
2679 3063
 			foreach ($addrFromList as $addr)
2680 3064
 			{
2681
-				if (!empty($addr)) $_emailAddressList[]=$addr;
3065
+				if (!empty($addr))
3066
+				{
3067
+					$_emailAddressList[]=$addr;
3068
+				}
2682 3069
 			}
2683 3070
 		}
2684 3071
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2732,7 +3119,10 @@  discard block
 block discarded – undo
2732 3119
 		// decide where to save the message (default to draft folder, if we find nothing else)
2733 3120
 		// if the current folder is in draft or template folder save it there
2734 3121
 		// if it is called from printview then save it with the draft folder
2735
-		if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder();
3122
+		if (empty($savingDestination))
3123
+		{
3124
+			$savingDestination = $mail_bo->getDraftFolder();
3125
+		}
2736 3126
 		if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox']))
2737 3127
 		{
2738 3128
 			$this->sessionData['messageFolder'] = $this->sessionData['mailbox'];
@@ -2743,13 +3133,17 @@  discard block
 block discarded – undo
2743 3133
 			$savingDestination = $this->sessionData['messageFolder'];
2744 3134
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2745 3135
 		}
2746
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
3136
+		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 )
3137
+		{
3138
+			$savingDestination = $mail_bo->getDraftFolder();
3139
+		}
2747 3140
 
2748 3141
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2749 3142
 		$mail->forceBccHeader();
2750 3143
 
2751 3144
 		$mail_bo->openConnection();
2752
-		if ($mail_bo->folderExists($savingDestination,true)) {
3145
+		if ($mail_bo->folderExists($savingDestination,true))
3146
+		{
2753 3147
 			try
2754 3148
 			{
2755 3149
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
@@ -2760,7 +3154,9 @@  discard block
 block discarded – undo
2760 3154
 				return false;
2761 3155
 			}
2762 3156
 
2763
-		} else {
3157
+		}
3158
+		else
3159
+		{
2764 3160
 			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2765 3161
 			return false;
2766 3162
 		}
@@ -2808,7 +3204,10 @@  discard block
 block discarded – undo
2808 3204
 					$fhA = mail_ui::splitRowID($rowid);
2809 3205
 					$this->sessionData['uid'][] = $fhA['msgUID'];
2810 3206
 					$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
2811
-					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
3207
+					if (!empty($fhA['folder']))
3208
+					{
3209
+						$this->sessionData['sourceFolder'] = $fhA['folder'];
3210
+					}
2812 3211
 				}
2813 3212
 			}
2814 3213
 			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
@@ -2840,7 +3239,8 @@  discard block
 block discarded – undo
2840 3239
 			#error_log($this->sessionData['body']);
2841 3240
 		}
2842 3241
 		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2843
-		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
3242
+		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder']))
3243
+		{
2844 3244
 		   	$messageIsDraft = true;
2845 3245
 		}
2846 3246
 		try
@@ -2856,7 +3256,11 @@  discard block
 block discarded – undo
2856 3256
 		// create the messages and store inline images
2857 3257
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2858 3258
 		// remember the identity
2859
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
3259
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3260
+		{
3261
+			$fromAddress = $mail->From;
3262
+		}
3263
+		//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2860 3264
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2861 3265
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2862 3266
 		#exit;
@@ -2869,7 +3273,10 @@  discard block
 block discarded – undo
2869 3273
 		{
2870 3274
 			$fval=$f;
2871 3275
 			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2872
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3276
+			if (stripos($f,'::')!==false)
3277
+			{
3278
+				list($icServerID,$fval) = explode('::',$f,2);
3279
+			}
2873 3280
 			if ($_formData['serverID']!=$_formData['mailaccount'])
2874 3281
 			{
2875 3282
 				if ($icServerID == $_formData['serverID'] )
@@ -2910,13 +3317,19 @@  discard block
 block discarded – undo
2910 3317
 			// sentFolder is account specific
2911 3318
 			$sentFolder = $this->mail_bo->getSentFolder();
2912 3319
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2913
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3320
+			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true))
3321
+			{
3322
+				$sentFolder=false;
3323
+			}
2914 3324
 		}
2915 3325
 		else
2916 3326
 		{
2917 3327
 			$sentFolder = $mail_bo->getSentFolder();
2918 3328
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2919
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3329
+			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true))
3330
+			{
3331
+				$sentFolder=false;
3332
+			}
2920 3333
 		}
2921 3334
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2922 3335
 
@@ -2952,19 +3365,30 @@  discard block
 block discarded – undo
2952 3365
 		{
2953 3366
 			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2954 3367
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2955
-				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3368
+				$sentFolder != 'none'))
3369
+			{
3370
+				$this->errorInfo = lang("No Send Folder set in preferences");
3371
+			}
2956 3372
 		}
2957 3373
 		// draftFolder is on Server we start from
2958
-		if($messageIsDraft == true) {
3374
+		if($messageIsDraft == true)
3375
+		{
2959 3376
 			$draftFolder = $mail_bo->getDraftFolder();
2960
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3377
+			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true))
3378
+			{
2961 3379
 				$this->sessionData['folder'] = array($draftFolder);
2962 3380
 				$folderOnServerID[] = $draftFolder;
2963 3381
 				$folder[$draftFolder] = $draftFolder;
2964 3382
 			}
2965 3383
 		}
2966
-		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2967
-		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3384
+		if ($folderOnServerID)
3385
+		{
3386
+			$folderOnServerID = array_unique($folderOnServerID);
3387
+		}
3388
+		if ($folderOnMailAccount)
3389
+		{
3390
+			$folderOnMailAccount = array_unique($folderOnMailAccount);
3391
+		}
2968 3392
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2969 3393
 			!( count($folder) > 0) &&
2970 3394
 			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
@@ -2978,7 +3402,8 @@  discard block
 block discarded – undo
2978 3402
 		@set_time_limit(120);
2979 3403
 		//$mail->SMTPDebug = 10;
2980 3404
 		//error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc']));
2981
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3405
+		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0)
3406
+		{
2982 3407
 			try {
2983 3408
 				$mail->send();
2984 3409
 			}
@@ -2988,10 +3413,15 @@  discard block
 block discarded – undo
2988 3413
 				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2989 3414
 				return false;
2990 3415
 			}
2991
-		} else {
2992
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3416
+		}
3417
+		else
3418
+		{
3419
+			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder']))
3420
+			{
2993 3421
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2994
-			} else {
3422
+			}
3423
+			else
3424
+			{
2995 3425
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
2996 3426
 				//error_log(__METHOD__.__LINE__.$this->errorInfo);
2997 3427
 				return false;
@@ -3001,14 +3431,16 @@  discard block
 block discarded – undo
3001 3431
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
3002 3432
 		//error_log(__METHOD__.__LINE__.array2string($folder));
3003 3433
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3004
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3434
+            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3435
+		{
3005 3436
 			$mail_bo = $this->mail_bo;
3006 3437
 			$mail_bo->openConnection();
3007 3438
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
3008 3439
 			#error_log("(re)opened Connection");
3009 3440
 		}
3010 3441
 		// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
3011
-		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
3442
+		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3443
+		{
3012 3444
 			//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
3013 3445
 
3014 3446
 			// normaly Bcc is only added to recipients, but not as header visible to all recipients
@@ -3017,17 +3449,28 @@  discard block
 block discarded – undo
3017 3449
 		// copying mail to folder
3018 3450
 		if (count($folder) > 0)
3019 3451
 		{
3020
-			foreach($folderOnServerID as $folderName) {
3021
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3452
+			foreach($folderOnServerID as $folderName)
3453
+			{
3454
+				if (is_array($folderName))
3455
+				{
3456
+					$folderName = array_shift($folderName);
3457
+				}
3458
+				// should not happen at all
3022 3459
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3023 3460
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3024 3461
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3025
-				if ($mail_bo->folderExists($folderName,true)) {
3026
-					if($mail_bo->isSentFolder($folderName)) {
3462
+				if ($mail_bo->folderExists($folderName,true))
3463
+				{
3464
+					if($mail_bo->isSentFolder($folderName))
3465
+					{
3027 3466
 						$flags = '\\Seen';
3028
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3467
+					}
3468
+					elseif($mail_bo->isDraftFolder($folderName))
3469
+					{
3029 3470
 						$flags = '\\Draft';
3030
-					} else {
3471
+					}
3472
+					else
3473
+					{
3031 3474
 						$flags = '\\Seen';
3032 3475
 					}
3033 3476
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3050,18 +3493,32 @@  discard block
 block discarded – undo
3050 3493
 				}
3051 3494
 			}
3052 3495
 			// if we choose to send from a differing profile
3053
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3054
-			foreach($folderOnMailAccount as $folderName) {
3055
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3496
+			if ($folderOnMailAccount)
3497
+			{
3498
+				$this->changeProfile($_formData['mailaccount']);
3499
+			}
3500
+			foreach($folderOnMailAccount as $folderName)
3501
+			{
3502
+				if (is_array($folderName))
3503
+				{
3504
+					$folderName = array_shift($folderName);
3505
+				}
3506
+				// should not happen at all
3056 3507
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3057 3508
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3058 3509
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3059
-				if ($this->mail_bo->folderExists($folderName,true)) {
3060
-					if($this->mail_bo->isSentFolder($folderName)) {
3510
+				if ($this->mail_bo->folderExists($folderName,true))
3511
+				{
3512
+					if($this->mail_bo->isSentFolder($folderName))
3513
+					{
3061 3514
 						$flags = '\\Seen';
3062
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3515
+					}
3516
+					elseif($this->mail_bo->isDraftFolder($folderName))
3517
+					{
3063 3518
 						$flags = '\\Draft';
3064
-					} else {
3519
+					}
3520
+					else
3521
+					{
3065 3522
 						$flags = '\\Seen';
3066 3523
 					}
3067 3524
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3083,7 +3540,10 @@  discard block
 block discarded – undo
3083 3540
 					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3084 3541
 				}
3085 3542
 			}
3086
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
3543
+			if ($folderOnMailAccount)
3544
+			{
3545
+				$this->changeProfile($_formData['serverID']);
3546
+			}
3087 3547
 
3088 3548
 			//$mail_bo->closeConnection();
3089 3549
 		}
@@ -3095,10 +3555,16 @@  discard block
 block discarded – undo
3095 3555
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3096 3556
 			$lastDrafted['uid'] = $dhA['msgUID'];
3097 3557
 			$lastDrafted['folder'] = $dhA['folder'];
3098
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3558
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid']))
3559
+			{
3560
+				$lastDrafted['uid']=trim($lastDrafted['uid']);
3561
+			}
3099 3562
 			// manually drafted, do not delete
3100 3563
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3101
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3564
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid']))
3565
+			{
3566
+				$lastDrafted=false;
3567
+			}
3102 3568
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3103 3569
 		}
3104 3570
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
@@ -3124,7 +3590,8 @@  discard block
 block discarded – undo
3124 3590
 
3125 3591
 		//error_log("handling draft messages, flagging and such");
3126 3592
 		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3127
-			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3593
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3594
+		{
3128 3595
 			// mark message as answered
3129 3596
 			$mail_bo->openConnection();
3130 3597
 			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
@@ -3146,7 +3613,9 @@  discard block
 block discarded – undo
3146 3613
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
3147 3614
 					unset($e);
3148 3615
 				}
3149
-			} else {
3616
+			}
3617
+			else
3618
+			{
3150 3619
 				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3151 3620
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3152 3621
 				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
@@ -3165,7 +3634,10 @@  discard block
 block discarded – undo
3165 3634
 			}
3166 3635
 			//$mail_bo->closeConnection();
3167 3636
 		}
3168
-		if ($mail_bo) $mail_bo->closeConnection();
3637
+		if ($mail_bo)
3638
+		{
3639
+			$mail_bo->closeConnection();
3640
+		}
3169 3641
 		//error_log("performing Infolog Stuff");
3170 3642
 		//error_log(print_r($this->sessionData['to'],true));
3171 3643
 		//error_log(print_r($this->sessionData['cc'],true));
@@ -3178,9 +3650,18 @@  discard block
 block discarded – undo
3178 3650
 		{
3179 3651
 			$mailaddresses = array();
3180 3652
 		}
3181
-		if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
3182
-		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3183
-		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3653
+		if (is_array($this->sessionData['cc']))
3654
+		{
3655
+			$mailaddresses['cc'] = $this->sessionData['cc'];
3656
+		}
3657
+		if (is_array($this->sessionData['bcc']))
3658
+		{
3659
+			$mailaddresses['bcc'] = $this->sessionData['bcc'];
3660
+		}
3661
+		if (!empty($mailaddresses))
3662
+		{
3663
+			$mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3664
+		}
3184 3665
 
3185 3666
 		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3186 3667
 		{
@@ -3212,7 +3693,10 @@  discard block
 block discarded – undo
3212 3693
 							$_formData['serverID']),true),
3213 3694
 						'app' => $app_name
3214 3695
 					);
3215
-					if ($entryid) $target['entry_id'] = $entryid;
3696
+					if ($entryid)
3697
+					{
3698
+						$target['entry_id'] = $entryid;
3699
+					}
3216 3700
 					// Open the app called for integration in a popup
3217 3701
 					// and store the mail raw data as egw_data, in order to
3218 3702
 					// be stored from registered app method later
@@ -3223,8 +3707,11 @@  discard block
 block discarded – undo
3223 3707
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3224 3708
 		elseif(is_array($this->sessionData['attachments']))
3225 3709
 		{
3226
-			foreach($this->sessionData['attachments'] as $value) {
3227
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3710
+			foreach($this->sessionData['attachments'] as $value)
3711
+			{
3712
+				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs')
3713
+				{
3714
+// happens when forwarding mails
3228 3715
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3229 3716
 				}
3230 3717
 			}
@@ -3261,7 +3748,10 @@  discard block
 block discarded – undo
3261 3748
 				$default_identity = null;
3262 3749
 				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3263 3750
 				{
3264
-					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3751
+					if (!isset($default_identity))
3752
+					{
3753
+						$default_identity = $identity['ident_id'];
3754
+					}
3265 3755
 					if (!empty($identity['ident_signature']))
3266 3756
 					{
3267 3757
 						$content['mailidentity'] = $identity['ident_id'];
@@ -3269,12 +3759,18 @@  discard block
 block discarded – undo
3269 3759
 					}
3270 3760
 				}
3271 3761
 			}
3272
-			if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity;
3762
+			if (empty($content['mailidentity']))
3763
+			{
3764
+				$content['mailidentity'] = $default_identity;
3765
+			}
3273 3766
 		}
3274 3767
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3275 3768
 		{
3276 3769
 			$content['mimeType'] = 'html';
3277
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3770
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text")
3771
+			{
3772
+				$content['mimeType']  = 'plain';
3773
+			}
3278 3774
 		}
3279 3775
 		return $content;
3280 3776
 
@@ -3282,9 +3778,12 @@  discard block
 block discarded – undo
3282 3778
 
3283 3779
 	function stripSlashes($_string)
3284 3780
 	{
3285
-		if (get_magic_quotes_gpc()) {
3781
+		if (get_magic_quotes_gpc())
3782
+		{
3286 3783
 			return stripslashes($_string);
3287
-		} else {
3784
+		}
3785
+		else
3786
+		{
3288 3787
 			return $_string;
3289 3788
 		}
3290 3789
 	}
@@ -3297,15 +3796,25 @@  discard block
 block discarded – undo
3297 3796
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3298 3797
 	 * @return type
3299 3798
 	 */
3300
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3799
+	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
3800
+	{
3301 3801
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3302 3802
 		static $useCacheIfPossible = null;
3303
-		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
3803
+		if (is_null($useCacheIfPossible))
3804
+		{
3805
+			$useCacheIfPossible = true;
3806
+		}
3304 3807
 		$_searchString = trim($_REQUEST['query']);
3305 3808
 		$results = array();
3306 3809
 		$rememberServerID = $this->mail_bo->icServer->ImapServerId;
3307
-		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount'];
3308
-		if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3810
+		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount']))
3811
+		{
3812
+			$_mailaccountToSearch = $_REQUEST['mailaccount'];
3813
+		}
3814
+		if (empty($_mailaccountToSearch))
3815
+		{
3816
+			$_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3817
+		}
3309 3818
 		if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch)
3310 3819
 		{
3311 3820
 			$this->changeProfile($_mailaccountToSearch);
@@ -3316,7 +3825,8 @@  discard block
 block discarded – undo
3316 3825
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3317 3826
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3318 3827
 			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3319
-			if (count($folderObjects)<=1) {
3828
+			if (count($folderObjects)<=1)
3829
+			{
3320 3830
 				$useCacheIfPossible = false;
3321 3831
 			}
3322 3832
 			else
@@ -3367,7 +3877,8 @@  discard block
 block discarded – undo
3367 3877
 		exit();
3368 3878
 	}
3369 3879
 
3370
-	public static function ajax_searchAddress($_searchStringLength=2) {
3880
+	public static function ajax_searchAddress($_searchStringLength=2)
3881
+	{
3371 3882
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3372 3883
 		$_searchString = trim($_REQUEST['query']);
3373 3884
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3380,7 +3891,8 @@  discard block
 block discarded – undo
3380 3891
 		{
3381 3892
 			$lists = array_filter(
3382 3893
 				$contacts_obj->get_lists(Acl::READ),
3383
-				function($element) use($_searchString) {
3894
+				function($element) use($_searchString)
3895
+				{
3384 3896
 					return (stripos($element, $_searchString) !== false);
3385 3897
 				}
3386 3898
 			);
@@ -3395,7 +3907,10 @@  discard block
 block discarded – undo
3395 3907
 					'title' => lang('Mailinglist'),
3396 3908
 					'data'	=> $key
3397 3909
 				);
3398
-				if($list_count++ > 5) break;
3910
+				if($list_count++ > 5)
3911
+				{
3912
+					break;
3913
+				}
3399 3914
 			}
3400 3915
 		}
3401 3916
 
@@ -3406,7 +3921,10 @@  discard block
 block discarded – undo
3406 3921
 			$search = explode(' ', $_searchString);
3407 3922
 			foreach ($search as $k => $v)
3408 3923
 			{
3409
-				if (mb_strlen($v) < 3) unset($search[$k]);
3924
+				if (mb_strlen($v) < 3)
3925
+				{
3926
+					unset($search[$k]);
3927
+				}
3410 3928
 			}
3411 3929
 			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3412 3930
 			//error_log(__METHOD__.__LINE__.$_searchString);
@@ -3436,9 +3954,12 @@  discard block
 block discarded – undo
3436 3954
 			}
3437 3955
 		}
3438 3956
 		
3439
-		if(is_array($contacts)) {
3440
-			foreach($contacts as $contact) {
3441
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3957
+		if(is_array($contacts))
3958
+		{
3959
+			foreach($contacts as $contact)
3960
+			{
3961
+				foreach(array($contact['email'],$contact['email_home']) as $email)
3962
+				{
3442 3963
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3443 3964
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3444 3965
 					$rfcAddr = Mail::parseAddressList($email);
@@ -3452,10 +3973,22 @@  discard block
 block discarded – undo
3452 3973
 					if (method_exists($contacts_obj,'search'))
3453 3974
 					{
3454 3975
 						$contact['n_fn']='';
3455
-						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3456
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3457
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3458
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3976
+						if (!empty($contact['n_prefix']))
3977
+						{
3978
+							$contact['n_fn'] = $contact['n_prefix'];
3979
+						}
3980
+						if (!empty($contact['n_given']))
3981
+						{
3982
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3983
+						}
3984
+						if (!empty($contact['n_family']))
3985
+						{
3986
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3987
+						}
3988
+						if (!empty($contact['org_name']))
3989
+						{
3990
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3991
+						}
3459 3992
 						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3460 3993
 					}
3461 3994
 					else
@@ -3465,7 +3998,8 @@  discard block
 block discarded – undo
3465 3998
 					$args = explode('@', trim($email));
3466 3999
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3467 4000
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3468
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
4001
+					if(!empty($email) && in_array($completeMailString ,$results) === false)
4002
+					{
3469 4003
 						$results[] = array(
3470 4004
 							'id'=>$completeMailString,
3471 4005
 							'label' => $completeMailString,
@@ -3484,7 +4018,10 @@  discard block
 block discarded – undo
3484 4018
 		foreach($groups as $g_id => $name)
3485 4019
 		{
3486 4020
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3487
-			if(!$group['account_email']) continue;
4021
+			if(!$group['account_email'])
4022
+			{
4023
+				continue;
4024
+			}
3488 4025
 			$args = explode('@', trim($group['account_email']));
3489 4026
 			$args[] = $name;
3490 4027
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
Please login to merge, or discard this patch.