Completed
Push — 16.1 ( b39e15...d98aac )
by Klaus
18:52
created
mail/inc/class.mail_compose.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1960,7 +1960,7 @@
 block discarded – undo
1960 1960
 	/**
1961 1961
 	 * Gather the replyData and save it with the session, to be used then
1962 1962
 	 *
1963
-	 * @param $_mode can be:
1963
+	 * @param string $_mode can be:
1964 1964
 	 * 		single: for a reply to one address
1965 1965
 	 * 		all: for a reply to all
1966 1966
 	 * 		forward: inlineforwarding of a message with its attachments
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2126,11 +2126,11 @@  discard block
 block discarded – undo
2126 2126
 		} else {
2127 2127
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2128 2128
 			// 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)
2129
-            $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2130
-                @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2129
+			$this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2130
+				@htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2131 2131
 				$toAddress.$ccAddress.
2132 2132
 				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
2133
-                '-------------------------------------------------'."\r\n \r\n ";
2133
+				'-------------------------------------------------'."\r\n \r\n ";
2134 2134
 			$this->sessionData['mimeType']	= 'plain';
2135 2135
 
2136 2136
 			for($i=0; $i<count($bodyParts); $i++) {
@@ -2968,7 +2968,7 @@  discard block
 block discarded – undo
2968 2968
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
2969 2969
 		//error_log(__METHOD__.__LINE__.array2string($folder));
2970 2970
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
2971
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
2971
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
2972 2972
 			$mail_bo = $this->mail_bo;
2973 2973
 			$mail_bo->openConnection();
2974 2974
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
Please login to merge, or discard this patch.
Braces   +803 added lines, -269 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
 			}
@@ -262,7 +276,10 @@  discard block
 block discarded – undo
262 276
 	 */
263 277
 	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
264 278
 	{
265
-		if ($msg) Framework::message($msg);
279
+		if ($msg)
280
+		{
281
+			Framework::message($msg);
282
+		}
266 283
 
267 284
 		if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
268 285
 		{
@@ -283,8 +300,14 @@  discard block
 block discarded – undo
283 300
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
284 301
 		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
285 302
 		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
286
-		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
287
-		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
303
+		if (isset($_GET['reply_id']))
304
+		{
305
+			$replyID = $_GET['reply_id'];
306
+		}
307
+		if (!$replyID && isset($_GET['id']))
308
+		{
309
+			$replyID = $_GET['id'];
310
+		}
288 311
 
289 312
 		// Process different places we can use as a start for composing an email
290 313
 		$actionToProcess = 'compose';
@@ -351,7 +374,10 @@  discard block
 block discarded – undo
351 374
 			$suppressSigOnTop = true;
352 375
 			foreach ($_content['uploadForCompose'] as $i => &$upload)
353 376
 			{
354
-				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
377
+				if (!isset($upload['file']))
378
+				{
379
+					$upload['file'] = $upload['tmp_name'];
380
+				}
355 381
 				try
356 382
 				{
357 383
 					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
@@ -385,9 +411,15 @@  discard block
 block discarded – undo
385 411
 				$remove=false;
386 412
 				foreach(array_keys($toDelete) as $k)
387 413
 				{
388
-					if ($att['tmp_name']==$k) $remove=true;
414
+					if ($att['tmp_name']==$k)
415
+					{
416
+						$remove=true;
417
+					}
418
+				}
419
+				if (!$remove)
420
+				{
421
+					$_content['attachments'][] = $att;
389 422
 				}
390
-				if (!$remove) $_content['attachments'][] = $att;
391 423
 			}
392 424
 		}
393 425
 		// someone clicked something like send, or saveAsDraft
@@ -402,8 +434,7 @@  discard block
 block discarded – undo
402 434
 		//error_log(__METHOD__.__LINE__.array2string($_content));
403 435
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
404 436
 			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
405
-		)
406
-		{
437
+		) {
407 438
 			$this->changeProfile($_content['serverID']);
408 439
 			$composeProfile = $this->mail_bo->profileID;
409 440
 		}
@@ -483,7 +514,10 @@  discard block
 block discarded – undo
483 514
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
484 515
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
485 516
 							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
486
-							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
517
+							if (!empty($fhA['folder']))
518
+							{
519
+								$workingFolder = $fhA['folder'];
520
+							}
487 521
 						}
488 522
 					}
489 523
 					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
@@ -534,7 +568,10 @@  discard block
 block discarded – undo
534 568
 			}
535 569
 		}
536 570
 
537
-		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
571
+		if ($activeProfile != $composeProfile)
572
+		{
573
+			$this->changeProfile($activeProfile);
574
+		}
538 575
 		$insertSigOnTop = false;
539 576
 		$content = (is_array($_content)?$_content:array());
540 577
 		if ($_contentHasMimeType)
@@ -563,7 +600,10 @@  discard block
 block discarded – undo
563 600
 				{
564 601
 					foreach ($contentArr as $k =>&$elem)
565 602
 					{
566
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
603
+						if (stripos($elem,'<pre>')!==false)
604
+						{
605
+							$elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
606
+						}
567 607
 					}
568 608
 					$content['mail_htmltext'] = implode('',$contentArr);
569 609
 				}
@@ -600,8 +640,7 @@  discard block
 block discarded – undo
600 640
 		if ( !empty($content['body']) &&
601 641
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
602 642
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
603
-		)
604
-		{
643
+		) {
605 644
 			$buttonClicked = true;
606 645
 			$suppressSigOnTop = true;
607 646
 			if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount'])
@@ -617,7 +656,10 @@  discard block
 block discarded – undo
617 656
 				else
618 657
 				{
619 658
 					$newSig = $this->mail_bo->getDefaultIdentity();
620
-					if ($newSig === false) $newSig = -2;
659
+					if ($newSig === false)
660
+					{
661
+						$newSig = -2;
662
+					}
621 663
 				}
622 664
 			}
623 665
 			$_oldSig = $composeCache['mailidentity'];
@@ -625,7 +667,10 @@  discard block
 block discarded – undo
625 667
 			$_currentMode = $_content['mimeType'];
626 668
 			if ($_oldSig != $_signatureid)
627 669
 			{
628
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
670
+				if($this->_debug)
671
+				{
672
+					error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
673
+				}
629 674
 				// prepare signatures, the selected sig may be used on top of the body
630 675
 				try
631 676
 				{
@@ -655,7 +700,10 @@  discard block
 block discarded – undo
655 700
 				{
656 701
 					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
657 702
 					$sigText = $this->convertHTMLToText($sigText,true,true);
658
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
703
+					if($this->_debug)
704
+					{
705
+						error_log(__METHOD__." Old signature:".$oldSigText);
706
+					}
659 707
 				}
660 708
 
661 709
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -672,7 +720,11 @@  discard block
 block discarded – undo
672 720
 				{
673 721
 					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
674 722
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
675
-					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
723
+					if (stripos($content['body'],'style')!==false)
724
+					{
725
+						Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true);
726
+					}
727
+					// clean out empty or pagewide style definitions / left over tags
676 728
 				}
677 729
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
678 730
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -717,8 +769,14 @@  discard block
 block discarded – undo
717 769
 
718 770
 				if ($found === false)
719 771
 				{
720
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
721
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
772
+					if($this->_debug)
773
+					{
774
+						error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
775
+					}
776
+					if($this->_debug)
777
+					{
778
+						error_log(__METHOD__." Compare content:".$content['body']);
779
+					}
722 780
 				}
723 781
 				else
724 782
 				{
@@ -733,7 +791,10 @@  discard block
 block discarded – undo
733 791
 		}
734 792
 
735 793
 		// do not double insert a signature on a server roundtrip
736
-		if ($buttonClicked) $suppressSigOnTop = true;
794
+		if ($buttonClicked)
795
+		{
796
+			$suppressSigOnTop = true;
797
+		}
737 798
 		if ($isFirstLoad)
738 799
 		{
739 800
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
@@ -772,7 +833,8 @@  discard block
 block discarded – undo
772 833
 							}
773 834
 						}
774 835
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
775
-						foreach(array('subject','body','mimetype') as $name) {
836
+						foreach(array('subject','body','mimetype') as $name)
837
+						{
776 838
 							$sName = $name;
777 839
 							if ($name=='mimetype'&&$res[$name])
778 840
 							{
@@ -781,7 +843,10 @@  discard block
 block discarded – undo
781 843
 							}
782 844
 							else
783 845
 							{
784
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
846
+								if ($res[$name])
847
+								{
848
+									$content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
849
+								}
785 850
 							}
786 851
 						}
787 852
 					}
@@ -792,7 +857,8 @@  discard block
 block discarded – undo
792 857
 			{
793 858
 				$alreadyProcessed=array();
794 859
 				//_debug_array($_REQUEST);
795
-				if ($_REQUEST['preset']['mailto']) {
860
+				if ($_REQUEST['preset']['mailto'])
861
+				{
796 862
 					// handle mailto strings such as
797 863
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
798 864
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
@@ -800,10 +866,12 @@  discard block
 block discarded – undo
800 866
 					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
801 867
 					// check if there is more than the to address
802 868
 					$mailtoArray = explode('?',$tmp_send_to,2);
803
-					if ($mailtoArray[1]) {
869
+					if ($mailtoArray[1])
870
+					{
804 871
 						// check if there are more than one requests
805 872
 						$addRequests = explode('&',$mailtoArray[1]);
806
-						foreach ($addRequests as $key => $reqval) {
873
+						foreach ($addRequests as $key => $reqval)
874
+						{
807 875
 							// the additional requests should have a =, to separate key from value.
808 876
 							$keyValuePair = explode('=',$reqval,2);
809 877
 							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
@@ -812,17 +880,24 @@  discard block
 block discarded – undo
812 880
 					$content['to']=$mailtoArray[0];
813 881
 					$alreadyProcessed['to']='to';
814 882
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
815
-					foreach(array('cc','bcc','subject','body') as $name) {
883
+					foreach(array('cc','bcc','subject','body') as $name)
884
+					{
816 885
 						$alreadyProcessed[$name]=$name;
817
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
886
+						if ($_REQUEST[$name])
887
+						{
888
+							$content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
889
+						}
818 890
 					}
819 891
 				}
820 892
 
821
-				if ($_REQUEST['preset']['mailtocontactbyid']) {
822
-					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
893
+				if ($_REQUEST['preset']['mailtocontactbyid'])
894
+				{
895
+					if ($GLOBALS['egw_info']['user']['apps']['addressbook'])
896
+					{
823 897
 						$contacts_obj = new Api\Contacts();
824 898
 						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
825
-						if (method_exists($contacts_obj,'search')) {
899
+						if (method_exists($contacts_obj,'search'))
900
+						{
826 901
 
827 902
 							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
828 903
 							foreach ((array)$addressArray as $id => $addressID)
@@ -837,7 +912,10 @@  discard block
 block discarded – undo
837 912
 							{
838 913
 								$_searchCond = array('contact_id'=>$addressArray);
839 914
 								//error_log(__METHOD__.__LINE__.$_searchString);
840
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
915
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
916
+								{
917
+									$showAccounts=false;
918
+								}
841 919
 								$filter = ($showAccounts?array():array('account_id' => null));
842 920
 								$filter['cols_to_search']=array('n_fn','email','email_home');
843 921
 								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
@@ -863,21 +941,28 @@  discard block
 block discarded – undo
863 941
 									unset($accounts);
864 942
 								}
865 943
 							}
866
-							if(is_array($contacts)) {
944
+							if(is_array($contacts))
945
+							{
867 946
 								$mailtoArray = array();
868 947
 								$primary = $addressbookprefs['distributionListPreferredMail'];
869
-								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
948
+								if ($primary != 'email' && $primary != 'email_home')
949
+								{
950
+									$primary = 'email';
951
+								}
870 952
 								$secondary = ($primary == 'email'?'email_home':'email');
871 953
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
872
-								foreach($contacts as $contact) {
954
+								foreach($contacts as $contact)
955
+								{
873 956
 									$innerCounter=0;
874
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
957
+									foreach(array($contact[$primary],$contact[$secondary]) as $email)
958
+									{
875 959
 										// use pref distributionListPreferredMail for the primary address
876 960
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
877 961
 										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
878 962
 										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
879 963
 										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
880
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
964
+										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false)
965
+										{
881 966
 											$i++;
882 967
 											$innerCounter++;
883 968
 											$mailtoArray[$i] = $completeMailString;
@@ -969,7 +1054,10 @@  discard block
 block discarded – undo
969 1054
 							}
970 1055
 						}
971 1056
 					}
972
-					if(!empty($remember)) $content = array_merge($content,$remember);
1057
+					if(!empty($remember))
1058
+					{
1059
+						$content = array_merge($content,$remember);
1060
+					}
973 1061
 				}
974 1062
 				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
975 1063
 				{
@@ -979,9 +1067,15 @@  discard block
 block discarded – undo
979 1067
 						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
980 1068
 					}
981 1069
 					//skip if already processed by "preset Routines"
982
-					if ($alreadyProcessed[$name]) continue;
1070
+					if ($alreadyProcessed[$name])
1071
+					{
1072
+						continue;
1073
+					}
983 1074
 					//error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]);
984
-					if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name];
1075
+					if ($_REQUEST['preset'][$name])
1076
+					{
1077
+						$content[$name] = $_REQUEST['preset'][$name];
1078
+					}
985 1079
 				}
986 1080
 			}
987 1081
 			// is the to address set already?
@@ -989,7 +1083,10 @@  discard block
 block discarded – undo
989 1083
 			{
990 1084
 				$content['to'] = base64_decode($_REQUEST['send_to']);
991 1085
 				// first check if there is a questionmark or ampersand
992
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1086
+				if (strpos($content['to'],'?')!== false)
1087
+				{
1088
+					list($content['to'],$rest) = explode('?',$content['to'],2);
1089
+				}
993 1090
 				$content['to'] = html_entity_decode($content['to']);
994 1091
 				if (($at_pos = strpos($content['to'],'@')) !== false)
995 1092
 				{
@@ -1002,9 +1099,15 @@  discard block
 block discarded – undo
1002 1099
 						$content['to'] = $email;
1003 1100
 					}
1004 1101
 				}
1005
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1102
+				if (strpos($content['to'],'%40')!== false)
1103
+				{
1104
+					$content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1105
+				}
1006 1106
 				$rarr = array(Api\Html::purify($rest));
1007
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1107
+				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false)
1108
+				{
1109
+					$rarr = explode('&',$rest);
1110
+				}
1008 1111
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1009 1112
 				$karr = array();
1010 1113
 				foreach ($rarr as &$rval)
@@ -1020,9 +1123,15 @@  discard block
 block discarded – undo
1020 1123
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1021 1124
 				foreach(array('cc','bcc','subject','body') as $name)
1022 1125
 				{
1023
-					if ($karr[$name]) $content[$name] = $karr[$name];
1126
+					if ($karr[$name])
1127
+					{
1128
+						$content[$name] = $karr[$name];
1129
+					}
1130
+				}
1131
+				if (!empty($_REQUEST['subject']))
1132
+				{
1133
+					$content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1024 1134
 				}
1025
-				if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1026 1135
 			}
1027 1136
 		}
1028 1137
 		//error_log(__METHOD__.__LINE__.array2string($content));
@@ -1040,7 +1149,10 @@  discard block
 block discarded – undo
1040 1149
 				$_content['mimeType'] = $content['mimeType']  = 'html';
1041 1150
 				$content['body'] = "<pre>".$content['body']."</pre>";
1042 1151
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1043
-				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);
1152
+				if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1153
+				{
1154
+					$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1155
+				}
1044 1156
 			}
1045 1157
 		}
1046 1158
 		else
@@ -1060,7 +1172,10 @@  discard block
 block discarded – undo
1060 1172
 					$_content['mimeType'] = $content['mimeType']  = 'html';
1061 1173
 					$content['body'] = "<pre>".$content['body']."</pre>";
1062 1174
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1063
-					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);
1175
+					if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1176
+					{
1177
+						$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1178
+					}
1064 1179
 				}
1065 1180
 			}
1066 1181
 		}
@@ -1098,24 +1213,33 @@  discard block
 block discarded – undo
1098 1213
 			$disableRuler = true;
1099 1214
 		}
1100 1215
 		$font_span = $font_part = '';
1101
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1216
+		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/)
1217
+		{
1102 1218
 			// User preferences for style
1103 1219
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1104 1220
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1105 1221
 			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1106 1222
 			$font_span = $font_part.'&#8203;</span>';
1107
-			if (empty($font) && empty($font_size)) $font_span = '';
1223
+			if (empty($font) && empty($font_size))
1224
+			{
1225
+				$font_span = '';
1226
+			}
1108 1227
 		}
1109 1228
 		// 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
1110
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1229
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false)
1230
+		{
1231
+			$font_span = '';
1232
+		}
1111 1233
 		//remove possible html header stuff
1112
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1234
+		if (stripos($content['body'],'<html><head></head><body>')!==false)
1235
+		{
1236
+			$content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1237
+		}
1113 1238
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1114 1239
 		$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');
1115 1240
 		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1116 1241
 			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1117
-		)
1118
-		{
1242
+		) {
1119 1243
 			// ON tOP OR BELOW? pREF CAN TELL
1120 1244
 			/*
1121 1245
 				Signature behavior preference changed. New default, if not set -> 0
@@ -1130,14 +1254,23 @@  discard block
 block discarded – undo
1130 1254
 				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1131 1255
 				foreach($blockElements as $e)
1132 1256
 				{
1133
-					if ($sigTextStartsWithBlockElement) break;
1134
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1257
+					if ($sigTextStartsWithBlockElement)
1258
+					{
1259
+						break;
1260
+					}
1261
+					if (stripos(trim($sigText),'<'.$e)===0)
1262
+					{
1263
+						$sigTextStartsWithBlockElement = true;
1264
+					}
1135 1265
 				}
1136 1266
 			}
1137
-			if($content['mimeType'] == 'html') {
1267
+			if($content['mimeType'] == 'html')
1268
+			{
1138 1269
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1139 1270
 				$inbetween = '';
1140
-			} else {
1271
+			}
1272
+			else
1273
+			{
1141 1274
 				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1142 1275
 				$inbetween = "\r\n";
1143 1276
 			}
@@ -1181,16 +1314,24 @@  discard block
 block discarded – undo
1181 1314
 		//$content['bcc'] = array('[email protected]','[email protected]');
1182 1315
 		// address stuff like from, to, cc, replyto
1183 1316
 		$destinationRows = 0;
1184
-		foreach(self::$destinations as $destination) {
1317
+		foreach(self::$destinations as $destination)
1318
+		{
1185 1319
 			if (!is_array($content[$destination]))
1186 1320
 			{
1187
-				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
1321
+				if (!empty($content[$destination]))
1322
+				{
1323
+					$content[$destination] = (array)$content[$destination];
1324
+				}
1188 1325
 			}
1189 1326
 			$addr_content = $content[strtolower($destination)];
1190 1327
 			// we clear the given address array and rebuild it
1191 1328
 			unset($content[strtolower($destination)]);
1192
-			foreach((array)$addr_content as $key => $value) {
1193
-				if ($value=="NIL@NIL") continue;
1329
+			foreach((array)$addr_content as $key => $value)
1330
+			{
1331
+				if ($value=="NIL@NIL")
1332
+				{
1333
+					continue;
1334
+				}
1194 1335
 				if ($destination=='replyto' && str_replace('"','',$value) ==
1195 1336
 					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1196 1337
 				{
@@ -1200,8 +1341,12 @@  discard block
 block discarded – undo
1200 1341
 				}
1201 1342
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1202 1343
 				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1203
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1204
-					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1344
+				foreach(Mail::parseAddressList($value) as $addressObject)
1345
+				{
1346
+					if ($addressObject->host == '.SYNTAX-ERROR.')
1347
+					{
1348
+						continue;
1349
+					}
1205 1350
 					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1206 1351
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1207 1352
 					$content[strtolower($destination)][]=$address;
@@ -1212,11 +1357,20 @@  discard block
 block discarded – undo
1212 1357
 		if ($_content)
1213 1358
 		{
1214 1359
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1215
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1360
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content))
1361
+			{
1362
+				unset($_content['mailidentity']);
1363
+			}
1216 1364
 			$content = array_merge($content,$_content);
1217 1365
 
1218
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1219
-			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1366
+			if (!empty($content['folder']))
1367
+			{
1368
+				$sel_options['folder']=$this->ajax_searchFolder(0,true);
1369
+			}
1370
+			if (empty($content['mailaccount']))
1371
+			{
1372
+				$content['mailaccount'] = $this->mail_bo->profileID;
1373
+			}
1220 1374
 		}
1221 1375
 		else
1222 1376
 		{
@@ -1259,11 +1413,17 @@  discard block
 block discarded – undo
1259 1413
 		//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
1260 1414
 		$preserv['is_html'] = $content['is_html'];
1261 1415
 		$preserv['is_plain'] = $content['is_plain'];
1262
-		if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
1416
+		if (isset($content['mimeType']))
1417
+		{
1418
+			$preserv['mimeType'] = $content['mimeType'];
1419
+		}
1263 1420
 		$sel_options['mimeType'] = self::$mimeTypes;
1264 1421
 		$sel_options['priority'] = self::$priorities;
1265 1422
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1266
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1423
+		if (!isset($content['priority']) || empty($content['priority']))
1424
+		{
1425
+			$content['priority']=3;
1426
+		}
1267 1427
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1268 1428
 		$etpl = new Etemplate('mail.compose');
1269 1429
 
@@ -1310,9 +1470,12 @@  discard block
 block discarded – undo
1310 1470
 		$preserv['list-id'] = $content['list-id'];
1311 1471
 		$preserv['mode'] = $content['mode'];
1312 1472
 		// convert it back to checkbox expectations
1313
-		if($content['mimeType'] == 'html') {
1473
+		if($content['mimeType'] == 'html')
1474
+		{
1314 1475
 			$content['mimeType']=1;
1315
-		} else {
1476
+		}
1477
+		else
1478
+		{
1316 1479
 			$content['mimeType']=0;
1317 1480
 		}
1318 1481
 		// set the current selected mailaccount as param for folderselection
@@ -1323,7 +1486,10 @@  discard block
 block discarded – undo
1323 1486
 		// Resolve distribution list before send content to client
1324 1487
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1325 1488
 		{
1326
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1489
+			if (is_array($content[$f]))
1490
+			{
1491
+				$content[$f]= self::resolveEmailAddressList ($content[$f]);
1492
+			}
1327 1493
 		}
1328 1494
 
1329 1495
 		$content['to'] = self::resolveEmailAddressList($content['to']);
@@ -1371,7 +1537,10 @@  discard block
 block discarded – undo
1371 1537
 				case 'composefromdraft':
1372 1538
 				case 'composeasnew':
1373 1539
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1374
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1540
+					if ($from =='composefromdraft')
1541
+					{
1542
+						$content['mode'] = 'composefromdraft';
1543
+					}
1375 1544
 					$content['processedmail_id'] = $mail_id;
1376 1545
 
1377 1546
 					$_focusElement = 'body';
@@ -1419,7 +1588,10 @@  discard block
 block discarded – undo
1419 1588
 			$document_merge = new $merge_class();
1420 1589
 			$this->mail_bo->openConnection();
1421 1590
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1422
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1591
+			if (!is_array($merge_ids))
1592
+			{
1593
+				$merge_ids = explode(',',$merge_ids);
1594
+			}
1423 1595
 			try
1424 1596
 			{
1425 1597
 				$merged_mail_id = '';
@@ -1450,7 +1622,10 @@  discard block
 block discarded – undo
1450 1622
 				{
1451 1623
 					$success = implode(', ',$results['success']);
1452 1624
 					$fail = implode(', ', $results['failed']);
1453
-					if($success) Framework::message($success, 'success');
1625
+					if($success)
1626
+					{
1627
+						Framework::message($success, 'success');
1628
+					}
1454 1629
 					Framework::window_close($fail);
1455 1630
 				}
1456 1631
 			}
@@ -1482,17 +1657,25 @@  discard block
 block discarded – undo
1482 1657
 	{
1483 1658
 		$stripalltags = true;
1484 1659
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1485
-		if (!$sourceishtml) $stripalltags=false;
1660
+		if (!$sourceishtml)
1661
+		{
1662
+			$stripalltags=false;
1663
+		}
1486 1664
 		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1487 1665
 	}
1488 1666
 
1489 1667
 	function generateRFC822Address($_addressObject)
1490 1668
 	{
1491
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1669
+		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host)
1670
+		{
1492 1671
 			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1493
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1672
+		}
1673
+		elseif($_addressObject->mailbox && $_addressObject->host)
1674
+		{
1494 1675
 			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1495
-		} else {
1676
+		}
1677
+		else
1678
+		{
1496 1679
 			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1497 1680
 		}
1498 1681
 	}
@@ -1526,16 +1709,28 @@  discard block
 block discarded – undo
1526 1709
 		//if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC'];
1527 1710
 
1528 1711
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1529
-		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1530
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1712
+		if (!empty($addHeadInfo['X-MAILFOLDER']))
1713
+		{
1714
+			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val )
1715
+			{
1531 1716
 				$fval=$val;
1532 1717
 				$icServerID = $mail_bo->icServer->ImapServerId;
1533
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1534
-				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1535
-				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1718
+				if (stripos($val,'::')!==false)
1719
+				{
1720
+					list($icServerID,$fval) = explode('::',$val,2);
1721
+				}
1722
+				if ($icServerID != $mail_bo->icServer->ImapServerId)
1723
+				{
1724
+					continue;
1725
+				}
1726
+				if ($mail_bo->folderExists($fval))
1727
+				{
1728
+					$this->sessionData['folder'][] = $val;
1729
+				}
1536 1730
 			}
1537 1731
 		}
1538
-		if (!empty($addHeadInfo['X-MAILIDENTITY'])) {
1732
+		if (!empty($addHeadInfo['X-MAILIDENTITY']))
1733
+		{
1539 1734
 			// with the new system it would be the identity
1540 1735
 			try
1541 1736
 			{
@@ -1551,7 +1746,8 @@  discard block
 block discarded – undo
1551 1746
 			$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
1552 1747
 		}
1553 1748
 		*/
1554
-		if (!empty($addHeadInfo['X-MAILACCOUNT'])) {
1749
+		if (!empty($addHeadInfo['X-MAILACCOUNT']))
1750
+		{
1555 1751
 			// with the new system it would the identity is the account id
1556 1752
 			try
1557 1753
 			{
@@ -1566,27 +1762,38 @@  discard block
 block discarded – undo
1566 1762
 			}
1567 1763
 		}
1568 1764
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1569
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1765
+		if ($mail_bo->isDraftFolder($_folder))
1766
+		{
1767
+			$this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);
1768
+		}
1769
+		//array('uid'=>$_uid,'folder'=>$_folder);
1570 1770
 		$this->sessionData['uid'] = $_uid;
1571 1771
 		$this->sessionData['messageFolder'] = $_folder;
1572 1772
 		$this->sessionData['isDraft'] = true;
1573 1773
 		$foundAddresses = array();
1574
-		foreach((array)$headers['CC'] as $val) {
1774
+		foreach((array)$headers['CC'] as $val)
1775
+		{
1575 1776
 			$rfcAddr=Mail::parseAddressList($val);
1576 1777
 			$_rfcAddr = $rfcAddr[0];
1577
-			if (!$_rfcAddr->valid) continue;
1578
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1778
+			if (!$_rfcAddr->valid)
1779
+			{
1780
+				continue;
1781
+			}
1782
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1783
+			{
1579 1784
 				continue;
1580 1785
 			}
1581 1786
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1582
-			if(!$foundAddresses[$keyemail]) {
1787
+			if(!$foundAddresses[$keyemail])
1788
+			{
1583 1789
 				$address = $this->mail_bo->decode_header($val,true);
1584 1790
 				$this->sessionData['cc'][] = $val;
1585 1791
 				$foundAddresses[$keyemail] = true;
1586 1792
 			}
1587 1793
 		}
1588 1794
 
1589
-		foreach((array)$headers['TO'] as $val) {
1795
+		foreach((array)$headers['TO'] as $val)
1796
+		{
1590 1797
 			if(!is_array($val))
1591 1798
 			{
1592 1799
 				$this->sessionData['to'][] = $val;
@@ -1594,42 +1801,59 @@  discard block
 block discarded – undo
1594 1801
 			}
1595 1802
 			$rfcAddr=Mail::parseAddressList($val);
1596 1803
 			$_rfcAddr = $rfcAddr[0];
1597
-			if (!$_rfcAddr->valid) continue;
1598
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1804
+			if (!$_rfcAddr->valid)
1805
+			{
1806
+				continue;
1807
+			}
1808
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1809
+			{
1599 1810
 				continue;
1600 1811
 			}
1601 1812
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1602
-			if(!$foundAddresses[$keyemail]) {
1813
+			if(!$foundAddresses[$keyemail])
1814
+			{
1603 1815
 				$address = $this->mail_bo->decode_header($val,true);
1604 1816
 				$this->sessionData['to'][] = $val;
1605 1817
 				$foundAddresses[$keyemail] = true;
1606 1818
 			}
1607 1819
 		}
1608 1820
 
1609
-		foreach((array)$headers['REPLY-TO'] as $val) {
1821
+		foreach((array)$headers['REPLY-TO'] as $val)
1822
+		{
1610 1823
 			$rfcAddr=Mail::parseAddressList($val);
1611 1824
 			$_rfcAddr = $rfcAddr[0];
1612
-			if (!$_rfcAddr->valid) continue;
1613
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1825
+			if (!$_rfcAddr->valid)
1826
+			{
1827
+				continue;
1828
+			}
1829
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1830
+			{
1614 1831
 				continue;
1615 1832
 			}
1616 1833
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1617
-			if(!$foundAddresses[$keyemail]) {
1834
+			if(!$foundAddresses[$keyemail])
1835
+			{
1618 1836
 				$address = $this->mail_bo->decode_header($val,true);
1619 1837
 				$this->sessionData['replyto'][] = $val;
1620 1838
 				$foundAddresses[$keyemail] = true;
1621 1839
 			}
1622 1840
 		}
1623 1841
 
1624
-		foreach((array)$headers['BCC'] as $val) {
1842
+		foreach((array)$headers['BCC'] as $val)
1843
+		{
1625 1844
 			$rfcAddr=Mail::parseAddressList($val);
1626 1845
 			$_rfcAddr = $rfcAddr[0];
1627
-			if (!$_rfcAddr->valid) continue;
1628
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1846
+			if (!$_rfcAddr->valid)
1847
+			{
1848
+				continue;
1849
+			}
1850
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1851
+			{
1629 1852
 				continue;
1630 1853
 			}
1631 1854
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1632
-			if(!$foundAddresses[$keyemail]) {
1855
+			if(!$foundAddresses[$keyemail])
1856
+			{
1633 1857
 				$address = $this->mail_bo->decode_header($val,true);
1634 1858
 				$this->sessionData['bcc'][] = $val;
1635 1859
 				$foundAddresses[$keyemail] = true;
@@ -1643,32 +1867,46 @@  discard block
 block discarded – undo
1643 1867
 		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1644 1868
 		//_debug_array($bodyParts);
1645 1869
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1646
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1870
+		if($bodyParts['0']['mimeType'] == 'text/html')
1871
+		{
1647 1872
 			$this->sessionData['mimeType'] 	= 'html';
1648 1873
 
1649
-			for($i=0; $i<count($bodyParts); $i++) {
1650
-				if($i>0) {
1874
+			for($i=0; $i<count($bodyParts); $i++)
1875
+			{
1876
+				if($i>0)
1877
+				{
1651 1878
 					$this->sessionData['body'] .= '<hr>';
1652 1879
 				}
1653
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1880
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
1881
+				{
1654 1882
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1655 1883
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1656 1884
 				}
1657
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1885
+				if ($bodyParts[$i]['charSet']===false)
1886
+				{
1887
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1888
+				}
1658 1889
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1659 1890
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1660 1891
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1661 1892
 			}
1662 1893
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1663 1894
 
1664
-		} else {
1895
+		}
1896
+		else
1897
+		{
1665 1898
 			$this->sessionData['mimeType']	= 'plain';
1666 1899
 
1667
-			for($i=0; $i<count($bodyParts); $i++) {
1668
-				if($i>0) {
1900
+			for($i=0; $i<count($bodyParts); $i++)
1901
+			{
1902
+				if($i>0)
1903
+				{
1669 1904
 					$this->sessionData['body'] .= "<hr>";
1670 1905
 				}
1671
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1906
+				if ($bodyParts[$i]['charSet']===false)
1907
+				{
1908
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1909
+				}
1672 1910
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1673 1911
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1674 1912
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
@@ -1676,8 +1914,10 @@  discard block
 block discarded – undo
1676 1914
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1677 1915
 		}
1678 1916
 
1679
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1680
-			foreach($attachments as $attachment) {
1917
+		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1918
+		{
1919
+			foreach($attachments as $attachment)
1920
+			{
1681 1921
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1682 1922
 				$cid = $attachment['cid'];
1683 1923
 				$match=null;
@@ -1699,7 +1939,8 @@  discard block
 block discarded – undo
1699 1939
 
1700 1940
 	function getErrorInfo()
1701 1941
 	{
1702
-		if(isset($this->errorInfo)) {
1942
+		if(isset($this->errorInfo))
1943
+		{
1703 1944
 			$errorInfo = $this->errorInfo;
1704 1945
 			unset($this->errorInfo);
1705 1946
 			return $errorInfo;
@@ -1714,7 +1955,8 @@  discard block
 block discarded – undo
1714 1955
 			$modebuff = $this->mailPreferences['message_forwarding'];
1715 1956
 			$this->mailPreferences['message_forwarding'] = $_mode;
1716 1957
 		}
1717
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1958
+		if  ($this->mailPreferences['message_forwarding'] == 'inline')
1959
+		{
1718 1960
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1719 1961
 		}
1720 1962
 		$mail_bo    = $this->mail_bo;
@@ -1731,12 +1973,16 @@  discard block
 block discarded – undo
1731 1973
 		//$this->sessionData['sourceFolder']=$_folder;
1732 1974
 		//$this->sessionData['forwardFlag']='forwarded';
1733 1975
 		//$this->sessionData['forwardedUID']=$_uid;
1734
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1976
+		if  ($this->mailPreferences['message_forwarding'] == 'asmail')
1977
+		{
1735 1978
 			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1736 1979
 			if($headers['SIZE'])
1737
-				$size				= $headers['SIZE'];
1738
-			else
1739
-				$size				= lang('unknown');
1980
+			{
1981
+							$size				= $headers['SIZE'];
1982
+			}
1983
+			else {
1984
+							$size				= lang('unknown');
1985
+			}
1740 1986
 
1741 1987
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1742 1988
 				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
@@ -1747,9 +1993,11 @@  discard block
 block discarded – undo
1747 1993
 			unset($this->sessionData['in-reply-to']);
1748 1994
 			unset($this->sessionData['to']);
1749 1995
 			unset($this->sessionData['cc']);
1750
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1996
+			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1997
+			{
1751 1998
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1752
-				foreach($attachments as $attachment) {
1999
+				foreach($attachments as $attachment)
2000
+				{
1753 2001
 					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])))
1754 2002
 					{
1755 2003
 						$this->addMessageAttachment($_uid, $attachment['partID'],
@@ -1805,7 +2053,10 @@  discard block
 block discarded – undo
1805 2053
 			{
1806 2054
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1807 2055
 					strtolower($_formData['type'])== strtolower($attach['type']) &&
1808
-					stripos($_formData['file'],'vfs://') !== false) return;
2056
+					stripos($_formData['file'],'vfs://') !== false)
2057
+				{
2058
+					return;
2059
+				}
1809 2060
 			}
1810 2061
 		}
1811 2062
 		if ($attachfailed === false)
@@ -1817,7 +2068,10 @@  discard block
 block discarded – undo
1817 2068
 				'tmp_name'	=> $tmpFileName,
1818 2069
 				'size'	=> $_formData['size']
1819 2070
 			);
1820
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
2071
+			if (!is_array($_content['attachments']))
2072
+			{
2073
+				$_content['attachments']=array();
2074
+			}
1821 2075
 			$_content['attachments'][] = $buffer;
1822 2076
 			unset($buffer);
1823 2077
 		}
@@ -1847,7 +2101,10 @@  discard block
 block discarded – undo
1847 2101
 		{
1848 2102
 			foreach($request->preserv['attachments'] as $attachment)
1849 2103
 			{
1850
-				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2104
+				if ($_GET['tmpname'] === $attachment['tmp_name'])
2105
+				{
2106
+					break;
2107
+				}
1851 2108
 			}
1852 2109
 		}
1853 2110
 		if (!$request || $_GET['tmpname'] !== $attachment['tmp_name'])
@@ -1881,10 +2138,20 @@  discard block
 block discarded – undo
1881 2138
 				$sfxMimeType = $attachment['type'];
1882 2139
 				$buff = explode('.',$attachment['tmp_name']);
1883 2140
 				$suffix = '';
1884
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1885
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2141
+				if (is_array($buff))
2142
+				{
2143
+					$suffix = array_pop($buff);
2144
+				}
2145
+				// take the last extension to check with ext2mime
2146
+				if (!empty($suffix))
2147
+				{
2148
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2149
+				}
1886 2150
 				$attachment['type'] = $sfxMimeType;
1887
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2151
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2152
+				{
2153
+					$attachment['type'] = strtoupper($sfxMimeType);
2154
+				}
1888 2155
 			}
1889 2156
 			//error_log(__METHOD__.print_r($attachment,true));
1890 2157
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -1893,7 +2160,10 @@  discard block
 block discarded – undo
1893 2160
 				$calendar_ical = new calendar_ical();
1894 2161
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1895 2162
 				//error_log(__METHOD__.array2string($eventid));
1896
-				if (!$eventid) $eventid = -1;
2163
+				if (!$eventid)
2164
+				{
2165
+					$eventid = -1;
2166
+				}
1897 2167
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1898 2168
 				//error_log(__METHOD__.$event);
1899 2169
 				if ((int)$event > 0)
@@ -1919,7 +2189,10 @@  discard block
 block discarded – undo
1919 2189
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1920 2190
 					$contact = $addressbook_vcal->find_contact($vcard,false);
1921 2191
 				}
1922
-				if (!$contact) $contact = null;
2192
+				if (!$contact)
2193
+				{
2194
+					$contact = null;
2195
+				}
1923 2196
 				// 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))
1924 2197
 				if ($contact || count($vcard)>2)
1925 2198
 				{
@@ -1950,7 +2223,8 @@  discard block
 block discarded – undo
1950 2223
 	 * @param string haystack
1951 2224
 	 * @return boolean
1952 2225
 	 */
1953
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2226
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack)
2227
+	{
1954 2228
 		foreach (array_keys($arrayToTestAgainst) as $k)
1955 2229
 		{
1956 2230
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
@@ -1997,21 +2271,34 @@  discard block
 block discarded – undo
1997 2271
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1998 2272
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
1999 2273
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
2000
-		if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2001
-		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2274
+		if ($headers['THREAD-INDEX'])
2275
+		{
2276
+			$this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2277
+		}
2278
+		if ($headers['LIST-ID'])
2279
+		{
2280
+			$this->sessionData['list-id'] = $headers['LIST-ID'];
2281
+		}
2002 2282
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2003 2283
 		// check for Reply-To: header and use if available
2004
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2005
-			foreach($headers['REPLY-TO'] as $val) {
2006
-				if(!$foundAddresses[$val]) {
2284
+		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM']))
2285
+		{
2286
+			foreach($headers['REPLY-TO'] as $val)
2287
+			{
2288
+				if(!$foundAddresses[$val])
2289
+				{
2007 2290
 					$oldTo[] = $val;
2008 2291
 					$foundAddresses[$val] = true;
2009 2292
 				}
2010 2293
 			}
2011 2294
 			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2012
-		} else {
2013
-			foreach($headers['FROM'] as $val) {
2014
-				if(!$foundAddresses[$val]) {
2295
+		}
2296
+		else
2297
+		{
2298
+			foreach($headers['FROM'] as $val)
2299
+			{
2300
+				if(!$foundAddresses[$val])
2301
+				{
2015 2302
 					$oldTo[] = $val;
2016 2303
 					$foundAddresses[$val] = true;
2017 2304
 				}
@@ -2019,18 +2306,23 @@  discard block
 block discarded – undo
2019 2306
 			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2020 2307
 		}
2021 2308
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2022
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2309
+		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) )
2310
+		{
2023 2311
 			$this->sessionData['to'] = $oldTo;
2024 2312
 		}
2025 2313
 
2026
-		if($_mode == 'all') {
2314
+		if($_mode == 'all')
2315
+		{
2027 2316
 			// reply to any address which is cc, but not to my self
2028 2317
 			#if($headers->cc) {
2029
-				foreach($headers['CC'] as $val) {
2030
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2318
+				foreach($headers['CC'] as $val)
2319
+				{
2320
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2321
+					{
2031 2322
 						continue;
2032 2323
 					}
2033
-					if(!$foundAddresses[$val]) {
2324
+					if(!$foundAddresses[$val])
2325
+					{
2034 2326
 						$this->sessionData['cc'][] = $val;
2035 2327
 						$foundAddresses[$val] = true;
2036 2328
 					}
@@ -2039,11 +2331,14 @@  discard block
 block discarded – undo
2039 2331
 
2040 2332
 			// reply to any address which is to, but not to my self
2041 2333
 			#if($headers->to) {
2042
-				foreach($headers['TO'] as $val) {
2043
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2334
+				foreach($headers['TO'] as $val)
2335
+				{
2336
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2337
+					{
2044 2338
 						continue;
2045 2339
 					}
2046
-					if(!$foundAddresses[$val]) {
2340
+					if(!$foundAddresses[$val])
2341
+					{
2047 2342
 						$this->sessionData['to'][] = $val;
2048 2343
 						$foundAddresses[$val] = true;
2049 2344
 					}
@@ -2051,12 +2346,15 @@  discard block
 block discarded – undo
2051 2346
 			#}
2052 2347
 
2053 2348
 			#if($headers->from) {
2054
-				foreach($headers['FROM'] as $val) {
2055
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2349
+				foreach($headers['FROM'] as $val)
2350
+				{
2351
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2352
+					{
2056 2353
 						continue;
2057 2354
 					}
2058 2355
 					//error_log(__METHOD__.__LINE__.' '.$val);
2059
-					if(!$foundAddresses[$val]) {
2356
+					if(!$foundAddresses[$val])
2357
+					{
2060 2358
 						$this->sessionData['to'][] = $val;
2061 2359
 						$foundAddresses[$val] = true;
2062 2360
 					}
@@ -2065,9 +2363,12 @@  discard block
 block discarded – undo
2065 2363
 		}
2066 2364
 
2067 2365
 		// check for Re: in subject header
2068
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2366
+		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:")
2367
+		{
2069 2368
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2070
-		} else {
2369
+		}
2370
+		else
2371
+		{
2071 2372
 			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2072 2373
 		}
2073 2374
 
@@ -2081,7 +2382,8 @@  discard block
 block discarded – undo
2081 2382
 
2082 2383
 		$toAddressA = array();
2083 2384
 		$toAddress = '';
2084
-		foreach ($headers['TO'] as $mailheader) {
2385
+		foreach ($headers['TO'] as $mailheader)
2386
+		{
2085 2387
 			$toAddressA[] =  $mailheader;
2086 2388
 		}
2087 2389
 		if (count($toAddressA)>0)
@@ -2091,7 +2393,8 @@  discard block
 block discarded – undo
2091 2393
 		}
2092 2394
 		$ccAddressA = array();
2093 2395
 		$ccAddress = '';
2094
-		foreach ($headers['CC'] as $mailheader) {
2396
+		foreach ($headers['CC'] as $mailheader)
2397
+		{
2095 2398
 			$ccAddressA[] =  $mailheader;
2096 2399
 		}
2097 2400
 		if (count($ccAddressA)>0)
@@ -2099,25 +2402,35 @@  discard block
 block discarded – undo
2099 2402
 			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2100 2403
 			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2101 2404
 		}
2102
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2405
+		if($bodyParts['0']['mimeType'] == 'text/html')
2406
+		{
2103 2407
 			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2104 2408
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2105 2409
 				$toAddress.$ccAddress.
2106 2410
 				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2107 2411
 				'----------------------------------------------------------'."</div>";
2108 2412
 			$this->sessionData['mimeType'] 	= 'html';
2109
-			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2413
+			if (!empty($styles))
2414
+			{
2415
+				$this->sessionData['body'] .= $styles;
2416
+			}
2110 2417
 			$this->sessionData['body']	.= '<blockquote type="cite">';
2111 2418
 
2112
-			for($i=0; $i<count($bodyParts); $i++) {
2113
-				if($i>0) {
2419
+			for($i=0; $i<count($bodyParts); $i++)
2420
+			{
2421
+				if($i>0)
2422
+				{
2114 2423
 					$this->sessionData['body'] .= '<hr>';
2115 2424
 				}
2116
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2425
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2426
+				{
2117 2427
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2118 2428
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2119 2429
 				}
2120
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2430
+				if ($bodyParts[$i]['charSet']===false)
2431
+				{
2432
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2433
+				}
2121 2434
 
2122 2435
 				$_htmlConfig = Mail::$htmLawed_config;
2123 2436
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2129,7 +2442,9 @@  discard block
 block discarded – undo
2129 2442
 
2130 2443
 			$this->sessionData['body']	.= '</blockquote><br>';
2131 2444
 			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2132
-		} else {
2445
+		}
2446
+		else
2447
+		{
2133 2448
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2134 2449
 			// 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)
2135 2450
             $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
@@ -2139,8 +2454,10 @@  discard block
 block discarded – undo
2139 2454
                 '-------------------------------------------------'."\r\n \r\n ";
2140 2455
 			$this->sessionData['mimeType']	= 'plain';
2141 2456
 
2142
-			for($i=0; $i<count($bodyParts); $i++) {
2143
-				if($i>0) {
2457
+			for($i=0; $i<count($bodyParts); $i++)
2458
+			{
2459
+				if($i>0)
2460
+				{
2144 2461
 					$this->sessionData['body'] .= "<hr>";
2145 2462
 				}
2146 2463
 
@@ -2150,9 +2467,11 @@  discard block
 block discarded – undo
2150 2467
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2151 2468
 				$this->sessionData['body'] .= "\r\n";
2152 2469
 				// create body new, with good line breaks and indention
2153
-				foreach(explode("\n",$newBody) as $value) {
2470
+				foreach(explode("\n",$newBody) as $value)
2471
+				{
2154 2472
 					// the explode is removing the character
2155
-					if (trim($value) != '') {
2473
+					if (trim($value) != '')
2474
+					{
2156 2475
 						#if ($value != "\r") $value .= "\n";
2157 2476
 					}
2158 2477
 					$numberOfChars = strspn(trim($value), ">");
@@ -2160,9 +2479,12 @@  discard block
 block discarded – undo
2160 2479
 
2161 2480
 					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2162 2481
 
2163
-					if($bodyAppend[0] == '>') {
2482
+					if($bodyAppend[0] == '>')
2483
+					{
2164 2484
 						$bodyAppend = '>'. $bodyAppend;
2165
-					} else {
2485
+					}
2486
+					else
2487
+					{
2166 2488
 						$bodyAppend = '> '. $bodyAppend;
2167 2489
 					}
2168 2490
 
@@ -2211,9 +2533,12 @@  discard block
 block discarded – undo
2211 2533
 
2212 2534
 	static function _getHostName()
2213 2535
 	{
2214
-		if (isset($_SERVER['SERVER_NAME'])) {
2536
+		if (isset($_SERVER['SERVER_NAME']))
2537
+		{
2215 2538
 			$result = $_SERVER['SERVER_NAME'];
2216
-		} else {
2539
+		}
2540
+		else
2541
+		{
2217 2542
 			$result = 'localhost.localdomain';
2218 2543
 		}
2219 2544
 		return $result;
@@ -2250,13 +2575,21 @@  discard block
 block discarded – undo
2250 2575
 
2251 2576
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2252 2577
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2253
-		if(!empty($_formData['in-reply-to'])) {
2254
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2578
+		if(!empty($_formData['in-reply-to']))
2579
+		{
2580
+			if (stripos($_formData['in-reply-to'],'<')===false)
2581
+			{
2582
+				$_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2583
+			}
2255 2584
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(In-Reply-To', $_formData['in-reply-to'].")");
2256 2585
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2257 2586
 		}
2258
-		if(!empty($_formData['references'])) {
2259
-			if (stripos($_formData['references'],'<')===false) $_formData['references']='<'.trim($_formData['references']).'>';
2587
+		if(!empty($_formData['references']))
2588
+		{
2589
+			if (stripos($_formData['references'],'<')===false)
2590
+			{
2591
+				$_formData['references']='<'.trim($_formData['references']).'>';
2592
+			}
2260 2593
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(References', $_formData['references'].")");
2261 2594
 			$_mailObject->addHeader('References', $_formData['references']);
2262 2595
 		}
@@ -2267,16 +2600,19 @@  discard block
 block discarded – undo
2267 2600
 		//	$_mailObject->addHeader('Thread-Topic', $_formData['thread-topic']);
2268 2601
 		//}
2269 2602
 
2270
-		if(!empty($_formData['thread-index'])) {
2603
+		if(!empty($_formData['thread-index']))
2604
+		{
2271 2605
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(Tread-Index', $_formData['thread-index'].")");
2272 2606
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2273 2607
 		}
2274
-		if(!empty($_formData['list-id'])) {
2608
+		if(!empty($_formData['list-id']))
2609
+		{
2275 2610
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(List-Id', $_formData['list-id'].")");
2276 2611
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2277 2612
 		}
2278 2613
 		//error_log(__METHOD__.__LINE__.' notify to:'.$_identity['ident_email'].'->'.array2string($_formData));
2279
-		if($_formData['disposition']=='on') {
2614
+		if($_formData['disposition']=='on')
2615
+		{
2280 2616
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2281 2617
 		}
2282 2618
 		//error_log(__METHOD__.__LINE__.' Organization:'.array2string($_identity));
@@ -2287,15 +2623,22 @@  discard block
 block discarded – undo
2287 2623
 		// Expand any mailing lists
2288 2624
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2289 2625
 		{
2290
-			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2626
+			if ($field != 'replyto')
2627
+			{
2628
+				$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2629
+			}
2291 2630
 
2292
-			if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field);
2631
+			if ($_formData[$field])
2632
+			{
2633
+				$_mailObject->addAddress($_formData[$field], '', $field);
2634
+			}
2293 2635
 		}
2294 2636
 
2295 2637
 		$_mailObject->addHeader('Subject', $_formData['subject']);
2296 2638
 
2297 2639
 		// this should never happen since we come from the edit dialog
2298
-		if (Mail::detect_qp($_formData['body'])) {
2640
+		if (Mail::detect_qp($_formData['body']))
2641
+		{
2299 2642
 			//error_log("Error: bocompose::createMessage found QUOTED-PRINTABLE while Composing Message. Charset:$realCharset Message:".print_r($_formData['body'],true));
2300 2643
 			$_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']);
2301 2644
 			$_formData['body'] = quoted_printable_decode($_formData['body']);
@@ -2361,7 +2704,10 @@  discard block
 block discarded – undo
2361 2704
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true));
2362 2705
 			}
2363 2706
 			// convert URL Images to inline images - if possible
2364
-			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2707
+			if (!$_autosaving)
2708
+			{
2709
+				$inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2710
+			}
2365 2711
 			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2366 2712
 			{
2367 2713
 				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@@ -2376,10 +2722,14 @@  discard block
 block discarded – undo
2376 2722
 		{
2377 2723
 			$body = $this->convertHTMLToText($_formData['body'],false);
2378 2724
 
2379
-			if ($attachment_links) $body .= $attachment_links;
2725
+			if ($attachment_links)
2726
+			{
2727
+				$body .= $attachment_links;
2728
+			}
2380 2729
 
2381 2730
 			#$_mailObject->Body = $_formData['body'];
2382
-			if(!empty($signature)) {
2731
+			if(!empty($signature))
2732
+			{
2383 2733
 				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2384 2734
 					$this->convertHTMLToText($signature,true,true);
2385 2735
 			}
@@ -2392,11 +2742,13 @@  discard block
 block discarded – undo
2392 2742
 			$connection_opened = false;
2393 2743
 			//error_log(__METHOD__.__LINE__.array2string($_formData['attachments']));
2394 2744
 			$tnfattachments = null;
2395
-			foreach((array)$_formData['attachments'] as $attachment) {
2745
+			foreach((array)$_formData['attachments'] as $attachment)
2746
+			{
2396 2747
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2397 2748
 				if(is_array($attachment))
2398 2749
 				{
2399
-					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2750
+					if (!empty($attachment['uid']) && !empty($attachment['folder']))
2751
+					{
2400 2752
 						/* Example:
2401 2753
 						Array([0] => Array(
2402 2754
 						[uid] => 21178
@@ -2412,14 +2764,18 @@  discard block
 block discarded – undo
2412 2764
 							$connection_opened = true;
2413 2765
 						}
2414 2766
 						$mail_bo->reopen($attachment['folder']);
2415
-						switch(strtoupper($attachment['type'])) {
2767
+						switch(strtoupper($attachment['type']))
2768
+						{
2416 2769
 							case 'MESSAGE/RFC':
2417 2770
 							case 'MESSAGE/RFC822':
2418 2771
 								$rawBody='';
2419
-								if (isset($attachment['partID'])) {
2772
+								if (isset($attachment['partID']))
2773
+								{
2420 2774
 									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2421 2775
 									$rawBody=$eml['attachment'];
2422
-								} else {
2776
+								}
2777
+								else
2778
+								{
2423 2779
 									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2424 2780
 								}
2425 2781
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
@@ -2428,7 +2784,10 @@  discard block
 block discarded – undo
2428 2784
 								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2429 2785
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2430 2786
 								{
2431
-									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2787
+									if (!is_array($tnfattachments))
2788
+									{
2789
+										$tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2790
+									}
2432 2791
 									foreach ($tnfattachments as $k)
2433 2792
 									{
2434 2793
 										if ($k['name'] == $attachment['name'])
@@ -2464,7 +2823,10 @@  discard block
 block discarded – undo
2464 2823
 					}
2465 2824
 				}
2466 2825
 			}
2467
-			if ($connection_opened) $mail_bo->closeConnection();
2826
+			if ($connection_opened)
2827
+			{
2828
+				$mail_bo->closeConnection();
2829
+			}
2468 2830
 		}
2469 2831
 		return is_array($inline_images)?$inline_images:array();
2470 2832
 	}
@@ -2484,13 +2846,20 @@  discard block
 block discarded – undo
2484 2846
 	 */
2485 2847
 	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2486 2848
 	{
2487
-		if ($filemode == Vfs\Sharing::ATTACH) return '';
2849
+		if ($filemode == Vfs\Sharing::ATTACH)
2850
+		{
2851
+			return '';
2852
+		}
2488 2853
 
2489 2854
 		$links = array();
2490 2855
 		foreach($attachments as $attachment)
2491 2856
 		{
2492 2857
 			$path = $attachment['file'];
2493
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2858
+			if (empty($path))
2859
+			{
2860
+				continue;
2861
+			}
2862
+			// we only care about file attachments, not forwarded messages or parts
2494 2863
 			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2495 2864
 			{
2496 2865
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
@@ -2593,13 +2962,19 @@  discard block
 block discarded – undo
2593 2962
 								$success = false;
2594 2963
 								error_log(__METHOD__.__LINE__.$msg);
2595 2964
 							}
2596
-						} else {
2965
+						}
2966
+						else
2967
+						{
2597 2968
 							error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former');
2598 2969
 						}
2599
-					} else {
2970
+					}
2971
+					else
2972
+					{
2600 2973
 						error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)");
2601 2974
 					}
2602
-				} else {
2975
+				}
2976
+				else
2977
+				{
2603 2978
 					error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)");
2604 2979
 				}
2605 2980
 			}
@@ -2615,7 +2990,10 @@  discard block
 block discarded – undo
2615 2990
 			$success = false;
2616 2991
 		}
2617 2992
 
2618
-		if ($success) $msg = lang('Message saved successfully.');
2993
+		if ($success)
2994
+		{
2995
+			$msg = lang('Message saved successfully.');
2996
+		}
2619 2997
 
2620 2998
 		// Include new information to json respose, because we need them in client-side callback
2621 2999
 		$response->data(array(
@@ -2639,7 +3017,10 @@  discard block
 block discarded – undo
2639 3017
 		{
2640 3018
 			if(is_int($address))
2641 3019
 			{
2642
-				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
3020
+				if (!isset($contacts_obs))
3021
+				{
3022
+					$contacts_obj = new Api\Contacts();
3023
+				}
2643 3024
 				// List was selected, expand to addresses
2644 3025
 				unset($_emailAddressList[$ak]);
2645 3026
 				$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));
@@ -2654,7 +3035,10 @@  discard block
 block discarded – undo
2654 3035
 		{
2655 3036
 			foreach ($addrFromList as $addr)
2656 3037
 			{
2657
-				if (!empty($addr)) $_emailAddressList[]=$addr;
3038
+				if (!empty($addr))
3039
+				{
3040
+					$_emailAddressList[]=$addr;
3041
+				}
2658 3042
 			}
2659 3043
 		}
2660 3044
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2708,7 +3092,10 @@  discard block
 block discarded – undo
2708 3092
 		// decide where to save the message (default to draft folder, if we find nothing else)
2709 3093
 		// if the current folder is in draft or template folder save it there
2710 3094
 		// if it is called from printview then save it with the draft folder
2711
-		if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder();
3095
+		if (empty($savingDestination))
3096
+		{
3097
+			$savingDestination = $mail_bo->getDraftFolder();
3098
+		}
2712 3099
 		if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox']))
2713 3100
 		{
2714 3101
 			$this->sessionData['messageFolder'] = $this->sessionData['mailbox'];
@@ -2719,13 +3106,17 @@  discard block
 block discarded – undo
2719 3106
 			$savingDestination = $this->sessionData['messageFolder'];
2720 3107
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2721 3108
 		}
2722
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
3109
+		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 )
3110
+		{
3111
+			$savingDestination = $mail_bo->getDraftFolder();
3112
+		}
2723 3113
 
2724 3114
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2725 3115
 		$mail->forceBccHeader();
2726 3116
 
2727 3117
 		$mail_bo->openConnection();
2728
-		if ($mail_bo->folderExists($savingDestination,true)) {
3118
+		if ($mail_bo->folderExists($savingDestination,true))
3119
+		{
2729 3120
 			try
2730 3121
 			{
2731 3122
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
@@ -2736,7 +3127,9 @@  discard block
 block discarded – undo
2736 3127
 				return false;
2737 3128
 			}
2738 3129
 
2739
-		} else {
3130
+		}
3131
+		else
3132
+		{
2740 3133
 			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2741 3134
 			return false;
2742 3135
 		}
@@ -2784,7 +3177,10 @@  discard block
 block discarded – undo
2784 3177
 					$fhA = mail_ui::splitRowID($rowid);
2785 3178
 					$this->sessionData['uid'][] = $fhA['msgUID'];
2786 3179
 					$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
2787
-					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
3180
+					if (!empty($fhA['folder']))
3181
+					{
3182
+						$this->sessionData['sourceFolder'] = $fhA['folder'];
3183
+					}
2788 3184
 				}
2789 3185
 			}
2790 3186
 			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
@@ -2816,7 +3212,8 @@  discard block
 block discarded – undo
2816 3212
 			#error_log($this->sessionData['body']);
2817 3213
 		}
2818 3214
 		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2819
-		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
3215
+		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder']))
3216
+		{
2820 3217
 		   	$messageIsDraft = true;
2821 3218
 		}
2822 3219
 		try
@@ -2832,7 +3229,11 @@  discard block
 block discarded – undo
2832 3229
 		// create the messages and store inline images
2833 3230
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2834 3231
 		// remember the identity
2835
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
3232
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3233
+		{
3234
+			$fromAddress = $mail->From;
3235
+		}
3236
+		//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2836 3237
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2837 3238
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2838 3239
 		#exit;
@@ -2845,7 +3246,10 @@  discard block
 block discarded – undo
2845 3246
 		{
2846 3247
 			$fval=$f;
2847 3248
 			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2848
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3249
+			if (stripos($f,'::')!==false)
3250
+			{
3251
+				list($icServerID,$fval) = explode('::',$f,2);
3252
+			}
2849 3253
 			if ($_formData['serverID']!=$_formData['mailaccount'])
2850 3254
 			{
2851 3255
 				if ($icServerID == $_formData['serverID'] )
@@ -2886,13 +3290,19 @@  discard block
 block discarded – undo
2886 3290
 			// sentFolder is account specific
2887 3291
 			$sentFolder = $this->mail_bo->getSentFolder();
2888 3292
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2889
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3293
+			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true))
3294
+			{
3295
+				$sentFolder=false;
3296
+			}
2890 3297
 		}
2891 3298
 		else
2892 3299
 		{
2893 3300
 			$sentFolder = $mail_bo->getSentFolder();
2894 3301
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2895
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3302
+			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true))
3303
+			{
3304
+				$sentFolder=false;
3305
+			}
2896 3306
 		}
2897 3307
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2898 3308
 
@@ -2928,19 +3338,30 @@  discard block
 block discarded – undo
2928 3338
 		{
2929 3339
 			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2930 3340
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2931
-				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3341
+				$sentFolder != 'none'))
3342
+			{
3343
+				$this->errorInfo = lang("No Send Folder set in preferences");
3344
+			}
2932 3345
 		}
2933 3346
 		// draftFolder is on Server we start from
2934
-		if($messageIsDraft == true) {
3347
+		if($messageIsDraft == true)
3348
+		{
2935 3349
 			$draftFolder = $mail_bo->getDraftFolder();
2936
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3350
+			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true))
3351
+			{
2937 3352
 				$this->sessionData['folder'] = array($draftFolder);
2938 3353
 				$folderOnServerID[] = $draftFolder;
2939 3354
 				$folder[$draftFolder] = $draftFolder;
2940 3355
 			}
2941 3356
 		}
2942
-		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2943
-		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3357
+		if ($folderOnServerID)
3358
+		{
3359
+			$folderOnServerID = array_unique($folderOnServerID);
3360
+		}
3361
+		if ($folderOnMailAccount)
3362
+		{
3363
+			$folderOnMailAccount = array_unique($folderOnMailAccount);
3364
+		}
2944 3365
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2945 3366
 			!( count($folder) > 0) &&
2946 3367
 			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
@@ -2954,7 +3375,8 @@  discard block
 block discarded – undo
2954 3375
 		@set_time_limit(120);
2955 3376
 		//$mail->SMTPDebug = 10;
2956 3377
 		//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']));
2957
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3378
+		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0)
3379
+		{
2958 3380
 			try {
2959 3381
 				$mail->send();
2960 3382
 			}
@@ -2964,10 +3386,15 @@  discard block
 block discarded – undo
2964 3386
 				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2965 3387
 				return false;
2966 3388
 			}
2967
-		} else {
2968
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3389
+		}
3390
+		else
3391
+		{
3392
+			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder']))
3393
+			{
2969 3394
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2970
-			} else {
3395
+			}
3396
+			else
3397
+			{
2971 3398
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
2972 3399
 				//error_log(__METHOD__.__LINE__.$this->errorInfo);
2973 3400
 				return false;
@@ -2977,14 +3404,16 @@  discard block
 block discarded – undo
2977 3404
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
2978 3405
 		//error_log(__METHOD__.__LINE__.array2string($folder));
2979 3406
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
2980
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3407
+            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3408
+		{
2981 3409
 			$mail_bo = $this->mail_bo;
2982 3410
 			$mail_bo->openConnection();
2983 3411
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
2984 3412
 			#error_log("(re)opened Connection");
2985 3413
 		}
2986 3414
 		// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
2987
-		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
3415
+		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3416
+		{
2988 3417
 			//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
2989 3418
 
2990 3419
 			// normaly Bcc is only added to recipients, but not as header visible to all recipients
@@ -2993,17 +3422,28 @@  discard block
 block discarded – undo
2993 3422
 		// copying mail to folder
2994 3423
 		if (count($folder) > 0)
2995 3424
 		{
2996
-			foreach($folderOnServerID as $folderName) {
2997
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3425
+			foreach($folderOnServerID as $folderName)
3426
+			{
3427
+				if (is_array($folderName))
3428
+				{
3429
+					$folderName = array_shift($folderName);
3430
+				}
3431
+				// should not happen at all
2998 3432
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
2999 3433
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3000 3434
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3001
-				if ($mail_bo->folderExists($folderName,true)) {
3002
-					if($mail_bo->isSentFolder($folderName)) {
3435
+				if ($mail_bo->folderExists($folderName,true))
3436
+				{
3437
+					if($mail_bo->isSentFolder($folderName))
3438
+					{
3003 3439
 						$flags = '\\Seen';
3004
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3440
+					}
3441
+					elseif($mail_bo->isDraftFolder($folderName))
3442
+					{
3005 3443
 						$flags = '\\Draft';
3006
-					} else {
3444
+					}
3445
+					else
3446
+					{
3007 3447
 						$flags = '\\Seen';
3008 3448
 					}
3009 3449
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3026,18 +3466,32 @@  discard block
 block discarded – undo
3026 3466
 				}
3027 3467
 			}
3028 3468
 			// if we choose to send from a differing profile
3029
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3030
-			foreach($folderOnMailAccount as $folderName) {
3031
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3469
+			if ($folderOnMailAccount)
3470
+			{
3471
+				$this->changeProfile($_formData['mailaccount']);
3472
+			}
3473
+			foreach($folderOnMailAccount as $folderName)
3474
+			{
3475
+				if (is_array($folderName))
3476
+				{
3477
+					$folderName = array_shift($folderName);
3478
+				}
3479
+				// should not happen at all
3032 3480
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3033 3481
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3034 3482
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3035
-				if ($this->mail_bo->folderExists($folderName,true)) {
3036
-					if($this->mail_bo->isSentFolder($folderName)) {
3483
+				if ($this->mail_bo->folderExists($folderName,true))
3484
+				{
3485
+					if($this->mail_bo->isSentFolder($folderName))
3486
+					{
3037 3487
 						$flags = '\\Seen';
3038
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3488
+					}
3489
+					elseif($this->mail_bo->isDraftFolder($folderName))
3490
+					{
3039 3491
 						$flags = '\\Draft';
3040
-					} else {
3492
+					}
3493
+					else
3494
+					{
3041 3495
 						$flags = '\\Seen';
3042 3496
 					}
3043 3497
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3059,7 +3513,10 @@  discard block
 block discarded – undo
3059 3513
 					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3060 3514
 				}
3061 3515
 			}
3062
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
3516
+			if ($folderOnMailAccount)
3517
+			{
3518
+				$this->changeProfile($_formData['serverID']);
3519
+			}
3063 3520
 
3064 3521
 			//$mail_bo->closeConnection();
3065 3522
 		}
@@ -3071,10 +3528,16 @@  discard block
 block discarded – undo
3071 3528
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3072 3529
 			$lastDrafted['uid'] = $dhA['msgUID'];
3073 3530
 			$lastDrafted['folder'] = $dhA['folder'];
3074
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3531
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid']))
3532
+			{
3533
+				$lastDrafted['uid']=trim($lastDrafted['uid']);
3534
+			}
3075 3535
 			// manually drafted, do not delete
3076 3536
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3077
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3537
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid']))
3538
+			{
3539
+				$lastDrafted=false;
3540
+			}
3078 3541
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3079 3542
 		}
3080 3543
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
@@ -3100,7 +3563,8 @@  discard block
 block discarded – undo
3100 3563
 
3101 3564
 		//error_log("handling draft messages, flagging and such");
3102 3565
 		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3103
-			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3566
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3567
+		{
3104 3568
 			// mark message as answered
3105 3569
 			$mail_bo->openConnection();
3106 3570
 			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
@@ -3122,7 +3586,9 @@  discard block
 block discarded – undo
3122 3586
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
3123 3587
 					unset($e);
3124 3588
 				}
3125
-			} else {
3589
+			}
3590
+			else
3591
+			{
3126 3592
 				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3127 3593
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3128 3594
 				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
@@ -3141,7 +3607,10 @@  discard block
 block discarded – undo
3141 3607
 			}
3142 3608
 			//$mail_bo->closeConnection();
3143 3609
 		}
3144
-		if ($mail_bo) $mail_bo->closeConnection();
3610
+		if ($mail_bo)
3611
+		{
3612
+			$mail_bo->closeConnection();
3613
+		}
3145 3614
 		//error_log("performing Infolog Stuff");
3146 3615
 		//error_log(print_r($this->sessionData['to'],true));
3147 3616
 		//error_log(print_r($this->sessionData['cc'],true));
@@ -3154,9 +3623,18 @@  discard block
 block discarded – undo
3154 3623
 		{
3155 3624
 			$mailaddresses = array();
3156 3625
 		}
3157
-		if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
3158
-		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3159
-		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3626
+		if (is_array($this->sessionData['cc']))
3627
+		{
3628
+			$mailaddresses['cc'] = $this->sessionData['cc'];
3629
+		}
3630
+		if (is_array($this->sessionData['bcc']))
3631
+		{
3632
+			$mailaddresses['bcc'] = $this->sessionData['bcc'];
3633
+		}
3634
+		if (!empty($mailaddresses))
3635
+		{
3636
+			$mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3637
+		}
3160 3638
 
3161 3639
 		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3162 3640
 		{
@@ -3188,7 +3666,10 @@  discard block
 block discarded – undo
3188 3666
 							$_formData['serverID']),true),
3189 3667
 						'app' => $app_name
3190 3668
 					);
3191
-					if ($entryid) $target['entry_id'] = $entryid;
3669
+					if ($entryid)
3670
+					{
3671
+						$target['entry_id'] = $entryid;
3672
+					}
3192 3673
 					// Open the app called for integration in a popup
3193 3674
 					// and store the mail raw data as egw_data, in order to
3194 3675
 					// be stored from registered app method later
@@ -3199,8 +3680,11 @@  discard block
 block discarded – undo
3199 3680
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3200 3681
 		elseif(is_array($this->sessionData['attachments']))
3201 3682
 		{
3202
-			foreach($this->sessionData['attachments'] as $value) {
3203
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3683
+			foreach($this->sessionData['attachments'] as $value)
3684
+			{
3685
+				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs')
3686
+				{
3687
+// happens when forwarding mails
3204 3688
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3205 3689
 				}
3206 3690
 			}
@@ -3237,7 +3721,10 @@  discard block
 block discarded – undo
3237 3721
 				$default_identity = null;
3238 3722
 				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3239 3723
 				{
3240
-					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3724
+					if (!isset($default_identity))
3725
+					{
3726
+						$default_identity = $identity['ident_id'];
3727
+					}
3241 3728
 					if (!empty($identity['ident_signature']))
3242 3729
 					{
3243 3730
 						$content['mailidentity'] = $identity['ident_id'];
@@ -3245,12 +3732,18 @@  discard block
 block discarded – undo
3245 3732
 					}
3246 3733
 				}
3247 3734
 			}
3248
-			if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity;
3735
+			if (empty($content['mailidentity']))
3736
+			{
3737
+				$content['mailidentity'] = $default_identity;
3738
+			}
3249 3739
 		}
3250 3740
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3251 3741
 		{
3252 3742
 			$content['mimeType'] = 'html';
3253
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3743
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text")
3744
+			{
3745
+				$content['mimeType']  = 'plain';
3746
+			}
3254 3747
 		}
3255 3748
 		return $content;
3256 3749
 
@@ -3258,9 +3751,12 @@  discard block
 block discarded – undo
3258 3751
 
3259 3752
 	function stripSlashes($_string)
3260 3753
 	{
3261
-		if (get_magic_quotes_gpc()) {
3754
+		if (get_magic_quotes_gpc())
3755
+		{
3262 3756
 			return stripslashes($_string);
3263
-		} else {
3757
+		}
3758
+		else
3759
+		{
3264 3760
 			return $_string;
3265 3761
 		}
3266 3762
 	}
@@ -3273,15 +3769,25 @@  discard block
 block discarded – undo
3273 3769
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3274 3770
 	 * @return type
3275 3771
 	 */
3276
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3772
+	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
3773
+	{
3277 3774
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3278 3775
 		static $useCacheIfPossible = null;
3279
-		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
3776
+		if (is_null($useCacheIfPossible))
3777
+		{
3778
+			$useCacheIfPossible = true;
3779
+		}
3280 3780
 		$_searchString = trim($_REQUEST['query']);
3281 3781
 		$results = array();
3282 3782
 		$rememberServerID = $this->mail_bo->icServer->ImapServerId;
3283
-		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount'];
3284
-		if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3783
+		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount']))
3784
+		{
3785
+			$_mailaccountToSearch = $_REQUEST['mailaccount'];
3786
+		}
3787
+		if (empty($_mailaccountToSearch))
3788
+		{
3789
+			$_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3790
+		}
3285 3791
 		if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch)
3286 3792
 		{
3287 3793
 			$this->changeProfile($_mailaccountToSearch);
@@ -3292,7 +3798,8 @@  discard block
 block discarded – undo
3292 3798
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3293 3799
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3294 3800
 			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3295
-			if (count($folderObjects)<=1) {
3801
+			if (count($folderObjects)<=1)
3802
+			{
3296 3803
 				$useCacheIfPossible = false;
3297 3804
 			}
3298 3805
 			else
@@ -3343,7 +3850,8 @@  discard block
 block discarded – undo
3343 3850
 		exit();
3344 3851
 	}
3345 3852
 
3346
-	public static function ajax_searchAddress($_searchStringLength=2) {
3853
+	public static function ajax_searchAddress($_searchStringLength=2)
3854
+	{
3347 3855
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3348 3856
 		$_searchString = trim($_REQUEST['query']);
3349 3857
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3356,7 +3864,10 @@  discard block
 block discarded – undo
3356 3864
 			$search = explode(' ', $_searchString);
3357 3865
 			foreach ($search as $k => $v)
3358 3866
 			{
3359
-				if (mb_strlen($v) < 3) unset($search[$k]);
3867
+				if (mb_strlen($v) < 3)
3868
+				{
3869
+					unset($search[$k]);
3870
+				}
3360 3871
 			}
3361 3872
 			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3362 3873
 			//error_log(__METHOD__.__LINE__.$_searchString);
@@ -3386,9 +3897,12 @@  discard block
 block discarded – undo
3386 3897
 			}
3387 3898
 		}
3388 3899
 		$results = array();
3389
-		if(is_array($contacts)) {
3390
-			foreach($contacts as $contact) {
3391
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3900
+		if(is_array($contacts))
3901
+		{
3902
+			foreach($contacts as $contact)
3903
+			{
3904
+				foreach(array($contact['email'],$contact['email_home']) as $email)
3905
+				{
3392 3906
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3393 3907
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3394 3908
 					$rfcAddr = Mail::parseAddressList($email);
@@ -3402,10 +3916,22 @@  discard block
 block discarded – undo
3402 3916
 					if (method_exists($contacts_obj,'search'))
3403 3917
 					{
3404 3918
 						$contact['n_fn']='';
3405
-						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3406
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3407
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3408
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3919
+						if (!empty($contact['n_prefix']))
3920
+						{
3921
+							$contact['n_fn'] = $contact['n_prefix'];
3922
+						}
3923
+						if (!empty($contact['n_given']))
3924
+						{
3925
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3926
+						}
3927
+						if (!empty($contact['n_family']))
3928
+						{
3929
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3930
+						}
3931
+						if (!empty($contact['org_name']))
3932
+						{
3933
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3934
+						}
3409 3935
 						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3410 3936
 					}
3411 3937
 					else
@@ -3415,7 +3941,8 @@  discard block
 block discarded – undo
3415 3941
 					$args = explode('@', trim($email));
3416 3942
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3417 3943
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3418
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3944
+					if(!empty($email) && in_array($completeMailString ,$results) === false)
3945
+					{
3419 3946
 						$results[] = array(
3420 3947
 							'id'=>$completeMailString,
3421 3948
 							'label' => $completeMailString,
@@ -3434,7 +3961,10 @@  discard block
 block discarded – undo
3434 3961
 		foreach($groups as $g_id => $name)
3435 3962
 		{
3436 3963
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3437
-			if(!$group['account_email']) continue;
3964
+			if(!$group['account_email'])
3965
+			{
3966
+				continue;
3967
+			}
3438 3968
 			$args = explode('@', trim($group['account_email']));
3439 3969
 			$args[] = $name;
3440 3970
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3451,7 +3981,8 @@  discard block
 block discarded – undo
3451 3981
 		{
3452 3982
 			$lists = array_filter(
3453 3983
 				$contacts_obj->get_lists(Acl::READ),
3454
-				function($element) use($_searchString) {
3984
+				function($element) use($_searchString)
3985
+				{
3455 3986
 					return (stripos($element, $_searchString) !== false);
3456 3987
 				}
3457 3988
 			);
@@ -3466,7 +3997,10 @@  discard block
 block discarded – undo
3466 3997
 					'title' => lang('Mailinglist'),
3467 3998
 					'data'	=> $key
3468 3999
 				);
3469
-				if($list_count++ > 5) break;
4000
+				if($list_count++ > 5)
4001
+				{
4002
+					break;
4003
+				}
3470 4004
 			}
3471 4005
 		}
3472 4006
 		 // switch regular JSON response handling off
Please login to merge, or discard this patch.
Spacing   +598 added lines, -599 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class mail_compose
26 26
 {
27
-	var $public_functions = array
28
-	(
27
+	var $public_functions = array(
29 28
 		'compose'		=> True,
30 29
 		'getAttachment'		=> True,
31 30
 	);
@@ -34,8 +33,8 @@  discard block
 block discarded – undo
34 33
 	 * class vars for destination, priorities, mimeTypes
35 34
 	 */
36 35
 	static $destinations = array(
37
-		'to' 		=> 'to',  // lang('to')
38
-		'cc'		=> 'cc',  // lang('cc')
36
+		'to' 		=> 'to', // lang('to')
37
+		'cc'		=> 'cc', // lang('cc')
39 38
 		'bcc'		=> 'bcc', // lang('bcc')
40 39
 		'replyto'	=> 'replyto', // lang('replyto')
41 40
 		'folder'	=> 'folder'  // lang('folder')
@@ -63,20 +62,20 @@  discard block
 block discarded – undo
63 62
 	 * @var array
64 63
 	 */
65 64
 	var $mailPreferences;
66
-	var $attachments;	// Array of attachments
65
+	var $attachments; // Array of attachments
67 66
 	var $displayCharset;
68 67
 	var $composeID;
69 68
 	var $sessionData;
70 69
 
71 70
 	function __construct()
72 71
 	{
73
-		$this->displayCharset   = Api\Translation::charset();
72
+		$this->displayCharset = Api\Translation::charset();
74 73
 
75 74
 		$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
76
-		$this->mail_bo	= Mail::getInstance(true,$profileID);
75
+		$this->mail_bo = Mail::getInstance(true, $profileID);
77 76
 		$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->mail_bo->profileID;
78 77
 
79
-		$this->mailPreferences	=& $this->mail_bo->mailPreferences;
78
+		$this->mailPreferences = & $this->mail_bo->mailPreferences;
80 79
 		//force the default for the forwarding -> asmail
81 80
 		if (!is_array($this->mailPreferences) || empty($this->mailPreferences['message_forwarding']))
82 81
 		{
@@ -84,7 +83,7 @@  discard block
 block discarded – undo
84 83
 		}
85 84
 		if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail');
86 85
 
87
-		$this->mailPreferences  =& $this->mail_bo->mailPreferences;
86
+		$this->mailPreferences = & $this->mail_bo->mailPreferences;
88 87
 	}
89 88
 
90 89
 	/**
@@ -94,15 +93,15 @@  discard block
 block discarded – undo
94 93
 	 */
95 94
 	function changeProfile($_icServerID)
96 95
 	{
97
-		if ($this->mail_bo->profileID!=$_icServerID)
96
+		if ($this->mail_bo->profileID != $_icServerID)
98 97
 		{
99 98
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID);
100
-			$this->mail_bo = Mail::getInstance(false,$_icServerID);
99
+			$this->mail_bo = Mail::getInstance(false, $_icServerID);
101 100
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
102 101
 			// no icServer Object: something failed big time
103 102
 			if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
104 103
 			$this->mail_bo->openConnection($this->mail_bo->profileID);
105
-			$this->mailPreferences  =& $this->mail_bo->mailPreferences;
104
+			$this->mailPreferences = & $this->mail_bo->mailPreferences;
106 105
 		}
107 106
 	}
108 107
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 				'checkbox' => true,
181 180
 				'hint' => 'check to save as trackerentry on send',
182 181
 				'onExecute' => 'javaScript:app.mail.compose_setToggle',
183
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
182
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
184 183
 			),
185 184
 			'to_calendar' => array(
186 185
 				'caption' => 'Calendar',
@@ -205,7 +204,7 @@  discard block
 block discarded – undo
205 204
 				'children' => array(),
206 205
 				'hint' => 'Select the message priority tag',
207 206
 			),
208
-			'save2vfs' => array (
207
+			'save2vfs' => array(
209 208
 				'caption' => 'Save to VFS',
210 209
 				'icon' => 'filesave',
211 210
 				'group' => ++$group,
@@ -242,7 +241,7 @@  discard block
 block discarded – undo
242 241
 		{
243 242
 			foreach (array_keys($actions) as $key)
244 243
 			{
245
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
244
+				if (!in_array($key, array('send', 'button[saveAsDraft]', 'uploadForCompose'))) {
246 245
 					$actions[$key]['toolbarDefault'] = false;
247 246
 				}
248 247
 			}
@@ -260,7 +259,7 @@  discard block
 block discarded – undo
260 259
 	 * @var boolean $suppressSigOnTop =false
261 260
 	 * @var boolean $isReply =false
262 261
 	 */
263
-	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
262
+	function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false)
264 263
 	{
265 264
 		if ($msg) Framework::message($msg);
266 265
 
@@ -281,14 +280,14 @@  discard block
 block discarded – undo
281 280
 		//lang('compose'),lang('from') // needed to be found by translationtools
282 281
 		//error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace());
283 282
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
284
-		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
285
-		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
283
+		$_contentHasSigID = $_content ? array_key_exists('mailidentity', (array)$_content) : false;
284
+		$_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false;
286 285
 		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
287 286
 		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
288 287
 
289 288
 		// Process different places we can use as a start for composing an email
290 289
 		$actionToProcess = 'compose';
291
-		if($_GET['from'] && $replyID)
290
+		if ($_GET['from'] && $replyID)
292 291
 		{
293 292
 			$_content = array_merge((array)$_content, $this->getComposeFrom(
294 293
 				// Parameters needed for fetching appropriate data
@@ -306,10 +305,10 @@  discard block
 block discarded – undo
306 305
 		}
307 306
 
308 307
 		$composeCache = array();
309
-		if (isset($_content['composeID'])&&!empty($_content['composeID']))
308
+		if (isset($_content['composeID']) && !empty($_content['composeID']))
310 309
 		{
311 310
 			$isFirstLoad = false;
312
-			$composeCache = Api\Cache::getCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2);
311
+			$composeCache = Api\Cache::getCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'], $callback = null, $callback_params = array(), $expiration = 60 * 60 * 2);
313 312
 			$this->composeID = $_content['composeID'];
314 313
 			//error_log(__METHOD__.__LINE__.array2string($composeCache));
315 314
 		}
@@ -319,7 +318,7 @@  discard block
 block discarded – undo
319 318
 			// respect that composeasnew may not want that, as we assume there
320 319
 			// is some style already set and our initalStyle always adds a span with &nbsp;
321 320
 			// and we want to avoid that
322
-			$isFirstLoad = !($actionToProcess=='composeasnew');//true;
321
+			$isFirstLoad = !($actionToProcess == 'composeasnew'); //true;
323 322
 			$this->composeID = $_content['composeID'] = $this->generateComposeID();
324 323
 			if (!is_array($_content))
325 324
 			{
@@ -354,7 +353,7 @@  discard block
 block discarded – undo
354 353
 				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
355 354
 				try
356 355
 				{
357
-					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
356
+					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload, $this->composeID, false);
358 357
 				}
359 358
 				catch (Api\Exception\WrongUserinput $e)
360 359
 				{
@@ -380,12 +379,12 @@  discard block
 block discarded – undo
380 379
 			unset($_content['attachments']['delete']);
381 380
 			$attachments = $_content['attachments'];
382 381
 			unset($_content['attachments']);
383
-			foreach($attachments as $i => $att)
382
+			foreach ($attachments as $i => $att)
384 383
 			{
385
-				$remove=false;
386
-				foreach(array_keys($toDelete) as $k)
384
+				$remove = false;
385
+				foreach (array_keys($toDelete) as $k)
387 386
 				{
388
-					if ($att['tmp_name']==$k) $remove=true;
387
+					if ($att['tmp_name'] == $k) $remove = true;
389 388
 				}
390 389
 				if (!$remove) $_content['attachments'][] = $att;
391 390
 			}
@@ -393,7 +392,7 @@  discard block
 block discarded – undo
393 392
 		// someone clicked something like send, or saveAsDraft
394 393
 		// make sure, we are connected to the correct server for sending and storing the send message
395 394
 		$activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose
396
-		$activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
395
+		$activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10);
397 396
 		if (!empty($activeFolderCache[$this->mail_bo->profileID]))
398 397
 		{
399 398
 			//error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]);
@@ -401,7 +400,7 @@  discard block
 block discarded – undo
401 400
 		}
402 401
 		//error_log(__METHOD__.__LINE__.array2string($_content));
403 402
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
404
-			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
403
+			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint'])
405 404
 		)
406 405
 		{
407 406
 			$this->changeProfile($_content['serverID']);
@@ -415,19 +414,19 @@  discard block
 block discarded – undo
415 414
 		{
416 415
 			$buttonClicked = $suppressSigOnTop = true;
417 416
 			$sendOK = true;
418
-			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']);
417
+			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
419 418
 			/*
420 419
 			perform some simple checks, before trying to send on:
421 420
 			$_content['to'];$_content['cc'];$_content['bcc'];
422 421
 			trim($_content['subject']);
423 422
 			trim(strip_tags(str_replace('&nbsp;','',$_content['body'])));
424 423
 			*/
425
-			if (strlen(trim(strip_tags(str_replace('&nbsp;','',$_content['body']))))==0 && count($_content['attachments'])==0)
424
+			if (strlen(trim(strip_tags(str_replace('&nbsp;', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0)
426 425
 			{
427 426
 				$sendOK = false;
428 427
 				$_content['msg'] = $message = lang("no message body supplied");
429 428
 			}
430
-			if ($sendOK && strlen(trim($_content['subject']))==0)
429
+			if ($sendOK && strlen(trim($_content['subject'])) == 0)
431 430
 			{
432 431
 				$sendOK = false;
433 432
 				$_content['msg'] = $message = lang("no subject supplied");
@@ -442,15 +441,15 @@  discard block
 block discarded – undo
442 441
 				try
443 442
 				{
444 443
 					$success = $this->send($_content);
445
-					if ($success==false)
444
+					if ($success == false)
446 445
 					{
447
-						$sendOK=false;
446
+						$sendOK = false;
448 447
 						$message = $this->errorInfo;
449 448
 					}
450 449
 					if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID])
451 450
 					{
452
-						$sigPref[$this->mail_bo->profileID]=$_content['mailidentity'];
453
-						$GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user');
451
+						$sigPref[$this->mail_bo->profileID] = $_content['mailidentity'];
452
+						$GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user');
454 453
 						// save prefs
455 454
 						$GLOBALS['egw']->preferences->save_repository(true);
456 455
 					}
@@ -474,23 +473,23 @@  discard block
 block discarded – undo
474 473
 				if (isset($_content['mode']) && !empty($_content['mode']))
475 474
 				{
476 475
 					$mode = $_content['mode'];
477
-					if ($_content['mode']=='forward' && !empty($_content['processedmail_id']))
476
+					if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id']))
478 477
 					{
479
-						$_content['processedmail_id'] = explode(',',$_content['processedmail_id']);
478
+						$_content['processedmail_id'] = explode(',', $_content['processedmail_id']);
480 479
 						foreach ($_content['processedmail_id'] as $k =>$rowid)
481 480
 						{
482 481
 							$fhA = mail_ui::splitRowID($rowid);
483 482
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
484 483
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
485
-							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
484
+							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false);
486 485
 							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
487 486
 						}
488 487
 					}
489
-					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
488
+					if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id']))
490 489
 					{
491 490
 						$rhA = mail_ui::splitRowID($_content['processedmail_id']);
492 491
 						//$this->sessionData['uid'] = $rhA['msgUID'];
493
-						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
492
+						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
494 493
 						$workingFolder = $rhA['folder'];
495 494
 					}
496 495
 				}
@@ -498,30 +497,30 @@  discard block
 block discarded – undo
498 497
 				if (empty($idsForRefresh) && !empty($_content['processedmail_id']))
499 498
 				{
500 499
 					$rhA = mail_ui::splitRowID($_content['processedmail_id']);
501
-					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
500
+					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
502 501
 				}
503 502
 				$response = Api\Json\Response::get();
504 503
 				if ($activeProfile != $composeProfile)
505 504
 				{
506 505
 					// we need a message only, when account ids (composeProfile vs. activeProfile) differ
507
-					$response->call('opener.egw_message',lang('Message send successfully.'));
506
+					$response->call('opener.egw_message', lang('Message send successfully.'));
508 507
 				}
509
-				elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)))
508
+				elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)))
510 509
 				{
511
-					if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))
510
+					if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))
512 511
 					{
513 512
 						// we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action
514
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail');
513
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail');
515 514
 					}
516 515
 					else
517 516
 					{
518 517
 						//error_log(__METHOD__.__LINE__.array2string($idsForRefresh));
519
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update');
518
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update');
520 519
 					}
521 520
 				}
522 521
 				else
523 522
 				{
524
-					$response->call('opener.egw_message',lang('Message send successfully.'));
523
+					$response->call('opener.egw_message', lang('Message send successfully.'));
525 524
 				}
526 525
 				//egw_framework::refresh_opener(lang('Message send successfully.'),'mail');
527 526
 				Framework::window_close();
@@ -529,60 +528,60 @@  discard block
 block discarded – undo
529 528
 			if ($sendOK == false)
530 529
 			{
531 530
 				$response = Api\Json\Response::get();
532
-				Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate
531
+				Framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate
533 532
 				$response->call('app.mail.clearIntevals');
534 533
 			}
535 534
 		}
536 535
 
537 536
 		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
538 537
 		$insertSigOnTop = false;
539
-		$content = (is_array($_content)?$_content:array());
538
+		$content = (is_array($_content) ? $_content : array());
540 539
 		if ($_contentHasMimeType)
541 540
 		{
542 541
 			// mimeType is now a checkbox; convert it here to match expectations
543 542
 			// ToDo: match Code to meet checkbox value
544
-			if ($content['mimeType']==1)
543
+			if ($content['mimeType'] == 1)
545 544
 			{
546
-				$_content['mimeType'] = $content['mimeType']='html';
545
+				$_content['mimeType'] = $content['mimeType'] = 'html';
547 546
 			}
548 547
 			else
549 548
 			{
550
-				$_content['mimeType'] = $content['mimeType']='plain';
549
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
551 550
 			}
552 551
 
553 552
 		}
554 553
 		// user might have switched desired mimetype, so we should convert
555
-		if ($content['is_html'] && $content['mimeType']=='plain')
554
+		if ($content['is_html'] && $content['mimeType'] == 'plain')
556 555
 		{
557 556
 			//error_log(__METHOD__.__LINE__.$content['mail_htmltext']);
558 557
 			$suppressSigOnTop = true;
559
-			if (stripos($content['mail_htmltext'],'<pre>')!==false)
558
+			if (stripos($content['mail_htmltext'], '<pre>') !== false)
560 559
 			{
561 560
 				$contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']);
562 561
 				if (is_array($contentArr))
563 562
 				{
564 563
 					foreach ($contentArr as $k =>&$elem)
565 564
 					{
566
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
565
+						if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem);
567 566
 					}
568
-					$content['mail_htmltext'] = implode('',$contentArr);
567
+					$content['mail_htmltext'] = implode('', $contentArr);
569 568
 				}
570 569
 			}
571 570
 			$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']);
572
-			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
571
+			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true);
573 572
 
574 573
 			$content['body'] = $content['mail_htmltext'];
575 574
 			unset($content['mail_htmltext']);
576 575
 			$content['is_html'] = false;
577 576
 			$content['is_plain'] = true;
578 577
 		}
579
-		if ($content['is_plain'] && $content['mimeType']=='html')
578
+		if ($content['is_plain'] && $content['mimeType'] == 'html')
580 579
 		{
581 580
 			// the possible font span should only be applied on first load or on switch plain->html
582 581
 			$isFirstLoad = "switchedplaintohtml";
583 582
 			//error_log(__METHOD__.__LINE__.$content['mail_plaintext']);
584 583
 			$suppressSigOnTop = true;
585
-			$content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']);
584
+			$content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']);
586 585
 			//$this->replaceEmailAdresses($content['mail_plaintext']);
587 586
 			$content['body'] = $content['mail_plaintext'];
588 587
 			unset($content['mail_plaintext']);
@@ -590,7 +589,7 @@  discard block
 block discarded – undo
590 589
 			$content['is_plain'] = false;
591 590
 		}
592 591
 
593
-		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']);
592
+		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
594 593
 		unset($_content['body']);
595 594
 		unset($_content['mail_htmltext']);
596 595
 		unset($_content['mail_plaintext']);
@@ -598,7 +597,7 @@  discard block
 block discarded – undo
598 597
 
599 598
 		// form was submitted either by clicking a button or by changing one of the triggering selectboxes
600 599
 		// identity and signatureid; this might trigger that the signature in mail body may have to be altered
601
-		if ( !empty($content['body']) &&
600
+		if (!empty($content['body']) &&
602 601
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
603 602
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
604 603
 		)
@@ -609,7 +608,7 @@  discard block
 block discarded – undo
609 608
 			{
610 609
 				$acc = Mail\Account::read($_content['mailaccount']);
611 610
 				//error_log(__METHOD__.__LINE__.array2string($acc));
612
-				$Identities = Mail\Account::read_identity($acc['ident_id'],true);
611
+				$Identities = Mail\Account::read_identity($acc['ident_id'], true);
613 612
 				//error_log(__METHOD__.__LINE__.array2string($Identities));
614 613
 				if ($Identities['ident_id'])
615 614
 				{
@@ -622,41 +621,41 @@  discard block
 block discarded – undo
622 621
 				}
623 622
 			}
624 623
 			$_oldSig = $composeCache['mailidentity'];
625
-			$_signatureid = ($newSig?$newSig:$_content['mailidentity']);
624
+			$_signatureid = ($newSig ? $newSig : $_content['mailidentity']);
626 625
 
627 626
 			if ($_oldSig != $_signatureid)
628 627
 			{
629
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
628
+				if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
630 629
 				// prepare signatures, the selected sig may be used on top of the body
631 630
 				try
632 631
 				{
633
-					$oldSignature = Mail\Account::read_identity($_oldSig,true);
632
+					$oldSignature = Mail\Account::read_identity($_oldSig, true);
634 633
 					//error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#');
635 634
 					$oldSigText = $oldSignature['ident_signature'];
636 635
 				}
637 636
 				catch (Exception $e)
638 637
 				{
639
-					$oldSignature=array();
638
+					$oldSignature = array();
640 639
 					$oldSigText = null;
641 640
 				}
642 641
 				try
643 642
 				{
644
-					$signature = Mail\Account::read_identity($_signatureid,true);
643
+					$signature = Mail\Account::read_identity($_signatureid, true);
645 644
 					//error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#');
646 645
 					$sigText = $signature['ident_signature'];
647 646
 				}
648 647
 				catch (Exception $e)
649 648
 				{
650
-					$signature=array();
649
+					$signature = array();
651 650
 					$sigText = null;
652 651
 				}
653 652
 				//error_log(__METHOD__.'Old:'.$oldSigText.'#');
654 653
 				//error_log(__METHOD__.'New:'.$sigText.'#');
655 654
 				if ($_currentMode == 'plain')
656 655
 				{
657
-					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
658
-					$sigText = $this->convertHTMLToText($sigText,true,true);
659
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
656
+					$oldSigText = $this->convertHTMLToText($oldSigText, true, true);
657
+					$sigText = $this->convertHTMLToText($sigText, true, true);
658
+					if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
660 659
 				}
661 660
 
662 661
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -671,9 +670,9 @@  discard block
 block discarded – undo
671 670
 				//error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#');
672 671
 				if ($_currentMode == 'html')
673 672
 				{
674
-					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
673
+					$content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace
675 674
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
676
-					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
675
+					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
677 676
 				}
678 677
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
679 678
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -681,9 +680,9 @@  discard block
 block discarded – undo
681 680
 				if ($_currentMode == 'html')
682 681
 				{
683 682
 					$replaced = null;
684
-					$content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u',
685
-						$rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced);
686
-					$content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'&ndash;','&mdash;','&euro;'),$content['body']);
683
+					$content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u',
684
+						$rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced);
685
+					$content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '&ndash;', '&mdash;', '&euro;'), $content['body']);
687 686
 					//error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced");
688 687
 					unset($rep, $in);
689 688
 					if ($replaced)
@@ -694,32 +693,32 @@  discard block
 block discarded – undo
694 693
 					else
695 694
 					{
696 695
 						// try the old way
697
-						$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
696
+						$found = (strlen(trim($oldSigTextCleaned)) > 0 ? strpos($content['body'], trim($oldSigTextCleaned)) : false);
698 697
 					}
699 698
 				}
700 699
 				else
701 700
 				{
702
-					$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
701
+					$found = (strlen(trim($oldSigTextCleaned)) > 0 ? strpos($content['body'], trim($oldSigTextCleaned)) : false);
703 702
 				}
704 703
 
705
-				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
704
+				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
706 705
 				{
707 706
 					//error_log(__METHOD__.'Old Content:'.$content['body'].'#');
708
-					$_oldSigText = preg_quote($oldSigTextCleaned,'~');
707
+					$_oldSigText = preg_quote($oldSigTextCleaned, '~');
709 708
 					//error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#');
710
-					$content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1);
709
+					$content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1);
711 710
 					//error_log(__METHOD__.'new Content:'.$content['body'].'#');
712 711
 				}
713 712
 
714
-				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
713
+				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
715 714
 				{
716 715
 					// if there is no sig selected, there is no way to replace a signature
717 716
 				}
718 717
 
719 718
 				if ($found === false)
720 719
 				{
721
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
722
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
720
+					if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
721
+					if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
723 722
 				}
724 723
 				else
725 724
 				{
@@ -741,7 +740,7 @@  discard block
 block discarded – undo
741 740
 		if ($isFirstLoad)
742 741
 		{
743 742
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
744
-			if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
743
+			if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
745 744
 				$this->mailPreferences['attachVCardAtCompose']))
746 745
 			{
747 746
 				$alwaysAttachVCardAtCompose = true;
@@ -750,7 +749,7 @@  discard block
 block discarded – undo
750 749
 					$f = $_REQUEST['preset']['file'];
751 750
 					$_REQUEST['preset']['file'] = array($f);
752 751
 				}
753
-				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry";
752
+				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry";
754 753
 			}
755 754
 			// an app passed the request for fetching and mailing an entry
756 755
 			if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))
@@ -759,33 +758,33 @@  discard block
 block discarded – undo
759 758
 				$mt = $_REQUEST['method'];
760 759
 				$id = $_REQUEST['id'];
761 760
 				// passed method MUST be registered
762
-				$method = Link::get_registry($app,$mt);
761
+				$method = Link::get_registry($app, $mt);
763 762
 				//error_log(__METHOD__.__LINE__.array2string($method));
764 763
 				if ($method)
765 764
 				{
766
-					$res = ExecMethod($method,array($id,'html'));
765
+					$res = ExecMethod($method, array($id, 'html'));
767 766
 					//error_log(__METHOD__.__LINE__.array2string($res));
768 767
 					if (!empty($res))
769 768
 					{
770 769
 						$insertSigOnTop = 'below';
771 770
 						if (isset($res['attachments']) && is_array($res['attachments']))
772 771
 						{
773
-							foreach($res['attachments'] as $f)
772
+							foreach ($res['attachments'] as $f)
774 773
 							{
775 774
 								$_REQUEST['preset']['file'][] = $f;
776 775
 							}
777 776
 						}
778 777
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
779
-						foreach(array('subject','body','mimetype') as $name) {
778
+						foreach (array('subject', 'body', 'mimetype') as $name) {
780 779
 							$sName = $name;
781
-							if ($name=='mimetype'&&$res[$name])
780
+							if ($name == 'mimetype' && $res[$name])
782 781
 							{
783 782
 								$sName = 'mimeType';
784 783
 								$content[$sName] = $res[$name];
785 784
 							}
786 785
 							else
787 786
 							{
788
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
787
+								if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name];
789 788
 							}
790 789
 						}
791 790
 					}
@@ -794,45 +793,45 @@  discard block
 block discarded – undo
794 793
 			// handle preset info/values
795 794
 			if (is_array($_REQUEST['preset']))
796 795
 			{
797
-				$alreadyProcessed=array();
796
+				$alreadyProcessed = array();
798 797
 				//_debug_array($_REQUEST);
799 798
 				if ($_REQUEST['preset']['mailto']) {
800 799
 					// handle mailto strings such as
801 800
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
802 801
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
803 802
 					// first, strip the mailto: string out of the mailto URL
804
-					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
803
+					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7)));
805 804
 					// check if there is more than the to address
806
-					$mailtoArray = explode('?',$tmp_send_to,2);
805
+					$mailtoArray = explode('?', $tmp_send_to, 2);
807 806
 					if ($mailtoArray[1]) {
808 807
 						// check if there are more than one requests
809
-						$addRequests = explode('&',$mailtoArray[1]);
808
+						$addRequests = explode('&', $mailtoArray[1]);
810 809
 						foreach ($addRequests as $key => $reqval) {
811 810
 							// the additional requests should have a =, to separate key from value.
812
-							$keyValuePair = explode('=',$reqval,2);
813
-							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
811
+							$keyValuePair = explode('=', $reqval, 2);
812
+							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1];
814 813
 						}
815 814
 					}
816
-					$content['to']=$mailtoArray[0];
817
-					$alreadyProcessed['to']='to';
815
+					$content['to'] = $mailtoArray[0];
816
+					$alreadyProcessed['to'] = 'to';
818 817
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
819
-					foreach(array('cc','bcc','subject','body') as $name) {
820
-						$alreadyProcessed[$name]=$name;
821
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
818
+					foreach (array('cc', 'bcc', 'subject', 'body') as $name) {
819
+						$alreadyProcessed[$name] = $name;
820
+						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name];
822 821
 					}
823 822
 				}
824 823
 
825 824
 				if ($_REQUEST['preset']['mailtocontactbyid']) {
826 825
 					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
827 826
 						$contacts_obj = new Api\Contacts();
828
-						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
829
-						if (method_exists($contacts_obj,'search')) {
827
+						$addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook'];
828
+						if (method_exists($contacts_obj, 'search')) {
830 829
 
831
-							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
830
+							$addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']);
832 831
 							foreach ((array)$addressArray as $id => $addressID)
833 832
 							{
834
-								$addressID = (int) $addressID;
835
-								if (!($addressID>0))
833
+								$addressID = (int)$addressID;
834
+								if (!($addressID > 0))
836 835
 								{
837 836
 									unset($addressArray[$id]);
838 837
 								}
@@ -841,44 +840,44 @@  discard block
 block discarded – undo
841 840
 							{
842 841
 								$_searchCond = array('contact_id'=>$addressArray);
843 842
 								//error_log(__METHOD__.__LINE__.$_searchString);
844
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
845
-								$filter = ($showAccounts?array():array('account_id' => null));
846
-								$filter['cols_to_search']=array('n_fn','email','email_home');
847
-								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
843
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts = false;
844
+								$filter = ($showAccounts ? array() : array('account_id' => null));
845
+								$filter['cols_to_search'] = array('n_fn', 'email', 'email_home');
846
+								$contacts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
848 847
 								// additionally search the accounts, if the contact storage is not the account storage
849 848
 								if ($showAccounts &&
850 849
 									$GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
851 850
 									$GLOBALS['egw_info']['server']['contact_repository'] == 'sql')
852 851
 								{
853
-									$accounts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0));
852
+									$accounts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0));
854 853
 
855 854
 									if ($contacts && $accounts)
856 855
 									{
857
-										$contacts = array_merge($contacts,$accounts);
858
-										usort($contacts,create_function('$a,$b','return strcasecmp($a["n_fn"],$b["n_fn"]);'));
856
+										$contacts = array_merge($contacts, $accounts);
857
+										usort($contacts, create_function('$a,$b', 'return strcasecmp($a["n_fn"],$b["n_fn"]);'));
859 858
 									}
860
-									elseif($accounts)
859
+									elseif ($accounts)
861 860
 									{
862
-										$contacts =& $accounts;
861
+										$contacts = & $accounts;
863 862
 									}
864 863
 									unset($accounts);
865 864
 								}
866 865
 							}
867
-							if(is_array($contacts)) {
866
+							if (is_array($contacts)) {
868 867
 								$mailtoArray = array();
869 868
 								$primary = $addressbookprefs['distributionListPreferredMail'];
870 869
 								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
871
-								$secondary = ($primary == 'email'?'email_home':'email');
870
+								$secondary = ($primary == 'email' ? 'email_home' : 'email');
872 871
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
873
-								foreach($contacts as $contact) {
874
-									$innerCounter=0;
875
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
872
+								foreach ($contacts as $contact) {
873
+									$innerCounter = 0;
874
+									foreach (array($contact[$primary], $contact[$secondary]) as $email) {
876 875
 										// use pref distributionListPreferredMail for the primary address
877 876
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
878
-										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
879
-										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
880
-										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
881
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
877
+										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email);
878
+										$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
879
+										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>');
880
+										if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) {
882 881
 											$i++;
883 882
 											$innerCounter++;
884 883
 											$mailtoArray[$i] = $completeMailString;
@@ -887,8 +886,8 @@  discard block
 block discarded – undo
887 886
 								}
888 887
 							}
889 888
 							//error_log(__METHOD__.__LINE__.array2string($mailtoArray));
890
-							$alreadyProcessed['to']='to';
891
-							$content['to']=$mailtoArray;
889
+							$alreadyProcessed['to'] = 'to';
890
+							$content['to'] = $mailtoArray;
892 891
 						}
893 892
 					}
894 893
 				}
@@ -903,20 +902,20 @@  discard block
 block discarded – undo
903 902
 					$types = (array)$_REQUEST['preset']['type'];
904 903
 					//if (!empty($types) && in_array('text/calendar; method=request',$types))
905 904
 					$files = (array)$_REQUEST['preset']['file'];
906
-					foreach($files as $k => $path)
905
+					foreach ($files as $k => $path)
907 906
 					{
908
-						if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false)
907
+						if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false)
909 908
 						{
910 909
 							$insertSigOnTop = 'below';
911 910
 						}
912 911
 						//error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs')));
913
-						if (parse_url($path,PHP_URL_SCHEME == 'vfs'))
912
+						if (parse_url($path, PHP_URL_SCHEME == 'vfs'))
914 913
 						{
915 914
 							//Vfs::load_wrapper('vfs');
916 915
 							$type = Vfs::mime_content_type($path);
917 916
 							// special handling for attaching vCard of iCal --> use their link-title as name
918
-							if (substr($path,-7) != '/.entry' ||
919
-								!(list($app,$id) = array_slice(explode('/',$path),-3)) ||
917
+							if (substr($path, -7) != '/.entry' ||
918
+								!(list($app, $id) = array_slice(explode('/', $path), -3)) ||
920 919
 								!($name = Link::title($app, $id)))
921 920
 							{
922 921
 								$name = Vfs::decodePath(Vfs::basename($path));
@@ -930,7 +929,7 @@  discard block
 block discarded – undo
930 929
 							{
931 930
 								$type = $types[$k];
932 931
 							}
933
-							$path = str_replace('+','%2B',$path);
932
+							$path = str_replace('+', '%2B', $path);
934 933
 							$formData = array(
935 934
 								'name' => $name,
936 935
 								'type' => $type,
@@ -943,7 +942,7 @@  discard block
 block discarded – undo
943 942
 								Framework::message(lang('Directories have to be shared.'), 'info');
944 943
 							}
945 944
 						}
946
-						elseif(is_readable($path))
945
+						elseif (is_readable($path))
947 946
 						{
948 947
 							$formData = array(
949 948
 								'name' => isset($names[$k]) ? $names[$k] : basename($path),
@@ -956,28 +955,28 @@  discard block
 block discarded – undo
956 955
 						{
957 956
 							continue;
958 957
 						}
959
-						$this->addAttachment($formData,$content,($alwaysAttachVCardAtCompose?true:false));
958
+						$this->addAttachment($formData, $content, ($alwaysAttachVCardAtCompose ? true : false));
960 959
 					}
961 960
 					$remember = array();
962 961
 					if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])))
963 962
 					{
964
-						foreach(array_keys($content) as $k)
963
+						foreach (array_keys($content) as $k)
965 964
 						{
966
-							if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k]))
965
+							if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k]))
967 966
 							{
968
-								$alreadyProcessed[$k]=$k;
967
+								$alreadyProcessed[$k] = $k;
969 968
 								$remember[$k] = $this->sessionData[$k];
970 969
 							}
971 970
 						}
972 971
 					}
973
-					if(!empty($remember)) $content = array_merge($content,$remember);
972
+					if (!empty($remember)) $content = array_merge($content, $remember);
974 973
 				}
975
-				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
974
+				foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name)
976 975
 				{
977 976
 					//always handle mimeType
978
-					if ($name=='mimeType' && $_REQUEST['preset'][$name])
977
+					if ($name == 'mimeType' && $_REQUEST['preset'][$name])
979 978
 					{
980
-						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
979
+						$_content[$name] = $content[$name] = $_REQUEST['preset'][$name];
981 980
 					}
982 981
 					//skip if already processed by "preset Routines"
983 982
 					if ($alreadyProcessed[$name]) continue;
@@ -990,36 +989,36 @@  discard block
 block discarded – undo
990 989
 			{
991 990
 				$content['to'] = base64_decode($_REQUEST['send_to']);
992 991
 				// first check if there is a questionmark or ampersand
993
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
992
+				if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2);
994 993
 				$content['to'] = html_entity_decode($content['to']);
995
-				if (($at_pos = strpos($content['to'],'@')) !== false)
994
+				if (($at_pos = strpos($content['to'], '@')) !== false)
996 995
 				{
997
-					if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false)
996
+					if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false)
998 997
 					{
999 998
 						//list($email,$addoptions) = explode('&',$value,2);
1000
-						$email = substr($content['to'],0,$amp_pos+$at_pos);
1001
-						$rest = substr($content['to'], $amp_pos+$at_pos+1);
999
+						$email = substr($content['to'], 0, $amp_pos + $at_pos);
1000
+						$rest = substr($content['to'], $amp_pos + $at_pos + 1);
1002 1001
 						//error_log(__METHOD__.__LINE__.$email.' '.$rest);
1003 1002
 						$content['to'] = $email;
1004 1003
 					}
1005 1004
 				}
1006
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1005
+				if (strpos($content['to'], '%40') !== false) $content['to'] = Api\Html::purify(str_replace('%40', '@', $content['to']));
1007 1006
 				$rarr = array(Api\Html::purify($rest));
1008
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1007
+				if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest);
1009 1008
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1010 1009
 				$karr = array();
1011 1010
 				foreach ($rarr as &$rval)
1012 1011
 				{
1013 1012
 					//must contain =
1014
-					if (strpos($rval,'=')!== false)
1013
+					if (strpos($rval, '=') !== false)
1015 1014
 					{
1016
-						list($k,$v) = explode('=',$rval,2);
1015
+						list($k, $v) = explode('=', $rval, 2);
1017 1016
 						$karr[$k] = (string)$v;
1018
-						unset($k,$v);
1017
+						unset($k, $v);
1019 1018
 					}
1020 1019
 				}
1021 1020
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1022
-				foreach(array('cc','bcc','subject','body') as $name)
1021
+				foreach (array('cc', 'bcc', 'subject', 'body') as $name)
1023 1022
 				{
1024 1023
 					if ($karr[$name]) $content[$name] = $karr[$name];
1025 1024
 				}
@@ -1031,17 +1030,17 @@  discard block
 block discarded – undo
1031 1030
 		if ($isFirstLoad && !empty($_REQUEST['mimeType']))
1032 1031
 		{
1033 1032
 			$_content['mimeType'] = $content['mimeType'];
1034
-			if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html')
1033
+			if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html')
1035 1034
 			{
1036
-				$_content['mimeType'] = $content['mimeType']  = 'plain';
1037
-				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1035
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
1036
+				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1038 1037
 			}
1039
-			if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html')
1038
+			if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html')
1040 1039
 			{
1041
-				$_content['mimeType'] = $content['mimeType']  = 'html';
1040
+				$_content['mimeType'] = $content['mimeType'] = 'html';
1042 1041
 				$content['body'] = "<pre>".$content['body']."</pre>";
1043 1042
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1044
-				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);
1043
+				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);
1045 1044
 			}
1046 1045
 		}
1047 1046
 		else
@@ -1049,24 +1048,24 @@  discard block
 block discarded – undo
1049 1048
 			// try to enforce a mimeType on reply ( if type is not of the wanted type )
1050 1049
 			if ($isReply)
1051 1050
 			{
1052
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" &&
1051
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" &&
1053 1052
 					$content['mimeType'] == 'html')
1054 1053
 				{
1055
-					$_content['mimeType'] = $content['mimeType']  = 'plain';
1056
-					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1054
+					$_content['mimeType'] = $content['mimeType'] = 'plain';
1055
+					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1057 1056
 				}
1058
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" &&
1057
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" &&
1059 1058
 					$content['mimeType'] != 'html')
1060 1059
 				{
1061
-					$_content['mimeType'] = $content['mimeType']  = 'html';
1060
+					$_content['mimeType'] = $content['mimeType'] = 'html';
1062 1061
 					$content['body'] = "<pre>".$content['body']."</pre>";
1063 1062
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1064
-					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);
1063
+					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);
1065 1064
 				}
1066 1065
 			}
1067 1066
 		}
1068 1067
 
1069
-		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false)
1068
+		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible() === false)
1070 1069
 		{
1071 1070
 			$_content['mimeType'] = $content['mimeType'] = 'plain';
1072 1071
 			$content['body'] = $this->convertHTMLToText($content['body']);
@@ -1085,36 +1084,36 @@  discard block
 block discarded – undo
1085 1084
 		//_debug_array(($presetSig ? $presetSig : $content['mailidentity']));
1086 1085
 		try
1087 1086
 		{
1088
-			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true);
1087
+			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true);
1089 1088
 		}
1090 1089
 		catch (Exception $e)
1091 1090
 		{
1092 1091
 			//PROBABLY NOT FOUND
1093
-			$signature=array();
1092
+			$signature = array();
1094 1093
 		}
1095 1094
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
1096 1095
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
1097
-			empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='')
1096
+			empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '')
1098 1097
 		{
1099 1098
 			$disableRuler = true;
1100 1099
 		}
1101 1100
 		$font_span = $font_part = '';
1102
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1101
+		if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1103 1102
 			// User preferences for style
1104 1103
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1105 1104
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1106
-			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1105
+			$font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">';
1107 1106
 			$font_span = $font_part.'&#8203;</span>';
1108 1107
 			if (empty($font) && empty($font_size)) $font_span = '';
1109 1108
 		}
1110 1109
 		// 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
1111
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1110
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = '';
1112 1111
 		//remove possible html header stuff
1113
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1112
+		if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']);
1114 1113
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1115
-		$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');
1116
-		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1117
-			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1114
+		$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');
1115
+		if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' &&
1116
+			!(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop
1118 1117
 		)
1119 1118
 		{
1120 1119
 			// ON tOP OR BELOW? pREF CAN TELL
@@ -1124,54 +1123,54 @@  discard block
 block discarded – undo
1124 1123
 						'1' => 'before reply, visible during compose',
1125 1124
 						'no_belowaftersend'  => 'appended after reply before sending',
1126 1125
 			*/
1127
-			$insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below'));
1128
-			$sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
1126
+			$insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below'));
1127
+			$sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
1129 1128
 			if ($content['mimeType'] == 'html')
1130 1129
 			{
1131
-				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1132
-				foreach($blockElements as $e)
1130
+				$sigTextStartsWithBlockElement = ($disableRuler ? false : true);
1131
+				foreach ($blockElements as $e)
1133 1132
 				{
1134 1133
 					if ($sigTextStartsWithBlockElement) break;
1135
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1134
+					if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true;
1136 1135
 				}
1137 1136
 			}
1138
-			if($content['mimeType'] == 'html') {
1137
+			if ($content['mimeType'] == 'html') {
1139 1138
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1140 1139
 				$inbetween = '';
1141 1140
 			} else {
1142
-				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1141
+				$before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
1143 1142
 				$inbetween = "\r\n";
1144 1143
 			}
1145 1144
 			if ($content['mimeType'] == 'html')
1146 1145
 			{
1147
-				$sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>");
1146
+				$sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>");
1148 1147
 			}
1149 1148
 
1150 1149
 			if ($insertSigOnTop === 'below')
1151 1150
 			{
1152
-				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true));
1151
+				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true));
1153 1152
 			}
1154 1153
 			else
1155 1154
 			{
1156
-				$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
1155
+				$content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body'];
1157 1156
 			}
1158 1157
 		}
1159 1158
 		else
1160 1159
 		{
1161
-			$content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":"");
1160
+			$content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : "");
1162 1161
 		}
1163 1162
 		//error_log(__METHOD__.__LINE__.$content['body']);
1164 1163
 
1165 1164
 		// prepare body
1166 1165
 		// in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct
1167
-		$content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8');
1166
+		$content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8');
1168 1167
 		//error_log(__METHOD__.__LINE__.array2string($content));
1169 1168
 
1170 1169
 		// get identities of all accounts as "$acc_id:$ident_id" => $identity
1171 1170
 		$sel_options['mailaccount'] = $identities = array();
1172
-		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1171
+		foreach (Mail\Account::search(true, false) as $acc_id => $account)
1173 1172
 		{
1174
-			foreach($account->identities($acc_id) as $ident_id => $identity)
1173
+			foreach ($account->identities($acc_id) as $ident_id => $identity)
1175 1174
 			{
1176 1175
 				$sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity;
1177 1176
 				$identities[$ident_id] = $identity;
@@ -1182,7 +1181,7 @@  discard block
 block discarded – undo
1182 1181
 		//$content['bcc'] = array('[email protected]','[email protected]');
1183 1182
 		// address stuff like from, to, cc, replyto
1184 1183
 		$destinationRows = 0;
1185
-		foreach(self::$destinations as $destination) {
1184
+		foreach (self::$destinations as $destination) {
1186 1185
 			if (!is_array($content[$destination]))
1187 1186
 			{
1188 1187
 				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
@@ -1190,22 +1189,22 @@  discard block
 block discarded – undo
1190 1189
 			$addr_content = $content[strtolower($destination)];
1191 1190
 			// we clear the given address array and rebuild it
1192 1191
 			unset($content[strtolower($destination)]);
1193
-			foreach((array)$addr_content as $key => $value) {
1194
-				if ($value=="NIL@NIL") continue;
1195
-				if ($destination=='replyto' && str_replace('"','',$value) ==
1196
-					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1192
+			foreach ((array)$addr_content as $key => $value) {
1193
+				if ($value == "NIL@NIL") continue;
1194
+				if ($destination == 'replyto' && str_replace('"', '', $value) ==
1195
+					str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()]))
1197 1196
 				{
1198 1197
 					// preserve/restore the value to content.
1199
-					$content[strtolower($destination)][]=$value;
1198
+					$content[strtolower($destination)][] = $value;
1200 1199
 					continue;
1201 1200
 				}
1202 1201
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1203
-				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1204
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1202
+				$value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT));
1203
+				foreach (Mail::parseAddressList($value) as $addressObject) {
1205 1204
 					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1206
-					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1205
+					$address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
1207 1206
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1208
-					$content[strtolower($destination)][]=$address;
1207
+					$content[strtolower($destination)][] = $address;
1209 1208
 					$destinationRows++;
1210 1209
 				}
1211 1210
 			}
@@ -1213,10 +1212,10 @@  discard block
 block discarded – undo
1213 1212
 		if ($_content)
1214 1213
 		{
1215 1214
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1216
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1217
-			$content = array_merge($content,$_content);
1215
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']);
1216
+			$content = array_merge($content, $_content);
1218 1217
 
1219
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1218
+			if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true);
1220 1219
 			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1221 1220
 		}
1222 1221
 		else
@@ -1225,12 +1224,12 @@  discard block
 block discarded – undo
1225 1224
 			$content['mailaccount'] = $this->mail_bo->profileID;
1226 1225
 			//error_log(__METHOD__.__LINE__.$content['body']);
1227 1226
 		}
1228
-		$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
1229
-		$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
1230
-		$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body'];
1231
-		$content['showtempname']=0;
1227
+		$content['is_html'] = ($content['mimeType'] == 'html' ? true : '');
1228
+		$content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true);
1229
+		$content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body'];
1230
+		$content['showtempname'] = 0;
1232 1231
 		//if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments']));
1233
-		$content['attachments']=(is_array($content['attachments'])&&is_array($content['uploadForCompose'])?array_merge($content['attachments'],(!empty($content['uploadForCompose'])?$content['uploadForCompose']:array())):(is_array($content['uploadForCompose'])?$content['uploadForCompose']:(is_array($content['attachments'])?$content['attachments']:null)));
1232
+		$content['attachments'] = (is_array($content['attachments']) && is_array($content['uploadForCompose']) ? array_merge($content['attachments'], (!empty($content['uploadForCompose']) ? $content['uploadForCompose'] : array())) : (is_array($content['uploadForCompose']) ? $content['uploadForCompose'] : (is_array($content['attachments']) ? $content['attachments'] : null)));
1234 1233
 		//if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0;
1235 1234
 		$content['no_griddata'] = empty($content['attachments']);
1236 1235
 		$preserv['attachments'] = $content['attachments'];
@@ -1264,12 +1263,12 @@  discard block
 block discarded – undo
1264 1263
 		$sel_options['mimeType'] = self::$mimeTypes;
1265 1264
 		$sel_options['priority'] = self::$priorities;
1266 1265
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1267
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1266
+		if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3;
1268 1267
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1269 1268
 		$etpl = new Etemplate('mail.compose');
1270 1269
 
1271 1270
 		$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content));
1272
-		if ($content['mimeType']=='html')
1271
+		if ($content['mimeType'] == 'html')
1273 1272
 		{
1274 1273
 			//mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]"
1275 1274
 			$_htmlConfig = Mail::$htmLawed_config;
@@ -1279,23 +1278,23 @@  discard block
 block discarded – undo
1279 1278
 			// and not the eGroupware wide pref to prevent users from trying things that will potentially not work
1280 1279
 			// or not work as expected, as a full featured editor that may be wanted in other apps
1281 1280
 			// is way overloading the "normal" needs for composing mails
1282
-			$content['rtfEditorFeatures']='simple-withimage';//Api\Html\CkEditorConfig::get_ckeditor_config();
1281
+			$content['rtfEditorFeatures'] = 'simple-withimage'; //Api\Html\CkEditorConfig::get_ckeditor_config();
1283 1282
 			//$content['rtfEditorFeatures']='advanced';//Api\Html\CkEditorConfig::get_ckeditor_config();
1284
-			$content['validation_rules']= json_encode(Mail::$htmLawed_config);
1285
-			$etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']);
1286
-			$etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']);
1283
+			$content['validation_rules'] = json_encode(Mail::$htmLawed_config);
1284
+			$etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']);
1285
+			$etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']);
1287 1286
 			Mail::$htmLawed_config = $_htmlConfig;
1288 1287
 		}
1289 1288
 
1290
-		if (isset($content['composeID'])&&!empty($content['composeID']))
1289
+		if (isset($content['composeID']) && !empty($content['composeID']))
1291 1290
 		{
1292 1291
 			$composeCache = $content;
1293 1292
 			unset($composeCache['body']);
1294 1293
 			unset($composeCache['mail_htmltext']);
1295 1294
 			unset($composeCache['mail_plaintext']);
1296
-			Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2);
1295
+			Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2);
1297 1296
 		}
1298
-		if (!isset($_content['serverID'])||empty($_content['serverID']))
1297
+		if (!isset($_content['serverID']) || empty($_content['serverID']))
1299 1298
 		{
1300 1299
 			$content['serverID'] = $this->mail_bo->profileID;
1301 1300
 		}
@@ -1311,25 +1310,25 @@  discard block
 block discarded – undo
1311 1310
 		$preserv['list-id'] = $content['list-id'];
1312 1311
 		$preserv['mode'] = $content['mode'];
1313 1312
 		// convert it back to checkbox expectations
1314
-		if($content['mimeType'] == 'html') {
1315
-			$content['mimeType']=1;
1313
+		if ($content['mimeType'] == 'html') {
1314
+			$content['mimeType'] = 1;
1316 1315
 		} else {
1317
-			$content['mimeType']=0;
1316
+			$content['mimeType'] = 0;
1318 1317
 		}
1319 1318
 		// set the current selected mailaccount as param for folderselection
1320
-		$etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount']));
1319
+		$etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount']));
1321 1320
 		// join again mailaccount and identity
1322 1321
 		$content['mailaccount'] .= ':'.$content['mailidentity'];
1323 1322
 
1324 1323
 		// Resolve distribution list before send content to client
1325
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1324
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $f)
1326 1325
 		{
1327
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1326
+			if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]);
1328 1327
 		}
1329 1328
 
1330 1329
 		$content['to'] = self::resolveEmailAddressList($content['to']);
1331 1330
 		//error_log(__METHOD__.__LINE__.array2string($content));
1332
-		$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
1331
+		$etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2);
1333 1332
 	}
1334 1333
 
1335 1334
 	/**
@@ -1350,9 +1349,9 @@  discard block
 block discarded – undo
1350 1349
 		$content = array();
1351 1350
 		//error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply");
1352 1351
 		// on forward we may have to support multiple ids
1353
-		if ($from=='forward')
1352
+		if ($from == 'forward')
1354 1353
 		{
1355
-			$replyIds = explode(',',$mail_id);
1354
+			$replyIds = explode(',', $mail_id);
1356 1355
 			$mail_id = $replyIds[0];
1357 1356
 		}
1358 1357
 		$hA = mail_ui::splitRowID($mail_id);
@@ -1364,15 +1363,15 @@  discard block
 block discarded – undo
1364 1363
 			$this->changeProfile($icServerID);
1365 1364
 		}
1366 1365
 		$icServer = $this->mail_bo->icServer;
1367
-		if (!empty($folder) && !empty($msgUID) )
1366
+		if (!empty($folder) && !empty($msgUID))
1368 1367
 		{
1369 1368
 			// this fill the session data with the values from the original email
1370
-			switch($from)
1369
+			switch ($from)
1371 1370
 			{
1372 1371
 				case 'composefromdraft':
1373 1372
 				case 'composeasnew':
1374 1373
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1375
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1374
+					if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft';
1376 1375
 					$content['processedmail_id'] = $mail_id;
1377 1376
 
1378 1377
 					$_focusElement = 'body';
@@ -1388,7 +1387,7 @@  discard block
 block discarded – undo
1388 1387
 					$isReply = true;
1389 1388
 					break;
1390 1389
 				case 'forward':
1391
-					$mode  = ($_GET['mode']=='forwardinline'?'inline':'asmail');
1390
+					$mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail');
1392 1391
 					// this fill the session data with the values from the original email
1393 1392
 					foreach ($replyIds as &$mail_id)
1394 1393
 					{
@@ -1398,14 +1397,14 @@  discard block
 block discarded – undo
1398 1397
 						$folder = $hA['folder'];
1399 1398
 						$content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode);
1400 1399
 					}
1401
-					$content['processedmail_id'] = implode(',',$replyIds);
1400
+					$content['processedmail_id'] = implode(',', $replyIds);
1402 1401
 					$content['mode'] = 'forward';
1403
-					$isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline');
1404
-					$suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution
1402
+					$isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline');
1403
+					$suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution
1405 1404
 					$_focusElement = 'to';
1406 1405
 					break;
1407 1406
 				default:
1408
-					error_log('Unhandled compose source: ' . $from);
1407
+					error_log('Unhandled compose source: '.$from);
1409 1408
 			}
1410 1409
 		}
1411 1410
 		else if ($from == 'merge' && $_REQUEST['document'])
@@ -1420,12 +1419,12 @@  discard block
 block discarded – undo
1420 1419
 			$document_merge = new $merge_class();
1421 1420
 			$this->mail_bo->openConnection();
1422 1421
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1423
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1422
+			if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids);
1424 1423
 			try
1425 1424
 			{
1426 1425
 				$merged_mail_id = '';
1427 1426
 				$folder = '';
1428
-				if(($error = $document_merge->check_document($_REQUEST['document'],'')))
1427
+				if (($error = $document_merge->check_document($_REQUEST['document'], '')))
1429 1428
 				{
1430 1429
 					$content['msg'] = $error;
1431 1430
 					return $content;
@@ -1435,10 +1434,10 @@  discard block
 block discarded – undo
1435 1434
 				//$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
1436 1435
 
1437 1436
 				// Actually do the merge
1438
-				if(count($merge_ids) <= 1)
1437
+				if (count($merge_ids) <= 1)
1439 1438
 				{
1440 1439
 					$results = $this->mail_bo->importMessageToMergeAndSend(
1441
-						$document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1440
+						$document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1442 1441
 					);
1443 1442
 
1444 1443
 					// Open compose
@@ -1449,9 +1448,9 @@  discard block
 block discarded – undo
1449 1448
 				}
1450 1449
 				else
1451 1450
 				{
1452
-					$success = implode(', ',$results['success']);
1451
+					$success = implode(', ', $results['success']);
1453 1452
 					$fail = implode(', ', $results['failed']);
1454
-					if($success) Framework::message($success, 'success');
1453
+					if ($success) Framework::message($success, 'success');
1455 1454
 					Framework::window_close($fail);
1456 1455
 				}
1457 1456
 			}
@@ -1479,22 +1478,22 @@  discard block
 block discarded – undo
1479 1478
 		return 1;
1480 1479
 	}
1481 1480
 
1482
-	function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false)
1481
+	function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false)
1483 1482
 	{
1484 1483
 		$stripalltags = true;
1485 1484
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1486
-		if (!$sourceishtml) $stripalltags=false;
1487
-		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1485
+		if (!$sourceishtml) $stripalltags = false;
1486
+		return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags);
1488 1487
 	}
1489 1488
 
1490 1489
 	function generateRFC822Address($_addressObject)
1491 1490
 	{
1492
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1493
-			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1494
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1495
-			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1491
+		if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1492
+			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1493
+		} elseif ($_addressObject->mailbox && $_addressObject->host) {
1494
+			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1496 1495
 		} else {
1497
-			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1496
+			return $this->mail_bo->decode_header($_addressObject->mailbox, true);
1498 1497
 		}
1499 1498
 	}
1500 1499
 
@@ -1509,9 +1508,9 @@  discard block
 block discarded – undo
1509 1508
 	// $_mode can be:
1510 1509
 	// single: for a reply to one address
1511 1510
 	// all: for a reply to all
1512
-	function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL)
1511
+	function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL)
1513 1512
 	{
1514
-		unset($_icServer);	// not used
1513
+		unset($_icServer); // not used
1515 1514
 		$this->sessionData['to'] = array();
1516 1515
 
1517 1516
 		$mail_bo = $this->mail_bo;
@@ -1520,7 +1519,7 @@  discard block
 block discarded – undo
1520 1519
 
1521 1520
 		// get message headers for specified message
1522 1521
 		#$headers	= $mail_bo->getMessageHeader($_folder, $_uid);
1523
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID);
1522
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
1524 1523
 		$addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID);
1525 1524
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1526 1525
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
@@ -1528,10 +1527,10 @@  discard block
 block discarded – undo
1528 1527
 
1529 1528
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1530 1529
 		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1531
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1532
-				$fval=$val;
1530
+			foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) {
1531
+				$fval = $val;
1533 1532
 				$icServerID = $mail_bo->icServer->ImapServerId;
1534
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1533
+				if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2);
1535 1534
 				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1536 1535
 				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1537 1536
 			}
@@ -1567,71 +1566,71 @@  discard block
 block discarded – undo
1567 1566
 			}
1568 1567
 		}
1569 1568
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1570
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1569
+		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder);
1571 1570
 		$this->sessionData['uid'] = $_uid;
1572 1571
 		$this->sessionData['messageFolder'] = $_folder;
1573 1572
 		$this->sessionData['isDraft'] = true;
1574 1573
 		$foundAddresses = array();
1575
-		foreach((array)$headers['CC'] as $val) {
1576
-			$rfcAddr=Mail::parseAddressList($val);
1574
+		foreach ((array)$headers['CC'] as $val) {
1575
+			$rfcAddr = Mail::parseAddressList($val);
1577 1576
 			$_rfcAddr = $rfcAddr[0];
1578 1577
 			if (!$_rfcAddr->valid) continue;
1579
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1578
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1580 1579
 				continue;
1581 1580
 			}
1582
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1583
-			if(!$foundAddresses[$keyemail]) {
1584
-				$address = $this->mail_bo->decode_header($val,true);
1581
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1582
+			if (!$foundAddresses[$keyemail]) {
1583
+				$address = $this->mail_bo->decode_header($val, true);
1585 1584
 				$this->sessionData['cc'][] = $val;
1586 1585
 				$foundAddresses[$keyemail] = true;
1587 1586
 			}
1588 1587
 		}
1589 1588
 
1590
-		foreach((array)$headers['TO'] as $val) {
1591
-			if(!is_array($val))
1589
+		foreach ((array)$headers['TO'] as $val) {
1590
+			if (!is_array($val))
1592 1591
 			{
1593 1592
 				$this->sessionData['to'][] = $val;
1594 1593
 				continue;
1595 1594
 			}
1596
-			$rfcAddr=Mail::parseAddressList($val);
1595
+			$rfcAddr = Mail::parseAddressList($val);
1597 1596
 			$_rfcAddr = $rfcAddr[0];
1598 1597
 			if (!$_rfcAddr->valid) continue;
1599
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1598
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1600 1599
 				continue;
1601 1600
 			}
1602
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1603
-			if(!$foundAddresses[$keyemail]) {
1604
-				$address = $this->mail_bo->decode_header($val,true);
1601
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1602
+			if (!$foundAddresses[$keyemail]) {
1603
+				$address = $this->mail_bo->decode_header($val, true);
1605 1604
 				$this->sessionData['to'][] = $val;
1606 1605
 				$foundAddresses[$keyemail] = true;
1607 1606
 			}
1608 1607
 		}
1609 1608
 
1610
-		foreach((array)$headers['REPLY-TO'] as $val) {
1611
-			$rfcAddr=Mail::parseAddressList($val);
1609
+		foreach ((array)$headers['REPLY-TO'] as $val) {
1610
+			$rfcAddr = Mail::parseAddressList($val);
1612 1611
 			$_rfcAddr = $rfcAddr[0];
1613 1612
 			if (!$_rfcAddr->valid) continue;
1614
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1613
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1615 1614
 				continue;
1616 1615
 			}
1617
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1618
-			if(!$foundAddresses[$keyemail]) {
1619
-				$address = $this->mail_bo->decode_header($val,true);
1616
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1617
+			if (!$foundAddresses[$keyemail]) {
1618
+				$address = $this->mail_bo->decode_header($val, true);
1620 1619
 				$this->sessionData['replyto'][] = $val;
1621 1620
 				$foundAddresses[$keyemail] = true;
1622 1621
 			}
1623 1622
 		}
1624 1623
 
1625
-		foreach((array)$headers['BCC'] as $val) {
1626
-			$rfcAddr=Mail::parseAddressList($val);
1624
+		foreach ((array)$headers['BCC'] as $val) {
1625
+			$rfcAddr = Mail::parseAddressList($val);
1627 1626
 			$_rfcAddr = $rfcAddr[0];
1628 1627
 			if (!$_rfcAddr->valid) continue;
1629
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1628
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1630 1629
 				continue;
1631 1630
 			}
1632
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1633
-			if(!$foundAddresses[$keyemail]) {
1634
-				$address = $this->mail_bo->decode_header($val,true);
1631
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1632
+			if (!$foundAddresses[$keyemail]) {
1633
+				$address = $this->mail_bo->decode_header($val, true);
1635 1634
 				$this->sessionData['bcc'][] = $val;
1636 1635
 				$foundAddresses[$keyemail] = true;
1637 1636
 			}
@@ -1640,48 +1639,48 @@  discard block
 block discarded – undo
1640 1639
 		$this->sessionData['subject']	= $mail_bo->decode_header($headers['SUBJECT']);
1641 1640
 		// remove a printview tag if composing
1642 1641
 		$searchfor = '/^\['.lang('printview').':\]/';
1643
-		$this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']);
1644
-		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1642
+		$this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']);
1643
+		$bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID);
1645 1644
 		//_debug_array($bodyParts);
1646 1645
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1647
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1648
-			$this->sessionData['mimeType'] 	= 'html';
1646
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
1647
+			$this->sessionData['mimeType'] = 'html';
1649 1648
 
1650
-			for($i=0; $i<count($bodyParts); $i++) {
1651
-				if($i>0) {
1649
+			for ($i = 0; $i < count($bodyParts); $i++) {
1650
+				if ($i > 0) {
1652 1651
 					$this->sessionData['body'] .= '<hr>';
1653 1652
 				}
1654
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1653
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
1655 1654
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1656 1655
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1657 1656
 				}
1658
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1657
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1659 1658
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1660 1659
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1661
-				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1660
+				$this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body'];
1662 1661
 			}
1663 1662
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1664 1663
 
1665 1664
 		} else {
1666
-			$this->sessionData['mimeType']	= 'plain';
1665
+			$this->sessionData['mimeType'] = 'plain';
1667 1666
 
1668
-			for($i=0; $i<count($bodyParts); $i++) {
1669
-				if($i>0) {
1667
+			for ($i = 0; $i < count($bodyParts); $i++) {
1668
+				if ($i > 0) {
1670 1669
 					$this->sessionData['body'] .= "<hr>";
1671 1670
 				}
1672
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1671
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1673 1672
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1674 1673
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1675
-				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
1674
+				$this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body'];
1676 1675
 			}
1677
-			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1676
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain');
1678 1677
 		}
1679 1678
 
1680
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1681
-			foreach($attachments as $attachment) {
1679
+		if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1680
+			foreach ($attachments as $attachment) {
1682 1681
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1683 1682
 				$cid = $attachment['cid'];
1684
-				$match=null;
1683
+				$match = null;
1685 1684
 				preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match);
1686 1685
 				//error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match));
1687 1686
 				if (!$match || !$attachment['cid'])
@@ -1700,7 +1699,7 @@  discard block
 block discarded – undo
1700 1699
 
1701 1700
 	function getErrorInfo()
1702 1701
 	{
1703
-		if(isset($this->errorInfo)) {
1702
+		if (isset($this->errorInfo)) {
1704 1703
 			$errorInfo = $this->errorInfo;
1705 1704
 			unset($this->errorInfo);
1706 1705
 			return $errorInfo;
@@ -1708,39 +1707,39 @@  discard block
 block discarded – undo
1708 1707
 		return false;
1709 1708
 	}
1710 1709
 
1711
-	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false)
1710
+	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false)
1712 1711
 	{
1713 1712
 		if ($_mode)
1714 1713
 		{
1715 1714
 			$modebuff = $this->mailPreferences['message_forwarding'];
1716 1715
 			$this->mailPreferences['message_forwarding'] = $_mode;
1717 1716
 		}
1718
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1717
+		if ($this->mailPreferences['message_forwarding'] == 'inline') {
1719 1718
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1720 1719
 		}
1721
-		$mail_bo    = $this->mail_bo;
1720
+		$mail_bo = $this->mail_bo;
1722 1721
 		$mail_bo->openConnection();
1723 1722
 		$mail_bo->reopen($_folder);
1724 1723
 
1725 1724
 		// get message headers for specified message
1726
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder);
1725
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder);
1727 1726
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1728 1727
 		//_debug_array($headers); exit;
1729 1728
 		// check for Re: in subject header
1730
-		$this->sessionData['subject'] 	= "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']);
1729
+		$this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']);
1731 1730
 		// the three attributes below are substituted by processedmail_id and mode
1732 1731
 		//$this->sessionData['sourceFolder']=$_folder;
1733 1732
 		//$this->sessionData['forwardFlag']='forwarded';
1734 1733
 		//$this->sessionData['forwardedUID']=$_uid;
1735
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1736
-			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1737
-			if($headers['SIZE'])
1734
+		if ($this->mailPreferences['message_forwarding'] == 'asmail') {
1735
+			$this->sessionData['mimeType'] = $this->mailPreferences['composeOptions'];
1736
+			if ($headers['SIZE'])
1738 1737
 				$size				= $headers['SIZE'];
1739 1738
 			else
1740 1739
 				$size				= lang('unknown');
1741 1740
 
1742 1741
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1743
-				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
1742
+				$mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml',
1744 1743
 				'MESSAGE/RFC822', $size);
1745 1744
 		}
1746 1745
 		else
@@ -1748,10 +1747,10 @@  discard block
 block discarded – undo
1748 1747
 			unset($this->sessionData['in-reply-to']);
1749 1748
 			unset($this->sessionData['to']);
1750 1749
 			unset($this->sessionData['cc']);
1751
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1750
+			if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1752 1751
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1753
-				foreach($attachments as $attachment) {
1754
-					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1752
+				foreach ($attachments as $attachment) {
1753
+					if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1755 1754
 					{
1756 1755
 						$this->addMessageAttachment($_uid, $attachment['partID'],
1757 1756
 							$_folder,
@@ -1780,7 +1779,7 @@  discard block
 block discarded – undo
1780 1779
 	 * @param array $_content the content passed to the function and to be modified
1781 1780
 	 * @return void
1782 1781
 	 */
1783
-	function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false)
1782
+	function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false)
1784 1783
 	{
1785 1784
 		//error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content));
1786 1785
 
@@ -1789,7 +1788,7 @@  discard block
 block discarded – undo
1789 1788
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
1790 1789
 		try
1791 1790
 		{
1792
-			$tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false);
1791
+			$tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false);
1793 1792
 		}
1794 1793
 		catch (Api\Exception\WrongUserinput $e)
1795 1794
 		{
@@ -1805,8 +1804,8 @@  discard block
 block discarded – undo
1805 1804
 			foreach ((array)$_content['attachments'] as $attach)
1806 1805
 			{
1807 1806
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1808
-					strtolower($_formData['type'])== strtolower($attach['type']) &&
1809
-					stripos($_formData['file'],'vfs://') !== false) return;
1807
+					strtolower($_formData['type']) == strtolower($attach['type']) &&
1808
+					stripos($_formData['file'], 'vfs://') !== false) return;
1810 1809
 			}
1811 1810
 		}
1812 1811
 		if ($attachfailed === false)
@@ -1818,7 +1817,7 @@  discard block
 block discarded – undo
1818 1817
 				'tmp_name'	=> $tmpFileName,
1819 1818
 				'size'	=> $_formData['size']
1820 1819
 			);
1821
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
1820
+			if (!is_array($_content['attachments'])) $_content['attachments'] = array();
1822 1821
 			$_content['attachments'][] = $buffer;
1823 1822
 			unset($buffer);
1824 1823
 		}
@@ -1830,14 +1829,14 @@  discard block
 block discarded – undo
1830 1829
 
1831 1830
 	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size)
1832 1831
 	{
1833
-		$this->sessionData['attachments'][]=array (
1832
+		$this->sessionData['attachments'][] = array(
1834 1833
 			'uid'		=> $_uid,
1835 1834
 			'partID'	=> $_partID,
1836 1835
 			'name'		=> $_name,
1837 1836
 			'type'		=> $_type,
1838 1837
 			'size'		=> $_size,
1839 1838
 			'folder'	=> $_folder,
1840
-			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1),
1839
+			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1),
1841 1840
 		);
1842 1841
 	}
1843 1842
 
@@ -1846,7 +1845,7 @@  discard block
 block discarded – undo
1846 1845
 		// read attachment data from etemplate request, use tmpname only to identify it
1847 1846
 		if (($request = Etemplate\Request::read($_GET['etemplate_exec_id'])))
1848 1847
 		{
1849
-			foreach($request->preserv['attachments'] as $attachment)
1848
+			foreach ($request->preserv['attachments'] as $attachment)
1850 1849
 			{
1851 1850
 				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
1852 1851
 			}
@@ -1858,7 +1857,7 @@  discard block
 block discarded – undo
1858 1857
 		}
1859 1858
 
1860 1859
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
1861
-		if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs')
1860
+		if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs')
1862 1861
 		{
1863 1862
 			Vfs::load_wrapper('vfs');
1864 1863
 		}
@@ -1867,7 +1866,7 @@  discard block
 block discarded – undo
1867 1866
 		{
1868 1867
 			$attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['tmp_name']);
1869 1868
 		}
1870
-		if(!file_exists($attachment['tmp_name']))
1869
+		if (!file_exists($attachment['tmp_name']))
1871 1870
 		{
1872 1871
 			header('HTTP/1.1 404 Not found');
1873 1872
 			die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!');
@@ -1880,7 +1879,7 @@  discard block
 block discarded – undo
1880 1879
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY')
1881 1880
 			{
1882 1881
 				$sfxMimeType = $attachment['type'];
1883
-				$buff = explode('.',$attachment['tmp_name']);
1882
+				$buff = explode('.', $attachment['tmp_name']);
1884 1883
 				$suffix = '';
1885 1884
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1886 1885
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -1892,10 +1891,10 @@  discard block
 block discarded – undo
1892 1891
 			{
1893 1892
 				//error_log(__METHOD__."about to call calendar_ical");
1894 1893
 				$calendar_ical = new calendar_ical();
1895
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1894
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
1896 1895
 				//error_log(__METHOD__.array2string($eventid));
1897 1896
 				if (!$eventid) $eventid = -1;
1898
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1897
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true);
1899 1898
 				//error_log(__METHOD__.$event);
1900 1899
 				if ((int)$event > 0)
1901 1900
 				{
@@ -1903,7 +1902,7 @@  discard block
 block discarded – undo
1903 1902
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
1904 1903
 						'cal_id'      => $event,
1905 1904
 					);
1906
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1905
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1907 1906
 				}
1908 1907
 				//Import failed, download content anyway
1909 1908
 			}
@@ -1918,13 +1917,13 @@  discard block
 block discarded – undo
1918 1917
 				{
1919 1918
 					$vcard['uid'] = trim($vcard['uid']);
1920 1919
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1921
-					$contact = $addressbook_vcal->find_contact($vcard,false);
1920
+					$contact = $addressbook_vcal->find_contact($vcard, false);
1922 1921
 				}
1923 1922
 				if (!$contact) $contact = null;
1924 1923
 				// 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))
1925
-				if ($contact || count($vcard)>2)
1924
+				if ($contact || count($vcard) > 2)
1926 1925
 				{
1927
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true);
1926
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true);
1928 1927
 				}
1929 1928
 				if ((int)$contact > 0)
1930 1929
 				{
@@ -1932,13 +1931,13 @@  discard block
 block discarded – undo
1932 1931
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
1933 1932
 						'contact_id'	=> $contact,
1934 1933
 					);
1935
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1934
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1936 1935
 				}
1937 1936
 				//Import failed, download content anyway
1938 1937
 			}
1939 1938
 		}
1940 1939
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
1941
-		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
1940
+		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save");
1942 1941
 		echo $attachment['attachment'];
1943 1942
 
1944 1943
 		exit();
@@ -1951,11 +1950,11 @@  discard block
 block discarded – undo
1951 1950
 	 * @param string haystack
1952 1951
 	 * @return boolean
1953 1952
 	 */
1954
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
1953
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) {
1955 1954
 		foreach (array_keys($arrayToTestAgainst) as $k)
1956 1955
 		{
1957 1956
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
1958
-			if (stripos($haystack,$k)!==false)
1957
+			if (stripos($haystack, $k) !== false)
1959 1958
 			{
1960 1959
 				//error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace());
1961 1960
 				return true;
@@ -1978,10 +1977,10 @@  discard block
 block discarded – undo
1978 1977
 	 */
1979 1978
 	function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID)
1980 1979
 	{
1981
-		unset($_icServer);	// not used
1980
+		unset($_icServer); // not used
1982 1981
 		$foundAddresses = array();
1983 1982
 
1984
-		$mail_bo  = $this->mail_bo;
1983
+		$mail_bo = $this->mail_bo;
1985 1984
 		$mail_bo->openConnection();
1986 1985
 		$mail_bo->reopen($_folder);
1987 1986
 
@@ -1989,12 +1988,12 @@  discard block
 block discarded – undo
1989 1988
 
1990 1989
 		// get message headers for specified message
1991 1990
 		//print "AAAA: $_folder, $_uid, $_partID<br>";
1992
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true);
1991
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true);
1993 1992
 		//$headers	= $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder);
1994 1993
 		$this->sessionData['uid'] = $_uid;
1995 1994
 		$this->sessionData['messageFolder'] = $_folder;
1996
-		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']);
1997
-		$this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']);
1995
+		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']);
1996
+		$this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']);
1998 1997
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1999 1998
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
2000 1999
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
@@ -2002,36 +2001,36 @@  discard block
 block discarded – undo
2002 2001
 		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2003 2002
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2004 2003
 		// check for Reply-To: header and use if available
2005
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2006
-			foreach($headers['REPLY-TO'] as $val) {
2007
-				if(!$foundAddresses[$val]) {
2004
+		if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2005
+			foreach ($headers['REPLY-TO'] as $val) {
2006
+				if (!$foundAddresses[$val]) {
2008 2007
 					$oldTo[] = $val;
2009 2008
 					$foundAddresses[$val] = true;
2010 2009
 				}
2011 2010
 			}
2012
-			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2011
+			$oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']);
2013 2012
 		} else {
2014
-			foreach($headers['FROM'] as $val) {
2015
-				if(!$foundAddresses[$val]) {
2013
+			foreach ($headers['FROM'] as $val) {
2014
+				if (!$foundAddresses[$val]) {
2016 2015
 					$oldTo[] = $val;
2017 2016
 					$foundAddresses[$val] = true;
2018 2017
 				}
2019 2018
 			}
2020
-			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2019
+			$oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']);
2021 2020
 		}
2022 2021
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2023
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2022
+		if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) {
2024 2023
 			$this->sessionData['to'] = $oldTo;
2025 2024
 		}
2026 2025
 
2027
-		if($_mode == 'all') {
2026
+		if ($_mode == 'all') {
2028 2027
 			// reply to any address which is cc, but not to my self
2029 2028
 			#if($headers->cc) {
2030
-				foreach($headers['CC'] as $val) {
2031
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2029
+				foreach ($headers['CC'] as $val) {
2030
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2032 2031
 						continue;
2033 2032
 					}
2034
-					if(!$foundAddresses[$val]) {
2033
+					if (!$foundAddresses[$val]) {
2035 2034
 						$this->sessionData['cc'][] = $val;
2036 2035
 						$foundAddresses[$val] = true;
2037 2036
 					}
@@ -2040,11 +2039,11 @@  discard block
 block discarded – undo
2040 2039
 
2041 2040
 			// reply to any address which is to, but not to my self
2042 2041
 			#if($headers->to) {
2043
-				foreach($headers['TO'] as $val) {
2044
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2042
+				foreach ($headers['TO'] as $val) {
2043
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2045 2044
 						continue;
2046 2045
 					}
2047
-					if(!$foundAddresses[$val]) {
2046
+					if (!$foundAddresses[$val]) {
2048 2047
 						$this->sessionData['to'][] = $val;
2049 2048
 						$foundAddresses[$val] = true;
2050 2049
 					}
@@ -2052,12 +2051,12 @@  discard block
 block discarded – undo
2052 2051
 			#}
2053 2052
 
2054 2053
 			#if($headers->from) {
2055
-				foreach($headers['FROM'] as $val) {
2056
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2054
+				foreach ($headers['FROM'] as $val) {
2055
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2057 2056
 						continue;
2058 2057
 					}
2059 2058
 					//error_log(__METHOD__.__LINE__.' '.$val);
2060
-					if(!$foundAddresses[$val]) {
2059
+					if (!$foundAddresses[$val]) {
2061 2060
 						$this->sessionData['to'][] = $val;
2062 2061
 						$foundAddresses[$val] = true;
2063 2062
 					}
@@ -2066,59 +2065,59 @@  discard block
 block discarded – undo
2066 2065
 		}
2067 2066
 
2068 2067
 		// check for Re: in subject header
2069
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2068
+		if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2070 2069
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2071 2070
 		} else {
2072
-			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2071
+			$this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']);
2073 2072
 		}
2074 2073
 
2075 2074
 		//_debug_array($headers);
2076 2075
 		//error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions']));
2077
-		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID);
2076
+		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID);
2078 2077
 		//_debug_array($bodyParts);
2079 2078
 		$styles = Mail::getStyles($bodyParts);
2080 2079
 
2081
-		$fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM']));
2080
+		$fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM']));
2082 2081
 
2083 2082
 		$toAddressA = array();
2084 2083
 		$toAddress = '';
2085 2084
 		foreach ($headers['TO'] as $mailheader) {
2086
-			$toAddressA[] =  $mailheader;
2085
+			$toAddressA[] = $mailheader;
2087 2086
 		}
2088
-		if (count($toAddressA)>0)
2087
+		if (count($toAddressA) > 0)
2089 2088
 		{
2090
-			$toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA));
2091
-			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2089
+			$toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA));
2090
+			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2092 2091
 		}
2093 2092
 		$ccAddressA = array();
2094 2093
 		$ccAddress = '';
2095 2094
 		foreach ($headers['CC'] as $mailheader) {
2096
-			$ccAddressA[] =  $mailheader;
2095
+			$ccAddressA[] = $mailheader;
2097 2096
 		}
2098
-		if (count($ccAddressA)>0)
2097
+		if (count($ccAddressA) > 0)
2099 2098
 		{
2100
-			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2101
-			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2099
+			$ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA));
2100
+			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2102 2101
 		}
2103
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2104
-			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2102
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
2103
+			$this->sessionData['body'] = /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2105 2104
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2106 2105
 				$toAddress.$ccAddress.
2107
-				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2106
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>".
2108 2107
 				'----------------------------------------------------------'."</div>";
2109
-			$this->sessionData['mimeType'] 	= 'html';
2108
+			$this->sessionData['mimeType'] = 'html';
2110 2109
 			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2111
-			$this->sessionData['body']	.= '<blockquote type="cite">';
2110
+			$this->sessionData['body'] .= '<blockquote type="cite">';
2112 2111
 
2113
-			for($i=0; $i<count($bodyParts); $i++) {
2114
-				if($i>0) {
2112
+			for ($i = 0; $i < count($bodyParts); $i++) {
2113
+				if ($i > 0) {
2115 2114
 					$this->sessionData['body'] .= '<hr>';
2116 2115
 				}
2117
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2116
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
2118 2117
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2119 2118
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2120 2119
 				}
2121
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2120
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2122 2121
 
2123 2122
 				$_htmlConfig = Mail::$htmLawed_config;
2124 2123
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2128,30 +2127,30 @@  discard block
 block discarded – undo
2128 2127
 				#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2129 2128
 			}
2130 2129
 
2131
-			$this->sessionData['body']	.= '</blockquote><br>';
2132
-			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2130
+			$this->sessionData['body'] .= '</blockquote><br>';
2131
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2133 2132
 		} else {
2134 2133
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2135 2134
 			// 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)
2136
-            $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2135
+            $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2137 2136
                 @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2138 2137
 				$toAddress.$ccAddress.
2139
-				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
2138
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n".
2140 2139
                 '-------------------------------------------------'."\r\n \r\n ";
2141
-			$this->sessionData['mimeType']	= 'plain';
2140
+			$this->sessionData['mimeType'] = 'plain';
2142 2141
 
2143
-			for($i=0; $i<count($bodyParts); $i++) {
2144
-				if($i>0) {
2142
+			for ($i = 0; $i < count($bodyParts); $i++) {
2143
+				if ($i > 0) {
2145 2144
 					$this->sessionData['body'] .= "<hr>";
2146 2145
 				}
2147 2146
 
2148 2147
 				// add line breaks to $bodyParts
2149
-				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
2148
+				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
2150 2149
 				#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2151 2150
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2152 2151
 				$this->sessionData['body'] .= "\r\n";
2153 2152
 				// create body new, with good line breaks and indention
2154
-				foreach(explode("\n",$newBody) as $value) {
2153
+				foreach (explode("\n", $newBody) as $value) {
2155 2154
 					// the explode is removing the character
2156 2155
 					if (trim($value) != '') {
2157 2156
 						#if ($value != "\r") $value .= "\n";
@@ -2159,12 +2158,12 @@  discard block
 block discarded – undo
2159 2158
 					$numberOfChars = strspn(trim($value), ">");
2160 2159
 					$appendString = str_repeat('>', $numberOfChars + 1);
2161 2160
 
2162
-					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2161
+					$bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>');
2163 2162
 
2164
-					if($bodyAppend[0] == '>') {
2165
-						$bodyAppend = '>'. $bodyAppend;
2163
+					if ($bodyAppend[0] == '>') {
2164
+						$bodyAppend = '>'.$bodyAppend;
2166 2165
 					} else {
2167
-						$bodyAppend = '> '. $bodyAppend;
2166
+						$bodyAppend = '> '.$bodyAppend;
2168 2167
 					}
2169 2168
 
2170 2169
 					$this->sessionData['body'] .= $bodyAppend;
@@ -2187,16 +2186,16 @@  discard block
 block discarded – undo
2187 2186
 	 */
2188 2187
 	static function _getCleanHTML($_body, $_useTidy = false)
2189 2188
 	{
2190
-		static $nonDisplayAbleCharacters = array('[\016]','[\017]',
2191
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2192
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2189
+		static $nonDisplayAbleCharacters = array('[\016]', '[\017]',
2190
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2191
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2193 2192
 
2194
-		if ($_useTidy && extension_loaded('tidy') )
2193
+		if ($_useTidy && extension_loaded('tidy'))
2195 2194
 		{
2196 2195
 			$tidy = new tidy();
2197
-			$cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8');
2196
+			$cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8');
2198 2197
 			// Found errors. Strip it all so there's some output
2199
-			if($tidy->getStatus() == 2)
2198
+			if ($tidy->getStatus() == 2)
2200 2199
 			{
2201 2200
 				error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
2202 2201
 			}
@@ -2230,14 +2229,14 @@  discard block
 block discarded – undo
2230 2229
 	 *
2231 2230
 	 * @return array returns found inline images as attachment structure
2232 2231
 	 */
2233
-	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
2232
+	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false)
2234 2233
 	{
2235 2234
 		if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----')
2236 2235
 		{
2237 2236
 			$_formData['mimeType'] = 'openpgp';
2238 2237
 		}
2239 2238
 		//error_log(__METHOD__."(, formDate[filemode]=$_formData[filemode], _autosaving=".array2string($_autosaving).') '.function_backtrace());
2240
-		$mail_bo	= $this->mail_bo;
2239
+		$mail_bo = $this->mail_bo;
2241 2240
 		$activeMailProfile = Mail\Account::read($this->mail_bo->profileID);
2242 2241
 
2243 2242
 		// you need to set the sender, if you work with different identities, since most smtp servers, dont allow
@@ -2247,17 +2246,17 @@  discard block
 block discarded – undo
2247 2246
 			error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity));
2248 2247
 		}
2249 2248
 		$_mailObject->setFrom($_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'],
2250
-			Mail::generateIdentityString($_identity,false));
2249
+			Mail::generateIdentityString($_identity, false));
2251 2250
 
2252 2251
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2253 2252
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2254
-		if(!empty($_formData['in-reply-to'])) {
2255
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2253
+		if (!empty($_formData['in-reply-to'])) {
2254
+			if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>';
2256 2255
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(In-Reply-To', $_formData['in-reply-to'].")");
2257 2256
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2258 2257
 		}
2259
-		if(!empty($_formData['references'])) {
2260
-			if (stripos($_formData['references'],'<')===false) $_formData['references']='<'.trim($_formData['references']).'>';
2258
+		if (!empty($_formData['references'])) {
2259
+			if (stripos($_formData['references'], '<') === false) $_formData['references'] = '<'.trim($_formData['references']).'>';
2261 2260
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(References', $_formData['references'].")");
2262 2261
 			$_mailObject->addHeader('References', $_formData['references']);
2263 2262
 		}
@@ -2268,16 +2267,16 @@  discard block
 block discarded – undo
2268 2267
 		//	$_mailObject->addHeader('Thread-Topic', $_formData['thread-topic']);
2269 2268
 		//}
2270 2269
 
2271
-		if(!empty($_formData['thread-index'])) {
2270
+		if (!empty($_formData['thread-index'])) {
2272 2271
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(Tread-Index', $_formData['thread-index'].")");
2273 2272
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2274 2273
 		}
2275
-		if(!empty($_formData['list-id'])) {
2274
+		if (!empty($_formData['list-id'])) {
2276 2275
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(List-Id', $_formData['list-id'].")");
2277 2276
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2278 2277
 		}
2279 2278
 		//error_log(__METHOD__.__LINE__.' notify to:'.$_identity['ident_email'].'->'.array2string($_formData));
2280
-		if($_formData['disposition']=='on') {
2279
+		if ($_formData['disposition'] == 'on') {
2281 2280
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2282 2281
 		}
2283 2282
 		//error_log(__METHOD__.__LINE__.' Organization:'.array2string($_identity));
@@ -2286,7 +2285,7 @@  discard block
 block discarded – undo
2286 2285
 		//}
2287 2286
 
2288 2287
 		// Expand any mailing lists
2289
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2288
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $field)
2290 2289
 		{
2291 2290
 			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2292 2291
 
@@ -2309,7 +2308,7 @@  discard block
 block discarded – undo
2309 2308
 					'1' => 'before reply, visible during compose',
2310 2309
 					'no_belowaftersend'  => 'appended after reply before sending',
2311 2310
 		*/
2312
-		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0;
2311
+		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0;
2313 2312
 		if ($sigAlreadyThere)
2314 2313
 		{
2315 2314
 			// note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature
@@ -2318,7 +2317,7 @@  discard block
 block discarded – undo
2318 2317
 		}
2319 2318
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
2320 2319
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
2321
-			empty($signature) || trim($this->convertHTMLToText($signature)) =='')
2320
+			empty($signature) || trim($this->convertHTMLToText($signature)) == '')
2322 2321
 		{
2323 2322
 			$disableRuler = true;
2324 2323
 		}
@@ -2335,7 +2334,7 @@  discard block
 block discarded – undo
2335 2334
 				array_unique(array_merge((array)$_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc'])),
2336 2335
 				$_formData['expiration'], $_formData['password']);
2337 2336
 		}
2338
-		if($_formData['mimeType'] == 'html')
2337
+		if ($_formData['mimeType'] == 'html')
2339 2338
 		{
2340 2339
 			$body = $_formData['body'];
2341 2340
 			if ($attachment_links)
@@ -2349,13 +2348,13 @@  discard block
 block discarded – undo
2349 2348
 					$body .= $attachment_links;
2350 2349
 				}
2351 2350
 			}
2352
-			if(!empty($signature))
2351
+			if (!empty($signature))
2353 2352
 			{
2354 2353
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true).
2355 2354
 					($disableRuler ? "\r\n" : "\r\n-- \r\n").
2356 2355
 					$this->convertHTMLToText($signature, true, true));
2357 2356
 
2358
-				$body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature;
2357
+				$body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature;
2359 2358
 			}
2360 2359
 			else
2361 2360
 			{
@@ -2363,11 +2362,11 @@  discard block
 block discarded – undo
2363 2362
 			}
2364 2363
 			// convert URL Images to inline images - if possible
2365 2364
 			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2366
-			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2365
+			if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false)
2367 2366
 			{
2368
-				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
2367
+				$body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body);
2369 2368
 			}
2370
-			$_mailObject->setHtmlBody($body, null, false);	// false = no automatic alternative, we called setBody()
2369
+			$_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody()
2371 2370
 		}
2372 2371
 		elseif ($_formData['mimeType'] == 'openpgp')
2373 2372
 		{
@@ -2375,14 +2374,14 @@  discard block
 block discarded – undo
2375 2374
 		}
2376 2375
 		else
2377 2376
 		{
2378
-			$body = $this->convertHTMLToText($_formData['body'],false);
2377
+			$body = $this->convertHTMLToText($_formData['body'], false);
2379 2378
 
2380 2379
 			if ($attachment_links) $body .= $attachment_links;
2381 2380
 
2382 2381
 			#$_mailObject->Body = $_formData['body'];
2383
-			if(!empty($signature)) {
2384
-				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2385
-					$this->convertHTMLToText($signature,true,true);
2382
+			if (!empty($signature)) {
2383
+				$body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n").
2384
+					$this->convertHTMLToText($signature, true, true);
2386 2385
 			}
2387 2386
 			$_mailObject->setBody($body);
2388 2387
 		}
@@ -2393,9 +2392,9 @@  discard block
 block discarded – undo
2393 2392
 			$connection_opened = false;
2394 2393
 			//error_log(__METHOD__.__LINE__.array2string($_formData['attachments']));
2395 2394
 			$tnfattachments = null;
2396
-			foreach((array)$_formData['attachments'] as $attachment) {
2395
+			foreach ((array)$_formData['attachments'] as $attachment) {
2397 2396
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2398
-				if(is_array($attachment))
2397
+				if (is_array($attachment))
2399 2398
 				{
2400 2399
 					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2401 2400
 						/* Example:
@@ -2413,20 +2412,20 @@  discard block
 block discarded – undo
2413 2412
 							$connection_opened = true;
2414 2413
 						}
2415 2414
 						$mail_bo->reopen($attachment['folder']);
2416
-						switch(strtoupper($attachment['type'])) {
2415
+						switch (strtoupper($attachment['type'])) {
2417 2416
 							case 'MESSAGE/RFC':
2418 2417
 							case 'MESSAGE/RFC822':
2419
-								$rawBody='';
2418
+								$rawBody = '';
2420 2419
 								if (isset($attachment['partID'])) {
2421
-									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2422
-									$rawBody=$eml['attachment'];
2420
+									$eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']);
2421
+									$rawBody = $eml['attachment'];
2423 2422
 								} else {
2424
-									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2423
+									$rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']);
2425 2424
 								}
2426 2425
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
2427 2426
 								break;
2428 2427
 							default:
2429
-								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2428
+								$attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false);
2430 2429
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2431 2430
 								{
2432 2431
 									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
@@ -2434,7 +2433,7 @@  discard block
 block discarded – undo
2434 2433
 									{
2435 2434
 										if ($k['name'] == $attachment['name'])
2436 2435
 										{
2437
-											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']);
2436
+											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']);
2438 2437
 											$attachmentData['attachment'] = $tnfpart['attachment'];
2439 2438
 											//error_log(__METHOD__.__LINE__.$k['name'].'<->'.$attachment['name'].':'.array2string($attachmentData['attachment']));
2440 2439
 											break;
@@ -2448,7 +2447,7 @@  discard block
 block discarded – undo
2448 2447
 					// attach files not for autosaving
2449 2448
 					elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving)
2450 2449
 					{
2451
-						if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
2450
+						if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs')
2452 2451
 						{
2453 2452
 							Vfs::load_wrapper('vfs');
2454 2453
 							$tmp_path = $attachment['file'];
@@ -2457,7 +2456,7 @@  discard block
 block discarded – undo
2457 2456
 						{
2458 2457
 							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['file']);
2459 2458
 						}
2460
-						$_mailObject->addAttachment (
2459
+						$_mailObject->addAttachment(
2461 2460
 							$tmp_path,
2462 2461
 							$attachment['name'],
2463 2462
 							$attachment['type']
@@ -2467,7 +2466,7 @@  discard block
 block discarded – undo
2467 2466
 			}
2468 2467
 			if ($connection_opened) $mail_bo->closeConnection();
2469 2468
 		}
2470
-		return is_array($inline_images)?$inline_images:array();
2469
+		return is_array($inline_images) ? $inline_images : array();
2471 2470
 	}
2472 2471
 
2473 2472
 	/**
@@ -2483,16 +2482,16 @@  discard block
 block discarded – undo
2483 2482
 	 * @param string $password =null
2484 2483
 	 * @return string might be empty if no file attachments found
2485 2484
 	 */
2486
-	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2485
+	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null)
2487 2486
 	{
2488 2487
 		if ($filemode == Vfs\Sharing::ATTACH) return '';
2489 2488
 
2490 2489
 		$links = array();
2491
-		foreach($attachments as $attachment)
2490
+		foreach ($attachments as $attachment)
2492 2491
 		{
2493 2492
 			$path = $attachment['file'];
2494
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2495
-			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2493
+			if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts
2494
+			if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs')
2496 2495
 			{
2497 2496
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
2498 2497
 			}
@@ -2522,7 +2521,7 @@  discard block
 block discarded – undo
2522 2521
 		}
2523 2522
 		if (!$links)
2524 2523
 		{
2525
-			return null;	// no file attachments found
2524
+			return null; // no file attachments found
2526 2525
 		}
2527 2526
 		elseif ($html)
2528 2527
 		{
@@ -2537,7 +2536,7 @@  discard block
 block discarded – undo
2537 2536
 	 * @param array $content content sent from client-side
2538 2537
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2539 2538
 	 */
2540
-	public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
2539
+	public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]')
2541 2540
 	{
2542 2541
 		//error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)");
2543 2542
 		$response = Api\Json\Response::get();
@@ -2551,8 +2550,8 @@  discard block
 block discarded – undo
2551 2550
 
2552 2551
 		$formData = array_merge($content, array(
2553 2552
 			'isDrafted' => 1,
2554
-			'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')],
2555
-			'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value
2553
+			'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')],
2554
+			'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value
2556 2555
 		));
2557 2556
 
2558 2557
 		//Saving draft procedure
@@ -2564,8 +2563,8 @@  discard block
 block discarded – undo
2564 2563
 			if (($messageUid = $this->saveAsDraft($formData, $folder, $action)))
2565 2564
 			{
2566 2565
 				// saving as draft, does not mean closing the message
2567
-				$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
2568
-				if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder)))
2566
+				$messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid);
2567
+				if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder)))
2569 2568
 				{
2570 2569
 					$draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid);
2571 2570
 					if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted']))
@@ -2574,7 +2573,7 @@  discard block
 block discarded – undo
2574 2573
 						$duid = $dhA['msgUID'];
2575 2574
 						$dmailbox = $dhA['folder'];
2576 2575
 						// beware: do not delete the original mail as found in processedmail_id
2577
-						$pMuid='';
2576
+						$pMuid = '';
2578 2577
 						if ($content['processedmail_id'])
2579 2578
 						{
2580 2579
 							$pMhA = mail_ui::splitRowID($content['processedmail_id']);
@@ -2582,15 +2581,15 @@  discard block
 block discarded – undo
2582 2581
 						}
2583 2582
 						//error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments']));
2584 2583
 						// do not delete the original message if attachments are present
2585
-						if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments']))
2584
+						if (empty($pMuid) || $pMuid != $duid || empty($content['attachments']))
2586 2585
 						{
2587 2586
 							try
2588 2587
 							{
2589
-								$this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately');
2588
+								$this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately');
2590 2589
 							}
2591 2590
 							catch (Api\Exception $e)
2592 2591
 							{
2593
-								$msg = str_replace('"',"'",$e->getMessage());
2592
+								$msg = str_replace('"', "'", $e->getMessage());
2594 2593
 								$success = false;
2595 2594
 								error_log(__METHOD__.__LINE__.$msg);
2596 2595
 							}
@@ -2611,7 +2610,7 @@  discard block
 block discarded – undo
2611 2610
 		}
2612 2611
 		catch (Api\Exception\WrongUserinput $e)
2613 2612
 		{
2614
-			$msg = str_replace('"',"'",$e->getMessage());
2613
+			$msg = str_replace('"', "'", $e->getMessage());
2615 2614
 			error_log(__METHOD__.__LINE__.$msg);
2616 2615
 			$success = false;
2617 2616
 		}
@@ -2635,17 +2634,17 @@  discard block
 block discarded – undo
2635 2634
 	static function resolveEmailAddressList($_emailAddressList)
2636 2635
 	{
2637 2636
 		$contacts_obs = null;
2638
-		$addrFromList=array();
2639
-		foreach((array)$_emailAddressList as $ak => $address)
2637
+		$addrFromList = array();
2638
+		foreach ((array)$_emailAddressList as $ak => $address)
2640 2639
 		{
2641
-			if(is_int($address))
2640
+			if (is_int($address))
2642 2641
 			{
2643 2642
 				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
2644 2643
 				// List was selected, expand to addresses
2645 2644
 				unset($_emailAddressList[$ak]);
2646
-				$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));
2645
+				$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));
2647 2646
 				// Just add email addresses, they'll be checked below
2648
-				foreach($list as $email)
2647
+				foreach ($list as $email)
2649 2648
 				{
2650 2649
 					$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
2651 2650
 				}
@@ -2655,7 +2654,7 @@  discard block
 block discarded – undo
2655 2654
 		{
2656 2655
 			foreach ($addrFromList as $addr)
2657 2656
 			{
2658
-				if (!empty($addr)) $_emailAddressList[]=$addr;
2657
+				if (!empty($addr)) $_emailAddressList[] = $addr;
2659 2658
 			}
2660 2659
 		}
2661 2660
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2669,15 +2668,15 @@  discard block
 block discarded – undo
2669 2668
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2670 2669
 	 * @return boolean return messageUID| false due to an error
2671 2670
 	 */
2672
-	function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]')
2671
+	function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]')
2673 2672
 	{
2674 2673
 		//error_log(__METHOD__."(..., $savingDestination, action=$action)");
2675
-		$mail_bo	= $this->mail_bo;
2676
-		$mail		= new Api\Mailer($this->mail_bo->profileID);
2674
+		$mail_bo = $this->mail_bo;
2675
+		$mail = new Api\Mailer($this->mail_bo->profileID);
2677 2676
 
2678 2677
 		// preserve the bcc and if possible the save to folder information
2679
-		$this->sessionData['folder']    = $_formData['folder'];
2680
-		$this->sessionData['bcc']   = $_formData['bcc'];
2678
+		$this->sessionData['folder'] = $_formData['folder'];
2679
+		$this->sessionData['bcc'] = $_formData['bcc'];
2681 2680
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2682 2681
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2683 2682
 		$this->sessionData['mailaccount']  = $_formData['mailaccount'];
@@ -2686,11 +2685,11 @@  discard block
 block discarded – undo
2686 2685
 		{
2687 2686
 			$acc = Mail\Account::read($this->sessionData['mailaccount']);
2688 2687
 			//error_log(__METHOD__.__LINE__.array2string($acc));
2689
-			$identity = Mail\Account::read_identity($acc['ident_id'],true);
2688
+			$identity = Mail\Account::read_identity($acc['ident_id'], true);
2690 2689
 		}
2691 2690
 		catch (Exception $e)
2692 2691
 		{
2693
-			$identity=array();
2692
+			$identity = array();
2694 2693
 		}
2695 2694
 
2696 2695
 		$flags = '\\Seen \\Draft';
@@ -2700,7 +2699,7 @@  discard block
 block discarded – undo
2700 2699
 		// folder list as Customheader
2701 2700
 		if (!empty($this->sessionData['folder']))
2702 2701
 		{
2703
-			$folders = implode('|',array_unique($this->sessionData['folder']));
2702
+			$folders = implode('|', array_unique($this->sessionData['folder']));
2704 2703
 			$mail->addHeader('X-Mailfolder', $folders);
2705 2704
 		}
2706 2705
 		$mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']);
@@ -2720,25 +2719,25 @@  discard block
 block discarded – undo
2720 2719
 			$savingDestination = $this->sessionData['messageFolder'];
2721 2720
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2722 2721
 		}
2723
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
2722
+		if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder();
2724 2723
 
2725 2724
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2726 2725
 		$mail->forceBccHeader();
2727 2726
 
2728 2727
 		$mail_bo->openConnection();
2729
-		if ($mail_bo->folderExists($savingDestination,true)) {
2728
+		if ($mail_bo->folderExists($savingDestination, true)) {
2730 2729
 			try
2731 2730
 			{
2732 2731
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
2733 2732
 			}
2734 2733
 			catch (Api\Exception\WrongUserinput $e)
2735 2734
 			{
2736
-				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage()));
2735
+				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage()));
2737 2736
 				return false;
2738 2737
 			}
2739 2738
 
2740 2739
 		} else {
2741
-			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2740
+			error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server."));
2742 2741
 			return false;
2743 2742
 		}
2744 2743
 		$mail_bo->closeConnection();
@@ -2747,26 +2746,26 @@  discard block
 block discarded – undo
2747 2746
 
2748 2747
 	function send($_formData)
2749 2748
 	{
2750
-		$mail_bo	= $this->mail_bo;
2751
-		$mail 		= new Api\Mailer($mail_bo->profileID);
2752
-		$messageIsDraft	=  false;
2749
+		$mail_bo = $this->mail_bo;
2750
+		$mail = new Api\Mailer($mail_bo->profileID);
2751
+		$messageIsDraft = false;
2753 2752
 
2754
-		$this->sessionData['mailaccount']	= $_formData['mailaccount'];
2753
+		$this->sessionData['mailaccount'] = $_formData['mailaccount'];
2755 2754
 		$this->sessionData['to']	= self::resolveEmailAddressList($_formData['to']);
2756 2755
 		$this->sessionData['cc']	= self::resolveEmailAddressList($_formData['cc']);
2757
-		$this->sessionData['bcc']	= self::resolveEmailAddressList($_formData['bcc']);
2758
-		$this->sessionData['folder']	= $_formData['folder'];
2756
+		$this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']);
2757
+		$this->sessionData['folder'] = $_formData['folder'];
2759 2758
 		$this->sessionData['replyto']	= $_formData['replyto'];
2760 2759
 		$this->sessionData['subject']	= trim($_formData['subject']);
2761
-		$this->sessionData['body']	= $_formData['body'];
2762
-		$this->sessionData['priority']	= $_formData['priority'];
2760
+		$this->sessionData['body'] = $_formData['body'];
2761
+		$this->sessionData['priority'] = $_formData['priority'];
2763 2762
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2764 2763
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2765 2764
 		$this->sessionData['disposition'] = $_formData['disposition'];
2766
-		$this->sessionData['mimeType']	= $_formData['mimeType'];
2765
+		$this->sessionData['mimeType'] = $_formData['mimeType'];
2767 2766
 		$this->sessionData['to_infolog'] = $_formData['to_infolog'];
2768 2767
 		$this->sessionData['to_tracker'] = $_formData['to_tracker'];
2769
-		$this->sessionData['attachments']  = $_formData['attachments'];
2768
+		$this->sessionData['attachments'] = $_formData['attachments'];
2770 2769
 
2771 2770
 		if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted']))
2772 2771
 		{
@@ -2775,11 +2774,11 @@  discard block
 block discarded – undo
2775 2774
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']);
2776 2775
 		if (isset($_formData['mode']) && !empty($_formData['mode']))
2777 2776
 		{
2778
-			if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id']))
2777
+			if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id']))
2779 2778
 			{
2780
-				$this->sessionData['forwardFlag']='forwarded';
2781
-				$_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']);
2782
-				$this->sessionData['uid']=array();
2779
+				$this->sessionData['forwardFlag'] = 'forwarded';
2780
+				$_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']);
2781
+				$this->sessionData['uid'] = array();
2783 2782
 				foreach ($_formData['processedmail_id'] as $k =>$rowid)
2784 2783
 				{
2785 2784
 					$fhA = mail_ui::splitRowID($rowid);
@@ -2788,13 +2787,13 @@  discard block
 block discarded – undo
2788 2787
 					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
2789 2788
 				}
2790 2789
 			}
2791
-			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
2790
+			if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id']))
2792 2791
 			{
2793 2792
 				$rhA = mail_ui::splitRowID($_formData['processedmail_id']);
2794 2793
 				$this->sessionData['uid'] = $rhA['msgUID'];
2795 2794
 				$this->sessionData['messageFolder'] = $rhA['folder'];
2796 2795
 			}
2797
-			if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id']))
2796
+			if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id']))
2798 2797
 			{
2799 2798
 				$dhA = mail_ui::splitRowID($_formData['processedmail_id']);
2800 2799
 				$this->sessionData['uid'] = $dhA['msgUID'];
@@ -2803,26 +2802,26 @@  discard block
 block discarded – undo
2803 2802
 		}
2804 2803
 		// if the body is empty, maybe someone pasted something with scripts, into the message body
2805 2804
 		// this should not happen anymore, unless you call send directly, since the check was introduced with the action command
2806
-		if(empty($this->sessionData['body']))
2805
+		if (empty($this->sessionData['body']))
2807 2806
 		{
2808 2807
 			// this is to be found with the egw_unset_vars array for the _POST['body'] array
2809
-			$name='_POST';
2810
-			$key='body';
2808
+			$name = '_POST';
2809
+			$key = 'body';
2811 2810
 			#error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2812 2811
 			if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']']))
2813 2812
 			{
2814
-				$this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2815
-				$_formData['body']=$this->sessionData['body'];
2813
+				$this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2814
+				$_formData['body'] = $this->sessionData['body'];
2816 2815
 			}
2817 2816
 			#error_log($this->sessionData['body']);
2818 2817
 		}
2819
-		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2818
+		if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2820 2819
 		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
2821 2820
 		   	$messageIsDraft = true;
2822 2821
 		}
2823 2822
 		try
2824 2823
 		{
2825
-			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true);
2824
+			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true);
2826 2825
 		}
2827 2826
 		catch (Exception $e)
2828 2827
 		{
@@ -2833,7 +2832,7 @@  discard block
 block discarded – undo
2833 2832
 		// create the messages and store inline images
2834 2833
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2835 2834
 		// remember the identity
2836
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2835
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2837 2836
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2838 2837
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2839 2838
 		#exit;
@@ -2844,12 +2843,12 @@  discard block
 block discarded – undo
2844 2843
 		$folderOnMailAccount = array();
2845 2844
 		foreach ($folderToCheck as $k => $f)
2846 2845
 		{
2847
-			$fval=$f;
2848
-			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2849
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
2850
-			if ($_formData['serverID']!=$_formData['mailaccount'])
2846
+			$fval = $f;
2847
+			$icServerID = $_formData['serverID']; //folders always assumed with serverID
2848
+			if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2);
2849
+			if ($_formData['serverID'] != $_formData['mailaccount'])
2851 2850
 			{
2852
-				if ($icServerID == $_formData['serverID'] )
2851
+				if ($icServerID == $_formData['serverID'])
2853 2852
 				{
2854 2853
 					$folder[$fval] = $fval;
2855 2854
 					$folderOnServerID[] = $fval;
@@ -2862,7 +2861,7 @@  discard block
 block discarded – undo
2862 2861
 			}
2863 2862
 			else
2864 2863
 			{
2865
-				if ($icServerID == $_formData['serverID'] )
2864
+				if ($icServerID == $_formData['serverID'])
2866 2865
 				{
2867 2866
 					$folder[$fval] = $fval;
2868 2867
 					$folderOnServerID[] = $fval;
@@ -2879,7 +2878,7 @@  discard block
 block discarded – undo
2879 2878
 		// we use the sentFolder settings of the choosen mailaccount
2880 2879
 		// sentFolder is account specific
2881 2880
 		$changeProfileOnSentFolderNeeded = false;
2882
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2881
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2883 2882
 		{
2884 2883
 			$this->changeProfile($_formData['mailaccount']);
2885 2884
 			//error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#');
@@ -2887,30 +2886,30 @@  discard block
 block discarded – undo
2887 2886
 			// sentFolder is account specific
2888 2887
 			$sentFolder = $this->mail_bo->getSentFolder();
2889 2888
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2890
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2889
+			if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2891 2890
 		}
2892 2891
 		else
2893 2892
 		{
2894 2893
 			$sentFolder = $mail_bo->getSentFolder();
2895 2894
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2896
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2895
+			if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2897 2896
 		}
2898 2897
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2899 2898
 
2900 2899
 		// we switch $this->mail_bo back to the account we used to work on
2901
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2900
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2902 2901
 		{
2903 2902
 			$this->changeProfile($_formData['serverID']);
2904 2903
 		}
2905 2904
 
2906 2905
 
2907
-		if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2906
+		if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2908 2907
 			$this->mailPreferences['sendOptions'] != 'send_only' &&
2909 2908
 			$messageIsDraft == false)
2910 2909
 		{
2911 2910
 			if ($sentFolder)
2912 2911
 			{
2913
-				if ($_formData['serverID']!=$_formData['mailaccount'])
2912
+				if ($_formData['serverID'] != $_formData['mailaccount'])
2914 2913
 				{
2915 2914
 					$folderOnMailAccount[] = $sentFolder;
2916 2915
 				}
@@ -2927,14 +2926,14 @@  discard block
 block discarded – undo
2927 2926
 		}
2928 2927
 		else
2929 2928
 		{
2930
-			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2929
+			if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2931 2930
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2932 2931
 				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
2933 2932
 		}
2934 2933
 		// draftFolder is on Server we start from
2935
-		if($messageIsDraft == true) {
2934
+		if ($messageIsDraft == true) {
2936 2935
 			$draftFolder = $mail_bo->getDraftFolder();
2937
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
2936
+			if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) {
2938 2937
 				$this->sessionData['folder'] = array($draftFolder);
2939 2938
 				$folderOnServerID[] = $draftFolder;
2940 2939
 				$folder[$draftFolder] = $draftFolder;
@@ -2943,10 +2942,10 @@  discard block
 block discarded – undo
2943 2942
 		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2944 2943
 		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
2945 2944
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2946
-			!( count($folder) > 0) &&
2947
-			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
2945
+			!(count($folder) > 0) &&
2946
+			!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on'))
2948 2947
 		{
2949
-			$this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo?' '.$this->errorInfo:'');
2948
+			$this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo ? ' '.$this->errorInfo : '');
2950 2949
 			#error_log($this->errorInfo);
2951 2950
 			return false;
2952 2951
 		}
@@ -2955,18 +2954,18 @@  discard block
 block discarded – undo
2955 2954
 		@set_time_limit(120);
2956 2955
 		//$mail->SMTPDebug = 10;
2957 2956
 		//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']));
2958
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2957
+		if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2959 2958
 			try {
2960 2959
 				$mail->send();
2961 2960
 			}
2962
-			catch(Exception $e) {
2961
+			catch (Exception $e) {
2963 2962
 				_egw_log_exception($e);
2964 2963
 				//if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details));
2965
-				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2964
+				$this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : '');
2966 2965
 				return false;
2967 2966
 			}
2968 2967
 		} else {
2969
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
2968
+			if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) {
2970 2969
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2971 2970
 			} else {
2972 2971
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
@@ -2994,15 +2993,15 @@  discard block
 block discarded – undo
2994 2993
 		// copying mail to folder
2995 2994
 		if (count($folder) > 0)
2996 2995
 		{
2997
-			foreach($folderOnServerID as $folderName) {
2996
+			foreach ($folderOnServerID as $folderName) {
2998 2997
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
2999 2998
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3000 2999
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3001 3000
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3002
-				if ($mail_bo->folderExists($folderName,true)) {
3003
-					if($mail_bo->isSentFolder($folderName)) {
3001
+				if ($mail_bo->folderExists($folderName, true)) {
3002
+					if ($mail_bo->isSentFolder($folderName)) {
3004 3003
 						$flags = '\\Seen';
3005
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3004
+					} elseif ($mail_bo->isDraftFolder($folderName)) {
3006 3005
 						$flags = '\\Draft';
3007 3006
 					} else {
3008 3007
 						$flags = '\\Seen';
@@ -3018,25 +3017,25 @@  discard block
 block discarded – undo
3018 3017
 					}
3019 3018
 					catch (Api\Exception\WrongUserinput $e)
3020 3019
 					{
3021
-						error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage()));
3020
+						error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage()));
3022 3021
 					}
3023 3022
 				}
3024 3023
 				else
3025 3024
 				{
3026
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3025
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3027 3026
 				}
3028 3027
 			}
3029 3028
 			// if we choose to send from a differing profile
3030 3029
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3031
-			foreach($folderOnMailAccount as $folderName) {
3030
+			foreach ($folderOnMailAccount as $folderName) {
3032 3031
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3033 3032
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3034 3033
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3035 3034
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3036
-				if ($this->mail_bo->folderExists($folderName,true)) {
3037
-					if($this->mail_bo->isSentFolder($folderName)) {
3035
+				if ($this->mail_bo->folderExists($folderName, true)) {
3036
+					if ($this->mail_bo->isSentFolder($folderName)) {
3038 3037
 						$flags = '\\Seen';
3039
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3038
+					} elseif ($this->mail_bo->isDraftFolder($folderName)) {
3040 3039
 						$flags = '\\Draft';
3041 3040
 					} else {
3042 3041
 						$flags = '\\Seen';
@@ -3052,12 +3051,12 @@  discard block
 block discarded – undo
3052 3051
 					}
3053 3052
 					catch (Api\Exception\WrongUserinput $e)
3054 3053
 					{
3055
-						error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage()));
3054
+						error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage()));
3056 3055
 					}
3057 3056
 				}
3058 3057
 				else
3059 3058
 				{
3060
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3059
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3061 3060
 				}
3062 3061
 			}
3063 3062
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
@@ -3068,27 +3067,27 @@  discard block
 block discarded – undo
3068 3067
 		$lastDrafted = false;
3069 3068
 		if (isset($this->sessionData['lastDrafted']))
3070 3069
 		{
3071
-			$lastDrafted=array();
3070
+			$lastDrafted = array();
3072 3071
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3073 3072
 			$lastDrafted['uid'] = $dhA['msgUID'];
3074 3073
 			$lastDrafted['folder'] = $dhA['folder'];
3075
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3074
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']);
3076 3075
 			// manually drafted, do not delete
3077 3076
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3078
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3077
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false;
3079 3078
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3080 3079
 		}
3081 3080
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
3082 3081
 		{
3083 3082
 			try
3084 3083
 			{
3085
-				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' &&
3086
-					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments']))
3084
+				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' &&
3085
+					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3087 3086
 				{
3088 3087
 					//error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData));
3089 3088
 					//error_log(__METHOD__.__LINE__."#".array2string($_formData));
3090 3089
 					//error_log(__METHOD__.__LINE__."#".array2string($this->sessionData));
3091
-					$mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately');
3090
+					$mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately');
3092 3091
 				}
3093 3092
 			}
3094 3093
 			catch (Api\Exception $e)
@@ -3100,22 +3099,22 @@  discard block
 block discarded – undo
3100 3099
 		unset($this->sessionData['lastDrafted']);
3101 3100
 
3102 3101
 		//error_log("handling draft messages, flagging and such");
3103
-		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3102
+		if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3104 3103
 			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3105 3104
 			// mark message as answered
3106 3105
 			$mail_bo->openConnection();
3107
-			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3106
+			$mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3108 3107
 			// if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send
3109 3108
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
3110 3109
 			if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder']))
3111 3110
 			{
3112 3111
 				try // message may be deleted already, as it maybe done by autosave
3113 3112
 				{
3114
-					if ($_formData['mode']=='composefromdraft' &&
3113
+					if ($_formData['mode'] == 'composefromdraft' &&
3115 3114
 						!(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3116 3115
 					{
3117 3116
 						//error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']);
3118
-						$mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']);
3117
+						$mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder']);
3119 3118
 					}
3120 3119
 				}
3121 3120
 				catch (Api\Exception $e)
@@ -3124,14 +3123,14 @@  discard block
 block discarded – undo
3124 3123
 					unset($e);
3125 3124
 				}
3126 3125
 			} else {
3127
-				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3126
+				$mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3128 3127
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3129
-				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
3128
+				if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded')
3130 3129
 				{
3131 3130
 					try
3132 3131
 					{
3133 3132
 						//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3134
-						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']);
3133
+						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']);
3135 3134
 					}
3136 3135
 					catch (Api\Exception $e)
3137 3136
 					{
@@ -3159,49 +3158,49 @@  discard block
 block discarded – undo
3159 3158
 		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3160 3159
 		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3161 3160
 
3162
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3161
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on')
3163 3162
 		{
3164 3163
 			$this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images);
3165 3164
 
3166
-			foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
3165
+			foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key)
3167 3166
 			{
3168 3167
 				$entryid = $_formData['to_integrate_ids'][0][$app_key];
3169 3168
 				if ($_formData[$app_key] == 'on')
3170 3169
 				{
3171
-					$app_name = substr($app_key,3);
3170
+					$app_name = substr($app_key, 3);
3172 3171
 					// Get registered hook data of the app called for integration
3173
-					$hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name);
3172
+					$hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name);
3174 3173
 
3175 3174
 					// store mail / eml in temp. file to not have to download it from mail-server again
3176
-					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
3175
+					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate');
3177 3176
 					$eml_fp = fopen($eml, 'w');
3178 3177
 					stream_copy_to_stream($mail->getRaw(), $eml_fp);
3179 3178
 					fclose($eml_fp);
3180 3179
 					$target = array(
3181 3180
 						'menuaction' => $hook['menuaction'],
3182
-						'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
3181
+						'egw_data' => Link::set_data(null, 'mail_integration::integrate', array(
3183 3182
 							$mailaddresses,
3184 3183
 							$this->sessionData['subject'],
3185 3184
 							$this->convertHTMLToText($this->sessionData['body']),
3186 3185
 							$this->sessionData['attachments'],
3187 3186
 							false, // date
3188 3187
 							$eml,
3189
-							$_formData['serverID']),true),
3188
+							$_formData['serverID']), true),
3190 3189
 						'app' => $app_name
3191 3190
 					);
3192 3191
 					if ($entryid) $target['entry_id'] = $entryid;
3193 3192
 					// Open the app called for integration in a popup
3194 3193
 					// and store the mail raw data as egw_data, in order to
3195 3194
 					// be stored from registered app method later
3196
-					Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']);
3195
+					Framework::popup(Egw::link('/index.php', $target), '_blank', $hook['popup']);
3197 3196
 				}
3198 3197
 			}
3199 3198
 		}
3200 3199
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3201
-		elseif(is_array($this->sessionData['attachments']))
3200
+		elseif (is_array($this->sessionData['attachments']))
3202 3201
 		{
3203
-			foreach($this->sessionData['attachments'] as $value) {
3204
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3202
+			foreach ($this->sessionData['attachments'] as $value) {
3203
+				if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3205 3204
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3206 3205
 				}
3207 3206
 			}
@@ -3218,7 +3217,7 @@  discard block
 block discarded – undo
3218 3217
 	 * @param array $content
3219 3218
 	 * @return array - the input, enriched with some not set attributes
3220 3219
 	 */
3221
-	function setDefaults($content=array())
3220
+	function setDefaults($content = array())
3222 3221
 	{
3223 3222
 		// if there's not already an identity selected for current account
3224 3223
 		if (empty($content['mailidentity']))
@@ -3227,7 +3226,7 @@  discard block
 block discarded – undo
3227 3226
 			if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
3228 3227
 			{
3229 3228
 				$sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'];
3230
-				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0)
3229
+				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0)
3231 3230
 				{
3232 3231
 					$content['mailidentity'] = $sigPref[$this->mail_bo->profileID];
3233 3232
 				}
@@ -3236,7 +3235,7 @@  discard block
 block discarded – undo
3236 3235
 			if (empty($content['mailidentity']))
3237 3236
 			{
3238 3237
 				$default_identity = null;
3239
-				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3238
+				foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3240 3239
 				{
3241 3240
 					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3242 3241
 					if (!empty($identity['ident_signature']))
@@ -3251,7 +3250,7 @@  discard block
 block discarded – undo
3251 3250
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3252 3251
 		{
3253 3252
 			$content['mimeType'] = 'html';
3254
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3253
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain';
3255 3254
 		}
3256 3255
 		return $content;
3257 3256
 
@@ -3274,7 +3273,7 @@  discard block
 block discarded – undo
3274 3273
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3275 3274
 	 * @return type
3276 3275
 	 */
3277
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3276
+	function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) {
3278 3277
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3279 3278
 		static $useCacheIfPossible = null;
3280 3279
 		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
@@ -3287,36 +3286,36 @@  discard block
 block discarded – undo
3287 3286
 		{
3288 3287
 			$this->changeProfile($_mailaccountToSearch);
3289 3288
 		}
3290
-		if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer))
3289
+		if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer))
3291 3290
 		{
3292 3291
 			//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
3293 3292
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3294 3293
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3295
-			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3296
-			if (count($folderObjects)<=1) {
3294
+			$folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible);
3295
+			if (count($folderObjects) <= 1) {
3297 3296
 				$useCacheIfPossible = false;
3298 3297
 			}
3299 3298
 			else
3300 3299
 			{
3301 3300
 				$useCacheIfPossible = true;
3302 3301
 			}
3303
-			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
3302
+			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP');
3304 3303
 			foreach ($folderObjects as $k =>$fA)
3305 3304
 			{
3306 3305
 				//error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
3307
-				$f=false;
3308
-				$key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k;
3309
-				if ($_searchStringLength<=0)
3306
+				$f = false;
3307
+				$key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k;
3308
+				if ($_searchStringLength <= 0)
3310 3309
 				{
3311
-					$f=true;
3310
+					$f = true;
3312 3311
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3313 3312
 				}
3314
-				if ($f==false && stripos($fA->displayName,$_searchString)!==false)
3313
+				if ($f == false && stripos($fA->displayName, $_searchString) !== false)
3315 3314
 				{
3316
-					$f=true;
3315
+					$f = true;
3317 3316
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3318 3317
 				}
3319
-				if ($f==false && stripos($k,$searchString)!==false)
3318
+				if ($f == false && stripos($k, $searchString) !== false)
3320 3319
 				{
3321 3320
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3322 3321
 				}
@@ -3344,13 +3343,13 @@  discard block
 block discarded – undo
3344 3343
 		exit();
3345 3344
 	}
3346 3345
 
3347
-	public static function ajax_searchAddress($_searchStringLength=2) {
3346
+	public static function ajax_searchAddress($_searchStringLength = 2) {
3348 3347
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3349 3348
 		$_searchString = trim($_REQUEST['query']);
3350 3349
 		$include_lists = (boolean)$_REQUEST['include_lists'];
3351 3350
 
3352 3351
 		$contacts_obj = new Api\Contacts();
3353
-		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength)
3352
+		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength)
3354 3353
 		{
3355 3354
 			//error_log(__METHOD__.__LINE__.array2string($_searchString));
3356 3355
 			$showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']);
@@ -3359,64 +3358,64 @@  discard block
 block discarded – undo
3359 3358
 			{
3360 3359
 				if (mb_strlen($v) < 3) unset($search[$k]);
3361 3360
 			}
3362
-			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3361
+			$search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns
3363 3362
 			//error_log(__METHOD__.__LINE__.$_searchString);
3364 3363
 			$filter = $showAccounts ? array() : array('account_id' => null);
3365
-			$filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home');
3366
-			$cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home');
3367
-			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter);
3364
+			$filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3365
+			$cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3366
+			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3368 3367
 			// additionally search the accounts, if the contact storage is not the account storage
3369 3368
 			if ($showAccounts && $contacts_obj->so_accounts)
3370 3369
 			{
3371 3370
 				$filter['owner'] = 0;
3372
-				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter);
3371
+				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3373 3372
 
3374 3373
 				if ($contacts && $accounts)
3375 3374
 				{
3376
-					$contacts = array_merge($contacts,$accounts);
3377
-					usort($contacts,function($a, $b)
3375
+					$contacts = array_merge($contacts, $accounts);
3376
+					usort($contacts, function($a, $b)
3378 3377
 					{
3379 3378
 						return strcasecmp($a['n_fn'], $b['n_fn']);
3380 3379
 					});
3381 3380
 				}
3382
-				elseif($accounts)
3381
+				elseif ($accounts)
3383 3382
 				{
3384
-					$contacts =& $accounts;
3383
+					$contacts = & $accounts;
3385 3384
 				}
3386 3385
 				unset($accounts);
3387 3386
 			}
3388 3387
 		}
3389 3388
 		$results = array();
3390
-		if(is_array($contacts)) {
3391
-			foreach($contacts as $contact) {
3392
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3389
+		if (is_array($contacts)) {
3390
+			foreach ($contacts as $contact) {
3391
+				foreach (array($contact['email'], $contact['email_home']) as $email) {
3393 3392
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3394 3393
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3395 3394
 					$rfcAddr = Mail::parseAddressList($email);
3396
-					$_rfcAddr=$rfcAddr->first();
3395
+					$_rfcAddr = $rfcAddr->first();
3397 3396
 					if (!$_rfcAddr->valid)
3398 3397
 					{
3399 3398
 						continue; // skip address if we encounter an error here
3400 3399
 					}
3401 3400
 					$email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
3402 3401
 
3403
-					if (method_exists($contacts_obj,'search'))
3402
+					if (method_exists($contacts_obj, 'search'))
3404 3403
 					{
3405
-						$contact['n_fn']='';
3404
+						$contact['n_fn'] = '';
3406 3405
 						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3407
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3408
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3409
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3410
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3406
+						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given'];
3407
+						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family'];
3408
+						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')';
3409
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3411 3410
 					}
3412 3411
 					else
3413 3412
 					{
3414
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3413
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3415 3414
 					}
3416 3415
 					$args = explode('@', trim($email));
3417 3416
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3418 3417
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3419
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3418
+					if (!empty($email) && in_array($completeMailString, $results) === false) {
3420 3419
 						$results[] = array(
3421 3420
 							'id'=>$completeMailString,
3422 3421
 							'label' => $completeMailString,
@@ -3432,10 +3431,10 @@  discard block
 block discarded – undo
3432 3431
 		// Add groups
3433 3432
 		$group_options = array('account_type' => 'groups');
3434 3433
 		$groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options);
3435
-		foreach($groups as $g_id => $name)
3434
+		foreach ($groups as $g_id => $name)
3436 3435
 		{
3437 3436
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3438
-			if(!$group['account_email']) continue;
3437
+			if (!$group['account_email']) continue;
3439 3438
 			$args = explode('@', trim($group['account_email']));
3440 3439
 			$args[] = $name;
3441 3440
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3448,7 +3447,7 @@  discard block
 block discarded – undo
3448 3447
 		}
3449 3448
 
3450 3449
 		// Add up to 5 matching mailing lists
3451
-		if($include_lists)
3450
+		if ($include_lists)
3452 3451
 		{
3453 3452
 			$lists = array_filter(
3454 3453
 				$contacts_obj->get_lists(Acl::READ),
@@ -3457,7 +3456,7 @@  discard block
 block discarded – undo
3457 3456
 				}
3458 3457
 			);
3459 3458
 			$list_count = 0;
3460
-			foreach($lists as $key => $list_name)
3459
+			foreach ($lists as $key => $list_name)
3461 3460
 			{
3462 3461
 				$results[] = array(
3463 3462
 					'id'	=> $key,
@@ -3467,7 +3466,7 @@  discard block
 block discarded – undo
3467 3466
 					'title' => lang('Mailinglist'),
3468 3467
 					'data'	=> $key
3469 3468
 				);
3470
-				if($list_count++ > 5) break;
3469
+				if ($list_count++ > 5) break;
3471 3470
 			}
3472 3471
 		}
3473 3472
 		 // switch regular JSON response handling off
@@ -3488,7 +3487,7 @@  discard block
 block discarded – undo
3488 3487
 	public function ajax_merge($contact_id)
3489 3488
 	{
3490 3489
 		$response = Api\Json\Response::get();
3491
-		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3490
+		if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3492 3491
 		{
3493 3492
 			$document_merge = new $_REQUEST['merge']();
3494 3493
 		}
@@ -3498,7 +3497,7 @@  discard block
 block discarded – undo
3498 3497
 		}
3499 3498
 		$this->mail_bo->openConnection();
3500 3499
 
3501
-		if(($error = $document_merge->check_document($_REQUEST['document'],'')))
3500
+		if (($error = $document_merge->check_document($_REQUEST['document'], '')))
3502 3501
 		{
3503 3502
 			$response->error($error);
3504 3503
 			return;
@@ -3509,11 +3508,11 @@  discard block
 block discarded – undo
3509 3508
 		try
3510 3509
 		{
3511 3510
 			$results = $this->mail_bo->importMessageToMergeAndSend(
3512
-				$document_merge, Vfs::PREFIX . $_REQUEST['document'],
3511
+				$document_merge, Vfs::PREFIX.$_REQUEST['document'],
3513 3512
 				// Send an extra non-numeric ID to force actual send of document
3514 3513
 				// instead of save as draft
3515 3514
 				array((int)$contact_id, ''),
3516
-				$folder,$merged_mail_id
3515
+				$folder, $merged_mail_id
3517 3516
 			);
3518 3517
 		}
3519 3518
 		catch (Exception $e)
@@ -3527,13 +3526,13 @@  discard block
 block discarded – undo
3527 3526
 			);
3528 3527
 		}
3529 3528
 
3530
-		if($results['success'])
3529
+		if ($results['success'])
3531 3530
 		{
3532
-			$response->data(implode(',',$results['success']));
3531
+			$response->data(implode(',', $results['success']));
3533 3532
 		}
3534
-		if($results['failed'])
3533
+		if ($results['failed'])
3535 3534
 		{
3536
-			$response->error(implode(',',$results['failed']));
3535
+			$response->error(implode(',', $results['failed']));
3537 3536
 		}
3538 3537
 	}
3539 3538
 }
Please login to merge, or discard this patch.
mail/inc/class.mail_sieve.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1278,7 +1278,7 @@
 block discarded – undo
1278 1278
 	 * int $_searchStringLength
1279 1279
 	 * @param boolean $_returnList
1280 1280
 	 * @param int $_mailaccountToSearch
1281
-	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1281
+	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283 1283
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1284
 	{
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277 277
 			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
278
-            $error = 0;
278
+			$error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 	/**
1203 1203
 	 *
1204 1204
 	 * Get the data for iterating the rows on rules list grid
1205
- 	 *
1205
+	 *
1206 1206
 	 * @return {boolean|array} Array of rows | false if failed
1207 1207
 	 */
1208 1208
 	function get_rows()
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
1224 1224
 				}
1225
-            }
1225
+			}
1226 1226
 		}
1227 1227
 		else
1228 1228
 		{
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 				'caption' => 'Edit',
1248 1248
 				'default' => true,
1249 1249
 				'onExecute' => 'javaScript:app.mail.action',
1250
-                'disableClass' => 'th'
1250
+				'disableClass' => 'th'
1251 1251
 			),
1252 1252
 			'add' => array(
1253 1253
 				'caption' => 'Add',
@@ -1257,13 +1257,13 @@  discard block
 block discarded – undo
1257 1257
 				'caption' => 'Enable',
1258 1258
 				'onExecute' => 'javaScript:app.mail.action',
1259 1259
 				'enableClass' => 'mail_sieve_DISABLED',
1260
-                'hideOnDisabled' => true
1260
+				'hideOnDisabled' => true
1261 1261
 			),
1262 1262
 			'disable' => array(
1263 1263
 				'caption' => 'Disable',
1264 1264
 				'onExecute' => 'javaScript:app.mail.action',
1265 1265
 				'disableClass' => 'mail_sieve_DISABLED',
1266
-                'hideOnDisabled' => true
1266
+				'hideOnDisabled' => true
1267 1267
 			),
1268 1268
 			'delete' => array(
1269 1269
 				'caption' => 'Delete',
Please login to merge, or discard this patch.
Braces   +39 added lines, -11 removed lines patch added patch discarded remove patch
@@ -305,11 +305,21 @@  discard block
 block discarded – undo
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307 307
 						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
308
+						if( $newRule['continue'] )
309
+						{
310
+$newRule['flg'] += 1; }
311
+						if( $newRule['gthan'] )
312
+						{
313
+$newRule['flg'] += 2; }
314
+						if( $newRule['anyof'] )
315
+						{
316
+$newRule['flg'] += 4; }
317
+						if( $newRule['keep'] )
318
+						{
319
+$newRule['flg'] += 8; }
320
+						if( $newRule['regexp'] )
321
+						{
322
+$newRule['flg'] += 128; }
313 323
 
314 324
 						if($newRule['action'] && $this->rulesByID['priority'])
315 325
 						{
@@ -443,7 +453,10 @@  discard block
 block discarded – undo
443 453
 		{
444 454
 			Framework::window_close(lang($e->getMessage()));
445 455
 		}
446
-		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
456
+		if (is_null($accountID))
457
+		{
458
+			$accountID = $GLOBALS['egw_info']['user']['account_id'];
459
+		}
447 460
 
448 461
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
449 462
 		$allAliases = array($this->account->ident_email);
@@ -473,7 +486,10 @@  discard block
 block discarded – undo
473 486
 		$vtmpl = new Etemplate('mail.sieve.vacation');
474 487
 		$vacation = array();
475 488
 
476
-		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
489
+		if (isset($_GET['account_id']))
490
+		{
491
+			$account_id = $preserv['account_id'] = $_GET['account_id'];
492
+		}
477 493
 
478 494
 		if (isset($content['account_id']))
479 495
 		{
@@ -543,7 +559,10 @@  discard block
 block discarded – undo
543 559
 				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
544 560
 				{
545 561
 					$content = $vacation = $vacRules['vacation'];
546
-					if (!empty($profileID)) $content['acc_id'] = $profileID;
562
+					if (!empty($profileID))
563
+					{
564
+						$content['acc_id'] = $profileID;
565
+					}
547 566
 					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
548 567
 					{
549 568
 						$content['addresses'] = $vacRules['aliases'];
@@ -556,7 +575,10 @@  discard block
 block discarded – undo
556 575
 					{
557 576
 						$content['forwards'] = '';
558 577
 					}
559
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
578
+					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text'])
579
+					{
580
+						$content['text'] = $this->mailConfig['default_vacation_text'];
581
+					}
560 582
 					if (strlen(trim($content['text']))==0)
561 583
 					{
562 584
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
@@ -746,7 +768,10 @@  discard block
 block discarded – undo
746 768
 		}
747 769
 		// setting up an async job to enable/disable the vacation message
748 770
 		$async = new Api\Asyncservice();
749
-		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
771
+		if (empty($_vacation['account_id']))
772
+		{
773
+			$_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
774
+		}
750 775
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
751 776
 		$async->delete($async_id);
752 777
 
@@ -1283,7 +1308,10 @@  discard block
 block discarded – undo
1283 1308
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1309
 	{
1285 1310
 		$mailCompose = new mail_compose();
1286
-		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
1311
+		if ($_REQUEST['noPrefixId'])
1312
+		{
1313
+			$_noPrefixId = $_REQUEST['noPrefixId'];
1314
+		}
1287 1315
 		$mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId);
1288 1316
 	}
1289 1317
 }
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		if ($acc_id > 0)
75 75
 		{
76 76
 			$this->account = Mail\Account::read($acc_id);
77
-			$identity = Mail\Account::read_identity($this->account->ident_id,true);
78
-			$this->currentIdentity = Mail::generateIdentityString($identity,false);
77
+			$identity = Mail\Account::read_identity($this->account->ident_id, true);
78
+			$this->currentIdentity = Mail::generateIdentityString($identity, false);
79 79
 		}
80 80
 
81 81
 		$this->restoreSessionData();
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param {array} $content
88 88
 	 * @param {string} $msg
89 89
 	 */
90
-	function index(array $content=null,$msg=null)
90
+	function index(array $content = null, $msg = null)
91 91
 	{
92 92
 		if (!is_array($content))
93 93
 		{
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 		if ($this->account->acc_sieve_enabled)
105 105
 		{
106 106
 			//Initializes the Grid contents
107
-			$content['rg']= $this->get_rows();
107
+			$content['rg'] = $this->get_rows();
108 108
 
109 109
 			// Set content-menu actions
110
-			$tmpl->setElementAttribute('rg', 'actions',$this->get_actions());
110
+			$tmpl->setElementAttribute('rg', 'actions', $this->get_actions());
111 111
 
112 112
 			$sel_options = array(
113 113
 				'status' => array(
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 		}
119 119
 		else
120 120
 		{
121
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
122
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
121
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
122
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
123 123
 		}
124
-		$tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array());
124
+		$tmpl->exec('mail.mail_sieve.index', $content, $sel_options, array());
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param {array} $content
132 132
 	 * @param {string} $msg
133 133
 	 */
134
-	function editEmailNotification($content=null, $msg='')
134
+	function editEmailNotification($content = null, $msg = '')
135 135
 	{
136 136
 		//Instantiate an eTemplate object, representing sieve.emailNotification
137 137
 		$eNotitmpl = new Etemplate('mail.sieve.emailNotification');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 				if (!empty($eNotification['externalEmail']))
148 148
 				{
149
-					$content['externalEmail'] = explode(",",$eNotification['externalEmail']);
149
+					$content['externalEmail'] = explode(",", $eNotification['externalEmail']);
150 150
 				}
151 151
 			}
152 152
 			else
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 				list($button) = @each($content['button']);
156 156
 				unset ($content['button']);
157 157
 
158
-				switch($button)
158
+				switch ($button)
159 159
 				{
160 160
 					case 'save':
161 161
 					case 'apply':
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 						{
164 164
 							$newEmailNotification = $content;
165 165
 							if (empty($this->mailConfig['prefpreventforwarding']) ||
166
-								$this->mailConfig['prefpreventforwarding'] == 0 )
166
+								$this->mailConfig['prefpreventforwarding'] == 0)
167 167
 							{
168 168
 								if (is_array($content['externalEmail']) && !empty($content['externalEmail']))
169 169
 								{
170
-									$newEmailNotification['externalEmail'] = implode(",",$content['externalEmail']);
170
+									$newEmailNotification['externalEmail'] = implode(",", $content['externalEmail']);
171 171
 								}
172 172
 							}
173 173
 						}
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 		else
217 217
 		{
218
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
219
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
218
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
219
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
220 220
 		}
221
-		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options);
221
+		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content, $sel_options);
222 222
 	}
223 223
 
224 224
 	/**
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param {array} $content
228 228
 	 */
229
-	function edit ($content=null)
229
+	function edit($content = null)
230 230
 	{
231 231
 		//Instantiate an eTemplate object, representing sieve.edit template
232 232
 		$etmpl = new Etemplate('mail.sieve.edit');
233
-		$etmpl->setElementAttribute('action_folder_text','autocomplete_params', array('noPrefixId'=> true));
233
+		$etmpl->setElementAttribute('action_folder_text', 'autocomplete_params', array('noPrefixId'=> true));
234 234
 		if (!is_array($content))
235 235
 		{
236
-			if ( $this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
236
+			if ($this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
237 237
 			{
238 238
 
239 239
 				$rules = $this->rulesByID;
240
-				$content= $rules;
240
+				$content = $rules;
241 241
 				$content ['ruleID'] = $_GET['ruleID'];
242 242
 				switch ($rules['action'])
243 243
 				{
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			{
258 258
 
259 259
 				$this->getRules(null);
260
-				$newRulePriority = count($this->rules)*2+1;
260
+				$newRulePriority = count($this->rules) * 2 + 1;
261 261
 				$newRules ['priority'] = $newRulePriority;
262 262
 				$newRules ['status'] = 'ENABLED';
263 263
 				$readonlys = array(
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
 			list($button) = @each($content['button']);
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277
-			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
277
+			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] - 1) / 2;
278 278
             $error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
282 282
 				case 'apply':
283
-					if($content)
283
+					if ($content)
284 284
 					{
285 285
 						unset($content['button']);
286 286
 
287 287
 						$newRule = $content;
288
-						$newRule['priority']	= $this->rulesByID['priority'];
289
-						$newRule['status']	= $this->rulesByID['status'];
288
+						$newRule['priority'] = $this->rulesByID['priority'];
289
+						$newRule['status'] = $this->rulesByID['status'];
290 290
 
291 291
 						switch ($content['action'])
292 292
 						{
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 						unset($newRule['action_address_text']);
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307
-						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
307
+						$newRule['flg'] = 0;
308
+						if ($newRule['continue']) { $newRule['flg'] += 1; }
309
+						if ($newRule['gthan']) { $newRule['flg'] += 2; }
310
+						if ($newRule['anyof']) { $newRule['flg'] += 4; }
311
+						if ($newRule['keep']) { $newRule['flg'] += 8; }
312
+						if ($newRule['regexp']) { $newRule['flg'] += 128; }
313 313
 
314
-						if($newRule['action'] && $this->rulesByID['priority'])
314
+						if ($newRule['action'] && $this->rulesByID['priority'])
315 315
 						{
316 316
 							$this->rules[$ruleID] = $newRule;
317 317
 							$ret = $this->account->imapServer()->setRules($this->rules);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 							}
322 322
 							else
323 323
 							{
324
-								$msg .= lang("The rule with priority %1 successfully saved!",$ruleID);
324
+								$msg .= lang("The rule with priority %1 successfully saved!", $ruleID);
325 325
 							}
326 326
 							$this->saveSessionData();
327 327
 						}
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 				case 'delete':
347 347
 					if ($button == "delete")
348 348
 					{
349
-						if ($ruleID === count($this->rules)-1)
349
+						if ($ruleID === count($this->rules) - 1)
350 350
 						{
351
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!');
351
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!');
352 352
 						}
353 353
 						else
354 354
 						{
355 355
 
356
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$ruleID+1,$ruleID);
356
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $ruleID + 1, $ruleID);
357 357
 						}
358 358
 						unset($this->rules[$ruleID]);
359 359
 						$this->rules = array_values($this->rules);
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 		);
385 385
 
386 386
 		//Set the preselect_options for mail/folders as we are not allow free entry for folder taglist
387
-		$sel_options['action_folder_text'] = $this->ajax_getFolders(0,true,null,true);
387
+		$sel_options['action_folder_text'] = $this->ajax_getFolders(0, true, null, true);
388 388
 
389
-		return $etmpl->exec('mail.mail_sieve.edit',$content,$sel_options,$readonlys,array(),2);
389
+		return $etmpl->exec('mail.mail_sieve.edit', $content, $sel_options, $readonlys, array(), 2);
390 390
 	}
391 391
 
392 392
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	function getEmailNotification()
400 400
 	{
401
-		if(!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
401
+		if (!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
402 402
 		{
403 403
 			throw new Api\Exception\NoPermission();
404 404
 		}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$emailNotification = $this->account->imapServer()->getEmailNotification();
408 408
 		}
409
-		catch(Exception $e) {
409
+		catch (Exception $e) {
410 410
 			unset($e);
411 411
 			$emailNotification = array();
412 412
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	function getVacation($accountID = null)
424 424
 	{
425
-		if(!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
425
+		if (!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
426 426
 		{
427 427
 			throw new Api\Exception\NoPermission();
428 428
 		}
@@ -439,19 +439,19 @@  discard block
 block discarded – undo
439 439
 				$vacation = $icServer->getVacation();
440 440
 			}
441 441
 		}
442
-		catch(Exception $e)
442
+		catch (Exception $e)
443 443
 		{
444 444
 			Framework::window_close(lang($e->getMessage()));
445 445
 		}
446 446
 		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
447 447
 
448 448
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
449
-		$allAliases = $this->account->ident_email !=''? array($this->account->ident_email): array();
449
+		$allAliases = $this->account->ident_email != '' ? array($this->account->ident_email) : array();
450 450
 		foreach ($accAllIdentities as &$arrVal)
451 451
 		{
452
-			if ($arrVal['type'] !='default')
452
+			if ($arrVal['type'] != 'default')
453 453
 			{
454
-				$allAliases[] =  $arrVal['address'];
454
+				$allAliases[] = $arrVal['address'];
455 455
 			}
456 456
 		}
457 457
 		asort($allAliases);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @param {array} $content
468 468
 	 * @param {string} $msg
469 469
 	 */
470
-	function editVacation($content=null, $msg='')
470
+	function editVacation($content = null, $msg = '')
471 471
 	{
472 472
 		//Instantiate an eTemplate object, representing the sieve.vacation template
473 473
 		$vtmpl = new Etemplate('mail.sieve.vacation');
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 			$account_id = $content['account_id'];
481 481
 			$preserv['acc_id'] = $content['acc_id'];
482 482
 		}
483
-		if(isset($account_id) && $this->mail_admin)
483
+		if (isset($account_id) && $this->mail_admin)
484 484
 		{
485
-			foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account)
485
+			foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account)
486 486
 			{
487 487
 				try {
488 488
 					// check if account is valid for multiple users, has admin credentials and sieve enabled
489 489
 					if (Mail\Account::is_multiple($account) &&
490
-						($icServer = $account->imapServer(true)) &&	// check on icServer object, so plugins can overwrite
490
+						($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite
491 491
 						$icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled)
492 492
 					{
493 493
 						$allAccounts[$account->acc_id] = $account->acc_name;
494 494
 						$accounts[$account->acc_id] = $account;
495 495
 					}
496 496
 				}
497
-				catch(Exception $e) {
497
+				catch (Exception $e) {
498 498
 					unset($e);
499 499
 					// ignore broken accounts
500 500
 				}
501 501
 			}
502 502
 
503
-			$profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id'];
503
+			$profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id'];
504 504
 			if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']]))
505 505
 			{
506 506
 				$profileID = $content['acc_id'] = (int)$_GET['acc_id'];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$this->is_admin_vac = true;
513 513
 			$preserv['account_id'] = $account_id;
514 514
 		}
515
-		elseif(!is_array($content) && isset($_GET['acc_id']))
515
+		elseif (!is_array($content) && isset($_GET['acc_id']))
516 516
 		{
517 517
 			$this->account = Mail\Account::read($_GET['acc_id']);
518 518
 			$preserv['acc_id'] = $this->account->acc_id;
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
 		if ($icServer->acc_sieve_enabled)
529 529
 		{
530 530
 			$vacRules = $this->getVacation($account_id);
531
-			if ($vacRules['vacation']===false)
531
+			if ($vacRules['vacation'] === false)
532 532
 			{
533 533
 				$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
534
-					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
535
-				$content['hideIfSieveDisabled']='mail_DisplayNone';
534
+					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
535
+				$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
536 536
 			}
537 537
 			else
538 538
 			{
@@ -540,24 +540,24 @@  discard block
 block discarded – undo
540 540
 				{
541 541
 					$ByDate = array('by_date' => lang('By date'));
542 542
 				}
543
-				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
543
+				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date'))))
544 544
 				{
545 545
 					$content = $vacation = $vacRules['vacation'];
546 546
 					if (!empty($profileID)) $content['acc_id'] = $profileID;
547
-					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
547
+					if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '')
548 548
 					{
549 549
 						$content['addresses'] = $vacRules['aliases'];
550 550
 					}
551 551
 					if (!empty($vacation['forwards']))
552 552
 					{
553
-						$content['forwards'] = explode(",",$vacation['forwards']);
553
+						$content['forwards'] = explode(",", $vacation['forwards']);
554 554
 					}
555 555
 					else
556 556
 					{
557 557
 						$content['forwards'] = '';
558 558
 					}
559
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
560
-					if (strlen(trim($content['text']))==0)
559
+					if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
560
+					if (strlen(trim($content['text'])) == 0)
561 561
 					{
562 562
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
563 563
 						Framework::refresh_opener($msg, 'mail');
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 					list($button) = @each($content['button']);
576 576
 					unset ($content['button']);
577 577
 
578
-					switch($button)
578
+					switch ($button)
579 579
 					{
580 580
 						case 'save':
581 581
 						case 'apply':
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 								$newVacation = $content;
594 594
 
595 595
 								if (empty($this->mailConfig['prefpreventforwarding']) ||
596
-									$this->mailConfig['prefpreventforwarding'] == 0 )
596
+									$this->mailConfig['prefpreventforwarding'] == 0)
597 597
 								{
598 598
 									$content['forwards'] = self::strip_rfc882_addresses($content['forwards']);
599 599
 									$newVacation['forwards'] = implode(',', $content['forwards']);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 									unset($newVacation ['forwards']);
604 604
 								}
605 605
 
606
-								if (!in_array($newVacation['status'],array('on','off','by_date')))
606
+								if (!in_array($newVacation['status'], array('on', 'off', 'by_date')))
607 607
 								{
608 608
 									$newVacation['status'] = 'off';
609 609
 								}
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 										self::strip_rfc882_addresses($content['addresses']);
616 616
 								}
617 617
 
618
-								if($this->checkRule($newVacation,$checkAddresses))
618
+								if ($this->checkRule($newVacation, $checkAddresses))
619 619
 								{
620 620
 									if (isset($account_id) && $this->mail_admin)
621 621
 									{
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 
629 629
 									if (!$resSetvac)
630 630
 									{
631
-										$msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error;
631
+										$msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error;
632 632
 										break;
633 633
 									}
634 634
 									// schedule job to switch message on/off, if request and not already in past
635 635
 									else
636 636
 									{
637
-										if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
637
+										if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() ||
638 638
 											$vacRules && $vacRules['vacation']['status'] == 'by_date')
639 639
 										{
640 640
 											self::setAsyncJob($newVacation);
@@ -642,29 +642,29 @@  discard block
 block discarded – undo
642 642
 										//Reset vacationNotice cache which is used in mail_ui get_rows
643 643
 										if (isset($account_id) && $this->mail_admin)
644 644
 										{
645
-											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
645
+											$account_lid = Api\Accounts::id2name($account_id, 'account_lid');
646 646
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
647 647
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
648
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
648
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations);
649 649
 										}
650 650
 										else
651 651
 										{
652 652
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
653 653
 											//error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations));
654
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
654
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
655 655
 										}
656 656
 										$msg = lang('Vacation notice sucessfully updated.');
657 657
 									}
658 658
 								}
659 659
 								else
660 660
 								{
661
-									$msg .= implode("\n",$this->errorStack);
661
+									$msg .= implode("\n", $this->errorStack);
662 662
 								}
663 663
 								// refresh vacationNotice on index
664 664
 								$response = Api\Json\Response::get();
665
-								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
665
+								$response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId);
666 666
 								Framework::refresh_opener($msg, 'mail');
667
-								if ($button === 'apply' || $icServer->error !=="")
667
+								if ($button === 'apply' || $icServer->error !== "")
668 668
 								{
669 669
 									break;
670 670
 								}
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 						'on' => lang('Active'),
681 681
 						'off' => lang('Deactive'),
682 682
 					),
683
-					'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']),
683
+					'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']),
684 684
 				);
685 685
 				if (!isset($account_id))
686 686
 				{
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 		}
705 705
 		else
706 706
 		{
707
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
708
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
707
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
708
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
709 709
 		}
710
-		$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);
710
+		$vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2);
711 711
 	}
712 712
 
713 713
 	/**
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	static function strip_rfc882_addresses($_addresses)
722 722
 	{
723 723
 		$addresses = array();
724
-		foreach(Mail::parseAddressList($_addresses) as $addr)
724
+		foreach (Mail::parseAddressList($_addresses) as $addr)
725 725
 		{
726 726
 			if ($addr->valid)
727 727
 			{
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes
739 739
 	 * @return  void
740 740
 	 */
741
-	static function setAsyncJob (array $_vacation, $_reschedule=false)
741
+	static function setAsyncJob(array $_vacation, $_reschedule = false)
742 742
 	{
743 743
 		if (!($_vacation['acc_id'] > 0))
744 744
 		{
@@ -750,19 +750,19 @@  discard block
 block discarded – undo
750 750
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
751 751
 		$async->delete($async_id);
752 752
 
753
-		$end_date = $_vacation['end_date'] + 24*3600;   // end-date is inclusive, so we have to add 24h
753
+		$end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h
754 754
 		if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
755 755
 		{
756 756
 			$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
757
-			$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
757
+			$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
758 758
 		}
759 759
 		if ($_reschedule)
760 760
 		{
761
-			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
761
+			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5;
762 762
 			// only try to reschedule for 2 days max
763 763
 			if ($_vacation['rescheduled'] <= 2 * 24 * 60)
764 764
 			{
765
-				$time = time() + 60*($_vacation['rescheduled']);
765
+				$time = time() + 60 * ($_vacation['rescheduled']);
766 766
 				unset($_vacation['next']);
767 767
 				unset($_vacation['times']);
768 768
 				$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 		catch (Exception $e) {
800 800
 			error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
801
-			self::setAsyncJob($_vacation, true);	// reschedule
801
+			self::setAsyncJob($_vacation, true); // reschedule
802 802
 			$ret = false;
803 803
 		}
804 804
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 *
814 814
 	 * @return boolean
815 815
 	 */
816
-	function checkRule($_vacation,$_checkAddresses=true)
816
+	function checkRule($_vacation, $_checkAddresses = true)
817 817
 	{
818 818
 		$this->errorStack = array();
819 819
 
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 			$this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!';
828 828
 		}
829 829
 
830
-		if(is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
830
+		if (is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
831 831
 		{
832
-			$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
832
+			$regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
833 833
 			foreach ($_vacation['addresses'] as $addr)
834 834
 			{
835
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
835
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
836 836
 				{
837 837
 					$this->errorStack['addresses'] = lang('One address is not valid').'!';
838 838
 				}
@@ -848,23 +848,23 @@  discard block
 block discarded – undo
848 848
 			{
849 849
 				$this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!');
850 850
 			}
851
-			elseif($_vacation['start_date'] > $_vacation['end_date'])
851
+			elseif ($_vacation['start_date'] > $_vacation['end_date'])
852 852
 			{
853 853
 				$this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!');
854 854
 			}
855 855
 		}
856 856
 		if ($_vacation['forwards'])
857 857
 		{
858
-			foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr)
858
+			foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr)
859 859
 			{
860
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
860
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
861 861
 				{
862 862
 					$this->errorStack['forwards'] = lang('One address is not valid'.'!');
863 863
 				}
864 864
 			}
865 865
 		}
866 866
 		//error_log(__METHOD__. array2string($this->errorStack));
867
-		if(count($this->errorStack) == 0)
867
+		if (count($this->errorStack) == 0)
868 868
 		{
869 869
 			return true;
870 870
 		}
@@ -885,14 +885,14 @@  discard block
 block discarded – undo
885 885
 
886 886
 		foreach ($orders as $keys => $val)
887 887
 		{
888
-			$orders[$keys] = $val -1;
888
+			$orders[$keys] = $val - 1;
889 889
 		}
890 890
 
891 891
 		$this->getRules(null);
892 892
 
893 893
 		$newrules = $this->rules;
894 894
 
895
-		foreach($orders as $keys => $ruleID)
895
+		foreach ($orders as $keys => $ruleID)
896 896
 		{
897 897
 			$newrules[$keys] = $this->rules[$ruleID];
898 898
 		}
@@ -921,24 +921,24 @@  discard block
 block discarded – undo
921 921
 		switch ($action)
922 922
 		{
923 923
 			case 'delete':
924
-				if ($checked === count($this->rules)-1)
924
+				if ($checked === count($this->rules) - 1)
925 925
 				{
926
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!');
926
+					$msg = lang('rule with priority ').$checked.lang(' deleted!');
927 927
 				}
928 928
 				else
929 929
 				{
930 930
 
931
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked);
931
+					$msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked);
932 932
 				}
933 933
 				unset($this->rules[$checked]);
934 934
 				$this->rules = array_values($this->rules);
935 935
 				break;
936 936
 			case 'enable':
937
-				$msg = lang('rule with priority ') . $checked . lang(' enabled!');
937
+				$msg = lang('rule with priority ').$checked.lang(' enabled!');
938 938
 				$this->rules[$checked][status] = 'ENABLED';
939 939
 				break;
940 940
 			case 'disable':
941
-				$msg = lang('rule with priority ') . $checked . lang(' disabled!');
941
+				$msg = lang('rule with priority ').$checked.lang(' disabled!');
942 942
 				$this->rules[$checked][status] = 'DISABLED';
943 943
 				break;
944 944
 			case 'move':
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 
951 951
 		$response = Api\Json\Response::get();
952 952
 
953
-		if($result)
953
+		if ($result)
954 954
 		{
955 955
 			$response->error($result);
956 956
 			return;
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	function buildRule($rule)
970 970
 	{
971
-		$andor = ' '. lang('and') .' ';
971
+		$andor = ' '.lang('and').' ';
972 972
 		$started = 0;
973 973
 		if ($rule['anyof'])
974 974
 		{
975
-			$andor = ' '. lang('or') .' ';
975
+			$andor = ' '.lang('or').' ';
976 976
 		}
977 977
 		$complete = lang('IF').' ';
978 978
 		if ($rule['unconditional'])
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 		}
982 982
 		if ($rule['from'])
983 983
 		{
984
-			$match = $this->setMatchType($rule['from'],$rule['regexp']);
985
-			$complete .= "'From:' " . $match . " '" . $rule['from'] . "'";
984
+			$match = $this->setMatchType($rule['from'], $rule['regexp']);
985
+			$complete .= "'From:' ".$match." '".$rule['from']."'";
986 986
 			$started = 1;
987 987
 		}
988 988
 		if ($rule['to'])
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				$complete .= $andor;
993 993
 			}
994
-			$match = $this->setMatchType($rule['to'],$rule['regexp']);
995
-			$complete .= "'To:' " . $match . " '" . $rule['to'] . "'";
994
+			$match = $this->setMatchType($rule['to'], $rule['regexp']);
995
+			$complete .= "'To:' ".$match." '".$rule['to']."'";
996 996
 			$started = 1;
997 997
 		}
998 998
 		if ($rule['subject'])
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 			{
1002 1002
 				$complete .= $andor;
1003 1003
 			}
1004
-			$match = $this->setMatchType($rule['subject'],$rule['regexp']);
1005
-			$complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'";
1004
+			$match = $this->setMatchType($rule['subject'], $rule['regexp']);
1005
+			$complete .= "'Subject:' ".$match." '".$rule['subject']."'";
1006 1006
 			$started = 1;
1007 1007
 		}
1008 1008
 		if ($rule['field'] && $rule['field_val'])
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 			{
1012 1012
 				$complete .= $andor;
1013 1013
 			}
1014
-			$match = $this->setMatchType($rule['field_val'],$rule['regexp']);
1015
-			$complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'";
1014
+			$match = $this->setMatchType($rule['field_val'], $rule['regexp']);
1015
+			$complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'";
1016 1016
 			$started = 1;
1017 1017
 		}
1018 1018
 		if ($rule['size'])
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 			{
1027 1027
 				$complete .= $andor;
1028 1028
 			}
1029
-			$complete .= "message " . $xthan . $rule['size'] . "KB'";
1029
+			$complete .= "message ".$xthan.$rule['size']."KB'";
1030 1030
 			$started = 1;
1031 1031
 		}
1032 1032
 		if (!empty($rule['field_bodytransform']))
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 			{
1036 1036
 				$newruletext .= ", ";
1037 1037
 			}
1038
-			$btransform	= " :raw ";
1038
+			$btransform = " :raw ";
1039 1039
 			$match = ' :contains';
1040 1040
 			if ($rule['bodytransform'])
1041 1041
 			{
@@ -1049,11 +1049,11 @@  discard block
 block discarded – undo
1049 1049
 			{
1050 1050
 				$match = ':regex';
1051 1051
 			}
1052
-			$complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\"";
1052
+			$complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\"";
1053 1053
 			$started = 1;
1054 1054
 
1055 1055
 		}
1056
-		if ($rule['ctype']!= '0' && !empty($rule['ctype']))
1056
+		if ($rule['ctype'] != '0' && !empty($rule['ctype']))
1057 1057
 		{
1058 1058
 			if ($started)
1059 1059
 			{
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 			{
1066 1066
 				$ctype_subtype = "/";
1067 1067
 			}
1068
-			$complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\"";
1068
+			$complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\"";
1069 1069
 			$started = 1;
1070 1070
 			//error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array));
1071 1071
 		}
@@ -1073,19 +1073,19 @@  discard block
 block discarded – undo
1073 1073
 		{
1074 1074
 			$complete .= ' '.lang('THEN').' ';
1075 1075
 		}
1076
-		if (preg_match("/folder/i",$rule['action']))
1076
+		if (preg_match("/folder/i", $rule['action']))
1077 1077
 		{
1078
-			$complete .= lang('file into')." '" . $rule['action_arg'] . "';";
1078
+			$complete .= lang('file into')." '".$rule['action_arg']."';";
1079 1079
 		}
1080
-		if (preg_match("/reject/i",$rule['action']))
1080
+		if (preg_match("/reject/i", $rule['action']))
1081 1081
 		{
1082
-			$complete .= lang('reject with')." '" . $rule['action_arg'] . "'.";
1082
+			$complete .= lang('reject with')." '".$rule['action_arg']."'.";
1083 1083
 		}
1084
-		if (preg_match("/address/i",$rule['action']))
1084
+		if (preg_match("/address/i", $rule['action']))
1085 1085
 		{
1086
-			$complete .= lang('forward to').' ' . $rule['action_arg'] .'.';
1086
+			$complete .= lang('forward to').' '.$rule['action_arg'].'.';
1087 1087
 		}
1088
-		if (preg_match("/discard/i",$rule['action']))
1088
+		if (preg_match("/discard/i", $rule['action']))
1089 1089
 		{
1090 1090
 			$complete .= lang('discard').'.';
1091 1091
 		}
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 * @param {string} $regex regular expresion as pattern to be matched
1108 1108
 	 * @return {string} return the type
1109 1109
 	 */
1110
-	function setMatchType (&$matchstr, $regex = false)
1110
+	function setMatchType(&$matchstr, $regex = false)
1111 1111
 	{
1112 1112
 		$match = lang('contains');
1113 1113
 		if (preg_match("/^\s*!/", $matchstr))
@@ -1132,11 +1132,11 @@  discard block
 block discarded – undo
1132 1132
 		}
1133 1133
 		if ($regex && preg_match("/^\s*\\\\!/", $matchstr))
1134 1134
 		{
1135
-			$matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr);
1135
+			$matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr);
1136 1136
 		}
1137 1137
 		else
1138 1138
 		{
1139
-			$matchstr = preg_replace("/^\s*!/","",$matchstr);
1139
+			$matchstr = preg_replace("/^\s*!/", "", $matchstr);
1140 1140
 		}
1141 1141
 		return $match;
1142 1142
 	}
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
 	 */
1147 1147
 	function saveSessionData()
1148 1148
 	{
1149
-		$sessionData['sieve_rules']		= $this->rules;
1149
+		$sessionData['sieve_rules'] = $this->rules;
1150 1150
 		$sessionData['sieve_rulesByID'] = $this->rulesByID;
1151
-		$sessionData['sieve_scriptToEdit']	= $this->scriptToEdit;
1151
+		$sessionData['sieve_scriptToEdit'] = $this->scriptToEdit;
1152 1152
 		Api\Cache::setSession(__CLASS__, 'sieve_session_data', $sessionData);
1153 1153
 	}
1154 1154
 
@@ -1174,15 +1174,15 @@  discard block
 block discarded – undo
1174 1174
 	{
1175 1175
 		try {
1176 1176
 			$this->account->imapServer()->retrieveRules();
1177
-			$this->rules	= $this->account->imapServer()->getRules();
1177
+			$this->rules = $this->account->imapServer()->getRules();
1178 1178
 			$this->rulesByID = $this->rules[$ruleID];
1179
-			$this->vacation	= $this->account->imapServer()->getVacation();
1179
+			$this->vacation = $this->account->imapServer()->getVacation();
1180 1180
 		}
1181
-		catch(Exception $e) {
1181
+		catch (Exception $e) {
1182 1182
 			error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details);
1183
-			$this->rules	= array();
1183
+			$this->rules = array();
1184 1184
 			$this->rulesByID = array();
1185
-			$this->vacation	= array();
1185
+			$this->vacation = array();
1186 1186
 			return false;
1187 1187
 		}
1188 1188
 		return true;
@@ -1194,9 +1194,9 @@  discard block
 block discarded – undo
1194 1194
 	function restoreSessionData()
1195 1195
 	{
1196 1196
 		$sessionData = Api\Cache::getSession(__CLASS__, 'sieve_session_data');
1197
-		$this->rules		= $sessionData['sieve_rules'];
1197
+		$this->rules = $sessionData['sieve_rules'];
1198 1198
 		$this->rulesByID = $sessionData['sieve_rulesByID'];
1199
-		$this->scriptToEdit	= $sessionData['sieve_scriptToEdit'];
1199
+		$this->scriptToEdit = $sessionData['sieve_scriptToEdit'];
1200 1200
 	}
1201 1201
 
1202 1202
 	/**
@@ -1210,14 +1210,14 @@  discard block
 block discarded – undo
1210 1210
 		$rows = array();
1211 1211
 		$this->getRules(null);
1212 1212
 
1213
-		if (is_array($this->rules) && !empty($this->rules) )
1213
+		if (is_array($this->rules) && !empty($this->rules))
1214 1214
 		{
1215 1215
 			$rows = $this->rules;
1216 1216
 
1217
-			foreach ($rows as &$row )
1217
+			foreach ($rows as &$row)
1218 1218
 			{
1219 1219
 				$row['rules'] = $this->buildRule($row);
1220
-				$row['ruleID'] =(string)(($row['priority'] -1) / 2 );
1220
+				$row['ruleID'] = (string)(($row['priority'] - 1) / 2);
1221 1221
 				if ($row ['status'] === 'DISABLED')
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 			return false;
1231 1231
 		}
1232 1232
 		// Shift one down, because in grid the first row is reserved for header
1233
-		array_unshift($rows,array(''=> ''));
1233
+		array_unshift($rows, array(''=> ''));
1234 1234
 		return $rows;
1235 1235
 	}
1236 1236
 
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 	 */
1242 1242
 	private function get_actions()
1243 1243
 	{
1244
-		$actions =array(
1244
+		$actions = array(
1245 1245
 
1246 1246
 			'edit' => array(
1247 1247
 				'caption' => 'Edit',
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	 * @param int $_mailaccountToSearch
1281 1281
 	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283
-	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1283
+	function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false)
1284 1284
 	{
1285 1285
 		$mailCompose = new mail_compose();
1286 1286
 		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
Please login to merge, or discard this patch.
mail/inc/class.mail_tree.inc.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $_profileID icServer profile id
77 77
 	 * @param string $_err error message to be shown on tree node
78 78
 	 * @param mixed $_path
79
-	 * @param mixed $_parent
79
+	 * @param string $_parent
80 80
 	 * @return array returns an array of tree node
81 81
 	 */
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * Check if the given tree id is account node (means root)
125 125
 	 *
126
-	 * @param type $_node a tree id node
126
+	 * @param string|null $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129 129
 	private static function isAccountNode ($_node)
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @param string $_parent = null no parent node means root with the first level of folders
157 157
 	 * @param string $_profileID = '' icServer id
158
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
158
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
159 159
 	 *  false|0 leaves them in closed state
160 160
 	 * @param $_noCheckboxNS = false no checkbox for namesapaces makes sure to not put checkbox for namespaces node
161 161
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @param type $_profileID = null Null means all accounts and giving profileid means fetches node for the account
445 445
 	 * @param type $_noCheckbox = false option to switch checkbox of
446
-	 * @param type $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
446
+	 * @param integer $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
447 447
 	 *
448 448
 	 * @return array an array of baseNodes of accounts
449 449
 	 */
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 *
492 492
 	 * @param string $_parent = null no parent node means root with the first level of folders
493 493
 	 * @param string $_profileID = '' active profile / acc_id
494
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
494
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
495 495
 	 *  false|0 leaves them in closed state
496 496
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
497 497
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		$this->ui = $mail_ui;
62 62
 
63 63
 		// check images available in png or svg
64
-		foreach(self::$leafImages as &$image)
64
+		foreach (self::$leafImages as &$image)
65 65
 		{
66 66
 			if (strpos($image, '.') === false)
67 67
 			{
68
-				$image = basename($img=Api\Image::find('mail', 'dhtmlxtree/'.$image));
68
+				$image = basename($img = Api\Image::find('mail', 'dhtmlxtree/'.$image));
69 69
 			}
70 70
 		}
71 71
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
83 83
 	{
84 84
 		$baseNode = array('id' => $_profileID);
85
-		$leaf =  array(
85
+		$leaf = array(
86 86
 			'id' => $_profileID.self::DELIMITER.'INBOX',
87 87
 			'text' => $_err,
88 88
 			'tooltip' => $_err,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		);
95 95
 		self::setOutStructure($leaf, $baseNode, self::DELIMITER);
96 96
 
97
-		return ($baseNode?$baseNode:array( // fallback not connected array
97
+		return ($baseNode ? $baseNode : array( // fallback not connected array
98 98
 						'id'=>0,
99 99
 						'item'=> array(
100 100
 							'text'=>'INBOX',
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param array $_node array of a node
112 112
 	 * @return int returns 1 if it has children flag set otherwise 0
113 113
 	 */
114
-	private static function nodeHasChildren ($_node)
114
+	private static function nodeHasChildren($_node)
115 115
 	{
116 116
 		$hasChildren = 0;
117 117
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param type $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129
-	private static function isAccountNode ($_node)
129
+	private static function isAccountNode($_node)
130 130
 	{
131 131
 		list(,$leaf) = explode(self::DELIMITER, $_node);
132 132
 		if ($leaf || $_node == null) return false;
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @return array returns an array of mail tree structure according to provided node
166 166
 	 */
167
-	function getTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly= false, $_allInOneGo = false, $_checkSubscribed = true)
167
+	function getTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly = false, $_allInOneGo = false, $_checkSubscribed = true)
168 168
 	{
169 169
 		//Init mail folders
170
-		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
170
+		$tree = array(Tree::ID=> $_parent ? $_parent : 0, Tree::CHILDREN => array());
171 171
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
172 172
 
173 173
 		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			{
179 179
 				$this->ui->changeProfile($_profileID);
180 180
 			} catch (Exception $ex) {
181
-				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
181
+				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
182 182
 			}
183 183
 		}
184 184
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
191 191
 			{
192 192
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
193
-				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
193
+				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly);
194 194
 
195 195
 				$childrenNode = array();
196 196
 				foreach ($folders as &$node)
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 					$nodeData = Mail::pathToFolderData($nodeId, $node['delimiter']);
200 200
 					$childrenNode[] = array(
201 201
 						Tree::ID=> $nodeId,
202
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node),
202
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($node),
203 203
 						Tree::CHILDREN =>array(),
204 204
 						Tree::LABEL => $nodeData['text'],
205 205
 						Tree::TOOLTIP => $nodeData['tooltip'],
206 206
 						Tree::IMAGE_LEAF => self::$leafImages['folderLeaf'],
207 207
 						Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'],
208 208
 						Tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClosed'],
209
-						Tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false,
209
+						Tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false,
210 210
 						'parent' => $_parent
211 211
 					);
212 212
 				}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 				}
227 227
 
228 228
 				//List of folders
229
-				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, false);
229
+				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, false);
230 230
 
231 231
 				// User defined folders based on account
232 232
 				$definedFolders = array(
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 
247 247
 					$data = array(
248 248
 						Tree::ID=>$_profileID.self::DELIMITER.$folder['MAILBOX'],
249
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder),
249
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($folder),
250 250
 						Tree::CHILDREN =>array(),
251 251
 						Tree::LABEL =>lang($folder['MAILBOX']),
252
-						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0,
252
+						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0,
253 253
 						Tree::TOOLTIP => lang($folder['MAILBOX']),
254
-						Tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false,
254
+						Tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false,
255 255
 						Tree::NOCHECKBOX => 0,
256
-						'parent' => $parent?$_profileID.self::DELIMITER.implode($folder['delimiter'], $parent):$_profileID,
256
+						'parent' => $parent ? $_profileID.self::DELIMITER.implode($folder['delimiter'], $parent) : $_profileID,
257 257
 						'path' => $path,
258 258
 						'folderarray' => $folder
259 259
 					);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		catch (Exception $ex) // Catch exceptions
292 292
 		{
293 293
 			//mail_ui::callWizard($ex->getMessage(), false, 'error');
294
-			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
294
+			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
295 295
 		}
296 296
 
297 297
 		return $tree;
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
 	 *					as clearance for access may be limited to a single branch-node of a tree
309 309
 	 * @return void
310 310
 	 */
311
-	static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array())
311
+	static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array())
312 312
 	{
313 313
 		//error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
314 314
 		$components = $data['path'];
315
-		array_pop($components);	// remove own name
315
+		array_pop($components); // remove own name
316 316
 
317 317
 		$insert = &$out;
318 318
 		$parents = array();
319
-		foreach($components as $component)
319
+		foreach ($components as $component)
320 320
 		{
321
-			if (count($parents)>1)
321
+			if (count($parents) > 1)
322 322
 			{
323
-				$helper = array_slice($parents,1,null,true);
323
+				$helper = array_slice($parents, 1, null, true);
324 324
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
325 325
 				if ($parent) $parent .= $del;
326 326
 			}
@@ -343,21 +343,21 @@  discard block
 block discarded – undo
343 343
 				{
344 344
 					// if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent
345 345
 					// we want to create the node in question as we meet the above considerations
346
-					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
346
+					if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::DELIMITER.$nsp['prefix']) === 0)
347 347
 					{
348 348
 						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
349
-						$break=false;
349
+						$break = false;
350 350
 					}
351 351
 				}
352 352
 				if ($break) break;
353 353
 			}
354 354
 			if ($insert['item'])
355 355
 			{
356
-				foreach($insert['item'] as &$item)
356
+				foreach ($insert['item'] as &$item)
357 357
 				{
358 358
 					if ($item['id'] == $parent.$component)
359 359
 					{
360
-						$insert =& $item;
360
+						$insert = & $item;
361 361
 						break;
362 362
 					}
363 363
 				}
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 						'im2' => self::$leafImages["folderNoSelectClosed"],
376 376
 						'tooltip' => lang('no access')
377 377
 					);
378
-					$insert['item'][] =& $item;
379
-					$insert =& $item;
378
+					$insert['item'][] = & $item;
379
+					$insert = & $item;
380 380
 				}
381 381
 				else
382 382
 				{
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 					$data[Tree::IMAGE_FOLDER_OPEN] =
410 410
 					$data [Tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png";
411 411
 			}
412
-			elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false)
412
+			elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false)
413 413
 			{
414 414
 				$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
415 415
 				$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @return array an array of baseNodes of accounts
453 453
 	 */
454
-	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 )
454
+	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0)
455 455
 	{
456 456
 		$roots = array(Tree::ID => 0, Tree::CHILDREN => array());
457 457
 
458
-		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
458
+		foreach (Mail\Account::search(true, false) as $acc_id => $accObj)
459 459
 		{
460
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
461
-			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
460
+			if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue;
461
+			$identity = Mail\Account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']);
462 462
 			// Open top level folders for active account
463
-			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
463
+			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0;
464 464
 
465 465
 			$baseNode = array(
466 466
 							Tree::ID=> (string)$acc_id,
467
-							Tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity),
467
+							Tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity),
468 468
 							Tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity),
469 469
 							Tree::IMAGE_LEAF => self::$leafImages['folderAccount'],
470 470
 							Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'],
@@ -473,16 +473,16 @@  discard block
 block discarded – undo
473 473
 							Tree::CHILDREN => array(), // dynamic loading on unfold
474 474
 							Tree::AUTOLOAD_CHILDREN => true,
475 475
 							'parent' => '',
476
-							Tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount,
476
+							Tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount,
477 477
 							// mark on account if Sieve is enabled
478 478
 							'data' => array(
479 479
 										'sieve' => $accObj->imapServer()->acc_sieve_enabled,
480
-										'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
481
-										'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
480
+										'spamfolder'=> $accObj->imapServer()->acc_folder_junk && (strtolower($accObj->imapServer()->acc_folder_junk) != 'none') ? true : false,
481
+										'archivefolder'=> $accObj->imapServer()->acc_folder_archive && (strtolower($accObj->imapServer()->acc_folder_archive) != 'none') ? true : false
482 482
 									),
483 483
 							Tree::NOCHECKBOX  => $_noCheckbox
484 484
 			);
485
-			self::setOutStructure($baseNode, $roots,self::DELIMITER);
485
+			self::setOutStructure($baseNode, $roots, self::DELIMITER);
486 486
 		}
487 487
 		return $roots;
488 488
 	}
@@ -501,15 +501,15 @@  discard block
 block discarded – undo
501 501
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
502 502
 	 * @return type an array of tree
503 503
 	 */
504
-	function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false)
504
+	function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false)
505 505
 	{
506 506
 		$tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo);
507
-		$branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo);
507
+		$branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo);
508 508
 		foreach ($tree[Tree::CHILDREN] as &$account)
509 509
 		{
510 510
 			if ($account[Tree::ID] == $_profileID)
511 511
 			{
512
-				$account = array_merge($account , $branches);
512
+				$account = array_merge($account, $branches);
513 513
 			}
514 514
 		}
515 515
 		return $tree;
Please login to merge, or discard this patch.
Braces   +54 added lines, -14 removed lines patch added patch discarded remove patch
@@ -116,7 +116,10 @@  discard block
 block discarded – undo
116 116
 		$hasChildren = 0;
117 117
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
118 118
 				in_array('\Haschildren', $_node['ATTRIBUTES']) ||
119
-				in_array('\HasChildren', $_node['ATTRIBUTES'])) $hasChildren = 1;
119
+				in_array('\HasChildren', $_node['ATTRIBUTES']))
120
+		{
121
+			$hasChildren = 1;
122
+		}
120 123
 		return $hasChildren;
121 124
 	}
122 125
 
@@ -129,7 +132,10 @@  discard block
 block discarded – undo
129 132
 	private static function isAccountNode ($_node)
130 133
 	{
131 134
 		list(,$leaf) = explode(self::DELIMITER, $_node);
132
-		if ($leaf || $_node == null) return false;
135
+		if ($leaf || $_node == null)
136
+		{
137
+			return false;
138
+		}
133 139
 		return true;
134 140
 	}
135 141
 
@@ -168,17 +174,24 @@  discard block
 block discarded – undo
168 174
 	{
169 175
 		//Init mail folders
170 176
 		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
171
-		if (!isset($this->ui->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
177
+		if (!isset($this->ui->mail_bo))
178
+		{
179
+			throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
180
+		}
172 181
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
173 182
 
174
-		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
183
+		if ($_parent)
184
+		{
185
+			list($_profileID) = explode(self::DELIMITER, $_parent);
186
+		}
175 187
 
176 188
 		if (is_numeric($_profileID) && $_profileID != $this->ui->mail_bo->profileID)
177 189
 		{
178 190
 			try
179 191
 			{
180 192
 				$this->ui->changeProfile($_profileID);
181
-			} catch (Exception $ex) {
193
+			}
194
+			catch (Exception $ex) {
182 195
 				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
183 196
 			}
184 197
 		}
@@ -188,9 +201,12 @@  discard block
 block discarded – undo
188 201
 			// *** Note: Should not apply any imap transaction, because in case of exception it will stop the
189 202
 			// process of rendering root node
190 203
 
191
-			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
204
+			if ($_parent && !self::isAccountNode($_parent))
205
+			{
206
+				// Single node loader
192 207
 			{
193 208
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
209
+			}
194 210
 				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
195 211
 
196 212
 				$childrenNode = array();
@@ -215,15 +231,21 @@  discard block
 block discarded – undo
215 231
 			}
216 232
 			else //Top Level Nodes loader
217 233
 			{
218
-				if (self::isAccountNode($_parent)) // An account called for open
234
+				if (self::isAccountNode($_parent))
235
+				{
236
+					// An account called for open
219 237
 				{
220 238
 					$_openTopLevel = 1;
239
+				}
221 240
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
222 241
 				}
223 242
 				else // Initial accounts|root nodes
224 243
 				{
225 244
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
226
-					if (!$_profileID && !$_openTopLevel) return $tree;
245
+					if (!$_profileID && !$_openTopLevel)
246
+					{
247
+						return $tree;
248
+					}
227 249
 				}
228 250
 
229 251
 				//List of folders
@@ -323,19 +345,28 @@  discard block
 block discarded – undo
323 345
 			{
324 346
 				$helper = array_slice($parents,1,null,true);
325 347
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
326
-				if ($parent) $parent .= $del;
348
+				if ($parent)
349
+				{
350
+					$parent .= $del;
351
+				}
327 352
 			}
328 353
 			else
329 354
 			{
330 355
 				$parent = implode(self::DELIMITER, $parents);
331
-				if ($parent) $parent .= self::DELIMITER;
356
+				if ($parent)
357
+				{
358
+					$parent .= self::DELIMITER;
359
+				}
332 360
 			}
333 361
 
334 362
 			if (!is_array($insert) || !isset($insert['item']))
335 363
 			{
336 364
 				// throwing an exeption here seems to be unrecoverable,
337 365
 				// even if the cause is a something that can be handeled by the mailserver
338
-				if (mail_bo::$debug) error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
366
+				if (mail_bo::$debug)
367
+				{
368
+					error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
369
+				}
339 370
 				// should we hit the break? if in personal: sure, something is wrong with the folderstructure
340 371
 				// if in shared or others we may proceed as access to folders may very well be limited to
341 372
 				// a single folder within the tree
@@ -346,11 +377,17 @@  discard block
 block discarded – undo
346 377
 					// we want to create the node in question as we meet the above considerations
347 378
 					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
348 379
 					{
349
-						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
380
+						if (mail_bo::$debug)
381
+						{
382
+							error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
383
+						}
350 384
 						$break=false;
351 385
 					}
352 386
 				}
353
-				if ($break) break;
387
+				if ($break)
388
+				{
389
+					break;
390
+				}
354 391
 			}
355 392
 			if ($insert['item'])
356 393
 			{
@@ -458,7 +495,10 @@  discard block
 block discarded – undo
458 495
 
459 496
 		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
460 497
 		{
461
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
498
+			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID)
499
+			{
500
+				continue;
501
+			}
462 502
 			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
463 503
 			// Open top level folders for active account
464 504
 			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
Please login to merge, or discard this patch.
mail/inc/class.mail_ui.inc.php 5 patches
Doc Comments   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
 	 * function splitRowID - split the rowID into its parts
1542 1542
 	 *
1543 1543
 	 * @param string $_rowID string - a colon separated string in the form accountID:profileID:folder:message_uid
1544
-	 * @return array populated named result array (accountID,profileID,folder,msgUID)
1544
+	 * @return string populated named result array (accountID,profileID,folder,msgUID)
1545 1545
 	 */
1546 1546
 	static function splitRowID($_rowID)
1547 1547
 	{
@@ -1623,9 +1623,9 @@  discard block
 block discarded – undo
1623 1623
 	 * function header2gridelements - to populate the grid elements with the collected Data
1624 1624
 	 *
1625 1625
 	 * @param array $_headers headerdata to process
1626
-	 * @param array $cols cols to populate
1626
+	 * @param string[] $cols cols to populate
1627 1627
 	 * @param array $_folderName to ensure the uniqueness of the uid over all folders
1628
-	 * @param array $_folderType used to determine if we need to populate from/to
1628
+	 * @param integer $_folderType used to determine if we need to populate from/to
1629 1629
 	 * @return array populated result array
1630 1630
 	 */
1631 1631
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
@@ -2863,6 +2863,9 @@  discard block
 block discarded – undo
2863 2863
 		return $GLOBALS['egw']->framework->header();
2864 2864
 	}
2865 2865
 
2866
+	/**
2867
+	 * @param string $body
2868
+	 */
2866 2869
 	function showBody(&$body, $print=true,$fullPageTags=true)
2867 2870
 	{
2868 2871
 		$BeginBody = '<div class="mailDisplayBody">
@@ -3099,9 +3102,9 @@  discard block
 block discarded – undo
3099 3102
 	 * Replace CID with proper type of content understandable by browser
3100 3103
 	 *
3101 3104
 	 * @param type $_body content of message
3102
-	 * @param type $_mailbox mail box
3103
-	 * @param type $_uid uid
3104
-	 * @param type $_partID part id
3105
+	 * @param string $_mailbox mail box
3106
+	 * @param string $_uid uid
3107
+	 * @param string $_partID part id
3105 3108
 	 * @param type $_type = 'src' type of inline image that needs to be resolved and replaced
3106 3109
 	 *	- types: {plain|src|url|background}
3107 3110
 	 * @return string returns body content including all CID replacements
@@ -3283,7 +3286,7 @@  discard block
 block discarded – undo
3283 3286
 	 * @param string $_folder (passed by reference) will set the folder used. must be set with a folder, but will hold modifications if
3284 3287
 	 *					folder is modified
3285 3288
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3286
-	 * @return mixed $messageUID or exception
3289
+	 * @return string $messageUID or exception
3287 3290
 	 */
3288 3291
 	function importMessageToFolder($_formData,&$_folder,$importID='')
3289 3292
 	{
@@ -3444,7 +3447,7 @@  discard block
 block discarded – undo
3444 3447
 	 *
3445 3448
 	 * @param string _messageID UID
3446 3449
 	 *
3447
-	 * @return xajax response
3450
+	 * @return string|null response
3448 3451
 	 */
3449 3452
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3450 3453
 	{
@@ -3995,7 +3998,7 @@  discard block
 block discarded – undo
3995 3998
 	 * ajax_deleteFolder - its called via json, so the function must start with ajax (or the class-name must contain ajax)
3996 3999
 	 * @param string $_folderName folder to delete
3997 4000
 	 * @param boolean $_return = false wheter return the success value (true) or send response to client (false)
3998
-	 * @return nothing
4001
+	 * @return null|boolean
3999 4002
 	 */
4000 4003
 	function ajax_deleteFolder($_folderName, $_return = false)
4001 4004
 	{
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3117,7 +3117,7 @@  discard block
 block discarded – undo
3117 3117
 		 * @param string $_partID
3118 3118
 		 * @param string $_type
3119 3119
 		 * @return string|boolean returns the replace
3120
-		*/
3120
+		 */
3121 3121
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3122 3122
 		{
3123 3123
 			if (!$_type)	return false;
@@ -3249,10 +3249,10 @@  discard block
 block discarded – undo
3249 3249
 			try
3250 3250
 			{
3251 3251
 				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3252
-			    $linkData = array
3253
-			    (
3252
+				$linkData = array
3253
+				(
3254 3254
 					'id' => $this->createRowID($destination, $messageUid, true),
3255
-			    );
3255
+				);
3256 3256
 			}
3257 3257
 			catch (Api\Exception\WrongUserinput $e)
3258 3258
 			{
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
 			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3419 3419
 			$linkData = array
3420 3420
 			(
3421
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3421
+				'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3422 3422
 				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3423 3423
 				'deleteDraftOnClose' => 1,
3424 3424
 			);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1811,7 +1811,7 @@
 block discarded – undo
1811 1811
 
1812 1812
 			$data["class"] = implode(' ', $css_styles);
1813 1813
 			//translate style-classes back to flags
1814
-			$data['flags'] = Array();
1814
+			$data['flags'] = array();
1815 1815
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1816 1816
 			foreach ($css_styles as &$flag) {
1817 1817
 				if ($flag!='mail')
Please login to merge, or discard this patch.
Braces   +931 added lines, -259 removed lines patch added patch discarded remove patch
@@ -127,9 +127,15 @@  discard block
 block discarded – undo
127 127
 	function __construct($run_constructor=true)
128 128
 	{
129 129
 		$this->mail_tree = new mail_tree($this);
130
-		if (!$run_constructor) return;
130
+		if (!$run_constructor)
131
+		{
132
+			return;
133
+		}
131 134
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
135
+		if (Mail::$debugTimes)
136
+		{
137
+			$starttime = microtime (true);
138
+		}
133 139
 		// no autohide of the sidebox, as we use it for folderlist now.
134 140
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 141
 
@@ -140,13 +146,19 @@  discard block
 block discarded – undo
140 146
 		if ($_GET["resetConnection"])
141 147
 		{
142 148
 			unset($_GET["resetConnection"]);
143
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
149
+			if (Mail::$debug)
150
+			{
151
+				error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
152
+			}
144 153
 			Mail::unsetCachedObjects(self::$icServerID);
145 154
 		}
146 155
 
147 156
 		try {
148 157
 			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
149
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
158
+			if (Mail::$debug)
159
+			{
160
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
161
+			}
150 162
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 163
 
152 164
 			// RegEx to minimize extra openConnection
@@ -167,9 +179,15 @@  discard block
 block discarded – undo
167 179
 				$response->call('egw.message',$e->getMessage(),'error');
168 180
 			}
169 181
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
182
+			if ($_GET['menuaction'] != 'mail.mail_ui.index')
183
+			{
184
+				self::callWizard($e->getMessage(),true,'error',false);
185
+			}
186
+		}
187
+		if (Mail::$debugTimes)
188
+		{
189
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171 190
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
173 191
 	}
174 192
 
175 193
 	/**
@@ -229,16 +247,28 @@  discard block
 block discarded – undo
229 247
 	 */
230 248
 	function changeProfile($_icServerID,$unsetCache=false)
231 249
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
250
+		if (Mail::$debugTimes)
251
+		{
252
+			$starttime = microtime (true);
253
+		}
233 254
 		if (self::$icServerID != $_icServerID)
234 255
 		{
235 256
 			self::$icServerID = $_icServerID;
236 257
 		}
237
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
258
+		if (Mail::$debug)
259
+		{
260
+			error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
261
+		}
238 262
 
239
-		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
263
+		if ($unsetCache)
264
+		{
265
+			Mail::unsetCachedObjects(self::$icServerID);
266
+		}
240 267
 		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
241
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
268
+		if (Mail::$debug)
269
+		{
270
+			error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
271
+		}
242 272
 		// no icServer Object: something failed big time
243 273
 		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
244 274
 		{
@@ -248,14 +278,23 @@  discard block
 block discarded – undo
248 278
 
249 279
 		// save session varchar
250 280
 		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
251
-		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252
-		if (true) $oldicServerID = self::$icServerID;
281
+		if ($oldicServerID <> self::$icServerID)
282
+		{
283
+			$this->mail_bo->openConnection(self::$icServerID);
284
+		}
285
+		if (true)
286
+		{
287
+			$oldicServerID = self::$icServerID;
288
+		}
253 289
 		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
254 290
 		{
255 291
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 292
 		}
257 293
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
294
+		if (Mail::$debugTimes)
295
+		{
296
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
297
+		}
259 298
 	}
260 299
 
261 300
 	/**
@@ -296,7 +335,8 @@  discard block
 block discarded – undo
296 335
 		// got subscribed or unsubscribed by the user
297 336
 		try {
298 337
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
299
-		} catch (Exception $ex) {
338
+		}
339
+		catch (Exception $ex) {
300 340
 			Framework::message($ex->getMessage());
301 341
 		}
302 342
 
@@ -330,9 +370,18 @@  discard block
 block discarded – undo
330 370
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 371
 						if ($node)
332 372
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
334
-							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335
-							if ($value['value']) $cont[] = $path;
373
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value'])
374
+							{
375
+								$to_unsubscribe []= $node;
376
+							}
377
+							if (is_array($subscribed) && !$subscribed[$node] && $value['value'])
378
+							{
379
+								$to_subscribe [] = $node;
380
+							}
381
+							if ($value['value'])
382
+							{
383
+								$cont[] = $path;
384
+							}
336 385
 						}
337 386
 
338 387
 					}
@@ -420,9 +469,15 @@  discard block
 block discarded – undo
420 469
 	{
421 470
 		//error_log(__METHOD__.__LINE__.array2string($content));
422 471
 		try	{
423
-				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
472
+				if (!isset($this->mail_bo))
473
+				{
474
+					throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
475
+				}
424 476
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
477
+				if (Mail::$debugTimes)
478
+				{
479
+					$starttime = microtime (true);
480
+				}
426 481
 				$this->mail_bo->restoreSessionData();
427 482
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 483
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -451,7 +506,10 @@  discard block
 block discarded – undo
451 506
 							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
452 507
 						);
453 508
 					}
454
-					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
509
+					if (Api\Header\UserAgent::mobile())
510
+					{
511
+						$content[self::$nm_index]['header_row'] = 'mail.index.header_right';
512
+					}
455 513
 				}
456 514
 
457 515
 				// These must always be set, even if $content is an array
@@ -475,13 +533,16 @@  discard block
 block discarded – undo
475 533
 				}
476 534
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477 535
 				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
536
+				if($quota !== false && $quota['limit'] != 'NOT SET')
537
+				{
479 538
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 539
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481 540
 					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
482 541
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 542
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484
-				} else {
543
+				}
544
+				else
545
+				{
485 546
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
486 547
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
487 548
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -489,7 +550,8 @@  discard block
 block discarded – undo
489 550
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
490 551
 				$vacation = false;//$this->gatherVacation();
491 552
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
492
-				if($vacation) {
553
+				if($vacation)
554
+				{
493 555
 					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
494 556
 					{
495 557
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
@@ -523,19 +585,31 @@  discard block
 block discarded – undo
523 585
 					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
524 586
 					foreach($keywords as &$k)
525 587
 					{
526
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
588
+						if (array_key_exists($k,$this->statusTypes))
589
+						{
590
+							unset($this->statusTypes[$k]);
591
+						}
527 592
 					}
528 593
 				}
529 594
 
530
-				if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
531
-				if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
595
+				if (!isset($content[self::$nm_index]['foldertree']))
596
+				{
597
+					$content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
598
+				}
599
+				if (!isset($content[self::$nm_index]['selectedFolder']))
600
+				{
601
+					$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
602
+				}
532 603
 
533 604
 				$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
534 605
 
535 606
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
536 607
 				{
537 608
 					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
538
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
609
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
610
+					{
611
+						Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
612
+					}
539 613
 				}
540 614
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
541 615
 				{
@@ -557,10 +631,16 @@  discard block
 block discarded – undo
557 631
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
558 632
 
559 633
 				// sending preview toolbar actions
560
-				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
634
+				if ($content['mailSplitter'])
635
+				{
636
+					$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
637
+				}
561 638
 
562 639
 				// We need to send toolbar actions to client-side because view template needs them
563
-				if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions();
640
+				if (Api\Header\UserAgent::mobile())
641
+				{
642
+					$sel_options['toolbar'] = $this->get_toolbar_actions();
643
+				}
564 644
 
565 645
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
566 646
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
@@ -568,7 +648,10 @@  discard block
 block discarded – undo
568 648
 					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
569 649
 				}
570 650
 				$readonlys = $preserv = array();
571
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
651
+				if (Mail::$debugTimes)
652
+				{
653
+					Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
654
+				}
572 655
 		}
573 656
 		catch (Exception $e)
574 657
 		{
@@ -584,13 +667,19 @@  discard block
 block discarded – undo
584 667
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
585 668
 			}
586 669
 			$readonlys = $preserv = array();
587
-			if (empty($content)) $content=array();
670
+			if (empty($content))
671
+			{
672
+				$content=array();
673
+			}
588 674
 
589 675
 			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
590 676
 			//return false;
591 677
 		}
592 678
 		// Check preview pane is enabled, then show splitter
593
-		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('splitter', 'template', 'mail.index.nosplitter');
679
+		if ($this->mail_bo->mailPreferences['previewPane'])
680
+		{
681
+			$etpl->setElementAttribute('splitter', 'template', 'mail.index.nosplitter');
682
+		}
594 683
 
595 684
 		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
596 685
 	}
@@ -811,7 +900,8 @@  discard block
 block discarded – undo
811 900
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
812 901
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
813 902
 			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
814
-		} catch (Horde_Imap_Client_Exception $ex) {
903
+		}
904
+		catch (Horde_Imap_Client_Exception $ex) {
815 905
 			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
816 906
 			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
817 907
 		}
@@ -828,12 +918,18 @@  discard block
 block discarded – undo
828 918
 	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
829 919
 	{
830 920
 		$nodeID = $_GET['id'];
831
-		if (!is_null($_nodeID)) $nodeID = $_nodeID;
921
+		if (!is_null($_nodeID))
922
+		{
923
+			$nodeID = $_nodeID;
924
+		}
832 925
 		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
833 926
 		$fetchCounters = !is_null($_nodeID);
834 927
 		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
835 928
 
836
-		if (!empty($_folderName)) $fetchCounters = true;
929
+		if (!empty($_folderName))
930
+		{
931
+			$fetchCounters = true;
932
+		}
837 933
 
838 934
 		// Check if it is called for refresh root
839 935
 		// then we need to reinitialized the index tree
@@ -845,7 +941,10 @@  discard block
 block discarded – undo
845 941
 		{
846 942
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
847 943
 		}
848
-		if (!is_null($_nodeID)) return $data;
944
+		if (!is_null($_nodeID))
945
+		{
946
+			return $data;
947
+		}
849 948
 		Etemplate\Widget\Tree::send_quote_json($data);
850 949
 	}
851 950
 
@@ -911,7 +1010,10 @@  discard block
 block discarded – undo
911 1010
 				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
912 1011
 			}
913 1012
 		}
914
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
1013
+		if (!is_array($lastFoldersUsedForMoveCont))
1014
+		{
1015
+			$lastFoldersUsedForMoveCont=array();
1016
+		}
915 1017
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
916 1018
 		{
917 1019
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
@@ -927,9 +1029,12 @@  discard block
 block discarded – undo
927 1029
 						$moveaction .= $lastFolderUsedForMoveCont;
928 1030
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
929 1031
 						//error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey);
930
-						if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1032
+						if ($this->mail_bo->folderExists($i))
1033
+						{
1034
+							// only 10 entries per mailaccount.Control this on setting the buffered folders
931 1035
 						{
932 1036
 							$fS['profileID'] = $this->mail_bo->profileID;
1037
+						}
933 1038
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
934 1039
 							$fS['shortDisplayName'] = $i;
935 1040
 							$moveactions[$moveaction] = $fS;
@@ -949,9 +1054,12 @@  discard block
 block discarded – undo
949 1054
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
950 1055
 				{
951 1056
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
952
-					if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1057
+					if (!empty($lastFolderUsedForMoveCont))
1058
+					{
1059
+						// only 10 entries per mailaccount.Control this on setting the buffered folders
953 1060
 					{
954 1061
 						$moveaction = 'move_'.$lastFolderUsedForMoveCont;
1062
+					}
955 1063
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
956 1064
 						$fS = array();
957 1065
 						$fS['profileID'] = $pid;
@@ -1054,7 +1162,9 @@  discard block
 block discarded – undo
1054 1162
 				'children' => $children,
1055 1163
 			);
1056 1164
 
1057
-		} else {
1165
+		}
1166
+		else
1167
+		{
1058 1168
 			$group++;
1059 1169
 		}
1060 1170
 
@@ -1330,7 +1440,10 @@  discard block
 block discarded – undo
1330 1440
 					$rows=array();
1331 1441
 					return 0;
1332 1442
 				}
1333
-				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1443
+				if (empty($folderName))
1444
+				{
1445
+					$query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1446
+				}
1334 1447
 			}
1335 1448
 		}
1336 1449
 		if (!isset($mail_ui))
@@ -1345,15 +1458,24 @@  discard block
 block discarded – undo
1345 1458
 				$rows=array();
1346 1459
 				return 0;
1347 1460
 			}
1348
-			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1461
+			if (empty($query['selectedFolder']))
1462
+			{
1463
+				$query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1464
+			}
1349 1465
 		}
1350 1466
 		//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
1351 1467
 		//Mail::$debugTimes=true;
1352
-		if (Mail::$debugTimes) $starttime = microtime(true);
1468
+		if (Mail::$debugTimes)
1469
+		{
1470
+			$starttime = microtime(true);
1471
+		}
1353 1472
 		//$query['search'] is the phrase in the searchbox
1354 1473
 
1355 1474
 		$mail_ui->mail_bo->restoreSessionData();
1356
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1475
+		if (isset($query['selectedFolder']))
1476
+		{
1477
+			$mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1478
+		}
1357 1479
 		$mail_ui->mail_bo->saveSessionData();
1358 1480
 
1359 1481
 		$sRToFetch = null;
@@ -1364,7 +1486,10 @@  discard block
 block discarded – undo
1364 1486
 			unset($app);
1365 1487
 		}
1366 1488
 		//save selected Folder to sessionData (mailbox)->currentFolder
1367
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1489
+		if (isset($query['selectedFolder']))
1490
+		{
1491
+			$mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1492
+		}
1368 1493
 		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1369 1494
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1370 1495
 		{
@@ -1397,8 +1522,16 @@  discard block
 block discarded – undo
1397 1522
 			}
1398 1523
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1399 1524
 			$cutoffdate = $cutoffdate2 = null;
1400
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1401
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1525
+			if ($query['startdate'])
1526
+			{
1527
+				$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
1528
+			}
1529
+			//SINCE, enddate
1530
+			if ($query['enddate'])
1531
+			{
1532
+				$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
1533
+			}
1534
+			//BEFORE, startdate
1402 1535
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1403 1536
 			$filter = array(
1404 1537
 				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -1407,15 +1540,24 @@  discard block
 block discarded – undo
1407 1540
 				'status' => 'any',
1408 1541
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1409 1542
 			);
1410
-			if ($query['enddate']||$query['startdate']) {
1543
+			if ($query['enddate']||$query['startdate'])
1544
+			{
1411 1545
 				$filter['range'] = "BETWEEN";
1412
-				if ($cutoffdate) {
1546
+				if ($cutoffdate)
1547
+				{
1413 1548
 					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1414
-					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1549
+					if (empty($cutoffdate2))
1550
+					{
1551
+						$filter['range'] = "SINCE";
1552
+					}
1415 1553
 				}
1416
-				if ($cutoffdate2) {
1554
+				if ($cutoffdate2)
1555
+				{
1417 1556
 					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1418
-					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1557
+					if (empty($cutoffdate))
1558
+					{
1559
+						$filter['range'] = "BEFORE";
1560
+					}
1419 1561
 				}
1420 1562
 			}
1421 1563
 		}
@@ -1468,7 +1610,10 @@  discard block
 block discarded – undo
1468 1610
 				$rowsFetched['messages'] = $_sR['count'];
1469 1611
 				$ids = $_sR['match']->ids;
1470 1612
 				// if $sR is false, something failed fundamentally
1471
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1613
+				if($reverse === true)
1614
+				{
1615
+					$ids = ($ids===false?array():array_reverse((array)$ids));
1616
+				}
1472 1617
 				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1473 1618
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1474 1619
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
@@ -1534,7 +1679,10 @@  discard block
 block discarded – undo
1534 1679
 				}
1535 1680
 				else
1536 1681
 				{
1537
-					if (!empty($v)) $sortResult['header'][] = array('uid'=>$v);
1682
+					if (!empty($v))
1683
+					{
1684
+						$sortResult['header'][] = array('uid'=>$v);
1685
+					}
1538 1686
 				}
1539 1687
 			}
1540 1688
 		}
@@ -1543,15 +1691,24 @@  discard block
 block discarded – undo
1543 1691
 			$sortResult = $sortResultwH;
1544 1692
 		}
1545 1693
 		$rowsFetched['rowsFetched'] = count($sortResult['header']);
1546
-		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1694
+		if (empty($rowsFetched['messages']))
1695
+		{
1696
+			$rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1697
+		}
1547 1698
 
1548 1699
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1549 1700
 		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1550
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1701
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE')
1702
+		{
1703
+			unset($cols[0]);
1704
+		}
1551 1705
 		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1552 1706
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1553 1707
 
1554
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1708
+		if (Mail::$debugTimes)
1709
+		{
1710
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1711
+		}
1555 1712
 		return $rowsFetched['messages'];
1556 1713
 	}
1557 1714
 
@@ -1653,7 +1810,10 @@  discard block
 block discarded – undo
1653 1810
 					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1654 1811
 					break;
1655 1812
 				default:
1656
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1813
+					if (isset($actions[$act]))
1814
+					{
1815
+						$actionsenabled[$act]=$actions[$act];
1816
+					}
1657 1817
 			}
1658 1818
 		}
1659 1819
 		unset($actionsenabled['drag_mail']);
@@ -1675,7 +1835,10 @@  discard block
 block discarded – undo
1675 1835
 	 */
1676 1836
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1677 1837
 	{
1678
-		if (Mail::$debugTimes) $starttime = microtime(true);
1838
+		if (Mail::$debugTimes)
1839
+		{
1840
+			$starttime = microtime(true);
1841
+		}
1679 1842
 		$rv = array();
1680 1843
 		$i=0;
1681 1844
 		foreach((array)$_headers as $header)
@@ -1688,17 +1851,50 @@  discard block
 block discarded – undo
1688 1851
 			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1689 1852
 
1690 1853
 			$flags = "";
1691
-			if(!empty($header['recent'])) $flags .= "R";
1692
-			if(!empty($header['flagged'])) $flags .= "F";
1693
-			if(!empty($header['answered'])) $flags .= "A";
1694
-			if(!empty($header['forwarded'])) $flags .= "W";
1695
-			if(!empty($header['deleted'])) $flags .= "D";
1696
-			if(!empty($header['seen'])) $flags .= "S";
1697
-			if(!empty($header['label1'])) $flags .= "1";
1698
-			if(!empty($header['label2'])) $flags .= "2";
1699
-			if(!empty($header['label3'])) $flags .= "3";
1700
-			if(!empty($header['label4'])) $flags .= "4";
1701
-			if(!empty($header['label5'])) $flags .= "5";
1854
+			if(!empty($header['recent']))
1855
+			{
1856
+				$flags .= "R";
1857
+			}
1858
+			if(!empty($header['flagged']))
1859
+			{
1860
+				$flags .= "F";
1861
+			}
1862
+			if(!empty($header['answered']))
1863
+			{
1864
+				$flags .= "A";
1865
+			}
1866
+			if(!empty($header['forwarded']))
1867
+			{
1868
+				$flags .= "W";
1869
+			}
1870
+			if(!empty($header['deleted']))
1871
+			{
1872
+				$flags .= "D";
1873
+			}
1874
+			if(!empty($header['seen']))
1875
+			{
1876
+				$flags .= "S";
1877
+			}
1878
+			if(!empty($header['label1']))
1879
+			{
1880
+				$flags .= "1";
1881
+			}
1882
+			if(!empty($header['label2']))
1883
+			{
1884
+				$flags .= "2";
1885
+			}
1886
+			if(!empty($header['label3']))
1887
+			{
1888
+				$flags .= "3";
1889
+			}
1890
+			if(!empty($header['label4']))
1891
+			{
1892
+				$flags .= "4";
1893
+			}
1894
+			if(!empty($header['label5']))
1895
+			{
1896
+				$flags .= "5";
1897
+			}
1702 1898
 
1703 1899
 			$data["status"] = "<span class=\"status_img\"></span>";
1704 1900
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
@@ -1706,41 +1902,53 @@  discard block
 block discarded – undo
1706 1902
 			// the css for this row
1707 1903
 			$is_recent=false;
1708 1904
 			$css_styles = array("mail");
1709
-			if ($header['deleted']) {
1905
+			if ($header['deleted'])
1906
+			{
1710 1907
 				$css_styles[] = 'deleted';
1711 1908
 			}
1712
-			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1909
+			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded']))
1910
+			{
1713 1911
 				$css_styles[] = 'recent';
1714 1912
 				$is_recent=true;
1715 1913
 			}
1716
-			if ($header['priority'] < 3) {
1914
+			if ($header['priority'] < 3)
1915
+			{
1717 1916
 				$css_styles[] = 'prio_high';
1718 1917
 			}
1719
-			if ($header['flagged']) {
1918
+			if ($header['flagged'])
1919
+			{
1720 1920
 				$css_styles[] = 'flagged';
1721 1921
 			}
1722
-			if (!$header['seen']) {
1922
+			if (!$header['seen'])
1923
+			{
1723 1924
 				$css_styles[] = 'unseen'; // different status image for recent // solved via css !important
1724 1925
 			}
1725
-			if ($header['answered']) {
1926
+			if ($header['answered'])
1927
+			{
1726 1928
 				$css_styles[] = 'replied';
1727 1929
 			}
1728
-			if ($header['forwarded']) {
1930
+			if ($header['forwarded'])
1931
+			{
1729 1932
 				$css_styles[] = 'forwarded';
1730 1933
 			}
1731
-			if ($header['label1']) {
1934
+			if ($header['label1'])
1935
+			{
1732 1936
 				$css_styles[] = 'labelone';
1733 1937
 			}
1734
-			if ($header['label2']) {
1938
+			if ($header['label2'])
1939
+			{
1735 1940
 				$css_styles[] = 'labeltwo';
1736 1941
 			}
1737
-			if ($header['label3']) {
1942
+			if ($header['label3'])
1943
+			{
1738 1944
 				$css_styles[] = 'labelthree';
1739 1945
 			}
1740
-			if ($header['label4']) {
1946
+			if ($header['label4'])
1947
+			{
1741 1948
 				$css_styles[] = 'labelfour';
1742 1949
 			}
1743
-			if ($header['label5']) {
1950
+			if ($header['label5'])
1951
+			{
1744 1952
 				$css_styles[] = 'labelfive';
1745 1953
 			}
1746 1954
 
@@ -1757,10 +1965,13 @@  discard block
 block discarded – undo
1757 1965
 				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1758 1966
 				// curly brackets get messed up by the template!
1759 1967
 
1760
-				if (!empty($header['subject'])) {
1968
+				if (!empty($header['subject']))
1969
+				{
1761 1970
 					// make the subject shorter if it is to long
1762 1971
 					$subject = $header['subject'];
1763
-				} else {
1972
+				}
1973
+				else
1974
+				{
1764 1975
 					$subject = '('. lang('no subject') .')';
1765 1976
 				}
1766 1977
 
@@ -1802,15 +2013,22 @@  discard block
 block discarded – undo
1802 2013
 					}
1803 2014
 
1804 2015
 					$attachmentFlag = $image;
1805
-				} else {
2016
+				}
2017
+				else
2018
+				{
1806 2019
 					$attachmentFlag ='&nbsp;';
1807 2020
 				}
1808 2021
 				// show priority flag
1809
-				if ($header['priority'] < 3) {
2022
+				if ($header['priority'] < 3)
2023
+				{
1810 2024
 					 $image = Api\Html::image('mail','prio_high');
1811
-				} elseif ($header['priority'] > 3) {
2025
+				}
2026
+				elseif ($header['priority'] > 3)
2027
+				{
1812 2028
 					$image = Api\Html::image('mail','prio_low');
1813
-				} else {
2029
+				}
2030
+				else
2031
+				{
1814 2032
 					$image = '';
1815 2033
 				}
1816 2034
 				// show a flag for flagged messages
@@ -1852,26 +2070,53 @@  discard block
 block discarded – undo
1852 2070
 			}
1853 2071
 
1854 2072
 			if (in_array("size", $cols))
1855
-				$data["size"] = $header['size']; /// size
2073
+			{
2074
+							$data["size"] = $header['size'];
2075
+			}
2076
+			/// size
1856 2077
 
1857 2078
 			$data["class"] = implode(' ', $css_styles);
1858 2079
 			//translate style-classes back to flags
1859 2080
 			$data['flags'] = Array();
1860
-			if ($header['seen']) $data["flags"]['read'] = 'read';
1861
-			foreach ($css_styles as &$flag) {
2081
+			if ($header['seen'])
2082
+			{
2083
+				$data["flags"]['read'] = 'read';
2084
+			}
2085
+			foreach ($css_styles as &$flag)
2086
+			{
1862 2087
 				if ($flag!='mail')
1863 2088
 				{
1864
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1865
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1866
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1867
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1868
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1869
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1870
-					else $data["flags"][$flag] = $flag;
2089
+					if ($flag=='labelone')
2090
+					{
2091
+$data["flags"]['label1'] = 'label1';}
2092
+					elseif ($flag=='labeltwo')
2093
+					{
2094
+$data["flags"]['label2'] = 'label2';}
2095
+					elseif ($flag=='labelthree')
2096
+					{
2097
+$data["flags"]['label3'] = 'label3';}
2098
+					elseif ($flag=='labelfour')
2099
+					{
2100
+$data["flags"]['label4'] = 'label4';}
2101
+					elseif ($flag=='labelfive')
2102
+					{
2103
+$data["flags"]['label5'] = 'label5';}
2104
+					elseif ($flag=='unseen')
2105
+					{
2106
+unset($data["flags"]['read']);}
2107
+					else {
2108
+						$data["flags"][$flag] = $flag;
2109
+					}
1871 2110
 				}
1872 2111
 			}
1873
-			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1874
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2112
+			if ($header['disposition-notification-to'])
2113
+			{
2114
+				$data['dispositionnotificationto'] = $header['disposition-notification-to'];
2115
+			}
2116
+			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto']))
2117
+			{
2118
+				unset($data['dispositionnotificationto']);
2119
+			}
1875 2120
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1876 2121
 			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1877 2122
 			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
@@ -1881,7 +2126,10 @@  discard block
 block discarded – undo
1881 2126
 			$rv[] = $data;
1882 2127
 			//error_log(__METHOD__.__LINE__.array2string($data));
1883 2128
 		}
1884
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2129
+		if (Mail::$debugTimes)
2130
+		{
2131
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2132
+		}
1885 2133
 
1886 2134
 		// ToDo: call this ONLY if labels change
1887 2135
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1896,8 +2144,14 @@  discard block
 block discarded – undo
1896 2144
 	 */
1897 2145
 	function displayHeader()
1898 2146
 	{
1899
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1900
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2147
+		if(isset($_GET['id']))
2148
+		{
2149
+			$rowID	= $_GET['id'];
2150
+		}
2151
+		if(isset($_GET['part']))
2152
+		{
2153
+			$partID = $_GET['part'];
2154
+		}
1901 2155
 
1902 2156
 		$hA = self::splitRowID($rowID);
1903 2157
 		$uid = $hA['msgUID'];
@@ -1921,7 +2175,8 @@  discard block
 block discarded – undo
1921 2175
 		$rawheaders 	= "";
1922 2176
 		// create it new, with good line breaks
1923 2177
 		reset($newRawHeaders);
1924
-		while(list($key,$value) = @each($newRawHeaders)) {
2178
+		while(list($key,$value) = @each($newRawHeaders))
2179
+		{
1925 2180
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1926 2181
 		}
1927 2182
 
@@ -1944,12 +2199,24 @@  discard block
 block discarded – undo
1944 2199
 	 */
1945 2200
 	function displayMessage($_requesteddata = null)
1946 2201
 	{
1947
-		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2202
+		if (is_null($_requesteddata))
2203
+		{
2204
+			$_requesteddata = $_GET;
2205
+		}
1948 2206
 
1949 2207
 		$preventRedirect=false;
1950
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1951
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1952
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2208
+		if(isset($_requesteddata['id']))
2209
+		{
2210
+			$rowID	= $_requesteddata['id'];
2211
+		}
2212
+		if(isset($_requesteddata['part']))
2213
+		{
2214
+			$partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2215
+		}
2216
+		if(isset($_requesteddata['mode']))
2217
+		{
2218
+			$preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2219
+		}
1953 2220
 
1954 2221
 		$hA = self::splitRowID($rowID);
1955 2222
 		$uid = $hA['msgUID'];
@@ -1962,8 +2229,14 @@  discard block
 block discarded – undo
1962 2229
 			$this->changeProfile($icServerID);
1963 2230
 		}
1964 2231
 		$htmlOptions = $this->mail_bo->htmlOptions;
1965
-		if (!empty($_requesteddata['tryastext'])) $htmlOptions  = "only_if_no_text";
1966
-		if (!empty($_requesteddata['tryashtml'])) $htmlOptions  = "always_display";
2232
+		if (!empty($_requesteddata['tryastext']))
2233
+		{
2234
+			$htmlOptions  = "only_if_no_text";
2235
+		}
2236
+		if (!empty($_requesteddata['tryashtml']))
2237
+		{
2238
+			$htmlOptions  = "always_display";
2239
+		}
1967 2240
 
1968 2241
 		//error_log(__METHOD__.__LINE__.array2string($hA));
1969 2242
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
@@ -1987,14 +2260,20 @@  discard block
 block discarded – undo
1987 2260
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1988 2261
 			Framework::message($e->getMessage(), 'error');
1989 2262
 		}
1990
-		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2263
+		if (!empty($uid))
2264
+		{
2265
+			$this->mail_bo->getFlags($uid);
2266
+		}
1991 2267
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1992 2268
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1993 2269
 		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1994 2270
 		$fetchEmbeddedImages = false;
1995 2271
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1996 2272
 		// we do NOT want to see those, that are embedded in the list of attachments
1997
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2273
+		if ($htmlOptions !='always_display')
2274
+		{
2275
+			$fetchEmbeddedImages = true;
2276
+		}
1998 2277
 		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1999 2278
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2000 2279
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
@@ -2010,11 +2289,17 @@  discard block
 block discarded – undo
2010 2289
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2011 2290
 
2012 2291
 		// Set up data for taglist widget(s)
2013
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2292
+		if ($envelope['FROM']==$envelope['SENDER'])
2293
+		{
2294
+			unset($envelope['SENDER']);
2295
+		}
2014 2296
 		$sel_options = array();
2015 2297
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2016 2298
 		{
2017
-			if (!isset($envelope[$field])) continue;
2299
+			if (!isset($envelope[$field]))
2300
+			{
2301
+				continue;
2302
+			}
2018 2303
 			foreach($envelope[$field] as $field_data)
2019 2304
 			{
2020 2305
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
@@ -2028,7 +2313,10 @@  discard block
 block discarded – undo
2028 2313
 		}
2029 2314
 		$actionsenabled = $this->getDisplayToolbarActions();
2030 2315
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2031
-		if (empty($subject)) $subject = lang('no subject');
2316
+		if (empty($subject))
2317
+		{
2318
+			$subject = lang('no subject');
2319
+		}
2032 2320
 		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2033 2321
 		// Send mail ID so we can use it for actions
2034 2322
 		$content['mail_id'] = $rowID;
@@ -2039,8 +2327,14 @@  discard block
 block discarded – undo
2039 2327
 		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2040 2328
 		$content['mail_displaysubject'] = $subject;
2041 2329
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2042
-		if (!empty($partID)) $linkData['_partID']=$partID;
2043
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2330
+		if (!empty($partID))
2331
+		{
2332
+			$linkData['_partID']=$partID;
2333
+		}
2334
+		if ($htmlOptions != $this->mail_bo->htmlOptions)
2335
+		{
2336
+			$linkData['_htmloptions']=$htmlOptions;
2337
+		}
2044 2338
 		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2045 2339
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2046 2340
 		$content['mail_id']=$rowID;
@@ -2108,7 +2402,8 @@  discard block
 block discarded – undo
2108 2402
 	{
2109 2403
 		$attachmentHTMLBlock='';
2110 2404
 		$attachmentHTML = array();
2111
-		if (is_array($attachments) && count($attachments) > 0) {
2405
+		if (is_array($attachments) && count($attachments) > 0)
2406
+		{
2112 2407
 			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2113 2408
 			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2114 2409
 
@@ -2118,7 +2413,10 @@  discard block
 block discarded – undo
2118 2413
 				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2119 2414
 				//error_log(array2string($value));
2120 2415
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2121
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2416
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM'))
2417
+				{
2418
+					$value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2419
+				}
2122 2420
 				$attachmentHTML[$key]['type']=$value['mimeType'];
2123 2421
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2124 2422
 				$hA = self::splitRowID($rowID);
@@ -2161,8 +2459,15 @@  discard block
 block discarded – undo
2161 2459
 						$sfxMimeType = $value['mimeType'];
2162 2460
 						$buff = explode('.',$value['name']);
2163 2461
 						$suffix = '';
2164
-						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2165
-						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2462
+						if (is_array($buff))
2463
+						{
2464
+							$suffix = array_pop($buff);
2465
+						}
2466
+						// take the last extension to check with ext2mime
2467
+						if (!empty($suffix))
2468
+						{
2469
+							$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2470
+						}
2166 2471
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2167 2472
 						{
2168 2473
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2331,9 +2636,12 @@  discard block
 block discarded – undo
2331 2636
 	function quotaDisplay($_usage, $_limit)
2332 2637
 	{
2333 2638
 
2334
-		if($_limit == 0) {
2639
+		if($_limit == 0)
2640
+		{
2335 2641
 			$quotaPercent=100;
2336
-		} else {
2642
+		}
2643
+		else
2644
+		{
2337 2645
 			$quotaPercent=round(($_usage*100)/$_limit);
2338 2646
 		}
2339 2647
 
@@ -2341,22 +2649,33 @@  discard block
 block discarded – undo
2341 2649
 		$quotaUsage=Mail::show_readable_size($_usage*1024);
2342 2650
 
2343 2651
 
2344
-		if($quotaPercent > 90 && $_limit>0) {
2652
+		if($quotaPercent > 90 && $_limit>0)
2653
+		{
2345 2654
 			$quotaBG='mail-index_QuotaRed';
2346
-		} elseif($quotaPercent > 80 && $_limit>0) {
2655
+		}
2656
+		elseif($quotaPercent > 80 && $_limit>0)
2657
+		{
2347 2658
 			$quotaBG='mail-index_QuotaYellow';
2348
-		} else {
2659
+		}
2660
+		else
2661
+		{
2349 2662
 			$quotaBG='mail-index_QuotaGreen';
2350 2663
 		}
2351 2664
 
2352
-		if($_limit > 0) {
2665
+		if($_limit > 0)
2666
+		{
2353 2667
 			$quotaText = $quotaUsage .'/'.$quotaLimit;
2354
-		} else {
2668
+		}
2669
+		else
2670
+		{
2355 2671
 			$quotaText = $quotaUsage;
2356 2672
 		}
2357 2673
 
2358
-		if($quotaPercent > 50) {
2359
-		} else {
2674
+		if($quotaPercent > 50)
2675
+		{
2676
+		}
2677
+		else
2678
+		{
2360 2679
 		}
2361 2680
 		$quota['class'] = $quotaBG;
2362 2681
 		$quota['text'] = lang('Quota: %1',$quotaText);
@@ -2374,7 +2693,10 @@  discard block
 block discarded – undo
2374 2693
 		$uid	= $_GET['uid'];
2375 2694
 		$cid	= base64_decode($_GET['cid']);
2376 2695
 		$partID = urldecode($_GET['partID']);
2377
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2696
+		if (!empty($_GET['mailbox']))
2697
+		{
2698
+			$mailbox  = base64_decode($_GET['mailbox']);
2699
+		}
2378 2700
 
2379 2701
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2380 2702
 		$this->mail_bo->reopen($mailbox);
@@ -2406,7 +2728,10 @@  discard block
 block discarded – undo
2406 2728
 
2407 2729
 	function getAttachment()
2408 2730
 	{
2409
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2731
+		if(isset($_GET['id']))
2732
+		{
2733
+			$rowID	= $_GET['id'];
2734
+		}
2410 2735
 
2411 2736
 		$hA = self::splitRowID($rowID);
2412 2737
 		$uid = $hA['msgUID'];
@@ -2439,10 +2764,20 @@  discard block
 block discarded – undo
2439 2764
 				$sfxMimeType = $attachment['type'];
2440 2765
 				$buff = explode('.',$attachment['filename']);
2441 2766
 				$suffix = '';
2442
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2443
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2767
+				if (is_array($buff))
2768
+				{
2769
+					$suffix = array_pop($buff);
2770
+				}
2771
+				// take the last extension to check with ext2mime
2772
+				if (!empty($suffix))
2773
+				{
2774
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2775
+				}
2444 2776
 				$attachment['type'] = $sfxMimeType;
2445
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2777
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2778
+				{
2779
+					$attachment['type'] = strtoupper($sfxMimeType);
2780
+				}
2446 2781
 			}
2447 2782
 			//error_log(__METHOD__.print_r($attachment,true));
2448 2783
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2451,7 +2786,10 @@  discard block
 block discarded – undo
2451 2786
 				$calendar_ical = new calendar_ical();
2452 2787
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2453 2788
 				//error_log(__METHOD__.array2string($eventid));
2454
-				if (!$eventid) $eventid = -1;
2789
+				if (!$eventid)
2790
+				{
2791
+					$eventid = -1;
2792
+				}
2455 2793
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2456 2794
 				//error_log(__METHOD__.$event);
2457 2795
 				if ((int)$event > 0)
@@ -2477,7 +2815,10 @@  discard block
 block discarded – undo
2477 2815
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2478 2816
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2479 2817
 				}
2480
-				if (!$contact) $contact = null;
2818
+				if (!$contact)
2819
+				{
2820
+					$contact = null;
2821
+				}
2481 2822
 				// 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))
2482 2823
 				if ($contact || count($vcard)>2)
2483 2824
 				{
@@ -2511,9 +2852,18 @@  discard block
 block discarded – undo
2511 2852
 	function saveMessage()
2512 2853
 	{
2513 2854
 		$display = false;
2514
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2515
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2516
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2855
+		if(isset($_GET['id']))
2856
+		{
2857
+			$rowID	= $_GET['id'];
2858
+		}
2859
+		if(isset($_GET['part']))
2860
+		{
2861
+			$partID = $_GET['part'];
2862
+		}
2863
+		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager'))
2864
+		{
2865
+			$display	= $_GET['location'];
2866
+		}
2517 2867
 
2518 2868
 		$hA = self::splitRowID($rowID);
2519 2869
 		$uid = $hA['msgUID'];
@@ -2602,7 +2952,10 @@  discard block
 block discarded – undo
2602 2952
 			{
2603 2953
 				$succeeded = true;
2604 2954
 			}
2605
-			if ($fp) fclose($fp);
2955
+			if ($fp)
2956
+			{
2957
+				fclose($fp);
2958
+			}
2606 2959
 			if ($succeeded)
2607 2960
 			{
2608 2961
 				unset($headers['SUBJECT']);//already in filename
@@ -2652,7 +3005,8 @@  discard block
 block discarded – undo
2652 3005
 		 *
2653 3006
 		 * @return array an array of parameters
2654 3007
 		 */
2655
-		$getParams = function ($id) {
3008
+		$getParams = function ($id)
3009
+		{
2656 3010
 			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2657 3011
 			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2658 3012
 			$hA = mail_ui::splitRowID($lId);
@@ -2688,7 +3042,10 @@  discard block
 block discarded – undo
2688 3042
 		{
2689 3043
 			$params = $getParams($id);
2690 3044
 			// when downloading a single file, name is not set
2691
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
3045
+			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload)
3046
+			{
3047
+				$params['name'] = $_GET['name'];
3048
+			}
2692 3049
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2693 3050
 			{
2694 3051
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2701,7 +3058,10 @@  discard block
 block discarded – undo
2701 3058
 				// Try to find the right content for file id
2702 3059
 				foreach ($attachments as $key => $val)
2703 3060
 				{
2704
-					if ($key == $params['is_winmail']) $attachment = $val;
3061
+					if ($key == $params['is_winmail'])
3062
+					{
3063
+						$attachment = $val;
3064
+					}
2705 3065
 				}
2706 3066
 			}
2707 3067
 			else
@@ -2748,7 +3108,10 @@  discard block
 block discarded – undo
2748 3108
 	{
2749 3109
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2750 3110
 		// First, get all attachment IDs
2751
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
3111
+		if(isset($_GET['id']))
3112
+		{
3113
+			$message_id	= $_GET['id'];
3114
+		}
2752 3115
 		//error_log(__METHOD__.__LINE__.$message_id);
2753 3116
 		$rememberServerID = $this->mail_bo->profileID;
2754 3117
 		if(!is_numeric($message_id))
@@ -2775,7 +3138,10 @@  discard block
 block discarded – undo
2775 3138
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2776 3139
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2777 3140
 		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2778
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
3141
+		if(Vfs::is_dir($temp_path))
3142
+		{
3143
+			Vfs::remove ($temp_path);
3144
+		}
2779 3145
 
2780 3146
 		// Add subject to path, so it gets used as the file name
2781 3147
 		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
@@ -2800,7 +3166,10 @@  discard block
 block discarded – undo
2800 3166
 				foreach ($tnefAttachments as $key => $val)
2801 3167
 				{
2802 3168
 					error_log(__METHOD__.' winmail = '.$key);
2803
-					if ($key == $file['is_winmail']) $attachment = $val;
3169
+					if ($key == $file['is_winmail'])
3170
+					{
3171
+						$attachment = $val;
3172
+					}
2804 3173
 				}
2805 3174
 			}
2806 3175
 			else
@@ -2808,7 +3177,10 @@  discard block
 block discarded – undo
2808 3177
 				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2809 3178
 			}
2810 3179
 			$success=true;
2811
-			if (empty($file['filename'])) $file['filename'] = $file['name'];
3180
+			if (empty($file['filename']))
3181
+			{
3182
+				$file['filename'] = $file['name'];
3183
+			}
2812 3184
 			if(in_array($path.$file['filename'], $file_list))
2813 3185
 			{
2814 3186
 				$dupe_count[$path.$file['filename']]++;
@@ -2822,8 +3194,14 @@  discard block
 block discarded – undo
2822 3194
 				$success=false;
2823 3195
 				Framework::message("Unable to zip {$file['filename']}",'error');
2824 3196
 			}
2825
-			if ($success) $file_list[] = $path.$file['filename'];
2826
-			if ($fp) fclose($fp);
3197
+			if ($success)
3198
+			{
3199
+				$file_list[] = $path.$file['filename'];
3200
+			}
3201
+			if ($fp)
3202
+			{
3203
+				fclose($fp);
3204
+			}
2827 3205
 		}
2828 3206
 		$this->mail_bo->closeConnection();
2829 3207
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2850,7 +3228,10 @@  discard block
 block discarded – undo
2850 3228
 		$this->uid = $uid;
2851 3229
 		$this->partID = $partID;
2852 3230
 		$bufferHtmlOptions = $this->mail_bo->htmlOptions;
2853
-		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
3231
+		if (empty($htmlOptions))
3232
+		{
3233
+			$htmlOptions = $this->mail_bo->htmlOptions;
3234
+		}
2854 3235
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2855 3236
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2856 3237
 		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
@@ -2914,10 +3295,16 @@  discard block
 block discarded – undo
2914 3295
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2915 3296
 
2916 3297
 		$EndBody = '</td></tr></table></div>';
2917
-		if ($fullPageTags) $EndBody .= "</body></html>";
2918
-		if ($print)	{
3298
+		if ($fullPageTags)
3299
+		{
3300
+			$EndBody .= "</body></html>";
3301
+		}
3302
+		if ($print)
3303
+		{
2919 3304
 			print $BeginBody. $body .$EndBody;
2920
-		} else {
3305
+		}
3306
+		else
3307
+		{
2921 3308
 			return $BeginBody. $body .$EndBody;
2922 3309
 		}
2923 3310
 	}
@@ -2933,9 +3320,14 @@  discard block
 block discarded – undo
2933 3320
 		$body = '';
2934 3321
 
2935 3322
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2936
-		if (empty($bodyParts)) return "";
2937
-		foreach((array)$bodyParts as $singleBodyPart) {
2938
-			if (!isset($singleBodyPart['body'])) {
3323
+		if (empty($bodyParts))
3324
+		{
3325
+			return "";
3326
+		}
3327
+		foreach((array)$bodyParts as $singleBodyPart)
3328
+		{
3329
+			if (!isset($singleBodyPart['body']))
3330
+			{
2939 3331
 				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2940 3332
 				$body .= $singleBodyPart['body'];
2941 3333
 				continue;
@@ -2946,7 +3338,8 @@  discard block
 block discarded – undo
2946 3338
 				$body .= '';
2947 3339
 				continue;
2948 3340
 			}
2949
-			if(!empty($body)) {
3341
+			if(!empty($body))
3342
+			{
2950 3343
 				$body .= '<hr style="border:dotted 1px silver;">';
2951 3344
 			}
2952 3345
 			//error_log($singleBodyPart['body']);
@@ -2984,16 +3377,25 @@  discard block
 block discarded – undo
2984 3377
 				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2985 3378
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2986 3379
 				// if empty and charset is utf8 try sanitizing the string in question
2987
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3380
+				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8')
3381
+				{
3382
+					$newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3383
+				}
2988 3384
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2989
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3385
+				if (empty($newBody))
3386
+				{
3387
+					$newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3388
+				}
2990 3389
 
2991 3390
 				// search http[s] links and make them as links available again
2992 3391
 				// to understand what's going on here, have a look at
2993 3392
 				// http://www.php.net/manual/en/function.preg-replace.php
2994 3393
 
2995 3394
 				// create links for websites
2996
-				if ($modifyURI) $newBody = Api\Html::activate_links($newBody);
3395
+				if ($modifyURI)
3396
+				{
3397
+					$newBody = Api\Html::activate_links($newBody);
3398
+				}
2997 3399
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2998 3400
 				// redirect links for websites if you use no cookies
2999 3401
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -3035,10 +3437,13 @@  discard block
 block discarded – undo
3035 3437
 					{
3036 3438
 						$newBody = $cleaned;
3037 3439
 					}
3038
-					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3440
+					if (!$preserveHTML)
3441
+					{
3442
+						// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3039 3443
 					{
3040 3444
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3041 3445
 						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3446
+					}
3042 3447
 						if ($matches[2])
3043 3448
 						{
3044 3449
 							$hasOther = true;
@@ -3060,7 +3465,10 @@  discard block
 block discarded – undo
3060 3465
 					// as we switched off HTMLaweds tidy functionality
3061 3466
 					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3062 3467
 					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3063
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3468
+					if ($hasOther && $preserveHTML)
3469
+					{
3470
+						$newBody = $matches[1]. $newBody. $matches[3];
3471
+					}
3064 3472
 					$alreadyHtmlLawed=true;
3065 3473
 				}
3066 3474
 				// do the cleanup, set for the use of purifier
@@ -3165,7 +3573,10 @@  discard block
 block discarded – undo
3165 3573
 		*/
3166 3574
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3167 3575
 		{
3168
-			if (!$_type)	return false;
3576
+			if (!$_type)
3577
+			{
3578
+				return false;
3579
+			}
3169 3580
 			$CID = '';
3170 3581
 			// Build up matches according to selected type
3171 3582
 			switch ($_type)
@@ -3208,9 +3619,12 @@  discard block
 block discarded – undo
3208 3619
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
3209 3620
 
3210 3621
 							// only use data uri for "smaller" images, as otherwise the first display of the mail takes to long
3211
-							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)	// msie=8 allows max 32k data uris
3622
+							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)
3623
+							{
3624
+								// msie=8 allows max 32k data uris
3212 3625
 							{
3213 3626
 								$bo->fetchPartContents($_uid, $attachment);
3627
+							}
3214 3628
 								$cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents());
3215 3629
 							}
3216 3630
 							else
@@ -3282,7 +3696,10 @@  discard block
 block discarded – undo
3282 3696
 			}
3283 3697
 			$destination = $content['FOLDER'][0];
3284 3698
 
3285
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3699
+			if (stripos($destination,self::$delimiter)!==false)
3700
+			{
3701
+				list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3702
+			}
3286 3703
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3287 3704
 			{
3288 3705
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3307,14 +3724,26 @@  discard block
 block discarded – undo
3307 3724
 			if (!$importFailed)
3308 3725
 			{
3309 3726
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3310
-				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3727
+				if ($width > 0 && $height > 0)
3728
+				{
3729
+					Api\Json\Response::get()->call('resizeTo', $width, $height);
3730
+				}
3311 3731
 				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3312 3732
 				return;
3313 3733
 			}
3314 3734
 		}
3315
-		if (!is_array($content)) $content = array();
3316
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3317
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3735
+		if (!is_array($content))
3736
+		{
3737
+			$content = array();
3738
+		}
3739
+		if (empty($content['FOLDER']))
3740
+		{
3741
+			$content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3742
+		}
3743
+		if (!empty($content['FOLDER']))
3744
+		{
3745
+			$sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3746
+		}
3318 3747
 
3319 3748
 		$etpl = new Etemplate('mail.importMessage');
3320 3749
 		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
@@ -3334,7 +3763,10 @@  discard block
 block discarded – undo
3334 3763
 	{
3335 3764
 		$importfailed = false;
3336 3765
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
3337
-		if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name'];
3766
+		if (empty($_formData['file']))
3767
+		{
3768
+			$_formData['file'] = $_formData['tmp_name'];
3769
+		}
3338 3770
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3339 3771
 		try
3340 3772
 		{
@@ -3365,10 +3797,14 @@  discard block
 block discarded – undo
3365 3797
 				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3366 3798
 			}
3367 3799
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3368
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3800
+			if($_folder=='INBOX'.$delimiter)
3801
+			{
3802
+				$_folder='INBOX';
3803
+			}
3369 3804
 			if ($importfailed === false)
3370 3805
 			{
3371
-				if ($this->mail_bo->folderExists($_folder,true)) {
3806
+				if ($this->mail_bo->folderExists($_folder,true))
3807
+				{
3372 3808
 					try
3373 3809
 					{
3374 3810
 						$messageUid = $this->mail_bo->appendMessage($_folder,
@@ -3429,7 +3865,10 @@  discard block
 block discarded – undo
3429 3865
 	 */
3430 3866
 	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3431 3867
 	{
3432
-		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3868
+		if (empty($formData))
3869
+		{
3870
+			if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3871
+		}
3433 3872
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
3434 3873
 		$draftFolder = $this->mail_bo->getDraftFolder(false);
3435 3874
 		$importID = Mail::getRandomString();
@@ -3443,15 +3882,26 @@  discard block
 block discarded – undo
3443 3882
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3444 3883
 		{
3445 3884
 			$buff = explode('/',$formData['file']);
3446
-			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3885
+			if (is_array($buff))
3886
+			{
3887
+				$formData['name'] = array_pop($buff);
3888
+			}
3889
+			// take the last part as name
3447 3890
 		}
3448 3891
 		// type should be set to meet the requirements of checkFileBasics
3449 3892
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3450 3893
 		{
3451 3894
 			$buff = explode('.',$formData['file']);
3452 3895
 			$suffix = '';
3453
-			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3454
-			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3896
+			if (is_array($buff))
3897
+			{
3898
+				$suffix = array_pop($buff);
3899
+			}
3900
+			// take the last extension to check with ext2mime
3901
+			if (!empty($suffix))
3902
+			{
3903
+				$formData['type'] = Api\MimeMagic::ext2mime($suffix);
3904
+			}
3455 3905
 		}
3456 3906
 		// size should be set to meet the requirements of checkFileBasics
3457 3907
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3494,17 +3944,35 @@  discard block
 block discarded – undo
3494 3944
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3495 3945
 	{
3496 3946
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3497
-		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3498
-		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3499
-		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3500
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3501
-		if (empty($_messageID)) return "";
3947
+		if (!$_messageID && !empty($_GET['_messageID']))
3948
+		{
3949
+			$_messageID = $_GET['_messageID'];
3950
+		}
3951
+		if (!$_partID && !empty($_GET['_partID']))
3952
+		{
3953
+			$_partID = $_GET['_partID'];
3954
+		}
3955
+		if (!$_htmloptions && !empty($_GET['_htmloptions']))
3956
+		{
3957
+			$_htmloptions = $_GET['_htmloptions'];
3958
+		}
3959
+		if(Mail::$debug)
3960
+		{
3961
+			error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3962
+		}
3963
+		if (empty($_messageID))
3964
+		{
3965
+			return "";
3966
+		}
3502 3967
 		$uidA = self::splitRowID($_messageID);
3503 3968
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
3504 3969
 		$messageID = $uidA['msgUID'];
3505 3970
 		$icServerID = $uidA['profileID'];
3506 3971
 		//something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled
3507
-		if (empty($messageID)) return "";
3972
+		if (empty($messageID))
3973
+		{
3974
+			return "";
3975
+		}
3508 3976
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
3509 3977
 		{
3510 3978
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3537,7 +4005,11 @@  discard block
 block discarded – undo
3537 4005
 				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3538 4006
 				if (is_numeric($profileID))
3539 4007
 				{
3540
-					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
4008
+					if ($profileID != $this->mail_bo->profileID)
4009
+					{
4010
+						continue;
4011
+					}
4012
+					// only current connection
3541 4013
 					if ($folderName)
3542 4014
 					{
3543 4015
 						try
@@ -3548,7 +4020,10 @@  discard block
 block discarded – undo
3548 4020
 						{
3549 4021
 							continue;
3550 4022
 						}
3551
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
4023
+						if (in_array($fS['shortDisplayName'],Mail::$autoFolders))
4024
+						{
4025
+							$fS['shortDisplayName']=lang($fS['shortDisplayName']);
4026
+						}
3552 4027
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3553 4028
 						if ($fS['unseen'])
3554 4029
 						{
@@ -3589,7 +4064,11 @@  discard block
 block discarded – undo
3589 4064
 			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3590 4065
 			if (is_numeric($profileID))
3591 4066
 			{
3592
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4067
+				if ($profileID != $this->mail_bo->profileID)
4068
+				{
4069
+					return;
4070
+				}
4071
+				// only current connection
3593 4072
 				$del = $this->mail_bo->getHierarchyDelimiter(false);
3594 4073
 				//$del = $prefix = '';
3595 4074
 				//$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -3629,7 +4108,10 @@  discard block
 block discarded – undo
3629 4108
 				$nA = explode($del,$_newName);
3630 4109
 
3631 4110
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3632
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4111
+				if (!!empty($parentFolderName))
4112
+				{
4113
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4114
+				}
3633 4115
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3634 4116
 
3635 4117
 				$this->mail_bo->reopen('INBOX');
@@ -3650,9 +4132,15 @@  discard block
 block discarded – undo
3650 4132
 							$errorMessage .= $error;
3651 4133
 						}
3652 4134
 					}
3653
-					if ($c==count($nA)) $created=true;
4135
+					if ($c==count($nA))
4136
+					{
4137
+						$created=true;
4138
+					}
4139
+				}
4140
+				if (!empty($parentName))
4141
+				{
4142
+					$this->mail_bo->reopen($parentName);
3654 4143
 				}
3655
-				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3656 4144
 			}
3657 4145
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3658 4146
 			if ($created===true)
@@ -3688,7 +4176,10 @@  discard block
 block discarded – undo
3688 4176
 	 */
3689 4177
 	function ajax_renameFolder($_folderName, $_newName)
3690 4178
 	{
3691
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4179
+		if (Mail::$debug)
4180
+		{
4181
+			error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4182
+		}
3692 4183
 		if ($_folderName)
3693 4184
 		{
3694 4185
 			Api\Translation::add_app('mail');
@@ -3700,7 +4191,11 @@  discard block
 block discarded – undo
3700 4191
 			$hasChildren = false;
3701 4192
 			if (is_numeric($profileID))
3702 4193
 			{
3703
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4194
+				if ($profileID != $this->mail_bo->profileID)
4195
+				{
4196
+					return;
4197
+				}
4198
+				// only current connection
3704 4199
 				$pA = explode($del,$folderName);
3705 4200
 				array_pop($pA);
3706 4201
 				$parentFolder = implode($del,$pA);
@@ -3841,8 +4336,15 @@  discard block
 block discarded – undo
3841 4336
 		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3842 4337
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3843 4338
 		// that we get what we request
3844
-		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3845
-		if ($profileID != $this->mail_bo->profileID) return; // only current connection
4339
+		if ($_subscribedOnly != $oldPrefForSubscribedOnly)
4340
+		{
4341
+			$this->mail_bo->resetFolderObjectCache($profileID);
4342
+		}
4343
+		if ($profileID != $this->mail_bo->profileID)
4344
+		{
4345
+			return;
4346
+		}
4347
+		// only current connection
3846 4348
 		if (!empty($folderName))
3847 4349
 		{
3848 4350
 			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
@@ -3917,7 +4419,10 @@  discard block
 block discarded – undo
3917 4419
 	 */
3918 4420
 	function ajax_MoveFolder($_folderName, $_target)
3919 4421
 	{
3920
-		if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4422
+		if (Mail::$debug)
4423
+		{
4424
+			error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4425
+		}
3921 4426
 		if ($_folderName)
3922 4427
 		{
3923 4428
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
@@ -3928,7 +4433,11 @@  discard block
 block discarded – undo
3928 4433
 			$hasChildren = false;
3929 4434
 			if (is_numeric($profileID))
3930 4435
 			{
3931
-				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
4436
+				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID)
4437
+				{
4438
+					return;
4439
+				}
4440
+				// only current connection
3932 4441
 				$pA = explode($del,$folderName);
3933 4442
 				$namePart = array_pop($pA);
3934 4443
 				$_newName = $namePart;
@@ -3939,10 +4448,13 @@  discard block
 block discarded – undo
3939 4448
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3940 4449
 					(($oldParentFolder != $parentFolder &&
3941 4450
 					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3942
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4451
+					strpos($parentFolder,$folderName)===false))))
4452
+				{
4453
+					// indicates that we move the older up the tree within its own branch
3943 4454
 				{
3944 4455
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3945 4456
 					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4457
+				}
3946 4458
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3947 4459
 					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3948 4460
 					{
@@ -4025,8 +4537,14 @@  discard block
 block discarded – undo
4025 4537
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4026 4538
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4027 4539
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4028
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4029
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4540
+				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false)
4541
+				{
4542
+					unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4543
+				}
4544
+				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false)
4545
+				{
4546
+					unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4547
+				}
4030 4548
 
4031 4549
 				// Send full info back in the response
4032 4550
 				foreach($refreshData as $folder => &$name)
@@ -4062,7 +4580,11 @@  discard block
 block discarded – undo
4062 4580
 			$hasChildren = false;
4063 4581
 			if (is_numeric($profileID))
4064 4582
 			{
4065
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4583
+				if ($profileID != $this->mail_bo->profileID)
4584
+				{
4585
+					return;
4586
+				}
4587
+				// only current connection
4066 4588
 				$pA = explode($del,$folderName);
4067 4589
 				array_pop($pA);
4068 4590
 				if (strtoupper($folderName)!= 'INBOX')
@@ -4088,7 +4610,9 @@  discard block
 block discarded – undo
4088 4610
 						}
4089 4611
 						krsort($ftD,SORT_NUMERIC);//sort per level
4090 4612
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4091
-						foreach($ftD as $k => $lc)//collection per level
4613
+						foreach($ftD as $k => $lc)
4614
+						{
4615
+							//collection per level
4092 4616
 						{
4093 4617
 							foreach($lc as $f)//folders contained in that level
4094 4618
 							{
@@ -4096,8 +4620,12 @@  discard block
 block discarded – undo
4096 4620
 								{
4097 4621
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4098 4622
 									$this->mail_bo->deleteFolder($f);
4623
+						}
4099 4624
 									$success = true;
4100
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4625
+									if ($f==$folderName)
4626
+									{
4627
+										$oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4628
+									}
4101 4629
 								}
4102 4630
 								catch (Exception $e)
4103 4631
 								{
@@ -4127,7 +4655,10 @@  discard block
 block discarded – undo
4127 4655
 					$msg = lang("refused to delete folder INBOX");
4128 4656
 				}
4129 4657
 			}
4130
-			if ($_return) return $success;
4658
+			if ($_return)
4659
+			{
4660
+				return $success;
4661
+			}
4131 4662
 			$response = Api\Json\Response::get();
4132 4663
 			if ($success)
4133 4664
 			{
@@ -4214,24 +4745,35 @@  discard block
 block discarded – undo
4214 4745
 				// Create mail app object
4215 4746
 				$mail = new mail_ui();
4216 4747
 
4217
-				if (empty($icServerID)) $icServerID = $mail->Mail->profileID;
4218
-				if ($icServerID != $mail->Mail->profileID) return;
4748
+				if (empty($icServerID))
4749
+				{
4750
+					$icServerID = $mail->Mail->profileID;
4751
+				}
4752
+				if ($icServerID != $mail->Mail->profileID)
4753
+				{
4754
+					return;
4755
+				}
4219 4756
 
4220 4757
 				$vacation = $mail->gatherVacation($cachedVacations);
4221
-			} catch (Exception $e) {
4758
+			}
4759
+			catch (Exception $e) {
4222 4760
 				$vacation=false;
4223 4761
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4224 4762
 				unset($e);
4225 4763
 			}
4226 4764
 		}
4227 4765
 
4228
-		if($vacation) {
4766
+		if($vacation)
4767
+		{
4229 4768
 			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4230 4769
 			{
4231 4770
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4232 4771
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4233 4772
 				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4234
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4773
+				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())
4774
+				{
4775
+					$refreshData = '';
4776
+				}
4235 4777
 			}
4236 4778
 		}
4237 4779
 		if ($vacation==false)
@@ -4253,11 +4795,17 @@  discard block
 block discarded – undo
4253 4795
 	function ajax_refreshFilters($icServerID=null)
4254 4796
 	{
4255 4797
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4256
-		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4798
+		if (empty($icServerID))
4799
+		{
4800
+			$icServerID = $this->mail_bo->profileID;
4801
+		}
4257 4802
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4258 4803
 		{
4259 4804
 			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4260
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4805
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4806
+			{
4807
+				Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4808
+			}
4261 4809
 		}
4262 4810
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4263 4811
 		{
@@ -4279,7 +4827,10 @@  discard block
 block discarded – undo
4279 4827
 			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4280 4828
 			foreach($keywords as &$k)
4281 4829
 			{
4282
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4830
+				if (array_key_exists($k,$this->statusTypes))
4831
+				{
4832
+					unset($this->statusTypes[$k]);
4833
+				}
4283 4834
 			}
4284 4835
 		}
4285 4836
 
@@ -4299,7 +4850,10 @@  discard block
 block discarded – undo
4299 4850
 	{
4300 4851
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4301 4852
 		Api\Translation::add_app('mail');
4302
-		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
4853
+		if (is_null($icServerID))
4854
+		{
4855
+			$icServerID = $this->mail_bo->profileID;
4856
+		}
4303 4857
 		$rememberServerID = $this->mail_bo->profileID;
4304 4858
 		try
4305 4859
 		{
@@ -4309,19 +4863,23 @@  discard block
 block discarded – undo
4309 4863
 				$this->changeProfile($icServerID);
4310 4864
 			}
4311 4865
 			$quota = $this->mail_bo->getQuotaRoot();
4312
-		} catch (Exception $e) {
4866
+		}
4867
+		catch (Exception $e) {
4313 4868
 			$quota['limit'] = 'NOT SET';
4314 4869
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4315 4870
 			unset($e);
4316 4871
 		}
4317 4872
 
4318
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4873
+		if($quota !== false && $quota['limit'] != 'NOT SET')
4874
+		{
4319 4875
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4320 4876
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4321 4877
 			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4322 4878
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4323 4879
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4324
-		} else {
4880
+		}
4881
+		else
4882
+		{
4325 4883
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
4326 4884
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
4327 4885
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -4332,7 +4890,8 @@  discard block
 block discarded – undo
4332 4890
 			{
4333 4891
 				//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
4334 4892
 				$this->changeProfile($rememberServerID);
4335
-			} catch (Exception $e) {
4893
+			}
4894
+			catch (Exception $e) {
4336 4895
 				//error_log(__METHOD__.__LINE__." ".$e->getMessage());
4337 4896
 				unset($e);
4338 4897
 			}
@@ -4360,7 +4919,8 @@  discard block
 block discarded – undo
4360 4919
 			$this->changeProfile($icServerID);
4361 4920
 		}
4362 4921
 		$junkFolder = $this->mail_bo->getJunkFolder();
4363
-		if(!empty($junkFolder)) {
4922
+		if(!empty($junkFolder))
4923
+		{
4364 4924
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4365 4925
 			{
4366 4926
 				// Lock the tree if the active folder is junk folder
@@ -4410,7 +4970,8 @@  discard block
 block discarded – undo
4410 4970
 			$this->changeProfile($icServerID);
4411 4971
 		}
4412 4972
 		$trashFolder = $this->mail_bo->getTrashFolder();
4413
-		if(!empty($trashFolder)) {
4973
+		if(!empty($trashFolder))
4974
+		{
4414 4975
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4415 4976
 			{
4416 4977
 				// Lock the tree if the active folder is Trash folder
@@ -4456,7 +5017,10 @@  discard block
 block discarded – undo
4456 5017
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4457 5018
 		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4458 5019
 
4459
-		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
5020
+		if (empty($folderName))
5021
+		{
5022
+			$folderName = $this->mail_bo->sessionData['mailbox'];
5023
+		}
4460 5024
 		if ($this->mail_bo->folderExists($folderName))
4461 5025
 		{
4462 5026
 			$rememberServerID = $this->mail_bo->profileID;
@@ -4465,7 +5029,8 @@  discard block
 block discarded – undo
4465 5029
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4466 5030
 				$this->changeProfile($icServerID);
4467 5031
 			}
4468
-			if(!empty($_folderName)) {
5032
+			if(!empty($_folderName))
5033
+			{
4469 5034
 				$this->mail_bo->compressFolder($folderName);
4470 5035
 			}
4471 5036
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4487,7 +5052,10 @@  discard block
 block discarded – undo
4487 5052
 	 */
4488 5053
 	function ajax_sendMDN($_messageList)
4489 5054
 	{
4490
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
5055
+		if(Mail::$debug)
5056
+		{
5057
+			error_log(__METHOD__."->".array2string($_messageList));
5058
+		}
4491 5059
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4492 5060
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4493 5061
 		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
@@ -4504,7 +5072,10 @@  discard block
 block discarded – undo
4504 5072
 	 */
4505 5073
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4506 5074
 	{
4507
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5075
+		if(Mail::$debug)
5076
+		{
5077
+			error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5078
+		}
4508 5079
 		Api\Translation::add_app('mail');
4509 5080
 		$alreadyFlagged=false;
4510 5081
 		$flag2check='';
@@ -4525,12 +5096,23 @@  discard block
 block discarded – undo
4525 5096
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4526 5097
 						{
4527 5098
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4528
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5099
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5100
+							{
5101
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5102
+							}
4529 5103
 						}
4530 5104
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4531 5105
 						$cutoffdate = $cutoffdate2 = null;
4532
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4533
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5106
+						if ($query['startdate'])
5107
+						{
5108
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5109
+						}
5110
+						//SINCE, enddate
5111
+						if ($query['enddate'])
5112
+						{
5113
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5114
+						}
5115
+						//BEFORE, startdate
4534 5116
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4535 5117
 						$filter = array(
4536 5118
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4539,15 +5121,24 @@  discard block
 block discarded – undo
4539 5121
 							'status' => 'any',//this is a status change. status will be manipulated later on
4540 5122
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4541 5123
 						);
4542
-						if ($query['enddate']||$query['startdate']) {
5124
+						if ($query['enddate']||$query['startdate'])
5125
+						{
4543 5126
 							$filter['range'] = "BETWEEN";
4544
-							if ($cutoffdate) {
5127
+							if ($cutoffdate)
5128
+							{
4545 5129
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4546
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5130
+								if (empty($cutoffdate2))
5131
+								{
5132
+									$filter['range'] = "SINCE";
5133
+								}
4547 5134
 							}
4548
-							if ($cutoffdate2) {
5135
+							if ($cutoffdate2)
5136
+							{
4549 5137
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4550
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5138
+								if (empty($cutoffdate))
5139
+								{
5140
+									$filter['range'] = "BEFORE";
5141
+								}
4551 5142
 							}
4552 5143
 						}
4553 5144
 						$filter2toggle = $filter;
@@ -4598,13 +5189,19 @@  discard block
 block discarded – undo
4598 5189
 						if (count($messageListForToggle)>0)
4599 5190
 						{
4600 5191
 							$flag2set = (strtolower($_flag));
4601
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5192
+							if(Mail::$debug)
5193
+							{
5194
+								error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5195
+							}
4602 5196
 							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4603 5197
 						}
4604 5198
 						if (count($messageList)>0)
4605 5199
 						{
4606 5200
 							$flag2set = 'un'.$_flag;
4607
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5201
+							if(Mail::$debug)
5202
+							{
5203
+								error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5204
+							}
4608 5205
 							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4609 5206
 						}
4610 5207
 						$alreadyFlagged=true;
@@ -4620,7 +5217,10 @@  discard block
 block discarded – undo
4620 5217
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4621 5218
 							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4622 5219
 						}
4623
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5220
+						if(Mail::$debug)
5221
+						{
5222
+							error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5223
+						}
4624 5224
 						$rByUid = true;
4625 5225
 						$reverse = 1;
4626 5226
 						$_sR = $this->mail_bo->getSortedList(
@@ -4637,7 +5237,10 @@  discard block
 block discarded – undo
4637 5237
 					}
4638 5238
 					else
4639 5239
 					{
4640
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5240
+						if(Mail::$debug)
5241
+						{
5242
+							error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5243
+						}
4641 5244
 						$alreadyFlagged=true;
4642 5245
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4643 5246
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -4657,13 +5260,19 @@  discard block
 block discarded – undo
4657 5260
 					$hA = self::splitRowID($rowID);
4658 5261
 					$messageList[] = $hA['msgUID'];
4659 5262
 				}
4660
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5263
+				if(Mail::$debug)
5264
+				{
5265
+					error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5266
+				}
4661 5267
 				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4662 5268
 			}
4663 5269
 		}
4664 5270
 		else
4665 5271
 		{
4666
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5272
+			if(Mail::$debug)
5273
+			{
5274
+				error_log(__METHOD__."-> No messages selected.");
5275
+			}
4667 5276
 		}
4668 5277
 
4669 5278
 		if ($_sendJsonResponse)
@@ -4700,7 +5309,10 @@  discard block
 block discarded – undo
4700 5309
 	 */
4701 5310
 	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4702 5311
 	{
4703
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5312
+		if(Mail::$debug)
5313
+		{
5314
+			error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5315
+		}
4704 5316
 		$error = null;
4705 5317
 		$filtered =  false;
4706 5318
 		if ($_messageList=='all' || !empty($_messageList['msg']))
@@ -4719,12 +5331,23 @@  discard block
 block discarded – undo
4719 5331
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4720 5332
 						{
4721 5333
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4722
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5334
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5335
+							{
5336
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5337
+							}
4723 5338
 						}
4724 5339
 						$filtered =  true;
4725 5340
 						$cutoffdate = $cutoffdate2 = null;
4726
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4727
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5341
+						if ($query['startdate'])
5342
+						{
5343
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5344
+						}
5345
+						//SINCE, enddate
5346
+						if ($query['enddate'])
5347
+						{
5348
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5349
+						}
5350
+						//BEFORE, startdate
4728 5351
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4729 5352
 						$filter = array(
4730 5353
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4733,15 +5356,24 @@  discard block
 block discarded – undo
4733 5356
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4734 5357
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4735 5358
 						);
4736
-						if ($query['enddate']||$query['startdate']) {
5359
+						if ($query['enddate']||$query['startdate'])
5360
+						{
4737 5361
 							$filter['range'] = "BETWEEN";
4738
-							if ($cutoffdate) {
5362
+							if ($cutoffdate)
5363
+							{
4739 5364
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4740
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5365
+								if (empty($cutoffdate2))
5366
+								{
5367
+									$filter['range'] = "SINCE";
5368
+								}
4741 5369
 							}
4742
-							if ($cutoffdate2) {
5370
+							if ($cutoffdate2)
5371
+							{
4743 5372
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4744
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5373
+								if (empty($cutoffdate))
5374
+								{
5375
+									$filter['range'] = "BEFORE";
5376
+								}
4745 5377
 							}
4746 5378
 						}
4747 5379
 					}
@@ -4808,7 +5440,10 @@  discard block
 block discarded – undo
4808 5440
 		}
4809 5441
 		else
4810 5442
 		{
4811
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5443
+			if(Mail::$debug)
5444
+			{
5445
+				error_log(__METHOD__."-> No messages selected.");
5446
+			}
4812 5447
 		}
4813 5448
 	}
4814 5449
 
@@ -4824,11 +5459,17 @@  discard block
 block discarded – undo
4824 5459
 	 */
4825 5460
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4826 5461
 	{
4827
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5462
+		if(Mail::$debug)
5463
+		{
5464
+			error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5465
+		}
4828 5466
 		Api\Translation::add_app('mail');
4829 5467
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4830 5468
 		// only copy or move are supported as method
4831
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5469
+		if (!($_copyOrMove=='copy' || $_copyOrMove=='move'))
5470
+		{
5471
+			$_copyOrMove='copy';
5472
+		}
4832 5473
 		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4833 5474
 		// check if move2archive was called with the correct archiveFolder
4834 5475
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
@@ -4851,8 +5492,13 @@  discard block
 block discarded – undo
4851 5492
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4852 5493
 				foreach( $keys as &$f)
4853 5494
 				{
4854
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4855
-					else break;
5495
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9)
5496
+					{
5497
+						unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5498
+					}
5499
+					else {
5500
+						break;
5501
+					}
4856 5502
 				}
4857 5503
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4858 5504
 			}
@@ -4879,12 +5525,23 @@  discard block
 block discarded – undo
4879 5525
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4880 5526
 						{
4881 5527
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4882
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5528
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5529
+							{
5530
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5531
+							}
4883 5532
 						}
4884 5533
 						$filtered = true;
4885 5534
 						$cutoffdate = $cutoffdate2 = null;
4886
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4887
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5535
+						if ($query['startdate'])
5536
+						{
5537
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5538
+						}
5539
+						//SINCE, enddate
5540
+						if ($query['enddate'])
5541
+						{
5542
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5543
+						}
5544
+						//BEFORE, startdate
4888 5545
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4889 5546
 						$filter = array(
4890 5547
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4893,15 +5550,24 @@  discard block
 block discarded – undo
4893 5550
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4894 5551
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4895 5552
 						);
4896
-						if ($query['enddate']||$query['startdate']) {
5553
+						if ($query['enddate']||$query['startdate'])
5554
+						{
4897 5555
 							$filter['range'] = "BETWEEN";
4898
-							if ($cutoffdate) {
5556
+							if ($cutoffdate)
5557
+							{
4899 5558
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4900
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5559
+								if (empty($cutoffdate2))
5560
+								{
5561
+									$filter['range'] = "SINCE";
5562
+								}
4901 5563
 							}
4902
-							if ($cutoffdate2) {
5564
+							if ($cutoffdate2)
5565
+							{
4903 5566
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4904
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5567
+								if (empty($cutoffdate))
5568
+								{
5569
+									$filter['range'] = "BEFORE";
5570
+								}
4905 5571
 							}
4906 5572
 						}
4907 5573
 					}
@@ -4957,7 +5623,10 @@  discard block
 block discarded – undo
4957 5623
 						$hA = self::splitRowID($rowID);
4958 5624
 
4959 5625
 						// If folder changes, stop and move what we've got
4960
-						if($hA['folder'] != $folder) break;
5626
+						if($hA['folder'] != $folder)
5627
+						{
5628
+							break;
5629
+						}
4961 5630
 
4962 5631
 						array_shift($_messageList['msg']);
4963 5632
 						$messageList[] = $hA['msgUID'];
@@ -5012,7 +5681,10 @@  discard block
 block discarded – undo
5012 5681
 		}
5013 5682
 		else
5014 5683
 		{
5015
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5684
+			if(Mail::$debug)
5685
+			{
5686
+				error_log(__METHOD__."-> No messages selected.");
5687
+			}
5016 5688
 		}
5017 5689
 	}
5018 5690
 
Please login to merge, or discard this patch.
Spacing   +822 added lines, -829 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @var array
42 42
 	 */
43
-	var $public_functions = array
44
-	(
43
+	var $public_functions = array(
45 44
 		'index' => True,
46 45
 		'displayHeader'	=> True,
47 46
 		'displayMessage'	=> True,
@@ -92,17 +91,17 @@  discard block
 block discarded – undo
92 91
 	 * @var array
93 92
 	 */
94 93
 	var $searchTypes = array(
95
-		'quick'		=> 'quicksearch',	// lang('quicksearch')
96
-		'quickwithcc'=> 'quicksearch (with cc)',	// lang('quicksearch (with cc)')
97
-		'subject'	=> 'subject',		// lang('subject')
98
-		'body'		=> 'message body',	// lang('message body')
99
-		'from'		=> 'from',			// lang('from')
100
-		'to'		=> 'to',			// lang('to')
101
-		'cc'		=> 'cc',			// lang('cc')
102
-		'text'		=> 'whole message',	// lang('whole message')
103
-		'larger'		=> 'greater than',	// lang('greater than')
104
-		'smaller'		=> 'less than',	// lang('less than')
105
-		'bydate' 	=> 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)')
94
+		'quick'		=> 'quicksearch', // lang('quicksearch')
95
+		'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)')
96
+		'subject'	=> 'subject', // lang('subject')
97
+		'body'		=> 'message body', // lang('message body')
98
+		'from'		=> 'from', // lang('from')
99
+		'to'		=> 'to', // lang('to')
100
+		'cc'		=> 'cc', // lang('cc')
101
+		'text'		=> 'whole message', // lang('whole message')
102
+		'larger'		=> 'greater than', // lang('greater than')
103
+		'smaller'		=> 'less than', // lang('less than')
104
+		'bydate' 	=> 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)')
106 105
 	);
107 106
 
108 107
 	/**
@@ -111,12 +110,12 @@  discard block
 block discarded – undo
111 110
 	 * @var array
112 111
 	 */
113 112
 	var $statusTypes = array(
114
-		'any'		=> 'any status',// lang('any status')
115
-		'flagged'	=> 'flagged',	// lang('flagged')
116
-		'unseen'	=> 'unread',	// lang('unread')
117
-		'answered'	=> 'replied',	// lang('replied')
118
-		'seen'		=> 'read',		// lang('read')
119
-		'deleted'	=> 'deleted',	// lang('deleted')
113
+		'any'		=> 'any status', // lang('any status')
114
+		'flagged'	=> 'flagged', // lang('flagged')
115
+		'unseen'	=> 'unread', // lang('unread')
116
+		'answered'	=> 'replied', // lang('replied')
117
+		'seen'		=> 'read', // lang('read')
118
+		'deleted'	=> 'deleted', // lang('deleted')
120 119
 	);
121 120
 
122 121
 	/**
@@ -124,12 +123,12 @@  discard block
 block discarded – undo
124 123
 	 *
125 124
 	 * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server
126 125
 	 */
127
-	function __construct($run_constructor=true)
126
+	function __construct($run_constructor = true)
128 127
 	{
129 128
 		$this->mail_tree = new mail_tree($this);
130 129
 		if (!$run_constructor) return;
131 130
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
131
+		if (Mail::$debugTimes) $starttime = microtime(true);
133 132
 		// no autohide of the sidebox, as we use it for folderlist now.
134 133
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 134
 
@@ -145,13 +144,13 @@  discard block
 block discarded – undo
145 144
 		}
146 145
 
147 146
 		try {
148
-			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
147
+			$this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true);
149 148
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
150 149
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 150
 
152 151
 			// RegEx to minimize extra openConnection
153 152
 			$needle = '/^(?!mail)/';
154
-			if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
153
+			if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
155 154
 			{
156 155
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
157 156
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -164,12 +163,12 @@  discard block
 block discarded – undo
164 163
 			if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index')
165 164
 			{
166 165
 				$response = Api\Json\Response::get();
167
-				$response->call('egw.message',$e->getMessage(),'error');
166
+				$response->call('egw.message', $e->getMessage(), 'error');
168 167
 			}
169 168
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
169
+			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false);
171 170
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
173 172
 	}
174 173
 
175 174
 	/**
@@ -179,10 +178,10 @@  discard block
 block discarded – undo
179 178
 	 * @param boolean $exit If true, will call exit() after opening the wizardpopup
180 179
 	 * @param string $msg_type = 'success' message type
181 180
 	 */
182
-	static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true)
181
+	static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true)
183 182
 	{
184 183
 		//error_log(__METHOD__."('$message', $exit) ".function_backtrace());
185
-		$linkData=(self::$icServerID ? array(
184
+		$linkData = (self::$icServerID ? array(
186 185
 				'menuaction' => 'mail.mail_wizard.edit',
187 186
 				'acc_id' => self::$icServerID,
188 187
 			) : array(
@@ -196,11 +195,11 @@  discard block
 block discarded – undo
196 195
 		{
197 196
 			$response = Api\Json\Response::get();
198 197
 			$windowName = "editMailAccount".self::$icServerID;
199
-			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
198
+			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true);
200 199
 			Framework::message($message, 'error');
201 200
 			if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index)
202 201
 			{
203
-				$response->call('framework.setSidebox','mail',array(),'md5');
202
+				$response->call('framework.setSidebox', 'mail', array(), 'md5');
204 203
 			}
205 204
 			if ($exit)
206 205
 			{
@@ -210,8 +209,8 @@  discard block
 block discarded – undo
210 209
 		else	// regular GET request eg. in idots template
211 210
 		{
212 211
 			$windowName = "editMailAccount".self::$icServerID;
213
-			Framework::popup(Framework::link('/index.php',$linkData),$windowName);
214
-			$GLOBALS['egw']->framework->render($message,'',true);
212
+			Framework::popup(Framework::link('/index.php', $linkData), $windowName);
213
+			$GLOBALS['egw']->framework->render($message, '', true);
215 214
 			if ($exit)
216 215
 			{
217 216
 				exit();
@@ -227,9 +226,9 @@  discard block
 block discarded – undo
227 226
 	 *
228 227
 	 * @throws Api\Exception
229 228
 	 */
230
-	function changeProfile($_icServerID,$unsetCache=false)
229
+	function changeProfile($_icServerID, $unsetCache = false)
231 230
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
231
+		if (Mail::$debugTimes) $starttime = microtime(true);
233 232
 		if (self::$icServerID != $_icServerID)
234 233
 		{
235 234
 			self::$icServerID = $_icServerID;
@@ -237,35 +236,35 @@  discard block
 block discarded – undo
237 236
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
238 237
 
239 238
 		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
240
-		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
239
+		$this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true);
241 240
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
242 241
 		// no icServer Object: something failed big time
243
-		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
242
+		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID)
244 243
 		{
245 244
 			self::$icServerID = $_icServerID;
246 245
 			throw new Api\Exception('Profile change failed!');
247 246
 		}
248 247
 
249 248
 		// save session varchar
250
-		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
249
+		$oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID');
251 250
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252 251
 		if (true) $oldicServerID = self::$icServerID;
253
-		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
252
+		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true))
254 253
 		{
255 254
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 255
 		}
257 256
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
257
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
259 258
 	}
260 259
 
261 260
 	/**
262 261
 	 * Ajax function to request next branch of a tree branch
263 262
 	 */
264
-	static function ajax_tree_autoloading ($_id = null)
263
+	static function ajax_tree_autoloading($_id = null)
265 264
 	{
266 265
 		$mail_ui = new mail_ui();
267 266
 		$id = $_id ? $_id : $_GET['id'];
268
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
267
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false));
269 268
 	}
270 269
 
271 270
 	/**
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 	 * @param array $content
275 274
 	 * @param type $msg
276 275
 	 */
277
-	function subscription(array $content=null ,$msg=null)
276
+	function subscription(array $content = null, $msg = null)
278 277
 	{
279 278
 		$stmpl = new Etemplate('mail.subscribe');
280 279
 
281
-		if(is_array($content))
280
+		if (is_array($content))
282 281
 		{
283 282
 			$profileId = $content['profileId'];
284 283
 		}
@@ -288,14 +287,14 @@  discard block
 block discarded – undo
288 287
 		}
289 288
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
290 289
 		// triggered from client-side. Also, we keep this here as
291
-		$sel_options['foldertree'] =  $this->mail_tree->getTree(null,$profileId,1,true,false,true);
290
+		$sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true);
292 291
 
293 292
 		//Get all subscribed folders
294 293
 		// as getting all subscribed folders is very fast operation
295 294
 		// we can use it to get a comparison base for folders which
296 295
 		// got subscribed or unsubscribed by the user
297 296
 		try {
298
-			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
297
+			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true);
299 298
 		} catch (Exception $ex) {
300 299
 			Framework::message($ex->getMessage());
301 300
 		}
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
 
307 306
 			foreach ($subscribed as $folder)
308 307
 			{
309
-				$folderName = $profileId . self::$delimiter . $folder['MAILBOX'];
308
+				$folderName = $profileId.self::$delimiter.$folder['MAILBOX'];
310 309
 				array_push($content['foldertree'], $folderName);
311 310
 			}
312 311
 		}
@@ -320,9 +319,9 @@  discard block
 block discarded – undo
320 319
 				{
321 320
 					// do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
322 321
 					$namespace_roots = array($profileId);
323
-					foreach($this->mail_bo->_getNameSpaces() as $namespace)
322
+					foreach ($this->mail_bo->_getNameSpaces() as $namespace)
324 323
 					{
325
-						$namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
324
+						$namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']);
326 325
 					}
327 326
 					$to_unsubscribe = $to_subscribe = array();
328 327
 					foreach ($content['foldertree'] as $path => $value)
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 330
 						if ($node)
332 331
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
332
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node;
334 333
 							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335 334
 							if ($value['value']) $cont[] = $path;
336 335
 						}
@@ -340,7 +339,7 @@  discard block
 block discarded – undo
340 339
 					// set foldertree options to basic node in order to avoid initial autoloading
341 340
 					// from client side, as no options would trigger that.
342 341
 					$sel_options['foldertree'] = array('id' => '0', 'item'=> array());
343
-					foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
342
+					foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
344 343
 					{
345 344
 						if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true))
346 345
 						{
@@ -376,18 +375,18 @@  discard block
 block discarded – undo
376 375
 						}
377 376
 					}
378 377
 					// update foldertree in main window
379
-					$parentFolder='INBOX';
378
+					$parentFolder = 'INBOX';
380 379
 					$refreshData = array(
381 380
 						$profileId => lang($parentFolder),
382 381
 					);
383 382
 					$response = Api\Json\Response::get();
384
-					foreach($refreshData as $folder => &$name)
383
+					foreach ($refreshData as $folder => &$name)
385 384
 					{
386
-						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
385
+						$name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true);
387 386
 					}
388 387
 					// give success/error message to opener and popup itself
389 388
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
390
-					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
389
+					$response->call('opener.app.mail.mail_reloadNode', $refreshData);
391 390
 
392 391
 					Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
393 392
 					if ($button == 'apply')
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 
408 407
 		$readonlys = array();
409 408
 
410
-		$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
409
+		$stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2);
411 410
 	}
412 411
 
413 412
 	/**
@@ -416,13 +415,13 @@  discard block
 block discarded – undo
416 415
 	 * @param array $content
417 416
 	 * @param string $msg
418 417
 	 */
419
-	function index(array $content=null,$msg=null)
418
+	function index(array $content = null, $msg = null)
420 419
 	{
421 420
 		//error_log(__METHOD__.__LINE__.array2string($content));
422
-		try	{
421
+		try {
423 422
 				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
424 423
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
424
+				if (Mail::$debugTimes) $starttime = microtime(true);
426 425
 				$this->mail_bo->restoreSessionData();
427 426
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 427
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -443,26 +442,26 @@  discard block
 block discarded – undo
443 442
 					{
444 443
 						// These only set on first load
445 444
 						$content[self::$nm_index] = array(
446
-							'filter'         => 'any',	// filter is used to choose the mailbox
447
-							'lettersearch'   => false,	// I  show a lettersearch
448
-							'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
449
-							'start'          =>	0,		// IO position in list
450
-							'order'          =>	'date',	// IO name of the column to sort after (optional for the sortheaders)
451
-							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
445
+							'filter'         => 'any', // filter is used to choose the mailbox
446
+							'lettersearch'   => false, // I  show a lettersearch
447
+							'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
448
+							'start'          =>	0, // IO position in list
449
+							'order'          =>	'date', // IO name of the column to sort after (optional for the sortheaders)
450
+							'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
452 451
 						);
453 452
 					}
454 453
 					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
455 454
 				}
456 455
 
457 456
 				// These must always be set, even if $content is an array
458
-				$content[self::$nm_index]['cat_is_select'] = true;    // Category select is just a normal selectbox
459
-				$content[self::$nm_index]['no_filter2'] = false;       // Disable second filter
457
+				$content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox
458
+				$content[self::$nm_index]['no_filter2'] = false; // Disable second filter
460 459
 				$content[self::$nm_index]['actions'] = self::get_actions();
461
-				$content[self::$nm_index]['row_id'] = 'row_id';	     // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
460
+				$content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
462 461
 				$content[self::$nm_index]['placeholder_actions'] = array('composeasnew');
463 462
 				$content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows';
464
-				$content[self::$nm_index]['num_rows'] = 0;      // Do not send any rows with initial request
465
-				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size';	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
463
+				$content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request
464
+				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
466 465
 				$content[self::$nm_index]['csv_fields'] = false;
467 466
 				if ($msg)
468 467
 				{
@@ -474,11 +473,11 @@  discard block
 block discarded – undo
474 473
 					unset($content['msg']);
475 474
 				}
476 475
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477
-				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
476
+				$quota = false; //$this->mail_bo->getQuotaRoot();
477
+				if ($quota !== false && $quota['limit'] != 'NOT SET') {
479 478
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 479
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481
-					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
480
+					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
482 481
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 482
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484 483
 				} else {
@@ -487,43 +486,43 @@  discard block
 block discarded – undo
487 486
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
488 487
 				}
489 488
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
490
-				$vacation = false;//$this->gatherVacation();
489
+				$vacation = false; //$this->gatherVacation();
491 490
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
492
-				if($vacation) {
493
-					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
491
+				if ($vacation) {
492
+					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time()))
494 493
 					{
495 494
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
496 495
 						$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
497
-						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
496
+						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
498 497
 					}
499 498
 				}
500
-				if ($vacation==false)
499
+				if ($vacation == false)
501 500
 				{
502 501
 					$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = '';
503 502
 					$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = '';
504 503
 				}
505 504
 				//$zstarttime = microtime (true);
506
-				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
505
+				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
507 506
 				//$zendtime = microtime(true) - $zstarttime;
508 507
 				//error_log(__METHOD__.__LINE__. " time used: ".$zendtime);
509
-				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX');
508
+				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX');
510 509
 				// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
511
-				if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
510
+				if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
512 511
 				{
513
-					$this->statusTypes = array_merge($this->statusTypes,array(
514
-						'keyword1'	=> 'important',//lang('important'),
515
-						'keyword2'	=> 'job',	//lang('job'),
516
-						'keyword3'	=> 'personal',//lang('personal'),
517
-						'keyword4'	=> 'to do',	//lang('to do'),
518
-						'keyword5'	=> 'later',	//lang('later'),
512
+					$this->statusTypes = array_merge($this->statusTypes, array(
513
+						'keyword1'	=> 'important', //lang('important'),
514
+						'keyword2'	=> 'job', //lang('job'),
515
+						'keyword3'	=> 'personal', //lang('personal'),
516
+						'keyword4'	=> 'to do', //lang('to do'),
517
+						'keyword5'	=> 'later', //lang('later'),
519 518
 					));
520 519
 				}
521 520
 				else
522 521
 				{
523
-					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
524
-					foreach($keywords as &$k)
522
+					$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
523
+					foreach ($keywords as &$k)
525 524
 					{
526
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
525
+						if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
527 526
 					}
528 527
 				}
529 528
 
@@ -534,8 +533,8 @@  discard block
 block discarded – undo
534 533
 
535 534
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
536 535
 				{
537
-					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
538
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
536
+					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
537
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
539 538
 				}
540 539
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
541 540
 				{
@@ -547,14 +546,14 @@  discard block
 block discarded – undo
547 546
 				//error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']));
548 547
 				$content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'];
549 548
 				$sel_options['filter'] = $this->statusTypes;
550
-				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'));
549
+				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'));
551 550
 				$content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'];
552 551
 
553 552
 				$etpl = new Etemplate('mail.index');
554 553
 				//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
555 554
 				$content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()";
556 555
 				// set the actions on tree
557
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
556
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions());
558 557
 
559 558
 				// sending preview toolbar actions
560 559
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
@@ -565,34 +564,34 @@  discard block
 block discarded – undo
565 564
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
566 565
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
567 566
 				{
568
-					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
567
+					$content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject'));
569 568
 				}
570 569
 				$readonlys = $preserv = array();
571
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
570
+				if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
572 571
 		}
573 572
 		catch (Exception $e)
574 573
 		{
575 574
 			// do not exit here. mail-tree should be build. if we exit here, we never get there.
576
-			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
575
+			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
577 576
 			if (isset($this->mail_bo))
578 577
 			{
579 578
 				if (empty($etpl))
580 579
 				{
581
-					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
580
+					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
582 581
 					$etpl = new Etemplate('mail.index');
583 582
 				}
584
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
583
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false));
585 584
 			}
586 585
 			$readonlys = $preserv = array();
587
-			if (empty($content)) $content=array();
586
+			if (empty($content)) $content = array();
588 587
 
589
-			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
588
+			self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ? false : true), 'error', false);
590 589
 			//return false;
591 590
 		}
592 591
 		// Check preview pane is enabled, then show splitter
593 592
 		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('splitter', 'template', 'mail.index.nosplitter');
594 593
 
595
-		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
594
+		return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv);
596 595
 	}
597 596
 
598 597
 	/**
@@ -602,11 +601,11 @@  discard block
 block discarded – undo
602 601
 	 * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server
603 602
 	 * @return array
604 603
 	 */
605
-	function get_tree_actions($imap_actions=true)
604
+	function get_tree_actions($imap_actions = true)
606 605
 	{
607 606
 		// Start at 2 so auto-added copy+paste actions show up as second group
608 607
 		// Needed because there's no 'select all' action to push things down
609
-		$group=1;
608
+		$group = 1;
610 609
 		// Set tree actions
611 610
 		$tree_actions = array(
612 611
 			'drop_move_mail' => array(
@@ -688,12 +687,12 @@  discard block
 block discarded – undo
688 687
 				'onExecute' => 'javaScript:app.mail.edit_sieve',
689 688
 
690 689
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
691
-				'icon' => 'mail/filter',	// funnel
690
+				'icon' => 'mail/filter', // funnel
692 691
 				'hideOnMobile' => true
693 692
 			),
694 693
 			'vacation' => array(
695 694
 				'caption' => 'Vacation notice',
696
-				'icon' => 'mail/navbar',	// mail as in admin
695
+				'icon' => 'mail/navbar', // mail as in admin
697 696
 				'onExecute' => 'javaScript:app.mail.edit_vacation',
698 697
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
699 698
 			),
@@ -734,8 +733,8 @@  discard block
 block discarded – undo
734 733
 			unset($tree_actions['subscribe']);
735 734
 			unset($tree_actions['unsubscribe']);
736 735
 		}
737
-		++$group;	// put delete in own group
738
-		switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
736
+		++$group; // put delete in own group
737
+		switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
739 738
 		{
740 739
 			case 'move_to_trash':
741 740
 				$tree_actions['empty_trash'] = array(
@@ -754,7 +753,7 @@  discard block
 block discarded – undo
754 753
 				);
755 754
 				break;
756 755
 		}
757
-		$junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null);
756
+		$junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null);
758 757
 
759 758
 		//error_log(__METHOD__.__LINE__.$junkFolder);
760 759
 		if ($junkFolder && !empty($junkFolder))
@@ -767,8 +766,8 @@  discard block
 block discarded – undo
767 766
 				'group'	=> $group,
768 767
 			);
769 768
 		}
770
-		$tree_actions['sieve']['group']	= $tree_actions['vacation']['group'] = ++$group;	// new group for filter
771
-		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group']	= ++$group;
769
+		$tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter
770
+		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group;
772 771
 
773 772
 
774 773
 		// enforce global (group-specific) ACL
@@ -803,17 +802,17 @@  discard block
 block discarded – undo
803 802
 	 * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed
804 803
 	 * @param {boolean} $_status set true for subscribe and false to unsubscribe
805 804
 	 */
806
-	public function ajax_foldersubscription($_acc_id,$_folderName, $_status)
805
+	public function ajax_foldersubscription($_acc_id, $_folderName, $_status)
807 806
 	{
808 807
 		//Change the Mail object to related profileId
809 808
 		$this->changeProfile($_acc_id);
810
-		try{
809
+		try {
811 810
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
812 811
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
813
-			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
812
+			$this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
814 813
 		} catch (Horde_Imap_Client_Exception $ex) {
815
-			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
816
-			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
814
+			error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex));
815
+			Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status));
817 816
 		}
818 817
 	}
819 818
 
@@ -825,25 +824,25 @@  discard block
 block discarded – undo
825 824
 	 * @param string $_nodeID if of node whos children are requested
826 825
 	 * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default)
827 826
 	 */
828
-	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
827
+	public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null)
829 828
 	{
830 829
 		$nodeID = $_GET['id'];
831 830
 		if (!is_null($_nodeID)) $nodeID = $_nodeID;
832
-		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
831
+		$subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
833 832
 		$fetchCounters = !is_null($_nodeID);
834
-		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
833
+		list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2);
835 834
 
836 835
 		if (!empty($_folderName)) $fetchCounters = true;
837 836
 
838 837
 		// Check if it is called for refresh root
839 838
 		// then we need to reinitialized the index tree
840
-		if(!$nodeID && !$_profileID)
839
+		if (!$nodeID && !$_profileID)
841 840
 		{
842
-			$data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
841
+			$data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
843 842
 		}
844 843
 		else
845 844
 		{
846
-			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
845
+			$data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
847 846
 		}
848 847
 		if (!is_null($_nodeID)) return $data;
849 848
 		Etemplate\Widget\Tree::send_quote_json($data);
@@ -859,17 +858,17 @@  discard block
 block discarded – undo
859 858
 	 */
860 859
 	static function findNode($_out, $_nodeID, $childElements = false)
861 860
 	{
862
-		foreach($_out['item'] as $node)
861
+		foreach ($_out['item'] as $node)
863 862
 		{
864
-			if (strcmp($node['id'],$_nodeID)===0)
863
+			if (strcmp($node['id'], $_nodeID) === 0)
865 864
 			{
866 865
 				//error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']);
867
-				return ($childElements?$node['item']:$node);
866
+				return ($childElements ? $node['item'] : $node);
868 867
 			}
869
-			elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id']))
868
+			elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id']))
870 869
 			{
871 870
 				//error_log(__METHOD__.__LINE__.' descend into '.$node['id']);
872
-				return self::findNode($node,$_nodeID,$childElements);
871
+				return self::findNode($node, $_nodeID, $childElements);
873 872
 			}
874 873
 		}
875 874
 	}
@@ -883,7 +882,7 @@  discard block
 block discarded – undo
883 882
 	 */
884 883
 	private function get_actions()
885 884
 	{
886
-		static $accArray=array(); // buffer identity names on single request
885
+		static $accArray = array(); // buffer identity names on single request
887 886
 		// duplicated from mail_hooks
888 887
 		static $deleteOptions = array(
889 888
 			'move_to_trash'		=> 'move to trash',
@@ -894,12 +893,12 @@  discard block
 block discarded – undo
894 893
 		$lastFolderUsedForMove = null;
895 894
 		$moveactions = array();
896 895
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
897
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
896
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
898 897
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
899 898
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
900 899
 		if (is_null($accArray))
901 900
 		{
902
-			foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj)
901
+			foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj)
903 902
 			{
904 903
 				//error_log(__METHOD__.__LINE__.array2string($accountObj));
905 904
 				if (!$accountObj->is_imap())
@@ -907,22 +906,22 @@  discard block
 block discarded – undo
907 906
 					// not to be used for IMAP Foldertree, as there is no Imap host
908 907
 					continue;
909 908
 				}
910
-				$identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']);
911
-				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
909
+				$identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']);
910
+				$accArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); // as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
912 911
 			}
913 912
 		}
914
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
913
+		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array();
915 914
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
916 915
 		{
917
-			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
916
+			if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
918 917
 			{
919 918
 				$_folder = $this->mail_bo->icServer->getCurrentMailbox();
920 919
 				//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace());
921
-				$counter =1;
920
+				$counter = 1;
922 921
 				foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont)
923 922
 				{
924 923
 					$moveaction = 'move_';
925
-					if ($_folder!=$i)
924
+					if ($_folder != $i)
926 925
 					{
927 926
 						$moveaction .= $lastFolderUsedForMoveCont;
928 927
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
@@ -933,7 +932,7 @@  discard block
 block discarded – undo
933 932
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
934 933
 							$fS['shortDisplayName'] = $i;
935 934
 							$moveactions[$moveaction] = $fS;
936
-							$counter ++;
935
+							$counter++;
937 936
 						}
938 937
 						else
939 938
 						{
@@ -943,9 +942,9 @@  discard block
 block discarded – undo
943 942
 					}
944 943
 				}
945 944
 			}
946
-			elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
945
+			elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
947 946
 			{
948
-				$counter =1;
947
+				$counter = 1;
949 948
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
950 949
 				{
951 950
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
@@ -958,19 +957,19 @@  discard block
 block discarded – undo
958 957
 						$fS['profileName'] = $accArray[$pid];
959 958
 						$fS['shortDisplayName'] = $i;
960 959
 						$moveactions[$moveaction] = $fS;
961
-						$counter ++;
960
+						$counter++;
962 961
 					}
963 962
 				}
964 963
 			}
965 964
 		}
966
-		Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
965
+		Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
967 966
 		$group = 0;
968
-		$actions =  array(
967
+		$actions = array(
969 968
 			'open' => array(
970 969
 				'caption' => lang('Open'),
971 970
 				'icon' => 'view',
972 971
 				'group' => ++$group,
973
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
972
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open',
974 973
 				'allowOnMultiple' => false,
975 974
 				'default' => true,
976 975
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet'))
@@ -1023,20 +1022,20 @@  discard block
 block discarded – undo
1023 1022
 				'allowOnMultiple' => false,
1024 1023
 			)
1025 1024
 		);
1026
-		$macounter=0;
1025
+		$macounter = 0;
1027 1026
 		if (!empty($moveactions))
1028 1027
 		{
1029 1028
 			//error_log(__METHOD__.__LINE__.array2string($moveactions));
1030
-			$children=array();
1031
-			$pID=0;
1029
+			$children = array();
1030
+			$pID = 0;
1032 1031
 			foreach ($moveactions as $moveaction => $lastFolderUsedForMove)
1033 1032
 			{
1034
-				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group);
1033
+				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group);
1035 1034
 				//error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#');
1036 1035
 				$children = array_merge($children,
1037 1036
 					array(
1038 1037
 						$moveaction => array(
1039
-							'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
1038
+							'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''),
1040 1039
 							'icon' => 'move',
1041 1040
 							'group' => $group,
1042 1041
 							'onExecute' => 'javaScript:app.mail.mail_move2folder',
@@ -1047,7 +1046,7 @@  discard block
 block discarded – undo
1047 1046
 				$pID = $lastFolderUsedForMove['profileID'];
1048 1047
 				$macounter++;
1049 1048
 			}
1050
-			$actions['moveto'] =	array(
1049
+			$actions['moveto'] = array(
1051 1050
 				'caption' => lang('Move selected to'),
1052 1051
 				'icon' => 'move',
1053 1052
 				'group' => $group,
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
 				'icon' => 'tracker/navbar',
1091 1090
 				'onExecute' => 'javaScript:app.mail.mail_integrate',
1092 1091
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1093
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
1092
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
1094 1093
 				'allowOnMultiple' => false,
1095 1094
 			),
1096 1095
 			'calendar' => array(
@@ -1309,25 +1308,25 @@  discard block
 block discarded – undo
1309 1308
 	 * @param array &$rows
1310 1309
 	 * @param array &$readonlys
1311 1310
 	 */
1312
-	public static function get_rows(&$query,&$rows,&$readonlys)
1311
+	public static function get_rows(&$query, &$rows, &$readonlys)
1313 1312
 	{
1314
-		unset($readonlys);	// not used, but required by function signature
1313
+		unset($readonlys); // not used, but required by function signature
1315 1314
 
1316 1315
 		// handle possible profile change in get_rows
1317 1316
 		if (!empty($query['selectedFolder']))
1318 1317
 		{
1319
-			list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1318
+			list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1320 1319
 			if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])
1321 1320
 			{
1322 1321
 				try {
1323
-					$mail_ui = new mail_ui(false);	// do NOT run constructor, as we change profile anyway
1322
+					$mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway
1324 1323
 					$mail_ui->changeProfile($_profileID);
1325 1324
 					$query['actions'] = $mail_ui->get_actions();
1326 1325
 				}
1327
-				catch(Exception $e)
1326
+				catch (Exception $e)
1328 1327
 				{
1329 1328
 					unset($e);
1330
-					$rows=array();
1329
+					$rows = array();
1331 1330
 					return 0;
1332 1331
 				}
1333 1332
 				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
@@ -1337,12 +1336,12 @@  discard block
 block discarded – undo
1337 1336
 		{
1338 1337
 			try
1339 1338
 			{
1340
-				$mail_ui = new mail_ui(true);	// run constructor for current profile
1339
+				$mail_ui = new mail_ui(true); // run constructor for current profile
1341 1340
 			}
1342
-			catch(Exception $e)
1341
+			catch (Exception $e)
1343 1342
 			{
1344 1343
 				unset($e);
1345
-				$rows=array();
1344
+				$rows = array();
1346 1345
 				return 0;
1347 1346
 			}
1348 1347
 			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
@@ -1353,68 +1352,68 @@  discard block
 block discarded – undo
1353 1352
 		//$query['search'] is the phrase in the searchbox
1354 1353
 
1355 1354
 		$mail_ui->mail_bo->restoreSessionData();
1356
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1355
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder'];
1357 1356
 		$mail_ui->mail_bo->saveSessionData();
1358 1357
 
1359 1358
 		$sRToFetch = null;
1360
-		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
1361
-		if (strpos($_folderName,self::$delimiter)!==false)
1359
+		list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1360
+		if (strpos($_folderName, self::$delimiter) !== false)
1362 1361
 		{
1363
-			list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3);
1362
+			list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3);
1364 1363
 			unset($app);
1365 1364
 		}
1366 1365
 		//save selected Folder to sessionData (mailbox)->currentFolder
1367
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1368
-		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1366
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName;
1367
+		$toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default)
1369 1368
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1370 1369
 		{
1371
-			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false);
1370
+			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false);
1372 1371
 		}
1373 1372
 		else
1374 1373
 		{
1375 1374
 			// take the extra time on failure
1376
-			if (!$mail_ui->mail_bo->folderExists($_folderName,true))
1375
+			if (!$mail_ui->mail_bo->folderExists($_folderName, true))
1377 1376
 			{
1378 1377
 				//error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead');
1379
-				$query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX';
1378
+				$query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX';
1380 1379
 			}
1381 1380
 		}
1382 1381
 		$mail_ui->mail_bo->saveSessionData();
1383 1382
 		$rowsFetched['messages'] = null;
1384
-		$offset = $query['start']+1; // we always start with 1
1383
+		$offset = $query['start'] + 1; // we always start with 1
1385 1384
 		$maxMessages = $query['num_rows'];
1386 1385
 		//error_log(__METHOD__.__LINE__.array2string($query));
1387
-		$sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']);
1388
-		if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
1386
+		$sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']);
1387
+		if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
1389 1388
 		{
1390 1389
 			if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1391 1390
 			{
1392
-				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
1391
+				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1393 1392
 				if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1394 1393
 				{
1395
-					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
1394
+					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true;
1396 1395
 				}
1397 1396
 			}
1398 1397
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1399 1398
 			$cutoffdate = $cutoffdate2 = null;
1400
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1401
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1399
+			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
1400
+			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
1402 1401
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1403 1402
 			$filter = array(
1404
-				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
1405
-				'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
1403
+				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
1404
+				'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
1406 1405
 				'string' => $query['search'],
1407 1406
 				'status' => 'any',
1408 1407
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1409 1408
 			);
1410
-			if ($query['enddate']||$query['startdate']) {
1409
+			if ($query['enddate'] || $query['startdate']) {
1411 1410
 				$filter['range'] = "BETWEEN";
1412 1411
 				if ($cutoffdate) {
1413
-					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1412
+					$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
1414 1413
 					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1415 1414
 				}
1416 1415
 				if ($cutoffdate2) {
1417
-					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1416
+					$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
1418 1417
 					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1419 1418
 				}
1420 1419
 			}
@@ -1427,17 +1426,17 @@  discard block
 block discarded – undo
1427 1426
 		{
1428 1427
 			$filter['status'] = $query['filter'];
1429 1428
 		}
1430
-		$reverse = ($query['sort']=='ASC'?false:true);
1429
+		$reverse = ($query['sort'] == 'ASC' ? false : true);
1431 1430
 		$prefchanged = false;
1432
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1431
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1433 1432
 		{
1434 1433
 			//error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']);
1435
-			$GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user');
1434
+			$GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user');
1436 1435
 			$prefchanged = true;
1437 1436
 		}
1438
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1437
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1439 1438
 		{
1440
-			$GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user');
1439
+			$GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user');
1441 1440
 			$prefchanged = true;
1442 1441
 		}
1443 1442
 		if ($prefchanged)
@@ -1468,13 +1467,13 @@  discard block
 block discarded – undo
1468 1467
 				$rowsFetched['messages'] = $_sR['count'];
1469 1468
 				$ids = $_sR['match']->ids;
1470 1469
 				// if $sR is false, something failed fundamentally
1471
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1472
-				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1473
-				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1470
+				if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids));
1471
+				$sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids
1472
+				$sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1474 1473
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
1475 1474
 				$maxMessages = 75;
1476 1475
 				$sortResultwH['header'] = array();
1477
-				if (count($sRToFetch)>0)
1476
+				if (count($sRToFetch) > 0)
1478 1477
 				{
1479 1478
 					//error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch));
1480 1479
 					$sortResult = array();
@@ -1488,7 +1487,7 @@  discard block
 block discarded – undo
1488 1487
 						$filter,
1489 1488
 						$sRToFetch,
1490 1489
 						true, //cacheResult
1491
-						($query['filter2']?true:false) // fetchPreview
1490
+						($query['filter2'] ? true : false) // fetchPreview
1492 1491
 					);
1493 1492
 				}
1494 1493
 			}
@@ -1505,30 +1504,30 @@  discard block
 block discarded – undo
1505 1504
 					$filter,
1506 1505
 					null, // this uids only
1507 1506
 					true, // cacheResult
1508
-					($query['filter2']?true:false) // fetchPreview
1507
+					($query['filter2'] ? true : false) // fetchPreview
1509 1508
 				);
1510 1509
 				$rowsFetched['messages'] = $sortResultwH['info']['total'];
1511 1510
 			}
1512 1511
 		}
1513 1512
 		catch (Exception $e)
1514 1513
 		{
1515
-			$sortResultwH=array();
1516
-			$sR=array();
1514
+			$sortResultwH = array();
1515
+			$sR = array();
1517 1516
 			self::callWizard($e->getMessage(), false, 'error');
1518 1517
 		}
1519 1518
 		$response = Api\Json\Response::get();
1520 1519
 		// unlock immediately after fetching the rows
1521
-		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
1520
+		if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false)
1522 1521
 		{
1523 1522
 			//error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']);
1524 1523
 			$response->call('app.mail.unlock_tree');
1525 1524
 		}
1526 1525
 
1527
-		if (is_array($sR) && count($sR)>0)
1526
+		if (is_array($sR) && count($sR) > 0)
1528 1527
 		{
1529 1528
 			foreach ((array)$sR as $key => $v)
1530 1529
 			{
1531
-				if (array_key_exists($key,(array)$sortResultwH['header'])==true)
1530
+				if (array_key_exists($key, (array)$sortResultwH['header']) == true)
1532 1531
 				{
1533 1532
 					$sortResult['header'][] = $sortResultwH['header'][$key];
1534 1533
 				}
@@ -1546,12 +1545,12 @@  discard block
 block discarded – undo
1546 1545
 		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1547 1546
 
1548 1547
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1549
-		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1550
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1551
-		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1548
+		$cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview');
1549
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1550
+		$rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema);
1552 1551
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1553 1552
 
1554
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1553
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__);
1555 1554
 		return $rowsFetched['messages'];
1556 1555
 	}
1557 1556
 
@@ -1563,7 +1562,7 @@  discard block
 block discarded – undo
1563 1562
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1564 1563
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1565 1564
 	 */
1566
-	function createRowID($_folderName, $message_uid, $_prependApp=false)
1565
+	function createRowID($_folderName, $message_uid, $_prependApp = false)
1567 1566
 	{
1568 1567
 		return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp);
1569 1568
 	}
@@ -1577,9 +1576,9 @@  discard block
 block discarded – undo
1577 1576
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1578 1577
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1579 1578
 	 */
1580
-	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false)
1579
+	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false)
1581 1580
 	{
1582
-		return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1581
+		return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1583 1582
 	}
1584 1583
 
1585 1584
 	/**
@@ -1590,13 +1589,13 @@  discard block
 block discarded – undo
1590 1589
 	 */
1591 1590
 	static function splitRowID($_rowID)
1592 1591
 	{
1593
-		$res = explode(self::$delimiter,$_rowID);
1592
+		$res = explode(self::$delimiter, $_rowID);
1594 1593
 		// as a rowID is perceeded by app::, should be mail!
1595 1594
 		//error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res));
1596
-		if (count($res)==4 && is_numeric($res[0]) )
1595
+		if (count($res) == 4 && is_numeric($res[0]))
1597 1596
 		{
1598 1597
 			// we have an own created rowID; prepend app=mail
1599
-			array_unshift($res,'mail');
1598
+			array_unshift($res, 'mail');
1600 1599
 		}
1601 1600
 		return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]);
1602 1601
 	}
@@ -1610,56 +1609,56 @@  discard block
 block discarded – undo
1610 1609
 	{
1611 1610
 		$actions = $this->get_actions();
1612 1611
 		$arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print',
1613
-			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1',	'label2', 'label3',	'label4', 'label5');
1614
-		foreach( $arrActions as &$act)
1612
+			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5');
1613
+		foreach ($arrActions as &$act)
1615 1614
 		{
1616 1615
 			//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
1617 1616
 			switch ($act)
1618 1617
 			{
1619 1618
 				case 'forward':
1620
-					$actionsenabled[$act]=$actions[$act];
1619
+					$actionsenabled[$act] = $actions[$act];
1621 1620
 					break;
1622 1621
 				case 'save':
1623
-					$actionsenabled[$act]=$actions[$act];
1622
+					$actionsenabled[$act] = $actions[$act];
1624 1623
 
1625 1624
 					break;
1626 1625
 				case 'view':
1627
-					$actionsenabled[$act]=$actions[$act];
1626
+					$actionsenabled[$act] = $actions[$act];
1628 1627
 					break;
1629 1628
 				case 'flagged':
1630
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1629
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1631 1630
 					break;
1632 1631
 				case 'read':
1633
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1632
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1634 1633
 					break;
1635 1634
 				case 'label1':
1636 1635
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important');
1637
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1636
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1638 1637
 					break;
1639 1638
 				case 'label2':
1640 1639
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job');
1641
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1640
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1642 1641
 					break;
1643 1642
 				case 'label3':
1644 1643
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal');
1645
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1644
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1646 1645
 					break;
1647 1646
 				case 'label4':
1648 1647
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do');
1649
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1648
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1650 1649
 					break;
1651 1650
 				case 'label5':
1652 1651
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later');
1653
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1652
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1654 1653
 					break;
1655 1654
 				default:
1656
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1655
+					if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act];
1657 1656
 			}
1658 1657
 		}
1659 1658
 		unset($actionsenabled['drag_mail']);
1660 1659
 		//error_log(array2string($actionsenabled['view']));
1661
-		unset($actionsenabled['view']['children']['openastext']);//not supported in preview
1662
-		unset($actionsenabled['view']['children']['openashtml']);//not supported in preview
1660
+		unset($actionsenabled['view']['children']['openastext']); //not supported in preview
1661
+		unset($actionsenabled['view']['children']['openashtml']); //not supported in preview
1663 1662
 
1664 1663
 		return $actionsenabled;
1665 1664
 	}
@@ -1673,45 +1672,45 @@  discard block
 block discarded – undo
1673 1672
 	 * @param array $_folderType used to determine if we need to populate from/to
1674 1673
 	 * @return array populated result array
1675 1674
 	 */
1676
-	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1675
+	public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0)
1677 1676
 	{
1678 1677
 		if (Mail::$debugTimes) $starttime = microtime(true);
1679 1678
 		$rv = array();
1680
-		$i=0;
1681
-		foreach((array)$_headers as $header)
1679
+		$i = 0;
1680
+		foreach ((array)$_headers as $header)
1682 1681
 		{
1683 1682
 			$i++;
1684 1683
 			$data = array();
1685 1684
 			//error_log(__METHOD__.array2string($header));
1686 1685
 			$message_uid = $header['uid'];
1687 1686
 			$data['uid'] = $message_uid;
1688
-			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1687
+			$data['row_id'] = $this->createRowID($_folderName, $message_uid);
1689 1688
 
1690 1689
 			$flags = "";
1691
-			if(!empty($header['recent'])) $flags .= "R";
1692
-			if(!empty($header['flagged'])) $flags .= "F";
1693
-			if(!empty($header['answered'])) $flags .= "A";
1694
-			if(!empty($header['forwarded'])) $flags .= "W";
1695
-			if(!empty($header['deleted'])) $flags .= "D";
1696
-			if(!empty($header['seen'])) $flags .= "S";
1697
-			if(!empty($header['label1'])) $flags .= "1";
1698
-			if(!empty($header['label2'])) $flags .= "2";
1699
-			if(!empty($header['label3'])) $flags .= "3";
1700
-			if(!empty($header['label4'])) $flags .= "4";
1701
-			if(!empty($header['label5'])) $flags .= "5";
1690
+			if (!empty($header['recent'])) $flags .= "R";
1691
+			if (!empty($header['flagged'])) $flags .= "F";
1692
+			if (!empty($header['answered'])) $flags .= "A";
1693
+			if (!empty($header['forwarded'])) $flags .= "W";
1694
+			if (!empty($header['deleted'])) $flags .= "D";
1695
+			if (!empty($header['seen'])) $flags .= "S";
1696
+			if (!empty($header['label1'])) $flags .= "1";
1697
+			if (!empty($header['label2'])) $flags .= "2";
1698
+			if (!empty($header['label3'])) $flags .= "3";
1699
+			if (!empty($header['label4'])) $flags .= "4";
1700
+			if (!empty($header['label5'])) $flags .= "5";
1702 1701
 
1703 1702
 			$data["status"] = "<span class=\"status_img\"></span>";
1704 1703
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
1705 1704
 
1706 1705
 			// the css for this row
1707
-			$is_recent=false;
1706
+			$is_recent = false;
1708 1707
 			$css_styles = array("mail");
1709 1708
 			if ($header['deleted']) {
1710 1709
 				$css_styles[] = 'deleted';
1711 1710
 			}
1712 1711
 			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1713 1712
 				$css_styles[] = 'recent';
1714
-				$is_recent=true;
1713
+				$is_recent = true;
1715 1714
 			}
1716 1715
 			if ($header['priority'] < 3) {
1717 1716
 				$css_styles[] = 'prio_high';
@@ -1749,19 +1748,19 @@  discard block
 block discarded – undo
1749 1748
 			if (in_array("subject", $cols))
1750 1749
 			{
1751 1750
 				// filter out undisplayable characters
1752
-				$search = array('[\016]','[\017]',
1753
-					'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1754
-					'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1751
+				$search = array('[\016]', '[\017]',
1752
+					'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1753
+					'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1755 1754
 				$replace = '';
1756 1755
 
1757
-				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1756
+				$header['subject'] = preg_replace($search, $replace, $header['subject']);
1758 1757
 				// curly brackets get messed up by the template!
1759 1758
 
1760 1759
 				if (!empty($header['subject'])) {
1761 1760
 					// make the subject shorter if it is to long
1762 1761
 					$subject = $header['subject'];
1763 1762
 				} else {
1764
-					$subject = '('. lang('no subject') .')';
1763
+					$subject = '('.lang('no subject').')';
1765 1764
 				}
1766 1765
 
1767 1766
 				$data["subject"] = $subject; // the mailsubject
@@ -1771,53 +1770,53 @@  discard block
 block discarded – undo
1771 1770
 			//error_log(__METHOD__.__LINE__.array2string($header));
1772 1771
 			if (in_array("attachments", $cols))
1773 1772
 			{
1774
-				if($header['mimetype'] == 'multipart/mixed' ||
1773
+				if ($header['mimetype'] == 'multipart/mixed' ||
1775 1774
 					$header['mimetype'] == 'multipart/signed' ||
1776 1775
 					$header['mimetype'] == 'multipart/related' ||
1777 1776
 					$header['mimetype'] == 'multipart/report' ||
1778 1777
 					$header['mimetype'] == 'text/calendar' ||
1779 1778
 					$header['mimetype'] == 'text/html' ||
1780
-					substr($header['mimetype'],0,11) == 'application' ||
1781
-					substr($header['mimetype'],0,5) == 'audio' ||
1782
-					substr($header['mimetype'],0,5) == 'video' ||
1779
+					substr($header['mimetype'], 0, 11) == 'application' ||
1780
+					substr($header['mimetype'], 0, 5) == 'audio' ||
1781
+					substr($header['mimetype'], 0, 5) == 'video' ||
1783 1782
 					$header['mimetype'] == 'multipart/alternative')
1784 1783
 				{
1785
-					$image = Api\Html::image('mail','attach');
1784
+					$image = Api\Html::image('mail', 'attach');
1786 1785
 					$imageHTMLBlock = '';
1787
-					$datarowid = $this->createRowID($_folderName,$message_uid,true);
1786
+					$datarowid = $this->createRowID($_folderName, $message_uid, true);
1788 1787
 					$attachments = $header['attachments'];
1789
-					if (count($attachments)<1)
1788
+					if (count($attachments) < 1)
1790 1789
 					{
1791 1790
 						$image = '&nbsp;';
1792 1791
 					}
1793
-					if (count($attachments)==1)
1792
+					if (count($attachments) == 1)
1794 1793
 					{
1795
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1796
-						$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
1794
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1795
+						$image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : ''));
1797 1796
 					}
1798
-					if (count($attachments)>1)
1797
+					if (count($attachments) > 1)
1799 1798
 					{
1800
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1801
-						$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
1799
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1800
+						$image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments)));
1802 1801
 					}
1803 1802
 
1804 1803
 					$attachmentFlag = $image;
1805 1804
 				} else {
1806
-					$attachmentFlag ='&nbsp;';
1805
+					$attachmentFlag = '&nbsp;';
1807 1806
 				}
1808 1807
 				// show priority flag
1809 1808
 				if ($header['priority'] < 3) {
1810
-					 $image = Api\Html::image('mail','prio_high');
1809
+					 $image = Api\Html::image('mail', 'prio_high');
1811 1810
 				} elseif ($header['priority'] > 3) {
1812
-					$image = Api\Html::image('mail','prio_low');
1811
+					$image = Api\Html::image('mail', 'prio_low');
1813 1812
 				} else {
1814 1813
 					$image = '';
1815 1814
 				}
1816 1815
 				// show a flag for flagged messages
1817
-				$imageflagged ='';
1816
+				$imageflagged = '';
1818 1817
 				if ($header['flagged'])
1819 1818
 				{
1820
-					$imageflagged = Api\Html::image('mail','unread_flagged_small');
1819
+					$imageflagged = Api\Html::image('mail', 'unread_flagged_small');
1821 1820
 				}
1822 1821
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
1823 1822
 			}
@@ -1826,7 +1825,7 @@  discard block
 block discarded – undo
1826 1825
 			if (in_array("toaddress", $cols))
1827 1826
 			{
1828 1827
 				// sent or drafts or template folder means foldertype > 0, use to address instead of from
1829
-				$data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset);
1828
+				$data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset);
1830 1829
 			}
1831 1830
 
1832 1831
 			if (in_array("additionaltoaddress", $cols))
@@ -1859,29 +1858,29 @@  discard block
 block discarded – undo
1859 1858
 			$data['flags'] = Array();
1860 1859
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1861 1860
 			foreach ($css_styles as &$flag) {
1862
-				if ($flag!='mail')
1861
+				if ($flag != 'mail')
1863 1862
 				{
1864
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1865
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1866
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1867
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1868
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1869
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1863
+					if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; }
1864
+					elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; }
1865
+					elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; }
1866
+					elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; }
1867
+					elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; }
1868
+					elseif ($flag == 'unseen') {unset($data["flags"]['read']); }
1870 1869
 					else $data["flags"][$flag] = $flag;
1871 1870
 				}
1872 1871
 			}
1873 1872
 			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1874
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1873
+			if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1875 1874
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1876
-			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1877
-			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
1875
+			$data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]);
1876
+			if (in_array("bodypreview", $cols) && $header['bodypreview'])
1878 1877
 			{
1879 1878
 				$data["bodypreview"] = $header['bodypreview'];
1880 1879
 			}
1881 1880
 			$rv[] = $data;
1882 1881
 			//error_log(__METHOD__.__LINE__.array2string($data));
1883 1882
 		}
1884
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
1883
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__);
1885 1884
 
1886 1885
 		// ToDo: call this ONLY if labels change
1887 1886
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1896,8 +1895,8 @@  discard block
 block discarded – undo
1896 1895
 	 */
1897 1896
 	function displayHeader()
1898 1897
 	{
1899
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1900
-		if(isset($_GET['part'])) $partID = $_GET['part'];
1898
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
1899
+		if (isset($_GET['part'])) $partID = $_GET['part'];
1901 1900
 
1902 1901
 		$hA = self::splitRowID($rowID);
1903 1902
 		$uid = $hA['msgUID'];
@@ -1911,17 +1910,17 @@  discard block
 block discarded – undo
1911 1910
 		}
1912 1911
 
1913 1912
 		$this->mail_bo->reopen($mailbox);
1914
-		$headers_in	= $this->mail_bo->getMessageRawHeader($uid, $partID);
1913
+		$headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID);
1915 1914
 
1916 1915
 		// add line breaks to $rawheaders
1917
-		$newRawHeaders = explode("\n",$headers_in);
1916
+		$newRawHeaders = explode("\n", $headers_in);
1918 1917
 		reset($newRawHeaders);
1919 1918
 
1920 1919
 		// reset $rawheaders
1921
-		$rawheaders 	= "";
1920
+		$rawheaders = "";
1922 1921
 		// create it new, with good line breaks
1923 1922
 		reset($newRawHeaders);
1924
-		while(list($key,$value) = @each($newRawHeaders)) {
1923
+		while (list($key, $value) = @each($newRawHeaders)) {
1925 1924
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1926 1925
 		}
1927 1926
 
@@ -1933,7 +1932,7 @@  discard block
 block discarded – undo
1933 1932
 		}
1934 1933
 
1935 1934
 		header('Content-type: text/html; charset=iso-8859-1');
1936
-		print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
1935
+		print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>';
1937 1936
 
1938 1937
 	}
1939 1938
 
@@ -1946,10 +1945,10 @@  discard block
 block discarded – undo
1946 1945
 	{
1947 1946
 		if (is_null($_requesteddata)) $_requesteddata = $_GET;
1948 1947
 
1949
-		$preventRedirect=false;
1950
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1951
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1952
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
1948
+		$preventRedirect = false;
1949
+		if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id'];
1950
+		if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null;
1951
+		if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false);
1953 1952
 
1954 1953
 		$hA = self::splitRowID($rowID);
1955 1954
 		$uid = $hA['msgUID'];
@@ -1973,79 +1972,79 @@  discard block
 block discarded – undo
1973 1972
 		}
1974 1973
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
1975 1974
 		{
1976
-			Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
1975
+			Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft'));
1977 1976
 		}
1978 1977
 		$this->mail_bo->reopen($mailbox);
1979 1978
 		// retrieve the flags of the message, before touching it.
1980 1979
 		try
1981 1980
 		{
1982
-			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
1981
+			$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox);
1983 1982
 		}
1984 1983
 		catch (Api\Exception $e)
1985 1984
 		{
1986 1985
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
1987
-			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1986
+			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID);
1988 1987
 			Framework::message($e->getMessage(), 'error');
1989 1988
 		}
1990 1989
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
1991
-		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1990
+		$envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox);
1992 1991
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1993
-		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1992
+		$this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox);
1994 1993
 		$fetchEmbeddedImages = false;
1995 1994
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1996 1995
 		// we do NOT want to see those, that are embedded in the list of attachments
1997
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
1998
-		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1996
+		if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true;
1997
+		$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox);
1999 1998
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2000 1999
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
2001 2000
 
2002
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2003
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2004
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2001
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2002
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2003
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2005 2004
 
2006 2005
 		//error_log(__METHOD__.__LINE__.$mailBody);
2007 2006
 		$this->mail_bo->closeConnection();
2008 2007
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
2009 2008
 		$etpl = new Etemplate('mail.display');
2010
-		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2009
+		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false);
2011 2010
 
2012 2011
 		// Set up data for taglist widget(s)
2013
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2012
+		if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']);
2014 2013
 		$sel_options = array();
2015
-		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2014
+		foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field)
2016 2015
 		{
2017 2016
 			if (!isset($envelope[$field])) continue;
2018
-			foreach($envelope[$field] as $field_data)
2017
+			foreach ($envelope[$field] as $field_data)
2019 2018
 			{
2020 2019
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
2021 2020
 				$content[$field][] = $field_data;
2022 2021
 				$sel_options[$field][] = array(
2023 2022
 					// taglist requires these - not optional
2024 2023
 					'id' => $field_data,
2025
-					'label' => str_replace('"',"'",$field_data),
2024
+					'label' => str_replace('"', "'", $field_data),
2026 2025
 				);
2027 2026
 			}
2028 2027
 		}
2029 2028
 		$actionsenabled = $this->getDisplayToolbarActions();
2030 2029
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2031 2030
 		if (empty($subject)) $subject = lang('no subject');
2032
-		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2031
+		$content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg);
2033 2032
 		// Send mail ID so we can use it for actions
2034 2033
 		$content['mail_id'] = $rowID;
2035 2034
 		if (!is_array($headers) || !isset($headers['DATE']))
2036 2035
 		{
2037
-			$headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:'');
2036
+			$headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : '');
2038 2037
 		}
2039
-		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2038
+		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true);
2040 2039
 		$content['mail_displaysubject'] = $subject;
2041
-		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2042
-		if (!empty($partID)) $linkData['_partID']=$partID;
2043
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2044
-		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2040
+		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID);
2041
+		if (!empty($partID)) $linkData['_partID'] = $partID;
2042
+		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions;
2043
+		$content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData);
2045 2044
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2046
-		$content['mail_id']=$rowID;
2047
-		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
2048
-		$content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone");
2045
+		$content['mail_id'] = $rowID;
2046
+		$content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight");
2047
+		$content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone");
2049 2048
 
2050 2049
 		// DRAG attachments actions
2051 2050
 		$etpl->setElementAttribute('mail_displayattachments', 'actions', array(
@@ -2062,22 +2061,22 @@  discard block
 block discarded – undo
2062 2061
 			$this->changeProfile($rememberServerID);
2063 2062
 		}
2064 2063
 
2065
-		$etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
2064
+		$etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2);
2066 2065
 	}
2067 2066
 
2068 2067
 	/**
2069 2068
 	 * Build actions for display toolbar
2070 2069
 	 */
2071
-	function getDisplayToolbarActions ()
2070
+	function getDisplayToolbarActions()
2072 2071
 	{
2073 2072
 		$actions = $this->get_toolbar_actions();
2074
-		$actions['mark']['children']['flagged']=array(
2073
+		$actions['mark']['children']['flagged'] = array(
2075 2074
 			'group' => $actions['mark']['children']['flagged']['group'],
2076 2075
 			'caption' => 'Flagged',
2077 2076
 			'icon' => 'unread_flagged_small',
2078 2077
 			'onExecute' => 'javaScript:app.mail.mail_flag',
2079 2078
 		);
2080
-		$actions['mark']['children']['unflagged']=array(
2079
+		$actions['mark']['children']['unflagged'] = array(
2081 2080
 			'group' => $actions['mark']['children']['flagged']['group'],
2082 2081
 			'caption' => 'Unflagged',
2083 2082
 			'icon' => 'read_flagged_small',
@@ -2089,9 +2088,9 @@  discard block
 block discarded – undo
2089 2088
 		$compose = $actions['composeasnew'];
2090 2089
 		unset($actions['composeasnew']);
2091 2090
 
2092
-		$actions2 = array_reverse($actions,true);
2093
-		$actions2['composeasnew']= $compose;
2094
-		return array_reverse($actions2,true);
2091
+		$actions2 = array_reverse($actions, true);
2092
+		$actions2['composeasnew'] = $compose;
2093
+		return array_reverse($actions2, true);
2095 2094
 	}
2096 2095
 
2097 2096
 	/**
@@ -2104,22 +2103,22 @@  discard block
 block discarded – undo
2104 2103
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
2105 2104
 	 * @return array|string data array or html or empty string
2106 2105
 	 */
2107
-	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
2106
+	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false)
2108 2107
 	{
2109
-		$attachmentHTMLBlock='';
2108
+		$attachmentHTMLBlock = '';
2110 2109
 		$attachmentHTML = array();
2111 2110
 		if (is_array($attachments) && count($attachments) > 0) {
2112
-			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2113
-			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2111
+			$url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"');
2112
+			$url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all'));
2114 2113
 
2115 2114
 			foreach ($attachments as $key => $value)
2116 2115
 			{
2117
-				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
2118
-				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2116
+				$attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)'));
2117
+				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8');
2119 2118
 				//error_log(array2string($value));
2120 2119
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2121
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2122
-				$attachmentHTML[$key]['type']=$value['mimeType'];
2120
+				if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2121
+				$attachmentHTML[$key]['type'] = $value['mimeType'];
2123 2122
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2124 2123
 				$hA = self::splitRowID($rowID);
2125 2124
 				$uid = $hA['msgUID'];
@@ -2129,28 +2128,27 @@  discard block
 block discarded – undo
2129 2128
 				$attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
2130 2129
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
2131 2130
 				));
2132
-				$attachmentHTML[$key]['size']=Vfs::hsize($value['size']);
2133
-				$attachmentHTML[$key]['attachment_number']=$key;
2134
-				$attachmentHTML[$key]['partID']=$value['partID'];
2131
+				$attachmentHTML[$key]['size'] = Vfs::hsize($value['size']);
2132
+				$attachmentHTML[$key]['attachment_number'] = $key;
2133
+				$attachmentHTML[$key]['partID'] = $value['partID'];
2135 2134
 				$attachmentHTML[$key]['mail_id'] = $rowID;
2136
-				$attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
2135
+				$attachmentHTML[$key]['winmailFlag'] = $value['is_winmail'];
2137 2136
 				$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
2138 2137
 				// reset mode array as it should be considered differently for
2139 2138
 				// each attachment
2140 2139
 				$mode = array();
2141
-				switch(strtoupper($value['mimeType']))
2140
+				switch (strtoupper($value['mimeType']))
2142 2141
 				{
2143 2142
 					case 'MESSAGE/RFC822':
2144
-						$linkData = array
2145
-						(
2143
+						$linkData = array(
2146 2144
 							'menuaction'	=> 'mail.mail_ui.displayMessage',
2147 2145
 							'mode'		=> 'display', //message/rfc822 attachments should be opened in display mode
2148 2146
 							'id'		=> $rowID,
2149 2147
 							'part'		=> $value['partID'],
2150 2148
 							'is_winmail'    => $value['is_winmail']
2151 2149
 						);
2152
-						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
2153
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2150
+						$windowName = 'displayMessage_'.$rowID.'_'.$value['partID'];
2151
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2154 2152
 						break;
2155 2153
 					case 'IMAGE/JPEG':
2156 2154
 					case 'IMAGE/PNG':
@@ -2166,7 +2164,7 @@  discard block
 block discarded – undo
2166 2164
 					case 'TEXT/HTML':
2167 2165
 					case 'TEXT/DIRECTORY':
2168 2166
 						$sfxMimeType = $value['mimeType'];
2169
-						$buff = explode('.',$value['name']);
2167
+						$buff = explode('.', $value['name']);
2170 2168
 						$suffix = '';
2171 2169
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2172 2170
 						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2179,49 +2177,47 @@  discard block
 block discarded – undo
2179 2177
 					case 'TEXT/VCARD':
2180 2178
 					case 'TEXT/CALENDAR':
2181 2179
 					case 'TEXT/X-VCALENDAR':
2182
-						$linkData = array_merge(array
2183
-						(
2180
+						$linkData = array_merge(array(
2184 2181
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2185 2182
 							'id'		=> $rowID,
2186 2183
 							'part'		=> $value['partID'],
2187 2184
 							'is_winmail'    => $value['is_winmail'],
2188 2185
 							'mailbox'   => base64_encode($mailbox),
2189
-						) , $mode);
2190
-						$windowName = 'displayAttachment_'. $uid;
2186
+						), $mode);
2187
+						$windowName = 'displayAttachment_'.$uid;
2191 2188
 						$reg = '800x600';
2192 2189
 						// handle calendar/vcard
2193
-						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
2190
+						if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR')
2194 2191
 						{
2195
-							$windowName = 'displayEvent_'. $rowID;
2196
-							$reg2 = Link::get_registry('calendar','view_popup');
2197
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2192
+							$windowName = 'displayEvent_'.$rowID;
2193
+							$reg2 = Link::get_registry('calendar', 'view_popup');
2194
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2198 2195
 						}
2199
-						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
2196
+						if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD')
2200 2197
 						{
2201
-							$windowName = 'displayContact_'. $rowID;
2202
-							$reg2 = Link::get_registry('addressbook','add_popup');
2203
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2198
+							$windowName = 'displayContact_'.$rowID;
2199
+							$reg2 = Link::get_registry('addressbook', 'add_popup');
2200
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2204 2201
 						}
2205 2202
 						// apply to action
2206
-						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
2207
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
2203
+						list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg));
2204
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);";
2208 2205
 						break;
2209 2206
 					default:
2210
-						$linkData = array
2211
-						(
2207
+						$linkData = array(
2212 2208
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2213 2209
 							'id'		=> $rowID,
2214 2210
 							'part'		=> $value['partID'],
2215 2211
 							'is_winmail'    => $value['is_winmail'],
2216 2212
 							'mailbox'   => base64_encode($mailbox),
2217 2213
 						);
2218
-						$linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';";
2214
+						$linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';";
2219 2215
 						break;
2220 2216
 				}
2221 2217
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
2222 2218
 				if (empty($attachmentHTML[$key]['mime_data']))
2223 2219
 				{
2224
-					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData);
2220
+					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData);
2225 2221
 					unset($attachmentHTML[$key]['mime_data']);
2226 2222
 				}
2227 2223
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2231,8 +2227,7 @@  discard block
 block discarded – undo
2231 2227
 					($value['name'] ? $value['name'] : lang('(no subject)')).
2232 2228
 					'</b></a>';
2233 2229
 
2234
-				$linkData = array
2235
-				(
2230
+				$linkData = array(
2236 2231
 					'menuaction'	=> 'mail.mail_ui.getAttachment',
2237 2232
 					'mode'		=> 'save',
2238 2233
 					'id'		=> $rowID,
@@ -2240,11 +2235,11 @@  discard block
 block discarded – undo
2240 2235
 					'is_winmail'    => $value['is_winmail'],
2241 2236
 					'mailbox'   => base64_encode($mailbox),
2242 2237
 				);
2243
-				$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
2238
+				$attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>";
2244 2239
 
2245 2240
 				if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
2246 2241
 				{
2247
-					$link_vfs_save = Egw::link('/index.php',array(
2242
+					$link_vfs_save = Egw::link('/index.php', array(
2248 2243
 						'menuaction' => 'filemanager.filemanager_select.select',
2249 2244
 						'mode' => 'saveas',
2250 2245
 						'name' => $value['name'],
@@ -2263,19 +2258,19 @@  discard block
 block discarded – undo
2263 2258
 							//$rowID
2264 2259
 							$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
2265 2260
 						}
2266
-						$link_vfs_save = Egw::link('/index.php',array(
2261
+						$link_vfs_save = Egw::link('/index.php', array(
2267 2262
 							'menuaction' => 'filemanager.filemanager_select.select',
2268 2263
 							'mode' => 'select-dir',
2269 2264
 							'method' => 'mail.mail_ui.vfsSaveAttachment',
2270 2265
 							'label' => lang('Save all'),
2271
-						)+$ids);
2266
+						) + $ids);
2272 2267
 						$vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>";
2273 2268
 					}
2274 2269
 					$attachmentHTML[$key]['link_save'] .= $vfs_save;
2275 2270
 					//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
2276 2271
 				}
2277 2272
 			}
2278
-			$attachmentHTMLBlock="<table width='100%'>";
2273
+			$attachmentHTMLBlock = "<table width='100%'>";
2279 2274
 			foreach ((array)$attachmentHTML as $row)
2280 2275
 			{
2281 2276
 				$attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>';
@@ -2293,7 +2288,7 @@  discard block
 block discarded – undo
2293 2288
 				unset($attachmentHTML[$ikey]['link_save']);
2294 2289
 			}
2295 2290
 		}
2296
-		return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML);
2291
+		return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML);
2297 2292
 	}
2298 2293
 
2299 2294
 	/**
@@ -2304,7 +2299,7 @@  discard block
 block discarded – undo
2304 2299
 	 */
2305 2300
 	function gatherVacation($cachedVacations = array())
2306 2301
 	{
2307
-		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host);
2302
+		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host);
2308 2303
 		//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
2309 2304
 
2310 2305
 		if ($isVacationEnabled)
@@ -2317,7 +2312,7 @@  discard block
 block discarded – undo
2317 2312
 
2318 2313
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
2319 2314
 				// Set vacation to the instance cache for particular account with expiration of one day
2320
-				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
2315
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24);
2321 2316
 			}
2322 2317
 			catch (PEAR_Exception $ex)
2323 2318
 			{
@@ -2338,36 +2333,36 @@  discard block
 block discarded – undo
2338 2333
 	function quotaDisplay($_usage, $_limit)
2339 2334
 	{
2340 2335
 
2341
-		if($_limit == 0) {
2342
-			$quotaPercent=100;
2336
+		if ($_limit == 0) {
2337
+			$quotaPercent = 100;
2343 2338
 		} else {
2344
-			$quotaPercent=round(($_usage*100)/$_limit);
2339
+			$quotaPercent = round(($_usage * 100) / $_limit);
2345 2340
 		}
2346 2341
 
2347
-		$quotaLimit=Mail::show_readable_size($_limit*1024);
2348
-		$quotaUsage=Mail::show_readable_size($_usage*1024);
2342
+		$quotaLimit = Mail::show_readable_size($_limit * 1024);
2343
+		$quotaUsage = Mail::show_readable_size($_usage * 1024);
2349 2344
 
2350 2345
 
2351
-		if($quotaPercent > 90 && $_limit>0) {
2352
-			$quotaBG='mail-index_QuotaRed';
2353
-		} elseif($quotaPercent > 80 && $_limit>0) {
2354
-			$quotaBG='mail-index_QuotaYellow';
2346
+		if ($quotaPercent > 90 && $_limit > 0) {
2347
+			$quotaBG = 'mail-index_QuotaRed';
2348
+		} elseif ($quotaPercent > 80 && $_limit > 0) {
2349
+			$quotaBG = 'mail-index_QuotaYellow';
2355 2350
 		} else {
2356
-			$quotaBG='mail-index_QuotaGreen';
2351
+			$quotaBG = 'mail-index_QuotaGreen';
2357 2352
 		}
2358 2353
 
2359
-		if($_limit > 0) {
2360
-			$quotaText = $quotaUsage .'/'.$quotaLimit;
2354
+		if ($_limit > 0) {
2355
+			$quotaText = $quotaUsage.'/'.$quotaLimit;
2361 2356
 		} else {
2362 2357
 			$quotaText = $quotaUsage;
2363 2358
 		}
2364 2359
 
2365
-		if($quotaPercent > 50) {
2360
+		if ($quotaPercent > 50) {
2366 2361
 		} else {
2367 2362
 		}
2368 2363
 		$quota['class'] = $quotaBG;
2369
-		$quota['text'] = lang('Quota: %1',$quotaText);
2370
-		$quota['percent'] = (string)round(($_usage*100)/$_limit);
2364
+		$quota['text'] = lang('Quota: %1', $quotaText);
2365
+		$quota['percent'] = (string)round(($_usage * 100) / $_limit);
2371 2366
 		return $quota;
2372 2367
 	}
2373 2368
 
@@ -2381,12 +2376,12 @@  discard block
 block discarded – undo
2381 2376
 		$uid	= $_GET['uid'];
2382 2377
 		$cid	= base64_decode($_GET['cid']);
2383 2378
 		$partID = urldecode($_GET['partID']);
2384
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2379
+		if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']);
2385 2380
 
2386 2381
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2387 2382
 		$this->mail_bo->reopen($mailbox);
2388 2383
 
2389
-		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true);	// true get contents as stream
2384
+		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream
2390 2385
 
2391 2386
 		$this->mail_bo->closeConnection();
2392 2387
 
@@ -2394,8 +2389,8 @@  discard block
 block discarded – undo
2394 2389
 
2395 2390
 		if ($attachment)
2396 2391
 		{
2397
-			header("Content-Type: ". $attachment->getType());
2398
-			header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"');
2392
+			header("Content-Type: ".$attachment->getType());
2393
+			header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"');
2399 2394
 			//header("Expires: 0");
2400 2395
 			// the next headers are for IE and SSL
2401 2396
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -2413,7 +2408,7 @@  discard block
 block discarded – undo
2413 2408
 
2414 2409
 	function getAttachment()
2415 2410
 	{
2416
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2411
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2417 2412
 
2418 2413
 		$hA = self::splitRowID($rowID);
2419 2414
 		$uid = $hA['msgUID'];
@@ -2425,11 +2420,11 @@  discard block
 block discarded – undo
2425 2420
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2426 2421
 			$this->changeProfile($icServerID);
2427 2422
 		}
2428
-		$part		= $_GET['part'];
2423
+		$part = $_GET['part'];
2429 2424
 		$is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0;
2430 2425
 
2431 2426
 		$this->mail_bo->reopen($mailbox);
2432
-		$attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false);
2427
+		$attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false);
2433 2428
 		$this->mail_bo->closeConnection();
2434 2429
 		if ($rememberServerID != $this->mail_bo->profileID)
2435 2430
 		{
@@ -2444,7 +2439,7 @@  discard block
 block discarded – undo
2444 2439
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type']))
2445 2440
 			{
2446 2441
 				$sfxMimeType = $attachment['type'];
2447
-				$buff = explode('.',$attachment['filename']);
2442
+				$buff = explode('.', $attachment['filename']);
2448 2443
 				$suffix = '';
2449 2444
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2450 2445
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2456,10 +2451,10 @@  discard block
 block discarded – undo
2456 2451
 			{
2457 2452
 				//error_log(__METHOD__."about to call calendar_ical");
2458 2453
 				$calendar_ical = new calendar_ical();
2459
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2454
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2460 2455
 				//error_log(__METHOD__.array2string($eventid));
2461 2456
 				if (!$eventid) $eventid = -1;
2462
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2457
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']);
2463 2458
 				//error_log(__METHOD__.$event);
2464 2459
 				if ((int)$event > 0)
2465 2460
 				{
@@ -2467,7 +2462,7 @@  discard block
 block discarded – undo
2467 2462
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2468 2463
 						'cal_id'      => $event,
2469 2464
 					);
2470
-					Egw::redirect_link('../index.php',$vars);
2465
+					Egw::redirect_link('../index.php', $vars);
2471 2466
 				}
2472 2467
 				//Import failed, download content anyway
2473 2468
 			}
@@ -2482,13 +2477,13 @@  discard block
 block discarded – undo
2482 2477
 				{
2483 2478
 					$vcard['uid'] = trim($vcard['uid']);
2484 2479
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2485
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2480
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2486 2481
 				}
2487 2482
 				if (!$contact) $contact = null;
2488 2483
 				// 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))
2489
-				if ($contact || count($vcard)>2)
2484
+				if ($contact || count($vcard) > 2)
2490 2485
 				{
2491
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2486
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']);
2492 2487
 				}
2493 2488
 				if ((int)$contact > 0)
2494 2489
 				{
@@ -2496,14 +2491,14 @@  discard block
 block discarded – undo
2496 2491
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2497 2492
 						'contact_id'	=> $contact,
2498 2493
 					);
2499
-					Egw::redirect_link('../index.php',$vars);
2494
+					Egw::redirect_link('../index.php', $vars);
2500 2495
 				}
2501 2496
 				//Import failed, download content anyway
2502 2497
 			}
2503 2498
 		}
2504 2499
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2505
-		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
2506
-		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
2500
+		$filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part));
2501
+		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save");
2507 2502
 		echo $attachment['attachment'];
2508 2503
 
2509 2504
 		exit();
@@ -2518,9 +2513,9 @@  discard block
 block discarded – undo
2518 2513
 	function saveMessage()
2519 2514
 	{
2520 2515
 		$display = false;
2521
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2522
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2523
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2516
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2517
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2518
+		if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location'];
2524 2519
 
2525 2520
 		$hA = self::splitRowID($rowID);
2526 2521
 		$uid = $hA['msgUID'];
@@ -2548,14 +2543,14 @@  discard block
 block discarded – undo
2548 2543
 		if (!$display)
2549 2544
 		{
2550 2545
 			$headers = Horde_Mime_Headers::parseHeaders($message);
2551
-			$subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT']));
2552
-			Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
2546
+			$subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT']));
2547
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true);
2553 2548
 			echo $message;
2554 2549
 		}
2555 2550
 		else
2556 2551
 		{
2557
-			Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false);
2558
-			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
2552
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false);
2553
+			print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>';
2559 2554
 		}
2560 2555
 	}
2561 2556
 
@@ -2567,18 +2562,18 @@  discard block
 block discarded – undo
2567 2562
 	 * @param boolean $close Return javascript to close the window
2568 2563
 	 * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
2569 2564
 	 */
2570
-	function vfsSaveMessage($ids,$path, $close = true)
2565
+	function vfsSaveMessage($ids, $path, $close = true)
2571 2566
 	{
2572 2567
 		//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
2573 2568
 
2574 2569
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2575 2570
 		{
2576
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2571
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2577 2572
 		}
2578 2573
 		Api\Translation::add_app('mail');
2579 2574
 
2580 2575
 		$rememberServerID = $this->mail_bo->profileID;
2581
-		foreach((array)$ids as $id)
2576
+		foreach ((array)$ids as $id)
2582 2577
 		{
2583 2578
 			$hA = self::splitRowID($id);
2584 2579
 			$uid = $hA['msgUID'];
@@ -2589,20 +2584,20 @@  discard block
 block discarded – undo
2589 2584
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2590 2585
 				$this->changeProfile($icServerID);
2591 2586
 			}
2592
-			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
2593
-			$err=null;
2594
-			if(Vfs::is_dir($path))
2587
+			$message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox);
2588
+			$err = null;
2589
+			if (Vfs::is_dir($path))
2595 2590
 			{
2596
-				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
2597
-				$file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml';
2591
+				$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2592
+				$file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml';
2598 2593
 			}
2599 2594
 			else
2600 2595
 			{
2601 2596
 				$file = $path;
2602 2597
 			}
2603
-			if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message))
2598
+			if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message))
2604 2599
 			{
2605
-				$err .= lang('Error saving %1!',$file);
2600
+				$err .= lang('Error saving %1!', $file);
2606 2601
 				$succeeded = false;
2607 2602
 			}
2608 2603
 			else
@@ -2612,10 +2607,10 @@  discard block
 block discarded – undo
2612 2607
 			if ($fp) fclose($fp);
2613 2608
 			if ($succeeded)
2614 2609
 			{
2615
-				unset($headers['SUBJECT']);//already in filename
2610
+				unset($headers['SUBJECT']); //already in filename
2616 2611
 				$infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false);
2617
-				$props = array(array('name' => 'comment','val' => $infoSection));
2618
-				Vfs::proppatch($file,$props);
2612
+				$props = array(array('name' => 'comment', 'val' => $infoSection));
2613
+				Vfs::proppatch($file, $props);
2619 2614
 			}
2620 2615
 		}
2621 2616
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2624,9 +2619,9 @@  discard block
 block discarded – undo
2624 2619
 			$this->changeProfile($rememberServerID);
2625 2620
 		}
2626 2621
 
2627
-		if($close)
2622
+		if ($close)
2628 2623
 		{
2629
-			Framework::window_close(($err?$err:null));
2624
+			Framework::window_close(($err ? $err : null));
2630 2625
 		}
2631 2626
 		else
2632 2627
 		{
@@ -2641,15 +2636,15 @@  discard block
 block discarded – undo
2641 2636
 	 * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
2642 2637
 	 * @return string javascript eg. to close the selector window
2643 2638
 	 */
2644
-	function vfsSaveAttachment($ids,$path)
2639
+	function vfsSaveAttachment($ids, $path)
2645 2640
 	{
2646 2641
 		//error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');");
2647 2642
 
2648 2643
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2649 2644
 		{
2650
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2645
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2651 2646
 		}
2652
-		$err=null;
2647
+		$err = null;
2653 2648
 		$dupe_count = array();
2654 2649
 		$rememberServerID = $this->mail_bo->profileID;
2655 2650
 
@@ -2659,12 +2654,12 @@  discard block
 block discarded – undo
2659 2654
 		 *
2660 2655
 		 * @return array an array of parameters
2661 2656
 		 */
2662
-		$getParams = function ($id) {
2663
-			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2664
-			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2657
+		$getParams = function($id) {
2658
+			list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8);
2659
+			$lId = implode('::', array($app, $user, $serverID, $mailbox, $uid));
2665 2660
 			$hA = mail_ui::splitRowID($lId);
2666 2661
 			return array(
2667
-				'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail,
2662
+				'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail,
2668 2663
 				'user' => $user,
2669 2664
 				'name' => $name,
2670 2665
 				'part' => $part,
@@ -2676,8 +2671,8 @@  discard block
 block discarded – undo
2676 2671
 
2677 2672
 		//Examine the first attachment to see if attachment
2678 2673
 		//is winmail.dat embedded attachments.
2679
-		$isMultipleDownload=is_array($ids);
2680
-		$p = $getParams((is_array($ids)?$ids[0]:$ids));
2674
+		$isMultipleDownload = is_array($ids);
2675
+		$p = $getParams((is_array($ids) ? $ids[0] : $ids));
2681 2676
 		if ($p['is_winmail'])
2682 2677
 		{
2683 2678
 			if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID)
@@ -2688,14 +2683,14 @@  discard block
 block discarded – undo
2688 2683
 			// Retrive all embedded attachments at once
2689 2684
 			// avoids to fetch heavy winmail.dat content
2690 2685
 			// for each file.
2691
-			$attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']);
2686
+			$attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']);
2692 2687
 		}
2693 2688
 
2694
-		foreach((array)$ids as $id)
2689
+		foreach ((array)$ids as $id)
2695 2690
 		{
2696 2691
 			$params = $getParams($id);
2697 2692
 			// when downloading a single file, name is not set
2698
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
2693
+			if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name'];
2699 2694
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2700 2695
 			{
2701 2696
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2713,25 +2708,25 @@  discard block
 block discarded – undo
2713 2708
 			}
2714 2709
 			else
2715 2710
 			{
2716
-				$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
2711
+				$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
2717 2712
 			}
2718 2713
 
2719 2714
 			$file = $params['name'];
2720 2715
 			// when $isMultipleDownload the path holds no filename
2721
-			while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2716
+			while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2722 2717
 			{
2723 2718
 				$dupe_count[$params['name']]++;
2724
-				$file = pathinfo($params['name'], PATHINFO_FILENAME) .
2725
-					' ('.($dupe_count[$params['name']] + 1).')' . '.' .
2719
+				$file = pathinfo($params['name'], PATHINFO_FILENAME).
2720
+					' ('.($dupe_count[$params['name']] + 1).')'.'.'.
2726 2721
 					pathinfo($params['name'], PATHINFO_EXTENSION);
2727 2722
 			}
2728 2723
 			$params['name'] = $file;
2729 2724
 			//error_log(__METHOD__.__LINE__.array2string($attachment));
2730 2725
 			// when $isMultipleDownload the path holds no filename
2731
-			if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
2732
-				!fwrite($fp,$attachment['attachment']))
2726
+			if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) ||
2727
+				!fwrite($fp, $attachment['attachment']))
2733 2728
 			{
2734
-				$err .= lang('Error saving %1!',$file);
2729
+				$err .= lang('Error saving %1!', $file);
2735 2730
 			}
2736 2731
 			if ($fp)
2737 2732
 			{
@@ -2744,21 +2739,21 @@  discard block
 block discarded – undo
2744 2739
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
2745 2740
 			$this->changeProfile($rememberServerID);
2746 2741
 		}
2747
-		Framework::window_close(($err?$err:null));
2742
+		Framework::window_close(($err ? $err : null));
2748 2743
 	}
2749 2744
 
2750 2745
 	/**
2751 2746
 	 * Zip all attachments and send to user
2752 2747
 	 * @param string $message_id = null
2753 2748
 	 */
2754
-	function download_zip($message_id=null)
2749
+	function download_zip($message_id = null)
2755 2750
 	{
2756 2751
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2757 2752
 		// First, get all attachment IDs
2758
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
2753
+		if (isset($_GET['id'])) $message_id = $_GET['id'];
2759 2754
 		//error_log(__METHOD__.__LINE__.$message_id);
2760 2755
 		$rememberServerID = $this->mail_bo->profileID;
2761
-		if(!is_numeric($message_id))
2756
+		if (!is_numeric($message_id))
2762 2757
 		{
2763 2758
 			$hA = self::splitRowID($message_id);
2764 2759
 			$message_id = $hA['msgUID'];
@@ -2776,30 +2771,30 @@  discard block
 block discarded – undo
2776 2771
 		}
2777 2772
 		// always fetch all, even inline (images)
2778 2773
 		$fetchEmbeddedImages = true;
2779
-		$attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox);
2774
+		$attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox);
2780 2775
 		// put them in VFS so they can be zipped
2781
-		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
2776
+		$header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox);
2782 2777
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2783 2778
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2784
-		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2785
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
2779
+		$temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id";
2780
+		if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path);
2786 2781
 
2787 2782
 		// Add subject to path, so it gets used as the file name
2788
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
2789
-		if(!Vfs::mkdir($path, 0700, true))
2783
+		$path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/';
2784
+		if (!Vfs::mkdir($path, 0700, true))
2790 2785
 		{
2791
-			Framework::message("Unable to open temp directory $path",'error');
2786
+			Framework::message("Unable to open temp directory $path", 'error');
2792 2787
 			return;
2793 2788
 		}
2794 2789
 
2795 2790
 		$file_list = array();
2796 2791
 		$dupe_count = array();
2797 2792
 		$this->mail_bo->reopen($mailbox);
2798
-		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null')
2793
+		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null')
2799 2794
 		{
2800
-			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true);
2795
+			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true);
2801 2796
 		}
2802
-		foreach($attachments as $file)
2797
+		foreach ($attachments as $file)
2803 2798
 		{
2804 2799
 			if ($file['is_winmail'])
2805 2800
 			{
@@ -2812,22 +2807,22 @@  discard block
 block discarded – undo
2812 2807
 			}
2813 2808
 			else
2814 2809
 			{
2815
-				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2810
+				$attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true);
2816 2811
 			}
2817
-			$success=true;
2812
+			$success = true;
2818 2813
 			if (empty($file['filename'])) $file['filename'] = $file['name'];
2819
-			if(in_array($path.$file['filename'], $file_list))
2814
+			if (in_array($path.$file['filename'], $file_list))
2820 2815
 			{
2821 2816
 				$dupe_count[$path.$file['filename']]++;
2822
-				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) .
2823
-					' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
2817
+				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME).
2818
+					' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'.
2824 2819
 					pathinfo($file['filename'], PATHINFO_EXTENSION);
2825 2820
 			}
2826
-			if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) ||
2821
+			if (!($fp = Vfs::fopen($path.$file['filename'], 'wb')) ||
2827 2822
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
2828 2823
 			{
2829
-				$success=false;
2830
-				Framework::message("Unable to zip {$file['filename']}",'error');
2824
+				$success = false;
2825
+				Framework::message("Unable to zip {$file['filename']}", 'error');
2831 2826
 			}
2832 2827
 			if ($success) $file_list[] = $path.$file['filename'];
2833 2828
 			if ($fp) fclose($fp);
@@ -2848,7 +2843,7 @@  discard block
 block discarded – undo
2848 2843
 		exit();
2849 2844
 	}
2850 2845
 
2851
-	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
2846
+	function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null)
2852 2847
 	{
2853 2848
 		// seems to be needed, as if we open a mail from notification popup that is
2854 2849
 		// located in a different folder, we experience: could not parse message
@@ -2861,7 +2856,7 @@  discard block
 block discarded – undo
2861 2856
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2862 2857
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2863 2858
 		$calendar_part = null;
2864
-		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox, $calendar_part);
2859
+		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox, $calendar_part);
2865 2860
 
2866 2861
 		// for meeting requests (multipart alternative with text/calendar part) let calendar render it
2867 2862
 		if ($calendar_part && isset($GLOBALS['egw_info']['user']['apps']['calendar']))
@@ -2876,26 +2871,26 @@  discard block
 block discarded – undo
2876 2871
 			$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2877 2872
 			Api\Translation::add_app('calendar');
2878 2873
 			return ExecMethod('calendar.calendar_uiforms.meeting',
2879
-				array('event'=>null,'msg'=>'','useSession'=>true)
2874
+				array('event'=>null, 'msg'=>'', 'useSession'=>true)
2880 2875
 			);
2881 2876
 		}
2882 2877
 		// Compose the content of the frame
2883 2878
 		$frameHtml =
2884 2879
 			$this->get_email_header($this->mail_bo->getStyles($bodyParts)).
2885
-			$this->showBody($this->getdisplayableBody($bodyParts,true,false), false);
2880
+			$this->showBody($this->getdisplayableBody($bodyParts, true, false), false);
2886 2881
 		//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
2887
-		$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
2882
+		$frameHtml = str_replace(" \r\n", "\r\n", $frameHtml);
2888 2883
 		$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2889 2884
 
2890 2885
 		return $frameHtml;
2891 2886
 	}
2892 2887
 
2893
-	static function get_email_header($additionalStyle='')
2888
+	static function get_email_header($additionalStyle = '')
2894 2889
 	{
2895 2890
 		// egw_info[flags][css] already include <style> tags
2896 2891
 		$GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle);
2897
-		$GLOBALS['egw_info']['flags']['nofooter']=true;
2898
-		$GLOBALS['egw_info']['flags']['nonavbar']=true;
2892
+		$GLOBALS['egw_info']['flags']['nofooter'] = true;
2893
+		$GLOBALS['egw_info']['flags']['nonavbar'] = true;
2899 2894
 		// do NOT include any default CSS
2900 2895
 		Framework::includeCSS('mail', 'preview', true, true);
2901 2896
 
@@ -2906,35 +2901,35 @@  discard block
 block discarded – undo
2906 2901
 		return $GLOBALS['egw']->framework->header();
2907 2902
 	}
2908 2903
 
2909
-	function showBody(&$body, $print=true,$fullPageTags=true)
2904
+	function showBody(&$body, $print = true, $fullPageTags = true)
2910 2905
 	{
2911 2906
 		$BeginBody = '<div class="mailDisplayBody">
2912 2907
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2913 2908
 
2914 2909
 		$EndBody = '</td></tr></table></div>';
2915 2910
 		if ($fullPageTags) $EndBody .= "</body></html>";
2916
-		if ($print)	{
2917
-			print $BeginBody. $body .$EndBody;
2911
+		if ($print) {
2912
+			print $BeginBody.$body.$EndBody;
2918 2913
 		} else {
2919
-			return $BeginBody. $body .$EndBody;
2914
+			return $BeginBody.$body.$EndBody;
2920 2915
 		}
2921 2916
 	}
2922 2917
 
2923
-	function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true)
2918
+	function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true)
2924 2919
 	{
2925
-		$bodyParts	= $_bodyParts;
2920
+		$bodyParts = $_bodyParts;
2926 2921
 
2927
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2928
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2929
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2922
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2923
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2924
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2930 2925
 
2931 2926
 		$body = '';
2932 2927
 
2933 2928
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2934 2929
 		if (empty($bodyParts)) return "";
2935
-		foreach((array)$bodyParts as $singleBodyPart) {
2930
+		foreach ((array)$bodyParts as $singleBodyPart) {
2936 2931
 			if (!isset($singleBodyPart['body'])) {
2937
-				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2932
+				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy);
2938 2933
 				$body .= $singleBodyPart['body'];
2939 2934
 				continue;
2940 2935
 			}
@@ -2944,7 +2939,7 @@  discard block
 block discarded – undo
2944 2939
 				$body .= '';
2945 2940
 				continue;
2946 2941
 			}
2947
-			if(!empty($body)) {
2942
+			if (!empty($body)) {
2948 2943
 				$body .= '<hr style="border:dotted 1px silver;">';
2949 2944
 			}
2950 2945
 			//error_log($singleBodyPart['body']);
@@ -2969,28 +2964,28 @@  discard block
 block discarded – undo
2969 2964
 				'(R)',
2970 2965
 			);
2971 2966
 
2972
-			if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2967
+			if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2973 2968
 				strtoupper($singleBodyPart['charSet']) != 'UTF-8')
2974 2969
 			{
2975
-				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
2970
+				$singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']);
2976 2971
 			}
2977 2972
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
2978
-			if ($singleBodyPart['charSet']=='us-ascii')
2973
+			if ($singleBodyPart['charSet'] == 'us-ascii')
2979 2974
 			{
2980
-				$orgCharSet=$singleBodyPart['charSet'];
2975
+				$orgCharSet = $singleBodyPart['charSet'];
2981 2976
 				$singleBodyPart['charSet'] = Api\Translation::detect_encoding($singleBodyPart['body']);
2982 2977
 				error_log(__METHOD__.__LINE__.'reports:'.$orgCharSet.' but seems to be:'.$singleBodyPart['charSet']);
2983 2978
 			}
2984
-			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
2979
+			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']);
2985 2980
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
2986
-			if($singleBodyPart['mimeType'] == 'text/plain')
2981
+			if ($singleBodyPart['mimeType'] == 'text/plain')
2987 2982
 			{
2988
-				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2983
+				$newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset));
2989 2984
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2990 2985
 				// if empty and charset is utf8 try sanitizing the string in question
2991
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
2986
+				if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset));
2992 2987
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2993
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
2988
+				if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
2994 2989
 
2995 2990
 				// search http[s] links and make them as links available again
2996 2991
 				// to understand what's going on here, have a look at
@@ -3018,20 +3013,20 @@  discard block
 block discarded – undo
3018 3013
 				// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
3019 3014
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3020 3015
 				// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
3021
-				$newBody	= "<pre>".Mail::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
3016
+				$newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '&gt;')."</pre>";
3022 3017
 			}
3023 3018
 			else
3024 3019
 			{
3025
-				$alreadyHtmlLawed=false;
3026
-				$newBody	= $singleBodyPart['body'];
3020
+				$alreadyHtmlLawed = false;
3021
+				$newBody = $singleBodyPart['body'];
3027 3022
 				//TODO:$newBody	= $this->highlightQuotes($newBody);
3028 3023
 				#error_log(print_r($newBody,true));
3029 3024
 				if ($useTidy && extension_loaded('tidy'))
3030 3025
 				{
3031 3026
 					$tidy = new tidy();
3032
-					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8');
3027
+					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8');
3033 3028
 					// Found errors. Strip it all so there's some output
3034
-					if($tidy->getStatus() == 2)
3029
+					if ($tidy->getStatus() == 2)
3035 3030
 					{
3036 3031
 						error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
3037 3032
 					}
@@ -3042,7 +3037,7 @@  discard block
 block discarded – undo
3042 3037
 					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3043 3038
 					{
3044 3039
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3045
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3040
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3046 3041
 						if ($matches[2])
3047 3042
 						{
3048 3043
 							$hasOther = true;
@@ -3053,7 +3048,7 @@  discard block
 block discarded – undo
3053 3048
 				else
3054 3049
 				{
3055 3050
 					// htmLawed filter only the 'body'
3056
-					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3051
+					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3057 3052
 					if ($matches[2])
3058 3053
 					{
3059 3054
 						$hasOther = true;
@@ -3062,10 +3057,10 @@  discard block
 block discarded – undo
3062 3057
 					$htmLawed = new Api\Html\HtmLawed();
3063 3058
 					// the next line should not be needed, but produces better results on HTML 2 Text conversion,
3064 3059
 					// as we switched off HTMLaweds tidy functionality
3065
-					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3066
-					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3067
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3068
-					$alreadyHtmlLawed=true;
3060
+					$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
3061
+					$newBody = $htmLawed->run($newBody, Mail::$htmLawed_config);
3062
+					if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
3063
+					$alreadyHtmlLawed = true;
3069 3064
 				}
3070 3065
 				// do the cleanup, set for the use of purifier
3071 3066
 				//$newBodyBuff = $newBody;
@@ -3087,8 +3082,8 @@  discard block
 block discarded – undo
3087 3082
 				}
3088 3083
 */
3089 3084
 				// removes stuff between http and ?http
3090
-				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';    // only http:// gets removed, other protocolls are shown
3091
-				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http://
3085
+				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
3086
+				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http://
3092 3087
 				// TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK
3093 3088
 				$newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
3094 3089
 					"\\1@\\2.\\3",
@@ -3101,7 +3096,7 @@  discard block
 block discarded – undo
3101 3096
 				// create links for inline images
3102 3097
 				if ($modifyURI)
3103 3098
 				{
3104
-					$newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID);
3099
+					$newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID);
3105 3100
 				}
3106 3101
 				// email addresses / mailto links get now activated on client-side
3107 3102
 			}
@@ -3113,7 +3108,7 @@  discard block
 block discarded – undo
3113 3108
 		$body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
3114 3109
 			"<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body);
3115 3110
 
3116
-		$body = preg_replace($nonDisplayAbleCharacters,'',$body);
3111
+		$body = preg_replace($nonDisplayAbleCharacters, '', $body);
3117 3112
 
3118 3113
 		return $body;
3119 3114
 	}
@@ -3128,7 +3123,7 @@  discard block
 block discarded – undo
3128 3123
 	 * @param string $_messageType = 'html', message type is either html or plain
3129 3124
 	 * @return string message body including all CID images replaced
3130 3125
 	 */
3131
-	public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html')
3126
+	public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html')
3132 3127
 	{
3133 3128
 		if ($_messageType === 'plain')
3134 3129
 		{
@@ -3136,7 +3131,7 @@  discard block
 block discarded – undo
3136 3131
 		}
3137 3132
 		else
3138 3133
 		{
3139
-			foreach(array('src','url','background') as $type)
3134
+			foreach (array('src', 'url', 'background') as $type)
3140 3135
 			{
3141 3136
 				$_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type);
3142 3137
 			}
@@ -3155,7 +3150,7 @@  discard block
 block discarded – undo
3155 3150
 	 *	- types: {plain|src|url|background}
3156 3151
 	 * @return string returns body content including all CID replacements
3157 3152
 	 */
3158
-	public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src')
3153
+	public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src')
3159 3154
 	{
3160 3155
 		/**
3161 3156
 		 * Callback for preg_replace_callback function
@@ -3167,7 +3162,7 @@  discard block
 block discarded – undo
3167 3162
 		 * @param string $_type
3168 3163
 		 * @return string|boolean returns the replace
3169 3164
 		*/
3170
-		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3165
+		$replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type)
3171 3166
 		{
3172 3167
 			if (!$_type)	return false;
3173 3168
 			$CID = '';
@@ -3189,11 +3184,11 @@  discard block
 block discarded – undo
3189 3184
 					break;
3190 3185
 			}
3191 3186
 
3192
-			static $cache = array();	// some caching, if mails containing the same image multiple times
3187
+			static $cache = array(); // some caching, if mails containing the same image multiple times
3193 3188
 
3194 3189
 			if (is_array($matches) && $CID)
3195 3190
 			{
3196
-				$linkData = array (
3191
+				$linkData = array(
3197 3192
 					'menuaction'    => 'mail.mail_ui.displayImage',
3198 3193
 					'uid'		=> $_uid,
3199 3194
 					'mailbox'	=> base64_encode($_mailbox),
@@ -3206,7 +3201,7 @@  discard block
 block discarded – undo
3206 3201
 				{
3207 3202
 					if (!isset($cache[$imageURL]))
3208 3203
 					{
3209
-						if ($_type !="background")
3204
+						if ($_type != "background")
3210 3205
 						{
3211 3206
 							$bo = Mail::getInstance(false, mail_ui::$icServerID);
3212 3207
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
@@ -3247,16 +3242,16 @@  discard block
 block discarded – undo
3247 3242
 		};
3248 3243
 
3249 3244
 		// return new body content base on chosen type
3250
-		switch($_type)
3245
+		switch ($_type)
3251 3246
 		{
3252 3247
 			case"plain":
3253
-				return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body);
3248
+				return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body);
3254 3249
 			case "src":
3255
-				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3250
+				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3256 3251
 			case "url":
3257
-				return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body);
3252
+				return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body);
3258 3253
 			case "background":
3259
-				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3254
+				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3260 3255
 		}
3261 3256
 	}
3262 3257
 
@@ -3264,7 +3259,7 @@  discard block
 block discarded – undo
3264 3259
 	 * importMessage
3265 3260
 	 * @param array $content = null an array of content
3266 3261
 	 */
3267
-	function importMessage($content=null)
3262
+	function importMessage($content = null)
3268 3263
 	{
3269 3264
 		//error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder());
3270 3265
 
@@ -3286,7 +3281,7 @@  discard block
 block discarded – undo
3286 3281
 			}
3287 3282
 			$destination = $content['FOLDER'][0];
3288 3283
 
3289
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3284
+			if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2);
3290 3285
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3291 3286
 			{
3292 3287
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3297,32 +3292,31 @@  discard block
 block discarded – undo
3297 3292
 			$importFailed = false;
3298 3293
 			try
3299 3294
 			{
3300
-				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3301
-			    $linkData = array
3302
-			    (
3295
+				$messageUid = $this->importMessageToFolder($file, $destination, $importID);
3296
+			    $linkData = array(
3303 3297
 					'id' => $this->createRowID($destination, $messageUid, true),
3304 3298
 			    );
3305 3299
 			}
3306 3300
 			catch (Api\Exception\WrongUserinput $e)
3307 3301
 			{
3308
-					$importFailed=true;
3309
-					$content['msg']		= $e->getMessage();
3302
+					$importFailed = true;
3303
+					$content['msg'] = $e->getMessage();
3310 3304
 			}
3311 3305
 			if (!$importFailed)
3312 3306
 			{
3313 3307
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3314 3308
 				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3315
-				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3309
+				ExecMethod2('mail.mail_ui.displayMessage', $linkData);
3316 3310
 				return;
3317 3311
 			}
3318 3312
 		}
3319 3313
 		if (!is_array($content)) $content = array();
3320
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3321
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3314
+		if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder();
3315
+		if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true);
3322 3316
 
3323 3317
 		$etpl = new Etemplate('mail.importMessage');
3324
-		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
3325
-		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
3318
+		$etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport');
3319
+		$etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2);
3326 3320
 	}
3327 3321
 
3328 3322
 	/**
@@ -3334,7 +3328,7 @@  discard block
 block discarded – undo
3334 3328
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3335 3329
 	 * @return mixed $messageUID or exception
3336 3330
 	 */
3337
-	function importMessageToFolder($_formData,&$_folder,$importID='')
3331
+	function importMessageToFolder($_formData, &$_folder, $importID = '')
3338 3332
 	{
3339 3333
 		$importfailed = false;
3340 3334
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -3342,7 +3336,7 @@  discard block
 block discarded – undo
3342 3336
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3343 3337
 		try
3344 3338
 		{
3345
-			$tmpFileName = Mail::checkFileBasics($_formData,$importID);
3339
+			$tmpFileName = Mail::checkFileBasics($_formData, $importID);
3346 3340
 		}
3347 3341
 		catch (Api\Exception\WrongUserinput $e)
3348 3342
 		{
@@ -3366,29 +3360,29 @@  discard block
 block discarded – undo
3366 3360
 			if (empty($_folder))
3367 3361
 			{
3368 3362
 				$importfailed = true;
3369
-				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3363
+				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']);
3370 3364
 			}
3371 3365
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3372
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3366
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
3373 3367
 			if ($importfailed === false)
3374 3368
 			{
3375
-				if ($this->mail_bo->folderExists($_folder,true)) {
3369
+				if ($this->mail_bo->folderExists($_folder, true)) {
3376 3370
 					try
3377 3371
 					{
3378 3372
 						$messageUid = $this->mail_bo->appendMessage($_folder,
3379 3373
 							$mailObject->getRaw(),
3380
-							null,'\\Seen');
3374
+							null, '\\Seen');
3381 3375
 					}
3382 3376
 					catch (Api\Exception\WrongUserinput $e)
3383 3377
 					{
3384 3378
 						$importfailed = true;
3385
-						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
3379
+						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage());
3386 3380
 					}
3387 3381
 				}
3388 3382
 				else
3389 3383
 				{
3390 3384
 					$importfailed = true;
3391
-					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder);
3385
+					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder);
3392 3386
 				}
3393 3387
 			}
3394 3388
 		}
@@ -3414,9 +3408,9 @@  discard block
 block discarded – undo
3414 3408
 	 *								 $formData['size']	= 2136;
3415 3409
 	 * @return void
3416 3410
 	 */
3417
-	function importMessageFromVFS2DraftAndEdit($formData='')
3411
+	function importMessageFromVFS2DraftAndEdit($formData = '')
3418 3412
 	{
3419
-		$this->importMessageFromVFS2DraftAndDisplay($formData,'edit');
3413
+		$this->importMessageFromVFS2DraftAndDisplay($formData, 'edit');
3420 3414
 	}
3421 3415
 
3422 3416
 	/**
@@ -3431,7 +3425,7 @@  discard block
 block discarded – undo
3431 3425
 	 * @param string $mode mode to open ImportedMessage display and edit are supported
3432 3426
 	 * @return void
3433 3427
 	 */
3434
-	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3428
+	function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display')
3435 3429
 	{
3436 3430
 		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3437 3431
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
@@ -3444,43 +3438,42 @@  discard block
 block discarded – undo
3444 3438
 			$formData['file'] = 'egw-data://'.$formData['data'];
3445 3439
 		}
3446 3440
 		// name should be set to meet the requirements of checkFileBasics
3447
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3441
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3448 3442
 		{
3449
-			$buff = explode('/',$formData['file']);
3443
+			$buff = explode('/', $formData['file']);
3450 3444
 			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3451 3445
 		}
3452 3446
 		// type should be set to meet the requirements of checkFileBasics
3453
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3447
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3454 3448
 		{
3455
-			$buff = explode('.',$formData['file']);
3449
+			$buff = explode('.', $formData['file']);
3456 3450
 			$suffix = '';
3457 3451
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3458 3452
 			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3459 3453
 		}
3460 3454
 		// size should be set to meet the requirements of checkFileBasics
3461
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3455
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3462 3456
 		{
3463 3457
 			$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
3464 3458
 		}
3465 3459
 		try
3466 3460
 		{
3467
-			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3468
-			$linkData = array
3469
-			(
3470
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3471
-				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3461
+			$messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID);
3462
+			$linkData = array(
3463
+		        'menuaction'    => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'),
3464
+				'id'		=> $this->createRowID($draftFolder, $messageUid, true),
3472 3465
 				'deleteDraftOnClose' => 1,
3473 3466
 			);
3474
-			if ($mode!='display')
3467
+			if ($mode != 'display')
3475 3468
 			{
3476 3469
 				unset($linkData['deleteDraftOnClose']);
3477
-				$linkData['method']	='importMessageToMergeAndSend';
3470
+				$linkData['method'] = 'importMessageToMergeAndSend';
3478 3471
 			}
3479 3472
 			else
3480 3473
 			{
3481
-				$linkData['mode']=$mode;
3474
+				$linkData['mode'] = $mode;
3482 3475
 			}
3483
-			Egw::redirect_link('/index.php',$linkData);
3476
+			Egw::redirect_link('/index.php', $linkData);
3484 3477
 		}
3485 3478
 		catch (Api\Exception\WrongUserinput $e)
3486 3479
 		{
@@ -3495,13 +3488,13 @@  discard block
 block discarded – undo
3495 3488
 	 *
3496 3489
 	 * @return xajax response
3497 3490
 	 */
3498
-	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3491
+	function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null)
3499 3492
 	{
3500 3493
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3501 3494
 		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3502 3495
 		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3503 3496
 		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3504
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3497
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions");
3505 3498
 		if (empty($_messageID)) return "";
3506 3499
 		$uidA = self::splitRowID($_messageID);
3507 3500
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -3515,7 +3508,7 @@  discard block
 block discarded – undo
3515 3508
 			$this->changeProfile($icServerID);
3516 3509
 		}
3517 3510
 
3518
-		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions);
3511
+		$bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions);
3519 3512
 		Api\Session::cache_control(true);
3520 3513
 		//error_log(array2string($bodyResponse));
3521 3514
 		echo $bodyResponse;
@@ -3538,7 +3531,7 @@  discard block
 block discarded – undo
3538 3531
 			$oA = array();
3539 3532
 			foreach ($_folder as $_folderName)
3540 3533
 			{
3541
-				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3534
+				list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2);
3542 3535
 				if (is_numeric($profileID))
3543 3536
 				{
3544 3537
 					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
@@ -3546,19 +3539,19 @@  discard block
 block discarded – undo
3546 3539
 					{
3547 3540
 						try
3548 3541
 						{
3549
-							$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3542
+							$fS = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3550 3543
 						}
3551 3544
 						catch (Exception $e)
3552 3545
 						{
3553 3546
 							continue;
3554 3547
 						}
3555
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3548
+						if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']);
3556 3549
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3557 3550
 						if ($fS['unseen'])
3558 3551
 						{
3559 3552
 							$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
3560 3553
 						}
3561
-						if ($fS['unseen']==0 && $fS['shortDisplayName'])
3554
+						if ($fS['unseen'] == 0 && $fS['shortDisplayName'])
3562 3555
 						{
3563 3556
 							$oA[$_folderName] = $fS['shortDisplayName'];
3564 3557
 						}
@@ -3569,7 +3562,7 @@  discard block
 block discarded – undo
3569 3562
 			if ($oA)
3570 3563
 			{
3571 3564
 				$response = Api\Json\Response::get();
3572
-				$response->call('app.mail.mail_setFolderStatus',$oA);
3565
+				$response->call('app.mail.mail_setFolderStatus', $oA);
3573 3566
 			}
3574 3567
 		}
3575 3568
 	}
@@ -3583,14 +3576,14 @@  discard block
 block discarded – undo
3583 3576
 	function ajax_addFolder($_parentFolderName, $_newName)
3584 3577
 	{
3585 3578
 		//error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName));
3586
-		$errorMessage='';
3579
+		$errorMessage = '';
3587 3580
 		if ($_parentFolderName)
3588 3581
 		{
3589 3582
 			$created = false;
3590 3583
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName);
3591 3584
 			//the conversion is handeled by horde, frontend interaction is all utf-8
3592 3585
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3593
-			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3586
+			list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2);
3594 3587
 			if (is_numeric($profileID))
3595 3588
 			{
3596 3589
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
@@ -3630,10 +3623,10 @@  discard block
 block discarded – undo
3630 3623
 
3631 3624
 				if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false);
3632 3625
 				*/
3633
-				$nA = explode($del,$_newName);
3626
+				$nA = explode($del, $_newName);
3634 3627
 
3635 3628
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3636
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3629
+				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false);
3637 3630
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3638 3631
 
3639 3632
 				$this->mail_bo->reopen('INBOX');
@@ -3641,11 +3634,11 @@  discard block
 block discarded – undo
3641 3634
 				// if newName has delimiter ($del) in it, we need to create the subtree
3642 3635
 				if (!empty($nA))
3643 3636
 				{
3644
-					$c=0;
3645
-					foreach($nA as $sTName)
3637
+					$c = 0;
3638
+					foreach ($nA as $sTName)
3646 3639
 					{
3647
-						$error=null;
3648
-						if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3640
+						$error = null;
3641
+						if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3649 3642
 						{
3650 3643
 							$c++;
3651 3644
 						}
@@ -3654,16 +3647,16 @@  discard block
 block discarded – undo
3654 3647
 							$errorMessage .= $error;
3655 3648
 						}
3656 3649
 					}
3657
-					if ($c==count($nA)) $created=true;
3650
+					if ($c == count($nA)) $created = true;
3658 3651
 				}
3659 3652
 				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3660 3653
 			}
3661 3654
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3662
-			if ($created===true)
3655
+			if ($created === true)
3663 3656
 			{
3664 3657
 				$this->mail_bo->resetFolderObjectCache($profileID);
3665 3658
 				$response = Api\Json\Response::get();
3666
-				if ( $oldFolderInfo['shortDisplayName'])
3659
+				if ($oldFolderInfo['shortDisplayName'])
3667 3660
 				{
3668 3661
 					$nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']);
3669 3662
 				}
@@ -3671,14 +3664,14 @@  discard block
 block discarded – undo
3671 3664
 				{
3672 3665
 					$nodeInfo = array($profileID=>lang('INBOX'));
3673 3666
 				}
3674
-				$response->call('app.mail.mail_reloadNode',$nodeInfo);
3667
+				$response->call('app.mail.mail_reloadNode', $nodeInfo);
3675 3668
 			}
3676 3669
 			else
3677 3670
 			{
3678 3671
 				if ($errorMessage)
3679 3672
 				{
3680 3673
 					$response = Api\Json\Response::get();
3681
-					$response->call('egw.message',$errorMessage);
3674
+					$response->call('egw.message', $errorMessage);
3682 3675
 				}
3683 3676
 			}
3684 3677
 		}
@@ -3700,22 +3693,22 @@  discard block
 block discarded – undo
3700 3693
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3701 3694
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3702 3695
 			$oA = array();
3703
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3696
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3704 3697
 			$hasChildren = false;
3705 3698
 			if (is_numeric($profileID))
3706 3699
 			{
3707 3700
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
3708
-				$pA = explode($del,$folderName);
3701
+				$pA = explode($del, $folderName);
3709 3702
 				array_pop($pA);
3710
-				$parentFolder = implode($del,$pA);
3711
-				if (strtoupper($folderName)!= 'INBOX')
3703
+				$parentFolder = implode($del, $pA);
3704
+				if (strtoupper($folderName) != 'INBOX')
3712 3705
 				{
3713 3706
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3714
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false);
3707
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false);
3715 3708
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3716
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3709
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3717 3710
 					{
3718
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3711
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3719 3712
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3720 3713
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3721 3714
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3732,7 +3725,7 @@  discard block
 block discarded – undo
3732 3725
 							else
3733 3726
 							{
3734 3727
 								$rv = $this->mail_bo->icServer->subscribeMailbox($folder, false);
3735
-								$fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName));
3728
+								$fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName));
3736 3729
 							}
3737 3730
 						}
3738 3731
 						//error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments));
@@ -3742,7 +3735,7 @@  discard block
 block discarded – undo
3742 3735
 					$success = false;
3743 3736
 					try
3744 3737
 					{
3745
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3738
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3746 3739
 						{
3747 3740
 							$this->mail_bo->resetFolderObjectCache($profileID);
3748 3741
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3753,11 +3746,11 @@  discard block
 block discarded – undo
3753 3746
 					}
3754 3747
 					catch (Exception $e)
3755 3748
 					{
3756
-						$newFolderName=$folderName;
3749
+						$newFolderName = $folderName;
3757 3750
 						$msg = $e->getMessage();
3758 3751
 					}
3759 3752
 					$this->mail_bo->reopen($newFolderName);
3760
-					$fS = $this->mail_bo->getFolderStatus($newFolderName,false);
3753
+					$fS = $this->mail_bo->getFolderStatus($newFolderName, false);
3761 3754
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3762 3755
 					if ($hasChildren)
3763 3756
 					{
@@ -3788,12 +3781,12 @@  discard block
 block discarded – undo
3788 3781
 					{
3789 3782
 						$oA[$_folderName]['desc'] = $fS['shortDisplayName'];
3790 3783
 					}
3791
-					foreach($fragments as $oldFolderName => $fragment)
3784
+					foreach ($fragments as $oldFolderName => $fragment)
3792 3785
 					{
3793 3786
 						//error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment);
3794 3787
 						$oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment;
3795 3788
 						$oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#';
3796
-						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
3789
+						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false);
3797 3790
 						if ($fS['unseen'])
3798 3791
 						{
3799 3792
 							$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
@@ -3806,20 +3799,20 @@  discard block
 block discarded – undo
3806 3799
 					}
3807 3800
 				}
3808 3801
 			}
3809
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
3802
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
3810 3803
 			{
3811
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
3804
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
3812 3805
 				$this->mail_bo->saveSessionData();
3813 3806
 			}
3814 3807
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3815 3808
 			$response = Api\Json\Response::get();
3816 3809
 			if ($oA && $success)
3817 3810
 			{
3818
-				$response->call('app.mail.mail_setLeaf',$oA);
3811
+				$response->call('app.mail.mail_setLeaf', $oA);
3819 3812
 			}
3820 3813
 			else
3821 3814
 			{
3822
-				$response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail');
3815
+				$response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail');
3823 3816
 			}
3824 3817
 		}
3825 3818
 	}
@@ -3831,7 +3824,7 @@  discard block
 block discarded – undo
3831 3824
 	 * @param boolean $_subscribedOnly = true
3832 3825
 	 * @return void
3833 3826
 	 */
3834
-	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
3827
+	function ajax_reloadNode($_folderName, $_subscribedOnly = true)
3835 3828
 	{
3836 3829
 		Api\Translation::add_app('mail');
3837 3830
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
@@ -3842,20 +3835,20 @@  discard block
 block discarded – undo
3842 3835
 
3843 3836
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3844 3837
 		$this->mail_bo->getHierarchyDelimiter(false);
3845
-		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3838
+		list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3846 3839
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3847 3840
 		// that we get what we request
3848 3841
 		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3849 3842
 		if ($profileID != $this->mail_bo->profileID) return; // only current connection
3850 3843
 		if (!empty($folderName))
3851 3844
 		{
3852
-			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
3853
-			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3845
+			$parentFolder = (!empty($folderName) ? $folderName : 'INBOX');
3846
+			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3854 3847
 			if ($folderInfo['unseen'])
3855 3848
 			{
3856 3849
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')';
3857 3850
 			}
3858
-			if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName'])
3851
+			if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName'])
3859 3852
 			{
3860 3853
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'];
3861 3854
 			}
@@ -3871,11 +3864,11 @@  discard block
 block discarded – undo
3871 3864
 		}
3872 3865
 		// Send full info back in the response
3873 3866
 		$response = Api\Json\Response::get();
3874
-		foreach($refreshData as $folder => &$name)
3867
+		foreach ($refreshData as $folder => &$name)
3875 3868
 		{
3876
-			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
3869
+			$name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true);
3877 3870
 		}
3878
-		$response->call('app.mail.mail_reloadNode',$refreshData);
3871
+		$response->call('app.mail.mail_reloadNode', $refreshData);
3879 3872
 
3880 3873
 	}
3881 3874
 
@@ -3891,7 +3884,7 @@  discard block
 block discarded – undo
3891 3884
 	 * @param type $_rowid row id from nm
3892 3885
 	 *
3893 3886
 	 */
3894
-	function ajax_resolveWinmail ($_rowid)
3887
+	function ajax_resolveWinmail($_rowid)
3895 3888
 	{
3896 3889
 		$response = Api\Json\Response::get();
3897 3890
 
@@ -3899,7 +3892,7 @@  discard block
 block discarded – undo
3899 3892
 		$uid = $idParts['msgUID'];
3900 3893
 		$mbox = $idParts['folder'];
3901 3894
 
3902
-		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
3895
+		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox);
3903 3896
 		if (is_array($attachments))
3904 3897
 		{
3905 3898
 			$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
@@ -3927,30 +3920,30 @@  discard block
 block discarded – undo
3927 3920
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3928 3921
 			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
3929 3922
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3930
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3931
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
3923
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3924
+			list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2);
3932 3925
 			$hasChildren = false;
3933 3926
 			if (is_numeric($profileID))
3934 3927
 			{
3935 3928
 				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
3936
-				$pA = explode($del,$folderName);
3929
+				$pA = explode($del, $folderName);
3937 3930
 				$namePart = array_pop($pA);
3938 3931
 				$_newName = $namePart;
3939
-				$oldParentFolder = implode($del,$pA);
3932
+				$oldParentFolder = implode($del, $pA);
3940 3933
 				$parentFolder = $_newLocation;
3941 3934
 
3942
-				if (strtoupper($folderName)!= 'INBOX' &&
3935
+				if (strtoupper($folderName) != 'INBOX' &&
3943 3936
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3944 3937
 					(($oldParentFolder != $parentFolder &&
3945
-					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3946
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
3938
+					strlen($parentFolder) > 0 && strlen($folderName) > 0 &&
3939
+					strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch
3947 3940
 				{
3948 3941
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3949
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3942
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3950 3943
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3951
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3944
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3952 3945
 					{
3953
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3946
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3954 3947
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3955 3948
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3956 3949
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3975,7 +3968,7 @@  discard block
 block discarded – undo
3975 3968
 					$success = false;
3976 3969
 					try
3977 3970
 					{
3978
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3971
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3979 3972
 						{
3980 3973
 							$this->mail_bo->resetFolderObjectCache($profileID);
3981 3974
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3987,11 +3980,11 @@  discard block
 block discarded – undo
3987 3980
 					}
3988 3981
 					catch (Exception $e)
3989 3982
 					{
3990
-						$newFolderName=$folderName;
3983
+						$newFolderName = $folderName;
3991 3984
 						$msg = $e->getMessage();
3992 3985
 					}
3993 3986
 					$this->mail_bo->reopen($parentFolder);
3994
-					$this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3987
+					$this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3995 3988
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3996 3989
 					if ($hasChildren)
3997 3990
 					{
@@ -4012,9 +4005,9 @@  discard block
 block discarded – undo
4012 4005
 					}
4013 4006
 				}
4014 4007
 			}
4015
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
4008
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
4016 4009
 			{
4017
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
4010
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
4018 4011
 				$this->mail_bo->saveSessionData();
4019 4012
 			}
4020 4013
 			//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -4023,26 +4016,26 @@  discard block
 block discarded – undo
4023 4016
 			{
4024 4017
 				Api\Translation::add_app('mail');
4025 4018
 
4026
-				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
4027
-				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4019
+				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false);
4020
+				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4028 4021
 				$refreshData = array(
4029 4022
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4030 4023
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4031 4024
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4032
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4033
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4025
+				if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4026
+				if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4034 4027
 
4035 4028
 				// Send full info back in the response
4036
-				foreach($refreshData as $folder => &$name)
4029
+				foreach ($refreshData as $folder => &$name)
4037 4030
 				{
4038
-					$name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true);
4031
+					$name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true);
4039 4032
 				}
4040
-				$response->call('app.mail.mail_reloadNode',$refreshData);
4033
+				$response->call('app.mail.mail_reloadNode', $refreshData);
4041 4034
 
4042 4035
 			}
4043 4036
 			else
4044 4037
 			{
4045
-				$response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail');
4038
+				$response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail');
4046 4039
 			}
4047 4040
 		}
4048 4041
 	}
@@ -4062,23 +4055,23 @@  discard block
 block discarded – undo
4062 4055
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4063 4056
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4064 4057
 			$oA = array();
4065
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4058
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4066 4059
 			$hasChildren = false;
4067 4060
 			if (is_numeric($profileID))
4068 4061
 			{
4069 4062
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4070
-				$pA = explode($del,$folderName);
4063
+				$pA = explode($del, $folderName);
4071 4064
 				array_pop($pA);
4072
-				if (strtoupper($folderName)!= 'INBOX')
4065
+				if (strtoupper($folderName) != 'INBOX')
4073 4066
 				{
4074 4067
 					//error_log(__METHOD__.__LINE__."$folderName,  implode($del,$pA), $_newName");
4075 4068
 					$oA = array();
4076 4069
 					$subFolders = array();
4077
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4070
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4078 4071
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4079
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4072
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4080 4073
 					{
4081
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4074
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4082 4075
 						$ftD = array();
4083 4076
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4084 4077
 						$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -4088,24 +4081,24 @@  discard block
 block discarded – undo
4088 4081
 						//error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix");
4089 4082
 						foreach ($subFolders as $k => $f)
4090 4083
 						{
4091
-							$ftD[substr_count($f,$delimiter)][]=$f;
4084
+							$ftD[substr_count($f, $delimiter)][] = $f;
4092 4085
 						}
4093
-						krsort($ftD,SORT_NUMERIC);//sort per level
4086
+						krsort($ftD, SORT_NUMERIC); //sort per level
4094 4087
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4095
-						foreach($ftD as $k => $lc)//collection per level
4088
+						foreach ($ftD as $k => $lc)//collection per level
4096 4089
 						{
4097
-							foreach($lc as $f)//folders contained in that level
4090
+							foreach ($lc as $f)//folders contained in that level
4098 4091
 							{
4099 4092
 								try
4100 4093
 								{
4101 4094
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4102 4095
 									$this->mail_bo->deleteFolder($f);
4103 4096
 									$success = true;
4104
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4097
+									if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4105 4098
 								}
4106 4099
 								catch (Exception $e)
4107 4100
 								{
4108
-									$msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage();
4101
+									$msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage();
4109 4102
 									$success = false;
4110 4103
 								}
4111 4104
 							}
@@ -4136,11 +4129,11 @@  discard block
 block discarded – undo
4136 4129
 			if ($success)
4137 4130
 			{
4138 4131
 				//error_log(__METHOD__.__LINE__.array2string($oA));
4139
-				$response->call('app.mail.mail_removeLeaf',$oA);
4132
+				$response->call('app.mail.mail_removeLeaf', $oA);
4140 4133
 			}
4141 4134
 			else
4142 4135
 			{
4143
-				$response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail');
4136
+				$response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail');
4144 4137
 			}
4145 4138
 		}
4146 4139
 	}
@@ -4154,7 +4147,7 @@  discard block
 block discarded – undo
4154 4147
 	 * @param bool $getFolders The client needs the folders for the profile
4155 4148
 	 * @return nothing
4156 4149
 	 */
4157
-	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
4150
+	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null)
4158 4151
 	{
4159 4152
 		$response = Api\Json\Response::get();
4160 4153
 
@@ -4162,7 +4155,7 @@  discard block
 block discarded – undo
4162 4155
 
4163 4156
 		if ($icServerID && $icServerID != $previous_id)
4164 4157
 		{
4165
-			$mail_ui = new mail_ui(false);	// do NOT run constructor, as we call changeProfile anyway
4158
+			$mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway
4166 4159
 			try
4167 4160
 			{
4168 4161
 				$mail_ui->changeProfile($icServerID);
@@ -4178,23 +4171,23 @@  discard block
 block discarded – undo
4178 4171
 				}
4179 4172
 			}
4180 4173
 			catch (Exception $e) {
4181
-				self::callWizard($e->getMessage(),true, 'error');
4174
+				self::callWizard($e->getMessage(), true, 'error');
4182 4175
 			}
4183 4176
 		}
4184 4177
 		else
4185 4178
 		{
4186
-			$mail_ui = new mail_ui(true);	// run constructor
4179
+			$mail_ui = new mail_ui(true); // run constructor
4187 4180
 		}
4188 4181
 
4189 4182
 		// Send full info back in the response
4190
-		if($getFolders)
4183
+		if ($getFolders)
4191 4184
 		{
4192 4185
 			Api\Translation::add_app('mail');
4193 4186
 
4194 4187
 			$refreshData = array(
4195
-				$icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4188
+				$icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4196 4189
 			);
4197
-			$response->call('app.mail.mail_reloadNode',$refreshData);
4190
+			$response->call('app.mail.mail_reloadNode', $refreshData);
4198 4191
 		}
4199 4192
 	}
4200 4193
 
@@ -4205,7 +4198,7 @@  discard block
 block discarded – undo
4205 4198
 	 *						if other than active profile; nothing is done!
4206 4199
 	 * @return nothing
4207 4200
 	 */
4208
-	public static function ajax_refreshVacationNotice($icServerID=null)
4201
+	public static function ajax_refreshVacationNotice($icServerID = null)
4209 4202
 	{
4210 4203
 		//Get vacation from cache if it's available
4211 4204
 		$cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
@@ -4223,28 +4216,28 @@  discard block
 block discarded – undo
4223 4216
 
4224 4217
 				$vacation = $mail->gatherVacation($cachedVacations);
4225 4218
 			} catch (Exception $e) {
4226
-				$vacation=false;
4219
+				$vacation = false;
4227 4220
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4228 4221
 				unset($e);
4229 4222
 			}
4230 4223
 		}
4231 4224
 
4232
-		if($vacation) {
4233
-			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4225
+		if ($vacation) {
4226
+			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date'))
4234 4227
 			{
4235 4228
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4236 4229
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4237
-				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4238
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4230
+				$refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
4231
+				if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = '';
4239 4232
 			}
4240 4233
 		}
4241
-		if ($vacation==false)
4234
+		if ($vacation == false)
4242 4235
 		{
4243
-			$refreshData['vacationnotice'] =  '';
4244
-			$refreshData['vacationrange'] =  '';
4236
+			$refreshData['vacationnotice'] = '';
4237
+			$refreshData['vacationrange'] = '';
4245 4238
 		}
4246 4239
 		$response = Api\Json\Response::get();
4247
-		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
4240
+		$response->call('app.mail.mail_refreshVacationNotice', $refreshData);
4248 4241
 	}
4249 4242
 
4250 4243
 	/**
@@ -4254,43 +4247,43 @@  discard block
 block discarded – undo
4254 4247
 	 *						if other than active profile; nothing is done!
4255 4248
 	 * @return nothing
4256 4249
 	 */
4257
-	function ajax_refreshFilters($icServerID=null)
4250
+	function ajax_refreshFilters($icServerID = null)
4258 4251
 	{
4259 4252
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4260 4253
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4261 4254
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4262 4255
 		{
4263
-			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4264
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4256
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4257
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4265 4258
 		}
4266 4259
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4267 4260
 		{
4268 4261
 			unset($this->searchTypes['quick']);
4269 4262
 			unset($this->searchTypes['quickwithcc']);
4270 4263
 		}
4271
-		if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4264
+		if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4272 4265
 		{
4273
-			$this->statusTypes = array_merge($this->statusTypes,array(
4274
-				'keyword1'	=> 'important',//lang('important'),
4275
-				'keyword2'	=> 'job',	//lang('job'),
4276
-				'keyword3'	=> 'personal',//lang('personal'),
4277
-				'keyword4'	=> 'to do',	//lang('to do'),
4278
-				'keyword5'	=> 'later',	//lang('later'),
4266
+			$this->statusTypes = array_merge($this->statusTypes, array(
4267
+				'keyword1'	=> 'important', //lang('important'),
4268
+				'keyword2'	=> 'job', //lang('job'),
4269
+				'keyword3'	=> 'personal', //lang('personal'),
4270
+				'keyword4'	=> 'to do', //lang('to do'),
4271
+				'keyword5'	=> 'later', //lang('later'),
4279 4272
 			));
4280 4273
 		}
4281 4274
 		else
4282 4275
 		{
4283
-			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4284
-			foreach($keywords as &$k)
4276
+			$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
4277
+			foreach ($keywords as &$k)
4285 4278
 			{
4286
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4279
+				if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
4287 4280
 			}
4288 4281
 		}
4289 4282
 
4290 4283
 		$response = Api\Json\Response::get();
4291
-		$response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes);
4292
-		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
4293
-		$response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')));
4284
+		$response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes);
4285
+		$response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes);
4286
+		$response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')));
4294 4287
 
4295 4288
 	}
4296 4289
 
@@ -4299,7 +4292,7 @@  discard block
 block discarded – undo
4299 4292
 	 *
4300 4293
 	 * @return nothing
4301 4294
 	 */
4302
-	function ajax_refreshQuotaDisplay($icServerID=null)
4295
+	function ajax_refreshQuotaDisplay($icServerID = null)
4303 4296
 	{
4304 4297
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4305 4298
 		Api\Translation::add_app('mail');
@@ -4319,10 +4312,10 @@  discard block
 block discarded – undo
4319 4312
 			unset($e);
4320 4313
 		}
4321 4314
 
4322
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4315
+		if ($quota !== false && $quota['limit'] != 'NOT SET') {
4323 4316
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4324 4317
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4325
-			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4318
+			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
4326 4319
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4327 4320
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4328 4321
 		} else {
@@ -4342,7 +4335,7 @@  discard block
 block discarded – undo
4342 4335
 			}
4343 4336
 		}
4344 4337
 		$response = Api\Json\Response::get();
4345
-		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
4338
+		$response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content));
4346 4339
 	}
4347 4340
 
4348 4341
 	/**
@@ -4364,34 +4357,34 @@  discard block
 block discarded – undo
4364 4357
 			$this->changeProfile($icServerID);
4365 4358
 		}
4366 4359
 		$junkFolder = $this->mail_bo->getJunkFolder();
4367
-		if(!empty($junkFolder)) {
4360
+		if (!empty($junkFolder)) {
4368 4361
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4369 4362
 			{
4370 4363
 				// Lock the tree if the active folder is junk folder
4371 4364
 				$response->call('app.mail.lock_tree');
4372 4365
 			}
4373
-			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4366
+			$this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately');
4374 4367
 
4375 4368
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4376
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4369
+			$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
4377 4370
 			$fStatus = array(
4378 4371
 				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4379 4372
 			);
4380 4373
 			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4381 4374
 			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4382
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4375
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4383 4376
 		}
4384 4377
 		if ($rememberServerID != $this->mail_bo->profileID)
4385 4378
 		{
4386
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4387
-			$response->call('egw.message',lang('empty junk'));
4388
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4379
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false);
4380
+			$response->call('egw.message', lang('empty junk'));
4381
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4389 4382
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4390 4383
 			$this->changeProfile($rememberServerID);
4391 4384
 		}
4392 4385
 		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4393 4386
 		{
4394
-			$response->call('egw.refresh',lang('empty junk'),'mail');
4387
+			$response->call('egw.refresh', lang('empty junk'), 'mail');
4395 4388
 		}
4396 4389
 	}
4397 4390
 
@@ -4414,7 +4407,7 @@  discard block
 block discarded – undo
4414 4407
 			$this->changeProfile($icServerID);
4415 4408
 		}
4416 4409
 		$trashFolder = $this->mail_bo->getTrashFolder();
4417
-		if(!empty($trashFolder)) {
4410
+		if (!empty($trashFolder)) {
4418 4411
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4419 4412
 			{
4420 4413
 				// Lock the tree if the active folder is Trash folder
@@ -4423,25 +4416,25 @@  discard block
 block discarded – undo
4423 4416
 			$this->mail_bo->compressFolder($trashFolder);
4424 4417
 
4425 4418
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4426
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4419
+			$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
4427 4420
 			$fStatus = array(
4428 4421
 				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4429 4422
 			);
4430 4423
 			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4431 4424
 			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4432
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4425
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4433 4426
 		}
4434 4427
 		if ($rememberServerID != $this->mail_bo->profileID)
4435 4428
 		{
4436
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4437
-			$response->call('egw.message',lang('empty trash'));
4438
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4429
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false);
4430
+			$response->call('egw.message', lang('empty trash'));
4431
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4439 4432
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4440 4433
 			$this->changeProfile($rememberServerID);
4441 4434
 		}
4442 4435
 		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4443 4436
 		{
4444
-			$response->call('egw.refresh',lang('empty trash'),'mail');
4437
+			$response->call('egw.refresh', lang('empty trash'), 'mail');
4445 4438
 		}
4446 4439
 	}
4447 4440
 
@@ -4458,7 +4451,7 @@  discard block
 block discarded – undo
4458 4451
 
4459 4452
 		$this->mail_bo->restoreSessionData();
4460 4453
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4461
-		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4454
+		list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4462 4455
 
4463 4456
 		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4464 4457
 		if ($this->mail_bo->folderExists($folderName))
@@ -4469,7 +4462,7 @@  discard block
 block discarded – undo
4469 4462
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4470 4463
 				$this->changeProfile($icServerID);
4471 4464
 			}
4472
-			if(!empty($_folderName)) {
4465
+			if (!empty($_folderName)) {
4473 4466
 				$this->mail_bo->compressFolder($folderName);
4474 4467
 			}
4475 4468
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4478,7 +4471,7 @@  discard block
 block discarded – undo
4478 4471
 				$this->changeProfile($rememberServerID);
4479 4472
 			}
4480 4473
 			$response = Api\Json\Response::get();
4481
-			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
4474
+			$response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail');
4482 4475
 		}
4483 4476
 	}
4484 4477
 
@@ -4491,10 +4484,10 @@  discard block
 block discarded – undo
4491 4484
 	 */
4492 4485
 	function ajax_sendMDN($_messageList)
4493 4486
 	{
4494
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4487
+		if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4495 4488
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4496 4489
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4497
-		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
4490
+		$this->mail_bo->sendMDN($uidA['msgUID'], $folder);
4498 4491
 	}
4499 4492
 
4500 4493
 	/**
@@ -4506,14 +4499,14 @@  discard block
 block discarded – undo
4506 4499
 	 *
4507 4500
 	 * @return xajax response
4508 4501
 	 */
4509
-	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4502
+	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true)
4510 4503
 	{
4511
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4504
+		if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4512 4505
 		Api\Translation::add_app('mail');
4513
-		$alreadyFlagged=false;
4514
-		$flag2check='';
4506
+		$alreadyFlagged = false;
4507
+		$flag2check = '';
4515 4508
 		$filter2toggle = $query = array();
4516
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4509
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4517 4510
 		{
4518 4511
 			if (isset($_messageList['all']) && $_messageList['all'])
4519 4512
 			{
@@ -4523,34 +4516,34 @@  discard block
 block discarded – undo
4523 4516
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4524 4517
 				{
4525 4518
 					$query = $_messageList['activeFilters'];
4526
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4519
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4527 4520
 					{
4528 4521
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4529 4522
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4530 4523
 						{
4531
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4532
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4524
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4525
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4533 4526
 						}
4534 4527
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4535 4528
 						$cutoffdate = $cutoffdate2 = null;
4536
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4537
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4529
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4530
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4538 4531
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4539 4532
 						$filter = array(
4540
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4541
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4533
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4534
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4542 4535
 							'string' => $query['search'],
4543
-							'status' => 'any',//this is a status change. status will be manipulated later on
4536
+							'status' => 'any', //this is a status change. status will be manipulated later on
4544 4537
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4545 4538
 						);
4546
-						if ($query['enddate']||$query['startdate']) {
4539
+						if ($query['enddate'] || $query['startdate']) {
4547 4540
 							$filter['range'] = "BETWEEN";
4548 4541
 							if ($cutoffdate) {
4549
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4542
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4550 4543
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4551 4544
 							}
4552 4545
 							if ($cutoffdate2) {
4553
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4546
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4554 4547
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4555 4548
 							}
4556 4549
 						}
@@ -4563,12 +4556,12 @@  discard block
 block discarded – undo
4563 4556
 					// flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder
4564 4557
 					// should be affected serverside. here.
4565 4558
 					$messageList = $messageListForToggle = array();
4566
-					$flag2check = ($_flag=='read'?'seen':$_flag);
4567
-					if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4568
-						!($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))
4559
+					$flag2check = ($_flag == 'read' ? 'seen' : $_flag);
4560
+					if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4561
+						!($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))
4569 4562
 					{
4570 4563
 						$filter2toggle['status'] = array('un'.$_flag);
4571
-						if ($query['filter'] && $query['filter']!='any')
4564
+						if ($query['filter'] && $query['filter'] != 'any')
4572 4565
 						{
4573 4566
 							$filter2toggle['status'][] = $query['filter'];
4574 4567
 						}
@@ -4576,7 +4569,7 @@  discard block
 block discarded – undo
4576 4569
 						$reverse = 1;
4577 4570
 						$_sRt = $this->mail_bo->getSortedList(
4578 4571
 							$folder,
4579
-							$sort=0,
4572
+							$sort = 0,
4580 4573
 							$reverse,
4581 4574
 							$filter2toggle,
4582 4575
 							$rByUid,
@@ -4584,52 +4577,52 @@  discard block
 block discarded – undo
4584 4577
 						);
4585 4578
 						$messageListForToggle = $_sRt['match']->ids;
4586 4579
 						$filter['status'] = array($_flag);
4587
-						if ($query['filter'] && $query['filter'] !='any')
4580
+						if ($query['filter'] && $query['filter'] != 'any')
4588 4581
 						{
4589 4582
 							$filter['status'][] = $query['filter'];
4590 4583
 						}
4591
-						$rByUid=true;
4584
+						$rByUid = true;
4592 4585
 						$reverse = 1;
4593 4586
 						$_sR = $this->mail_bo->getSortedList(
4594 4587
 							$folder,
4595
-							$sort=0,
4588
+							$sort = 0,
4596 4589
 							$reverse,
4597 4590
 							$filter,
4598 4591
 							$rByUid,
4599 4592
 							false
4600 4593
 						);
4601 4594
 						$messageList = $_sR['match']->ids;
4602
-						if (count($messageListForToggle)>0)
4595
+						if (count($messageListForToggle) > 0)
4603 4596
 						{
4604 4597
 							$flag2set = (strtolower($_flag));
4605
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4606
-							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4598
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4599
+							$this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder);
4607 4600
 						}
4608
-						if (count($messageList)>0)
4601
+						if (count($messageList) > 0)
4609 4602
 						{
4610 4603
 							$flag2set = 'un'.$_flag;
4611
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4612
-							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4604
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4605
+							$this->mail_bo->flagMessages($flag2set, $messageList, $folder);
4613 4606
 						}
4614
-						$alreadyFlagged=true;
4607
+						$alreadyFlagged = true;
4615 4608
 					}
4616 4609
 					elseif (!empty($filter) &&
4617
-						(!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) ||
4618
-						(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4619
-						($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
4610
+						(!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) ||
4611
+						(in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4612
+						($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))))
4620 4613
 					{
4621
-						if ($query['filter'] && $query['filter'] !='any')
4614
+						if ($query['filter'] && $query['filter'] != 'any')
4622 4615
 						{
4623 4616
 							$filter['status'] = $query['filter'];
4624 4617
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4625
-							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4618
+							$_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag)));
4626 4619
 						}
4627
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4620
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4628 4621
 						$rByUid = true;
4629 4622
 						$reverse = 1;
4630 4623
 						$_sR = $this->mail_bo->getSortedList(
4631 4624
 							$folder,
4632
-							$sort=0,
4625
+							$sort = 0,
4633 4626
 							$reverse,
4634 4627
 							$filter,
4635 4628
 							$rByUid,
@@ -4641,8 +4634,8 @@  discard block
 block discarded – undo
4641 4634
 					}
4642 4635
 					else
4643 4636
 					{
4644
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4645
-						$alreadyFlagged=true;
4637
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4638
+						$alreadyFlagged = true;
4646 4639
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4647 4640
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4648 4641
 						$this->mail_bo->flagMessages($_flag, 'all', $folder);
@@ -4656,41 +4649,41 @@  discard block
 block discarded – undo
4656 4649
 			}
4657 4650
 			if (!$alreadyFlagged)
4658 4651
 			{
4659
-				foreach($_messageList['msg'] as $rowID)
4652
+				foreach ($_messageList['msg'] as $rowID)
4660 4653
 				{
4661 4654
 					$hA = self::splitRowID($rowID);
4662 4655
 					$messageList[] = $hA['msgUID'];
4663 4656
 				}
4664
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
4665
-				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4657
+				if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList)));
4658
+				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder);
4666 4659
 			}
4667 4660
 		}
4668 4661
 		else
4669 4662
 		{
4670
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4663
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4671 4664
 		}
4672 4665
 
4673 4666
 		if ($_sendJsonResponse)
4674 4667
 		{
4675
-			$flag=array(
4676
-				'label1'	=> 'important',//lang('important'),
4677
-				'label2'	=> 'job',	//lang('job'),
4678
-				'label3'	=> 'personal',//lang('personal'),
4679
-				'label4'	=> 'to do',	//lang('to do'),
4680
-				'label5'	=> 'later',	//lang('later'),
4668
+			$flag = array(
4669
+				'label1'	=> 'important', //lang('important'),
4670
+				'label2'	=> 'job', //lang('job'),
4671
+				'label3'	=> 'personal', //lang('personal'),
4672
+				'label4'	=> 'to do', //lang('to do'),
4673
+				'label5'	=> 'later', //lang('later'),
4681 4674
 			);
4682 4675
 			$response = Api\Json\Response::get();
4683 4676
 			if (isset($_messageList['msg']) && $_messageList['popup'])
4684 4677
 			{
4685
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update');
4678
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', $_messageList['msg'], lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail', $_messageList['msg'], 'update');
4686 4679
 			}
4687
-			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
4680
+			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))
4688 4681
 			{
4689
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail');
4682
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail');
4690 4683
 			}
4691 4684
 			else
4692 4685
 			{
4693
-				$response->call('egw.message',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder));
4686
+				$response->call('egw.message', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder));
4694 4687
 			}
4695 4688
 		}
4696 4689
 	}
@@ -4702,12 +4695,12 @@  discard block
 block discarded – undo
4702 4695
 	 * @param string _forceDeleteMethod - method of deletion to be enforced
4703 4696
 	 * @return xajax response
4704 4697
 	 */
4705
-	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4698
+	function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null)
4706 4699
 	{
4707
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
4700
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod);
4708 4701
 		$error = null;
4709
-		$filtered =  false;
4710
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4702
+		$filtered = false;
4703
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4711 4704
 		{
4712 4705
 			if (isset($_messageList['all']) && $_messageList['all'])
4713 4706
 			{
@@ -4717,34 +4710,34 @@  discard block
 block discarded – undo
4717 4710
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4718 4711
 				{
4719 4712
 					$query = $_messageList['activeFilters'];
4720
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4713
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4721 4714
 					{
4722 4715
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4723 4716
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4724 4717
 						{
4725
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4726
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4718
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4719
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4727 4720
 						}
4728
-						$filtered =  true;
4721
+						$filtered = true;
4729 4722
 						$cutoffdate = $cutoffdate2 = null;
4730
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4731
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4723
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4724
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4732 4725
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4733 4726
 						$filter = array(
4734
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4735
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4727
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4728
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4736 4729
 							'string' => $query['search'],
4737
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4730
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4738 4731
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4739 4732
 						);
4740
-						if ($query['enddate']||$query['startdate']) {
4733
+						if ($query['enddate'] || $query['startdate']) {
4741 4734
 							$filter['range'] = "BETWEEN";
4742 4735
 							if ($cutoffdate) {
4743
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4736
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4744 4737
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4745 4738
 							}
4746 4739
 							if ($cutoffdate2) {
4747
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4740
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4748 4741
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4749 4742
 							}
4750 4743
 						}
@@ -4758,7 +4751,7 @@  discard block
 block discarded – undo
4758 4751
 					$rByUid = true;
4759 4752
 					$_sR = $this->mail_bo->getSortedList(
4760 4753
 						$folder,
4761
-						$sort=0,
4754
+						$sort = 0,
4762 4755
 						$reverse,
4763 4756
 						$filter,
4764 4757
 						$rByUid,
@@ -4768,23 +4761,23 @@  discard block
 block discarded – undo
4768 4761
 				}
4769 4762
 				else
4770 4763
 				{
4771
-					$messageList='all';
4764
+					$messageList = 'all';
4772 4765
 				}
4773 4766
 				try
4774 4767
 				{
4775 4768
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4776
-					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4769
+					$this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4777 4770
 				}
4778 4771
 				catch (Api\Exception $e)
4779 4772
 				{
4780
-					$error = str_replace('"',"'",$e->getMessage());
4773
+					$error = str_replace('"', "'", $e->getMessage());
4781 4774
 				}
4782 4775
 			}
4783 4776
 			else
4784 4777
 			{
4785 4778
 				$uidA = self::splitRowID($_messageList['msg'][0]);
4786 4779
 				$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4787
-				foreach($_messageList['msg'] as $rowID)
4780
+				foreach ($_messageList['msg'] as $rowID)
4788 4781
 				{
4789 4782
 					$hA = self::splitRowID($rowID);
4790 4783
 					$messageList[] = $hA['msgUID'];
@@ -4792,27 +4785,27 @@  discard block
 block discarded – undo
4792 4785
 				try
4793 4786
 				{
4794 4787
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4795
-					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4788
+					$this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4796 4789
 				}
4797 4790
 				catch (Api\Exception $e)
4798 4791
 				{
4799
-					$error = str_replace('"',"'",$e->getMessage());
4792
+					$error = str_replace('"', "'", $e->getMessage());
4800 4793
 				}
4801 4794
 			}
4802 4795
 			$response = Api\Json\Response::get();
4803 4796
 			if (empty($error))
4804 4797
 			{
4805
-				$response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg']));
4798
+				$response->call('app.mail.mail_deleteMessagesShowResult', array('egw_message'=>lang('deleted %1 messages in %2', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($_messageList['msg'])), $folder), 'msg'=>$_messageList['msg']));
4806 4799
 			}
4807 4800
 			else
4808 4801
 			{
4809
-				$error = str_replace('\n',"\n",lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)',$error));
4810
-				$response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList));
4802
+				$error = str_replace('\n', "\n", lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)', $error));
4803
+				$response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList));
4811 4804
 			}
4812 4805
 		}
4813 4806
 		else
4814 4807
 		{
4815
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4808
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4816 4809
 		}
4817 4810
 	}
4818 4811
 
@@ -4826,48 +4819,48 @@  discard block
 block discarded – undo
4826 4819
 	 *
4827 4820
 	 * @return xajax response
4828 4821
 	 */
4829
-	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4822
+	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_')
4830 4823
 	{
4831
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4824
+		if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4832 4825
 		Api\Translation::add_app('mail');
4833 4826
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4834 4827
 		// only copy or move are supported as method
4835
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
4836
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4828
+		if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy';
4829
+		list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2);
4837 4830
 		// check if move2archive was called with the correct archiveFolder
4838 4831
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
4839
-		if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder)
4832
+		if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder)
4840 4833
 		{
4841 4834
 			error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder");
4842 4835
 			$targetProfileID = $this->mail_bo->profileID;
4843 4836
 			$targetFolder = $archiveFolder;
4844 4837
 			error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder");
4845 4838
 		}
4846
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
4839
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
4847 4840
 		$changeFolderActions = false;
4848 4841
 		//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
4849 4842
 		//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
4850 4843
 		if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
4851 4844
 		{
4852 4845
 			//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]));
4853
-			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
4846
+			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3)
4854 4847
 			{
4855 4848
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4856
-				foreach( $keys as &$f)
4849
+				foreach ($keys as &$f)
4857 4850
 				{
4858
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4851
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4859 4852
 					else break;
4860 4853
 				}
4861 4854
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4862 4855
 			}
4863 4856
 			//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
4864
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName;
4857
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName;
4865 4858
 			$changeFolderActions = true;
4866 4859
 		}
4867 4860
 		$filtered = false;
4868
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4861
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4869 4862
 		{
4870
-			$error=false;
4863
+			$error = false;
4871 4864
 			if (isset($_messageList['all']) && $_messageList['all'])
4872 4865
 			{
4873 4866
 				// we have both messageIds AND allFlag folder information
@@ -4877,34 +4870,34 @@  discard block
 block discarded – undo
4877 4870
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4878 4871
 				{
4879 4872
 					$query = $_messageList['activeFilters'];
4880
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4873
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4881 4874
 					{
4882 4875
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4883 4876
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4884 4877
 						{
4885
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4886
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4878
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4879
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4887 4880
 						}
4888 4881
 						$filtered = true;
4889 4882
 						$cutoffdate = $cutoffdate2 = null;
4890
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4891
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4883
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4884
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4892 4885
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4893 4886
 						$filter = array(
4894
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4895
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4887
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4888
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4896 4889
 							'string' => $query['search'],
4897
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4890
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4898 4891
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4899 4892
 						);
4900
-						if ($query['enddate']||$query['startdate']) {
4893
+						if ($query['enddate'] || $query['startdate']) {
4901 4894
 							$filter['range'] = "BETWEEN";
4902 4895
 							if ($cutoffdate) {
4903
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4896
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4904 4897
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4905 4898
 							}
4906 4899
 							if ($cutoffdate2) {
4907
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4900
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4908 4901
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4909 4902
 							}
4910 4903
 						}
@@ -4917,70 +4910,70 @@  discard block
 block discarded – undo
4917 4910
 					$rByUid = true;
4918 4911
 					$_sR = $this->mail_bo->getSortedList(
4919 4912
 						$folder,
4920
-						$sort=0,
4913
+						$sort = 0,
4921 4914
 						$reverse,
4922 4915
 						$filter,
4923
-						$rByUid=true,
4916
+						$rByUid = true,
4924 4917
 						false
4925 4918
 					);
4926 4919
 					$messageList = $_sR['match']->ids;
4927
-					foreach($messageList as $uID)
4920
+					foreach ($messageList as $uID)
4928 4921
 					{
4929 4922
 						//error_log(__METHOD__.__LINE__.$uID);
4930
-						if ($_copyOrMove=='move')
4923
+						if ($_copyOrMove == 'move')
4931 4924
 						{
4932
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false);
4925
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false);
4933 4926
 						}
4934 4927
 					}
4935 4928
 				}
4936 4929
 				else
4937 4930
 				{
4938
-					$messageList='all';
4931
+					$messageList = 'all';
4939 4932
 				}
4940 4933
 				try
4941 4934
 				{
4942 4935
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4943
-					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4936
+					$this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4944 4937
 				}
4945 4938
 				catch (Api\Exception $e)
4946 4939
 				{
4947
-					$error = str_replace('"',"'",$e->getMessage());
4940
+					$error = str_replace('"', "'", $e->getMessage());
4948 4941
 				}
4949 4942
 			}
4950 4943
 			else
4951 4944
 			{
4952 4945
 				$messageList = array();
4953
-				while(count($_messageList['msg']) > 0)
4946
+				while (count($_messageList['msg']) > 0)
4954 4947
 				{
4955 4948
 					$uidA = self::splitRowID($_messageList['msg'][0]);
4956 4949
 					$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4957 4950
 					$sourceProfileID = $uidA['profileID'];
4958 4951
 					$moveList = array();
4959
-					foreach($_messageList['msg'] as $rowID)
4952
+					foreach ($_messageList['msg'] as $rowID)
4960 4953
 					{
4961 4954
 						$hA = self::splitRowID($rowID);
4962 4955
 
4963 4956
 						// If folder changes, stop and move what we've got
4964
-						if($hA['folder'] != $folder) break;
4957
+						if ($hA['folder'] != $folder) break;
4965 4958
 
4966 4959
 						array_shift($_messageList['msg']);
4967 4960
 						$messageList[] = $hA['msgUID'];
4968 4961
 						$moveList[] = $hA['msgUID'];
4969
-						if ($_copyOrMove=='move')
4962
+						if ($_copyOrMove == 'move')
4970 4963
 						{
4971
-							$helpvar = explode(self::$delimiter,$rowID);
4964
+							$helpvar = explode(self::$delimiter, $rowID);
4972 4965
 							array_shift($helpvar);
4973
-							$messageListForRefresh[]= implode(self::$delimiter,$helpvar);
4966
+							$messageListForRefresh[] = implode(self::$delimiter, $helpvar);
4974 4967
 						}
4975 4968
 					}
4976 4969
 					try
4977 4970
 					{
4978 4971
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4979
-						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4972
+						$this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4980 4973
 					}
4981 4974
 					catch (Api\Exception $e)
4982 4975
 					{
4983
-						$error = str_replace('"',"'",$e->getMessage());
4976
+						$error = str_replace('"', "'", $e->getMessage());
4984 4977
 					}
4985 4978
 				}
4986 4979
 			}
@@ -4993,30 +4986,30 @@  discard block
 block discarded – undo
4993 4986
 					unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]);
4994 4987
 					$changeFolderActions = true;
4995 4988
 				}
4996
-				$response->call('egw.message',$error,"error");
4989
+				$response->call('egw.message', $error, "error");
4997 4990
 			}
4998 4991
 			else
4999 4992
 			{
5000
-				if ($_copyOrMove=='copy')
4993
+				if ($_copyOrMove == 'copy')
5001 4994
 				{
5002
-					$response->call('egw.message',lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder));
4995
+					$response->call('egw.message', lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder));
5003 4996
 				}
5004 4997
 				else
5005 4998
 				{
5006
-					$response->call('egw.refresh',lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder),'mail',$messageListForRefresh,'delete');
4999
+					$response->call('egw.refresh', lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder), 'mail', $messageListForRefresh, 'delete');
5007 5000
 				}
5008 5001
 			}
5009 5002
 			if ($changeFolderActions == true)
5010 5003
 			{
5011 5004
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
5012
-				Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
5005
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
5013 5006
 				$actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions());
5014
-				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
5007
+				$response->call('app.mail.mail_rebuildActionsOnList', $actionsnew);
5015 5008
 			}
5016 5009
 		}
5017 5010
 		else
5018 5011
 		{
5019
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5012
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5020 5013
 		}
5021 5014
 	}
5022 5015
 
@@ -5026,11 +5019,11 @@  discard block
 block discarded – undo
5026 5019
 	 *
5027 5020
 	 * @param type $_id
5028 5021
 	 */
5029
-	function ajax_folderMgmtTree_autoloading ($_id = null)
5022
+	function ajax_folderMgmtTree_autoloading($_id = null)
5030 5023
 	{
5031 5024
 		$mail_ui = new mail_ui();
5032
-		$id = $_id? $_id : $_GET['id'];
5033
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false));
5025
+		$id = $_id ? $_id : $_GET['id'];
5026
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false));
5034 5027
 	}
5035 5028
 
5036 5029
 	/**
@@ -5038,15 +5031,15 @@  discard block
 block discarded – undo
5038 5031
 	 *
5039 5032
 	 * @param array $content content of dialog
5040 5033
 	 */
5041
-	function folderManagement (array $content = null)
5034
+	function folderManagement(array $content = null)
5042 5035
 	{
5043 5036
 		$dtmpl = new Etemplate('mail.folder_management');
5044
-		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
5045
-		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
5037
+		$profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id'];
5038
+		$sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false);
5046 5039
 
5047 5040
 		if (!is_array($content))
5048 5041
 		{
5049
-			$content = array ('acc_id' => $profileID);
5042
+			$content = array('acc_id' => $profileID);
5050 5043
 		}
5051 5044
 
5052 5045
 		$readonlys = array();
@@ -5054,7 +5047,7 @@  discard block
 block discarded – undo
5054 5047
 		$preserv = array(
5055 5048
 			'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side
5056 5049
 		);
5057
-		$dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2);
5050
+		$dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2);
5058 5051
 	}
5059 5052
 
5060 5053
 	/**
@@ -5064,11 +5057,11 @@  discard block
 block discarded – undo
5064 5057
 	 *
5065 5058
 	 * @param type $_folderName
5066 5059
 	 */
5067
-	function ajax_folderMgmt_delete ($_folderName)
5060
+	function ajax_folderMgmt_delete($_folderName)
5068 5061
 	{
5069 5062
 		if ($_folderName)
5070 5063
 		{
5071
-			$success = $this->ajax_deleteFolder($_folderName,true);
5064
+			$success = $this->ajax_deleteFolder($_folderName, true);
5072 5065
 			$response = Api\Json\Response::get();
5073 5066
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
5074 5067
 			if ($success)
@@ -5077,7 +5070,7 @@  discard block
 block discarded – undo
5077 5070
 			}
5078 5071
 			else
5079 5072
 			{
5080
-				$res = lang("Failed to delete %1",$folderName);
5073
+				$res = lang("Failed to delete %1", $folderName);
5081 5074
 			}
5082 5075
 			$response->data($res);
5083 5076
 		}
Please login to merge, or discard this patch.
notifications/inc/class.notifications.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -434,7 +434,7 @@
 block discarded – undo
434 434
 	 * Sets backends that should be skipped even if the user
435 435
 	 * defined them in its chain
436 436
 	 *
437
-	 * @param array $_skip_backends array with names of the backends to be skipped
437
+	 * @param string[] $_skip_backends array with names of the backends to be skipped
438 438
 	 * e.g. array('popup', 'winpopup')
439 439
 	 */
440 440
 	public function set_skip_backends(array $_skip_backends) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -660,14 +660,14 @@
 block discarded – undo
660 660
 	 }
661 661
 
662 662
 	 /**
663
-	 * returns notification chains based on admin prefs
664
-	 * @abstract the available chains can be retrieved in two different output formats:
665
-	 * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
-	 * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
-	 *
668
-	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
-	 * @return array containing notification chains, output like given in $_output
670
-	 */
663
+	  * returns notification chains based on admin prefs
664
+	  * @abstract the available chains can be retrieved in two different output formats:
665
+	  * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
+	  * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
+	  *
668
+	  * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
+	  * @return array containing notification chains, output like given in $_output
670
+	  */
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 */
181 181
 	public function __construct() {
182
-		$this->config = (object) Api\Config::read(self::_appname);
182
+		$this->config = (object)Api\Config::read(self::_appname);
183 183
 	}
184 184
 
185 185
 	/**
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @param boolean $reset =false true: reset all errors
189 189
 	 * @return array
190 190
 	 */
191
-	public static function errors($reset=false)
191
+	public static function errors($reset = false)
192 192
 	{
193 193
 		$ret = self::$errors;
194 194
 		if ($reset) self::$errors = array();
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 	 * it's an int with the account id or the e-mail address of a non-eGW user
204 204
 	 */
205 205
 	public function set_sender($_sender) {
206
-		if(is_object($_sender)) {
206
+		if (is_object($_sender)) {
207 207
 			$this->sender = $_sender;
208 208
 			return true;
209 209
 		} else {
210 210
 			// no object atm, we have to handle this and make a pseudo-object
211
-			if(is_numeric($_sender)) {
212
-				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
211
+			if (is_numeric($_sender)) {
212
+				$this->sender = (object)$GLOBALS['egw']->accounts->read($_sender);
213 213
 				return true;
214 214
 			}
215
-			if(is_string($_sender) && strpos($_sender,'@')) {
216
-				$this->sender = (object) array (
217
-									'account_email' => $this->get_addresspart($_sender,'email'),
218
-									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
215
+			if (is_string($_sender) && strpos($_sender, '@')) {
216
+				$this->sender = (object)array(
217
+									'account_email' => $this->get_addresspart($_sender, 'email'),
218
+									'account_fullname' => $this->get_addresspart($_sender, 'fullname'),
219 219
 									);
220 220
 				return true;
221 221
 			}
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
 	 * it's an int with the account id or the e-mail address of a non-eGW user
246 246
 	 */
247 247
 	public function add_receiver($_receiver) {
248
-		if(is_object($_receiver)) {
248
+		if (is_object($_receiver)) {
249 249
 			$this->receivers[] = $_receiver;
250 250
 			return true;
251 251
 		} else {
252 252
 			// no object atm, we have to handle this and make a pseudo-object
253
-			if(is_numeric($_receiver)) {
254
-				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
253
+			if (is_numeric($_receiver)) {
254
+				$this->receivers[] = (object)$GLOBALS['egw']->accounts->read($_receiver);
255 255
 				return true;
256 256
 			}
257
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
258
-				$this->receivers[] = (object) array (
259
-									'account_email' => $this->get_addresspart($_receiver,'email'),
260
-									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
257
+			if (is_string($_receiver) && strpos($_receiver, '@')) {
258
+				$this->receivers[] = (object)array(
259
+									'account_email' => $this->get_addresspart($_receiver, 'email'),
260
+									'account_fullname' => $this->get_addresspart($_receiver, 'fullname'),
261 261
 									);
262 262
 				return true;
263 263
 			}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 * @param string $_message
297 297
 	 */
298 298
 	public function set_message($_message) {
299
-		if(strlen($_message) == strlen(strip_tags($_message))) {
299
+		if (strlen($_message) == strlen(strip_tags($_message))) {
300 300
 			$this->message_plain = $_message;
301 301
 		} else {
302 302
 			$this->message_html = $_message;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function set_popupmessage($_message) {
316 316
 		//popup requires html
317
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
317
+		if (strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
318 318
 		$this->message_popup = $_message;
319 319
 		return true;
320 320
 	}
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function set_links(array $_links) {
328 328
 		$this->links = array(); // clear array if set
329
-		foreach($_links as $link) {
330
-			if(is_array($link)) {
331
-				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
329
+		foreach ($_links as $link) {
330
+			if (is_array($link)) {
331
+				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'], $link['id']);
332 332
 			}
333 333
 		}
334 334
 		return true;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function set_popuplinks(array $_links) {
343 343
 		$this->popup_links = array(); // clear array if set
344
-		foreach($_links as $link) {
345
-			if(is_array($link)) {
344
+		foreach ($_links as $link) {
345
+			if (is_array($link)) {
346 346
 				$this->add_popuplink($link['text'], $link['view'], $link['popup']);
347 347
 			}
348 348
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
360 360
 	 */
361 361
 	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
362
-		if(!$_view || !$_text) { return false; }
362
+		if (!$_view || !$_text) { return false; }
363 363
 		$this->links[] = (object)array(
364 364
 			'text'	=> $_text,
365 365
 			'view'	=> $_view,
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
379 379
 	 */
380 380
 	public function add_popuplink($_text, $_view, $_popup = false) {
381
-		if(!$_view || !$_text) { return false; }
382
-		$this->popup_links[] = (object)array(	'text'	=> $_text,
381
+		if (!$_view || !$_text) { return false; }
382
+		$this->popup_links[] = (object)array('text'	=> $_text,
383 383
 										'view'	=> $_view,
384 384
 										'popup'	=> $_popup,
385 385
 										);
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	public function set_attachments(array $_attachments) {
395 395
 		$this->attachments = array(); // clear array if set
396
-		foreach($_attachments as $attachment) {
397
-			if(is_array($attachment)) {
396
+		foreach ($_attachments as $attachment) {
397
+			if (is_array($attachment)) {
398 398
 				$this->add_attachment(
399 399
 					$attachment['string'],
400 400
 					$attachment['filename'],
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param string $_type File extension (MIME) type.
419 419
 	 * @param string $_path optional path to attachment, if !$_string
420 420
 	 */
421
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
422
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
421
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path = null) {
422
+		if (!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
423 423
 		$this->attachments[] = (object)array(
424 424
 			'string' => $_string,
425 425
 			'filename' => $_filename,
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		if (!is_array($this->receivers) || count($this->receivers) == 0) {
452 452
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
453 453
 		}
454
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
454
+		if (!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
455 455
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
456 456
 		}
457 457
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			$backend_errors = array();
464 464
 			try {
465 465
 				// system or non-system user
466
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
466
+				if ($receiver->account_id && is_numeric($receiver->account_id)) {
467 467
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
468 468
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
469 469
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -476,17 +476,17 @@  discard block
 block discarded – undo
476 476
 					}
477 477
 					$receiver->handle = $receiver->account_lid;
478 478
 					// check if the receiver has rights to run the notifcation app
479
-					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
479
+					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id, true);
480 480
 					$ids[] = $receiver->account_id;
481
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
481
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids, 'run', 'notifications')) {
482 482
 						// read the users notification chain
483 483
 						$prefs = new Api\Preferences($receiver->account_id);
484 484
 						$preferences_all = $prefs->read();
485 485
 						$preferences = (object)$preferences_all[self::_appname];
486
-						if($preferences->notification_chain) {
486
+						if ($preferences->notification_chain) {
487 487
 							// fallback: admin disabled user-chosen chain
488
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
489
-								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
488
+							if (!$notification_chain = $available_chains[$preferences->notification_chain]) {
489
+								$prepend_message .= lang('This eGroupWare notification has been sent to you by mail because your'
490 490
 															.' chosen notification-chain has been disabled by the administrator.'
491 491
 															.' Please choose another notification-chain in your preferences!');
492 492
 								$notification_chain = $available_chains[self::_fallback];
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
504 504
 				}
505 505
 
506
-				if($notification_chain == 'disable') {
506
+				if ($notification_chain == 'disable') {
507 507
 					continue; //user disabled notifications
508 508
 				}
509 509
 
510
-				foreach($notification_chain as $backend => $action) {
510
+				foreach ($notification_chain as $backend => $action) {
511 511
 					$notification_backend = null;
512 512
 					try {
513 513
 						// check if backend should be skipped
514
-						if( in_array($backend, $this->skip_backends) ) {
514
+						if (in_array($backend, $this->skip_backends)) {
515 515
 							// log as error just for the case too much skipping prevents user from being notified
516 516
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
517 517
 							continue;
518 518
 						}
519 519
 
520 520
 						$notification_backend = self::_appname.'_'.$backend;
521
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
522
-							throw new Exception('file for '.$notification_backend. ' does not exist');
521
+						if (!file_exists(EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.'.$notification_backend.'.inc.php')) {
522
+							throw new Exception('file for '.$notification_backend.' does not exist');
523 523
 						}
524
-						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
525
-						if ( !($obj instanceof notifications_iface) ) {
526
-							unset ( $obj );
527
-					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
524
+						$obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences);
525
+						if (!($obj instanceof notifications_iface)) {
526
+							unset ($obj);
527
+					 		throw new Exception($notification_backend.' is no implementation of notifications_iface');
528 528
 						}
529 529
 						$lsubject = $this->subject;
530 530
 						$llinks = $this->links;
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
 					catch (Exception $exception) {
539 539
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
540 540
 						// try next backend
541
-						if($action == 'fail' || $action == 'continue') {
541
+						if ($action == 'fail' || $action == 'continue') {
542 542
 							continue;
543 543
 						}
544 544
 						break; // stop running through chain
545 545
 					}
546 546
 					// backend sucseeded
547 547
 					$user_notified = true;
548
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
548
+					if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain
549 549
 				}
550 550
 				// check if the user has been notified at all
551
-				if(!$user_notified) {
551
+				if (!$user_notified) {
552 552
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
553 553
 					foreach($backend_errors as $id=>$backend_error) {
554 554
 						error_log($backend_error);
@@ -575,22 +575,22 @@  discard block
 block discarded – undo
575 575
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
576 576
 	 */
577 577
 	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
578
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
578
+		if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
579 579
 		$messages = array();
580 580
 
581 581
 		// create the messages
582
-		if(!empty($_message_plain)) {
582
+		if (!empty($_message_plain)) {
583 583
 			$messages['plain'] = $_message_plain;
584 584
 		} else {
585 585
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
586 586
 		}
587 587
 
588
-		if(!empty($_message_html)) {
588
+		if (!empty($_message_html)) {
589 589
 			$messages['html'] = $_message_html;
590 590
 		} else {
591 591
 			$messages['html'] = self::plain2html($_message_plain);
592 592
 		}
593
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
593
+		if (!empty($_message_popup)) $messages['popup'] = $_message_popup;
594 594
 		return $messages;
595 595
 	}
596 596
 
@@ -613,9 +613,9 @@  discard block
 block discarded – undo
613 613
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
614 614
 	 */
615 615
 	 private function prepend_message(array $_messages, $_prepend = null) {
616
-		if(strlen($_prepend) > 0) {
617
-			foreach($_messages as $key => $value) {
618
-				switch($key) {
616
+		if (strlen($_prepend) > 0) {
617
+			foreach ($_messages as $key => $value) {
618
+				switch ($key) {
619 619
 					case 'plain':
620 620
 						$_messages[$key] = $_prepend."\n\n".$value;
621 621
 						break;
@@ -639,17 +639,17 @@  discard block
 block discarded – undo
639 639
 	 * @param string $_part
640 640
 	 * @return string chosen part of the address
641 641
 	 */
642
-	private function get_addresspart($_address, $_part='email')
642
+	private function get_addresspart($_address, $_part = 'email')
643 643
 	{
644 644
 		$parts = null;
645
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
646
-	 		$fullname = trim(trim($parts[1]),'\"');
645
+	 	if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part
646
+	 		$fullname = trim(trim($parts[1]), '\"');
647 647
 	 		$email = $parts[2];
648 648
 	 	} else {
649 649
 	 		$fullname = false;
650 650
 	 		$email = $_address;
651 651
 	 	}
652
-	 	switch($_part) {
652
+	 	switch ($_part) {
653 653
 	 		case 'fullname':
654 654
 	 			return $fullname;
655 655
 	 		case 'email':
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
674
-		foreach($this->backends as $backend) {
675
-			switch($backend) {
674
+		foreach ($this->backends as $backend) {
675
+			switch ($backend) {
676 676
 				case 'email':
677 677
 				case 'popup':
678 678
 				case 'jpopup':
@@ -687,15 +687,15 @@  discard block
 block discarded – undo
687 687
 
688 688
 		$enabled_chains = array();
689 689
 		$disabled_chains = array();
690
-		foreach($this->notification_chains as $key => $chain) {
690
+		foreach ($this->notification_chains as $key => $chain) {
691 691
 			$allow_chain = true;
692
-			if(is_array($chain)) {
693
-				foreach(array_keys($chain) as $name) {
694
-					if(!$enabled_backends[$name]) {
692
+			if (is_array($chain)) {
693
+				foreach (array_keys($chain) as $name) {
694
+					if (!$enabled_backends[$name]) {
695 695
 						$allow_chain = false; // disable whole chain if one backend is disabled
696 696
 					}
697 697
 				}
698
-				if($allow_chain) {
698
+				if ($allow_chain) {
699 699
 					$enabled_chains[$key] = $chain;
700 700
 				} else {
701 701
 					$disabled_chains[$key] = $chain;
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
 		// create the 'all' chain from the enabled backends
711 711
 		$chain_all = array();
712 712
 		$backend_count = 1;
713
-		foreach($enabled_backends as $backend => $enabled) {
714
-			if($enabled) {
713
+		foreach ($enabled_backends as $backend => $enabled) {
714
+			if ($enabled) {
715 715
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
716 716
 			}
717 717
 			$backend_count++;
718 718
 		}
719 719
 		$common_chains['all'] = $chain_all;
720 720
 
721
-		switch($_output) {
721
+		switch ($_output) {
722 722
 			case 'human':
723 723
 				$chain_groups = array(
724 724
 					lang('Common chains')	=> 'common_chains',
@@ -727,10 +727,10 @@  discard block
 block discarded – undo
727 727
 					);
728 728
 				$suffix = '_human';
729 729
 				// create descriptions for each chain key in each group
730
-				foreach($chain_groups as $name => $arr_name) {
730
+				foreach ($chain_groups as $name => $arr_name) {
731 731
 					${$arr_name.$suffix} = array();
732
-					foreach(array_keys(${$arr_name}) as $key) {
733
-						if($arr_name == 'disabled_chains') {
732
+					foreach (array_keys(${$arr_name}) as $key) {
733
+						if ($arr_name == 'disabled_chains') {
734 734
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
735 735
 						} else {
736 736
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 				}
740 740
 				// summarize all groups with minimum one chain to the final array
741 741
 				$chains_final = array();
742
-				foreach($chain_groups as $name => $arr_name) {
743
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
742
+				foreach ($chain_groups as $name => $arr_name) {
743
+					if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
744 744
 						$chains_final[$name] = ${$arr_name.$suffix};
745 745
 					}
746 746
 				}
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
761 761
 	 */
762 762
 	public function deleteaccount($settings) {
763
-		foreach($this->backends as $backend) {
764
-			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
763
+		foreach ($this->backends as $backend) {
764
+			$backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount');
765 765
 			if (is_callable($backend_hook)) {
766
-				call_user_func($backend_hook,$settings);
766
+				call_user_func($backend_hook, $settings);
767 767
 			}
768 768
 		}
769 769
 	}
Please login to merge, or discard this patch.
Braces   +222 added lines, -96 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
  * called from this class. The backend's job is to deliver ONE message to ONE recipient.
25 25
  *
26 26
  */
27
-final class notifications {
27
+final class notifications
28
+{
28 29
 
29 30
 	/**
30 31
 	 * Appname
@@ -178,7 +179,8 @@  discard block
 block discarded – undo
178 179
 	 * constructor of notifications
179 180
 	 *
180 181
 	 */
181
-	public function __construct() {
182
+	public function __construct()
183
+	{
182 184
 		$this->config = (object) Api\Config::read(self::_appname);
183 185
 	}
184 186
 
@@ -191,7 +193,10 @@  discard block
 block discarded – undo
191 193
 	public static function errors($reset=false)
192 194
 	{
193 195
 		$ret = self::$errors;
194
-		if ($reset) self::$errors = array();
196
+		if ($reset)
197
+		{
198
+			self::$errors = array();
199
+		}
195 200
 		return $ret;
196 201
 	}
197 202
 
@@ -202,17 +207,23 @@  discard block
 block discarded – undo
202 207
 	 * as long as the accounts class isn't a nice object,
203 208
 	 * it's an int with the account id or the e-mail address of a non-eGW user
204 209
 	 */
205
-	public function set_sender($_sender) {
206
-		if(is_object($_sender)) {
210
+	public function set_sender($_sender)
211
+	{
212
+		if(is_object($_sender))
213
+		{
207 214
 			$this->sender = $_sender;
208 215
 			return true;
209
-		} else {
216
+		}
217
+		else
218
+		{
210 219
 			// no object atm, we have to handle this and make a pseudo-object
211
-			if(is_numeric($_sender)) {
220
+			if(is_numeric($_sender))
221
+			{
212 222
 				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
213 223
 				return true;
214 224
 			}
215
-			if(is_string($_sender) && strpos($_sender,'@')) {
225
+			if(is_string($_sender) && strpos($_sender,'@'))
226
+			{
216 227
 				$this->sender = (object) array (
217 228
 									'account_email' => $this->get_addresspart($_sender,'email'),
218 229
 									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
@@ -230,9 +241,11 @@  discard block
 block discarded – undo
230 241
 	 * as long as the accounts class isn't a nice object,
231 242
 	 * it's an array with the int of the account id or the e-mail address of a non-eGW user
232 243
 	 */
233
-	public function set_receivers(array $_receivers) {
244
+	public function set_receivers(array $_receivers)
245
+	{
234 246
 		$this->receivers = array();
235
-		foreach ($_receivers as $receiver) {
247
+		foreach ($_receivers as $receiver)
248
+		{
236 249
 			$this->add_receiver($receiver);
237 250
 		}
238 251
 	}
@@ -244,17 +257,23 @@  discard block
 block discarded – undo
244 257
 	 * as long as the accounts class isn't a nice object,
245 258
 	 * it's an int with the account id or the e-mail address of a non-eGW user
246 259
 	 */
247
-	public function add_receiver($_receiver) {
248
-		if(is_object($_receiver)) {
260
+	public function add_receiver($_receiver)
261
+	{
262
+		if(is_object($_receiver))
263
+		{
249 264
 			$this->receivers[] = $_receiver;
250 265
 			return true;
251
-		} else {
266
+		}
267
+		else
268
+		{
252 269
 			// no object atm, we have to handle this and make a pseudo-object
253
-			if(is_numeric($_receiver)) {
270
+			if(is_numeric($_receiver))
271
+			{
254 272
 				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
255 273
 				return true;
256 274
 			}
257
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
275
+			if(is_string($_receiver) && strpos($_receiver,'@'))
276
+			{
258 277
 				$this->receivers[] = (object) array (
259 278
 									'account_email' => $this->get_addresspart($_receiver,'email'),
260 279
 									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
@@ -270,7 +289,8 @@  discard block
 block discarded – undo
270 289
 	 *
271 290
 	 * @param string $_subject
272 291
 	 */
273
-	public function set_subject($_subject) {
292
+	public function set_subject($_subject)
293
+	{
274 294
 		$this->subject = $_subject;
275 295
 		return true;
276 296
 	}
@@ -280,7 +300,8 @@  discard block
 block discarded – undo
280 300
 	 *
281 301
 	 * @param string $_subject
282 302
 	 */
283
-	public function set_popupsubject($_subject) {
303
+	public function set_popupsubject($_subject)
304
+	{
284 305
 		$this->popupsubject = $_subject;
285 306
 		return true;
286 307
 	}
@@ -295,10 +316,14 @@  discard block
 block discarded – undo
295 316
 	 *
296 317
 	 * @param string $_message
297 318
 	 */
298
-	public function set_message($_message) {
299
-		if(strlen($_message) == strlen(strip_tags($_message))) {
319
+	public function set_message($_message)
320
+	{
321
+		if(strlen($_message) == strlen(strip_tags($_message)))
322
+		{
300 323
 			$this->message_plain = $_message;
301
-		} else {
324
+		}
325
+		else
326
+		{
302 327
 			$this->message_html = $_message;
303 328
 		}
304 329
 		return true;
@@ -312,9 +337,13 @@  discard block
 block discarded – undo
312 337
 	 *
313 338
 	 * @param string $_message
314 339
 	 */
315
-	public function set_popupmessage($_message) {
340
+	public function set_popupmessage($_message)
341
+	{
316 342
 		//popup requires html
317
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
343
+		if(strlen($_message) == strlen(strip_tags($_message)))
344
+		{
345
+			$_message = self::plain2html($_message);
346
+		}
318 347
 		$this->message_popup = $_message;
319 348
 		return true;
320 349
 	}
@@ -324,10 +353,13 @@  discard block
 block discarded – undo
324 353
 	 *
325 354
 	 * @param array $_links link array (like defined in $this->add_link)
326 355
 	 */
327
-	public function set_links(array $_links) {
356
+	public function set_links(array $_links)
357
+	{
328 358
 		$this->links = array(); // clear array if set
329
-		foreach($_links as $link) {
330
-			if(is_array($link)) {
359
+		foreach($_links as $link)
360
+		{
361
+			if(is_array($link))
362
+			{
331 363
 				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
332 364
 			}
333 365
 		}
@@ -339,10 +371,13 @@  discard block
 block discarded – undo
339 371
 	 *
340 372
 	 * @param array $_links link array (like defined in $this->add_link)
341 373
 	 */
342
-	public function set_popuplinks(array $_links) {
374
+	public function set_popuplinks(array $_links)
375
+	{
343 376
 		$this->popup_links = array(); // clear array if set
344
-		foreach($_links as $link) {
345
-			if(is_array($link)) {
377
+		foreach($_links as $link)
378
+		{
379
+			if(is_array($link))
380
+			{
346 381
 				$this->add_popuplink($link['text'], $link['view'], $link['popup']);
347 382
 			}
348 383
 		}
@@ -358,8 +393,11 @@  discard block
 block discarded – undo
358 393
 	 * @param string $_app Application name, to use link registry (popup & view ignored)
359 394
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
360 395
 	 */
361
-	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
362
-		if(!$_view || !$_text) { return false; }
396
+	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false)
397
+	{
398
+		if(!$_view || !$_text)
399
+		{
400
+return false; }
363 401
 		$this->links[] = (object)array(
364 402
 			'text'	=> $_text,
365 403
 			'view'	=> $_view,
@@ -377,8 +415,11 @@  discard block
 block discarded – undo
377 415
 	 * @param array $_view all params needed to view the link (name => value pairs)
378 416
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
379 417
 	 */
380
-	public function add_popuplink($_text, $_view, $_popup = false) {
381
-		if(!$_view || !$_text) { return false; }
418
+	public function add_popuplink($_text, $_view, $_popup = false)
419
+	{
420
+		if(!$_view || !$_text)
421
+		{
422
+return false; }
382 423
 		$this->popup_links[] = (object)array(	'text'	=> $_text,
383 424
 										'view'	=> $_view,
384 425
 										'popup'	=> $_popup,
@@ -391,10 +432,13 @@  discard block
 block discarded – undo
391 432
 	 *
392 433
 	 * @param array $_attachments attachment array (like defined in $this->add_attachment)
393 434
 	 */
394
-	public function set_attachments(array $_attachments) {
435
+	public function set_attachments(array $_attachments)
436
+	{
395 437
 		$this->attachments = array(); // clear array if set
396
-		foreach($_attachments as $attachment) {
397
-			if(is_array($attachment)) {
438
+		foreach($_attachments as $attachment)
439
+		{
440
+			if(is_array($attachment))
441
+			{
398 442
 				$this->add_attachment(
399 443
 					$attachment['string'],
400 444
 					$attachment['filename'],
@@ -418,8 +462,12 @@  discard block
 block discarded – undo
418 462
 	 * @param string $_type File extension (MIME) type.
419 463
 	 * @param string $_path optional path to attachment, if !$_string
420 464
 	 */
421
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
422
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
465
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null)
466
+	{
467
+		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename)
468
+		{
469
+			return false;
470
+		}
423 471
 		$this->attachments[] = (object)array(
424 472
 			'string' => $_string,
425 473
 			'filename' => $_filename,
@@ -437,33 +485,40 @@  discard block
 block discarded – undo
437 485
 	 * @param array $_skip_backends array with names of the backends to be skipped
438 486
 	 * e.g. array('popup', 'winpopup')
439 487
 	 */
440
-	public function set_skip_backends(array $_skip_backends) {
488
+	public function set_skip_backends(array $_skip_backends)
489
+	{
441 490
 		$this->skip_backends = $_skip_backends;
442 491
 	}
443 492
 
444 493
 	/**
445 494
 	 * sends notifications
446 495
 	 */
447
-	public function send() {
448
-		if (!is_object($this->sender)) {
496
+	public function send()
497
+	{
498
+		if (!is_object($this->sender))
499
+		{
449 500
 			throw new Exception('Error: cannot send notifications. No sender supplied');
450 501
 		}
451
-		if (!is_array($this->receivers) || count($this->receivers) == 0) {
502
+		if (!is_array($this->receivers) || count($this->receivers) == 0)
503
+		{
452 504
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
453 505
 		}
454
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
506
+		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup))
507
+		{
455 508
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
456 509
 		}
457 510
 
458 511
 		$available_chains = $this->get_available_chains('routing');
459 512
 
460
-		foreach ($this->receivers as $receiver) {
513
+		foreach ($this->receivers as $receiver)
514
+		{
461 515
 			$user_notified = false;
462 516
 			$prepend_message = '';
463 517
 			$backend_errors = array();
464 518
 			try {
465 519
 				// system or non-system user
466
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
520
+				if($receiver->account_id && is_numeric($receiver->account_id))
521
+				{
467 522
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
468 523
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
469 524
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -478,51 +533,65 @@  discard block
 block discarded – undo
478 533
 					// check if the receiver has rights to run the notifcation app
479 534
 					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
480 535
 					$ids[] = $receiver->account_id;
481
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
536
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications'))
537
+					{
482 538
 						// read the users notification chain
483 539
 						$prefs = new Api\Preferences($receiver->account_id);
484 540
 						$preferences_all = $prefs->read();
485 541
 						$preferences = (object)$preferences_all[self::_appname];
486
-						if($preferences->notification_chain) {
542
+						if($preferences->notification_chain)
543
+						{
487 544
 							// fallback: admin disabled user-chosen chain
488
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
545
+							if(!$notification_chain = $available_chains[$preferences->notification_chain])
546
+							{
489 547
 								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
490 548
 															.' chosen notification-chain has been disabled by the administrator.'
491 549
 															.' Please choose another notification-chain in your preferences!');
492 550
 								$notification_chain = $available_chains[self::_fallback];
493 551
 							}
494
-						} else {
552
+						}
553
+						else
554
+						{
495 555
 							$notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs
496 556
 						}
497
-					} else {
557
+					}
558
+					else
559
+					{
498 560
 						$notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app
499 561
 					}
500
-				} else {
562
+				}
563
+				else
564
+				{
501 565
 					// non-system user
502 566
 					$receiver->handle = $receiver->account_email;
503 567
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
504 568
 				}
505 569
 
506
-				if($notification_chain == 'disable') {
570
+				if($notification_chain == 'disable')
571
+				{
507 572
 					continue; //user disabled notifications
508 573
 				}
509 574
 
510
-				foreach($notification_chain as $backend => $action) {
575
+				foreach($notification_chain as $backend => $action)
576
+				{
511 577
 					$notification_backend = null;
512 578
 					try {
513 579
 						// check if backend should be skipped
514
-						if( in_array($backend, $this->skip_backends) ) {
580
+						if( in_array($backend, $this->skip_backends) )
581
+						{
515 582
 							// log as error just for the case too much skipping prevents user from being notified
516 583
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
517 584
 							continue;
518 585
 						}
519 586
 
520 587
 						$notification_backend = self::_appname.'_'.$backend;
521
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
588
+						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php'))
589
+						{
522 590
 							throw new Exception('file for '.$notification_backend. ' does not exist');
523 591
 						}
524 592
 						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
525
-						if ( !($obj instanceof notifications_iface) ) {
593
+						if ( !($obj instanceof notifications_iface) )
594
+						{
526 595
 							unset ( $obj );
527 596
 					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
528 597
 						}
@@ -530,31 +599,44 @@  discard block
 block discarded – undo
530 599
 						$llinks = $this->links;
531 600
 						if ($backend == 'popup')
532 601
 						{
533
-							if (!empty($this->popupsubject)) $lsubject = $this->popupsubject;
534
-							if ($this->popup_links) $llinks = $this->popup_links;
602
+							if (!empty($this->popupsubject))
603
+							{
604
+								$lsubject = $this->popupsubject;
605
+							}
606
+							if ($this->popup_links)
607
+							{
608
+								$llinks = $this->popup_links;
609
+							}
535 610
 						}
536 611
 						$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments);
537 612
 					}
538 613
 					catch (Exception $exception) {
539 614
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
540 615
 						// try next backend
541
-						if($action == 'fail' || $action == 'continue') {
616
+						if($action == 'fail' || $action == 'continue')
617
+						{
542 618
 							continue;
543 619
 						}
544 620
 						break; // stop running through chain
545 621
 					}
546 622
 					// backend sucseeded
547 623
 					$user_notified = true;
548
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
624
+					if($action == 'stop' || $action == 'fail')
625
+					{
626
+break; } // stop running through chain
549 627
 				}
550 628
 				// check if the user has been notified at all
551
-				if(!$user_notified) {
629
+				if(!$user_notified)
630
+				{
552 631
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
553 632
 					foreach($backend_errors as $id=>$backend_error) {
554 633
 						error_log($backend_error);
555 634
 					}*/
556 635
 					$error = implode(', ', $backend_errors);
557
-					if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error;
636
+					if (stripos($error, (string)$receiver->handle) !== false)
637
+					{
638
+						$error = $receiver->handle.': '.$error;
639
+					}
558 640
 					self::$errors[] = $error;
559 641
 				}
560 642
 			}
@@ -574,23 +656,35 @@  discard block
 block discarded – undo
574 656
 	 * @param string $_message_popup
575 657
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
576 658
 	 */
577
-	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
578
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
659
+	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '')
660
+	{
661
+		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup))
662
+		{
663
+return false; } // no message set
579 664
 		$messages = array();
580 665
 
581 666
 		// create the messages
582
-		if(!empty($_message_plain)) {
667
+		if(!empty($_message_plain))
668
+		{
583 669
 			$messages['plain'] = $_message_plain;
584
-		} else {
670
+		}
671
+		else
672
+		{
585 673
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
586 674
 		}
587 675
 
588
-		if(!empty($_message_html)) {
676
+		if(!empty($_message_html))
677
+		{
589 678
 			$messages['html'] = $_message_html;
590
-		} else {
679
+		}
680
+		else
681
+		{
591 682
 			$messages['html'] = self::plain2html($_message_plain);
592 683
 		}
593
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
684
+		if (!empty($_message_popup))
685
+		{
686
+			$messages['popup']=$_message_popup;
687
+		}
594 688
 		return $messages;
595 689
 	}
596 690
 
@@ -612,10 +706,14 @@  discard block
 block discarded – undo
612 706
 	 * @param string $_prepend just a plain message to prepend, no html!
613 707
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
614 708
 	 */
615
-	 private function prepend_message(array $_messages, $_prepend = null) {
616
-		if(strlen($_prepend) > 0) {
617
-			foreach($_messages as $key => $value) {
618
-				switch($key) {
709
+	 private function prepend_message(array $_messages, $_prepend = null)
710
+	 {
711
+		if(strlen($_prepend) > 0)
712
+		{
713
+			foreach($_messages as $key => $value)
714
+			{
715
+				switch($key)
716
+				{
619 717
 					case 'plain':
620 718
 						$_messages[$key] = $_prepend."\n\n".$value;
621 719
 						break;
@@ -642,14 +740,19 @@  discard block
 block discarded – undo
642 740
 	private function get_addresspart($_address, $_part='email')
643 741
 	{
644 742
 		$parts = null;
645
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
743
+	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts))
744
+	 	{
745
+// _address contains a fullname part
646 746
 	 		$fullname = trim(trim($parts[1]),'\"');
647 747
 	 		$email = $parts[2];
648
-	 	} else {
748
+	 	}
749
+	 	else
750
+	 	{
649 751
 	 		$fullname = false;
650 752
 	 		$email = $_address;
651 753
 	 	}
652
-	 	switch($_part) {
754
+	 	switch($_part)
755
+	 	{
653 756
 	 		case 'fullname':
654 757
 	 			return $fullname;
655 758
 	 		case 'email':
@@ -668,11 +771,14 @@  discard block
 block discarded – undo
668 771
 	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669 772
 	 * @return array containing notification chains, output like given in $_output
670 773
 	 */
671
-	public function get_available_chains($_output = 'routing') {
774
+	public function get_available_chains($_output = 'routing')
775
+	{
672 776
 		// determine enabled backends from Api\Config
673 777
 		$enabled_backends = array();
674
-		foreach($this->backends as $backend) {
675
-			switch($backend) {
778
+		foreach($this->backends as $backend)
779
+		{
780
+			switch($backend)
781
+			{
676 782
 				case 'email':
677 783
 				case 'popup':
678 784
 				case 'jpopup':
@@ -687,17 +793,24 @@  discard block
 block discarded – undo
687 793
 
688 794
 		$enabled_chains = array();
689 795
 		$disabled_chains = array();
690
-		foreach($this->notification_chains as $key => $chain) {
796
+		foreach($this->notification_chains as $key => $chain)
797
+		{
691 798
 			$allow_chain = true;
692
-			if(is_array($chain)) {
693
-				foreach(array_keys($chain) as $name) {
694
-					if(!$enabled_backends[$name]) {
799
+			if(is_array($chain))
800
+			{
801
+				foreach(array_keys($chain) as $name)
802
+				{
803
+					if(!$enabled_backends[$name])
804
+					{
695 805
 						$allow_chain = false; // disable whole chain if one backend is disabled
696 806
 					}
697 807
 				}
698
-				if($allow_chain) {
808
+				if($allow_chain)
809
+				{
699 810
 					$enabled_chains[$key] = $chain;
700
-				} else {
811
+				}
812
+				else
813
+				{
701 814
 					$disabled_chains[$key] = $chain;
702 815
 				}
703 816
 			}
@@ -710,15 +823,18 @@  discard block
 block discarded – undo
710 823
 		// create the 'all' chain from the enabled backends
711 824
 		$chain_all = array();
712 825
 		$backend_count = 1;
713
-		foreach($enabled_backends as $backend => $enabled) {
714
-			if($enabled) {
826
+		foreach($enabled_backends as $backend => $enabled)
827
+		{
828
+			if($enabled)
829
+			{
715 830
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
716 831
 			}
717 832
 			$backend_count++;
718 833
 		}
719 834
 		$common_chains['all'] = $chain_all;
720 835
 
721
-		switch($_output) {
836
+		switch($_output)
837
+		{
722 838
 			case 'human':
723 839
 				$chain_groups = array(
724 840
 					lang('Common chains')	=> 'common_chains',
@@ -727,20 +843,27 @@  discard block
 block discarded – undo
727 843
 					);
728 844
 				$suffix = '_human';
729 845
 				// create descriptions for each chain key in each group
730
-				foreach($chain_groups as $name => $arr_name) {
846
+				foreach($chain_groups as $name => $arr_name)
847
+				{
731 848
 					${$arr_name.$suffix} = array();
732
-					foreach(array_keys(${$arr_name}) as $key) {
733
-						if($arr_name == 'disabled_chains') {
849
+					foreach(array_keys(${$arr_name}) as $key)
850
+					{
851
+						if($arr_name == 'disabled_chains')
852
+						{
734 853
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
735
-						} else {
854
+						}
855
+						else
856
+						{
736 857
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
737 858
 						}
738 859
 					}
739 860
 				}
740 861
 				// summarize all groups with minimum one chain to the final array
741 862
 				$chains_final = array();
742
-				foreach($chain_groups as $name => $arr_name) {
743
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
863
+				foreach($chain_groups as $name => $arr_name)
864
+				{
865
+					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0)
866
+					{
744 867
 						$chains_final[$name] = ${$arr_name.$suffix};
745 868
 					}
746 869
 				}
@@ -759,10 +882,13 @@  discard block
 block discarded – undo
759 882
 	 *
760 883
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
761 884
 	 */
762
-	public function deleteaccount($settings) {
763
-		foreach($this->backends as $backend) {
885
+	public function deleteaccount($settings)
886
+	{
887
+		foreach($this->backends as $backend)
888
+		{
764 889
 			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
765
-			if (is_callable($backend_hook)) {
890
+			if (is_callable($backend_hook))
891
+			{
766 892
 				call_user_func($backend_hook,$settings);
767 893
 			}
768 894
 		}
Please login to merge, or discard this patch.
notifications/inc/class.notifications_email.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 	 * @param array $_links
132 132
 	 * @param boolean $_render_html
133 133
 	 * @param boolean $_render_external
134
-	 * @return plain or html rendered link(s) as complete string
134
+	 * @return false|string or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137 137
 		if(!is_array($_links) || count($_links) == 0) { return false; }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 	 * @param object $_preferences
67 67
 	 */
68 68
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
70
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
71 71
 		$this->sender = $_sender;
72 72
 		$this->recipient = $_recipient;
73 73
 		$this->config = $_config;
74 74
 		$this->preferences = $_preferences;
75
-		if(is_object($this->mail))
75
+		if (is_object($this->mail))
76 76
 		{
77 77
 			unset($this->mail);
78 78
 		}
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 		$this->mail->setFrom($this->sender->account_email, $this->sender->account_fullname);
105 105
 
106 106
 		$this->mail->addHeader('Subject', trim($_subject)); // trim the subject to avoid strange wrong encoding problem
107
-		$this->mail->setHtmlBody($body_html, null, false);	// no automatic alternativ
107
+		$this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ
108 108
 		$this->mail->setBody($body_plain);
109 109
 
110
-		if(is_array($_attachments) && count($_attachments) > 0)
110
+		if (is_array($_attachments) && count($_attachments) > 0)
111 111
 		{
112
-			foreach($_attachments as $attachment)
112
+			foreach ($_attachments as $attachment)
113 113
 			{
114 114
 				if ($attachment->string)
115 115
 				{
116 116
 					$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
117 117
 				}
118
-				elseif($attachment->path)
118
+				elseif ($attachment->path)
119 119
 				{
120 120
 					$this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type);
121 121
 				}
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
 	 * @return plain or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137
-		if(!is_array($_links) || count($_links) == 0) { return false; }
137
+		if (!is_array($_links) || count($_links) == 0) { return false; }
138 138
 
139 139
 		// provide defaults if given arguments are null
140 140
 		// php distinguishes between missing and present(null) arguments
141
-		if(is_null($_render_html)) { $_render_html = false; }
142
-		if(is_null($_render_external)) { $_render_external = true; }
141
+		if (is_null($_render_html)) { $_render_html = false; }
142
+		if (is_null($_render_external)) { $_render_external = true; }
143 143
 		$newline = $_render_html ? "<br />" : "\n";
144 144
 		$hruler = $_render_html ? Api\Html::hr() : '';
145 145
 
146 146
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
147
+		foreach ($_links as $link) {
148
+			if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; }
149 149
 			// do not expose sensitive data
150
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
150
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', Api\Html::link('/index.php', $link->view));
151 151
 			// complete missing protocol and domain part if needed
152 152
 			if ($url{0} == '/' && $_render_external) {
153 153
 				$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			$rendered_links[] = $_render_html ? $a_href : $url;
158 158
 		}
159 159
 
160
-		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links);
160
+		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links);
161 161
 	}
162 162
 
163 163
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via email.
17 17
  */
18
-class notifications_email implements notifications_iface {
18
+class notifications_email implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -65,9 +66,14 @@  discard block
 block discarded – undo
65 66
 	 * @param object $_config
66 67
 	 * @param object $_preferences
67 68
 	 */
68
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
70
+	{
71
+		if(!is_object($_sender))
72
+		{
73
+throw new Exception("no sender given."); }
74
+		if(!is_object($_recipient))
75
+		{
76
+throw new Exception("no recipient given."); }
71 77
 		$this->sender = $_sender;
72 78
 		$this->recipient = $_recipient;
73 79
 		$this->config = $_config;
@@ -133,23 +139,34 @@  discard block
 block discarded – undo
133 139
 	 * @param boolean $_render_external
134 140
 	 * @return plain or html rendered link(s) as complete string
135 141
 	 */
136
-	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137
-		if(!is_array($_links) || count($_links) == 0) { return false; }
142
+	private function render_links($_links = false, $_render_html = false, $_render_external = true)
143
+	{
144
+		if(!is_array($_links) || count($_links) == 0)
145
+		{
146
+return false; }
138 147
 
139 148
 		// provide defaults if given arguments are null
140 149
 		// php distinguishes between missing and present(null) arguments
141
-		if(is_null($_render_html)) { $_render_html = false; }
142
-		if(is_null($_render_external)) { $_render_external = true; }
150
+		if(is_null($_render_html))
151
+		{
152
+$_render_html = false; }
153
+		if(is_null($_render_external))
154
+		{
155
+$_render_external = true; }
143 156
 		$newline = $_render_html ? "<br />" : "\n";
144 157
 		$hruler = $_render_html ? Api\Html::hr() : '';
145 158
 
146 159
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
160
+		foreach($_links as $link)
161
+		{
162
+			if($_render_external || ! $link->popup)
163
+			{
164
+$link->view['no_popup'] = 1; }
149 165
 			// do not expose sensitive data
150 166
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
151 167
 			// complete missing protocol and domain part if needed
152
-			if ($url{0} == '/' && $_render_external) {
168
+			if ($url{0} == '/' && $_render_external)
169
+			{
153 170
 				$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
154 171
 					($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$url;
155 172
 			}
Please login to merge, or discard this patch.
notifications/inc/class.notifications_jpopup.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,6 @@
 block discarded – undo
152 152
 	* saves notification into database so that the client can fetch it from there
153 153
 	*
154 154
 	* @param string $_message
155
-	* @param array $_user_sessions
156 155
 	*/
157 156
 	private function save( $_message ) {
158 157
 		$result = $this->db->insert( self::_notification_table, array(
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,63 +15,63 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
 	/**
18
-	* Appname
19
-	*/
18
+	 * Appname
19
+	 */
20 20
 	const _appname = 'notifications';
21 21
 
22 22
 	/**
23
-	* Notification table in SQL database
24
-	*/
23
+	 * Notification table in SQL database
24
+	 */
25 25
 	const _notification_table = 'egw_notificationpopup';
26 26
 
27 27
 	/**
28
-	* Notification type
29
-	*/
28
+	 * Notification type
29
+	 */
30 30
 	const _type = 'jpopup';
31 31
 
32 32
 	/**
33
-	* holds account object for user who sends the message
34
-	*
35
-	* @var object
36
-	*/
33
+	 * holds account object for user who sends the message
34
+	 *
35
+	 * @var object
36
+	 */
37 37
 	private $sender;
38 38
 
39 39
 	/**
40
-	* holds account object for user to notify
41
-	*
42
-	* @var object
43
-	*/
40
+	 * holds account object for user to notify
41
+	 *
42
+	 * @var object
43
+	 */
44 44
 	private $recipient;
45 45
 
46 46
 	/**
47
-	* holds config object (sitewide application config)
48
-	*
49
-	* @var object
50
-	*/
47
+	 * holds config object (sitewide application config)
48
+	 *
49
+	 * @var object
50
+	 */
51 51
 	private $config;
52 52
 
53 53
 	/**
54
-	* holds preferences object of user to notify
55
-	*
56
-	* @var object
57
-	*/
54
+	 * holds preferences object of user to notify
55
+	 *
56
+	 * @var object
57
+	 */
58 58
 	private $preferences;
59 59
 
60 60
 	/**
61
-	* holds db object of SQL database
62
-	*
63
-	* @var Api\Db
64
-	*/
61
+	 * holds db object of SQL database
62
+	 *
63
+	 * @var Api\Db
64
+	 */
65 65
 	private $db;
66 66
 
67 67
 	/**
68
-	* constructor of notifications_egwpopup
69
-	*
70
-	* @param object $_sender
71
-	* @param object $_recipient
72
-	* @param object $_config
73
-	* @param object $_preferences
74
-	*/
68
+	 * constructor of notifications_egwpopup
69
+	 *
70
+	 * @param object $_sender
71
+	 * @param object $_recipient
72
+	 * @param object $_config
73
+	 * @param object $_preferences
74
+	 */
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77 77
 		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	/**
88
-	* sends notification if user is online
89
-	*
90
-	* @param array $_messages
91
-	* @param string $_subject
92
-	* @param array $_links
93
-	* @param array $_attachments
94
-	*/
88
+	 * sends notification if user is online
89
+	 *
90
+	 * @param array $_messages
91
+	 * @param string $_subject
92
+	 * @param array $_links
93
+	 * @param array $_attachments
94
+	 */
95 95
 	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false)
96 96
 	{
97 97
 		unset($_attachments);	// not used
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	* renders additional infos from sender and subject
137
-	*
138
-	* @param string $_subject
139
-	* @return string html rendered info as complete string
140
-	*/
136
+	 * renders additional infos from sender and subject
137
+	 *
138
+	 * @param string $_subject
139
+	 * @return string html rendered info as complete string
140
+	 */
141 141
 	private function render_infos($_subject = false) {
142 142
 		$infos = array();
143 143
 		$newline = "<br />";
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* saves notification into database so that the client can fetch it from there
153
-	*
154
-	* @param string $_message
155
-	* @param array $_user_sessions
156
-	*/
152
+	 * saves notification into database so that the client can fetch it from there
153
+	 *
154
+	 * @param string $_message
155
+	 * @param array $_user_sessions
156
+	 */
157 157
 	private function save( $_message ) {
158 158
 		$result = $this->db->insert( self::_notification_table, array(
159 159
 			'account_id'     => $this->recipient->account_id,
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	*/
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77
-		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
78
-		if( !is_object($_recipient) ) { throw new Exception("no recipient given."); }
77
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
78
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
79 79
 
80 80
 		$this->sender		= $_sender;
81
-		$this->recipient	= $_recipient;
81
+		$this->recipient = $_recipient;
82 82
 		$this->config		= $_config;
83
-		$this->preferences	= $_preferences;
84
-		$this->db			= $GLOBALS['egw']->db;
83
+		$this->preferences = $_preferences;
84
+		$this->db = $GLOBALS['egw']->db;
85 85
 	}
86 86
 
87 87
 	/**
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
 	* @param array $_links
93 93
 	* @param array $_attachments
94 94
 	*/
95
-	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false)
95
+	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
96 96
 	{
97
-		unset($_attachments);	// not used
97
+		unset($_attachments); // not used
98 98
 
99 99
 		$jmessage = array();
100 100
 
101 101
 		// app-message
102
-		if( ($_links != null) && (count($_links) > 0) )
102
+		if (($_links != null) && (count($_links) > 0))
103 103
 		{
104
-			$tlink		= $_links[0];
105
-			$appname	= "";
104
+			$tlink = $_links[0];
105
+			$appname = "";
106 106
 
107
-			if( key_exists('menuaction', $tlink->view) )
107
+			if (key_exists('menuaction', $tlink->view))
108 108
 			{
109 109
 				$tmp = explode(".", $tlink->view['menuaction']);
110 110
 				$appname = $tmp[0];
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 
113 113
 			$link = array();
114 114
 
115
-			foreach( $tlink->view as $pkey => $pvalue )
115
+			foreach ($tlink->view as $pkey => $pvalue)
116 116
 			{
117
-				$link[] = $pkey . '=' . $pvalue;
117
+				$link[] = $pkey.'='.$pvalue;
118 118
 			}
119 119
 
120 120
 			// TODO more links?
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 			.Api\Html::hr()
126 126
 			.$_messages['html'];
127 127
 
128
-		$jmessage['msghtml']	= $message;
129
-		$jmessage['app']		= $appname;
128
+		$jmessage['msghtml'] = $message;
129
+		$jmessage['app'] = $appname;
130 130
 
131 131
 
132
-		$this->save( serialize($jmessage) );
132
+		$this->save(serialize($jmessage));
133 133
 	}
134 134
 
135 135
 	/**
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 
145 145
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
146 146
 		$infos[] = lang('Message from').': '.$sender;
147
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
148
-		return implode($newline,$infos);
147
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
148
+		return implode($newline, $infos);
149 149
 	}
150 150
 
151 151
 	/**
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 	* @param string $_message
155 155
 	* @param array $_user_sessions
156 156
 	*/
157
-	private function save( $_message ) {
158
-		$result = $this->db->insert( self::_notification_table, array(
157
+	private function save($_message) {
158
+		$result = $this->db->insert(self::_notification_table, array(
159 159
 			'account_id'     => $this->recipient->account_id,
160 160
 			'notify_message' => $_message,
161 161
 			'notify_type'	 => self::_type
162
-			), false,__LINE__,__FILE__,self::_appname);
162
+			), false, __LINE__, __FILE__, self::_appname);
163 163
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
164 164
 	}
165 165
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,8 +74,12 @@  discard block
 block discarded – undo
74 74
 	*/
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77
-		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
78
-		if( !is_object($_recipient) ) { throw new Exception("no recipient given."); }
77
+		if( !is_object($_sender) )
78
+		{
79
+throw new Exception("no sender given."); }
80
+		if( !is_object($_recipient) )
81
+		{
82
+throw new Exception("no recipient given."); }
79 83
 
80 84
 		$this->sender		= $_sender;
81 85
 		$this->recipient	= $_recipient;
@@ -138,13 +142,16 @@  discard block
 block discarded – undo
138 142
 	* @param string $_subject
139 143
 	* @return string html rendered info as complete string
140 144
 	*/
141
-	private function render_infos($_subject = false) {
145
+	private function render_infos($_subject = false)
146
+	{
142 147
 		$infos = array();
143 148
 		$newline = "<br />";
144 149
 
145 150
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
146 151
 		$infos[] = lang('Message from').': '.$sender;
147
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
152
+		if(!empty($_subject))
153
+		{
154
+$infos[] = Api\Html::bold($_subject); }
148 155
 		return implode($newline,$infos);
149 156
 	}
150 157
 
@@ -154,12 +161,16 @@  discard block
 block discarded – undo
154 161
 	* @param string $_message
155 162
 	* @param array $_user_sessions
156 163
 	*/
157
-	private function save( $_message ) {
164
+	private function save( $_message )
165
+	{
158 166
 		$result = $this->db->insert( self::_notification_table, array(
159 167
 			'account_id'     => $this->recipient->account_id,
160 168
 			'notify_message' => $_message,
161 169
 			'notify_type'	 => self::_type
162 170
 			), false,__LINE__,__FILE__,self::_appname);
163
-		if ($result === false) throw new Exception("Can't save notification into SQL table");
171
+		if ($result === false)
172
+		{
173
+			throw new Exception("Can't save notification into SQL table");
174
+		}
164 175
 	}
165 176
 }
Please login to merge, or discard this patch.
notifications/inc/class.notifications_popup.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,6 @@
 block discarded – undo
121 121
 	 * saves notification into database so that the client can fetch it from there
122 122
 	 *
123 123
 	 * @param string $_message
124
-	 * @param array $_user_sessions
125 124
 	 */
126 125
 	private function save( $_message ) {
127 126
 		$result = $this->db->insert( self::_notification_table, array(
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
85 85
 		//error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)');
86
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
87
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
87
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
88 88
 		$this->sender = $_sender;
89 89
 		$this->recipient = $_recipient;
90 90
 		$this->config = $_config;
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
104 104
 	{
105
-		unset($_attachments);	// not used
105
+		unset($_attachments); // not used
106 106
 		// Check access log to see if user is still logged in
107
-		if ( !Api\Session::notifications_active($this->recipient->account_id) )
107
+		if (!Api\Session::notifications_active($this->recipient->account_id))
108 108
 		{
109 109
 			throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
110 110
 		}
111 111
 
112
-		$message = 	$this->render_infos($_subject)
112
+		$message = $this->render_infos($_subject)
113 113
 					.Api\Html::hr()
114
-					.(isset($_messages['popup'])&&!empty($_messages['popup'])?$_messages['popup']:$_messages['html'])
114
+					.(isset($_messages['popup']) && !empty($_messages['popup']) ? $_messages['popup'] : $_messages['html'])
115 115
 					.$this->render_links($_links);
116 116
 
117
-		$this->save( $message );
117
+		$this->save($message);
118 118
 	}
119 119
 
120 120
 	/**
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 * @param string $_message
124 124
 	 * @param array $_user_sessions
125 125
 	 */
126
-	private function save( $_message ) {
127
-		$result = $this->db->insert( self::_notification_table, array(
126
+	private function save($_message) {
127
+		$result = $this->db->insert(self::_notification_table, array(
128 128
 			'account_id'     => $this->recipient->account_id,
129 129
 			'notify_message' => $_message,
130 130
 			'notify_type'	 => self::_type
131
-			), false,__LINE__,__FILE__,self::_appname);
131
+			), false, __LINE__, __FILE__, self::_appname);
132 132
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
133 133
 	}
134 134
 
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 	 * @return string html rendered link(s) as complete string with jspopup or a new window
141 141
 	 */
142 142
 	private function render_links($_links = false) {
143
-		if(!is_array($_links) || count($_links) == 0) { return false; }
143
+		if (!is_array($_links) || count($_links) == 0) { return false; }
144 144
 		$newline = "<br />";
145 145
 
146 146
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if(!$link->popup) { $link->view['no_popup'] = 1; }
147
+		foreach ($_links as $link) {
148
+			if (!$link->popup) { $link->view['no_popup'] = 1; }
149 149
 
150 150
 			// do not expose sensitive data
151
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',
151
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '',
152 152
 				Api\Html::link('/index.php', $link->view));
153 153
 			// extract application-icon from menuaction
154
-			if($link->view['menuaction']) {
155
-				$menuaction_arr = explode('.',$link->view['menuaction']);
154
+			if ($link->view['menuaction']) {
155
+				$menuaction_arr = explode('.', $link->view['menuaction']);
156 156
 				$application = $menuaction_arr[0];
157
-				$image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
157
+				$image = $application ? Api\Html::image($application, 'navbar', $link->text, 'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
158 158
 			} else {
159 159
 				$image = '';
160 160
 			}
161
-			if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
161
+			if ($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
162 162
 			{
163 163
 				$data = array(
164 164
 					"data-app = '{$link->app}'",
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 					"data-popup = '{$link->popup}'"
168 168
 				);
169 169
 
170
-				$rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link');
170
+				$rendered_links[] = Api\Html::div($image.$link->text, implode(' ', $data), 'link');
171 171
 			} else {
172
-				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link');
172
+				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>', '', 'link');
173 173
 			}
174 174
 
175 175
 		}
176
-		if(count($rendered_links) > 0) {
177
-			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
176
+		if (count($rendered_links) > 0) {
177
+			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline, $rendered_links);
178 178
 		}
179 179
 	}
180 180
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	 * @param int $height =400 height of the window
188 188
 	 * @return string javascript (using single quotes)
189 189
 	 */
190
-	private function jspopup($link,$target='_blank',$width=750,$height=410)
190
+	private function jspopup($link, $target = '_blank', $width = 750, $height = 410)
191 191
 	{
192
-		if($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
192
+		if ($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
193 193
 		{
194 194
 			return 'window.open('.($link == 'this.href' ? $link : "'".$link."'").','.
195 195
 				($target == 'this.target' ? $target : "'".$target."'").",$width,$height,'yes')";
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 
214 214
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
215 215
 		$infos[] = lang('Message from').': '.$sender;
216
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
217
-		return implode($newline,$infos);
216
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
217
+		return implode($newline, $infos);
218 218
 	}
219 219
 
220 220
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
224 224
 	 */
225 225
 	public static function deleteaccount($settings) {
226
-		$GLOBALS['egw']->db->delete( self::_notification_table, array(
226
+		$GLOBALS['egw']->db->delete(self::_notification_table, array(
227 227
 			'account_id'	=> $settings['account_id']
228
-		),__LINE__,__FILE__,self::_appname);
228
+		), __LINE__, __FILE__, self::_appname);
229 229
 	}
230 230
 }
Please login to merge, or discard this patch.
Braces   +43 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
  * out the table to look if there is a notificaton for this
22 22
  * client. The second stage is done in class.notifications_ajax.inc.php
23 23
  */
24
-class notifications_popup implements notifications_iface {
24
+class notifications_popup implements notifications_iface
25
+{
25 26
 
26 27
 	/**
27 28
 	 * Appname
@@ -81,10 +82,15 @@  discard block
 block discarded – undo
81 82
 	 * @param object $_config
82 83
 	 * @param object $_preferences
83 84
 	 */
84
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
85
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
86
+	{
85 87
 		//error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)');
86
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
87
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
88
+		if(!is_object($_sender))
89
+		{
90
+throw new Exception("no sender given."); }
91
+		if(!is_object($_recipient))
92
+		{
93
+throw new Exception("no recipient given."); }
88 94
 		$this->sender = $_sender;
89 95
 		$this->recipient = $_recipient;
90 96
 		$this->config = $_config;
@@ -123,13 +129,17 @@  discard block
 block discarded – undo
123 129
 	 * @param string $_message
124 130
 	 * @param array $_user_sessions
125 131
 	 */
126
-	private function save( $_message ) {
132
+	private function save( $_message )
133
+	{
127 134
 		$result = $this->db->insert( self::_notification_table, array(
128 135
 			'account_id'     => $this->recipient->account_id,
129 136
 			'notify_message' => $_message,
130 137
 			'notify_type'	 => self::_type
131 138
 			), false,__LINE__,__FILE__,self::_appname);
132
-		if ($result === false) throw new Exception("Can't save notification into SQL table");
139
+		if ($result === false)
140
+		{
141
+			throw new Exception("Can't save notification into SQL table");
142
+		}
133 143
 	}
134 144
 
135 145
 	/**
@@ -139,23 +149,32 @@  discard block
 block discarded – undo
139 149
 	 * @param array $_links
140 150
 	 * @return string html rendered link(s) as complete string with jspopup or a new window
141 151
 	 */
142
-	private function render_links($_links = false) {
143
-		if(!is_array($_links) || count($_links) == 0) { return false; }
152
+	private function render_links($_links = false)
153
+	{
154
+		if(!is_array($_links) || count($_links) == 0)
155
+		{
156
+return false; }
144 157
 		$newline = "<br />";
145 158
 
146 159
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if(!$link->popup) { $link->view['no_popup'] = 1; }
160
+		foreach($_links as $link)
161
+		{
162
+			if(!$link->popup)
163
+			{
164
+$link->view['no_popup'] = 1; }
149 165
 
150 166
 			// do not expose sensitive data
151 167
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',
152 168
 				Api\Html::link('/index.php', $link->view));
153 169
 			// extract application-icon from menuaction
154
-			if($link->view['menuaction']) {
170
+			if($link->view['menuaction'])
171
+			{
155 172
 				$menuaction_arr = explode('.',$link->view['menuaction']);
156 173
 				$application = $menuaction_arr[0];
157 174
 				$image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
158
-			} else {
175
+			}
176
+			else
177
+			{
159 178
 				$image = '';
160 179
 			}
161 180
 			if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
@@ -168,12 +187,15 @@  discard block
 block discarded – undo
168 187
 				);
169 188
 
170 189
 				$rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link');
171
-			} else {
190
+			}
191
+			else
192
+			{
172 193
 				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link');
173 194
 			}
174 195
 
175 196
 		}
176
-		if(count($rendered_links) > 0) {
197
+		if(count($rendered_links) > 0)
198
+		{
177 199
 			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
178 200
 		}
179 201
 	}
@@ -207,13 +229,16 @@  discard block
 block discarded – undo
207 229
 	 * @param string $_subject
208 230
 	 * @return string html rendered info as complete string
209 231
 	 */
210
-	private function render_infos($_subject = false) {
232
+	private function render_infos($_subject = false)
233
+	{
211 234
 		$infos = array();
212 235
 		$newline = "<br />";
213 236
 
214 237
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
215 238
 		$infos[] = lang('Message from').': '.$sender;
216
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
239
+		if(!empty($_subject))
240
+		{
241
+$infos[] = Api\Html::bold($_subject); }
217 242
 		return implode($newline,$infos);
218 243
 	}
219 244
 
@@ -222,7 +247,8 @@  discard block
 block discarded – undo
222 247
 	 *
223 248
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
224 249
 	 */
225
-	public static function deleteaccount($settings) {
250
+	public static function deleteaccount($settings)
251
+	{
226 252
 		$GLOBALS['egw']->db->delete( self::_notification_table, array(
227 253
 			'account_id'	=> $settings['account_id']
228 254
 		),__LINE__,__FILE__,self::_appname);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
 		// Check access log to see if user is still logged in
107 107
 		if ( !Api\Session::notifications_active($this->recipient->account_id) )
108 108
 		{
109
-			throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
109
+			throw new Exception("user {$this->recipient->account_lid} isn't online. Can't send notification via popup");
110 110
 		}
111 111
 
112 112
 		$message = 	$this->render_infos($_subject)
Please login to merge, or discard this patch.
notifications/inc/class.notifications_winpopup.inc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * checks for a valid IPv4-address without CIDR notation
156 156
 	 *
157 157
 	 * @param string $_ip
158
-	 * @return true or false
158
+	 * @return integer or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161 161
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * renders additional info from subject
166 166
 	 *
167 167
 	 * @param string $_subject
168
-	 * @return plain rendered info as complete string
168
+	 * @return string|false rendered info as complete string
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
Please login to merge, or discard this patch.
Braces   +43 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via winpopup.
17 17
  */
18
-class notifications_winpopup implements notifications_iface {
18
+class notifications_winpopup implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -80,10 +81,16 @@  discard block
 block discarded – undo
80 81
 	 * @param object $_config
81 82
 	 * @param object $_preferences
82 83
 	 */
83
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
84
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
85
+	{
86
+		if(!is_object($_sender))
87
+		{
88
+throw new Exception("no sender given."); }
89
+		if(!is_object($_recipient))
90
+		{
91
+throw new Exception("no recipient given."); }
92
+		if(!$this->netbios_command)
93
+		{
87 94
 			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
88 95
 									'Please check var "netbios_command" in winpopup backend '.
89 96
 									'('.EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.notifications_winpopup.inc.php).');
@@ -107,14 +114,20 @@  discard block
 block discarded – undo
107 114
 		unset($_links, $_attachments);	// not used
108 115
 
109 116
 		$user_sessions = array();
110
-		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
111
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
112
-				if($this->valid_ip($session['session_ip'])) {
117
+		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session)
118
+		{
119
+			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain'])
120
+			{
121
+				if($this->valid_ip($session['session_ip']))
122
+				{
113 123
 					$user_sessions[] = $session['session_ip'];
114 124
 				}
115 125
 			}
116 126
 		}
117
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
127
+		if ( empty($user_sessions) )
128
+		{
129
+			throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
130
+		}
118 131
 
119 132
 		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
120 133
 		return true;
@@ -126,13 +139,20 @@  discard block
 block discarded – undo
126 139
 	 * @param string $_message
127 140
 	 * @param array $_user_sessions
128 141
 	 */
129
-	private function send_winpopup( $_message, array $_user_sessions ) {
130
-		foreach($_user_sessions as $user_session) {
142
+	private function send_winpopup( $_message, array $_user_sessions )
143
+	{
144
+		foreach($_user_sessions as $user_session)
145
+		{
131 146
 			$ip_octets=explode(".",$user_session);
132 147
 			// format the ip_octets to 3 digits each
133
-			foreach($ip_octets as $id=>$ip_octet) {
134
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
135
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
148
+			foreach($ip_octets as $id=>$ip_octet)
149
+			{
150
+				if(strlen($ip_octet)==1)
151
+				{
152
+$ip_octets[$id] = '00'.$ip_octet; }
153
+				if(strlen($ip_octet)==2)
154
+				{
155
+$ip_octets[$id] = '0'.$ip_octet; }
136 156
 			}
137 157
 			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138 158
 									'/\[1\]/' => $ip_octets[0],
@@ -145,7 +165,8 @@  discard block
 block discarded – undo
145 165
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
146 166
 			$output = $returncode = null;
147 167
 			exec($command,$output,$returncode);
148
-			if($returncode != 0) {
168
+			if($returncode != 0)
169
+			{
149 170
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
150 171
 			}
151 172
 		}
@@ -157,7 +178,8 @@  discard block
 block discarded – undo
157 178
 	 * @param string $_ip
158 179
 	 * @return true or false
159 180
 	 */
160
-	private function valid_ip($_ip) {
181
+	private function valid_ip($_ip)
182
+	{
161 183
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
162 184
 	}
163 185
 
@@ -167,9 +189,12 @@  discard block
 block discarded – undo
167 189
 	 * @param string $_subject
168 190
 	 * @return plain rendered info as complete string
169 191
 	 */
170
-	private function render_infos($_subject = false) {
192
+	private function render_infos($_subject = false)
193
+	{
171 194
 		$newline = "\n";
172
-		if(!empty($_subject)) { return $_subject.$newline; }
195
+		if(!empty($_subject))
196
+		{
197
+return $_subject.$newline; }
173 198
 		return false;
174 199
 	}
175 200
 }
176 201
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	 * @param object $_preferences
82 82
 	 */
83 83
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
87
-			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
84
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
85
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!$this->netbios_command) {
87
+			throw new Exception('Winpopup plugin not configured yet. Skipped sending notification message. '.
88 88
 									'Please check var "netbios_command" in winpopup backend '.
89
-									'('.EGW_INCLUDE_ROOT. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
89
+									'('.EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.notifications_winpopup.inc.php).');
90 90
 		}
91 91
 		$this->sender = $_sender;
92 92
 		$this->recipient = $_recipient;
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
106 106
 	{
107
-		unset($_links, $_attachments);	// not used
107
+		unset($_links, $_attachments); // not used
108 108
 
109 109
 		$user_sessions = array();
110 110
 		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
111
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
112
-				if($this->valid_ip($session['session_ip'])) {
111
+			if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) {
112
+				if ($this->valid_ip($session['session_ip'])) {
113 113
 					$user_sessions[] = $session['session_ip'];
114 114
 				}
115 115
 			}
116 116
 		}
117
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
117
+		if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
118 118
 
119
-		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
119
+		$this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions);
120 120
 		return true;
121 121
 	}
122 122
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	 * @param string $_message
127 127
 	 * @param array $_user_sessions
128 128
 	 */
129
-	private function send_winpopup( $_message, array $_user_sessions ) {
130
-		foreach($_user_sessions as $user_session) {
131
-			$ip_octets=explode(".",$user_session);
129
+	private function send_winpopup($_message, array $_user_sessions) {
130
+		foreach ($_user_sessions as $user_session) {
131
+			$ip_octets = explode(".", $user_session);
132 132
 			// format the ip_octets to 3 digits each
133
-			foreach($ip_octets as $id=>$ip_octet) {
134
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
135
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
133
+			foreach ($ip_octets as $id=>$ip_octet) {
134
+				if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; }
135
+				if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; }
136 136
 			}
137
-			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
137
+			$placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138 138
 									'/\[1\]/' => $ip_octets[0],
139 139
 									'/\[2\]/' => $ip_octets[1],
140 140
 									'/\[3\]/' => $ip_octets[2],
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 									);
145 145
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
146 146
 			$output = $returncode = null;
147
-			exec($command,$output,$returncode);
148
-			if($returncode != 0) {
147
+			exec($command, $output, $returncode);
148
+			if ($returncode != 0) {
149 149
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
150 150
 			}
151 151
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return true or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161
-		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
161
+		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip);
162 162
 	}
163 163
 
164 164
 	/**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
172
-		if(!empty($_subject)) { return $_subject.$newline; }
172
+		if (!empty($_subject)) { return $_subject.$newline; }
173 173
 		return false;
174 174
 	}
175 175
 }
176 176
\ No newline at end of file
Please login to merge, or discard this patch.