Completed
Push — master ( 93853c...0bd975 )
by Klaus
26:31 queued 06:23
created
mail/inc/class.mail_ui.inc.php 1 patch
Braces   +915 added lines, -254 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
@@ -163,7 +175,10 @@  discard block
 block discarded – undo
163 175
 			// redirect to mail wizard to handle it (redirect works for ajax too)
164 176
 			self::callWizard($e->getMessage(),true,'error');
165 177
 		}
166
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
178
+		if (Mail::$debugTimes)
179
+		{
180
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
181
+		}
167 182
 	}
168 183
 
169 184
 	/**
@@ -222,16 +237,28 @@  discard block
 block discarded – undo
222 237
 	 */
223 238
 	function changeProfile($_icServerID,$unsetCache=false)
224 239
 	{
225
-		if (Mail::$debugTimes) $starttime = microtime (true);
240
+		if (Mail::$debugTimes)
241
+		{
242
+			$starttime = microtime (true);
243
+		}
226 244
 		if (self::$icServerID != $_icServerID)
227 245
 		{
228 246
 			self::$icServerID = $_icServerID;
229 247
 		}
230
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
248
+		if (Mail::$debug)
249
+		{
250
+			error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
251
+		}
231 252
 
232
-		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
253
+		if ($unsetCache)
254
+		{
255
+			Mail::unsetCachedObjects(self::$icServerID);
256
+		}
233 257
 		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
234
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
258
+		if (Mail::$debug)
259
+		{
260
+			error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
261
+		}
235 262
 		// no icServer Object: something failed big time
236 263
 		if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
237 264
 		{
@@ -241,14 +268,23 @@  discard block
 block discarded – undo
241 268
 
242 269
 		// save session varchar
243 270
 		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
244
-		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
245
-		if (true) $oldicServerID = self::$icServerID;
271
+		if ($oldicServerID <> self::$icServerID)
272
+		{
273
+			$this->mail_bo->openConnection(self::$icServerID);
274
+		}
275
+		if (true)
276
+		{
277
+			$oldicServerID = self::$icServerID;
278
+		}
246 279
 		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
247 280
 		{
248 281
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
249 282
 		}
250 283
 
251
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
284
+		if (Mail::$debugTimes)
285
+		{
286
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
287
+		}
252 288
 	}
253 289
 
254 290
 	/**
@@ -289,7 +325,8 @@  discard block
 block discarded – undo
289 325
 		// got subscribed or unsubscribed by the user
290 326
 		try {
291 327
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
292
-		} catch (Exception $ex) {
328
+		}
329
+		catch (Exception $ex) {
293 330
 			Framework::message($ex->getMessage());
294 331
 		}
295 332
 
@@ -323,9 +360,18 @@  discard block
 block discarded – undo
323 360
 						list(,$node) = explode($profileId.self::$delimiter, $path);
324 361
 						if ($node)
325 362
 						{
326
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
327
-							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
328
-							if ($value['value']) $cont[] = $path;
363
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value'])
364
+							{
365
+								$to_unsubscribe []= $node;
366
+							}
367
+							if (is_array($subscribed) && !$subscribed[$node] && $value['value'])
368
+							{
369
+								$to_subscribe [] = $node;
370
+							}
371
+							if ($value['value'])
372
+							{
373
+								$cont[] = $path;
374
+							}
329 375
 						}
330 376
 
331 377
 					}
@@ -414,7 +460,10 @@  discard block
 block discarded – undo
414 460
 		//error_log(__METHOD__.__LINE__.array2string($content));
415 461
 		try	{
416 462
 				//error_log(__METHOD__.__LINE__.function_backtrace());
417
-				if (Mail::$debugTimes) $starttime = microtime (true);
463
+				if (Mail::$debugTimes)
464
+				{
465
+					$starttime = microtime (true);
466
+				}
418 467
 				$this->mail_bo->restoreSessionData();
419 468
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
420 469
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -443,7 +492,10 @@  discard block
 block discarded – undo
443 492
 							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
444 493
 						);
445 494
 					}
446
-					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
495
+					if (Api\Header\UserAgent::mobile())
496
+					{
497
+						$content[self::$nm_index]['header_row'] = 'mail.index.header_right';
498
+					}
447 499
 				}
448 500
 
449 501
 				// These must always be set, even if $content is an array
@@ -477,13 +529,16 @@  discard block
 block discarded – undo
477 529
 				}
478 530
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
479 531
 				$quota = false;//$this->mail_bo->getQuotaRoot();
480
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
532
+				if($quota !== false && $quota['limit'] != 'NOT SET')
533
+				{
481 534
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
482 535
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
483 536
 					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
484 537
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
485 538
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
486
-				} else {
539
+				}
540
+				else
541
+				{
487 542
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
488 543
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
489 544
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -491,7 +546,8 @@  discard block
 block discarded – undo
491 546
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
492 547
 				$vacation = false;//$this->gatherVacation();
493 548
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
494
-				if($vacation) {
549
+				if($vacation)
550
+				{
495 551
 					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
496 552
 					{
497 553
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
@@ -525,19 +581,31 @@  discard block
 block discarded – undo
525 581
 					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
526 582
 					foreach($keywords as &$k)
527 583
 					{
528
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
584
+						if (array_key_exists($k,$this->statusTypes))
585
+						{
586
+							unset($this->statusTypes[$k]);
587
+						}
529 588
 					}
530 589
 				}
531 590
 
532
-				if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
533
-				if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
591
+				if (!isset($content[self::$nm_index]['foldertree']))
592
+				{
593
+					$content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
594
+				}
595
+				if (!isset($content[self::$nm_index]['selectedFolder']))
596
+				{
597
+					$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
598
+				}
534 599
 
535 600
 				$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
536 601
 
537 602
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
538 603
 				{
539 604
 					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
540
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
605
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
606
+					{
607
+						Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
608
+					}
541 609
 				}
542 610
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
543 611
 				{
@@ -747,10 +815,16 @@  discard block
 block discarded – undo
747 815
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions);
748 816
 
749 817
 				// sending preview toolbar actions
750
-				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
818
+				if ($content['mailSplitter'])
819
+				{
820
+					$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
821
+				}
751 822
 
752 823
 				// We need to send toolbar actions to client-side because view template needs them
753
-				if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions();
824
+				if (Api\Header\UserAgent::mobile())
825
+				{
826
+					$sel_options['toolbar'] = $this->get_toolbar_actions();
827
+				}
754 828
 
755 829
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
756 830
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
@@ -758,7 +832,10 @@  discard block
 block discarded – undo
758 832
 					$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'));
759 833
 				}
760 834
 				$readonlys = $preserv = array();
761
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
835
+				if (Mail::$debugTimes)
836
+				{
837
+					Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
838
+				}
762 839
 		}
763 840
 		catch (Exception $e)
764 841
 		{
@@ -768,7 +845,10 @@  discard block
 block discarded – undo
768 845
 			//return false;
769 846
 		}
770 847
 		// Check preview pane is enabled, then show spliter
771
-		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
848
+		if ($this->mail_bo->mailPreferences['previewPane'])
849
+		{
850
+			$etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
851
+		}
772 852
 
773 853
 		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
774 854
 	}
@@ -807,12 +887,18 @@  discard block
 block discarded – undo
807 887
 	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
808 888
 	{
809 889
 		$nodeID = $_GET['id'];
810
-		if (!is_null($_nodeID)) $nodeID = $_nodeID;
890
+		if (!is_null($_nodeID))
891
+		{
892
+			$nodeID = $_nodeID;
893
+		}
811 894
 		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
812 895
 		$fetchCounters = !is_null($_nodeID);
813 896
 		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
814 897
 
815
-		if (!empty($_folderName)) $fetchCounters = true;
898
+		if (!empty($_folderName))
899
+		{
900
+			$fetchCounters = true;
901
+		}
816 902
 
817 903
 		// Check if it is called for refresh root
818 904
 		// then we need to reinitialized the index tree
@@ -824,7 +910,10 @@  discard block
 block discarded – undo
824 910
 		{
825 911
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
826 912
 		}
827
-		if (!is_null($_nodeID)) return $data;
913
+		if (!is_null($_nodeID))
914
+		{
915
+			return $data;
916
+		}
828 917
 		Etemplate\Widget\Tree::send_quote_json($data);
829 918
 	}
830 919
 
@@ -890,7 +979,10 @@  discard block
 block discarded – undo
890 979
 				$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
891 980
 			}
892 981
 		}
893
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
982
+		if (!is_array($lastFoldersUsedForMoveCont))
983
+		{
984
+			$lastFoldersUsedForMoveCont=array();
985
+		}
894 986
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
895 987
 		{
896 988
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
@@ -906,9 +998,12 @@  discard block
 block discarded – undo
906 998
 						$moveaction .= $lastFolderUsedForMoveCont;
907 999
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
908 1000
 						//error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey);
909
-						if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1001
+						if ($this->mail_bo->folderExists($i))
1002
+						{
1003
+							// only 10 entries per mailaccount.Control this on setting the buffered folders
910 1004
 						{
911 1005
 							$fS['profileID'] = $this->mail_bo->profileID;
1006
+						}
912 1007
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
913 1008
 							$fS['shortDisplayName'] = $i;
914 1009
 							$moveactions[$moveaction] = $fS;
@@ -928,9 +1023,12 @@  discard block
 block discarded – undo
928 1023
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
929 1024
 				{
930 1025
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
931
-					if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1026
+					if (!empty($lastFolderUsedForMoveCont))
1027
+					{
1028
+						// only 10 entries per mailaccount.Control this on setting the buffered folders
932 1029
 					{
933 1030
 						$moveaction = 'move_'.$lastFolderUsedForMoveCont;
1031
+					}
934 1032
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
935 1033
 						$fS = array();
936 1034
 						$fS['profileID'] = $pid;
@@ -1033,7 +1131,9 @@  discard block
 block discarded – undo
1033 1131
 				'children' => $children,
1034 1132
 			);
1035 1133
 
1036
-		} else {
1134
+		}
1135
+		else
1136
+		{
1037 1137
 			$group++;
1038 1138
 		}
1039 1139
 
@@ -1308,21 +1408,33 @@  discard block
 block discarded – undo
1308 1408
 					$rows=array();
1309 1409
 					return 0;
1310 1410
 				}
1311
-				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1411
+				if (empty($folderName))
1412
+				{
1413
+					$query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1414
+				}
1312 1415
 			}
1313 1416
 		}
1314 1417
 		if (!isset($mail_ui))
1315 1418
 		{
1316 1419
 			$mail_ui = new mail_ui(true);	// run constructor for current profile
1317
-			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1420
+			if (empty($query['selectedFolder']))
1421
+			{
1422
+				$query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1423
+			}
1318 1424
 		}
1319 1425
 		//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
1320 1426
 		//Mail::$debugTimes=true;
1321
-		if (Mail::$debugTimes) $starttime = microtime(true);
1427
+		if (Mail::$debugTimes)
1428
+		{
1429
+			$starttime = microtime(true);
1430
+		}
1322 1431
 		//$query['search'] is the phrase in the searchbox
1323 1432
 
1324 1433
 		$mail_ui->mail_bo->restoreSessionData();
1325
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1434
+		if (isset($query['selectedFolder']))
1435
+		{
1436
+			$mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1437
+		}
1326 1438
 		$mail_ui->mail_bo->saveSessionData();
1327 1439
 
1328 1440
 		$sRToFetch = null;
@@ -1333,7 +1445,10 @@  discard block
 block discarded – undo
1333 1445
 			unset($app);
1334 1446
 		}
1335 1447
 		//save selected Folder to sessionData (mailbox)->currentFolder
1336
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1448
+		if (isset($query['selectedFolder']))
1449
+		{
1450
+			$mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1451
+		}
1337 1452
 		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1338 1453
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1339 1454
 		{
@@ -1366,8 +1481,16 @@  discard block
 block discarded – undo
1366 1481
 			}
1367 1482
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1368 1483
 			$cutoffdate = $cutoffdate2 = null;
1369
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1370
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1484
+			if ($query['startdate'])
1485
+			{
1486
+				$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
1487
+			}
1488
+			//SINCE, enddate
1489
+			if ($query['enddate'])
1490
+			{
1491
+				$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
1492
+			}
1493
+			//BEFORE, startdate
1371 1494
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1372 1495
 			$filter = array(
1373 1496
 				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -1376,15 +1499,24 @@  discard block
 block discarded – undo
1376 1499
 				'status' => 'any',
1377 1500
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1378 1501
 			);
1379
-			if ($query['enddate']||$query['startdate']) {
1502
+			if ($query['enddate']||$query['startdate'])
1503
+			{
1380 1504
 				$filter['range'] = "BETWEEN";
1381
-				if ($cutoffdate) {
1505
+				if ($cutoffdate)
1506
+				{
1382 1507
 					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1383
-					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1508
+					if (empty($cutoffdate2))
1509
+					{
1510
+						$filter['range'] = "SINCE";
1511
+					}
1384 1512
 				}
1385
-				if ($cutoffdate2) {
1513
+				if ($cutoffdate2)
1514
+				{
1386 1515
 					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1387
-					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1516
+					if (empty($cutoffdate))
1517
+					{
1518
+						$filter['range'] = "BEFORE";
1519
+					}
1388 1520
 				}
1389 1521
 			}
1390 1522
 		}
@@ -1436,7 +1568,10 @@  discard block
 block discarded – undo
1436 1568
 				$rowsFetched['messages'] = $_sR['count'];
1437 1569
 				$ids = $_sR['match']->ids;
1438 1570
 				// if $sR is false, something failed fundamentally
1439
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1571
+				if($reverse === true)
1572
+				{
1573
+					$ids = ($ids===false?array():array_reverse((array)$ids));
1574
+				}
1440 1575
 				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1441 1576
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1442 1577
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
@@ -1502,7 +1637,10 @@  discard block
 block discarded – undo
1502 1637
 				}
1503 1638
 				else
1504 1639
 				{
1505
-					if (!empty($v)) $sortResult['header'][] = array('uid'=>$v);
1640
+					if (!empty($v))
1641
+					{
1642
+						$sortResult['header'][] = array('uid'=>$v);
1643
+					}
1506 1644
 				}
1507 1645
 			}
1508 1646
 		}
@@ -1511,15 +1649,24 @@  discard block
 block discarded – undo
1511 1649
 			$sortResult = $sortResultwH;
1512 1650
 		}
1513 1651
 		$rowsFetched['rowsFetched'] = count($sortResult['header']);
1514
-		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1652
+		if (empty($rowsFetched['messages']))
1653
+		{
1654
+			$rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1655
+		}
1515 1656
 
1516 1657
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1517 1658
 		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1518
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1659
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE')
1660
+		{
1661
+			unset($cols[0]);
1662
+		}
1519 1663
 		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1520 1664
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1521 1665
 
1522
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1666
+		if (Mail::$debugTimes)
1667
+		{
1668
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1669
+		}
1523 1670
 		return $rowsFetched['messages'];
1524 1671
 	}
1525 1672
 
@@ -1621,7 +1768,10 @@  discard block
 block discarded – undo
1621 1768
 					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1622 1769
 					break;
1623 1770
 				default:
1624
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1771
+					if (isset($actions[$act]))
1772
+					{
1773
+						$actionsenabled[$act]=$actions[$act];
1774
+					}
1625 1775
 			}
1626 1776
 		}
1627 1777
 		unset($actionsenabled['drag_mail']);
@@ -1643,7 +1793,10 @@  discard block
 block discarded – undo
1643 1793
 	 */
1644 1794
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1645 1795
 	{
1646
-		if (Mail::$debugTimes) $starttime = microtime(true);
1796
+		if (Mail::$debugTimes)
1797
+		{
1798
+			$starttime = microtime(true);
1799
+		}
1647 1800
 		$rv = array();
1648 1801
 		$i=0;
1649 1802
 		foreach((array)$_headers as $header)
@@ -1656,17 +1809,50 @@  discard block
 block discarded – undo
1656 1809
 			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1657 1810
 
1658 1811
 			$flags = "";
1659
-			if(!empty($header['recent'])) $flags .= "R";
1660
-			if(!empty($header['flagged'])) $flags .= "F";
1661
-			if(!empty($header['answered'])) $flags .= "A";
1662
-			if(!empty($header['forwarded'])) $flags .= "W";
1663
-			if(!empty($header['deleted'])) $flags .= "D";
1664
-			if(!empty($header['seen'])) $flags .= "S";
1665
-			if(!empty($header['label1'])) $flags .= "1";
1666
-			if(!empty($header['label2'])) $flags .= "2";
1667
-			if(!empty($header['label3'])) $flags .= "3";
1668
-			if(!empty($header['label4'])) $flags .= "4";
1669
-			if(!empty($header['label5'])) $flags .= "5";
1812
+			if(!empty($header['recent']))
1813
+			{
1814
+				$flags .= "R";
1815
+			}
1816
+			if(!empty($header['flagged']))
1817
+			{
1818
+				$flags .= "F";
1819
+			}
1820
+			if(!empty($header['answered']))
1821
+			{
1822
+				$flags .= "A";
1823
+			}
1824
+			if(!empty($header['forwarded']))
1825
+			{
1826
+				$flags .= "W";
1827
+			}
1828
+			if(!empty($header['deleted']))
1829
+			{
1830
+				$flags .= "D";
1831
+			}
1832
+			if(!empty($header['seen']))
1833
+			{
1834
+				$flags .= "S";
1835
+			}
1836
+			if(!empty($header['label1']))
1837
+			{
1838
+				$flags .= "1";
1839
+			}
1840
+			if(!empty($header['label2']))
1841
+			{
1842
+				$flags .= "2";
1843
+			}
1844
+			if(!empty($header['label3']))
1845
+			{
1846
+				$flags .= "3";
1847
+			}
1848
+			if(!empty($header['label4']))
1849
+			{
1850
+				$flags .= "4";
1851
+			}
1852
+			if(!empty($header['label5']))
1853
+			{
1854
+				$flags .= "5";
1855
+			}
1670 1856
 
1671 1857
 			$data["status"] = "<span class=\"status_img\"></span>";
1672 1858
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
@@ -1674,41 +1860,53 @@  discard block
 block discarded – undo
1674 1860
 			// the css for this row
1675 1861
 			$is_recent=false;
1676 1862
 			$css_styles = array("mail");
1677
-			if ($header['deleted']) {
1863
+			if ($header['deleted'])
1864
+			{
1678 1865
 				$css_styles[] = 'deleted';
1679 1866
 			}
1680
-			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1867
+			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded']))
1868
+			{
1681 1869
 				$css_styles[] = 'recent';
1682 1870
 				$is_recent=true;
1683 1871
 			}
1684
-			if ($header['priority'] < 3) {
1872
+			if ($header['priority'] < 3)
1873
+			{
1685 1874
 				$css_styles[] = 'prio_high';
1686 1875
 			}
1687
-			if ($header['flagged']) {
1876
+			if ($header['flagged'])
1877
+			{
1688 1878
 				$css_styles[] = 'flagged';
1689 1879
 			}
1690
-			if (!$header['seen']) {
1880
+			if (!$header['seen'])
1881
+			{
1691 1882
 				$css_styles[] = 'unseen'; // different status image for recent // solved via css !important
1692 1883
 			}
1693
-			if ($header['answered']) {
1884
+			if ($header['answered'])
1885
+			{
1694 1886
 				$css_styles[] = 'replied';
1695 1887
 			}
1696
-			if ($header['forwarded']) {
1888
+			if ($header['forwarded'])
1889
+			{
1697 1890
 				$css_styles[] = 'forwarded';
1698 1891
 			}
1699
-			if ($header['label1']) {
1892
+			if ($header['label1'])
1893
+			{
1700 1894
 				$css_styles[] = 'labelone';
1701 1895
 			}
1702
-			if ($header['label2']) {
1896
+			if ($header['label2'])
1897
+			{
1703 1898
 				$css_styles[] = 'labeltwo';
1704 1899
 			}
1705
-			if ($header['label3']) {
1900
+			if ($header['label3'])
1901
+			{
1706 1902
 				$css_styles[] = 'labelthree';
1707 1903
 			}
1708
-			if ($header['label4']) {
1904
+			if ($header['label4'])
1905
+			{
1709 1906
 				$css_styles[] = 'labelfour';
1710 1907
 			}
1711
-			if ($header['label5']) {
1908
+			if ($header['label5'])
1909
+			{
1712 1910
 				$css_styles[] = 'labelfive';
1713 1911
 			}
1714 1912
 
@@ -1725,10 +1923,13 @@  discard block
 block discarded – undo
1725 1923
 				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1726 1924
 				// curly brackets get messed up by the template!
1727 1925
 
1728
-				if (!empty($header['subject'])) {
1926
+				if (!empty($header['subject']))
1927
+				{
1729 1928
 					// make the subject shorter if it is to long
1730 1929
 					$subject = $header['subject'];
1731
-				} else {
1930
+				}
1931
+				else
1932
+				{
1732 1933
 					$subject = '('. lang('no subject') .')';
1733 1934
 				}
1734 1935
 
@@ -1770,15 +1971,22 @@  discard block
 block discarded – undo
1770 1971
 					}
1771 1972
 
1772 1973
 					$attachmentFlag = $image;
1773
-				} else {
1974
+				}
1975
+				else
1976
+				{
1774 1977
 					$attachmentFlag ='&nbsp;';
1775 1978
 				}
1776 1979
 				// show priority flag
1777
-				if ($header['priority'] < 3) {
1980
+				if ($header['priority'] < 3)
1981
+				{
1778 1982
 					 $image = Api\Html::image('mail','prio_high');
1779
-				} elseif ($header['priority'] > 3) {
1983
+				}
1984
+				elseif ($header['priority'] > 3)
1985
+				{
1780 1986
 					$image = Api\Html::image('mail','prio_low');
1781
-				} else {
1987
+				}
1988
+				else
1989
+				{
1782 1990
 					$image = '';
1783 1991
 				}
1784 1992
 				// show a flag for flagged messages
@@ -1820,26 +2028,53 @@  discard block
 block discarded – undo
1820 2028
 			}
1821 2029
 
1822 2030
 			if (in_array("size", $cols))
1823
-				$data["size"] = $header['size']; /// size
2031
+			{
2032
+							$data["size"] = $header['size'];
2033
+			}
2034
+			/// size
1824 2035
 
1825 2036
 			$data["class"] = implode(' ', $css_styles);
1826 2037
 			//translate style-classes back to flags
1827 2038
 			$data['flags'] = Array();
1828
-			if ($header['seen']) $data["flags"]['read'] = 'read';
1829
-			foreach ($css_styles as &$flag) {
2039
+			if ($header['seen'])
2040
+			{
2041
+				$data["flags"]['read'] = 'read';
2042
+			}
2043
+			foreach ($css_styles as &$flag)
2044
+			{
1830 2045
 				if ($flag!='mail')
1831 2046
 				{
1832
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1833
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1834
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1835
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1836
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1837
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1838
-					else $data["flags"][$flag] = $flag;
2047
+					if ($flag=='labelone')
2048
+					{
2049
+$data["flags"]['label1'] = 'label1';}
2050
+					elseif ($flag=='labeltwo')
2051
+					{
2052
+$data["flags"]['label2'] = 'label2';}
2053
+					elseif ($flag=='labelthree')
2054
+					{
2055
+$data["flags"]['label3'] = 'label3';}
2056
+					elseif ($flag=='labelfour')
2057
+					{
2058
+$data["flags"]['label4'] = 'label4';}
2059
+					elseif ($flag=='labelfive')
2060
+					{
2061
+$data["flags"]['label5'] = 'label5';}
2062
+					elseif ($flag=='unseen')
2063
+					{
2064
+unset($data["flags"]['read']);}
2065
+					else {
2066
+						$data["flags"][$flag] = $flag;
2067
+					}
1839 2068
 				}
1840 2069
 			}
1841
-			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1842
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2070
+			if ($header['disposition-notification-to'])
2071
+			{
2072
+				$data['dispositionnotificationto'] = $header['disposition-notification-to'];
2073
+			}
2074
+			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto']))
2075
+			{
2076
+				unset($data['dispositionnotificationto']);
2077
+			}
1843 2078
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1844 2079
 			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1845 2080
 			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
@@ -1849,7 +2084,10 @@  discard block
 block discarded – undo
1849 2084
 			$rv[] = $data;
1850 2085
 			//error_log(__METHOD__.__LINE__.array2string($data));
1851 2086
 		}
1852
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2087
+		if (Mail::$debugTimes)
2088
+		{
2089
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2090
+		}
1853 2091
 
1854 2092
 		// ToDo: call this ONLY if labels change
1855 2093
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1864,8 +2102,14 @@  discard block
 block discarded – undo
1864 2102
 	 */
1865 2103
 	function displayHeader()
1866 2104
 	{
1867
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1868
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2105
+		if(isset($_GET['id']))
2106
+		{
2107
+			$rowID	= $_GET['id'];
2108
+		}
2109
+		if(isset($_GET['part']))
2110
+		{
2111
+			$partID = $_GET['part'];
2112
+		}
1869 2113
 
1870 2114
 		$hA = self::splitRowID($rowID);
1871 2115
 		$uid = $hA['msgUID'];
@@ -1889,7 +2133,8 @@  discard block
 block discarded – undo
1889 2133
 		$rawheaders 	= "";
1890 2134
 		// create it new, with good line breaks
1891 2135
 		reset($newRawHeaders);
1892
-		while(list($key,$value) = @each($newRawHeaders)) {
2136
+		while(list($key,$value) = @each($newRawHeaders))
2137
+		{
1893 2138
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1894 2139
 		}
1895 2140
 
@@ -1912,12 +2157,24 @@  discard block
 block discarded – undo
1912 2157
 	 */
1913 2158
 	function displayMessage($_requesteddata = null)
1914 2159
 	{
1915
-		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2160
+		if (is_null($_requesteddata))
2161
+		{
2162
+			$_requesteddata = $_GET;
2163
+		}
1916 2164
 
1917 2165
 		$preventRedirect=false;
1918
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1919
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1920
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2166
+		if(isset($_requesteddata['id']))
2167
+		{
2168
+			$rowID	= $_requesteddata['id'];
2169
+		}
2170
+		if(isset($_requesteddata['part']))
2171
+		{
2172
+			$partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2173
+		}
2174
+		if(isset($_requesteddata['mode']))
2175
+		{
2176
+			$preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2177
+		}
1921 2178
 
1922 2179
 		$hA = self::splitRowID($rowID);
1923 2180
 		$uid = $hA['msgUID'];
@@ -1930,8 +2187,14 @@  discard block
 block discarded – undo
1930 2187
 			$this->changeProfile($icServerID);
1931 2188
 		}
1932 2189
 		$htmlOptions = $this->mail_bo->htmlOptions;
1933
-		if (!empty($_requesteddata['tryastext'])) $htmlOptions  = "only_if_no_text";
1934
-		if (!empty($_requesteddata['tryashtml'])) $htmlOptions  = "always_display";
2190
+		if (!empty($_requesteddata['tryastext']))
2191
+		{
2192
+			$htmlOptions  = "only_if_no_text";
2193
+		}
2194
+		if (!empty($_requesteddata['tryashtml']))
2195
+		{
2196
+			$htmlOptions  = "always_display";
2197
+		}
1935 2198
 
1936 2199
 		//error_log(__METHOD__.__LINE__.array2string($hA));
1937 2200
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
@@ -1955,14 +2218,20 @@  discard block
 block discarded – undo
1955 2218
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1956 2219
 			Framework::message($e->getMessage(), 'error');
1957 2220
 		}
1958
-		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2221
+		if (!empty($uid))
2222
+		{
2223
+			$this->mail_bo->getFlags($uid);
2224
+		}
1959 2225
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1960 2226
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1961 2227
 		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1962 2228
 		$fetchEmbeddedImages = false;
1963 2229
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1964 2230
 		// we do NOT want to see those, that are embedded in the list of attachments
1965
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2231
+		if ($htmlOptions !='always_display')
2232
+		{
2233
+			$fetchEmbeddedImages = true;
2234
+		}
1966 2235
 		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1967 2236
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
1968 2237
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
@@ -1978,11 +2247,17 @@  discard block
 block discarded – undo
1978 2247
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
1979 2248
 
1980 2249
 		// Set up data for taglist widget(s)
1981
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2250
+		if ($envelope['FROM']==$envelope['SENDER'])
2251
+		{
2252
+			unset($envelope['SENDER']);
2253
+		}
1982 2254
 		$sel_options = array();
1983 2255
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
1984 2256
 		{
1985
-			if (!isset($envelope[$field])) continue;
2257
+			if (!isset($envelope[$field]))
2258
+			{
2259
+				continue;
2260
+			}
1986 2261
 			foreach($envelope[$field] as $field_data)
1987 2262
 			{
1988 2263
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
@@ -1996,7 +2271,10 @@  discard block
 block discarded – undo
1996 2271
 		}
1997 2272
 		$actionsenabled = $this->getDisplayToolbarActions();
1998 2273
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
1999
-		if (empty($subject)) $subject = lang('no subject');
2274
+		if (empty($subject))
2275
+		{
2276
+			$subject = lang('no subject');
2277
+		}
2000 2278
 		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2001 2279
 		// Send mail ID so we can use it for actions
2002 2280
 		$content['mail_id'] = $rowID;
@@ -2007,8 +2285,14 @@  discard block
 block discarded – undo
2007 2285
 		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2008 2286
 		$content['mail_displaysubject'] = $subject;
2009 2287
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2010
-		if (!empty($partID)) $linkData['_partID']=$partID;
2011
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2288
+		if (!empty($partID))
2289
+		{
2290
+			$linkData['_partID']=$partID;
2291
+		}
2292
+		if ($htmlOptions != $this->mail_bo->htmlOptions)
2293
+		{
2294
+			$linkData['_htmloptions']=$htmlOptions;
2295
+		}
2012 2296
 		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2013 2297
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2014 2298
 		$content['mail_id']=$rowID;
@@ -2076,7 +2360,8 @@  discard block
 block discarded – undo
2076 2360
 	{
2077 2361
 		$attachmentHTMLBlock='';
2078 2362
 		$attachmentHTML = array();
2079
-		if (is_array($attachments) && count($attachments) > 0) {
2363
+		if (is_array($attachments) && count($attachments) > 0)
2364
+		{
2080 2365
 			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2081 2366
 			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2082 2367
 
@@ -2086,7 +2371,10 @@  discard block
 block discarded – undo
2086 2371
 				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2087 2372
 				//error_log(array2string($value));
2088 2373
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2089
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2374
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM'))
2375
+				{
2376
+					$value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2377
+				}
2090 2378
 				$attachmentHTML[$key]['type']=$value['mimeType'];
2091 2379
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2092 2380
 				$hA = self::splitRowID($rowID);
@@ -2129,8 +2417,15 @@  discard block
 block discarded – undo
2129 2417
 						$sfxMimeType = $value['mimeType'];
2130 2418
 						$buff = explode('.',$value['name']);
2131 2419
 						$suffix = '';
2132
-						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2133
-						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2420
+						if (is_array($buff))
2421
+						{
2422
+							$suffix = array_pop($buff);
2423
+						}
2424
+						// take the last extension to check with ext2mime
2425
+						if (!empty($suffix))
2426
+						{
2427
+							$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2428
+						}
2134 2429
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2135 2430
 						{
2136 2431
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2299,9 +2594,12 @@  discard block
 block discarded – undo
2299 2594
 	function quotaDisplay($_usage, $_limit)
2300 2595
 	{
2301 2596
 
2302
-		if($_limit == 0) {
2597
+		if($_limit == 0)
2598
+		{
2303 2599
 			$quotaPercent=100;
2304
-		} else {
2600
+		}
2601
+		else
2602
+		{
2305 2603
 			$quotaPercent=round(($_usage*100)/$_limit);
2306 2604
 		}
2307 2605
 
@@ -2309,22 +2607,33 @@  discard block
 block discarded – undo
2309 2607
 		$quotaUsage=Mail::show_readable_size($_usage*1024);
2310 2608
 
2311 2609
 
2312
-		if($quotaPercent > 90 && $_limit>0) {
2610
+		if($quotaPercent > 90 && $_limit>0)
2611
+		{
2313 2612
 			$quotaBG='mail-index_QuotaRed';
2314
-		} elseif($quotaPercent > 80 && $_limit>0) {
2613
+		}
2614
+		elseif($quotaPercent > 80 && $_limit>0)
2615
+		{
2315 2616
 			$quotaBG='mail-index_QuotaYellow';
2316
-		} else {
2617
+		}
2618
+		else
2619
+		{
2317 2620
 			$quotaBG='mail-index_QuotaGreen';
2318 2621
 		}
2319 2622
 
2320
-		if($_limit > 0) {
2623
+		if($_limit > 0)
2624
+		{
2321 2625
 			$quotaText = $quotaUsage .'/'.$quotaLimit;
2322
-		} else {
2626
+		}
2627
+		else
2628
+		{
2323 2629
 			$quotaText = $quotaUsage;
2324 2630
 		}
2325 2631
 
2326
-		if($quotaPercent > 50) {
2327
-		} else {
2632
+		if($quotaPercent > 50)
2633
+		{
2634
+		}
2635
+		else
2636
+		{
2328 2637
 		}
2329 2638
 		$quota['class'] = $quotaBG;
2330 2639
 		$quota['text'] = lang('Quota: %1',$quotaText);
@@ -2342,7 +2651,10 @@  discard block
 block discarded – undo
2342 2651
 		$uid	= $_GET['uid'];
2343 2652
 		$cid	= base64_decode($_GET['cid']);
2344 2653
 		$partID = urldecode($_GET['partID']);
2345
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2654
+		if (!empty($_GET['mailbox']))
2655
+		{
2656
+			$mailbox  = base64_decode($_GET['mailbox']);
2657
+		}
2346 2658
 
2347 2659
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2348 2660
 		$this->mail_bo->reopen($mailbox);
@@ -2374,7 +2686,10 @@  discard block
 block discarded – undo
2374 2686
 
2375 2687
 	function getAttachment()
2376 2688
 	{
2377
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2689
+		if(isset($_GET['id']))
2690
+		{
2691
+			$rowID	= $_GET['id'];
2692
+		}
2378 2693
 
2379 2694
 		$hA = self::splitRowID($rowID);
2380 2695
 		$uid = $hA['msgUID'];
@@ -2407,10 +2722,20 @@  discard block
 block discarded – undo
2407 2722
 				$sfxMimeType = $attachment['type'];
2408 2723
 				$buff = explode('.',$attachment['filename']);
2409 2724
 				$suffix = '';
2410
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2411
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2725
+				if (is_array($buff))
2726
+				{
2727
+					$suffix = array_pop($buff);
2728
+				}
2729
+				// take the last extension to check with ext2mime
2730
+				if (!empty($suffix))
2731
+				{
2732
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2733
+				}
2412 2734
 				$attachment['type'] = $sfxMimeType;
2413
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2735
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2736
+				{
2737
+					$attachment['type'] = strtoupper($sfxMimeType);
2738
+				}
2414 2739
 			}
2415 2740
 			//error_log(__METHOD__.print_r($attachment,true));
2416 2741
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2419,7 +2744,10 @@  discard block
 block discarded – undo
2419 2744
 				$calendar_ical = new calendar_ical();
2420 2745
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2421 2746
 				//error_log(__METHOD__.array2string($eventid));
2422
-				if (!$eventid) $eventid = -1;
2747
+				if (!$eventid)
2748
+				{
2749
+					$eventid = -1;
2750
+				}
2423 2751
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2424 2752
 				//error_log(__METHOD__.$event);
2425 2753
 				if ((int)$event > 0)
@@ -2445,7 +2773,10 @@  discard block
 block discarded – undo
2445 2773
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2446 2774
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2447 2775
 				}
2448
-				if (!$contact) $contact = null;
2776
+				if (!$contact)
2777
+				{
2778
+					$contact = null;
2779
+				}
2449 2780
 				// 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))
2450 2781
 				if ($contact || count($vcard)>2)
2451 2782
 				{
@@ -2479,9 +2810,18 @@  discard block
 block discarded – undo
2479 2810
 	function saveMessage()
2480 2811
 	{
2481 2812
 		$display = false;
2482
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2483
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2484
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2813
+		if(isset($_GET['id']))
2814
+		{
2815
+			$rowID	= $_GET['id'];
2816
+		}
2817
+		if(isset($_GET['part']))
2818
+		{
2819
+			$partID = $_GET['part'];
2820
+		}
2821
+		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager'))
2822
+		{
2823
+			$display	= $_GET['location'];
2824
+		}
2485 2825
 
2486 2826
 		$hA = self::splitRowID($rowID);
2487 2827
 		$uid = $hA['msgUID'];
@@ -2570,7 +2910,10 @@  discard block
 block discarded – undo
2570 2910
 			{
2571 2911
 				$succeeded = true;
2572 2912
 			}
2573
-			if ($fp) fclose($fp);
2913
+			if ($fp)
2914
+			{
2915
+				fclose($fp);
2916
+			}
2574 2917
 			if ($succeeded)
2575 2918
 			{
2576 2919
 				unset($headers['SUBJECT']);//already in filename
@@ -2620,7 +2963,8 @@  discard block
 block discarded – undo
2620 2963
 		 *
2621 2964
 		 * @return array an array of parameters
2622 2965
 		 */
2623
-		$getParams = function ($id) {
2966
+		$getParams = function ($id)
2967
+		{
2624 2968
 			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2625 2969
 			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2626 2970
 			$hA = mail_ui::splitRowID($lId);
@@ -2656,7 +3000,10 @@  discard block
 block discarded – undo
2656 3000
 		{
2657 3001
 			$params = $getParams($id);
2658 3002
 			// when downloading a single file, name is not set
2659
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
3003
+			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload)
3004
+			{
3005
+				$params['name'] = $_GET['name'];
3006
+			}
2660 3007
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2661 3008
 			{
2662 3009
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2669,7 +3016,10 @@  discard block
 block discarded – undo
2669 3016
 				// Try to find the right content for file id
2670 3017
 				foreach ($attachments as $key => $val)
2671 3018
 				{
2672
-					if ($key == $params['is_winmail']) $attachment = $val;
3019
+					if ($key == $params['is_winmail'])
3020
+					{
3021
+						$attachment = $val;
3022
+					}
2673 3023
 				}
2674 3024
 			}
2675 3025
 			else
@@ -2716,7 +3066,10 @@  discard block
 block discarded – undo
2716 3066
 	{
2717 3067
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2718 3068
 		// First, get all attachment IDs
2719
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
3069
+		if(isset($_GET['id']))
3070
+		{
3071
+			$message_id	= $_GET['id'];
3072
+		}
2720 3073
 		//error_log(__METHOD__.__LINE__.$message_id);
2721 3074
 		$rememberServerID = $this->mail_bo->profileID;
2722 3075
 		if(!is_numeric($message_id))
@@ -2743,7 +3096,10 @@  discard block
 block discarded – undo
2743 3096
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2744 3097
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2745 3098
 		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2746
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
3099
+		if(Vfs::is_dir($temp_path))
3100
+		{
3101
+			Vfs::remove ($temp_path);
3102
+		}
2747 3103
 
2748 3104
 		// Add subject to path, so it gets used as the file name
2749 3105
 		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
@@ -2768,7 +3124,10 @@  discard block
 block discarded – undo
2768 3124
 				foreach ($tnefAttachments as $key => $val)
2769 3125
 				{
2770 3126
 					error_log(__METHOD__.' winmail = '.$key);
2771
-					if ($key == $file['is_winmail']) $attachment = $val;
3127
+					if ($key == $file['is_winmail'])
3128
+					{
3129
+						$attachment = $val;
3130
+					}
2772 3131
 				}
2773 3132
 			}
2774 3133
 			else
@@ -2776,7 +3135,10 @@  discard block
 block discarded – undo
2776 3135
 				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2777 3136
 			}
2778 3137
 			$success=true;
2779
-			if (empty($file['filename'])) $file['filename'] = $file['name'];
3138
+			if (empty($file['filename']))
3139
+			{
3140
+				$file['filename'] = $file['name'];
3141
+			}
2780 3142
 			if(in_array($path.$file['filename'], $file_list))
2781 3143
 			{
2782 3144
 				$dupe_count[$path.$file['filename']]++;
@@ -2790,8 +3152,14 @@  discard block
 block discarded – undo
2790 3152
 				$success=false;
2791 3153
 				Framework::message("Unable to zip {$file['filename']}",'error');
2792 3154
 			}
2793
-			if ($success) $file_list[] = $path.$file['filename'];
2794
-			if ($fp) fclose($fp);
3155
+			if ($success)
3156
+			{
3157
+				$file_list[] = $path.$file['filename'];
3158
+			}
3159
+			if ($fp)
3160
+			{
3161
+				fclose($fp);
3162
+			}
2795 3163
 		}
2796 3164
 		$this->mail_bo->closeConnection();
2797 3165
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2818,7 +3186,10 @@  discard block
 block discarded – undo
2818 3186
 		$this->uid = $uid;
2819 3187
 		$this->partID = $partID;
2820 3188
 		$bufferHtmlOptions = $this->mail_bo->htmlOptions;
2821
-		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
3189
+		if (empty($htmlOptions))
3190
+		{
3191
+			$htmlOptions = $this->mail_bo->htmlOptions;
3192
+		}
2822 3193
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2823 3194
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2824 3195
 		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
@@ -2882,10 +3253,16 @@  discard block
 block discarded – undo
2882 3253
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2883 3254
 
2884 3255
 		$EndBody = '</td></tr></table></div>';
2885
-		if ($fullPageTags) $EndBody .= "</body></html>";
2886
-		if ($print)	{
3256
+		if ($fullPageTags)
3257
+		{
3258
+			$EndBody .= "</body></html>";
3259
+		}
3260
+		if ($print)
3261
+		{
2887 3262
 			print $BeginBody. $body .$EndBody;
2888
-		} else {
3263
+		}
3264
+		else
3265
+		{
2889 3266
 			return $BeginBody. $body .$EndBody;
2890 3267
 		}
2891 3268
 	}
@@ -2901,9 +3278,14 @@  discard block
 block discarded – undo
2901 3278
 		$body = '';
2902 3279
 
2903 3280
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2904
-		if (empty($bodyParts)) return "";
2905
-		foreach((array)$bodyParts as $singleBodyPart) {
2906
-			if (!isset($singleBodyPart['body'])) {
3281
+		if (empty($bodyParts))
3282
+		{
3283
+			return "";
3284
+		}
3285
+		foreach((array)$bodyParts as $singleBodyPart)
3286
+		{
3287
+			if (!isset($singleBodyPart['body']))
3288
+			{
2907 3289
 				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2908 3290
 				$body .= $singleBodyPart['body'];
2909 3291
 				continue;
@@ -2914,7 +3296,8 @@  discard block
 block discarded – undo
2914 3296
 				$body .= '';
2915 3297
 				continue;
2916 3298
 			}
2917
-			if(!empty($body)) {
3299
+			if(!empty($body))
3300
+			{
2918 3301
 				$body .= '<hr style="border:dotted 1px silver;">';
2919 3302
 			}
2920 3303
 			//error_log($singleBodyPart['body']);
@@ -2952,16 +3335,25 @@  discard block
 block discarded – undo
2952 3335
 				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2953 3336
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2954 3337
 				// if empty and charset is utf8 try sanitizing the string in question
2955
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3338
+				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8')
3339
+				{
3340
+					$newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3341
+				}
2956 3342
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2957
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3343
+				if (empty($newBody))
3344
+				{
3345
+					$newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3346
+				}
2958 3347
 
2959 3348
 				// search http[s] links and make them as links available again
2960 3349
 				// to understand what's going on here, have a look at
2961 3350
 				// http://www.php.net/manual/en/function.preg-replace.php
2962 3351
 
2963 3352
 				// create links for websites
2964
-				if ($modifyURI) $newBody = Api\Html::activate_links($newBody);
3353
+				if ($modifyURI)
3354
+				{
3355
+					$newBody = Api\Html::activate_links($newBody);
3356
+				}
2965 3357
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2966 3358
 				// redirect links for websites if you use no cookies
2967 3359
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -3003,10 +3395,13 @@  discard block
 block discarded – undo
3003 3395
 					{
3004 3396
 						$newBody = $cleaned;
3005 3397
 					}
3006
-					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3398
+					if (!$preserveHTML)
3399
+					{
3400
+						// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3007 3401
 					{
3008 3402
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3009 3403
 						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3404
+					}
3010 3405
 						if ($matches[2])
3011 3406
 						{
3012 3407
 							$hasOther = true;
@@ -3028,7 +3423,10 @@  discard block
 block discarded – undo
3028 3423
 					// as we switched off HTMLaweds tidy functionality
3029 3424
 					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3030 3425
 					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3031
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3426
+					if ($hasOther && $preserveHTML)
3427
+					{
3428
+						$newBody = $matches[1]. $newBody. $matches[3];
3429
+					}
3032 3430
 					$alreadyHtmlLawed=true;
3033 3431
 				}
3034 3432
 				// do the cleanup, set for the use of purifier
@@ -3133,7 +3531,10 @@  discard block
 block discarded – undo
3133 3531
 		*/
3134 3532
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3135 3533
 		{
3136
-			if (!$_type)	return false;
3534
+			if (!$_type)
3535
+			{
3536
+				return false;
3537
+			}
3137 3538
 			$CID = '';
3138 3539
 			// Build up matches according to selected type
3139 3540
 			switch ($_type)
@@ -3176,9 +3577,12 @@  discard block
 block discarded – undo
3176 3577
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
3177 3578
 
3178 3579
 							// only use data uri for "smaller" images, as otherwise the first display of the mail takes to long
3179
-							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)	// msie=8 allows max 32k data uris
3580
+							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)
3581
+							{
3582
+								// msie=8 allows max 32k data uris
3180 3583
 							{
3181 3584
 								$bo->fetchPartContents($_uid, $attachment);
3585
+							}
3182 3586
 								$cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents());
3183 3587
 							}
3184 3588
 							else
@@ -3250,7 +3654,10 @@  discard block
 block discarded – undo
3250 3654
 			}
3251 3655
 			$destination = $content['FOLDER'][0];
3252 3656
 
3253
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3657
+			if (stripos($destination,self::$delimiter)!==false)
3658
+			{
3659
+				list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3660
+			}
3254 3661
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3255 3662
 			{
3256 3663
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3275,14 +3682,26 @@  discard block
 block discarded – undo
3275 3682
 			if (!$importFailed)
3276 3683
 			{
3277 3684
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3278
-				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3685
+				if ($width > 0 && $height > 0)
3686
+				{
3687
+					Api\Json\Response::get()->call('resizeTo', $width, $height);
3688
+				}
3279 3689
 				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3280 3690
 				return;
3281 3691
 			}
3282 3692
 		}
3283
-		if (!is_array($content)) $content = array();
3284
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3285
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3693
+		if (!is_array($content))
3694
+		{
3695
+			$content = array();
3696
+		}
3697
+		if (empty($content['FOLDER']))
3698
+		{
3699
+			$content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3700
+		}
3701
+		if (!empty($content['FOLDER']))
3702
+		{
3703
+			$sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3704
+		}
3286 3705
 
3287 3706
 		$etpl = new Etemplate('mail.importMessage');
3288 3707
 		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
@@ -3302,7 +3721,10 @@  discard block
 block discarded – undo
3302 3721
 	{
3303 3722
 		$importfailed = false;
3304 3723
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
3305
-		if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name'];
3724
+		if (empty($_formData['file']))
3725
+		{
3726
+			$_formData['file'] = $_formData['tmp_name'];
3727
+		}
3306 3728
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3307 3729
 		try
3308 3730
 		{
@@ -3333,10 +3755,14 @@  discard block
 block discarded – undo
3333 3755
 				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3334 3756
 			}
3335 3757
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3336
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3758
+			if($_folder=='INBOX'.$delimiter)
3759
+			{
3760
+				$_folder='INBOX';
3761
+			}
3337 3762
 			if ($importfailed === false)
3338 3763
 			{
3339
-				if ($this->mail_bo->folderExists($_folder,true)) {
3764
+				if ($this->mail_bo->folderExists($_folder,true))
3765
+				{
3340 3766
 					try
3341 3767
 					{
3342 3768
 						$messageUid = $this->mail_bo->appendMessage($_folder,
@@ -3397,7 +3823,10 @@  discard block
 block discarded – undo
3397 3823
 	 */
3398 3824
 	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3399 3825
 	{
3400
-		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3826
+		if (empty($formData))
3827
+		{
3828
+			if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3829
+		}
3401 3830
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
3402 3831
 		$draftFolder = $this->mail_bo->getDraftFolder(false);
3403 3832
 		$importID = Mail::getRandomString();
@@ -3411,15 +3840,26 @@  discard block
 block discarded – undo
3411 3840
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3412 3841
 		{
3413 3842
 			$buff = explode('/',$formData['file']);
3414
-			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3843
+			if (is_array($buff))
3844
+			{
3845
+				$formData['name'] = array_pop($buff);
3846
+			}
3847
+			// take the last part as name
3415 3848
 		}
3416 3849
 		// type should be set to meet the requirements of checkFileBasics
3417 3850
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3418 3851
 		{
3419 3852
 			$buff = explode('.',$formData['file']);
3420 3853
 			$suffix = '';
3421
-			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3422
-			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3854
+			if (is_array($buff))
3855
+			{
3856
+				$suffix = array_pop($buff);
3857
+			}
3858
+			// take the last extension to check with ext2mime
3859
+			if (!empty($suffix))
3860
+			{
3861
+				$formData['type'] = Api\MimeMagic::ext2mime($suffix);
3862
+			}
3423 3863
 		}
3424 3864
 		// size should be set to meet the requirements of checkFileBasics
3425 3865
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3462,17 +3902,35 @@  discard block
 block discarded – undo
3462 3902
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3463 3903
 	{
3464 3904
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3465
-		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3466
-		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3467
-		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3468
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3469
-		if (empty($_messageID)) return "";
3905
+		if (!$_messageID && !empty($_GET['_messageID']))
3906
+		{
3907
+			$_messageID = $_GET['_messageID'];
3908
+		}
3909
+		if (!$_partID && !empty($_GET['_partID']))
3910
+		{
3911
+			$_partID = $_GET['_partID'];
3912
+		}
3913
+		if (!$_htmloptions && !empty($_GET['_htmloptions']))
3914
+		{
3915
+			$_htmloptions = $_GET['_htmloptions'];
3916
+		}
3917
+		if(Mail::$debug)
3918
+		{
3919
+			error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3920
+		}
3921
+		if (empty($_messageID))
3922
+		{
3923
+			return "";
3924
+		}
3470 3925
 		$uidA = self::splitRowID($_messageID);
3471 3926
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
3472 3927
 		$messageID = $uidA['msgUID'];
3473 3928
 		$icServerID = $uidA['profileID'];
3474 3929
 		//something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled
3475
-		if (empty($messageID)) return "";
3930
+		if (empty($messageID))
3931
+		{
3932
+			return "";
3933
+		}
3476 3934
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
3477 3935
 		{
3478 3936
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3501,7 +3959,8 @@  discard block
 block discarded – undo
3501 3959
 			try
3502 3960
 			{
3503 3961
 				$this->mail_bo->getHierarchyDelimiter(false);
3504
-			} catch (Exception $e)
3962
+			}
3963
+			catch (Exception $e)
3505 3964
 			{
3506 3965
 				continue;
3507 3966
 			}
@@ -3511,7 +3970,11 @@  discard block
 block discarded – undo
3511 3970
 				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3512 3971
 				if (is_numeric($profileID))
3513 3972
 				{
3514
-					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
3973
+					if ($profileID != $this->mail_bo->profileID)
3974
+					{
3975
+						continue;
3976
+					}
3977
+					// only current connection
3515 3978
 					if ($folderName)
3516 3979
 					{
3517 3980
 						try
@@ -3522,7 +3985,10 @@  discard block
 block discarded – undo
3522 3985
 						{
3523 3986
 							continue;
3524 3987
 						}
3525
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3988
+						if (in_array($fS['shortDisplayName'],Mail::$autoFolders))
3989
+						{
3990
+							$fS['shortDisplayName']=lang($fS['shortDisplayName']);
3991
+						}
3526 3992
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3527 3993
 						if ($fS['unseen'])
3528 3994
 						{
@@ -3563,7 +4029,11 @@  discard block
 block discarded – undo
3563 4029
 			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3564 4030
 			if (is_numeric($profileID))
3565 4031
 			{
3566
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4032
+				if ($profileID != $this->mail_bo->profileID)
4033
+				{
4034
+					return;
4035
+				}
4036
+				// only current connection
3567 4037
 				$del = $this->mail_bo->getHierarchyDelimiter(false);
3568 4038
 				//$del = $prefix = '';
3569 4039
 				//$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -3603,7 +4073,10 @@  discard block
 block discarded – undo
3603 4073
 				$nA = explode($del,$_newName);
3604 4074
 
3605 4075
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3606
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4076
+				if (!!empty($parentFolderName))
4077
+				{
4078
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4079
+				}
3607 4080
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3608 4081
 
3609 4082
 				$this->mail_bo->reopen('INBOX');
@@ -3624,9 +4097,15 @@  discard block
 block discarded – undo
3624 4097
 							$errorMessage .= $error;
3625 4098
 						}
3626 4099
 					}
3627
-					if ($c==count($nA)) $created=true;
4100
+					if ($c==count($nA))
4101
+					{
4102
+						$created=true;
4103
+					}
4104
+				}
4105
+				if (!empty($parentName))
4106
+				{
4107
+					$this->mail_bo->reopen($parentName);
3628 4108
 				}
3629
-				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3630 4109
 			}
3631 4110
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3632 4111
 			if ($created===true)
@@ -3662,7 +4141,10 @@  discard block
 block discarded – undo
3662 4141
 	 */
3663 4142
 	function ajax_renameFolder($_folderName, $_newName)
3664 4143
 	{
3665
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4144
+		if (Mail::$debug)
4145
+		{
4146
+			error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4147
+		}
3666 4148
 		if ($_folderName)
3667 4149
 		{
3668 4150
 			Api\Translation::add_app('mail');
@@ -3674,7 +4156,11 @@  discard block
 block discarded – undo
3674 4156
 			$hasChildren = false;
3675 4157
 			if (is_numeric($profileID))
3676 4158
 			{
3677
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4159
+				if ($profileID != $this->mail_bo->profileID)
4160
+				{
4161
+					return;
4162
+				}
4163
+				// only current connection
3678 4164
 				$pA = explode($del,$folderName);
3679 4165
 				array_pop($pA);
3680 4166
 				$parentFolder = implode($del,$pA);
@@ -3815,8 +4301,15 @@  discard block
 block discarded – undo
3815 4301
 		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3816 4302
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3817 4303
 		// that we get what we request
3818
-		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3819
-		if ($profileID != $this->mail_bo->profileID) return; // only current connection
4304
+		if ($_subscribedOnly != $oldPrefForSubscribedOnly)
4305
+		{
4306
+			$this->mail_bo->resetFolderObjectCache($profileID);
4307
+		}
4308
+		if ($profileID != $this->mail_bo->profileID)
4309
+		{
4310
+			return;
4311
+		}
4312
+		// only current connection
3820 4313
 		if (!empty($folderName))
3821 4314
 		{
3822 4315
 			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
@@ -3891,7 +4384,10 @@  discard block
 block discarded – undo
3891 4384
 	 */
3892 4385
 	function ajax_MoveFolder($_folderName, $_target)
3893 4386
 	{
3894
-		if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4387
+		if (Mail::$debug)
4388
+		{
4389
+			error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4390
+		}
3895 4391
 		if ($_folderName)
3896 4392
 		{
3897 4393
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
@@ -3902,7 +4398,11 @@  discard block
 block discarded – undo
3902 4398
 			$hasChildren = false;
3903 4399
 			if (is_numeric($profileID))
3904 4400
 			{
3905
-				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
4401
+				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID)
4402
+				{
4403
+					return;
4404
+				}
4405
+				// only current connection
3906 4406
 				$pA = explode($del,$folderName);
3907 4407
 				$namePart = array_pop($pA);
3908 4408
 				$_newName = $namePart;
@@ -3913,10 +4413,13 @@  discard block
 block discarded – undo
3913 4413
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3914 4414
 					(($oldParentFolder != $parentFolder &&
3915 4415
 					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3916
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4416
+					strpos($parentFolder,$folderName)===false))))
4417
+				{
4418
+					// indicates that we move the older up the tree within its own branch
3917 4419
 				{
3918 4420
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3919 4421
 					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4422
+				}
3920 4423
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3921 4424
 					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3922 4425
 					{
@@ -3999,8 +4502,14 @@  discard block
 block discarded – undo
3999 4502
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4000 4503
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4001 4504
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4002
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4003
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4505
+				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false)
4506
+				{
4507
+					unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4508
+				}
4509
+				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false)
4510
+				{
4511
+					unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4512
+				}
4004 4513
 
4005 4514
 				// Send full info back in the response
4006 4515
 				foreach($refreshData as $folder => &$name)
@@ -4036,7 +4545,11 @@  discard block
 block discarded – undo
4036 4545
 			$hasChildren = false;
4037 4546
 			if (is_numeric($profileID))
4038 4547
 			{
4039
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4548
+				if ($profileID != $this->mail_bo->profileID)
4549
+				{
4550
+					return;
4551
+				}
4552
+				// only current connection
4040 4553
 				$pA = explode($del,$folderName);
4041 4554
 				array_pop($pA);
4042 4555
 				if (strtoupper($folderName)!= 'INBOX')
@@ -4062,7 +4575,9 @@  discard block
 block discarded – undo
4062 4575
 						}
4063 4576
 						krsort($ftD,SORT_NUMERIC);//sort per level
4064 4577
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4065
-						foreach($ftD as $k => $lc)//collection per level
4578
+						foreach($ftD as $k => $lc)
4579
+						{
4580
+							//collection per level
4066 4581
 						{
4067 4582
 							foreach($lc as $f)//folders contained in that level
4068 4583
 							{
@@ -4070,8 +4585,12 @@  discard block
 block discarded – undo
4070 4585
 								{
4071 4586
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4072 4587
 									$this->mail_bo->deleteFolder($f);
4588
+						}
4073 4589
 									$success = true;
4074
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4590
+									if ($f==$folderName)
4591
+									{
4592
+										$oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4593
+									}
4075 4594
 								}
4076 4595
 								catch (Exception $e)
4077 4596
 								{
@@ -4101,7 +4620,10 @@  discard block
 block discarded – undo
4101 4620
 					$msg = lang("refused to delete folder INBOX");
4102 4621
 				}
4103 4622
 			}
4104
-			if ($_return) return $success;
4623
+			if ($_return)
4624
+			{
4625
+				return $success;
4626
+			}
4105 4627
 			$response = Api\Json\Response::get();
4106 4628
 			if ($success)
4107 4629
 			{
@@ -4186,19 +4708,29 @@  discard block
 block discarded – undo
4186 4708
 			// Create mail app object
4187 4709
 			$mail = new mail_ui();
4188 4710
 
4189
-			if (empty($icServerID)) $icServerID = $mail->Mail->profileID;
4190
-			if ($icServerID != $mail->Mail->profileID) return;
4711
+			if (empty($icServerID))
4712
+			{
4713
+				$icServerID = $mail->Mail->profileID;
4714
+			}
4715
+			if ($icServerID != $mail->Mail->profileID)
4716
+			{
4717
+				return;
4718
+			}
4191 4719
 
4192 4720
 			$vacation = $mail->gatherVacation($cachedVacations);
4193 4721
 		}
4194 4722
 
4195
-		if($vacation) {
4723
+		if($vacation)
4724
+		{
4196 4725
 			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4197 4726
 			{
4198 4727
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4199 4728
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4200 4729
 				$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):''):'');
4201
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4730
+				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())
4731
+				{
4732
+					$refreshData = '';
4733
+				}
4202 4734
 			}
4203 4735
 		}
4204 4736
 		if ($vacation==false)
@@ -4220,11 +4752,17 @@  discard block
 block discarded – undo
4220 4752
 	function ajax_refreshFilters($icServerID=null)
4221 4753
 	{
4222 4754
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4223
-		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4755
+		if (empty($icServerID))
4756
+		{
4757
+			$icServerID = $this->mail_bo->profileID;
4758
+		}
4224 4759
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4225 4760
 		{
4226 4761
 			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4227
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4762
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4763
+			{
4764
+				Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4765
+			}
4228 4766
 		}
4229 4767
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4230 4768
 		{
@@ -4246,7 +4784,10 @@  discard block
 block discarded – undo
4246 4784
 			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4247 4785
 			foreach($keywords as &$k)
4248 4786
 			{
4249
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4787
+				if (array_key_exists($k,$this->statusTypes))
4788
+				{
4789
+					unset($this->statusTypes[$k]);
4790
+				}
4250 4791
 			}
4251 4792
 		}
4252 4793
 
@@ -4266,7 +4807,10 @@  discard block
 block discarded – undo
4266 4807
 	{
4267 4808
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4268 4809
 		Api\Translation::add_app('mail');
4269
-		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
4810
+		if (is_null($icServerID))
4811
+		{
4812
+			$icServerID = $this->mail_bo->profileID;
4813
+		}
4270 4814
 		$rememberServerID = $this->mail_bo->profileID;
4271 4815
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
4272 4816
 		{
@@ -4276,19 +4820,23 @@  discard block
 block discarded – undo
4276 4820
 		try
4277 4821
 		{
4278 4822
 			$quota = $this->mail_bo->getQuotaRoot();
4279
-		} catch (Exception $e) {
4823
+		}
4824
+		catch (Exception $e) {
4280 4825
 			$quota['limit'] = 'NOT SET';
4281 4826
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4282 4827
 			unset($e);
4283 4828
 		}
4284 4829
 
4285
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4830
+		if($quota !== false && $quota['limit'] != 'NOT SET')
4831
+		{
4286 4832
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4287 4833
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4288 4834
 			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4289 4835
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4290 4836
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4291
-		} else {
4837
+		}
4838
+		else
4839
+		{
4292 4840
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
4293 4841
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
4294 4842
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -4321,7 +4869,8 @@  discard block
 block discarded – undo
4321 4869
 			$this->changeProfile($icServerID);
4322 4870
 		}
4323 4871
 		$junkFolder = $this->mail_bo->getJunkFolder();
4324
-		if(!empty($junkFolder)) {
4872
+		if(!empty($junkFolder))
4873
+		{
4325 4874
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4326 4875
 			{
4327 4876
 				// Lock the tree if the active folder is junk folder
@@ -4371,7 +4920,8 @@  discard block
 block discarded – undo
4371 4920
 			$this->changeProfile($icServerID);
4372 4921
 		}
4373 4922
 		$trashFolder = $this->mail_bo->getTrashFolder();
4374
-		if(!empty($trashFolder)) {
4923
+		if(!empty($trashFolder))
4924
+		{
4375 4925
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4376 4926
 			{
4377 4927
 				// Lock the tree if the active folder is Trash folder
@@ -4417,7 +4967,10 @@  discard block
 block discarded – undo
4417 4967
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4418 4968
 		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4419 4969
 
4420
-		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4970
+		if (empty($folderName))
4971
+		{
4972
+			$folderName = $this->mail_bo->sessionData['mailbox'];
4973
+		}
4421 4974
 		if ($this->mail_bo->folderExists($folderName))
4422 4975
 		{
4423 4976
 			$rememberServerID = $this->mail_bo->profileID;
@@ -4426,7 +4979,8 @@  discard block
 block discarded – undo
4426 4979
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4427 4980
 				$this->changeProfile($icServerID);
4428 4981
 			}
4429
-			if(!empty($_folderName)) {
4982
+			if(!empty($_folderName))
4983
+			{
4430 4984
 				$this->mail_bo->compressFolder($folderName);
4431 4985
 			}
4432 4986
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4448,7 +5002,10 @@  discard block
 block discarded – undo
4448 5002
 	 */
4449 5003
 	function ajax_sendMDN($_messageList)
4450 5004
 	{
4451
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
5005
+		if(Mail::$debug)
5006
+		{
5007
+			error_log(__METHOD__."->".array2string($_messageList));
5008
+		}
4452 5009
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4453 5010
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4454 5011
 		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
@@ -4465,7 +5022,10 @@  discard block
 block discarded – undo
4465 5022
 	 */
4466 5023
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4467 5024
 	{
4468
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5025
+		if(Mail::$debug)
5026
+		{
5027
+			error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5028
+		}
4469 5029
 		Api\Translation::add_app('mail');
4470 5030
 		$alreadyFlagged=false;
4471 5031
 		$flag2check='';
@@ -4486,12 +5046,23 @@  discard block
 block discarded – undo
4486 5046
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4487 5047
 						{
4488 5048
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4489
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5049
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5050
+							{
5051
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5052
+							}
4490 5053
 						}
4491 5054
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4492 5055
 						$cutoffdate = $cutoffdate2 = null;
4493
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4494
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5056
+						if ($query['startdate'])
5057
+						{
5058
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5059
+						}
5060
+						//SINCE, enddate
5061
+						if ($query['enddate'])
5062
+						{
5063
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5064
+						}
5065
+						//BEFORE, startdate
4495 5066
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4496 5067
 						$filter = array(
4497 5068
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4500,15 +5071,24 @@  discard block
 block discarded – undo
4500 5071
 							'status' => 'any',//this is a status change. status will be manipulated later on
4501 5072
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4502 5073
 						);
4503
-						if ($query['enddate']||$query['startdate']) {
5074
+						if ($query['enddate']||$query['startdate'])
5075
+						{
4504 5076
 							$filter['range'] = "BETWEEN";
4505
-							if ($cutoffdate) {
5077
+							if ($cutoffdate)
5078
+							{
4506 5079
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4507
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5080
+								if (empty($cutoffdate2))
5081
+								{
5082
+									$filter['range'] = "SINCE";
5083
+								}
4508 5084
 							}
4509
-							if ($cutoffdate2) {
5085
+							if ($cutoffdate2)
5086
+							{
4510 5087
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4511
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5088
+								if (empty($cutoffdate))
5089
+								{
5090
+									$filter['range'] = "BEFORE";
5091
+								}
4512 5092
 							}
4513 5093
 						}
4514 5094
 						$filter2toggle = $filter;
@@ -4555,13 +5135,19 @@  discard block
 block discarded – undo
4555 5135
 						if (count($messageListForToggle)>0)
4556 5136
 						{
4557 5137
 							$flag2set = (strtolower($_flag));
4558
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5138
+							if(Mail::$debug)
5139
+							{
5140
+								error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5141
+							}
4559 5142
 							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4560 5143
 						}
4561 5144
 						if (count($messageList)>0)
4562 5145
 						{
4563 5146
 							$flag2set = 'un'.$_flag;
4564
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5147
+							if(Mail::$debug)
5148
+							{
5149
+								error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5150
+							}
4565 5151
 							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4566 5152
 						}
4567 5153
 						$alreadyFlagged=true;
@@ -4577,7 +5163,10 @@  discard block
 block discarded – undo
4577 5163
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4578 5164
 							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4579 5165
 						}
4580
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5166
+						if(Mail::$debug)
5167
+						{
5168
+							error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5169
+						}
4581 5170
 						$_sR = $this->mail_bo->getSortedList(
4582 5171
 							$folder,
4583 5172
 							$sort=0,
@@ -4592,7 +5181,10 @@  discard block
 block discarded – undo
4592 5181
 					}
4593 5182
 					else
4594 5183
 					{
4595
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5184
+						if(Mail::$debug)
5185
+						{
5186
+							error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5187
+						}
4596 5188
 						$alreadyFlagged=true;
4597 5189
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4598 5190
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -4612,13 +5204,19 @@  discard block
 block discarded – undo
4612 5204
 					$hA = self::splitRowID($rowID);
4613 5205
 					$messageList[] = $hA['msgUID'];
4614 5206
 				}
4615
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5207
+				if(Mail::$debug)
5208
+				{
5209
+					error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5210
+				}
4616 5211
 				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4617 5212
 			}
4618 5213
 		}
4619 5214
 		else
4620 5215
 		{
4621
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5216
+			if(Mail::$debug)
5217
+			{
5218
+				error_log(__METHOD__."-> No messages selected.");
5219
+			}
4622 5220
 		}
4623 5221
 
4624 5222
 		if ($_sendJsonResponse)
@@ -4655,7 +5253,10 @@  discard block
 block discarded – undo
4655 5253
 	 */
4656 5254
 	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4657 5255
 	{
4658
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5256
+		if(Mail::$debug)
5257
+		{
5258
+			error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5259
+		}
4659 5260
 		$error = null;
4660 5261
 		$filtered =  false;
4661 5262
 		if ($_messageList=='all' || !empty($_messageList['msg']))
@@ -4674,12 +5275,23 @@  discard block
 block discarded – undo
4674 5275
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4675 5276
 						{
4676 5277
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4677
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5278
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5279
+							{
5280
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5281
+							}
4678 5282
 						}
4679 5283
 						$filtered =  true;
4680 5284
 						$cutoffdate = $cutoffdate2 = null;
4681
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4682
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5285
+						if ($query['startdate'])
5286
+						{
5287
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5288
+						}
5289
+						//SINCE, enddate
5290
+						if ($query['enddate'])
5291
+						{
5292
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5293
+						}
5294
+						//BEFORE, startdate
4683 5295
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4684 5296
 						$filter = array(
4685 5297
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4688,15 +5300,24 @@  discard block
 block discarded – undo
4688 5300
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4689 5301
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4690 5302
 						);
4691
-						if ($query['enddate']||$query['startdate']) {
5303
+						if ($query['enddate']||$query['startdate'])
5304
+						{
4692 5305
 							$filter['range'] = "BETWEEN";
4693
-							if ($cutoffdate) {
5306
+							if ($cutoffdate)
5307
+							{
4694 5308
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4695
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5309
+								if (empty($cutoffdate2))
5310
+								{
5311
+									$filter['range'] = "SINCE";
5312
+								}
4696 5313
 							}
4697
-							if ($cutoffdate2) {
5314
+							if ($cutoffdate2)
5315
+							{
4698 5316
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4699
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5317
+								if (empty($cutoffdate))
5318
+								{
5319
+									$filter['range'] = "BEFORE";
5320
+								}
4700 5321
 							}
4701 5322
 						}
4702 5323
 					}
@@ -4763,7 +5384,10 @@  discard block
 block discarded – undo
4763 5384
 		}
4764 5385
 		else
4765 5386
 		{
4766
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5387
+			if(Mail::$debug)
5388
+			{
5389
+				error_log(__METHOD__."-> No messages selected.");
5390
+			}
4767 5391
 		}
4768 5392
 	}
4769 5393
 
@@ -4779,11 +5403,17 @@  discard block
 block discarded – undo
4779 5403
 	 */
4780 5404
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4781 5405
 	{
4782
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5406
+		if(Mail::$debug)
5407
+		{
5408
+			error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5409
+		}
4783 5410
 		Api\Translation::add_app('mail');
4784 5411
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4785 5412
 		// only copy or move are supported as method
4786
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5413
+		if (!($_copyOrMove=='copy' || $_copyOrMove=='move'))
5414
+		{
5415
+			$_copyOrMove='copy';
5416
+		}
4787 5417
 		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4788 5418
 		// check if move2archive was called with the correct archiveFolder
4789 5419
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
@@ -4806,8 +5436,13 @@  discard block
 block discarded – undo
4806 5436
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4807 5437
 				foreach( $keys as &$f)
4808 5438
 				{
4809
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4810
-					else break;
5439
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9)
5440
+					{
5441
+						unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5442
+					}
5443
+					else {
5444
+						break;
5445
+					}
4811 5446
 				}
4812 5447
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4813 5448
 			}
@@ -4834,12 +5469,23 @@  discard block
 block discarded – undo
4834 5469
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4835 5470
 						{
4836 5471
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4837
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5472
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5473
+							{
5474
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5475
+							}
4838 5476
 						}
4839 5477
 						$filtered = true;
4840 5478
 						$cutoffdate = $cutoffdate2 = null;
4841
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4842
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5479
+						if ($query['startdate'])
5480
+						{
5481
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5482
+						}
5483
+						//SINCE, enddate
5484
+						if ($query['enddate'])
5485
+						{
5486
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5487
+						}
5488
+						//BEFORE, startdate
4843 5489
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4844 5490
 						$filter = array(
4845 5491
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4848,15 +5494,24 @@  discard block
 block discarded – undo
4848 5494
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4849 5495
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4850 5496
 						);
4851
-						if ($query['enddate']||$query['startdate']) {
5497
+						if ($query['enddate']||$query['startdate'])
5498
+						{
4852 5499
 							$filter['range'] = "BETWEEN";
4853
-							if ($cutoffdate) {
5500
+							if ($cutoffdate)
5501
+							{
4854 5502
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4855
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5503
+								if (empty($cutoffdate2))
5504
+								{
5505
+									$filter['range'] = "SINCE";
5506
+								}
4856 5507
 							}
4857
-							if ($cutoffdate2) {
5508
+							if ($cutoffdate2)
5509
+							{
4858 5510
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4859
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5511
+								if (empty($cutoffdate))
5512
+								{
5513
+									$filter['range'] = "BEFORE";
5514
+								}
4860 5515
 							}
4861 5516
 						}
4862 5517
 					}
@@ -4912,7 +5567,10 @@  discard block
 block discarded – undo
4912 5567
 						$hA = self::splitRowID($rowID);
4913 5568
 
4914 5569
 						// If folder changes, stop and move what we've got
4915
-						if($hA['folder'] != $folder) break;
5570
+						if($hA['folder'] != $folder)
5571
+						{
5572
+							break;
5573
+						}
4916 5574
 
4917 5575
 						array_shift($_messageList['msg']);
4918 5576
 						$messageList[] = $hA['msgUID'];
@@ -4967,7 +5625,10 @@  discard block
 block discarded – undo
4967 5625
 		}
4968 5626
 		else
4969 5627
 		{
4970
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5628
+			if(Mail::$debug)
5629
+			{
5630
+				error_log(__METHOD__."-> No messages selected.");
5631
+			}
4971 5632
 		}
4972 5633
 	}
4973 5634
 
Please login to merge, or discard this patch.
api/src/Mail.php 1 patch
Braces   +1778 added lines, -527 removed lines patch added patch discarded remove patch
@@ -199,7 +199,10 @@  discard block
 block discarded – undo
199 199
 	public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null)
200 200
 	{
201 201
 		//$_restoreSession=false;
202
-		if (is_null($_reuseCache)) $_reuseCache = $_restoreSession;
202
+		if (is_null($_reuseCache))
203
+		{
204
+			$_reuseCache = $_restoreSession;
205
+		}
203 206
 		//error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.'/'.Mail\Account::get_default_acc_id().' for user:'.$GLOBALS['egw_info']['user']['account_lid'].' called from:'.function_backtrace());
204 207
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject));
205 208
 		if (isset(self::$profileDefunct[$_profileID]) && self::$profileDefunct[$_profileID]===true)
@@ -229,9 +232,15 @@  discard block
 block discarded – undo
229 232
 			{
230 233
 				$profileID = Mail\Account::get_default_acc_id();
231 234
 			}
232
-			if ($profileID!=$_profileID) $_restoreSession==false;
235
+			if ($profileID!=$_profileID)
236
+			{
237
+				$_restoreSession==false;
238
+			}
233 239
 			$_profileID=$profileID;
234
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace());
240
+			if (self::$debug)
241
+			{
242
+				error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace());
243
+			}
235 244
 		}
236 245
 		// no validation or restoreSession for old ImapServer Object, just fetch it and return it
237 246
 		if ($_oldImapServerObject===true)
@@ -270,7 +279,8 @@  discard block
 block discarded – undo
270 279
 				// TODO: merge mailprefs into userprefs, for easy treatment
271 280
 				self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
272 281
 				self::$instances[$_profileID]->htmlOptions  = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
273
-			} catch (\Exception $e)
282
+			}
283
+			catch (\Exception $e)
274 284
 			{
275 285
 				$newprofileID = Mail\Account::get_default_acc_id();
276 286
 				// try loading the default profile for the user
@@ -288,9 +298,15 @@  discard block
 block discarded – undo
288 298
 			self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate );
289 299
 		}
290 300
 		self::$instances[$_profileID]->profileID = $_profileID;
291
-		if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna;
301
+		if (!isset(self::$instances[$_profileID]->idna2))
302
+		{
303
+			self::$instances[$_profileID]->idna2 = new Horde_Idna;
304
+		}
292 305
 		//if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID);
293
-		if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
306
+		if (is_null(self::$mailConfig))
307
+		{
308
+			self::$mailConfig = Config::read('mail');
309
+		}
294 310
 		return self::$instances[$_profileID];
295 311
 	}
296 312
 
@@ -315,14 +331,20 @@  discard block
 block discarded – undo
315 331
 			}
316 332
 			catch (\Exception $e)
317 333
 			{
318
-				if ($_profileID != Mail\Account::get_default_acc_id()) $_profileID = Mail\Account::get_default_acc_id();
334
+				if ($_profileID != Mail\Account::get_default_acc_id())
335
+				{
336
+					$_profileID = Mail\Account::get_default_acc_id();
337
+				}
319 338
 				error_log(__METHOD__.__LINE__.' '.$e->getMessage());
320 339
 				return false;
321 340
 			}
322 341
 		}
323 342
 		if ($oldProfileID != $_profileID)
324 343
 		{
325
-			if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID;
344
+			if ($oldProfileID && $_profileID==0)
345
+			{
346
+				$_profileID = $oldProfileID;
347
+			}
326 348
 			$GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user');
327 349
 			// save prefs
328 350
 			$GLOBALS['egw']->preferences->save_repository(true);
@@ -352,11 +374,17 @@  discard block
 block discarded – undo
352 374
 				{
353 375
 					return $_acc_id;
354 376
 				}
355
-				if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!");
377
+				if (self::$debug)
378
+				{
379
+					error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!");
380
+				}
356 381
 			}
357 382
 			catch (\Exception $e) {
358 383
 				unset($e);
359
-				if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!");
384
+				if (self::$debug)
385
+				{
386
+					error_log(__METHOD__."($_acc_id) account NOT found!");
387
+				}
360 388
 			}
361 389
 		}
362 390
 		// no account specified or specified account not found or not valid
@@ -365,11 +393,17 @@  discard block
 block discarded – undo
365 393
 		{
366 394
 			if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap())
367 395
 			{
368
-				if (self::$debug && $_acc_id) error_log(__METHOD__."($_acc_id) using $acc_id instead");
396
+				if (self::$debug && $_acc_id)
397
+				{
398
+					error_log(__METHOD__."($_acc_id) using $acc_id instead");
399
+				}
369 400
 				return $acc_id;
370 401
 			}
371 402
 		}
372
-		if (self::$debug) error_log(__METHOD__."($_acc_id) NO valid account found!");
403
+		if (self::$debug)
404
+		{
405
+			error_log(__METHOD__."($_acc_id) NO valid account found!");
406
+		}
373 407
 		return 0;
374 408
 	}
375 409
 
@@ -385,10 +419,19 @@  discard block
 block discarded – undo
385 419
 	 */
386 420
 	private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null)
387 421
 	{
388
-		if (is_null($_reuseCache)) $_reuseCache = $_restoreSession;
389
-		if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset;
422
+		if (is_null($_reuseCache))
423
+		{
424
+			$_reuseCache = $_restoreSession;
425
+		}
426
+		if (!empty($_displayCharset))
427
+		{
428
+			self::$displayCharset = $_displayCharset;
429
+		}
390 430
 		// not nummeric, we assume we only want an empty class object
391
-		if (!is_numeric($_profileID)) return true;
431
+		if (!is_numeric($_profileID))
432
+		{
433
+			return true;
434
+		}
392 435
 		if ($_restoreSession)
393 436
 		{
394 437
 			//error_log(__METHOD__." Session restore ".function_backtrace());
@@ -403,7 +446,10 @@  discard block
 block discarded – undo
403 446
 			$firstMessage = $this->sessionData['previewMessage'];
404 447
 			$this->sessionData = array();
405 448
 		}
406
-		if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache);
449
+		if (!$_reuseCache)
450
+		{
451
+			$this->forcePrefReload($_profileID,!$_reuseCache);
452
+		}
407 453
 		try
408 454
 		{
409 455
 			$this->profileID = self::validateProfileID($_profileID);
@@ -427,7 +473,10 @@  discard block
 block discarded – undo
427 473
 			$_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId;
428 474
 		}
429 475
 
430
-		if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
476
+		if (is_null(self::$mailConfig))
477
+		{
478
+			self::$mailConfig = Config::read('mail');
479
+		}
431 480
 	}
432 481
 
433 482
 	/**
@@ -456,7 +505,10 @@  discard block
 block discarded – undo
456 505
 		// unset the mail_preferences session object, to force the reload/rebuild
457 506
 		Cache::setSession('mail','mail_preferences',serialize(array()));
458 507
 		Cache::setSession('emailadmin','session_data',serialize(array()));
459
-		if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id);
508
+		if ($_resetFolderObjects)
509
+		{
510
+			self::resetFolderObjectCache($_profile_id);
511
+		}
460 512
 	}
461 513
 
462 514
 	/**
@@ -466,7 +518,10 @@  discard block
 block discarded – undo
466 518
 	{
467 519
 		$this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1);
468 520
 		self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
469
-		if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID];
521
+		if (!empty(self::$activeFolderCache[$this->profileID]))
522
+		{
523
+			$this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID];
524
+		}
470 525
 	}
471 526
 
472 527
 	/**
@@ -475,7 +530,10 @@  discard block
 block discarded – undo
475 530
 	function saveSessionData()
476 531
 	{
477 532
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData)));
478
-		if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox'];
533
+		if (!empty($this->sessionData['mailbox']))
534
+		{
535
+			self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox'];
536
+		}
479 537
 		if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache))
480 538
 		{
481 539
 			Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10);
@@ -496,8 +554,14 @@  discard block
 block discarded – undo
496 554
 	 */
497 555
 	static function unsetCachedObjects($_profileID=null)
498 556
 	{
499
-		if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id();
500
-		if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id'];
557
+		if (is_null($_profileID))
558
+		{
559
+			$_profileID = Mail\Account::get_default_acc_id();
560
+		}
561
+		if (is_array($_profileID) && $_profileID['account_id'])
562
+		{
563
+			$account_id = $_profileID['account_id'];
564
+		}
501 565
 		//error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace());
502 566
 		if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false)))
503 567
 		{
@@ -530,7 +594,10 @@  discard block
 block discarded – undo
530 594
 				Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1);
531 595
 			}
532 596
 
533
-			if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]);
597
+			if (isset(self::$instances[$_profileID]))
598
+			{
599
+				unset(self::$instances[$_profileID]);
600
+			}
534 601
 		}
535 602
 		if (is_array($_profileID) && $_profileID['location'] == 'clear_cache')
536 603
 		{
@@ -559,7 +626,10 @@  discard block
 block discarded – undo
559 626
 	static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null)
560 627
 	{
561 628
 		//error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id));
562
-		if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
629
+		if (is_null($account_id))
630
+		{
631
+			$account_id = $GLOBALS['egw_info']['user']['account_id'];
632
+		}
563 633
 		if (is_array($_ImapServerId))
564 634
 		{
565 635
 			// called via hook
@@ -598,7 +668,10 @@  discard block
 block discarded – undo
598 668
 	static function resetFolderObjectCache($_ImapServerId=null,$account_id=null)
599 669
 	{
600 670
 		//error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace());
601
-		if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
671
+		if (is_null($account_id))
672
+		{
673
+			$account_id = $GLOBALS['egw_info']['user']['account_id'];
674
+		}
602 675
 		// on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId
603 676
 		// or treat it as not given. we try that path
604 677
 		if (is_null($_ImapServerId)||is_array($_ImapServerId))
@@ -672,10 +745,14 @@  discard block
 block discarded – undo
672 745
 
673 746
 		$userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']);
674 747
 
675
-		foreach($identities as $ik => $ident) {
748
+		foreach($identities as $ik => $ident)
749
+		{
676 750
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
677 751
 			$identity = Mail\Account::read_identity($ik);
678
-			if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
752
+			if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']]))
753
+			{
754
+				$userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
755
+			}
679 756
 		}
680 757
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses));
681 758
 		return $userEMailAdresses;
@@ -693,13 +770,20 @@  discard block
 block discarded – undo
693 770
 		foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name)
694 771
 		{
695 772
 			$acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null));
696
-			if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
773
+			if (!$resolve_placeholders)
774
+			{
775
+				$userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
776
+			}
697 777
 
698
-			foreach(Mail\Account::identities($acc) as $ik => $ident) {
778
+			foreach(Mail\Account::identities($acc) as $ik => $ident)
779
+			{
699 780
 				//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
700 781
 				$identity = Mail\Account::read_identity($ik,$resolve_placeholders);
701 782
 				//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
702
-				if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']);
783
+				if (!isset($userEMailAdresses[$identity['ident_id']]))
784
+				{
785
+					$userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']);
786
+				}
703 787
 			}
704 788
 		}
705 789
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses));
@@ -719,12 +803,16 @@  discard block
 block discarded – undo
719 803
 			$account = Mail\Account::read($account);
720 804
 		}
721 805
 		$userEMailAdresses = array();
722
-		foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) {
806
+		foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident)
807
+		{
723 808
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
724 809
 			$identity = Mail\Account::read_identity($ik,true,null,$account);
725 810
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
726 811
 			// standardIdentity has ident_id==acc_id (as it is done within account->identities)
727
-			if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id'];
812
+			if (empty($identity['ident_id']))
813
+			{
814
+				$identity['ident_id'] = $identity['acc_id'];
815
+			}
728 816
 			if (!isset($userEMailAdresses[$identity['ident_id']]))
729 817
 			{
730 818
 				$userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$identity['acc_id'],
@@ -767,15 +855,25 @@  discard block
 block discarded – undo
767 855
 		// account select box
768 856
 		$selectedID = $this->profileID;
769 857
 		$allAccountData = Mail\Account::search($only_current_user=true, false, null);
770
-		if ($allAccountData) {
858
+		if ($allAccountData)
859
+		{
771 860
 			$rememberFirst=$selectedFound=null;
772 861
 			foreach ($allAccountData as $tmpkey => $icServers)
773 862
 			{
774
-				if (is_null($rememberFirst)) $rememberFirst = $tmpkey;
775
-				if ($tmpkey == $selectedID) $selectedFound=true;
863
+				if (is_null($rememberFirst))
864
+				{
865
+					$rememberFirst = $tmpkey;
866
+				}
867
+				if ($tmpkey == $selectedID)
868
+				{
869
+					$selectedFound=true;
870
+				}
776 871
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host));
777 872
 				$host = $icServers->acc_imap_host;
778
-				if (empty($host)) continue;
873
+				if (empty($host))
874
+				{
875
+					continue;
876
+				}
779 877
 				$identities[$icServers->acc_id] = $icServers['ident_realname'].' '.$icServers['ident_org'].' <'.$icServers['ident_email'].'>';
780 878
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id]));
781 879
 			}
@@ -835,7 +933,10 @@  discard block
 block discarded – undo
835 933
 	 */
836 934
 	function reopen($_foldername)
837 935
 	{
838
-		if (self::$debugTimes) $starttime = microtime (true);
936
+		if (self::$debugTimes)
937
+		{
938
+			$starttime = microtime (true);
939
+		}
839 940
 
840 941
 		//error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace());
841 942
 		// TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of
@@ -845,12 +946,16 @@  discard block
 block discarded – undo
845 946
 		//{
846 947
 			//error_log( __METHOD__.' ('.__LINE__.') '." $_foldername ".function_backtrace());
847 948
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Connected with icServer for Profile:'.$this->profileID.'?'.print_r($this->icServer->_connected,true));
848
-			if ($this->folderIsSelectable($_foldername)) {
949
+			if ($this->folderIsSelectable($_foldername))
950
+			{
849 951
 				$this->icServer->openMailbox($_foldername);
850 952
 			}
851 953
 			$folderOpened = $_foldername;
852 954
 		//}
853
-		if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') ');
955
+		if (self::$debugTimes)
956
+		{
957
+			self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') ');
958
+		}
854 959
 	}
855 960
 
856 961
 
@@ -865,13 +970,22 @@  discard block
 block discarded – undo
865 970
 	{
866 971
 		//error_log( "-------------------------->open connection ".function_backtrace());
867 972
 		//error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer));
868
-		if (self::$debugTimes) $starttime = microtime (true);
973
+		if (self::$debugTimes)
974
+		{
975
+			$starttime = microtime (true);
976
+		}
869 977
 		$mailbox=null;
870 978
 		try
871 979
 		{
872
-			if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox'];
873
-			if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox();
874
-/*
980
+			if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox']))
981
+			{
982
+				$mailbox = $this->sessionData['mailbox'];
983
+			}
984
+			if (empty($mailbox))
985
+			{
986
+				$mailbox = $this->icServer->getCurrentMailbox();
987
+			}
988
+			/*
875 989
 			if (isset(Mail\Imap::$supports_keywords[$_icServerID]))
876 990
 			{
877 991
 				$this->icServer->openMailbox($mailbox);
@@ -896,7 +1010,10 @@  discard block
 block discarded – undo
896 1010
 			error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage());
897 1011
 			throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage());
898 1012
 		}
899
-		if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') ');
1013
+		if (self::$debugTimes)
1014
+		{
1015
+			self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') ');
1016
+		}
900 1017
 	}
901 1018
 
902 1019
 	/**
@@ -908,7 +1025,10 @@  discard block
 block discarded – undo
908 1025
 	function getQuotaRoot()
909 1026
 	{
910 1027
 		static $quota;
911
-		if (isset($quota)) return $quota;
1028
+		if (isset($quota))
1029
+		{
1030
+			return $quota;
1031
+		}
912 1032
 		if (isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID]===true)
913 1033
 		{
914 1034
 			// something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request
@@ -917,7 +1037,8 @@  discard block
 block discarded – undo
917 1037
 		try
918 1038
 		{
919 1039
 			$this->icServer->getCurrentMailbox();
920
-			if(!$this->icServer->hasCapability('QUOTA')) {
1040
+			if(!$this->icServer->hasCapability('QUOTA'))
1041
+			{
921 1042
 				$quota = false;
922 1043
 				return false;
923 1044
 			}
@@ -934,12 +1055,15 @@  discard block
 block discarded – undo
934 1055
 			}
935 1056
 		}
936 1057
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota));
937
-		if(is_array($quota)) {
1058
+		if(is_array($quota))
1059
+		{
938 1060
 			$quota = array(
939 1061
 				'usage'	=> $quota['USED'],
940 1062
 				'limit'	=> $quota['QMAX'],
941 1063
 			);
942
-		} else {
1064
+		}
1065
+		else
1066
+		{
943 1067
 			$quota = false;
944 1068
 		}
945 1069
 		return $quota;
@@ -955,7 +1079,11 @@  discard block
 block discarded – undo
955 1079
 	static function getTimeOut($_use='IMAP')
956 1080
 	{
957 1081
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
958
-		if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value
1082
+		if (empty($timeout))
1083
+		{
1084
+			$timeout = ($_use=='SIEVE'?10:20);
1085
+		}
1086
+		// this is the default value
959 1087
 		return $timeout;
960 1088
 	}
961 1089
 
@@ -973,9 +1101,13 @@  discard block
 block discarded – undo
973 1101
 		$foldersNameSpace = array();
974 1102
 		$delimiter = $this->getHierarchyDelimiter();
975 1103
 		// TODO: cache by $this->icServer->ImapServerId
976
-		if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray();
1104
+		if (is_null($nameSpace))
1105
+		{
1106
+			$nameSpace = $this->icServer->getNameSpaceArray();
1107
+		}
977 1108
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace));
978
-		if (is_array($nameSpace)) {
1109
+		if (is_array($nameSpace))
1110
+		{
979 1111
 			foreach($nameSpace as $type => $singleNameSpaceArray)
980 1112
 			{
981 1113
 				foreach ($singleNameSpaceArray as $singleNameSpace)
@@ -992,7 +1124,9 @@  discard block
 block discarded – undo
992 1124
 						$_foldersNameSpace['prefix_present'] = 'forced';
993 1125
 						// uw-imap server with mailbox prefix or dovecot maybe
994 1126
 						$_foldersNameSpace['prefix'] = 'mail';
995
-					} else {
1127
+					}
1128
+					else
1129
+					{
996 1130
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
997 1131
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
998 1132
 					}
@@ -1019,7 +1153,10 @@  discard block
 block discarded – undo
1019 1153
 		foreach($nameSpace as &$singleNameSpace)
1020 1154
 		{
1021 1155
 			//if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix'];
1022
-			if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix'];
1156
+			if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix'])
1157
+			{
1158
+				return $singleNameSpace['prefix'];
1159
+			}
1023 1160
 		}
1024 1161
 		return "";
1025 1162
 	}
@@ -1033,8 +1170,14 @@  discard block
 block discarded – undo
1033 1170
 	function getHierarchyDelimiter($_useCache=true)
1034 1171
 	{
1035 1172
 		static $HierarchyDelimiter = null;
1036
-		if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1037
-		if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
1173
+		if (is_null($HierarchyDelimiter))
1174
+		{
1175
+			$HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1176
+		}
1177
+		if ($_useCache===false)
1178
+		{
1179
+			unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
1180
+		}
1038 1181
 		if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId]))
1039 1182
 		{
1040 1183
 			return $HierarchyDelimiter[$this->icServer->ImapServerId];
@@ -1047,7 +1190,10 @@  discard block
 block discarded – undo
1047 1190
 		}
1048 1191
 		catch(\Exception $e)
1049 1192
 		{
1050
-			if ($e->getCode()==102) self::$profileDefunct[$this->profileID]=true;
1193
+			if ($e->getCode()==102)
1194
+			{
1195
+				self::$profileDefunct[$this->profileID]=true;
1196
+			}
1051 1197
 			unset($e);
1052 1198
 			$HierarchyDelimiter[$this->icServer->ImapServerId] = '/';
1053 1199
 		}
@@ -1064,14 +1210,19 @@  discard block
 block discarded – undo
1064 1210
 	{
1065 1211
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected);
1066 1212
 		static $_specialUseFolders = null;
1067
-		if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1213
+		if (is_null($_specialUseFolders)||empty($_specialUseFolders))
1214
+		{
1215
+			$_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1216
+		}
1068 1217
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash));
1069 1218
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent));
1070 1219
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft));
1071 1220
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template));
1072 1221
 		self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
1073 1222
 		if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId]))
1074
-			return $_specialUseFolders[$this->icServer->ImapServerId];
1223
+		{
1224
+					return $_specialUseFolders[$this->icServer->ImapServerId];
1225
+		}
1075 1226
 		$_specialUseFolders[$this->icServer->ImapServerId]=array();
1076 1227
 		//if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]))
1077 1228
 			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash';
@@ -1099,7 +1250,8 @@  discard block
 block discarded – undo
1099 1250
 	function folderIsSelectable($folderToSelect)
1100 1251
 	{
1101 1252
 		$retval = true;
1102
-		if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) {
1253
+		if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true)))
1254
+		{
1103 1255
 			if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false)
1104 1256
 			{
1105 1257
 				$retval = false;
@@ -1152,7 +1304,10 @@  discard block
 block discarded – undo
1152 1304
 	 */
1153 1305
 	function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true)
1154 1306
 	{
1155
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly");
1307
+		if (self::$debug)
1308
+		{
1309
+			error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly");
1310
+		}
1156 1311
 		if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID]===true))
1157 1312
 		{
1158 1313
 			// something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request
@@ -1164,7 +1319,10 @@  discard block
 block discarded – undo
1164 1319
 		{
1165 1320
 			$folderInfoCache = $folderBasicInfo[$this->profileID];
1166 1321
 		}
1167
-		if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName];
1322
+		if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly)
1323
+		{
1324
+			return $folderInfoCache[$_folderName];
1325
+		}
1168 1326
 		$retValue = array();
1169 1327
 		$retValue['subscribed'] = false;
1170 1328
 /*
@@ -1192,7 +1350,10 @@  discard block
 block discarded – undo
1192 1350
 			if (is_array($ret))
1193 1351
 			{
1194 1352
 				$retkeys = array_keys($ret);
1195
-				if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]];
1353
+				if ($retkeys[0]==$_folderName)
1354
+				{
1355
+					$folderInfoCache[$_folderName] = $ret[$retkeys[0]];
1356
+				}
1196 1357
 			}
1197 1358
 			else
1198 1359
 			{
@@ -1201,7 +1362,8 @@  discard block
 block discarded – undo
1201 1362
 		}
1202 1363
 		$folderInfo = $folderInfoCache[$_folderName];
1203 1364
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace());
1204
-		if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) {
1365
+		if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo))
1366
+		{
1205 1367
 			try
1206 1368
 			{
1207 1369
 				$folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache);
@@ -1235,7 +1397,8 @@  discard block
 block discarded – undo
1235 1397
 		$retValue['shortName']		= array_pop($shortNameParts);
1236 1398
 		$retValue['displayName']	= $_folderName;
1237 1399
 		$retValue['shortDisplayName']	= $retValue['shortName'];
1238
-		if(strtoupper($retValue['shortName']) == 'INBOX') {
1400
+		if(strtoupper($retValue['shortName']) == 'INBOX')
1401
+		{
1239 1402
 			$retValue['displayName']	= lang('INBOX');
1240 1403
 			$retValue['shortDisplayName']	= lang('INBOX');
1241 1404
 		}
@@ -1244,7 +1407,10 @@  discard block
 block discarded – undo
1244 1407
 		{
1245 1408
 			$retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']);
1246 1409
 		}
1247
-		if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue;
1410
+		if ($folderInfo)
1411
+		{
1412
+			$folderBasicInfo[$this->profileID][$_folderName]=$retValue;
1413
+		}
1248 1414
 		//error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes']));
1249 1415
 		if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false))
1250 1416
 		{
@@ -1256,24 +1422,34 @@  discard block
 block discarded – undo
1256 1422
 		static $subscribedFolders = null;
1257 1423
 		static $nameSpace = null;
1258 1424
 		static $prefix = null;
1259
-		if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces();
1425
+		if (is_null($nameSpace) || empty($nameSpace[$this->profileID]))
1426
+		{
1427
+			$nameSpace[$this->profileID] = $this->_getNameSpaces();
1428
+		}
1260 1429
 		if (!empty($nameSpace[$this->profileID]))
1261 1430
 		{
1262 1431
 			$nsNoPersonal=array();
1263 1432
 			foreach($nameSpace[$this->profileID] as &$ns)
1264 1433
 			{
1265
-				if ($ns['type']!='personal') $nsNoPersonal[]=$ns;
1434
+				if ($ns['type']!='personal')
1435
+				{
1436
+					$nsNoPersonal[]=$ns;
1437
+				}
1266 1438
 			}
1267 1439
 			$nameSpace[$this->profileID]=$nsNoPersonal;
1268 1440
 		}
1269
-		if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName);
1441
+		if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName]))
1442
+		{
1443
+			$prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName);
1444
+		}
1270 1445
 
1271 1446
 		if ($fetchSubscribedInfo && is_null($subscribedFolders) || empty($subscribedFolders[$this->profileID]))
1272 1447
 		{
1273 1448
 			$subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes();
1274 1449
 		}
1275 1450
 
1276
-		if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) {
1451
+		if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID]))
1452
+		{
1277 1453
 			$retValue['subscribed'] = true;
1278 1454
 		}
1279 1455
 
@@ -1292,8 +1468,7 @@  discard block
 block discarded – undo
1292 1468
 				(isset($this->mailPreferences['trustServersUnseenInfo']) &&
1293 1469
 				$this->mailPreferences['trustServersUnseenInfo']==2 &&
1294 1470
 				$prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false)
1295
-			)
1296
-			{
1471
+			) {
1297 1472
 				//error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']);
1298 1473
 				// we filter for the combined status of unseen and undeleted, as this is what we show in list
1299 1474
 				try
@@ -1303,13 +1478,19 @@  discard block
 block discarded – undo
1303 1478
 				}
1304 1479
 				catch (\Exception $ee)
1305 1480
 				{
1306
-					if (self::$debug) error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested.");
1481
+					if (self::$debug)
1482
+					{
1483
+						error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested.");
1484
+					}
1307 1485
 				}
1308 1486
 			}
1309 1487
 		}
1310 1488
 		catch (\Exception $e)
1311 1489
 		{
1312
-			if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true));
1490
+			if (self::$debug)
1491
+			{
1492
+				error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true));
1493
+			}
1313 1494
 		}
1314 1495
 
1315 1496
 		return $retValue;
@@ -1334,8 +1515,14 @@  discard block
 block discarded – undo
1334 1515
 	function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false)
1335 1516
 	{
1336 1517
 		//self::$debug=true;
1337
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace());
1338
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly");
1518
+		if (self::$debug)
1519
+		{
1520
+			error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace());
1521
+		}
1522
+		if (self::$debug)
1523
+		{
1524
+			error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly");
1525
+		}
1339 1526
 		$reverse = (bool)$_reverse;
1340 1527
 		// get the list of messages to fetch
1341 1528
 		$this->reopen($_folderName);
@@ -1356,21 +1543,34 @@  discard block
 block discarded – undo
1356 1543
 				//$_filter['range'] ="$start:$end";
1357 1544
 				//$_filter['range'] ="$_startMessage:*";
1358 1545
 			}
1359
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid");
1360
-			if (self::$debug||self::$debugTimes) $starttime = microtime (true);
1546
+			if (self::$debug)
1547
+			{
1548
+				error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid");
1549
+			}
1550
+			if (self::$debug||self::$debugTimes)
1551
+			{
1552
+				$starttime = microtime (true);
1553
+			}
1361 1554
 			//see this example below for a 12 week datefilter (since)
1362 1555
 			//$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12)));
1363 1556
 			$_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult);
1364 1557
 			$sortResult = $_sortResult['match']->ids;
1365 1558
 			//$modseq = $_sortResult['modseq'];
1366 1559
 			//error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq);
1367
-			if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') ');
1560
+			if (self::$debug||self::$debugTimes)
1561
+			{
1562
+				self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') ');
1563
+			}
1368 1564
 
1369
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1565
+			if (self::$debug)
1566
+			{
1567
+				error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1568
+			}
1370 1569
 			#$this->icServer->setDebug(false);
1371 1570
 			#print "</pre>";
1372 1571
 			// nothing found
1373
-			if(!is_array($sortResult) || empty($sortResult)) {
1572
+			if(!is_array($sortResult) || empty($sortResult))
1573
+			{
1374 1574
 				$retValue = array();
1375 1575
 				$retValue['info']['total']	= 0;
1376 1576
 				$retValue['info']['first']	= 0;
@@ -1382,7 +1582,8 @@  discard block
 block discarded – undo
1382 1582
 			#_debug_array($sortResult);
1383 1583
 			#_debug_array(array_slice($sortResult, -5, -2));
1384 1584
 			//error_log("REVERSE: $reverse");
1385
-			if($reverse === true) {
1585
+			if($reverse === true)
1586
+			{
1386 1587
 				if  ($_startMessage<=$total)
1387 1588
 				{
1388 1589
 					$startMessage = $_startMessage-1;
@@ -1394,7 +1595,10 @@  discard block
 block discarded – undo
1394 1595
 					{
1395 1596
 						$numberOfMessages = $total%$_numberOfMessages;
1396 1597
 						//$numberOfMessages = abs($_startMessage-$total-1);
1397
-						if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages;
1598
+						if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages)
1599
+						{
1600
+							$_numberOfMessages = $numberOfMessages;
1601
+						}
1398 1602
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total);
1399 1603
 					}
1400 1604
 					$startMessage=($total-$_numberOfMessages)-1;
@@ -1408,19 +1612,36 @@  discard block
 block discarded – undo
1408 1612
 					//$retValue['info']['first'] = $startMessage;
1409 1613
 					//$retValue['info']['last'] = $total;
1410 1614
 				}
1411
-				if($startMessage > 0) {
1412
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult));
1615
+				if($startMessage > 0)
1616
+				{
1617
+					if (self::$debug)
1618
+					{
1619
+						error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult));
1620
+					}
1413 1621
 					$sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage);
1414
-				} else {
1415
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult));
1622
+				}
1623
+				else
1624
+				{
1625
+					if (self::$debug)
1626
+					{
1627
+						error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult));
1628
+					}
1416 1629
 					$sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1)));
1417 1630
 				}
1418 1631
 				$sortResult = array_reverse($sortResult);
1419
-			} else {
1420
-				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult));
1632
+			}
1633
+			else
1634
+			{
1635
+				if (self::$debug)
1636
+				{
1637
+					error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult));
1638
+				}
1421 1639
 				$sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages);
1422 1640
 			}
1423
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1641
+			if (self::$debug)
1642
+			{
1643
+				error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1644
+			}
1424 1645
 		}
1425 1646
 		else
1426 1647
 		{
@@ -1429,7 +1650,10 @@  discard block
 block discarded – undo
1429 1650
 
1430 1651
 
1431 1652
 		// fetch the data for the selected messages
1432
-		if (self::$debug||self::$debugTimes) $starttime = microtime(true);
1653
+		if (self::$debug||self::$debugTimes)
1654
+		{
1655
+			$starttime = microtime(true);
1656
+		}
1433 1657
 		try
1434 1658
 		{
1435 1659
 			$uidsToFetch = new Horde_Imap_Client_Ids();
@@ -1453,7 +1677,10 @@  discard block
 block discarded – undo
1453 1677
 			$fquery->flags();
1454 1678
 			$fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time
1455 1679
 			// if $_fetchPreviews is activated fetch part of the messages too
1456
-			if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0));
1680
+			if ($_fetchPreviews)
1681
+			{
1682
+				$fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0));
1683
+			}
1457 1684
 			$headersNew = $this->icServer->fetch($_folderName, $fquery, array(
1458 1685
 				'ids' => $uidsToFetch,
1459 1686
 			));
@@ -1476,14 +1703,20 @@  discard block
 block discarded – undo
1476 1703
 
1477 1704
 		$cnt = 0;
1478 1705
 
1479
-		foreach((array)$sortResult as $uid) {
1706
+		foreach((array)$sortResult as $uid)
1707
+		{
1480 1708
 			$sortOrder[$uid] = $cnt++;
1481 1709
 		}
1482 1710
 
1483 1711
 		$count = 0;
1484
-		if (is_object($headersNew)) {
1485
-			if (self::$debug||self::$debugTimes) $starttime = microtime(true);
1486
-			foreach($headersNew->ids() as $id) {
1712
+		if (is_object($headersNew))
1713
+		{
1714
+			if (self::$debug||self::$debugTimes)
1715
+			{
1716
+				$starttime = microtime(true);
1717
+			}
1718
+			foreach($headersNew->ids() as $id)
1719
+			{
1487 1720
 				$_headerObject = $headersNew->get($id);
1488 1721
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject));
1489 1722
 				$headerObject = array();
@@ -1496,7 +1729,10 @@  discard block
 block discarded – undo
1496 1729
 				// Get already cached headers, 'fetchHeaders' is a label matchimg above
1497 1730
 				$headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray();
1498 1731
 				// Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com
1499
-				if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray();
1732
+				if (empty($headerForPrio))
1733
+				{
1734
+					$headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray();
1735
+				}
1500 1736
 				//fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns
1501 1737
 				//nothing worthwhile (as it does for googlemail accounts, when preview is switched on
1502 1738
 				if ($_fetchPreviews)
@@ -1507,12 +1743,16 @@  discard block
 block discarded – undo
1507 1743
 					if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio['']))
1508 1744
 					{
1509 1745
 						$length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL);
1510
-						if ($length===false) $length = strlen($bodyPreview);
1746
+						if ($length===false)
1747
+						{
1748
+							$length = strlen($bodyPreview);
1749
+						}
1511 1750
 						$headerForPrio =  Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray();
1512 1751
 					}
1513 1752
 				}
1514 1753
 				$headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER);
1515
-				if (self::$debug) {
1754
+				if (self::$debug)
1755
+				{
1516 1756
 					error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(),'Y-m-d H:i:s'));
1517 1757
 					error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio));
1518 1758
 				}
@@ -1522,11 +1762,16 @@  discard block
 block discarded – undo
1522 1762
 					$total--;
1523 1763
 					continue;
1524 1764
 				}
1525
-				if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) {
1765
+				if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) )
1766
+				{
1526 1767
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO']));
1527
-				} else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) {
1768
+				}
1769
+				else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) )
1770
+				{
1528 1771
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO']));
1529
-				} else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) {
1772
+				}
1773
+				else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) )
1774
+				{
1530 1775
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO']));
1531 1776
 				} /*else $sent_not = "";*/
1532 1777
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject));
@@ -1557,7 +1802,11 @@  discard block
 block discarded – undo
1557 1802
 						$rfcAddr = self::parseAddressList($ad); // does some fixing of known problems too
1558 1803
 						foreach ($rfcAddr as $_rfcAddr)
1559 1804
 						{
1560
-							if (!$_rfcAddr->valid)	continue; // skip. not a valid address
1805
+							if (!$_rfcAddr->valid)
1806
+							{
1807
+								continue;
1808
+							}
1809
+							// skip. not a valid address
1561 1810
 							$address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal);
1562 1811
 						}
1563 1812
 					}
@@ -1573,7 +1822,10 @@  discard block
 block discarded – undo
1573 1822
 				{
1574 1823
 					// $bodyPreview is populated at the beginning of the loop, as it may be
1575 1824
 					// needed to parse the Headers of the Message
1576
-					if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg();
1825
+					if (empty($bodyPreview))
1826
+					{
1827
+						$bodyPreview = $_headerObject->getFullMsg();
1828
+					}
1577 1829
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview));
1578 1830
 					$base = Horde_Mime_Part::parseMessage($bodyPreview);
1579 1831
 					foreach($base->partIterator() as $part)
@@ -1586,7 +1838,8 @@  discard block
 block discarded – undo
1586 1838
 												'encode' => Horde_Mime_Part::ENCODE_BINARY,	// otherwise we cant recode charset
1587 1839
 											)), $charset, 'utf-8');
1588 1840
 							$headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews))));
1589
-						} elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart')
1841
+						}
1842
+						elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart')
1590 1843
 						{
1591 1844
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($part));
1592 1845
 						}
@@ -1602,7 +1855,10 @@  discard block
 block discarded – undo
1602 1855
 				$messageMimeType='';
1603 1856
 				foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type)
1604 1857
 				{
1605
-					if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type;
1858
+					if ($mime_id==0 || $messageMimeType==='')
1859
+					{
1860
+						$messageMimeType = $mime_type;
1861
+					}
1606 1862
 					$part = $mailStructureObject->getPart($mime_id);
1607 1863
 					$partdisposition = $part->getDisposition();
1608 1864
 					$partPrimaryType = $part->getPrimaryType();
@@ -1612,7 +1868,8 @@  discard block
 block discarded – undo
1612 1868
 					// bodypreview could be found (multipart/....)
1613 1869
 					if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') &&
1614 1870
 						((intval($mime_id) === 1) || !$mime_id) &&
1615
-						($partdisposition !== 'attachment')) {
1871
+						($partdisposition !== 'attachment'))
1872
+					{
1616 1873
 							$_structure=$part;
1617 1874
 							$this->fetchPartContents($uid, $_structure, false,true);
1618 1875
 							$headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews))));
@@ -1634,10 +1891,19 @@  discard block
 block discarded – undo
1634 1891
 					if ($mime_type=='message/rfc822')
1635 1892
 					{
1636 1893
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap()));
1637
-						foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;}
1894
+						foreach($part->contentTypeMap() as $sub_id => $sub_type)
1895
+						{
1896
+if ($sub_id != $mime_id)
1897
+						{
1898
+							$skipParts[$sub_id] = $sub_type;
1899
+						}
1900
+						}
1638 1901
 					}
1639 1902
 					//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts));
1640
-					if (array_key_exists($mime_id,$skipParts)) continue;
1903
+					if (array_key_exists($mime_id,$skipParts))
1904
+					{
1905
+						continue;
1906
+					}
1641 1907
 					if ($partdisposition=='attachment' ||
1642 1908
 						($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs
1643 1909
 						($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) ||
@@ -1648,7 +1914,10 @@  discard block
 block discarded – undo
1648 1914
 						$headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid;
1649 1915
 						$headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid;
1650 1916
 						$headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id;
1651
-						if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName();
1917
+						if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))
1918
+						{
1919
+							$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName();
1920
+						}
1652 1921
 						if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') ||
1653 1922
 							$headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef')
1654 1923
 						{
@@ -1662,18 +1931,27 @@  discard block
 block discarded – undo
1662 1931
 				//error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (plain):'.array2string($mailStructureObject->findBody('plain')));
1663 1932
 				//error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (html):'.array2string($mailStructureObject->findBody('html')));
1664 1933
 				//if($count == 0) error_log(__METHOD__.array2string($headerObject));
1665
-				if (empty($headerObject['UID'])) continue;
1934
+				if (empty($headerObject['UID']))
1935
+				{
1936
+					continue;
1937
+				}
1666 1938
 				//$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']);
1667 1939
 				// make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime
1668
-				if(substr($headerObject['DATE'],-2) === 'UT') {
1940
+				if(substr($headerObject['DATE'],-2) === 'UT')
1941
+				{
1669 1942
 					$headerObject['DATE'] .= 'C';
1670 1943
 				}
1671
-				if(substr($headerObject['INTERNALDATE'],-2) === 'UT') {
1944
+				if(substr($headerObject['INTERNALDATE'],-2) === 'UT')
1945
+				{
1672 1946
 					$headerObject['INTERNALDATE'] .= 'C';
1673 1947
 				}
1674 1948
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#');
1675 1949
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']);
1676
-				if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;}
1950
+				if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS']))
1951
+				{
1952
+					foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;
1953
+				}
1954
+				}
1677 1955
 				$retValue['header'][$sortOrder[$uid]]['subject']	= $this->decode_subject($headerObject['SUBJECT']);
1678 1956
 				$retValue['header'][$sortOrder[$uid]]['size'] 		= $headerObject['SIZE'];
1679 1957
 				$retValue['header'][$sortOrder[$uid]]['date']		= self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true);
@@ -1684,22 +1962,31 @@  discard block
 block discarded – undo
1684 1962
 				$retValue['header'][$sortOrder[$uid]]['bodypreview']		= $headerObject['BODYPREVIEW'];
1685 1963
 				$retValue['header'][$sortOrder[$uid]]['priority']		= ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3);
1686 1964
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]]));
1687
-				if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO'];
1688
-				if (is_array($headerObject['FLAGS'])) {
1965
+				if (isset($headerObject['DISPOSITION-NOTIFICATION-TO']))
1966
+				{
1967
+					$retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO'];
1968
+				}
1969
+				if (is_array($headerObject['FLAGS']))
1970
+				{
1689 1971
 					$retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject));
1690 1972
 				}
1691 1973
 				//error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from')));
1692
-				if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) {
1974
+				if(is_array($headerObject['FROM']) && $headerObject['FROM'][0])
1975
+				{
1693 1976
 					$retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true);
1694 1977
 				}
1695
-				if(is_array($headerObject['TO']) && $headerObject['TO'][0]) {
1978
+				if(is_array($headerObject['TO']) && $headerObject['TO'][0])
1979
+				{
1696 1980
 					$retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true);
1697 1981
 					if (count($headerObject['TO'])>1)
1698 1982
 					{
1699 1983
 						$ki=0;
1700 1984
 						foreach($headerObject['TO'] as $k => $add)
1701 1985
 						{
1702
-							if ($k==0) continue;
1986
+							if ($k==0)
1987
+							{
1988
+								continue;
1989
+							}
1703 1990
 							//error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add));
1704 1991
 							$retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true);
1705 1992
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki]));
@@ -1707,7 +1994,8 @@  discard block
 block discarded – undo
1707 1994
 						}
1708 1995
 					}
1709 1996
 				}
1710
-				if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) {
1997
+				if(is_array($headerObject['CC']) && count($headerObject['CC'])>0)
1998
+				{
1711 1999
 					$ki=0;
1712 2000
 					foreach($headerObject['CC'] as $k => $add)
1713 2001
 					{
@@ -1721,27 +2009,41 @@  discard block
 block discarded – undo
1721 2009
 
1722 2010
 				$count++;
1723 2011
 			}
1724
-			if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') ');
2012
+			if (self::$debug||self::$debugTimes)
2013
+			{
2014
+				self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') ');
2015
+			}
1725 2016
 			//self::$debug=false;
1726 2017
 			// sort the messages to the requested displayorder
1727
-			if(is_array($retValue['header'])) {
2018
+			if(is_array($retValue['header']))
2019
+			{
1728 2020
 				$countMessages = $total;
1729
-				if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages'];
2021
+				if (isset($_filter['range']))
2022
+				{
2023
+					$countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages'];
2024
+				}
1730 2025
 				ksort($retValue['header']);
1731 2026
 				$retValue['info']['total']	= $total;
1732 2027
 				//if ($_startMessage>$total) $_startMessage = $total-($count-1);
1733 2028
 				$retValue['info']['first']	= $_startMessage;
1734 2029
 				$retValue['info']['last']	= $_startMessage + $count - 1 ;
1735 2030
 				return $retValue;
1736
-			} else {
2031
+			}
2032
+			else
2033
+			{
1737 2034
 				$retValue = array();
1738 2035
 				$retValue['info']['total']	= 0;
1739 2036
 				$retValue['info']['first']	= 0;
1740 2037
 				$retValue['info']['last']	= 0;
1741 2038
 				return $retValue;
1742 2039
 			}
1743
-		} else {
1744
-			if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE));
2040
+		}
2041
+		else
2042
+		{
2043
+			if ($headersNew == null && empty($_thisUIDOnly))
2044
+			{
2045
+				error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE));
2046
+			}
1745 2047
 			$retValue = array();
1746 2048
 			$retValue['info']['total']  = 0;
1747 2049
 			$retValue['info']['first']  = 0;
@@ -1758,7 +2060,10 @@  discard block
 block discarded – undo
1758 2060
 	 */
1759 2061
 	static function prepareFlagsArray($headerObject)
1760 2062
 	{
1761
-		if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']);
2063
+		if (is_array($headerObject['FLAGS']))
2064
+		{
2065
+			$headerFlags = array_map('strtolower',$headerObject['FLAGS']);
2066
+		}
1762 2067
 		$retValue = array();
1763 2068
 		$retValue['recent']		= in_array('\\recent', $headerFlags);
1764 2069
 		$retValue['flagged']	= in_array('\\flagged', $headerFlags);
@@ -1809,24 +2114,43 @@  discard block
 block discarded – undo
1809 2114
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter));
1810 2115
 		$try2useCache = true;
1811 2116
 		static $eMailListContainsDeletedMessages = null;
1812
-		if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2117
+		if (is_null($eMailListContainsDeletedMessages))
2118
+		{
2119
+			$eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2120
+		}
1813 2121
 		// this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED
1814 2122
 		if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false)))
1815 2123
 		{
1816
-			if (self::$debugTimes) $starttime = microtime(true);
1817
-			if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
1818
-			$deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false);
1819
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages));
1820
-			$eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count'];
1821
-			Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1);
1822
-			if (self::$debugTimes) self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') ');			//error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']);
2124
+			if (self::$debugTimes)
2125
+			{
2126
+				$starttime = microtime(true);
2127
+			}
2128
+			if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName]))
2129
+			{
2130
+				$eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2131
+			}
2132
+			$deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false);
2133
+			if (self::$debug)
2134
+			{
2135
+				error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages));
2136
+			}
2137
+			$eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count'];
2138
+			Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1);
2139
+			if (self::$debugTimes)
2140
+			{
2141
+				self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') ');
2142
+			}
2143
+			//error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']);
1823 2144
 		}
1824 2145
 		$try2useCache = false;
1825 2146
 		//self::$supportsORinQuery[$this->profileID]=true;
1826 2147
 		if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID]))
1827 2148
 		{
1828 2149
 			self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
1829
-			if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true;
2150
+			if (!isset(self::$supportsORinQuery[$this->profileID]))
2151
+			{
2152
+				self::$supportsORinQuery[$this->profileID]=true;
2153
+			}
1830 2154
 		}
1831 2155
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]);
1832 2156
 		$filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]);
@@ -1837,15 +2161,26 @@  discard block
 block discarded – undo
1837 2161
 		}
1838 2162
 		//_debug_array($filter);
1839 2163
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability()));
1840
-		if($this->icServer->hasCapability('SORT')) {
2164
+		if($this->icServer->hasCapability('SORT'))
2165
+		{
1841 2166
 			// when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client
1842 2167
 			// thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if
1843 2168
 			// there is no messing with the dates)
1844 2169
 			//if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE';
1845
-			if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse");
2170
+			if (self::$debug)
2171
+			{
2172
+				error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse");
2173
+			}
1846 2174
 			$sortOrder = $this->_getSortString($_sort, $_reverse);
1847
-			if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already
1848
-			if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter));
2175
+			if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder))
2176
+			{
2177
+				$_reverse=false;
2178
+			}
2179
+			// as we reversed the result already
2180
+			if (self::$debug)
2181
+			{
2182
+				error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter));
2183
+			}
1849 2184
 			try
1850 2185
 			{
1851 2186
 				$sortResult = $this->icServer->search($_folderName, $filter, array(
@@ -1857,7 +2192,10 @@  discard block
 block discarded – undo
1857 2192
 				//error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage());
1858 2193
 				$resultByUid = false;
1859 2194
 				$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE);
1860
-				if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
2195
+				if ($_reverse)
2196
+				{
2197
+					array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
2198
+				}
1861 2199
 				try
1862 2200
 				{
1863 2201
 					$sortResult = $this->icServer->search($_folderName, $filter, array(
@@ -1869,9 +2207,17 @@  discard block
 block discarded – undo
1869 2207
 					$sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'];
1870 2208
 				}
1871 2209
 			}
1872
-			if (self::$debug) error_log(__METHOD__.print_r($sortResult,true));
1873
-		} else {
1874
-			if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability");
2210
+			if (self::$debug)
2211
+			{
2212
+				error_log(__METHOD__.print_r($sortResult,true));
2213
+			}
2214
+		}
2215
+		else
2216
+		{
2217
+			if (self::$debug)
2218
+			{
2219
+				error_log(__METHOD__." Mailserver has NO SORT Capability");
2220
+			}
1875 2221
 			//$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE);
1876 2222
 			//if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
1877 2223
 			try
@@ -1885,7 +2231,10 @@  discard block
 block discarded – undo
1885 2231
 				// possible error OR Query. But Horde gives no detailed Info :-(
1886 2232
 				self::$supportsORinQuery[$this->profileID]=false;
1887 2233
 				Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10);
1888
-				if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message);
2234
+				if (self::$debug)
2235
+				{
2236
+					error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message);
2237
+				}
1889 2238
 				$filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]);
1890 2239
 				try
1891 2240
 				{
@@ -1896,11 +2245,15 @@  discard block
 block discarded – undo
1896 2245
 				{
1897 2246
 				}
1898 2247
 			}
1899
-			if(is_array($sortResult['match'])) {
2248
+			if(is_array($sortResult['match']))
2249
+			{
1900 2250
 					// not sure that this is going so succeed as $sortResult['match'] is a hordeObject
1901 2251
 					sort($sortResult['match'], SORT_NUMERIC);
1902 2252
 			}
1903
-			if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true));
2253
+			if (self::$debug)
2254
+			{
2255
+				error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true));
2256
+			}
1904 2257
 		}
1905 2258
 		if ($setSession)
1906 2259
 		{
@@ -1929,7 +2282,8 @@  discard block
 block discarded – undo
1929 2282
 		$_reverse=false;
1930 2283
 		if (is_numeric($_sort))
1931 2284
 		{
1932
-			switch($_sort) {
2285
+			switch($_sort)
2286
+			{
1933 2287
 				case 2:
1934 2288
 					$retValue = array(Horde_Imap_Client::SORT_FROM);
1935 2289
 					break;
@@ -1951,7 +2305,8 @@  discard block
 block discarded – undo
1951 2305
 		}
1952 2306
 		else
1953 2307
 		{
1954
-			switch(strtoupper($_sort)) {
2308
+			switch(strtoupper($_sort))
2309
+			{
1955 2310
 				case 'FROMADDRESS':
1956 2311
 					$retValue = array(Horde_Imap_Client::SORT_FROM);
1957 2312
 					break;
@@ -1977,7 +2332,10 @@  discard block
 block discarded – undo
1977 2332
 					break;
1978 2333
 			}
1979 2334
 		}
1980
-		if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE);
2335
+		if ($_reverse)
2336
+		{
2337
+			array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE);
2338
+		}
1981 2339
 		//error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue);
1982 2340
 		return $retValue;
1983 2341
 	}
@@ -1996,7 +2354,10 @@  discard block
 block discarded – undo
1996 2354
 		$imapFilter->charset('UTF-8');
1997 2355
 
1998 2356
 		//_debug_array($_criterias);
1999
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
2357
+		if (self::$debug)
2358
+		{
2359
+			error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
2360
+		}
2000 2361
 		if((!is_array($_criterias) || $_criterias['status']=='any') &&
2001 2362
 			(!isset($_criterias['string']) || empty($_criterias['string'])) &&
2002 2363
 			(!isset($_criterias['range'])|| empty($_criterias['range']) ||
@@ -2011,11 +2372,13 @@  discard block
 block discarded – undo
2011 2372
 		// statusQuery MUST be placed first, as search for subject/mailbody and such is
2012 2373
 		// depending on charset. flagSearch is not BUT messes the charset if called afterwards
2013 2374
 		$statusQueryValid = false;
2014
-		foreach((array)$_criterias['status'] as $k => $criteria) {
2375
+		foreach((array)$_criterias['status'] as $k => $criteria)
2376
+		{
2015 2377
 			$imapStatusFilter = new Horde_Imap_Client_Search_Query();
2016 2378
 			$imapStatusFilter->charset('UTF-8');
2017 2379
 			$criteria = strtoupper($criteria);
2018
-			switch ($criteria) {
2380
+			switch ($criteria)
2381
+			{
2019 2382
 				case 'ANSWERED':
2020 2383
 				case 'DELETED':
2021 2384
 				case 'FLAGGED':
@@ -2098,9 +2461,11 @@  discard block
 block discarded – undo
2098 2461
 		$imapSearchFilter = new Horde_Imap_Client_Search_Query();
2099 2462
 		$imapSearchFilter->charset('UTF-8');
2100 2463
 
2101
-		if(!empty($_criterias['string'])) {
2464
+		if(!empty($_criterias['string']))
2465
+		{
2102 2466
 			$criteria = strtoupper($_criterias['type']);
2103
-			switch ($criteria) {
2467
+			switch ($criteria)
2468
+			{
2104 2469
 				case 'BYDATE':
2105 2470
 				case 'QUICK':
2106 2471
 				case 'QUICKWITHCC':
@@ -2108,9 +2473,12 @@  discard block
 block discarded – undo
2108 2473
 					//$imapSearchFilter->charset('UTF-8');
2109 2474
 					$imapFilter2 = new Horde_Imap_Client_Search_Query();
2110 2475
 					$imapFilter2->charset('UTF-8');
2111
-					if($this->isSentFolder($_folder)) {
2476
+					if($this->isSentFolder($_folder))
2477
+					{
2112 2478
 						$imapFilter2->headerText('TO', $_criterias['string'], $not=false);
2113
-					} else {
2479
+					}
2480
+					else
2481
+					{
2114 2482
 						$imapFilter2->headerText('FROM', $_criterias['string'], $not=false);
2115 2483
 					}
2116 2484
 					if ($_supportsOrInQuery)
@@ -2141,7 +2509,10 @@  discard block
 block discarded – undo
2141 2509
 											'GB'=>1024*1000*1000,'G'=>1024*1000*1000,
2142 2510
 											'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000);
2143 2511
 						$numberinBytes=(float)$_criterias['string'];
2144
-						if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit];
2512
+						if (isset($multipleBy[$unit]))
2513
+						{
2514
+							$numberinBytes=(float)$_criterias['string']*$multipleBy[$unit];
2515
+						}
2145 2516
 						//error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes);
2146 2517
 						$_criterias['string']=$numberinBytes;
2147 2518
 					}
@@ -2178,8 +2549,14 @@  discard block
 block discarded – undo
2178 2549
 					break;
2179 2550
 			}
2180 2551
 		}
2181
-		if ($statusQueryValid && !$queryValid) $queryValid=true;
2182
-		if ($queryValid) $imapFilter->andSearch($imapSearchFilter);
2552
+		if ($statusQueryValid && !$queryValid)
2553
+		{
2554
+			$queryValid=true;
2555
+		}
2556
+		if ($queryValid)
2557
+		{
2558
+			$imapFilter->andSearch($imapSearchFilter);
2559
+		}
2183 2560
 
2184 2561
 		if (isset($_criterias['range']) && !empty($_criterias['range']))
2185 2562
 		{
@@ -2194,7 +2571,8 @@  discard block
 block discarded – undo
2194 2571
 				unset($_criterias['before']);
2195 2572
 				$criteria=$_criterias['range']='ON';
2196 2573
 			}
2197
-			switch ($criteria) {
2574
+			switch ($criteria)
2575
+			{
2198 2576
 				case 'BETWEEN':
2199 2577
 					//try to be smart about missing
2200 2578
 					//enddate
@@ -2230,8 +2608,14 @@  discard block
 block discarded – undo
2230 2608
 					$rangeValid = true;
2231 2609
 					break;
2232 2610
 			}
2233
-			if ($rangeValid && !$queryValid) $queryValid=true;
2234
-			if ($rangeValid) $imapFilter->andSearch($imapRangeFilter);
2611
+			if ($rangeValid && !$queryValid)
2612
+			{
2613
+				$queryValid=true;
2614
+			}
2615
+			if ($rangeValid)
2616
+			{
2617
+				$imapFilter->andSearch($imapRangeFilter);
2618
+			}
2235 2619
 		}
2236 2620
 		if (self::$debug)
2237 2621
 		{
@@ -2239,10 +2623,13 @@  discard block
 block discarded – undo
2239 2623
 			$query_str = $imapFilter->build();
2240 2624
 			//error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
2241 2625
 		}
2242
-		if($queryValid==false) {
2626
+		if($queryValid==false)
2627
+		{
2243 2628
 			$imapFilter->flag('DELETED', $set=false);
2244 2629
 			return $imapFilter;
2245
-		} else {
2630
+		}
2631
+		else
2632
+		{
2246 2633
 			return $imapFilter;
2247 2634
 		}
2248 2635
 	}
@@ -2299,7 +2686,10 @@  discard block
 block discarded – undo
2299 2686
 					}
2300 2687
 					$stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal);
2301 2688
 				}
2302
-				if (!empty($stringA)) $_string = implode(',',$stringA);
2689
+				if (!empty($stringA))
2690
+				{
2691
+					$_string = implode(',',$stringA);
2692
+				}
2303 2693
 			}
2304 2694
 			if ($_tryIDNConversion==='FORCE')
2305 2695
 			{
@@ -2324,7 +2714,10 @@  discard block
 block discarded – undo
2324 2714
 		{
2325 2715
 			return 'No Subject';
2326 2716
 		}
2327
-		if ($decode) $_string = self::decode_header($_string);
2717
+		if ($decode)
2718
+		{
2719
+			$_string = self::decode_header($_string);
2720
+		}
2328 2721
 		// make sure its utf-8
2329 2722
 		$test = @json_encode($_string);
2330 2723
 		if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0)
@@ -2362,7 +2755,8 @@  discard block
 block discarded – undo
2362 2755
 	 * @param string _parent the parent foldername
2363 2756
 	 * @return ISO-8859-1 / UTF7-IMAP encoded string
2364 2757
 	 */
2365
-	function _encodeFolderName($_folderName) {
2758
+	function _encodeFolderName($_folderName)
2759
+	{
2366 2760
 		return Translation::convert($_folderName, self::$displayCharset, 'ISO-8859-1');
2367 2761
 		#return Translation::convert($_folderName, self::$displayCharset, 'UTF7-IMAP');
2368 2762
 	}
@@ -2378,21 +2772,36 @@  discard block
 block discarded – undo
2378 2772
 	 */
2379 2773
 	function createFolder($_parent, $_folderName, &$_error)
2380 2774
 	{
2381
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace());
2775
+		if (self::$debug)
2776
+		{
2777
+			error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace());
2778
+		}
2382 2779
 		$parent		= $_parent;//$this->_encodeFolderName($_parent);
2383 2780
 		$folderName	= $_folderName;//$this->_encodeFolderName($_folderName);
2384 2781
 
2385
-		if(empty($parent)) {
2782
+		if(empty($parent))
2783
+		{
2386 2784
 			$newFolderName = $folderName;
2387
-		} else {
2785
+		}
2786
+		else
2787
+		{
2388 2788
 			$HierarchyDelimiter = $this->getHierarchyDelimiter();
2389 2789
 			$newFolderName = $parent . $HierarchyDelimiter . $folderName;
2390 2790
 		}
2391
-		if (empty($newFolderName)) return false;
2392
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName);
2791
+		if (empty($newFolderName))
2792
+		{
2793
+			return false;
2794
+		}
2795
+		if (self::$debug)
2796
+		{
2797
+			error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName);
2798
+		}
2393 2799
 		if ($this->folderExists($newFolderName,true))
2394 2800
 		{
2395
-			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists.");
2801
+			if (self::$debug)
2802
+			{
2803
+				error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists.");
2804
+			}
2396 2805
 			return $newFolderName;
2397 2806
 		}
2398 2807
 		try
@@ -2440,13 +2849,19 @@  discard block
 block discarded – undo
2440 2849
 		$parent		= $_parent;//$this->_encodeFolderName($_parent);
2441 2850
 		$folderName	= $_folderName;//$this->_encodeFolderName($_folderName);
2442 2851
 
2443
-		if(empty($parent)) {
2852
+		if(empty($parent))
2853
+		{
2444 2854
 			$newFolderName = $folderName;
2445
-		} else {
2855
+		}
2856
+		else
2857
+		{
2446 2858
 			$HierarchyDelimiter = $this->getHierarchyDelimiter();
2447 2859
 			$newFolderName = $parent . $HierarchyDelimiter . $folderName;
2448 2860
 		}
2449
-		if (self::$debug) error_log("create folder: $newFolderName");
2861
+		if (self::$debug)
2862
+		{
2863
+			error_log("create folder: $newFolderName");
2864
+		}
2450 2865
 		try
2451 2866
 		{
2452 2867
 			$this->icServer->renameMailbox($oldFolderName, $newFolderName);
@@ -2520,8 +2935,14 @@  discard block
 block discarded – undo
2520 2935
 	 */
2521 2936
 	function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true)
2522 2937
 	{
2523
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible");
2524
-		if (self::$debugTimes) $starttime = microtime (true);
2938
+		if (self::$debug)
2939
+		{
2940
+			error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible");
2941
+		}
2942
+		if (self::$debugTimes)
2943
+		{
2944
+			$starttime = microtime (true);
2945
+		}
2525 2946
 		static $folders2return;
2526 2947
 		//$_subscribedOnly=false;
2527 2948
 		// always use static on single request if info is available;
@@ -2529,23 +2950,35 @@  discard block
 block discarded – undo
2529 2950
 		// set $_useCacheIfPossible to false !
2530 2951
 		if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
2531 2952
 		{
2532
-			if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') ');
2953
+			if (self::$debugTimes)
2954
+			{
2955
+				self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') ');
2956
+			}
2533 2957
 			return $folders2return[$this->icServer->ImapServerId];
2534 2958
 		}
2535 2959
 
2536 2960
 		if ($_subscribedOnly && $_getCounters===false)
2537 2961
 		{
2538
-			if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2962
+			if (is_null($folders2return))
2963
+			{
2964
+				$folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2965
+			}
2539 2966
 			if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
2540 2967
 			{
2541 2968
 				//error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId]));
2542
-				if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') ');
2969
+				if (self::$debugTimes)
2970
+				{
2971
+					self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') ');
2972
+				}
2543 2973
 				return $folders2return[$this->icServer->ImapServerId];
2544 2974
 			}
2545 2975
 		}
2546 2976
 		// use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId]
2547 2977
 		static $folderBasicInfo;
2548
-		if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2978
+		if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId]))
2979
+		{
2980
+			$folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2981
+		}
2549 2982
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId])));
2550 2983
 
2551 2984
 		$delimiter = $this->getHierarchyDelimiter();
@@ -2558,7 +2991,8 @@  discard block
 block discarded – undo
2558 2991
 		$inboxData->shortFolderName	= 'INBOX';
2559 2992
 		$inboxData->shortDisplayName	= lang('INBOX');
2560 2993
 		$inboxData->subscribed = true;
2561
-		if($_getCounters == true) {
2994
+		if($_getCounters == true)
2995
+		{
2562 2996
 			$inboxData->counter = $this->getMailBoxCounters('INBOX');
2563 2997
 		}
2564 2998
 		// force unsubscribed by preference showAllFoldersInFolderPane
@@ -2577,12 +3011,14 @@  discard block
 block discarded – undo
2577 3011
 		//error_log(__METHOD__.__LINE__.array2string($nameSpace));
2578 3012
 		if (is_array($nameSpace))
2579 3013
 		{
2580
-			foreach($nameSpace as $k => $singleNameSpace) {
3014
+			foreach($nameSpace as $k => $singleNameSpace)
3015
+			{
2581 3016
 				$type = $singleNameSpace['type'];
2582 3017
 				// the following line (assumption that for the same namespace the delimiter should be equal) may be wrong
2583 3018
 				$foldersNameSpace[$type]['delimiter']  = $singleNameSpace['delimiter'];
2584 3019
 
2585
-				if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) {
3020
+				if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false)
3021
+				{
2586 3022
 					// fetch and sort the subscribed folders
2587 3023
 					// we alway fetch the subscribed, as this provides the only way to tell
2588 3024
 					// if a folder is subscribed or not
@@ -2633,8 +3069,12 @@  discard block
 block discarded – undo
2633 3069
 							}
2634 3070
 						}
2635 3071
 						//error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($foldersNameSpace[$type]['subscribed']));
2636
-						if (!is_array($foldersNameSpace[$type]['all'])) $foldersNameSpace[$type]['all'] = array();
2637
-						if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) {
3072
+						if (!is_array($foldersNameSpace[$type]['all']))
3073
+						{
3074
+							$foldersNameSpace[$type]['all'] = array();
3075
+						}
3076
+						if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed']))
3077
+						{
2638 3078
 							continue;
2639 3079
 						}
2640 3080
 
@@ -2664,7 +3104,8 @@  discard block
 block discarded – undo
2664 3104
 					}
2665 3105
 
2666 3106
 					//error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($allMailboxesExt));
2667
-					foreach ($allMailboxesExt as $mbx) {
3107
+					foreach ($allMailboxesExt as $mbx)
3108
+					{
2668 3109
 						if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]))
2669 3110
 						{
2670 3111
 							$folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array(
@@ -2687,20 +3128,33 @@  discard block
 block discarded – undo
2687 3128
 						if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])||
2688 3129
 							isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])||
2689 3130
 							(substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)]))
2690
-						) continue;
3131
+						)
3132
+						{
3133
+							continue;
3134
+						}
2691 3135
 
2692 3136
 						//echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>";
2693 3137
 						$allMailBoxesExtSorted[$mbx['MAILBOX']] = $mbx;
2694 3138
 					}
2695
-					if (is_array($allMailBoxesExtSorted)) ksort($allMailBoxesExtSorted);
3139
+					if (is_array($allMailBoxesExtSorted))
3140
+					{
3141
+						ksort($allMailBoxesExtSorted);
3142
+					}
2696 3143
 					//_debug_array(array_keys($allMailBoxesExtSorted));
2697 3144
 					$allMailboxes = array();
2698
-					foreach ((array)$allMailBoxesExtSorted as $mbx) {
2699
-						if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX'];
3145
+					foreach ((array)$allMailBoxesExtSorted as $mbx)
3146
+					{
3147
+						if (!in_array($mbx['MAILBOX'],$allMailboxes))
3148
+						{
3149
+							$allMailboxes[] = $mbx['MAILBOX'];
3150
+						}
2700 3151
 						//echo "Result:";_debug_array($allMailboxes);
2701 3152
 					}
2702 3153
 					$foldersNameSpace[$type]['all'] = $allMailboxes;
2703
-					if (is_array($foldersNameSpace[$type]['all'])) sort($foldersNameSpace[$type]['all']);
3154
+					if (is_array($foldersNameSpace[$type]['all']))
3155
+					{
3156
+						sort($foldersNameSpace[$type]['all']);
3157
+					}
2704 3158
 				}
2705 3159
 			}
2706 3160
 		}
@@ -2709,24 +3163,50 @@  discard block
 block discarded – undo
2709 3163
 		//echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
2710 3164
 		$autoFolderObjects = $folders = array();
2711 3165
 		$autofolder_exists = array();
2712
-		foreach( array('personal', 'others', 'shared') as $type) {
2713
-			if(isset($foldersNameSpace[$type])) {
2714
-				if($_subscribedOnly) {
2715
-					if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed'];
2716
-				} else {
2717
-					if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all'];
2718
-				}
2719
-				foreach((array)$listOfFolders as $folderName) {
3166
+		foreach( array('personal', 'others', 'shared') as $type)
3167
+		{
3168
+			if(isset($foldersNameSpace[$type]))
3169
+			{
3170
+				if($_subscribedOnly)
3171
+				{
3172
+					if( !empty($foldersNameSpace[$type]['subscribed']) )
3173
+					{
3174
+						$listOfFolders = $foldersNameSpace[$type]['subscribed'];
3175
+					}
3176
+				}
3177
+				else
3178
+				{
3179
+					if( !empty($foldersNameSpace[$type]['all']))
3180
+					{
3181
+						$listOfFolders = $foldersNameSpace[$type]['all'];
3182
+					}
3183
+				}
3184
+				foreach((array)$listOfFolders as $folderName)
3185
+				{
2720 3186
 					//echo "<br>FolderToCheck:$folderName<br>";
2721 3187
 					//error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName);
2722
-					if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go.
2723
-					if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) {
3188
+					if ($_subscribedOnly && empty($foldersNameSpace[$type]['all']))
3189
+					{
3190
+						continue;
3191
+					}
3192
+					//when subscribedonly, we fetch all folders in one go.
3193
+					if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all'])))
3194
+					{
2724 3195
 						#echo "$folderName failed to be here <br>";
2725 3196
 						continue;
2726 3197
 					}
2727
-					if (isset($folders[$folderName])) continue;
2728
-					if (isset($autoFolderObjects[$folderName])) continue;
2729
-					if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter'];
3198
+					if (isset($folders[$folderName]))
3199
+					{
3200
+						continue;
3201
+					}
3202
+					if (isset($autoFolderObjects[$folderName]))
3203
+					{
3204
+						continue;
3205
+					}
3206
+					if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter'])
3207
+					{
3208
+						$delimiter = $foldersNameSpace[$type]['delimiter'];
3209
+					}
2730 3210
 					$folderParts = explode($delimiter, $folderName);
2731 3211
 					$shortName = array_pop($folderParts);
2732 3212
 
@@ -2734,17 +3214,20 @@  discard block
 block discarded – undo
2734 3214
 					$folderObject->delimiter	= $delimiter;
2735 3215
 					$folderObject->folderName	= $folderName;
2736 3216
 					$folderObject->shortFolderName	= $shortName;
2737
-					if(!$_subscribedOnly) {
3217
+					if(!$_subscribedOnly)
3218
+					{
2738 3219
 						#echo $folderName."->".$type."<br>";
2739 3220
 						#_debug_array($foldersNameSpace[$type]['subscribed']);
2740 3221
 						$folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']);
2741 3222
 					}
2742 3223
 
2743
-					if($_getCounters == true) {
3224
+					if($_getCounters == true)
3225
+					{
2744 3226
 						//error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName);
2745 3227
 						$folderObject->counter = $this->getMailBoxCounters($folderName);
2746 3228
 					}
2747
-					if(strtoupper($folderName) == 'INBOX') {
3229
+					if(strtoupper($folderName) == 'INBOX')
3230
+					{
2748 3231
 						$folderName = 'INBOX';
2749 3232
 						$folderObject->folderName	= 'INBOX';
2750 3233
 						$folderObject->shortFolderName	= 'INBOX';
@@ -2752,24 +3235,34 @@  discard block
 block discarded – undo
2752 3235
 						$folderObject->shortDisplayName = lang('INBOX');
2753 3236
 						$folderObject->subscribed	= true;
2754 3237
 					// translate the automatic Folders (Sent, Drafts, ...) like the INBOX
2755
-					} elseif (in_array($shortName,self::$autoFolders)) {
3238
+					}
3239
+					elseif (in_array($shortName,self::$autoFolders))
3240
+					{
2756 3241
 						$tmpfolderparts = explode($delimiter,$folderObject->folderName);
2757 3242
 						array_pop($tmpfolderparts);
2758 3243
 						$folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName);
2759 3244
 						$folderObject->shortDisplayName = lang($shortName);
2760 3245
 						unset($tmpfolderparts);
2761
-					} else {
3246
+					}
3247
+					else
3248
+					{
2762 3249
 						$folderObject->displayName = $folderObject->folderName;
2763 3250
 						$folderObject->shortDisplayName = $shortName;
2764 3251
 					}
2765 3252
 					//$folderName = $folderName;
2766
-					if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) {
3253
+					if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false)
3254
+					{
2767 3255
 						$autoFolderObjects[$folderName] = $folderObject;
2768
-					} else {
3256
+					}
3257
+					else
3258
+					{
2769 3259
 						$folders[$folderName] = $folderObject;
2770 3260
 					}
2771 3261
 					//error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName);
2772
-					if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders ();
3262
+					if (!isset(self::$specialUseFolders))
3263
+					{
3264
+						$this->getSpecialUseFolders ();
3265
+					}
2773 3266
 					if (isset(self::$specialUseFolders[$folderName]))
2774 3267
 					{
2775 3268
 						$autofolder_exists[$folderName] = self::$specialUseFolders[$folderName];
@@ -2777,7 +3270,8 @@  discard block
 block discarded – undo
2777 3270
 				}
2778 3271
 			}
2779 3272
 		}
2780
-		if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) {
3273
+		if (is_array($autoFolderObjects) && !empty($autoFolderObjects))
3274
+		{
2781 3275
 			uasort($autoFolderObjects,array($this,"sortByAutoFolderPos"));
2782 3276
 		}
2783 3277
 		// check if some standard folders are missing and need to be created
@@ -2786,7 +3280,10 @@  discard block
 block discarded – undo
2786 3280
 			// if new folders have been created, re-read folders ignoring the cache
2787 3281
 			return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false);	// false = do NOT use cache
2788 3282
 		}
2789
-		if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName"));
3283
+		if (is_array($folders))
3284
+		{
3285
+			uasort($folders,array($this,"sortByDisplayName"));
3286
+		}
2790 3287
 		//$folders2return = array_merge($autoFolderObjects,$folders);
2791 3288
 		//_debug_array($folders2return); #exit;
2792 3289
 		$folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders);
@@ -2798,7 +3295,10 @@  discard block
 block discarded – undo
2798 3295
 			Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1);
2799 3296
 		}
2800 3297
 		Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1);
2801
-		if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') ');
3298
+		if (self::$debugTimes)
3299
+		{
3300
+			self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') ');
3301
+		}
2802 3302
 		return $folders2return[$this->icServer->ImapServerId];
2803 3303
 	}
2804 3304
 
@@ -2826,31 +3326,44 @@  discard block
 block discarded – undo
2826 3326
 
2827 3327
 		$folders = $nameSpace =  array();
2828 3328
 		$nameSpaceTmp = $this->_getNameSpaces();
2829
-		foreach($nameSpaceTmp as $k => $singleNameSpace) {
3329
+		foreach($nameSpaceTmp as $k => $singleNameSpace)
3330
+		{
2830 3331
 			$nameSpace[$singleNameSpace['type']]=$singleNameSpace;
2831 3332
 		}
2832 3333
 		unset($nameSpaceTmp);
2833 3334
 
2834 3335
 		//error_log(__METHOD__.__LINE__.array2string($nameSpace));
2835 3336
 		// Get special use folders
2836
-		if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders
3337
+		if (!isset(self::$specialUseFolders))
3338
+		{
3339
+			$this->getSpecialUseFolders ();
3340
+		}
3341
+		// Set self::$specialUseFolders
2837 3342
 		// topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace
2838
-		if ($_onlyTopLevel) // top level leaves
3343
+		if ($_onlyTopLevel)
3344
+		{
3345
+			// top level leaves
2839 3346
 		{
2840 3347
 			// Get top mailboxes of icServer
2841 3348
 			$topFolders = $this->icServer->getMailboxes("", 2, true);
3349
+		}
2842 3350
 			// Trigger examination of namespace to retrieve
2843 3351
 			// folders located in other and shared; needed only for some servers
2844
-			if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
3352
+			if (is_null(self::$mailConfig))
3353
+			{
3354
+				self::$mailConfig = Config::read('mail');
3355
+			}
2845 3356
 			if (self::$mailConfig['examineNamespace'])
2846 3357
 			{
2847 3358
 				$prefixes=array();
2848 3359
 				if (is_array($nameSpace))
2849 3360
 				{
2850
-					foreach($nameSpace as $k => $singleNameSpace) {
3361
+					foreach($nameSpace as $k => $singleNameSpace)
3362
+					{
2851 3363
 						$type = $singleNameSpace['type'];
2852 3364
 
2853
-						if(is_array($singleNameSpace) && $singleNameSpace['prefix']){
3365
+						if(is_array($singleNameSpace) && $singleNameSpace['prefix'])
3366
+						{
2854 3367
 							$prefixes[$type] = $singleNameSpace['prefix'];
2855 3368
 							//regard extra care for nameSpacequeries when configured AND respect $_search
2856 3369
 							$result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true);
@@ -2926,7 +3439,10 @@  discard block
 block discarded – undo
2926 3439
 							$nFolders [$path] = $folder;
2927 3440
 						}
2928 3441
 					}
2929
-					if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder'));
3442
+					if (is_array($aFolders))
3443
+					{
3444
+						uasort ($aFolders, array($this,'sortByAutofolder'));
3445
+					}
2930 3446
 					//ksort($aFolders);
2931 3447
 
2932 3448
 					// Sort none auto folders base on mailbox name
@@ -2936,12 +3452,17 @@  discard block
 block discarded – undo
2936 3452
 				}
2937 3453
 				else
2938 3454
 				{
2939
-					if (is_array($subFolders)) ksort($subFolders);
3455
+					if (is_array($subFolders))
3456
+					{
3457
+						ksort($subFolders);
3458
+					}
2940 3459
 				}
2941 3460
 				$folders = array_merge($folders,(array)$mainFolder, (array)$subFolders);
2942 3461
 			}
2943 3462
 		}
2944
-		elseif ($_nodePath) // single node
3463
+		elseif ($_nodePath)
3464
+		{
3465
+			// single node
2945 3466
 		{
2946 3467
 			switch ($_search)
2947 3468
 			{
@@ -2949,6 +3470,7 @@  discard block
 block discarded – undo
2949 3470
 				case 0:
2950 3471
 				case 2:
2951 3472
 					$path = $_nodePath.''.$delimiter;
3473
+		}
2952 3474
 					break;
2953 3475
 				// Node itself
2954 3476
 				// shouldn't contain next level delimiter
@@ -2967,11 +3489,14 @@  discard block
 block discarded – undo
2967 3489
 
2968 3490
 			uasort($folders,array($this,'sortByMailbox'));//ksort($folders);
2969 3491
 		}
2970
-		elseif(!$_nodePath) // all
3492
+		elseif(!$_nodePath)
3493
+		{
3494
+			// all
2971 3495
 		{
2972 3496
 			if ($_subscribedOnly)
2973 3497
 			{
2974 3498
 				$folders = $this->icServer->listSubscribedMailboxes('', 0, true);
3499
+		}
2975 3500
 			}
2976 3501
 			else
2977 3502
 			{
@@ -2983,7 +3508,10 @@  discard block
 block discarded – undo
2983 3508
 		{
2984 3509
 			// SORTING FOLDERS
2985 3510
 			//self::$debugTimes=true;
2986
-			if (self::$debugTimes) $starttime = microtime (true);
3511
+			if (self::$debugTimes)
3512
+			{
3513
+				$starttime = microtime (true);
3514
+			}
2987 3515
 			// Merge of all auto folders and specialusefolders
2988 3516
 			$autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders))));
2989 3517
 			uasort($folders,array($this,'sortByMailbox'));//ksort($folders);
@@ -2993,73 +3521,103 @@  discard block
 block discarded – undo
2993 3521
 			$isGoogleMail=false;
2994 3522
 			foreach($autoFoldersTmp as $afk=>$aF)
2995 3523
 			{
2996
-				if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false);
3524
+				if (!isset($mySpecialUseFolders[$aF]) && $aF)
3525
+				{
3526
+					$mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false);
3527
+				}
2997 3528
 				//error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
2998 3529
 			}
2999 3530
 			//error_log(array2string($mySpecialUseFolders));
3000
-			foreach ($tmpFolders as $k => $f) {
3531
+			foreach ($tmpFolders as $k => $f)
3532
+			{
3001 3533
 				$sorted=false;
3002
-				if (strtoupper(substr($k,0,5))=='INBOX') {
3003
-					if (strtoupper($k)=='INBOX') {
3534
+				if (strtoupper(substr($k,0,5))=='INBOX')
3535
+				{
3536
+					if (strtoupper($k)=='INBOX')
3537
+					{
3004 3538
 						//error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k);
3005 3539
 						$inboxFolderObject[$k]=$f;
3006 3540
 						unset($folders[$k]);
3007 3541
 						$sorted=true;
3008
-					} else {
3542
+					}
3543
+					else
3544
+					{
3009 3545
 						$isAutoFolder=false;
3010 3546
 						foreach($autoFoldersTmp as $afk=>$aF)
3011 3547
 						{
3012 3548
 							//error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3013 3549
 							if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
3014 3550
 								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder
3015
-								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder
3551
+								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false))
3552
+							{
3553
+								// k is parent of an autofolder
3016 3554
 							{
3017 3555
 								//error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]);
3018 3556
 								$isAutoFolder=true;
3557
+							}
3019 3558
 								$autoFolderObjects[$k]=$f;
3020 3559
 								break;
3021 3560
 							}
3022 3561
 						}
3023
-						if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f;
3562
+						if ($isAutoFolder==false)
3563
+						{
3564
+							$inboxSubFolderObjects[$k]=$f;
3565
+						}
3024 3566
 						unset($folders[$k]);
3025 3567
 						$sorted=true;
3026 3568
 					}
3027
-				} elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') {
3569
+				}
3570
+				elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]')
3571
+				{
3028 3572
 					$isGoogleMail=true;
3029
-					if (strtoupper($k)=='[GOOGLE MAIL]') {
3573
+					if (strtoupper($k)=='[GOOGLE MAIL]')
3574
+					{
3030 3575
 						$googleMailFolderObject[$k]=$f;
3031 3576
 						unset($folders[$k]);
3032 3577
 						$sorted=true;
3033
-					} else {
3578
+					}
3579
+					else
3580
+					{
3034 3581
 						$isAutoFolder=false;
3035 3582
 						foreach($autoFoldersTmp as $afk=>$aF)
3036 3583
 						{
3037 3584
 							//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3038 3585
 							if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
3039 3586
 								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder
3040
-								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder
3587
+								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false))
3588
+							{
3589
+								// k is parent of an autofolder
3041 3590
 							{
3042 3591
 								//error_log($k.'->'.$mySpecialUseFolders[$aF]);
3043 3592
 								$isAutoFolder=true;
3593
+							}
3044 3594
 								$googleAutoFolderObjects[$k]=$f;
3045 3595
 								break;
3046 3596
 							}
3047 3597
 						}
3048
-						if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f;
3598
+						if ($isAutoFolder==false)
3599
+						{
3600
+							$googleSubFolderObjects[$k]=$f;
3601
+						}
3049 3602
 						unset($folders[$k]);
3050 3603
 						$sorted=true;
3051 3604
 					}
3052
-				} else {
3605
+				}
3606
+				else
3607
+				{
3053 3608
 					$isAutoFolder=false;
3054 3609
 					foreach($autoFoldersTmp as $afk=>$aF)
3055 3610
 					{
3056 3611
 						//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
3057 3612
 						if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
3058 3613
 								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder
3059
-								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder
3614
+								stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false))
3615
+						{
3616
+							// k is parent of an autofolder
3060 3617
 						{
3061 3618
 							//error_log($k.'->'.$mySpecialUseFolders[$aF]);
3062 3619
 							$isAutoFolder=true;
3620
+						}
3063 3621
 							$autoFolderObjects[$k]=$f;
3064 3622
 							unset($folders[$k]);
3065 3623
 							$sorted=true;
@@ -3075,7 +3633,8 @@  discard block
 block discarded – undo
3075 3633
 						if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix'])
3076 3634
 						{
3077 3635
 							if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']||
3078
-								substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) {
3636
+								substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1))
3637
+							{
3079 3638
 								//error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k);
3080 3639
 								$typeFolderObject[$type][$k]=$f;
3081 3640
 								unset($folders[$k]);
@@ -3102,9 +3661,12 @@  discard block
 block discarded – undo
3102 3661
 				}
3103 3662
 			}
3104 3663
 			//error_log(__METHOD__.__LINE__.array2string($autoFolderObjects));
3105
-			if (!$isGoogleMail) {
3664
+			if (!$isGoogleMail)
3665
+			{
3106 3666
 				$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']);
3107
-			} else {
3667
+			}
3668
+			else
3669
+			{
3108 3670
 				// avoid calling sortByAutoFolder as it is not regarding subfolders
3109 3671
 				$gAutoFolderObjectsTmp = $googleAutoFolderObjects;
3110 3672
 				unset($googleAutoFolderObjects);
@@ -3121,7 +3683,10 @@  discard block
 block discarded – undo
3121 3683
 				}
3122 3684
 				$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']);
3123 3685
 			}
3124
-			if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:');
3686
+			if (self::$debugTimes)
3687
+			{
3688
+				self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:');
3689
+			}
3125 3690
 			//self::$debugTimes=false;
3126 3691
 		}
3127 3692
 		// Get counter information and add them to each fetched folders array
@@ -3171,7 +3736,13 @@  discard block
 block discarded – undo
3171 3736
 		$rv = false;
3172 3737
 		foreach ($haystack as $k => $v)
3173 3738
 		{
3174
-			foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;}
3739
+			foreach($v as &$sv)
3740
+			{
3741
+if (trim($sv)==trim($needle))
3742
+			{
3743
+				return $k;
3744
+			}
3745
+			}
3175 3746
 		}
3176 3747
 		return $rv;
3177 3748
 	}
@@ -3198,7 +3769,10 @@  discard block
 block discarded – undo
3198 3769
 	 */
3199 3770
 	static function pathToFolderData ($_path, $_hDelimiter)
3200 3771
 	{
3201
-		if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path;
3772
+		if (!strpos($_path, self::DELIMITER))
3773
+		{
3774
+			$_path = self::DELIMITER.$_path;
3775
+		}
3202 3776
 		list(,$path) = explode(self::DELIMITER, $_path);
3203 3777
 		$path_chain = $parts = explode($_hDelimiter, $path);
3204 3778
 		$name = array_pop($parts);
@@ -3227,7 +3801,10 @@  discard block
 block discarded – undo
3227 3801
 		$b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']);
3228 3802
 		$pos1 = array_search(trim($a['name']),self::$autoFolders);
3229 3803
 		$pos2 = array_search(trim($b['name']),self::$autoFolders);
3230
-		if ($pos1 == $pos2) return 0;
3804
+		if ($pos1 == $pos2)
3805
+		{
3806
+			return 0;
3807
+		}
3231 3808
 		return ($pos1 < $pos2) ? -1 : 1;
3232 3809
 	}
3233 3810
 
@@ -3258,7 +3835,10 @@  discard block
 block discarded – undo
3258 3835
 		// 0, 1 und -1
3259 3836
 		$pos1 = array_search(trim($a->shortFolderName),self::$autoFolders);
3260 3837
 		$pos2 = array_search(trim($b->shortFolderName),self::$autoFolders);
3261
-		if ($pos1 == $pos2) return 0;
3838
+		if ($pos1 == $pos2)
3839
+		{
3840
+			return 0;
3841
+		}
3262 3842
 		return ($pos1 < $pos2) ? -1 : 1;
3263 3843
 	}
3264 3844
 
@@ -3279,11 +3859,18 @@  discard block
 block discarded – undo
3279 3859
 		}
3280 3860
 		catch (\Exception $e)
3281 3861
 		{
3282
-			if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage());
3862
+			if (self::$debug)
3863
+			{
3864
+				error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage());
3865
+			}
3283 3866
 			return false;
3284 3867
 		}
3285
-		if(is_array($folderStatus)) {
3286
-			if ($_returnObject===false) return $folderStatus;
3868
+		if(is_array($folderStatus))
3869
+		{
3870
+			if ($_returnObject===false)
3871
+			{
3872
+				return $folderStatus;
3873
+			}
3287 3874
 			$status =  new \stdClass;
3288 3875
 			$status->messages   = $folderStatus['MESSAGES'];
3289 3876
 			$status->unseen     = $folderStatus['UNSEEN'];
@@ -3310,7 +3897,8 @@  discard block
 block discarded – undo
3310 3897
 	{
3311 3898
 		#echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>";
3312 3899
 		$maxreclevel=25;
3313
-		if ($reclevel > $maxreclevel) {
3900
+		if ($reclevel > $maxreclevel)
3901
+		{
3314 3902
 			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
3315 3903
 			return array();
3316 3904
 		}
@@ -3324,7 +3912,8 @@  discard block
 block discarded – undo
3324 3912
 //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter));
3325 3913
 //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx));
3326 3914
 		// Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /))
3327
-		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) {
3915
+		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
3916
+		{
3328 3917
 			// if there are children fetch them
3329 3918
 			//echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>";
3330 3919
 
@@ -3332,7 +3921,8 @@  discard block
 block discarded – undo
3332 3921
 			//$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false);
3333 3922
 			//_debug_array($buff);
3334 3923
 			$allMailboxes = array();
3335
-			foreach ($buff as $mbxname) {
3924
+			foreach ($buff as $mbxname)
3925
+			{
3336 3926
 //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname));
3337 3927
 				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
3338 3928
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
@@ -3341,9 +3931,14 @@  discard block
 block discarded – undo
3341 3931
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
3342 3932
 				}
3343 3933
 			}
3344
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
3934
+			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
3935
+			{
3936
+				$allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
3937
+			}
3345 3938
 			return $allMailboxes;
3346
-		} else {
3939
+		}
3940
+		else
3941
+		{
3347 3942
 			return array($_mailbox);
3348 3943
 		}
3349 3944
 	}
@@ -3367,14 +3962,21 @@  discard block
 block discarded – undo
3367 3962
 			'Outbox'   => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'),
3368 3963
 			'Archive'   => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'),
3369 3964
 		);
3370
-		if ($_type == 'Templates') $_type = 'Template';	// for some reason self::$autofolders uses 'Templates'!
3965
+		if ($_type == 'Templates')
3966
+		{
3967
+			$_type = 'Template';
3968
+		}
3969
+		// for some reason self::$autofolders uses 'Templates'!
3371 3970
 		$created = false;
3372 3971
 		if (!isset($types[$_type]))
3373 3972
 		{
3374 3973
 			error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__);
3375 3974
 			return false;
3376 3975
 		}
3377
-		if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders();
3976
+		if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders))
3977
+		{
3978
+			self::$specialUseFolders = $this->getSpecialUseFolders();
3979
+		}
3378 3980
 
3379 3981
 		//highest precedence
3380 3982
 		try
@@ -3384,25 +3986,39 @@  discard block
 block discarded – undo
3384 3986
 		catch (\Exception $e)
3385 3987
 		{
3386 3988
 			// we know that outbox is not supported, but we use this here, as we autocreate expected SpecialUseFolders in this function
3387
-			if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage());
3989
+			if ($_type != 'Outbox')
3990
+			{
3991
+				error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage());
3992
+			}
3388 3993
 			$_folderName = false;
3389 3994
 		}
3390 3995
 		// do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist
3391
-		if ($_type == 'Archive') {
3392
-			if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) {
3996
+		if ($_type == 'Archive')
3997
+		{
3998
+			if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true))
3999
+			{
3393 4000
 				return false;
3394
-			} else {
4001
+			}
4002
+			else
4003
+			{
3395 4004
 				return $_folderName;
3396 4005
 			}
3397 4006
 
3398 4007
 		}
3399 4008
 		// does the folder exist??? (is configured/preset, but non-existent)
3400
-		if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) {
4009
+		if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true))
4010
+		{
3401 4011
 			try
3402 4012
 			{
3403 4013
 				$error = null;
3404
-				if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true;
3405
-				if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4014
+				if (($_folderName = $this->createFolder('', $_folderName, $error)))
4015
+				{
4016
+					$created = true;
4017
+				}
4018
+				if ($error)
4019
+				{
4020
+					error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4021
+				}
3406 4022
 			}
3407 4023
 			catch(Exception $e)
3408 4024
 			{
@@ -3411,9 +4027,16 @@  discard block
 block discarded – undo
3411 4027
 			}
3412 4028
 		}
3413 4029
 		// not sure yet if false is the correct behavior on none
3414
-		if ($_folderName =='none') return 'none' ; //false;
4030
+		if ($_folderName =='none')
4031
+		{
4032
+			return 'none' ;
4033
+		}
4034
+		//false;
3415 4035
 		//no (valid) folder found yet; try specialUseFolders
3416
-		if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f;
4036
+		if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders)))
4037
+		{
4038
+			$_folderName = $f;
4039
+		}
3417 4040
 		//no specialUseFolder; try some Defaults
3418 4041
 		if (empty($_folderName) && isset($types[$_type]))
3419 4042
 		{
@@ -3439,7 +4062,10 @@  discard block
 block discarded – undo
3439 4062
 					$error = null;
3440 4063
 					$this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error);
3441 4064
 					$_folderName = $prefix.$types[$_type]['autoFolderName'];
3442
-					if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4065
+					if ($error)
4066
+					{
4067
+						error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
4068
+					}
3443 4069
 				}
3444 4070
 				catch(Exception $e)
3445 4071
 				{
@@ -3541,17 +4167,22 @@  discard block
 block discarded – undo
3541 4167
 	function isSentFolder($_folderName, $_checkexistance=TRUE)
3542 4168
 	{
3543 4169
 		$sentFolder = $this->getSentFolder($_checkexistance);
3544
-		if(empty($sentFolder)) {
4170
+		if(empty($sentFolder))
4171
+		{
3545 4172
 			return false;
3546 4173
 		}
3547 4174
 		// does the folder exist???
3548
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4175
+		if ($_checkexistance && !$this->folderExists($_folderName))
4176
+		{
3549 4177
 			return false;
3550 4178
 		}
3551 4179
 
3552
-		if(false !== stripos($_folderName, $sentFolder)) {
4180
+		if(false !== stripos($_folderName, $sentFolder))
4181
+		{
3553 4182
 			return true;
3554
-		} else {
4183
+		}
4184
+		else
4185
+		{
3555 4186
 			return false;
3556 4187
 		}
3557 4188
 	}
@@ -3564,15 +4195,20 @@  discard block
 block discarded – undo
3564 4195
 	 */
3565 4196
 	function isOutbox($_folderName, $_checkexistance=TRUE)
3566 4197
 	{
3567
-		if (stripos($_folderName, 'Outbox')===false) {
4198
+		if (stripos($_folderName, 'Outbox')===false)
4199
+		{
3568 4200
 			return false;
3569 4201
 		}
3570 4202
 		// does the folder exist???
3571
-		if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) {
4203
+		if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName))
4204
+		{
3572 4205
 			$outboxFolder = $this->getOutboxFolder($_checkexistance);
3573
-			if(false !== stripos($_folderName, $outboxFolder)) {
4206
+			if(false !== stripos($_folderName, $outboxFolder))
4207
+			{
3574 4208
 				return true;
3575
-			} else {
4209
+			}
4210
+			else
4211
+			{
3576 4212
 				return false;
3577 4213
 			}
3578 4214
 		}
@@ -3588,17 +4224,25 @@  discard block
 block discarded – undo
3588 4224
 	function isDraftFolder($_folderName, $_checkexistance=TRUE)
3589 4225
 	{
3590 4226
 		$draftFolder = $this->getDraftFolder($_checkexistance);
3591
-		if(empty($draftFolder)) {
4227
+		if(empty($draftFolder))
4228
+		{
3592 4229
 			return false;
3593 4230
 		}
3594 4231
 		// does the folder exist???
3595
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4232
+		if ($_checkexistance && !$this->folderExists($_folderName))
4233
+		{
3596 4234
 			return false;
3597 4235
 		}
3598
-		if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8;
3599
-		if(false !== stripos($_folderName, $draftFolder)) {
4236
+		if (is_a($_folderName,"Horde_Imap_Client_Mailbox"))
4237
+		{
4238
+			$_folderName = $_folderName->utf8;
4239
+		}
4240
+		if(false !== stripos($_folderName, $draftFolder))
4241
+		{
3600 4242
 			return true;
3601
-		} else {
4243
+		}
4244
+		else
4245
+		{
3602 4246
 			return false;
3603 4247
 		}
3604 4248
 	}
@@ -3612,17 +4256,22 @@  discard block
 block discarded – undo
3612 4256
 	function isTrashFolder($_folderName, $_checkexistance=TRUE)
3613 4257
 	{
3614 4258
 		$trashFolder = $this->getTrashFolder($_checkexistance);
3615
-		if(empty($trashFolder)) {
4259
+		if(empty($trashFolder))
4260
+		{
3616 4261
 			return false;
3617 4262
 		}
3618 4263
 		// does the folder exist???
3619
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4264
+		if ($_checkexistance && !$this->folderExists($_folderName))
4265
+		{
3620 4266
 			return false;
3621 4267
 		}
3622 4268
 
3623
-		if(false !== stripos($_folderName, $trashFolder)) {
4269
+		if(false !== stripos($_folderName, $trashFolder))
4270
+		{
3624 4271
 			return true;
3625
-		} else {
4272
+		}
4273
+		else
4274
+		{
3626 4275
 			return false;
3627 4276
 		}
3628 4277
 	}
@@ -3636,17 +4285,22 @@  discard block
 block discarded – undo
3636 4285
 	function isTemplateFolder($_folderName, $_checkexistance=TRUE)
3637 4286
 	{
3638 4287
 		$templateFolder = $this->getTemplateFolder($_checkexistance);
3639
-		if(empty($templateFolder)) {
4288
+		if(empty($templateFolder))
4289
+		{
3640 4290
 			return false;
3641 4291
 		}
3642 4292
 		// does the folder exist???
3643
-		if ($_checkexistance && !$this->folderExists($_folderName)) {
4293
+		if ($_checkexistance && !$this->folderExists($_folderName))
4294
+		{
3644 4295
 			return false;
3645 4296
 		}
3646 4297
 
3647
-		if(false !== stripos($_folderName, $templateFolder)) {
4298
+		if(false !== stripos($_folderName, $templateFolder))
4299
+		{
3648 4300
 			return true;
3649
-		} else {
4301
+		}
4302
+		else
4303
+		{
3650 4304
 			return false;
3651 4305
 		}
3652 4306
 	}
@@ -3664,15 +4318,27 @@  discard block
 block discarded – undo
3664 4318
 		if (empty($_folder))
3665 4319
 		{
3666 4320
 			// this error is more or less without significance, unless we force the check
3667
-			if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace());
4321
+			if ($_forceCheck===true)
4322
+			{
4323
+				error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace());
4324
+			}
3668 4325
 			return false;
3669 4326
 		}
3670 4327
 		// when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder
3671
-		if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true;
3672
-		if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder =  $_folder->utf8;
4328
+		if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false)
4329
+		{
4330
+			return true;
4331
+		}
4332
+		if (is_a($_folder,"Horde_Imap_Client_Mailbox"))
4333
+		{
4334
+			$_folder =  $_folder->utf8;
4335
+		}
3673 4336
 		// reduce traffic within the Instance per User; Expire every 5 hours
3674 4337
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace());
3675
-		if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5);
4338
+		if (is_null($folderInfo))
4339
+		{
4340
+			$folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5);
4341
+		}
3676 4342
 		//error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo));
3677 4343
 		if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false)
3678 4344
 		{
@@ -3690,7 +4356,8 @@  discard block
 block discarded – undo
3690 4356
 
3691 4357
 		// does the folder exist???
3692 4358
 		//error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server'));
3693
-		if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) {
4359
+		if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder]))
4360
+		{
3694 4361
 			//error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID);
3695 4362
 			//return false;
3696 4363
 			//try to connect
@@ -3731,9 +4398,12 @@  discard block
 block discarded – undo
3731 4398
 
3732 4399
 		$this->icServer->openMailbox($folderName);
3733 4400
 
3734
-		if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") {
4401
+		if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash")
4402
+		{
3735 4403
 			$this->deleteMessages('all',$folderName,'remove_immediately');
3736
-		} else {
4404
+		}
4405
+		else
4406
+		{
3737 4407
 			$this->icServer->expunge($folderName);
3738 4408
 		}
3739 4409
 	}
@@ -3752,10 +4422,16 @@  discard block
 block discarded – undo
3752 4422
 	{
3753 4423
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod);
3754 4424
 		$oldMailbox = '';
3755
-		if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox'];
4425
+		if (is_null($_folder) || empty($_folder))
4426
+		{
4427
+			$_folder = $this->sessionData['mailbox'];
4428
+		}
3756 4429
 		if (empty($_messageUID))
3757 4430
 		{
3758
-			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4431
+			if (self::$debug)
4432
+			{
4433
+				error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4434
+			}
3759 4435
 			return false;
3760 4436
 		}
3761 4437
 		elseif ($_messageUID==='all')
@@ -3765,32 +4441,48 @@  discard block
 block discarded – undo
3765 4441
 		else
3766 4442
 		{
3767 4443
 			$uidsToDelete = new Horde_Imap_Client_Ids();
3768
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4444
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4445
+			{
4446
+				$_messageUID = (array)$_messageUID;
4447
+			}
3769 4448
 			$uidsToDelete->add($_messageUID);
3770 4449
 		}
3771 4450
 		$deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method
3772
-		if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions  = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted");
4451
+		if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately")))
4452
+		{
4453
+			$deleteOptions  = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted");
4454
+		}
3773 4455
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
3774 4456
 		$trashFolder    = $this->getTrashFolder();
3775 4457
 		$draftFolder	= $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder'];
3776 4458
 		$templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder'];
3777 4459
 		if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") ||
3778
-		   (strtolower($_folder) == strtolower($draftFolder))) {
4460
+		   (strtolower($_folder) == strtolower($draftFolder)))
4461
+		{
3779 4462
 			$deleteOptions = "remove_immediately";
3780 4463
 		}
3781
-		if($this->icServer->getCurrentMailbox() != $_folder) {
4464
+		if($this->icServer->getCurrentMailbox() != $_folder)
4465
+		{
3782 4466
 			$oldMailbox = $this->icServer->getCurrentMailbox();
3783 4467
 			$this->icServer->openMailbox($_folder);
3784 4468
 		}
3785 4469
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
3786 4470
 		$updateCache = false;
3787
-		switch($deleteOptions) {
4471
+		switch($deleteOptions)
4472
+		{
3788 4473
 			case "move_to_trash":
3789 4474
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3790 4475
 				$updateCache = true;
3791
-				if(!empty($trashFolder)) {
3792
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID));
3793
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
4476
+				if(!empty($trashFolder))
4477
+				{
4478
+					if (self::$debug)
4479
+					{
4480
+						error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID));
4481
+					}
4482
+					if (self::$debug)
4483
+					{
4484
+						error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
4485
+					}
3794 4486
 					// copy messages
3795 4487
 					try
3796 4488
 					{
@@ -3806,7 +4498,10 @@  discard block
 block discarded – undo
3806 4498
 			case "mark_as_deleted":
3807 4499
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3808 4500
 				// mark messages as deleted
3809
-				if (is_null($_messageUID)) $_messageUID='all';
4501
+				if (is_null($_messageUID))
4502
+				{
4503
+					$_messageUID='all';
4504
+				}
3810 4505
 				foreach((array)$_messageUID as $key =>$uid)
3811 4506
 				{
3812 4507
 					//flag messages, that are flagged for deletion as seen too
@@ -3814,7 +4509,10 @@  discard block
 block discarded – undo
3814 4509
 					$flags = $this->getFlags($uid);
3815 4510
 					$this->flagMessages('delete', $uid, $_folder);
3816 4511
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags));
3817
-					if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid;
4512
+					if (strpos( array2string($flags),'Deleted')!==false)
4513
+					{
4514
+						$undelete[] = $uid;
4515
+					}
3818 4516
 					unset($flags);
3819 4517
 				}
3820 4518
 				foreach((array)$undelete as $key =>$uid)
@@ -3826,7 +4524,10 @@  discard block
 block discarded – undo
3826 4524
 			case "remove_immediately":
3827 4525
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3828 4526
 				$updateCache = true;
3829
-				if (is_null($_messageUID)) $_messageUID='all';
4527
+				if (is_null($_messageUID))
4528
+				{
4529
+					$_messageUID='all';
4530
+				}
3830 4531
 				if (is_object($_messageUID))
3831 4532
 				{
3832 4533
 					$this->flagMessages('delete', $_messageUID, $_folder);
@@ -3843,7 +4544,8 @@  discard block
 block discarded – undo
3843 4544
 				$this->icServer->expunge($_folder);
3844 4545
 				break;
3845 4546
 		}
3846
-		if($oldMailbox != '') {
4547
+		if($oldMailbox != '')
4548
+		{
3847 4549
 			$this->icServer->openMailbox($oldMailbox);
3848 4550
 		}
3849 4551
 
@@ -3857,11 +4559,15 @@  discard block
 block discarded – undo
3857 4559
 	 *
3858 4560
 	 * @return null/array flags
3859 4561
 	 */
3860
-	function getFlags ($_messageUID) {
4562
+	function getFlags ($_messageUID)
4563
+	{
3861 4564
 		try
3862 4565
 		{
3863 4566
 			$uidsToFetch = new Horde_Imap_Client_Ids();
3864
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4567
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4568
+			{
4569
+				$_messageUID = (array)$_messageUID;
4570
+			}
3865 4571
 			$uidsToFetch->add($_messageUID);
3866 4572
 			$_folderName = $this->icServer->getCurrentMailbox();
3867 4573
 			$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -3869,8 +4575,10 @@  discard block
 block discarded – undo
3869 4575
 			$headersNew = $this->icServer->fetch($_folderName, $fquery, array(
3870 4576
 				'ids' => $uidsToFetch,
3871 4577
 			));
3872
-			if (is_object($headersNew)) {
3873
-				foreach($headersNew->ids() as $id) {
4578
+			if (is_object($headersNew))
4579
+			{
4580
+				foreach($headersNew->ids() as $id)
4581
+				{
3874 4582
 					$_headerObject = $headersNew->get($id);
3875 4583
 					$flags = $_headerObject->getFlags();
3876 4584
 				}
@@ -3895,10 +4603,16 @@  discard block
 block discarded – undo
3895 4603
 	 */
3896 4604
 	function getNotifyFlags ($_messageUID, $flags=null)
3897 4605
 	{
3898
-		if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags));
4606
+		if (self::$debug)
4607
+		{
4608
+			error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags));
4609
+		}
3899 4610
 		try
3900 4611
 		{
3901
-			if($flags===null) $flags =  $this->getFlags($_messageUID);
4612
+			if($flags===null)
4613
+			{
4614
+				$flags =  $this->getFlags($_messageUID);
4615
+			}
3902 4616
 		}
3903 4617
 		catch (\Exception $e)
3904 4618
 		{
@@ -3906,10 +4620,14 @@  discard block
 block discarded – undo
3906 4620
 		}
3907 4621
 
3908 4622
 		if ( stripos( array2string($flags),'MDNSent')!==false)
3909
-			return true;
4623
+		{
4624
+					return true;
4625
+		}
3910 4626
 
3911 4627
 		if ( stripos( array2string($flags),'MDNnotSent')!==false)
3912
-			return false;
4628
+		{
4629
+					return false;
4630
+		}
3913 4631
 
3914 4632
 		return null;
3915 4633
 	}
@@ -3930,7 +4648,10 @@  discard block
 block discarded – undo
3930 4648
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']);
3931 4649
 		if (empty($_messageUID))
3932 4650
 		{
3933
-			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4651
+			if (self::$debug)
4652
+			{
4653
+				error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
4654
+			}
3934 4655
 			return false;
3935 4656
 		}
3936 4657
 		$this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox']));
@@ -3938,7 +4659,10 @@  discard block
 block discarded – undo
3938 4659
 		if (is_array($_messageUID)&& count($_messageUID)>50)
3939 4660
 		{
3940 4661
 			$count = $this->getMailBoxCounters($folder,true);
3941
-			if ($count->messages == count($_messageUID)) $_messageUID='all';
4662
+			if ($count->messages == count($_messageUID))
4663
+			{
4664
+				$_messageUID='all';
4665
+			}
3942 4666
 		}
3943 4667
 
3944 4668
 		if ($_messageUID==='all')
@@ -3947,7 +4671,10 @@  discard block
 block discarded – undo
3947 4671
 		}
3948 4672
 		else
3949 4673
 		{
3950
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4674
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4675
+			{
4676
+				$_messageUID = (array)$_messageUID;
4677
+			}
3951 4678
 			$messageUIDs = array_chunk($_messageUID,50,true);
3952 4679
 		}
3953 4680
 		try
@@ -3963,7 +4690,8 @@  discard block
 block discarded – undo
3963 4690
 					$uidsToModify = new Horde_Imap_Client_Ids();
3964 4691
 					$uidsToModify->add($uids);
3965 4692
 				}
3966
-				switch($_flag) {
4693
+				switch($_flag)
4694
+				{
3967 4695
 					case "delete":
3968 4696
 						$ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify));
3969 4697
 						break;
@@ -4049,7 +4777,10 @@  discard block
 block discarded – undo
4049 4777
 		{
4050 4778
 			error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage());
4051 4779
 		}
4052
-		if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8;
4780
+		if ($folder instanceof Horde_Imap_Client_Mailbox)
4781
+		{
4782
+			$_folder = $folder->utf8;
4783
+		}
4053 4784
 		//error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#');
4054 4785
 		self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0;
4055 4786
 
@@ -4078,7 +4809,10 @@  discard block
 block discarded – undo
4078 4809
 		//$deleteOptions  = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"];
4079 4810
 		if (empty($_messageUID))
4080 4811
 		{
4081
-			if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID));
4812
+			if (self::$debug)
4813
+			{
4814
+				error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID));
4815
+			}
4082 4816
 			return false;
4083 4817
 		}
4084 4818
 		elseif ($_messageUID==='all')
@@ -4090,7 +4824,10 @@  discard block
 block discarded – undo
4090 4824
 		{
4091 4825
 			//error_log(__METHOD__." Message(s): ".implode(',',$_messageUID));
4092 4826
 			$uidsToMove = new Horde_Imap_Client_Ids();
4093
-			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
4827
+			if (!(is_object($_messageUID) || is_array($_messageUID)))
4828
+			{
4829
+				$_messageUID = (array)$_messageUID;
4830
+			}
4094 4831
 			$uidsToMove->add($_messageUID);
4095 4832
 		}
4096 4833
 		$sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']);
@@ -4112,12 +4849,14 @@  discard block
 block discarded – undo
4112 4849
 
4113 4850
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew));
4114 4851
 
4115
-			if (is_object($headersNew)) {
4852
+			if (is_object($headersNew))
4853
+			{
4116 4854
 				$c=0;
4117 4855
 				$retUid = new Horde_Imap_Client_Ids();
4118 4856
 				// we copy chunks of 5 to avoid too much memory and/or server stress
4119 4857
 				// some servers seem not to allow/support the appendig of multiple messages. so we are down to one
4120
-				foreach($headersNew as &$_headerObject) {
4858
+				foreach($headersNew as &$_headerObject)
4859
+				{
4121 4860
 					$c++;
4122 4861
 					$flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message
4123 4862
 					$date = $_headerObject->getImapDate();
@@ -4201,7 +4940,11 @@  discard block
 block discarded – undo
4201 4940
 	{
4202 4941
 		try {
4203 4942
 			$date = new DateTime($_date);	// parse date & time including timezone (throws exception, if not parsable)
4204
-			if ($convert2usertime) $date->setUser();	// convert to user-time
4943
+			if ($convert2usertime)
4944
+			{
4945
+				$date->setUser();
4946
+			}
4947
+			// convert to user-time
4205 4948
 			$date2return = $date->format($format);
4206 4949
 		}
4207 4950
 		catch(\Exception $e)
@@ -4233,9 +4976,15 @@  discard block
 block discarded – undo
4233 4976
 	static function htmlentities($_string, $_charset=false)
4234 4977
 	{
4235 4978
 		//setting the charset (if not given)
4236
-		if ($_charset===false) $_charset = self::$displayCharset;
4979
+		if ($_charset===false)
4980
+		{
4981
+			$_charset = self::$displayCharset;
4982
+		}
4237 4983
 		$string = @htmlentities($_string, ENT_QUOTES, $_charset, false);
4238
-		if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false);
4984
+		if (empty($string) && !empty($_string))
4985
+		{
4986
+			$string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false);
4987
+		}
4239 4988
 		return $string;
4240 4989
 	}
4241 4990
 
@@ -4255,18 +5004,41 @@  discard block
 block discarded – undo
4255 5004
 		$_html = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>','</td></font>','<br><td>','<tr></tr>','<o:p></o:p>','<o:p>','</o:p>'),
4256 5005
 							 array('&amp;',    '<BR>',           '<BR>',             '<BR>',             '</font></td>','<td>',    '',         '',           '',  ''),$_html);
4257 5006
 		//$_html = str_replace(array('&amp;amp;'),array('&amp;'),$_html);
4258
-		if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags
4259
-		if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head
5007
+		if (stripos($_html,'style')!==false)
5008
+		{
5009
+			Mail\Html::replaceTagsCompletley($_html,'style');
5010
+		}
5011
+		// clean out empty or pagewide style definitions / left over tags
5012
+		if (stripos($_html,'head')!==false)
5013
+		{
5014
+			Mail\Html::replaceTagsCompletley($_html,'head');
5015
+		}
5016
+		// Strip out stuff in head
4260 5017
 		//if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs
4261 5018
 		//if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
4262 5019
 		//error_log(__METHOD__.' ('.__LINE__.') '.$_html);
4263 5020
 
4264
-		if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
5021
+		if (get_magic_quotes_gpc() === 1)
5022
+		{
5023
+			$_html = stripslashes($_html);
5024
+		}
4265 5025
 		// Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards
4266
-		if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype');
4267
-		if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
4268
-		if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false);
4269
-		if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR');
5026
+		if (stripos($_html,'!doctype')!==false)
5027
+		{
5028
+			Mail\Html::replaceTagsCompletley($_html,'!doctype');
5029
+		}
5030
+		if (stripos($_html,'?xml:namespace')!==false)
5031
+		{
5032
+			Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
5033
+		}
5034
+		if (stripos($_html,'?xml version')!==false)
5035
+		{
5036
+			Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false);
5037
+		}
5038
+		if (strpos($_html,'!CURSOR')!==false)
5039
+		{
5040
+			Mail\Html::replaceTagsCompletley($_html,'!CURSOR');
5041
+		}
4270 5042
 		// htmLawed filter only the 'body'
4271 5043
 		//preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches);
4272 5044
 		//if ($matches[2])
@@ -4305,8 +5077,10 @@  discard block
 block discarded – undo
4305 5077
 		//$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1
4306 5078
 		$CharsetFound=false;
4307 5079
 		//echo "#".$_mimePartObject->encoding.'#<br>';
4308
-		if(is_array($_mimePartObject->parameters)) {
4309
-			if(isset($_mimePartObject->parameters['CHARSET'])) {
5080
+		if(is_array($_mimePartObject->parameters))
5081
+		{
5082
+			if(isset($_mimePartObject->parameters['CHARSET']))
5083
+			{
4310 5084
 				$charSet = $_mimePartObject->parameters['CHARSET'];
4311 5085
 				$CharsetFound=true;
4312 5086
 			}
@@ -4327,7 +5101,10 @@  discard block
 block discarded – undo
4327 5101
 	function decodeMimePart($_mimeMessage, $_encoding, $_charset = '')
4328 5102
 	{
4329 5103
 		// decode the part
4330
-		if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true));
5104
+		if (self::$debug)
5105
+		{
5106
+			error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true));
5107
+		}
4331 5108
 		switch (strtoupper($_encoding))
4332 5109
 		{
4333 5110
 			case 'BASE64':
@@ -4367,13 +5144,19 @@  discard block
 block discarded – undo
4367 5144
 		// sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that
4368 5145
 		// as attachment AND as abstracted ical information (we use our notification style here).
4369 5146
 		$partText = $partCalendar = $partHTML = null;
4370
-		if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure));
5147
+		if (self::$debug)
5148
+		{
5149
+			_debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure));
5150
+		}
4371 5151
 		//error_log(__METHOD__.' ('.__LINE__.') ');
4372 5152
 		$ignore_first_part = true;
4373 5153
 		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
4374 5154
 		{
4375 5155
 			//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part);
4376
-			if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5156
+			if (self::$debug)
5157
+			{
5158
+				echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5159
+			}
4377 5160
 
4378 5161
 			if ($ignore_first_part)
4379 5162
 			{
@@ -4389,11 +5172,17 @@  discard block
 block discarded – undo
4389 5172
 					switch($mimePart->getSubType())
4390 5173
 					{
4391 5174
 						case 'plain':
4392
-							if ($mimePart->getBytes() > 0) $partText = $mimePart;
5175
+							if ($mimePart->getBytes() > 0)
5176
+							{
5177
+								$partText = $mimePart;
5178
+							}
4393 5179
 							break;
4394 5180
 
4395 5181
 						case 'html':
4396
-							if ($mimePart->getBytes() > 0)  $partHTML = $mimePart;
5182
+							if ($mimePart->getBytes() > 0)
5183
+							{
5184
+								$partHTML = $mimePart;
5185
+							}
4397 5186
 							break;
4398 5187
 					}
4399 5188
 					break;
@@ -4406,7 +5195,10 @@  discard block
 block discarded – undo
4406 5195
 							if (count($mimePart->getParts()) > 1)
4407 5196
 							{
4408 5197
 								// in a multipart alternative we treat the multipart/related as html part
4409
-								if (self::$debug) error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts");
5198
+								if (self::$debug)
5199
+								{
5200
+									error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts");
5201
+								}
4410 5202
 								$partHTML = $mimePart;
4411 5203
 								break 3; // GET OUT OF LOOP, will be processed according to type
4412 5204
 							}
@@ -4487,9 +5279,15 @@  discard block
 block discarded – undo
4487 5279
 	 */
4488 5280
 	function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array())
4489 5281
 	{
4490
-		if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>";
5282
+		if (self::$debug)
5283
+		{
5284
+			echo __METHOD__."$_uid, $_htmlMode<br>";
5285
+		}
4491 5286
 		$bodyPart = array();
4492
-		if (self::$debug) _debug_array($_structure);
5287
+		if (self::$debug)
5288
+		{
5289
+			_debug_array($_structure);
5290
+		}
4493 5291
 
4494 5292
 		$ignore_first_part = true;
4495 5293
 		//$skipParts = array();
@@ -4497,7 +5295,10 @@  discard block
 block discarded – undo
4497 5295
 		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
4498 5296
 		{
4499 5297
 			//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type");
4500
-			if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5298
+			if (self::$debug)
5299
+			{
5300
+				echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
5301
+			}
4501 5302
 			if ($ignore_first_part)
4502 5303
 			{
4503 5304
 				$ignore_first_part = false;
@@ -4515,7 +5316,10 @@  discard block
 block discarded – undo
4515 5316
 			switch($part->getPrimaryType())
4516 5317
 			{
4517 5318
 				case 'multipart':
4518
-					if ($part->getDisposition() == 'attachment') continue;
5319
+					if ($part->getDisposition() == 'attachment')
5320
+					{
5321
+						continue;
5322
+					}
4519 5323
 					switch($part->getSubType())
4520 5324
 					{
4521 5325
 						case 'alternative':
@@ -4580,7 +5384,9 @@  discard block
 block discarded – undo
4580 5384
 					if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment')
4581 5385
 					{
4582 5386
 						$skipParts[$mime_id.'.0'] = $mime_type;
4583
-						foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;}
5387
+						foreach($part->contentTypeMap() as $sub_id => $sub_type)
5388
+						{
5389
+$skipParts[$sub_id] = $sub_type;}
4584 5390
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts));
4585 5391
 						//break 2;
4586 5392
 					}
@@ -4623,7 +5429,10 @@  discard block
 block discarded – undo
4623 5429
 	 */
4624 5430
 	function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true)
4625 5431
 	{
4626
-		if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)");
5432
+		if (self::$debug)
5433
+		{
5434
+			error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)");
5435
+		}
4627 5436
 
4628 5437
 		if (empty($_folder))
4629 5438
 		{
@@ -4632,7 +5441,10 @@  discard block
 block discarded – undo
4632 5441
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']);
4633 5442
 		// querying contents of body part
4634 5443
 		$uidsToFetch = new Horde_Imap_Client_Ids();
4635
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
5444
+		if (!(is_object($_uid) || is_array($_uid)))
5445
+		{
5446
+			$_uid = (array)$_uid;
5447
+		}
4636 5448
 		$uidsToFetch->add($_uid);
4637 5449
 
4638 5450
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -4640,9 +5452,12 @@  discard block
 block discarded – undo
4640 5452
 			'peek' => $_preserveSeen,
4641 5453
 			'decode' => true,	// try decode on server, does NOT neccessary work
4642 5454
 		);
4643
-		if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder)))
5455
+		if ($_tryDecodingServerside===false)
5456
+		{
5457
+			// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder)))
4644 5458
 		{
4645 5459
 			$_tryDecodingServerside=false;
5460
+		}
4646 5461
 			$fetchParams = array(
4647 5462
 				'peek' => $_preserveSeen,
4648 5463
 			);
@@ -4684,7 +5499,10 @@  discard block
 block discarded – undo
4684 5499
 	{
4685 5500
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace());
4686 5501
 		$bodyPart = array();
4687
-		if (self::$debug) _debug_array(array($_structure,function_backtrace()));
5502
+		if (self::$debug)
5503
+		{
5504
+			_debug_array(array($_structure,function_backtrace()));
5505
+		}
4688 5506
 
4689 5507
 		if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text')))
4690 5508
 		{
@@ -4734,8 +5552,12 @@  discard block
 block discarded – undo
4734 5552
 	 */
4735 5553
 	function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '')
4736 5554
 	{
4737
-		if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
4738
-		if($_htmlOptions != '') {
5555
+		if (self::$debug)
5556
+		{
5557
+			echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
5558
+		}
5559
+		if($_htmlOptions != '')
5560
+		{
4739 5561
 			$this->htmlOptions = $_htmlOptions;
4740 5562
 		}
4741 5563
 		if (empty($_folder))
@@ -4824,7 +5646,9 @@  discard block
 block discarded – undo
4824 5646
 						default:
4825 5647
 							$bodyPart = array($this->getTextPart($_uid, $_structure, $this->htmlOptions, $_preserveSeen));
4826 5648
 					}
4827
-				} else {
5649
+				}
5650
+				else
5651
+				{
4828 5652
 					// what if the structure->disposition is attachment ,...
4829 5653
 				}
4830 5654
 				return self::normalizeBodyParts($bodyPart);
@@ -4835,13 +5659,18 @@  discard block
 block discarded – undo
4835 5659
 				{
4836 5660
 					case 'rfc822':
4837 5661
 						$newStructure = $_structure->getParts();
4838
-						if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);}
5662
+						if (self::$debug)
5663
+						{
5664
+echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);}
4839 5665
 						return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder));
4840 5666
 				}
4841 5667
 				break;
4842 5668
 
4843 5669
 			default:
4844
-				if (self::$debug) _debug_array($_structure);
5670
+				if (self::$debug)
5671
+				{
5672
+					_debug_array($_structure);
5673
+				}
4845 5674
 				return array(
4846 5675
 					array(
4847 5676
 						'body'		=> lang('The mimeparser can not parse this message.').$_structure->getType(),
@@ -4865,9 +5694,12 @@  discard block
 block discarded – undo
4865 5694
 		{
4866 5695
 			foreach($_bodyParts as $singleBodyPart)
4867 5696
 			{
4868
-				if (!isset($singleBodyPart['body'])) {
5697
+				if (!isset($singleBodyPart['body']))
5698
+				{
4869 5699
 					$buff = self::normalizeBodyParts($singleBodyPart);
4870
-					foreach ((array)$buff as $val) { $body2return[] = $val;}
5700
+					foreach ((array)$buff as $val)
5701
+					{
5702
+$body2return[] = $val;}
4871 5703
 					continue;
4872 5704
 				}
4873 5705
 				$body2return[] = $singleBodyPart;
@@ -4893,13 +5725,20 @@  discard block
 block discarded – undo
4893 5725
 		$message='';
4894 5726
 		for($i=0; $i<count($bodyParts); $i++)
4895 5727
 		{
4896
-			if (!isset($bodyParts[$i]['body'])) {
5728
+			if (!isset($bodyParts[$i]['body']))
5729
+			{
4897 5730
 				$bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy);
4898 5731
 				$message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body'];
4899 5732
 				continue;
4900 5733
 			}
4901
-			if (isset($bodyParts[$i]['error'])) continue;
4902
-			if (empty($bodyParts[$i]['body'])) continue;
5734
+			if (isset($bodyParts[$i]['error']))
5735
+			{
5736
+				continue;
5737
+			}
5738
+			if (empty($bodyParts[$i]['body']))
5739
+			{
5740
+				continue;
5741
+			}
4903 5742
 			// some characterreplacements, as they fail to translate
4904 5743
 			$sar = array(
4905 5744
 				'@(\x84|\x93|\x94)@',
@@ -4926,13 +5765,17 @@  discard block
 block discarded – undo
4926 5765
 				$bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']);
4927 5766
 			}
4928 5767
 
4929
-			if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']);
5768
+			if ($bodyParts[$i]['charSet']===false)
5769
+			{
5770
+				$bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']);
5771
+			}
4930 5772
 			// add line breaks to $bodyParts
4931 5773
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']);
4932 5774
 			$newBody  = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
4933 5775
 			//error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody);
4934 5776
 			$mailClass->activeMimeType = 'text/plain';
4935
-			if ($bodyParts[$i]['mimeType'] == 'text/html') {
5777
+			if ($bodyParts[$i]['mimeType'] == 'text/html')
5778
+			{
4936 5779
 				$mailClass->activeMimeType = $bodyParts[$i]['mimeType'];
4937 5780
 				if (!$preserveHTML)
4938 5781
 				{
@@ -4978,15 +5821,28 @@  discard block
 block discarded – undo
4978 5821
 						// as we switched off HTMLaweds tidy functionality
4979 5822
 						$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
4980 5823
 						$newBody = $htmLawed->run($newBody,self::$htmLawed_config);
4981
-						if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
5824
+						if ($hasOther && $preserveHTML)
5825
+						{
5826
+							$newBody = $matches[1]. $newBody. $matches[3];
5827
+						}
4982 5828
 						$alreadyHtmlLawed=true;
4983 5829
 					}
4984 5830
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody);
4985
-					if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true);
5831
+					if ($preserveHTML==false)
5832
+					{
5833
+						$newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true);
5834
+					}
4986 5835
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody);
4987
-					if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n
5836
+					if ($preserveHTML==false)
5837
+					{
5838
+						$newBody = nl2br($newBody);
5839
+					}
5840
+					// we need this, as htmLawed removes \r\n
4988 5841
 					/*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted
4989
-					if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody);
5842
+					if ($preserveHTML==false)
5843
+					{
5844
+						$newBody = str_replace("<br />","\r\n",$newBody);
5845
+					}
4990 5846
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody);
4991 5847
 				}
4992 5848
 				$message .= $newBody;
@@ -5023,12 +5879,12 @@  discard block
 block discarded – undo
5023 5879
 				  substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith
5024 5880
 				 )
5025 5881
 				)
5026
-			   )
5027
-			{
5882
+			   ) {
5028 5883
 				$s=explode(" ", $line);
5029 5884
 				$line = "";
5030 5885
 				$linecnt = 0;
5031
-				foreach ($s as &$v) {
5886
+				foreach ($s as &$v)
5887
+				{
5032 5888
 					$cnt = strlen($v);
5033 5889
 					// only break long words within the wordboundaries,
5034 5890
 					// but it may destroy links, so we check for href and dont do it if we find one
@@ -5038,14 +5894,20 @@  discard block
 block discarded – undo
5038 5894
 						$v=wordwrap($v, $allowedLength, $cut, true);
5039 5895
 					}
5040 5896
 					// the rest should be broken at the start of the new word that exceeds the limit
5041
-					if ($linecnt+$cnt > $allowedLength) {
5897
+					if ($linecnt+$cnt > $allowedLength)
5898
+					{
5042 5899
 						$v=$cut.$v;
5043 5900
 						#$linecnt = 0;
5044 5901
 						$linecnt =strlen($v)-strlen($cut);
5045
-					} else {
5902
+					}
5903
+					else
5904
+					{
5046 5905
 						$linecnt += $cnt;
5047 5906
 					}
5048
-					if (strlen($v)) $line .= (strlen($line) ? " " : "").$v;
5907
+					if (strlen($v))
5908
+					{
5909
+						$line .= (strlen($line) ? " " : "").$v;
5910
+					}
5049 5911
 				}
5050 5912
 			}
5051 5913
 			$newStr .= $line . "\n";
@@ -5066,11 +5928,18 @@  discard block
 block discarded – undo
5066 5928
 	function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false)
5067 5929
 	{
5068 5930
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace());
5069
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5931
+		if (empty($_folder))
5932
+		{
5933
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5934
+		}
5070 5935
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder");
5071
-		if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) {
5936
+		if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false)
5937
+		{
5072 5938
 			$uidsToFetch = new Horde_Imap_Client_Ids();
5073
-			if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
5939
+			if (!(is_object($_uid) || is_array($_uid)))
5940
+			{
5941
+				$_uid = (array)$_uid;
5942
+			}
5074 5943
 			$uidsToFetch->add($_uid);
5075 5944
 
5076 5945
 			$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5080,8 +5949,10 @@  discard block
 block discarded – undo
5080 5949
 			$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5081 5950
 				'ids' => $uidsToFetch,
5082 5951
 			));
5083
-			if (is_object($headersNew)) {
5084
-				foreach($headersNew as &$_headerObject) {
5952
+			if (is_object($headersNew))
5953
+			{
5954
+				foreach($headersNew as &$_headerObject)
5955
+				{
5085 5956
 					$env = $_headerObject->getEnvelope();
5086 5957
 					//_debug_array($envFields->singleFields());
5087 5958
 					$singleFields = $envFields->singleFields();
@@ -5098,7 +5969,10 @@  discard block
 block discarded – undo
5098 5969
 								//error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses));
5099 5970
 								$envelope[$v]=$env->$v->addresses;
5100 5971
 								$address = array();
5101
-								if (!is_array($envelope[$v])) break;
5972
+								if (!is_array($envelope[$v]))
5973
+								{
5974
+									break;
5975
+								}
5102 5976
 								foreach ($envelope[$v] as $k => $ad)
5103 5977
 								{
5104 5978
 									if (stripos($ad,'@')===false)
@@ -5135,7 +6009,9 @@  discard block
 block discarded – undo
5135 6009
 				}
5136 6010
 			}
5137 6011
 			return $envelope;
5138
-		} else {
6012
+		}
6013
+		else
6014
+		{
5139 6015
 
5140 6016
 			$headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder);
5141 6017
 
@@ -5146,19 +6022,43 @@  discard block
 block discarded – undo
5146 6022
 				'SUBJECT'	=> ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']),
5147 6023
 				'MESSAGE_ID'	=> $headers['MESSAGE-ID']
5148 6024
 			);
5149
-			if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO'];
5150
-			if (isset($headers['REFERENCES'])) $newData['REFERENCES'] = $headers['REFERENCES'];
5151
-			if (isset($headers['THREAD-TOPIC'])) $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC'];
5152
-			if (isset($headers['THREAD-INDEX'])) $newData['THREAD-INDEX'] = $headers['THREAD-INDEX'];
5153
-			if (isset($headers['LIST-ID'])) $newData['LIST-ID'] = $headers['LIST-ID'];
5154
-			if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE'];
6025
+			if (isset($headers['IN-REPLY-TO']))
6026
+			{
6027
+				$newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO'];
6028
+			}
6029
+			if (isset($headers['REFERENCES']))
6030
+			{
6031
+				$newData['REFERENCES'] = $headers['REFERENCES'];
6032
+			}
6033
+			if (isset($headers['THREAD-TOPIC']))
6034
+			{
6035
+				$newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC'];
6036
+			}
6037
+			if (isset($headers['THREAD-INDEX']))
6038
+			{
6039
+				$newData['THREAD-INDEX'] = $headers['THREAD-INDEX'];
6040
+			}
6041
+			if (isset($headers['LIST-ID']))
6042
+			{
6043
+				$newData['LIST-ID'] = $headers['LIST-ID'];
6044
+			}
6045
+			if (isset($headers['SIZE']))
6046
+			{
6047
+				$newData['SIZE'] = $headers['SIZE'];
6048
+			}
5155 6049
 			//_debug_array($newData);
5156 6050
 			$recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO');
5157
-			foreach($recepientList as $recepientType) {
5158
-				if(isset($headers[$recepientType])) {
5159
-					if ($decode) $headers[$recepientType] =  self::decode_header($headers[$recepientType],true);
6051
+			foreach($recepientList as $recepientType)
6052
+			{
6053
+				if(isset($headers[$recepientType]))
6054
+				{
6055
+					if ($decode)
6056
+					{
6057
+						$headers[$recepientType] =  self::decode_header($headers[$recepientType],true);
6058
+					}
5160 6059
 					//error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType]));
5161
-					foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) {
6060
+					foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress)
6061
+					{
5162 6062
 						$addressData = array(
5163 6063
 							'PERSONAL_NAME'		=> $singleAddress->personal ? $singleAddress->personal : 'NIL',
5164 6064
 							'AT_DOMAIN_LIST'	=> $singleAddress->adl ? $singleAddress->adl : 'NIL',
@@ -5166,17 +6066,25 @@  discard block
 block discarded – undo
5166 6066
 							'HOST_NAME'		=> $singleAddress->host ? $singleAddress->host : 'NIL',
5167 6067
 							'EMAIL'			=> $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox,
5168 6068
 						);
5169
-						if($addressData['PERSONAL_NAME'] != 'NIL') {
6069
+						if($addressData['PERSONAL_NAME'] != 'NIL')
6070
+						{
5170 6071
 							$addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal);
5171
-						} else {
6072
+						}
6073
+						else
6074
+						{
5172 6075
 							$addressData['RFC822_EMAIL'] = 'NIL';
5173 6076
 						}
5174 6077
 						$newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData;
5175 6078
 					}
5176
-				} else {
5177
-					if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') {
6079
+				}
6080
+				else
6081
+				{
6082
+					if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO')
6083
+					{
5178 6084
 						$newData[$recepientType] = $newData['FROM'];
5179
-					} else {
6085
+					}
6086
+					else
6087
+					{
5180 6088
 						$newData[$recepientType] = array();
5181 6089
 					}
5182 6090
 				}
@@ -5199,9 +6107,15 @@  discard block
 block discarded – undo
5199 6107
 	function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='')
5200 6108
 	{
5201 6109
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder);
5202
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6110
+		if (empty($_folder))
6111
+		{
6112
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6113
+		}
5203 6114
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5204
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
6115
+		if (!(is_object($_uid) || is_array($_uid)))
6116
+		{
6117
+			$_uid = (array)$_uid;
6118
+		}
5205 6119
 		$uidsToFetch->add($_uid);
5206 6120
 
5207 6121
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5219,7 +6133,8 @@  discard block
 block discarded – undo
5219 6133
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5220 6134
 			'ids' => $uidsToFetch,
5221 6135
 		));
5222
-		if (is_object($headersNew)) {
6136
+		if (is_object($headersNew))
6137
+		{
5223 6138
 			foreach($headersNew as $_fetchObject)
5224 6139
 			{
5225 6140
 				$headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
@@ -5241,11 +6156,17 @@  discard block
 block discarded – undo
5241 6156
 			}
5242 6157
 			if ($decode === 'object')
5243 6158
 			{
5244
-				if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
6159
+				if (is_object($headers))
6160
+				{
6161
+					$headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
6162
+				}
5245 6163
 				return $headers;
5246 6164
 			}
5247 6165
 			$retValue = is_object($headers) ? $headers->toArray():array();
5248
-			if ($size) $retValue['size'] = $size;
6166
+			if ($size)
6167
+			{
6168
+				$retValue['size'] = $size;
6169
+			}
5249 6170
 		}
5250 6171
 		$retValue = array_change_key_case($retValue,CASE_UPPER);
5251 6172
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue));
@@ -5277,10 +6198,16 @@  discard block
 block discarded – undo
5277 6198
 	function getMessageRawHeader($_uid, $_partID = '', $_folder = '')
5278 6199
 	{
5279 6200
 		static $rawHeaders;
5280
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6201
+		if (empty($_folder))
6202
+		{
6203
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6204
+		}
5281 6205
 		//error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder");
5282 6206
 
5283
-		if (is_null($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
6207
+		if (is_null($rawHeaders)||!is_array($rawHeaders))
6208
+		{
6209
+			$rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
6210
+		}
5284 6211
 		if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
5285 6212
 		{
5286 6213
 			//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder");
@@ -5288,7 +6215,10 @@  discard block
 block discarded – undo
5288 6215
 		}
5289 6216
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5290 6217
 		$uid = $_uid;
5291
-		if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid;
6218
+		if (!(is_object($_uid) || is_array($_uid)))
6219
+		{
6220
+			$uid = (array)$_uid;
6221
+		}
5292 6222
 		$uidsToFetch->add($uid);
5293 6223
 
5294 6224
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5304,8 +6234,10 @@  discard block
 block discarded – undo
5304 6234
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5305 6235
 			'ids' => $uidsToFetch,
5306 6236
 		));
5307
-		if (is_object($headersNew)) {
5308
-			foreach($headersNew as &$_headerObject) {
6237
+		if (is_object($headersNew))
6238
+		{
6239
+			foreach($headersNew as &$_headerObject)
6240
+			{
5309 6241
 				$retValue = $_headerObject->getHeaderText();
5310 6242
 				if ($_partID != '')
5311 6243
 				{
@@ -5333,22 +6265,33 @@  discard block
 block discarded – undo
5333 6265
 	static function &getStyles($_bodyParts)
5334 6266
 	{
5335 6267
 		$style = '';
5336
-		if (empty($_bodyParts)) return "";
5337
-		foreach((array)$_bodyParts as $singleBodyPart) {
5338
-			if (!isset($singleBodyPart['body'])) {
6268
+		if (empty($_bodyParts))
6269
+		{
6270
+			return "";
6271
+		}
6272
+		foreach((array)$_bodyParts as $singleBodyPart)
6273
+		{
6274
+			if (!isset($singleBodyPart['body']))
6275
+			{
5339 6276
 				$singleBodyPart['body'] = self::getStyles($singleBodyPart);
5340 6277
 				$style .= $singleBodyPart['body'];
5341 6278
 				continue;
5342 6279
 			}
5343 6280
 
5344
-			if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']);
6281
+			if ($singleBodyPart['charSet']===false)
6282
+			{
6283
+				$singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']);
6284
+			}
5345 6285
 			$singleBodyPart['body'] = Translation::convert(
5346 6286
 				$singleBodyPart['body'],
5347 6287
 				strtolower($singleBodyPart['charSet'])
5348 6288
 			);
5349 6289
 			$ct = 0;
5350 6290
 			$newStyle=array();
5351
-			if (stripos($singleBodyPart['body'],'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle);
6291
+			if (stripos($singleBodyPart['body'],'<style')!==false)
6292
+			{
6293
+				$ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle);
6294
+			}
5352 6295
 			if ($ct>0)
5353 6296
 			{
5354 6297
 				//error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle));
@@ -5380,7 +6323,11 @@  discard block
 block discarded – undo
5380 6323
 		// CSS Security
5381 6324
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
5382 6325
 		$css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style);
5383
-		if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included
6326
+		if (stripos($css,'script')!==false)
6327
+		{
6328
+			Mail\Html::replaceTagsCompletley($css,'script');
6329
+		}
6330
+		// Strip out script that may be included
5384 6331
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
5385 6332
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
5386 6333
 		$css = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
@@ -5401,8 +6348,14 @@  discard block
 block discarded – undo
5401 6348
 	{
5402 6349
 		//TODO: caching einbauen static!
5403 6350
 		static $rawBody;
5404
-		if (is_null($rawBody)) $rawBody = array();
5405
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6351
+		if (is_null($rawBody))
6352
+		{
6353
+			$rawBody = array();
6354
+		}
6355
+		if (empty($_folder))
6356
+		{
6357
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6358
+		}
5406 6359
 		if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
5407 6360
 		{
5408 6361
 			//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder");
@@ -5411,7 +6364,10 @@  discard block
 block discarded – undo
5411 6364
 
5412 6365
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5413 6366
 		$uid = $_uid;
5414
-		if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid;
6367
+		if (!(is_object($_uid) || is_array($_uid)))
6368
+		{
6369
+			$uid = (array)$_uid;
6370
+		}
5415 6371
 		$uidsToFetch->add($uid);
5416 6372
 
5417 6373
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5424,8 +6380,10 @@  discard block
 block discarded – undo
5424 6380
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5425 6381
 			'ids' => $uidsToFetch,
5426 6382
 		));
5427
-		if (is_object($headersNew)) {
5428
-			foreach($headersNew as &$_headerObject) {
6383
+		if (is_object($headersNew))
6384
+		{
6385
+			foreach($headersNew as &$_headerObject)
6386
+			{
5429 6387
 				$body = $_headerObject->getFullMsg();
5430 6388
 				if ($_partID != '')
5431 6389
 				{
@@ -5458,14 +6416,20 @@  discard block
 block discarded – undo
5458 6416
 	 */
5459 6417
 	function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false)
5460 6418
 	{
5461
-		if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID");
6419
+		if (self::$debug)
6420
+		{
6421
+			error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID");
6422
+		}
5462 6423
 
5463 6424
 		if (empty($_folder))
5464 6425
 		{
5465 6426
 			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5466 6427
 		}
5467 6428
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5468
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
6429
+		if (!(is_object($_uid) || is_array($_uid)))
6430
+		{
6431
+			$_uid = (array)$_uid;
6432
+		}
5469 6433
 		$uidsToFetch->add($_uid);
5470 6434
 		try
5471 6435
 		{
@@ -5474,7 +6438,10 @@  discard block
 block discarded – undo
5474 6438
 	//		$fquery->envelope();
5475 6439
 	//		$fquery->size();
5476 6440
 			$_fquery->structure();
5477
-			if ($_partID) $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen));
6441
+			if ($_partID)
6442
+			{
6443
+				$_fquery->bodyPart($_partID, array('peek' => $_preserveSeen));
6444
+			}
5478 6445
 
5479 6446
 			$mail = $this->icServer->fetch($_folder, $_fquery, array(
5480 6447
 				'ids' => $uidsToFetch,
@@ -5505,16 +6472,28 @@  discard block
 block discarded – undo
5505 6472
 	 */
5506 6473
 	function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='')
5507 6474
 	{
5508
-		if (self::$debug) error_log( __METHOD__.":$_uid, $_partID");
5509
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6475
+		if (self::$debug)
6476
+		{
6477
+			error_log( __METHOD__.":$_uid, $_partID");
6478
+		}
6479
+		if (empty($_folder))
6480
+		{
6481
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6482
+		}
5510 6483
 		$attachments = array();
5511 6484
 		if (!isset($_structure))
5512 6485
 		{
5513 6486
 			$_structure = $this->getStructure($_uid, $_partID,$_folder,true);
5514 6487
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true));
5515 6488
 		}
5516
-		if (!$_structure || !$_structure->contentTypeMap()) return array();
5517
-		if (!empty($_partID)) $_structure = $_structure->getPart($_partID);
6489
+		if (!$_structure || !$_structure->contentTypeMap())
6490
+		{
6491
+			return array();
6492
+		}
6493
+		if (!empty($_partID))
6494
+		{
6495
+			$_structure = $_structure->getPart($_partID);
6496
+		}
5518 6497
 		$skipParts = array();
5519 6498
 		$tnefParts = array();
5520 6499
 		$skip = 0;
@@ -5543,7 +6522,13 @@  discard block
 block discarded – undo
5543 6522
 			if ($mime_type=='message/rfc822' && $_partID!=$mime_id)
5544 6523
 			{
5545 6524
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap()));
5546
-				foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;}
6525
+				foreach($part->contentTypeMap() as $sub_id => $sub_type)
6526
+				{
6527
+if ($sub_id != $mime_id)
6528
+				{
6529
+					$skipParts[$sub_id] = $sub_type;
6530
+				}
6531
+				}
5547 6532
 			}
5548 6533
 			if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')
5549 6534
 			{
@@ -5554,7 +6539,10 @@  discard block
 block discarded – undo
5554 6539
 				$partDisposition='attachment';
5555 6540
 			}
5556 6541
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts));
5557
-			if (array_key_exists($mime_id,$skipParts)) continue;
6542
+			if (array_key_exists($mime_id,$skipParts))
6543
+			{
6544
+				continue;
6545
+			}
5558 6546
 
5559 6547
 			if ($partDisposition == 'attachment' ||
5560 6548
 				(($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') ||
@@ -5565,23 +6553,41 @@  discard block
 block discarded – undo
5565 6553
 			{
5566 6554
 				// if type is message/rfc822 and _partID is given, and MimeID equals partID
5567 6555
 				// we attempt to fetch "ourselves"
5568
-				if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue;
6556
+				if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message')
6557
+				{
6558
+					continue;
6559
+				}
5569 6560
 				$attachment = $part->getAllDispositionParameters();
5570 6561
 				$attachment['disposition'] = $part->getDisposition();
5571 6562
 				$attachment['mimeType'] = $mime_type;
5572 6563
 				$attachment['uid'] = $_uid;
5573 6564
 				$attachment['partID'] = $mime_id;
5574
-				if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName();
6565
+				if (!isset($attachment['name'])||empty($attachment['name']))
6566
+				{
6567
+					$attachment['name'] = $part->getName();
6568
+				}
5575 6569
 				if ($fetchTextCalendar)
5576 6570
 				{
5577 6571
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters()));
5578 6572
 					$method = $part->getContentTypeParameter('method');
5579
-					if ($method) $attachment['method'] = $method;
5580
-					if (!isset($attachment['name'])) $attachment['name'] = 'event.ics';
6573
+					if ($method)
6574
+					{
6575
+						$attachment['method'] = $method;
6576
+					}
6577
+					if (!isset($attachment['name']))
6578
+					{
6579
+						$attachment['name'] = 'event.ics';
6580
+					}
5581 6581
 				}
5582 6582
 				$attachment['size'] = $part->getBytes();
5583
-				if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5584
-				if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type);
6583
+				if (($cid = $part->getContentId()))
6584
+				{
6585
+					$attachment['cid'] = $cid;
6586
+				}
6587
+				if (empty($attachment['name']))
6588
+				{
6589
+					$attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type);
6590
+				}
5585 6591
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment));
5586 6592
 				//typical winmail.dat attachment is
5587 6593
 				//Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat)
@@ -5617,14 +6623,26 @@  discard block
 block discarded – undo
5617 6623
 						$attachment['uid'] = $tnp['uid'];
5618 6624
 						$attachment['partID'] = $tnp['partID'];
5619 6625
 						$attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id;
5620
-						if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName();
6626
+						if (!isset($attachment['name'])||empty($attachment['name']))
6627
+						{
6628
+							$attachment['name'] = $part->getName();
6629
+						}
5621 6630
 						$attachment['size'] = $part->getBytes();
5622
-						if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5623
-						if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6631
+						if (($cid = $part->getContentId()))
6632
+						{
6633
+							$attachment['cid'] = $cid;
6634
+						}
6635
+						if (empty($attachment['name']))
6636
+						{
6637
+							$attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6638
+						}
5624 6639
 						$attachments[] = $attachment;
5625 6640
 					}
5626 6641
 				}
5627
-				if ($tnefResolved===false) $attachments[]=$tnp;
6642
+				if ($tnefResolved===false)
6643
+				{
6644
+					$attachments[]=$tnp;
6645
+				}
5628 6646
 			}
5629 6647
 		}
5630 6648
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
@@ -5728,8 +6746,14 @@  discard block
 block discarded – undo
5728 6746
 
5729 6747
 				$attachment = $part->getAllDispositionParameters();
5730 6748
 				$attachment['mimeType'] = $part->getType();
5731
-				if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5732
-				if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
6749
+				if (!isset($attachment['filename'])||empty($attachment['filename']))
6750
+				{
6751
+					$attachment['filename'] = $part->getName();
6752
+				}
6753
+				if (($cid = $part->getContentId()))
6754
+				{
6755
+					$attachment['cid'] = $cid;
6756
+				}
5733 6757
 				if (empty($attachment['filename']))
5734 6758
 				{
5735 6759
 					$attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?
@@ -5741,7 +6765,10 @@  discard block
 block discarded – undo
5741 6765
 				$attachments[$_uid.'@'.$_partID.'@'.$mime_id] = $attachment;
5742 6766
 			}
5743 6767
 		}
5744
-		if (!is_array($attachments)) return false;
6768
+		if (!is_array($attachments))
6769
+		{
6770
+			return false;
6771
+		}
5745 6772
 		return $attachments;
5746 6773
 	}
5747 6774
 
@@ -5760,10 +6787,16 @@  discard block
 block discarded – undo
5760 6787
 	function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null)
5761 6788
 	{
5762 6789
 		//error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace());
5763
-		if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6790
+		if (!isset($_folder))
6791
+		{
6792
+			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
6793
+		}
5764 6794
 
5765 6795
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5766
-		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
6796
+		if (!(is_object($_uid) || is_array($_uid)))
6797
+		{
6798
+			$_uid = (array)$_uid;
6799
+		}
5767 6800
 		$uidsToFetch->add($_uid);
5768 6801
 
5769 6802
 		$fquery = new Horde_Imap_Client_Fetch_Query();
@@ -5772,8 +6805,10 @@  discard block
 block discarded – undo
5772 6805
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5773 6806
 			'ids' => $uidsToFetch,
5774 6807
 		));
5775
-		if (is_object($headersNew)) {
5776
-			foreach($headersNew as $id=>$_headerObject) {
6808
+		if (is_object($headersNew))
6809
+		{
6810
+			foreach($headersNew as $id=>$_headerObject)
6811
+			{
5777 6812
 				$body = $_headerObject->getFullMsg();
5778 6813
 				if ($_partID != '')
5779 6814
 				{
@@ -5787,7 +6822,10 @@  discard block
 block discarded – undo
5787 6822
 					}
5788 6823
 					// if $partDisposition is empty, we assume attachment, and hope that the function
5789 6824
 					// itself is only triggered to fetch attachments
5790
-					if (empty($partDisposition)) $partDisposition='attachment';
6825
+					if (empty($partDisposition))
6826
+					{
6827
+						$partDisposition='attachment';
6828
+					}
5791 6829
 					if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar')))
5792 6830
 					{
5793 6831
 						//$headerObject=$part->getAllDispositionParameters();//not used anywhere around here
@@ -5796,13 +6834,19 @@  discard block
 block discarded – undo
5796 6834
 						$charset = $part->getContentTypeParameter('charset');
5797 6835
 						//$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" );
5798 6836
 						$this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime);
5799
-						if ($_returnPart) return $part;
6837
+						if ($_returnPart)
6838
+						{
6839
+							return $part;
6840
+						}
5800 6841
 					}
5801 6842
 				}
5802 6843
 			}
5803 6844
 		}
5804 6845
 		$ext = MimeMagic::mime2ext($structure_mime);
5805
-		if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext;
6846
+		if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false)
6847
+		{
6848
+			$filename = trim($filename).'.'.$ext;
6849
+		}
5806 6850
 		if (!$part)
5807 6851
 		{
5808 6852
 			throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder");
@@ -5818,7 +6862,10 @@  discard block
 block discarded – undo
5818 6862
 		);
5819 6863
 
5820 6864
 		// try guessing the mimetype, if we get the application/octet-stream
5821
-		if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']);
6865
+		if (strtolower($attachmentData['type']) == 'application/octet-stream')
6866
+		{
6867
+			$attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']);
6868
+		}
5822 6869
 		# if the attachment holds a winmail number and is a winmail.dat then we have to handle that.
5823 6870
 		if ( $filename == 'winmail.dat' && $_winmail_nr)
5824 6871
 		{
@@ -5841,9 +6888,18 @@  discard block
 block discarded – undo
5841 6888
 					if ($_winmail_nr == $wantedPart.'@'.$mime_id)
5842 6889
 					{
5843 6890
 						//error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment));
5844
-						if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5845
-						if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5846
-						if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6891
+						if (!isset($attachment['filename'])||empty($attachment['filename']))
6892
+						{
6893
+							$attachment['filename'] = $part->getName();
6894
+						}
6895
+						if (($cid = $part->getContentId()))
6896
+						{
6897
+							$attachment['cid'] = $cid;
6898
+						}
6899
+						if (empty($attachment['filename']))
6900
+						{
6901
+							$attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']);
6902
+						}
5847 6903
 						$wmattach = $attachment;
5848 6904
 						$wmattach['attachment'] = $part->getContents(array('stream'=>$_stream));
5849 6905
 
@@ -5853,7 +6909,10 @@  discard block
 block discarded – undo
5853 6909
 			if ($tnefResolved)
5854 6910
 			{
5855 6911
 				$ext = MimeMagic::mime2ext($wmattach['mimeType']);
5856
-				if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext;
6912
+				if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false)
6913
+				{
6914
+					$wmattach['filename'] = trim($wmattach['filename']).'.'.$ext;
6915
+				}
5857 6916
 				$attachmentData = array(
5858 6917
 					'type'       => $wmattach['mimeType'],
5859 6918
 					'filename'   => $wmattach['filename'],
@@ -5883,7 +6942,10 @@  discard block
 block discarded – undo
5883 6942
 		static $uid=null, $part=null, $structure=null;
5884 6943
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part");
5885 6944
 
5886
-		if(empty($_cid)) return false;
6945
+		if(empty($_cid))
6946
+		{
6947
+			return false;
6948
+		}
5887 6949
 
5888 6950
 		if ($_uid != $uid || $_part != $part)
5889 6951
 		{
@@ -5908,13 +6970,19 @@  discard block
 block discarded – undo
5908 6970
 					$attachment = $part;
5909 6971
 				}
5910 6972
 				// everything else we only consider after we checked all
5911
-				if (!isset($attachment)) $attachment = $part;
6973
+				if (!isset($attachment))
6974
+				{
6975
+					$attachment = $part;
6976
+				}
5912 6977
 				// do we want content fetched, can be done later, if not needed
5913 6978
 				if (isset($_stream))
5914 6979
 				{
5915 6980
 					$this->fetchPartContents($_uid, $attachment, $_stream);
5916 6981
 				}
5917
-				if (isset($attachment)) break;
6982
+				if (isset($attachment))
6983
+				{
6984
+					break;
6985
+				}
5918 6986
 			}
5919 6987
 		}
5920 6988
 		// set name as filename, if not set
@@ -5945,10 +7013,17 @@  discard block
 block discarded – undo
5945 7013
 	 */
5946 7014
 	public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null)
5947 7015
 	{
5948
-		if (is_null($part)) return null;//new Horde_Mime_Part;
7016
+		if (is_null($part))
7017
+		{
7018
+			return null;
7019
+		}
7020
+		//new Horde_Mime_Part;
5949 7021
 		$encoding = null;
5950 7022
 		$fetchAsBinary = true;
5951
-		if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false;
7023
+		if ($_mimetype && strtolower($_mimetype)=='message/rfc822')
7024
+		{
7025
+			$fetchAsBinary = false;
7026
+		}
5952 7027
 		// we need to set content on structure to decode transfer encoding
5953 7028
 		$part->setContents(
5954 7029
 			$this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary),
@@ -5985,7 +7060,10 @@  discard block
 block discarded – undo
5985 7060
 		// the recent flag is the default enforced here ; as we assume the _flags is always set,
5986 7061
 		// we default it to hordes default (Recent) (, other wise we should not pass the parameter
5987 7062
 		// for flags at all)
5988
-		if (empty($_flags)) $_flags = '\\Recent';
7063
+		if (empty($_flags))
7064
+		{
7065
+			$_flags = '\\Recent';
7066
+		}
5989 7067
 		//if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags);
5990 7068
 		//if (!is_array($_flags)) $_flags = (array) $_flags;
5991 7069
 		try
@@ -6002,18 +7080,27 @@  discard block
 block discarded – undo
6002 7080
 		}
6003 7081
 		catch (\Exception $e)
6004 7082
 		{
6005
-			if (self::$debug) error_log("Could not append Message: ".$e->getMessage());
7083
+			if (self::$debug)
7084
+			{
7085
+				error_log("Could not append Message: ".$e->getMessage());
7086
+			}
6006 7087
 			throw new Exception\WrongUserinput(lang("Could not append Message:").' '.$e->getMessage().': '.$e->details);
6007 7088
 			//return false;
6008 7089
 		}
6009 7090
 		//error_log(__METHOD__.' ('.__LINE__.') '.' appended UID:'.$messageid);
6010 7091
 		//$messageid = true; // for debug reasons only
6011
-		if ($messageid === true || empty($messageid)) // try to figure out the message uid
7092
+		if ($messageid === true || empty($messageid))
7093
+		{
7094
+			// try to figure out the message uid
6012 7095
 		{
6013 7096
 			$list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false);
7097
+		}
6014 7098
 			if ($list)
6015 7099
 			{
6016
-				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list));
7100
+				if (self::$debug)
7101
+				{
7102
+					error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list));
7103
+				}
6017 7104
 				$messageid = $list['header'][0]['uid'];
6018 7105
 			}
6019 7106
 		}
@@ -6054,7 +7141,10 @@  discard block
 block discarded – undo
6054 7141
 	{
6055 7142
 			//echo __METHOD__." called for $uid,$partid <br>";
6056 7143
 			$headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox);
6057
-			if (empty($headers)) return false;
7144
+			if (empty($headers))
7145
+			{
7146
+				return false;
7147
+			}
6058 7148
 			// dont force retrieval of the textpart, let mailClass preferences decide
6059 7149
 			$bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox);
6060 7150
 			// if we do not want HTML but there is no TextRepresentation with the message itself, try converting
@@ -6072,15 +7162,30 @@  discard block
 block discarded – undo
6072 7162
 			//error_log(array2string($bodyParts));
6073 7163
 			$attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array();
6074 7164
 
6075
-			if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO'];
6076
-			elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM'];
6077
-			elseif (isset($headers['SENDER'])) $mailaddress = $headers['SENDER'];
6078
-			if (isset($headers['CC'])) $mailaddress .= ','.$headers['CC'];
7165
+			if ($mailClass->isSentFolder($mailbox))
7166
+			{
7167
+				$mailaddress = $headers['TO'];
7168
+			}
7169
+			elseif (isset($headers['FROM']))
7170
+			{
7171
+				$mailaddress = $headers['FROM'];
7172
+			}
7173
+			elseif (isset($headers['SENDER']))
7174
+			{
7175
+				$mailaddress = $headers['SENDER'];
7176
+			}
7177
+			if (isset($headers['CC']))
7178
+			{
7179
+				$mailaddress .= ','.$headers['CC'];
7180
+			}
6079 7181
 			//_debug_array(array($headers,$mailaddress));
6080 7182
 			$subject = $headers['SUBJECT'];
6081 7183
 
6082 7184
 			$message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML);
6083
-			if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>';
7185
+			if ($preserveHTML && $mailClass->activeMimeType == 'text/plain')
7186
+			{
7187
+				$message = '<pre>'.$message.'</pre>';
7188
+			}
6084 7189
 			$headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : '');
6085 7190
 			$message = $headdata.$message;
6086 7191
 			//echo __METHOD__.'<br>';
@@ -6131,7 +7236,8 @@  discard block
 block discarded – undo
6131 7236
 							$attachments[$num]['attachment'] = $c->getContents();
6132 7237
 						}
6133 7238
 						// no attempt to convert, if we dont know about the charset
6134
-						if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) {
7239
+						if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset']))
7240
+						{
6135 7241
 							// we do not try guessing the charset, if it is not set
6136 7242
 							//if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']);
6137 7243
 							Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']);
@@ -6152,7 +7258,10 @@  discard block
 block discarded – undo
6152 7258
 						unset($attachments[$num]['attachment']);
6153 7259
 					}
6154 7260
 				}
6155
-				if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages);
7261
+				if (is_array($attachedMessages))
7262
+				{
7263
+					$attachments = array_merge($attachments,$attachedMessages);
7264
+				}
6156 7265
 			}
6157 7266
 			return array(
6158 7267
 					'mailaddress'=>$mailaddress,
@@ -6174,10 +7283,17 @@  discard block
 block discarded – undo
6174 7283
 	{
6175 7284
 		$c = 0;
6176 7285
 		// use the standardIdentity
6177
-		foreach($_identities as $key => $acc) {
6178
-			if ($c==0) $identity = $acc;
7286
+		foreach($_identities as $key => $acc)
7287
+		{
7288
+			if ($c==0)
7289
+			{
7290
+				$identity = $acc;
7291
+			}
6179 7292
 			//error_log(__METHOD__.__LINE__." $key == $_profile_id ");
6180
-			if ($key==$_profile_id) $identity = $acc;
7293
+			if ($key==$_profile_id)
7294
+			{
7295
+				$identity = $acc;
7296
+			}
6181 7297
 			$c++;
6182 7298
 		}
6183 7299
 		return $identity;
@@ -6193,20 +7309,53 @@  discard block
 block discarded – undo
6193 7309
 	{
6194 7310
 		$headdata = null;
6195 7311
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace());
6196
-		if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n");
6197
-		if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n");
6198
-		if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n");
6199
-		if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n");
6200
-		if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n");
6201
-		if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n");
6202
-		if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n");
6203
-		if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n");
6204
-		if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n");
7312
+		if ($header['SUBJECT'])
7313
+		{
7314
+			$headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n");
7315
+		}
7316
+		if ($header['FROM'])
7317
+		{
7318
+			$headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n");
7319
+		}
7320
+		if ($header['SENDER'])
7321
+		{
7322
+			$headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n");
7323
+		}
7324
+		if ($header['TO'])
7325
+		{
7326
+			$headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n");
7327
+		}
7328
+		if ($header['CC'])
7329
+		{
7330
+			$headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n");
7331
+		}
7332
+		if ($header['BCC'])
7333
+		{
7334
+			$headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n");
7335
+		}
7336
+		if ($header['DATE'])
7337
+		{
7338
+			$headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n");
7339
+		}
7340
+		if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal')
7341
+		{
7342
+			$headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n");
7343
+		}
7344
+		if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal')
7345
+		{
7346
+			$headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n");
7347
+		}
6205 7348
 		//if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\
6206 7349
 		if (!empty($headdata))
6207 7350
 		{
6208
-			if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
6209
-			if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata;
7351
+			if (!empty($headline) && $headline != 'SUPPRESS')
7352
+			{
7353
+				$headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
7354
+			}
7355
+			if (empty($headline))
7356
+			{
7357
+				$headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata;
7358
+			}
6210 7359
 			$headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'');
6211 7360
 		}
6212 7361
 		else
@@ -6240,12 +7389,15 @@  discard block
 block discarded – undo
6240 7389
 		$returnAddr ='';
6241 7390
 		if (is_array($rfcAddressArray))
6242 7391
 		{
6243
-			foreach((array)$rfcAddressArray as $addressData) {
7392
+			foreach((array)$rfcAddressArray as $addressData)
7393
+			{
6244 7394
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData));
6245
-				if($addressData['MAILBOX_NAME'] == 'NIL') {
7395
+				if($addressData['MAILBOX_NAME'] == 'NIL')
7396
+				{
6246 7397
 					continue;
6247 7398
 				}
6248
-				if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') {
7399
+				if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients')
7400
+				{
6249 7401
 					continue;
6250 7402
 				}
6251 7403
 				if ($addressData['RFC822_EMAIL'])
@@ -6259,7 +7411,10 @@  discard block
 block discarded – undo
6259 7411
 				}
6260 7412
 				$addressObject = $addressObjectA[0];
6261 7413
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject));
6262
-				if (!$addressObject->valid) continue;
7414
+				if (!$addressObject->valid)
7415
+				{
7416
+					continue;
7417
+				}
6263 7418
 				//$mb =(string)$addressObject->mailbox;
6264 7419
 				//$h = (string)$addressObject->host;
6265 7420
 				//$p = (string)$addressObject->personal;
@@ -6276,7 +7431,10 @@  discard block
 block discarded – undo
6276 7431
 			// do not mess with strings, return them untouched /* ToDo: validate string as Address */
6277 7432
 			$rfcAddressArray = self::decode_header($rfcAddressArray,true);
6278 7433
 			$rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray);
6279
-			if (is_string($rfcAddressArray)) return $rfcAddressArray;
7434
+			if (is_string($rfcAddressArray))
7435
+			{
7436
+				return $rfcAddressArray;
7437
+			}
6280 7438
 		}
6281 7439
 		return $returnAddr;
6282 7440
 	}
@@ -6293,10 +7451,19 @@  discard block
 block discarded – undo
6293 7451
 	{
6294 7452
 		$mergeobj = new Contacts\Merge();
6295 7453
 
6296
-		if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html');
7454
+		if (empty($mimetype))
7455
+		{
7456
+			$mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html');
7457
+		}
6297 7458
 		$rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset);
6298
-		if (empty($rv) && !empty($content) && !empty($err)) $rv = $content;
6299
-		if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err));
7459
+		if (empty($rv) && !empty($content) && !empty($err))
7460
+		{
7461
+			$rv = $content;
7462
+		}
7463
+		if (!empty($err) && !empty($content) && !empty($ids))
7464
+		{
7465
+			error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err));
7466
+		}
6300 7467
 		return $rv;
6301 7468
 	}
6302 7469
 
@@ -6333,13 +7500,15 @@  discard block
 block discarded – undo
6333 7500
 			settype($bytes, 'integer');
6334 7501
 			$bytes /= 10;
6335 7502
 		}
6336
-		else
6337
-			settype($bytes, 'integer');
7503
+		else {
7504
+					settype($bytes, 'integer');
7505
+		}
6338 7506
 
6339 7507
 		return $bytes . ' ' . $type ;
6340 7508
 	}
6341 7509
 
6342
-	static function detect_qp(&$sting) {
7510
+	static function detect_qp(&$sting)
7511
+	{
6343 7512
 		$needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/';
6344 7513
 		return preg_match("$needle",$string);
6345 7514
 	}
@@ -6356,9 +7525,15 @@  discard block
 block discarded – undo
6356 7525
 	 */
6357 7526
 	static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='')
6358 7527
 	{
6359
-		if (is_null($_endtime)) $_endtime = microtime(true);
7528
+		if (is_null($_endtime))
7529
+		{
7530
+			$_endtime = microtime(true);
7531
+		}
6360 7532
 		$usagetime = microtime(true) - $_starttime;
6361
-		if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:''));
7533
+		if (self::$debugTimes)
7534
+		{
7535
+			error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:''));
7536
+		}
6362 7537
 	}
6363 7538
 
6364 7539
 	/**
@@ -6373,7 +7548,10 @@  discard block
 block discarded – undo
6373 7548
 	 */
6374 7549
 	static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822')
6375 7550
 	{
6376
-		if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file'];
7551
+		if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data')
7552
+		{
7553
+			return $_formData['file'];
7554
+		}
6377 7555
 
6378 7556
 		//error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType);
6379 7557
 		$importfailed = $tmpFileName = false;
@@ -6422,8 +7600,15 @@  discard block
 block discarded – undo
6422 7600
 			{
6423 7601
 				$buff = explode('.',$_formData['name']);
6424 7602
 				$suffix = '';
6425
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
6426
-				if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix);
7603
+				if (is_array($buff))
7604
+				{
7605
+					$suffix = array_pop($buff);
7606
+				}
7607
+				// take the last extension to check with ext2mime
7608
+				if (!empty($suffix))
7609
+				{
7610
+					$sfxMimeType = MimeMagic::ext2mime($suffix);
7611
+				}
6427 7612
 				if (!empty($suffix) && !empty($sfxMimeType) &&
6428 7613
 					(strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType)))
6429 7614
 				{
@@ -6471,7 +7656,9 @@  discard block
 block discarded – undo
6471 7656
 			{
6472 7657
 				rename($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName);
6473 7658
 			}
6474
-		} else {
7659
+		}
7660
+		else
7661
+		{
6475 7662
 			//error_log("Import of message ".$_formData['file']." failes to meet basic restrictions");
6476 7663
 			$importfailed = true;
6477 7664
 			$alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']);
@@ -6517,21 +7704,32 @@  discard block
 block discarded – undo
6517 7704
 				if (substr($url, 0, 5) !== 'data:')
6518 7705
 				{
6519 7706
 					$filename = basename($url);
6520
-					if (($directory = dirname($url)) == '.') $directory = '';
7707
+					if (($directory = dirname($url)) == '.')
7708
+					{
7709
+						$directory = '';
7710
+					}
6521 7711
 					$ext = pathinfo($filename, PATHINFO_EXTENSION);
6522 7712
 					$mimeType  = MimeMagic::ext2mime($ext);
6523
-					if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
7713
+					if ( strlen($directory) > 1 && substr($directory,-1) != '/')
7714
+					{
7715
+$directory .= '/'; }
6524 7716
 					$myUrl = $directory.$filename;
6525
-					if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs)
7717
+					if ($myUrl[0]=='/')
7718
+					{
7719
+						// local path -> we only allow path's that are available via http/https (or vfs)
6526 7720
 					{
6527 7721
 						$basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']);
6528 7722
 					}
7723
+					}
6529 7724
 					// use vfs instead of url containing webdav.php
6530 7725
 					// ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign
6531 7726
 					// webdav.php urls as vfs
6532
-					if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it.
7727
+					if (strpos($myUrl,'/webdav.php') !== false)
7728
+					{
7729
+						// we have a webdav link, so we build a vfs/sqlfs link of it.
6533 7730
 					{
6534 7731
 						Vfs::load_wrapper('vfs');
7732
+					}
6535 7733
 						list(,$myUrl) = explode('/webdav.php',$myUrl,2);
6536 7734
 						$basedir = 'vfs://default';
6537 7735
 						$needTempFile = false;
@@ -6560,8 +7758,13 @@  discard block
 block discarded – undo
6560 7758
 						}
6561 7759
 					}
6562 7760
 
6563
-					if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; }
6564
-					if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl));
7761
+					if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/')
7762
+					{
7763
+$basedir .= '/'; }
7764
+					if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http")
7765
+					{
7766
+						$data = file_get_contents($basedir.urldecode($myUrl));
7767
+					}
6565 7768
 				}
6566 7769
 				if (substr($url,0,strlen('data:'))=='data:')
6567 7770
 				{
@@ -6662,7 +7865,10 @@  discard block
 block discarded – undo
6662 7865
 				$_folder = $this->getSentFolder();
6663 7866
 			}
6664 7867
 			$delimiter = $this->getHierarchyDelimiter();
6665
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
7868
+			if($_folder=='INBOX'.$delimiter)
7869
+			{
7870
+				$_folder='INBOX';
7871
+			}
6666 7872
 			if ($importfailed === false)
6667 7873
 			{
6668 7874
 				$Subject = $mailObject->getHeader('Subject');
@@ -6691,7 +7897,9 @@  discard block
 block discarded – undo
6691 7897
 					//error_log(__METHOD__.' ('.__LINE__.') '.' Id To Merge:'.$val);
6692 7898
 					if (/*$GLOBALS['egw_info']['flags']['currentapp'] == 'addressbook' &&*/
6693 7899
 						count($SendAndMergeTocontacts) > 1 && $val &&
6694
-						(is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) // do the merge
7900
+						(is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)))
7901
+					{
7902
+						// do the merge
6695 7903
 					{
6696 7904
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject));
6697 7905
 
@@ -6700,6 +7908,7 @@  discard block
 block discarded – undo
6700 7908
 						{
6701 7909
 							//error_log('ID ' . $val . ' ' .$type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset));
6702 7910
 							$merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset);
7911
+					}
6703 7912
 							$mailObject->addAddress($merged,'',$type);
6704 7913
 							if($type == 'to')
6705 7914
 							{
@@ -6731,9 +7940,15 @@  discard block
 block discarded – undo
6731 7940
 						$mailObject->clearCustomHeaders();
6732 7941
 						$mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset));
6733 7942
 						//error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType);
6734
-						if($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7943
+						if($text_body)
7944
+						{
7945
+							$text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7946
+						}
6735 7947
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e));
6736
-						if($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7948
+						if($html_body)
7949
+						{
7950
+							$html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
7951
+						}
6737 7952
 
6738 7953
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject));
6739 7954
 						// set a higher timeout for big messages
@@ -6748,9 +7963,12 @@  discard block
 block discarded – undo
6748 7963
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo));
6749 7964
 						}
6750 7965
 					}
6751
-					elseif (!$k)	// 1. entry, further entries will fail for apps other then addressbook
7966
+					elseif (!$k)
7967
+					{
7968
+						// 1. entry, further entries will fail for apps other then addressbook
6752 7969
 					{
6753 7970
 						$openAsDraft = true;
7971
+					}
6754 7972
 						$mailObject->removeHeader('Message-ID');
6755 7973
 						$mailObject->removeHeader('Date');
6756 7974
 						$mailObject->clearCustomHeaders();
@@ -6765,9 +7983,12 @@  discard block
 block discarded – undo
6765 7983
 
6766 7984
 						// No addresses from placeholders?  Treat it as just a contact ID
6767 7985
 						if (count($mailObject->getAddresses('to',true)) == 0 &&
6768
-							is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge
7986
+							is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))
7987
+						{
7988
+							// do the merge
6769 7989
 						{
6770 7990
 							$contact = $bo_merge->contacts->read($val);
7991
+						}
6771 7992
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact));
6772 7993
 							$email = ($contact['email'] ? $contact['email'] : $contact['email_home']);
6773 7994
 							$nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']);
@@ -6778,9 +7999,15 @@  discard block
 block discarded – undo
6778 7999
 						}
6779 8000
 						$mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset));
6780 8001
 						//error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType);
6781
-						if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8002
+						if (!empty($Body))
8003
+						{
8004
+							$text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8005
+						}
6782 8006
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e));
6783
-						if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8007
+						if (!empty($AltBody))
8008
+						{
8009
+							$html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
8010
+						}
6784 8011
 						$_folder = $this->getDraftFolder();
6785 8012
 					}
6786 8013
 					if ($sendOK || $openAsDraft)
@@ -6788,11 +8015,15 @@  discard block
 block discarded – undo
6788 8015
 						if ($this->folderExists($_folder,true))
6789 8016
 						{
6790 8017
 						    if($this->isSentFolder($_folder))
6791
-							{
8018
+						    {
6792 8019
 						        $flags = '\\Seen';
6793
-						    } elseif($this->isDraftFolder($_folder)) {
8020
+						    }
8021
+						    elseif($this->isDraftFolder($_folder))
8022
+						    {
6794 8023
 						        $flags = '\\Draft';
6795
-						    } else {
8024
+						    }
8025
+						    else
8026
+						    {
6796 8027
 						        $flags = '';
6797 8028
 						    }
6798 8029
 							$savefailed = false;
@@ -6826,7 +8057,10 @@  discard block
 block discarded – undo
6826 8057
 						}
6827 8058
 						else
6828 8059
 						{
6829
-							if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
8060
+							if (!$openComposeWindow)
8061
+							{
8062
+								$processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
8063
+							}
6830 8064
 						}
6831 8065
 					}
6832 8066
 					if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow))
@@ -6874,7 +8108,10 @@  discard block
 block discarded – undo
6874 8108
 				$tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmpFileName);
6875 8109
 				break;
6876 8110
 		}
6877
-		if (!isset($message)) $message = fopen($tmpFileName, 'r');
8111
+		if (!isset($message))
8112
+		{
8113
+			$message = fopen($tmpFileName, 'r');
8114
+		}
6878 8115
 
6879 8116
 		if (!$message)
6880 8117
 		{
@@ -6905,7 +8142,10 @@  discard block
 block discarded – undo
6905 8142
 				(fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192));
6906 8143
 
6907 8144
 			$length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL);
6908
-			if ($length===false) $length = strlen($start);
8145
+			if ($length===false)
8146
+			{
8147
+				$length = strlen($start);
8148
+			}
6909 8149
 			$headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length));
6910 8150
 
6911 8151
 			foreach($headers->toArray(array('nowrap' => true)) as $header => $value)
@@ -6934,7 +8174,10 @@  discard block
 block discarded – undo
6934 8174
 		}
6935 8175
 		else
6936 8176
 		{
6937
-			if (($type = gettype($message)) == 'object') $type = get_class ($message);
8177
+			if (($type = gettype($message)) == 'object')
8178
+			{
8179
+				$type = get_class ($message);
8180
+			}
6938 8181
 			throw new Exception\WrongParameter('Wrong parameter type for message: '.$type);
6939 8182
 		}
6940 8183
 	}
@@ -6958,7 +8201,9 @@  discard block
 block discarded – undo
6958 8201
 			$matches = array();
6959 8202
 			preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches);
6960 8203
 			//error_log(__METHOD__.__LINE__.array2string($matches));
6961
-			foreach ($matches[0] as &$match) {$match = trim($match,', ');}
8204
+			foreach ($matches[0] as &$match)
8205
+			{
8206
+$match = trim($match,', ');}
6962 8207
 			$addresses = implode(',',$matches[0]);
6963 8208
 			//error_log(__METHOD__.__LINE__.array2string($addresses));
6964 8209
 			$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
@@ -6989,7 +8234,10 @@  discard block
 block discarded – undo
6989 8234
 			}
6990 8235
 			else
6991 8236
 			{
6992
-				if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal;
8237
+				if ($previousFailed && $remember)
8238
+				{
8239
+					$adr->personal = $remember. ' ' . $adr->personal;
8240
+				}
6993 8241
 				$remember = '';
6994 8242
 				$previousFailed=false;
6995 8243
 				//error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal");
@@ -7011,7 +8259,10 @@  discard block
 block discarded – undo
7011 8259
 	{
7012 8260
 		$acc = Mail\Account::read($this->profileID);
7013 8261
 		$identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc);
7014
-		if (self::$debug) error_log(__METHOD__.__LINE__.array2string($identity));
8262
+		if (self::$debug)
8263
+		{
8264
+			error_log(__METHOD__.__LINE__.array2string($identity));
8265
+		}
7015 8266
 		$headers = $this->getMessageHeader($uid, '', 'object', true, $_folder);
7016 8267
 
7017 8268
 		$mdn = new Horde_Mime_Mdn($headers);
Please login to merge, or discard this patch.