Completed
Push — 14.2 ( ebfddb...2a0133 )
by Hadi
130:14 queued 111:10
created
mail/inc/class.mail_ui.inc.php 1 patch
Braces   +806 added lines, -222 removed lines patch added patch discarded remove patch
@@ -114,9 +114,15 @@  discard block
 block discarded – undo
114 114
 	function __construct($run_constructor=true)
115 115
 	{
116 116
 		$this->mail_tree = new mail_tree($this);
117
-		if (!$run_constructor) return;
117
+		if (!$run_constructor)
118
+		{
119
+			return;
120
+		}
118 121
 
119
-		if (mail_bo::$debugTimes) $starttime = microtime (true);
122
+		if (mail_bo::$debugTimes)
123
+		{
124
+			$starttime = microtime (true);
125
+		}
120 126
 		// no autohide of the sidebox, as we use it for folderlist now.
121 127
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
122 128
 
@@ -127,13 +133,19 @@  discard block
 block discarded – undo
127 133
 		if ($_GET["resetConnection"])
128 134
 		{
129 135
 			unset($_GET["resetConnection"]);
130
-			if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
136
+			if (mail_bo::$debug)
137
+			{
138
+				error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
139
+			}
131 140
 			emailadmin_imapbase::unsetCachedObjects(self::$icServerID);
132 141
 		}
133 142
 
134 143
 		try {
135 144
 			$this->mail_bo = mail_bo::getInstance(true,self::$icServerID, true, false, true);
136
-			if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
145
+			if (mail_bo::$debug)
146
+			{
147
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
148
+			}
137 149
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
138 150
 
139 151
 			// RegEx to minimize extra openConnection
@@ -150,7 +162,10 @@  discard block
 block discarded – undo
150 162
 			// redirect to mail wizard to handle it (redirect works for ajax too)
151 163
 			self::callWizard($e->getMessage(),true,'error');
152 164
 		}
153
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
165
+		if (mail_bo::$debugTimes)
166
+		{
167
+			mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
168
+		}
154 169
 	}
155 170
 
156 171
 	/**
@@ -209,16 +224,28 @@  discard block
 block discarded – undo
209 224
 	 */
210 225
 	function changeProfile($_icServerID,$unsetCache=false)
211 226
 	{
212
-		if (mail_bo::$debugTimes) $starttime = microtime (true);
227
+		if (mail_bo::$debugTimes)
228
+		{
229
+			$starttime = microtime (true);
230
+		}
213 231
 		if (self::$icServerID != $_icServerID)
214 232
 		{
215 233
 			self::$icServerID = $_icServerID;
216 234
 		}
217
-		if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
235
+		if (mail_bo::$debug)
236
+		{
237
+			error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
238
+		}
218 239
 
219
-		if ($unsetCache) emailadmin_imapbase::unsetCachedObjects(self::$icServerID);
240
+		if ($unsetCache)
241
+		{
242
+			emailadmin_imapbase::unsetCachedObjects(self::$icServerID);
243
+		}
220 244
 		$this->mail_bo = mail_bo::getInstance(false,self::$icServerID,true, false, true);
221
-		if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
245
+		if (mail_bo::$debug)
246
+		{
247
+			error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
248
+		}
222 249
 		// no icServer Object: something failed big time
223 250
 		if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
224 251
 		{
@@ -228,14 +255,20 @@  discard block
 block discarded – undo
228 255
 
229 256
 		// save session varchar
230 257
 		$oldicServerID =& egw_cache::getSession('mail','activeProfileID');
231
-		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
258
+		if ($oldicServerID <> self::$icServerID)
259
+		{
260
+			$this->mail_bo->openConnection(self::$icServerID);
261
+		}
232 262
 		$oldicServerID = self::$icServerID;
233 263
 		if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
234 264
 		{
235 265
 			throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID");
236 266
 		}
237 267
 
238
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
268
+		if (mail_bo::$debugTimes)
269
+		{
270
+			mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
271
+		}
239 272
 	}
240 273
 
241 274
 	/**
@@ -276,7 +309,8 @@  discard block
 block discarded – undo
276 309
 		// got subscribed or unsubscribed by the user
277 310
 		try {
278 311
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
279
-		} catch (Exception $ex) {
312
+		}
313
+		catch (Exception $ex) {
280 314
 			egw_framework::message($ex->getMessage());
281 315
 		}
282 316
 
@@ -310,9 +344,18 @@  discard block
 block discarded – undo
310 344
 						list(,$node) = explode($profileId.self::$delimiter, $path);
311 345
 						if ($node)
312 346
 						{
313
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
314
-							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
315
-							if ($value['value']) $cont[] = $path;
347
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value'])
348
+							{
349
+								$to_unsubscribe []= $node;
350
+							}
351
+							if (is_array($subscribed) && !$subscribed[$node] && $value['value'])
352
+							{
353
+								$to_subscribe [] = $node;
354
+							}
355
+							if ($value['value'])
356
+							{
357
+								$cont[] = $path;
358
+							}
316 359
 						}
317 360
 
318 361
 					}
@@ -400,7 +443,10 @@  discard block
 block discarded – undo
400 443
 	{
401 444
 		try	{
402 445
 				//error_log(__METHOD__.__LINE__.function_backtrace());
403
-				if (mail_bo::$debugTimes) $starttime = microtime (true);
446
+				if (mail_bo::$debugTimes)
447
+				{
448
+					$starttime = microtime (true);
449
+				}
404 450
 				$this->mail_bo->restoreSessionData();
405 451
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
406 452
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -455,13 +501,16 @@  discard block
 block discarded – undo
455 501
 				}
456 502
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
457 503
 				$quota = false;//$this->mail_bo->getQuotaRoot();
458
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
504
+				if($quota !== false && $quota['limit'] != 'NOT SET')
505
+				{
459 506
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
460 507
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
461 508
 					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
462 509
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
463 510
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
464
-				} else {
511
+				}
512
+				else
513
+				{
465 514
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
466 515
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
467 516
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -469,7 +518,8 @@  discard block
 block discarded – undo
469 518
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
470 519
 				$vacation = false;//$this->gatherVacation();
471 520
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
472
-				if($vacation) {
521
+				if($vacation)
522
+				{
473 523
 					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
474 524
 					{
475 525
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
@@ -503,21 +553,36 @@  discard block
 block discarded – undo
503 553
 					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
504 554
 					foreach($keywords as &$k)
505 555
 					{
506
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
556
+						if (array_key_exists($k,$this->statusTypes))
557
+						{
558
+							unset($this->statusTypes[$k]);
559
+						}
507 560
 					}
508 561
 				}
509 562
 
510
-				if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
511
-				if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
563
+				if (!isset($content[self::$nm_index]['foldertree']))
564
+				{
565
+					$content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
566
+				}
567
+				if (!isset($content[self::$nm_index]['selectedFolder']))
568
+				{
569
+					$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
570
+				}
512 571
 
513 572
 				$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
514 573
 
515 574
 				if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
516 575
 				{
517 576
 					emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
518
-					if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
577
+					if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
578
+					{
579
+						emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
580
+					}
581
+				}
582
+				if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])
583
+				{
584
+					unset($this->searchTypes['quick']);
519 585
 				}
520
-				if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) unset($this->searchTypes['quick']);
521 586
 				$sel_options['filter2'] = $this->searchTypes;
522 587
 				$sel_options['filter'] = $this->statusTypes;
523 588
 
@@ -712,18 +777,30 @@  discard block
 block discarded – undo
712 777
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions);
713 778
 
714 779
 				// sending preview toolbar actions
715
-				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
780
+				if ($content['mailSplitter'])
781
+				{
782
+					$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
783
+				}
716 784
 
717
-				if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']=(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject');
785
+				if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search']))
786
+				{
787
+					$content[self::$nm_index]['filter2']=(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject');
788
+				}
718 789
 				$readonlys = $preserv = array();
719
-				if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
790
+				if (mail_bo::$debugTimes)
791
+				{
792
+					mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
793
+				}
720 794
 		}
721 795
 		catch (Exception $e)
722 796
 		{
723 797
 			self::callWizard($e->getMessage(),true, 'error');
724 798
 		}
725 799
 		// Check preview pane is enabled, then show spliter
726
-		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
800
+		if ($this->mail_bo->mailPreferences['previewPane'])
801
+		{
802
+			$etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
803
+		}
727 804
 
728 805
 		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
729 806
 	}
@@ -762,12 +839,18 @@  discard block
 block discarded – undo
762 839
 	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
763 840
 	{
764 841
 		$nodeID = $_GET['id'];
765
-		if (!is_null($_nodeID)) $nodeID = $_nodeID;
842
+		if (!is_null($_nodeID))
843
+		{
844
+			$nodeID = $_nodeID;
845
+		}
766 846
 		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
767 847
 		$fetchCounters = !is_null($_nodeID);
768 848
 		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
769 849
 
770
-		if (!empty($_folderName)) $fetchCounters = true;
850
+		if (!empty($_folderName))
851
+		{
852
+			$fetchCounters = true;
853
+		}
771 854
 
772 855
 		// Check if it is called for refresh root
773 856
 		// then we need to reinitialized the index tree
@@ -779,7 +862,10 @@  discard block
 block discarded – undo
779 862
 		{
780 863
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
781 864
 		}
782
-		if (!is_null($_nodeID)) return $data;
865
+		if (!is_null($_nodeID))
866
+		{
867
+			return $data;
868
+		}
783 869
 		etemplate_widget_tree::send_quote_json($data);
784 870
 	}
785 871
 
@@ -844,7 +930,10 @@  discard block
 block discarded – undo
844 930
 				$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
845 931
 			}
846 932
 		}
847
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
933
+		if (!is_array($lastFoldersUsedForMoveCont))
934
+		{
935
+			$lastFoldersUsedForMoveCont=array();
936
+		}
848 937
 		foreach ($lastFoldersUsedForMoveCont as $pid => $info)
849 938
 		{
850 939
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
@@ -859,9 +948,12 @@  discard block
 block discarded – undo
859 948
 					{
860 949
 						$moveaction .= $lastFolderUsedForMoveCont;
861 950
 
862
-						if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
951
+						if ($this->mail_bo->folderExists($i))
952
+						{
953
+							// only 10 entries per mailaccount.Control this on setting the buffered folders
863 954
 						{
864 955
 							$fS['profileID'] = $this->mail_bo->profileID;
956
+						}
865 957
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
866 958
 							$fS['shortDisplayName'] = $i;
867 959
 							$moveactions[$moveaction] = $fS;
@@ -881,9 +973,12 @@  discard block
 block discarded – undo
881 973
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
882 974
 				{
883 975
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
884
-					if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders
976
+					if (!empty($lastFolderUsedForMoveCont))
977
+					{
978
+						// only 10 entries per mailaccount.Control this on setting the buffered folders
885 979
 					{
886 980
 						$moveaction = 'move_';
981
+					}
887 982
 						$fS = array();
888 983
 						$fS['profileID'] = $pid;
889 984
 						$fS['profileName'] = $accArray[$pid];
@@ -1241,22 +1336,34 @@  discard block
 block discarded – undo
1241 1336
 					$rows=array();
1242 1337
 					return 0;
1243 1338
 				}
1244
-				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1339
+				if (empty($folderName))
1340
+				{
1341
+					$query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1342
+				}
1245 1343
 			}
1246 1344
 		}
1247 1345
 		if (!isset($mail_ui))
1248 1346
 		{
1249 1347
 			$mail_ui = new mail_ui(true);	// run constructor for current profile
1250
-			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1348
+			if (empty($query['selectedFolder']))
1349
+			{
1350
+				$query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1351
+			}
1251 1352
 		}
1252 1353
 
1253 1354
 		//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
1254 1355
 		//mail_bo::$debugTimes=true;
1255
-		if (mail_bo::$debugTimes) $starttime = microtime(true);
1356
+		if (mail_bo::$debugTimes)
1357
+		{
1358
+			$starttime = microtime(true);
1359
+		}
1256 1360
 		//$query['search'] is the phrase in the searchbox
1257 1361
 
1258 1362
 		$mail_ui->mail_bo->restoreSessionData();
1259
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1363
+		if (isset($query['selectedFolder']))
1364
+		{
1365
+			$mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1366
+		}
1260 1367
 
1261 1368
 		$sRToFetch = null;
1262 1369
 		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
@@ -1266,7 +1373,10 @@  discard block
 block discarded – undo
1266 1373
 			unset($app);
1267 1374
 		}
1268 1375
 		//save selected Folder to sessionData (mailbox)->currentFolder
1269
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1376
+		if (isset($query['selectedFolder']))
1377
+		{
1378
+			$mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1379
+		}
1270 1380
 		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1271 1381
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1272 1382
 		{
@@ -1327,7 +1437,10 @@  discard block
 block discarded – undo
1327 1437
 				$rowsFetched['messages'] = $_sR['count'];
1328 1438
 				$sR = $_sR['match']->ids;
1329 1439
 				// if $sR is false, something failed fundamentally
1330
-				if($reverse === true) $sR = ($sR===false?array():array_reverse((array)$sR));
1440
+				if($reverse === true)
1441
+				{
1442
+					$sR = ($sR===false?array():array_reverse((array)$sR));
1443
+				}
1331 1444
 				$sR = array_slice((array)$sR,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1332 1445
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1333 1446
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
@@ -1393,7 +1506,10 @@  discard block
 block discarded – undo
1393 1506
 				}
1394 1507
 				else
1395 1508
 				{
1396
-					if (!empty($v)) $sortResult['header'][] = array('uid'=>$v);
1509
+					if (!empty($v))
1510
+					{
1511
+						$sortResult['header'][] = array('uid'=>$v);
1512
+					}
1397 1513
 				}
1398 1514
 			}
1399 1515
 		}
@@ -1402,15 +1518,24 @@  discard block
 block discarded – undo
1402 1518
 			$sortResult = $sortResultwH;
1403 1519
 		}
1404 1520
 		$rowsFetched['rowsFetched'] = count($sortResult['header']);
1405
-		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1521
+		if (empty($rowsFetched['messages']))
1522
+		{
1523
+			$rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1524
+		}
1406 1525
 
1407 1526
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1408 1527
 		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1409
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1528
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE')
1529
+		{
1530
+			unset($cols[0]);
1531
+		}
1410 1532
 		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1411 1533
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1412 1534
 
1413
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1535
+		if (mail_bo::$debugTimes)
1536
+		{
1537
+			mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1538
+		}
1414 1539
 		return $rowsFetched['messages'];
1415 1540
 	}
1416 1541
 
@@ -1512,7 +1637,10 @@  discard block
 block discarded – undo
1512 1637
 					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1513 1638
 					break;
1514 1639
 				default:
1515
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1640
+					if (isset($actions[$act]))
1641
+					{
1642
+						$actionsenabled[$act]=$actions[$act];
1643
+					}
1516 1644
 			}
1517 1645
 		}
1518 1646
 		unset($actionsenabled['drag_mail']);
@@ -1534,7 +1662,10 @@  discard block
 block discarded – undo
1534 1662
 	 */
1535 1663
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1536 1664
 	{
1537
-		if (mail_bo::$debugTimes) $starttime = microtime(true);
1665
+		if (mail_bo::$debugTimes)
1666
+		{
1667
+			$starttime = microtime(true);
1668
+		}
1538 1669
 		$rv = array();
1539 1670
 		$i=0;
1540 1671
 		foreach((array)$_headers as $header)
@@ -1547,17 +1678,50 @@  discard block
 block discarded – undo
1547 1678
 			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1548 1679
 
1549 1680
 			$flags = "";
1550
-			if(!empty($header['recent'])) $flags .= "R";
1551
-			if(!empty($header['flagged'])) $flags .= "F";
1552
-			if(!empty($header['answered'])) $flags .= "A";
1553
-			if(!empty($header['forwarded'])) $flags .= "W";
1554
-			if(!empty($header['deleted'])) $flags .= "D";
1555
-			if(!empty($header['seen'])) $flags .= "S";
1556
-			if(!empty($header['label1'])) $flags .= "1";
1557
-			if(!empty($header['label2'])) $flags .= "2";
1558
-			if(!empty($header['label3'])) $flags .= "3";
1559
-			if(!empty($header['label4'])) $flags .= "4";
1560
-			if(!empty($header['label5'])) $flags .= "5";
1681
+			if(!empty($header['recent']))
1682
+			{
1683
+				$flags .= "R";
1684
+			}
1685
+			if(!empty($header['flagged']))
1686
+			{
1687
+				$flags .= "F";
1688
+			}
1689
+			if(!empty($header['answered']))
1690
+			{
1691
+				$flags .= "A";
1692
+			}
1693
+			if(!empty($header['forwarded']))
1694
+			{
1695
+				$flags .= "W";
1696
+			}
1697
+			if(!empty($header['deleted']))
1698
+			{
1699
+				$flags .= "D";
1700
+			}
1701
+			if(!empty($header['seen']))
1702
+			{
1703
+				$flags .= "S";
1704
+			}
1705
+			if(!empty($header['label1']))
1706
+			{
1707
+				$flags .= "1";
1708
+			}
1709
+			if(!empty($header['label2']))
1710
+			{
1711
+				$flags .= "2";
1712
+			}
1713
+			if(!empty($header['label3']))
1714
+			{
1715
+				$flags .= "3";
1716
+			}
1717
+			if(!empty($header['label4']))
1718
+			{
1719
+				$flags .= "4";
1720
+			}
1721
+			if(!empty($header['label5']))
1722
+			{
1723
+				$flags .= "5";
1724
+			}
1561 1725
 
1562 1726
 			$data["status"] = "<span class=\"status_img\"></span>";
1563 1727
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
@@ -1565,41 +1729,53 @@  discard block
 block discarded – undo
1565 1729
 			// the css for this row
1566 1730
 			$is_recent=false;
1567 1731
 			$css_styles = array("mail");
1568
-			if ($header['deleted']) {
1732
+			if ($header['deleted'])
1733
+			{
1569 1734
 				$css_styles[] = 'deleted';
1570 1735
 			}
1571
-			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1736
+			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded']))
1737
+			{
1572 1738
 				$css_styles[] = 'recent';
1573 1739
 				$is_recent=true;
1574 1740
 			}
1575
-			if ($header['priority'] < 3) {
1741
+			if ($header['priority'] < 3)
1742
+			{
1576 1743
 				$css_styles[] = 'prio_high';
1577 1744
 			}
1578
-			if ($header['flagged']) {
1745
+			if ($header['flagged'])
1746
+			{
1579 1747
 				$css_styles[] = 'flagged';
1580 1748
 			}
1581
-			if (!$header['seen']) {
1749
+			if (!$header['seen'])
1750
+			{
1582 1751
 				$css_styles[] = 'unseen'; // different status image for recent // solved via css !important
1583 1752
 			}
1584
-			if ($header['answered']) {
1753
+			if ($header['answered'])
1754
+			{
1585 1755
 				$css_styles[] = 'replied';
1586 1756
 			}
1587
-			if ($header['forwarded']) {
1757
+			if ($header['forwarded'])
1758
+			{
1588 1759
 				$css_styles[] = 'forwarded';
1589 1760
 			}
1590
-			if ($header['label1']) {
1761
+			if ($header['label1'])
1762
+			{
1591 1763
 				$css_styles[] = 'labelone';
1592 1764
 			}
1593
-			if ($header['label2']) {
1765
+			if ($header['label2'])
1766
+			{
1594 1767
 				$css_styles[] = 'labeltwo';
1595 1768
 			}
1596
-			if ($header['label3']) {
1769
+			if ($header['label3'])
1770
+			{
1597 1771
 				$css_styles[] = 'labelthree';
1598 1772
 			}
1599
-			if ($header['label4']) {
1773
+			if ($header['label4'])
1774
+			{
1600 1775
 				$css_styles[] = 'labelfour';
1601 1776
 			}
1602
-			if ($header['label5']) {
1777
+			if ($header['label5'])
1778
+			{
1603 1779
 				$css_styles[] = 'labelfive';
1604 1780
 			}
1605 1781
 
@@ -1616,10 +1792,13 @@  discard block
 block discarded – undo
1616 1792
 				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1617 1793
 				// curly brackets get messed up by the template!
1618 1794
 
1619
-				if (!empty($header['subject'])) {
1795
+				if (!empty($header['subject']))
1796
+				{
1620 1797
 					// make the subject shorter if it is to long
1621 1798
 					$subject = $header['subject'];
1622
-				} else {
1799
+				}
1800
+				else
1801
+				{
1623 1802
 					$subject = '('. lang('no subject') .')';
1624 1803
 				}
1625 1804
 
@@ -1661,15 +1840,22 @@  discard block
 block discarded – undo
1661 1840
 					}
1662 1841
 
1663 1842
 					$attachmentFlag = $image;
1664
-				} else {
1843
+				}
1844
+				else
1845
+				{
1665 1846
 					$attachmentFlag ='&nbsp;';
1666 1847
 				}
1667 1848
 				// show priority flag
1668
-				if ($header['priority'] < 3) {
1849
+				if ($header['priority'] < 3)
1850
+				{
1669 1851
 					 $image = html::image('mail','prio_high');
1670
-				} elseif ($header['priority'] > 3) {
1852
+				}
1853
+				elseif ($header['priority'] > 3)
1854
+				{
1671 1855
 					$image = html::image('mail','prio_low');
1672
-				} else {
1856
+				}
1857
+				else
1858
+				{
1673 1859
 					$image = '';
1674 1860
 				}
1675 1861
 				// show a flag for flagged messages
@@ -1711,26 +1897,53 @@  discard block
 block discarded – undo
1711 1897
 			}
1712 1898
 
1713 1899
 			if (in_array("size", $cols))
1714
-				$data["size"] = $header['size']; /// size
1900
+			{
1901
+							$data["size"] = $header['size'];
1902
+			}
1903
+			/// size
1715 1904
 
1716 1905
 			$data["class"] = implode(' ', $css_styles);
1717 1906
 			//translate style-classes back to flags
1718 1907
 			$data['flags'] = Array();
1719
-			if ($header['seen']) $data["flags"]['read'] = 'read';
1720
-			foreach ($css_styles as &$flag) {
1908
+			if ($header['seen'])
1909
+			{
1910
+				$data["flags"]['read'] = 'read';
1911
+			}
1912
+			foreach ($css_styles as &$flag)
1913
+			{
1721 1914
 				if ($flag!='mail')
1722 1915
 				{
1723
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1724
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1725
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1726
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1727
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1728
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1729
-					else $data["flags"][$flag] = $flag;
1916
+					if ($flag=='labelone')
1917
+					{
1918
+$data["flags"]['label1'] = 'label1';}
1919
+					elseif ($flag=='labeltwo')
1920
+					{
1921
+$data["flags"]['label2'] = 'label2';}
1922
+					elseif ($flag=='labelthree')
1923
+					{
1924
+$data["flags"]['label3'] = 'label3';}
1925
+					elseif ($flag=='labelfour')
1926
+					{
1927
+$data["flags"]['label4'] = 'label4';}
1928
+					elseif ($flag=='labelfive')
1929
+					{
1930
+$data["flags"]['label5'] = 'label5';}
1931
+					elseif ($flag=='unseen')
1932
+					{
1933
+unset($data["flags"]['read']);}
1934
+					else {
1935
+						$data["flags"][$flag] = $flag;
1936
+					}
1730 1937
 				}
1731 1938
 			}
1732
-			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1733
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1939
+			if ($header['disposition-notification-to'])
1940
+			{
1941
+				$data['dispositionnotificationto'] = $header['disposition-notification-to'];
1942
+			}
1943
+			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto']))
1944
+			{
1945
+				unset($data['dispositionnotificationto']);
1946
+			}
1734 1947
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1735 1948
 			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1736 1949
 			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
@@ -1740,7 +1953,10 @@  discard block
 block discarded – undo
1740 1953
 			$rv[] = $data;
1741 1954
 			//error_log(__METHOD__.__LINE__.array2string($data));
1742 1955
 		}
1743
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
1956
+		if (mail_bo::$debugTimes)
1957
+		{
1958
+			mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
1959
+		}
1744 1960
 
1745 1961
 		// ToDo: call this ONLY if labels change
1746 1962
 		etemplate_widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1755,8 +1971,14 @@  discard block
 block discarded – undo
1755 1971
 	 */
1756 1972
 	function displayHeader()
1757 1973
 	{
1758
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1759
-		if(isset($_GET['part'])) $partID = $_GET['part'];
1974
+		if(isset($_GET['id']))
1975
+		{
1976
+			$rowID	= $_GET['id'];
1977
+		}
1978
+		if(isset($_GET['part']))
1979
+		{
1980
+			$partID = $_GET['part'];
1981
+		}
1760 1982
 
1761 1983
 		$hA = self::splitRowID($rowID);
1762 1984
 		$uid = $hA['msgUID'];
@@ -1780,7 +2002,8 @@  discard block
 block discarded – undo
1780 2002
 		$rawheaders 	= "";
1781 2003
 		// create it new, with good line breaks
1782 2004
 		reset($newRawHeaders);
1783
-		while(list($key,$value) = @each($newRawHeaders)) {
2005
+		while(list($key,$value) = @each($newRawHeaders))
2006
+		{
1784 2007
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1785 2008
 		}
1786 2009
 
@@ -1803,12 +2026,24 @@  discard block
 block discarded – undo
1803 2026
 	 */
1804 2027
 	function displayMessage($_requesteddata = null)
1805 2028
 	{
1806
-		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2029
+		if (is_null($_requesteddata))
2030
+		{
2031
+			$_requesteddata = $_GET;
2032
+		}
1807 2033
 
1808 2034
 		$preventRedirect=false;
1809
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1810
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1811
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2035
+		if(isset($_requesteddata['id']))
2036
+		{
2037
+			$rowID	= $_requesteddata['id'];
2038
+		}
2039
+		if(isset($_requesteddata['part']))
2040
+		{
2041
+			$partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2042
+		}
2043
+		if(isset($_requesteddata['mode']))
2044
+		{
2045
+			$preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2046
+		}
1812 2047
 
1813 2048
 		$hA = self::splitRowID($rowID);
1814 2049
 		$uid = $hA['msgUID'];
@@ -1821,8 +2056,14 @@  discard block
 block discarded – undo
1821 2056
 			$this->changeProfile($icServerID);
1822 2057
 		}
1823 2058
 		$htmlOptions = $this->mail_bo->htmlOptions;
1824
-		if (!empty($_requesteddata['tryastext'])) $htmlOptions  = "only_if_no_text";
1825
-		if (!empty($_requesteddata['tryashtml'])) $htmlOptions  = "always_display";
2059
+		if (!empty($_requesteddata['tryastext']))
2060
+		{
2061
+			$htmlOptions  = "only_if_no_text";
2062
+		}
2063
+		if (!empty($_requesteddata['tryashtml']))
2064
+		{
2065
+			$htmlOptions  = "always_display";
2066
+		}
1826 2067
 
1827 2068
 		//error_log(__METHOD__.__LINE__.array2string($hA));
1828 2069
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
@@ -1846,14 +2087,20 @@  discard block
 block discarded – undo
1846 2087
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1847 2088
 			egw_framework::message($e->getMessage(), 'error');
1848 2089
 		}
1849
-		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2090
+		if (!empty($uid))
2091
+		{
2092
+			$this->mail_bo->getFlags($uid);
2093
+		}
1850 2094
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1851 2095
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1852 2096
 		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1853 2097
 		$fetchEmbeddedImages = false;
1854 2098
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1855 2099
 		// we do NOT want to see those, that are embedded in the list of attachments
1856
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2100
+		if ($htmlOptions !='always_display')
2101
+		{
2102
+			$fetchEmbeddedImages = true;
2103
+		}
1857 2104
 		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1858 2105
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
1859 2106
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
@@ -1869,10 +2116,16 @@  discard block
 block discarded – undo
1869 2116
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
1870 2117
 
1871 2118
 		// Set up data for taglist widget(s)
1872
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2119
+		if ($envelope['FROM']==$envelope['SENDER'])
2120
+		{
2121
+			unset($envelope['SENDER']);
2122
+		}
1873 2123
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
1874 2124
 		{
1875
-			if (!isset($envelope[$field])) continue;
2125
+			if (!isset($envelope[$field]))
2126
+			{
2127
+				continue;
2128
+			}
1876 2129
 			foreach($envelope[$field] as $field_data)
1877 2130
 			{
1878 2131
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
@@ -1886,7 +2139,10 @@  discard block
 block discarded – undo
1886 2139
 		}
1887 2140
 		$actionsenabled = $this->getDisplayToolbarActions();
1888 2141
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
1889
-		if (empty($subject)) $subject = lang('no subject');
2142
+		if (empty($subject))
2143
+		{
2144
+			$subject = lang('no subject');
2145
+		}
1890 2146
 		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
1891 2147
 		// Send mail ID so we can use it for actions
1892 2148
 		$content['mail_id'] = $rowID;
@@ -1897,8 +2153,14 @@  discard block
 block discarded – undo
1897 2153
 		$content['mail_displaydate'] = mail_bo::_strtotime($headers['DATE'],'ts',true);
1898 2154
 		$content['mail_displaysubject'] = $subject;
1899 2155
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
1900
-		if (!empty($partID)) $linkData['_partID']=$partID;
1901
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2156
+		if (!empty($partID))
2157
+		{
2158
+			$linkData['_partID']=$partID;
2159
+		}
2160
+		if ($htmlOptions != $this->mail_bo->htmlOptions)
2161
+		{
2162
+			$linkData['_htmloptions']=$htmlOptions;
2163
+		}
1902 2164
 		$content['mailDisplayBodySrc'] = egw::link('/index.php',$linkData);
1903 2165
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
1904 2166
 		$content['mail_id']=$rowID;
@@ -1966,7 +2228,8 @@  discard block
 block discarded – undo
1966 2228
 	{
1967 2229
 		$attachmentHTMLBlock='';
1968 2230
 		$attachmentHTML = array();
1969
-		if (is_array($attachments) && count($attachments) > 0) {
2231
+		if (is_array($attachments) && count($attachments) > 0)
2232
+		{
1970 2233
 			$url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
1971 2234
 			$url_img_vfs_save_all = html::image('mail','save_all', lang('Save all'));
1972 2235
 
@@ -1976,7 +2239,10 @@  discard block
 block discarded – undo
1976 2239
 				$attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
1977 2240
 				//error_log(array2string($value));
1978 2241
 				//error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename']));
1979
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']);
2242
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM'))
2243
+				{
2244
+					$value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']);
2245
+				}
1980 2246
 				$attachmentHTML[$key]['type']=$value['mimeType'];
1981 2247
 				$attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']);
1982 2248
 				$hA = self::splitRowID($rowID);
@@ -2019,8 +2285,15 @@  discard block
 block discarded – undo
2019 2285
 						$sfxMimeType = $value['mimeType'];
2020 2286
 						$buff = explode('.',$value['name']);
2021 2287
 						$suffix = '';
2022
-						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2023
-						if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
2288
+						if (is_array($buff))
2289
+						{
2290
+							$suffix = array_pop($buff);
2291
+						}
2292
+						// take the last extension to check with ext2mime
2293
+						if (!empty($suffix))
2294
+						{
2295
+							$sfxMimeType = mime_magic::ext2mime($suffix);
2296
+						}
2024 2297
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2025 2298
 						{
2026 2299
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2190,9 +2463,12 @@  discard block
 block discarded – undo
2190 2463
 	function quotaDisplay($_usage, $_limit)
2191 2464
 	{
2192 2465
 
2193
-		if($_limit == 0) {
2466
+		if($_limit == 0)
2467
+		{
2194 2468
 			$quotaPercent=100;
2195
-		} else {
2469
+		}
2470
+		else
2471
+		{
2196 2472
 			$quotaPercent=round(($_usage*100)/$_limit);
2197 2473
 		}
2198 2474
 
@@ -2200,22 +2476,33 @@  discard block
 block discarded – undo
2200 2476
 		$quotaUsage=mail_bo::show_readable_size($_usage*1024);
2201 2477
 
2202 2478
 
2203
-		if($quotaPercent > 90 && $_limit>0) {
2479
+		if($quotaPercent > 90 && $_limit>0)
2480
+		{
2204 2481
 			$quotaBG='mail-index_QuotaRed';
2205
-		} elseif($quotaPercent > 80 && $_limit>0) {
2482
+		}
2483
+		elseif($quotaPercent > 80 && $_limit>0)
2484
+		{
2206 2485
 			$quotaBG='mail-index_QuotaYellow';
2207
-		} else {
2486
+		}
2487
+		else
2488
+		{
2208 2489
 			$quotaBG='mail-index_QuotaGreen';
2209 2490
 		}
2210 2491
 
2211
-		if($_limit > 0) {
2492
+		if($_limit > 0)
2493
+		{
2212 2494
 			$quotaText = $quotaUsage .'/'.$quotaLimit;
2213
-		} else {
2495
+		}
2496
+		else
2497
+		{
2214 2498
 			$quotaText = $quotaUsage;
2215 2499
 		}
2216 2500
 
2217
-		if($quotaPercent > 50) {
2218
-		} else {
2501
+		if($quotaPercent > 50)
2502
+		{
2503
+		}
2504
+		else
2505
+		{
2219 2506
 		}
2220 2507
 		$quota['class'] = $quotaBG;
2221 2508
 		$quota['text'] = lang('Quota: %1',$quotaText);
@@ -2233,7 +2520,10 @@  discard block
 block discarded – undo
2233 2520
 		$uid	= $_GET['uid'];
2234 2521
 		$cid	= base64_decode($_GET['cid']);
2235 2522
 		$partID = urldecode($_GET['partID']);
2236
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2523
+		if (!empty($_GET['mailbox']))
2524
+		{
2525
+			$mailbox  = base64_decode($_GET['mailbox']);
2526
+		}
2237 2527
 
2238 2528
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2239 2529
 		$this->mail_bo->reopen($mailbox);
@@ -2265,7 +2555,10 @@  discard block
 block discarded – undo
2265 2555
 
2266 2556
 	function getAttachment()
2267 2557
 	{
2268
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2558
+		if(isset($_GET['id']))
2559
+		{
2560
+			$rowID	= $_GET['id'];
2561
+		}
2269 2562
 
2270 2563
 		$hA = self::splitRowID($rowID);
2271 2564
 		$uid = $hA['msgUID'];
@@ -2298,10 +2591,20 @@  discard block
 block discarded – undo
2298 2591
 				$sfxMimeType = $attachment['type'];
2299 2592
 				$buff = explode('.',$attachment['filename']);
2300 2593
 				$suffix = '';
2301
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2302
-				if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
2594
+				if (is_array($buff))
2595
+				{
2596
+					$suffix = array_pop($buff);
2597
+				}
2598
+				// take the last extension to check with ext2mime
2599
+				if (!empty($suffix))
2600
+				{
2601
+					$sfxMimeType = mime_magic::ext2mime($suffix);
2602
+				}
2303 2603
 				$attachment['type'] = $sfxMimeType;
2304
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2604
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2605
+				{
2606
+					$attachment['type'] = strtoupper($sfxMimeType);
2607
+				}
2305 2608
 			}
2306 2609
 			//error_log(__METHOD__.print_r($attachment,true));
2307 2610
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2310,7 +2613,10 @@  discard block
 block discarded – undo
2310 2613
 				$calendar_ical = new calendar_ical();
2311 2614
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2312 2615
 				//error_log(__METHOD__.array2string($eventid));
2313
-				if (!$eventid) $eventid = -1;
2616
+				if (!$eventid)
2617
+				{
2618
+					$eventid = -1;
2619
+				}
2314 2620
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2315 2621
 				//error_log(__METHOD__.$event);
2316 2622
 				if ((int)$event > 0)
@@ -2336,7 +2642,10 @@  discard block
 block discarded – undo
2336 2642
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2337 2643
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2338 2644
 				}
2339
-				if (!$contact) $contact = null;
2645
+				if (!$contact)
2646
+				{
2647
+					$contact = null;
2648
+				}
2340 2649
 				// 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))
2341 2650
 				if ($contact || count($vcard)>2)
2342 2651
 				{
@@ -2370,9 +2679,18 @@  discard block
 block discarded – undo
2370 2679
 	function saveMessage()
2371 2680
 	{
2372 2681
 		$display = false;
2373
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2374
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2375
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2682
+		if(isset($_GET['id']))
2683
+		{
2684
+			$rowID	= $_GET['id'];
2685
+		}
2686
+		if(isset($_GET['part']))
2687
+		{
2688
+			$partID = $_GET['part'];
2689
+		}
2690
+		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager'))
2691
+		{
2692
+			$display	= $_GET['location'];
2693
+		}
2376 2694
 
2377 2695
 		$hA = self::splitRowID($rowID);
2378 2696
 		$uid = $hA['msgUID'];
@@ -2461,7 +2779,10 @@  discard block
 block discarded – undo
2461 2779
 			{
2462 2780
 				$succeeded = true;
2463 2781
 			}
2464
-			if ($fp) fclose($fp);
2782
+			if ($fp)
2783
+			{
2784
+				fclose($fp);
2785
+			}
2465 2786
 			if ($succeeded)
2466 2787
 			{
2467 2788
 				unset($headers['SUBJECT']);//already in filename
@@ -2511,7 +2832,8 @@  discard block
 block discarded – undo
2511 2832
 		 *
2512 2833
 		 * @return array an array of parameters
2513 2834
 		 */
2514
-		$getParams = function ($id) {
2835
+		$getParams = function ($id)
2836
+		{
2515 2837
 			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2516 2838
 			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2517 2839
 			$hA = mail_ui::splitRowID($lId);
@@ -2547,7 +2869,10 @@  discard block
 block discarded – undo
2547 2869
 		{
2548 2870
 			$params = $getParams($id);
2549 2871
 			// when downloading a single file, name is not set
2550
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
2872
+			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload)
2873
+			{
2874
+				$params['name'] = $_GET['name'];
2875
+			}
2551 2876
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2552 2877
 			{
2553 2878
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2560,7 +2885,10 @@  discard block
 block discarded – undo
2560 2885
 				// Try to find the right content for file id
2561 2886
 				foreach ($attachments as $key => $val)
2562 2887
 				{
2563
-					if ($key == $params['is_winmail']) $attachment = $val;
2888
+					if ($key == $params['is_winmail'])
2889
+					{
2890
+						$attachment = $val;
2891
+					}
2564 2892
 				}
2565 2893
 			}
2566 2894
 			else
@@ -2607,7 +2935,10 @@  discard block
 block discarded – undo
2607 2935
 	{
2608 2936
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2609 2937
 		// First, get all attachment IDs
2610
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
2938
+		if(isset($_GET['id']))
2939
+		{
2940
+			$message_id	= $_GET['id'];
2941
+		}
2611 2942
 		//error_log(__METHOD__.__LINE__.$message_id);
2612 2943
 		$rememberServerID = $this->mail_bo->profileID;
2613 2944
 		if(!is_numeric($message_id))
@@ -2634,7 +2965,10 @@  discard block
 block discarded – undo
2634 2965
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2635 2966
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2636 2967
 		$temp_path = $homedir/*egw_vfs::get_home_dir()*/ . "/.mail_$message_id";
2637
-		if(egw_vfs::is_dir($temp_path)) egw_vfs::remove ($temp_path);
2968
+		if(egw_vfs::is_dir($temp_path))
2969
+		{
2970
+			egw_vfs::remove ($temp_path);
2971
+		}
2638 2972
 
2639 2973
 		// Add subject to path, so it gets used as the file name
2640 2974
 		$path = $temp_path . '/' . ($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
@@ -2658,7 +2992,10 @@  discard block
 block discarded – undo
2658 2992
 				foreach ($tnefAttachments as $key => $val)
2659 2993
 				{
2660 2994
 					error_log(__METHOD__.' winmail = '.$key);
2661
-					if ($key == $file['is_winmail']) $attachment = $val;
2995
+					if ($key == $file['is_winmail'])
2996
+					{
2997
+						$attachment = $val;
2998
+					}
2662 2999
 				}
2663 3000
 			}
2664 3001
 			else
@@ -2666,15 +3003,24 @@  discard block
 block discarded – undo
2666 3003
 				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2667 3004
 			}
2668 3005
 			$success=true;
2669
-			if (empty($file['filename'])) $file['filename'] = $file['name'];
3006
+			if (empty($file['filename']))
3007
+			{
3008
+				$file['filename'] = $file['name'];
3009
+			}
2670 3010
 			if (!($fp = egw_vfs::fopen($path.$file['filename'],'wb')) ||
2671 3011
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
2672 3012
 			{
2673 3013
 				$success=false;
2674 3014
 				egw_framework::message("Unable to zip {$file['filename']}",'error');
2675 3015
 			}
2676
-			if ($success) $file_list[] = $path.$file['filename'];
2677
-			if ($fp) fclose($fp);
3016
+			if ($success)
3017
+			{
3018
+				$file_list[] = $path.$file['filename'];
3019
+			}
3020
+			if ($fp)
3021
+			{
3022
+				fclose($fp);
3023
+			}
2678 3024
 		}
2679 3025
 		$this->mail_bo->closeConnection();
2680 3026
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2701,7 +3047,10 @@  discard block
 block discarded – undo
2701 3047
 		$this->uid = $uid;
2702 3048
 		$this->partID = $partID;
2703 3049
 		$bufferHtmlOptions = $this->mail_bo->htmlOptions;
2704
-		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
3050
+		if (empty($htmlOptions))
3051
+		{
3052
+			$htmlOptions = $this->mail_bo->htmlOptions;
3053
+		}
2705 3054
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2706 3055
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2707 3056
 		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
@@ -2765,10 +3114,16 @@  discard block
 block discarded – undo
2765 3114
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2766 3115
 
2767 3116
 		$EndBody = '</td></tr></table></div>';
2768
-		if ($fullPageTags) $EndBody .= "</body></html>";
2769
-		if ($print)	{
3117
+		if ($fullPageTags)
3118
+		{
3119
+			$EndBody .= "</body></html>";
3120
+		}
3121
+		if ($print)
3122
+		{
2770 3123
 			print $BeginBody. $body .$EndBody;
2771
-		} else {
3124
+		}
3125
+		else
3126
+		{
2772 3127
 			return $BeginBody. $body .$EndBody;
2773 3128
 		}
2774 3129
 	}
@@ -2784,9 +3139,14 @@  discard block
 block discarded – undo
2784 3139
 		$body = '';
2785 3140
 
2786 3141
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2787
-		if (empty($bodyParts)) return "";
2788
-		foreach((array)$bodyParts as $singleBodyPart) {
2789
-			if (!isset($singleBodyPart['body'])) {
3142
+		if (empty($bodyParts))
3143
+		{
3144
+			return "";
3145
+		}
3146
+		foreach((array)$bodyParts as $singleBodyPart)
3147
+		{
3148
+			if (!isset($singleBodyPart['body']))
3149
+			{
2790 3150
 				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2791 3151
 				$body .= $singleBodyPart['body'];
2792 3152
 				continue;
@@ -2797,7 +3157,8 @@  discard block
 block discarded – undo
2797 3157
 				$body .= '';
2798 3158
 				continue;
2799 3159
 			}
2800
-			if(!empty($body)) {
3160
+			if(!empty($body))
3161
+			{
2801 3162
 				$body .= '<hr style="border:dotted 1px silver;">';
2802 3163
 			}
2803 3164
 			//error_log($singleBodyPart['body']);
@@ -2835,16 +3196,25 @@  discard block
 block discarded – undo
2835 3196
 				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
2836 3197
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2837 3198
 				// if empty and charset is utf8 try sanitizing the string in question
2838
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
3199
+				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8')
3200
+				{
3201
+					$newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
3202
+				}
2839 3203
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2840
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3204
+				if (empty($newBody))
3205
+				{
3206
+					$newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3207
+				}
2841 3208
 
2842 3209
 				// search http[s] links and make them as links available again
2843 3210
 				// to understand what's going on here, have a look at
2844 3211
 				// http://www.php.net/manual/en/function.preg-replace.php
2845 3212
 
2846 3213
 				// create links for websites
2847
-				if ($modifyURI) $newBody = html::activate_links($newBody);
3214
+				if ($modifyURI)
3215
+				{
3216
+					$newBody = html::activate_links($newBody);
3217
+				}
2848 3218
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2849 3219
 				// redirect links for websites if you use no cookies
2850 3220
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -2911,7 +3281,10 @@  discard block
 block discarded – undo
2911 3281
 					// as we switched off HTMLaweds tidy functionality
2912 3282
 					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
2913 3283
 					$newBody = $htmLawed->egw_htmLawed($newBody,mail_bo::$htmLawed_config);
2914
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3284
+					if ($hasOther && $preserveHTML)
3285
+					{
3286
+						$newBody = $matches[1]. $newBody. $matches[3];
3287
+					}
2915 3288
 					$alreadyHtmlLawed=true;
2916 3289
 				}
2917 3290
 				// do the cleanup, set for the use of purifier
@@ -3016,7 +3389,10 @@  discard block
 block discarded – undo
3016 3389
 		*/
3017 3390
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3018 3391
 		{
3019
-			if (!$_type)	return false;
3392
+			if (!$_type)
3393
+			{
3394
+				return false;
3395
+			}
3020 3396
 			$CID = '';
3021 3397
 			// Build up matches according to selected type
3022 3398
 			switch ($_type)
@@ -3059,9 +3435,12 @@  discard block
 block discarded – undo
3059 3435
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
3060 3436
 
3061 3437
 							// only use data uri for "smaller" images, as otherwise the first display of the mail takes to long
3062
-							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)	// msie=8 allows max 32k data uris
3438
+							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)
3439
+							{
3440
+								// msie=8 allows max 32k data uris
3063 3441
 							{
3064 3442
 								$bo->fetchPartContents($_uid, $attachment);
3443
+							}
3065 3444
 								$cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents());
3066 3445
 							}
3067 3446
 							else
@@ -3133,7 +3512,10 @@  discard block
 block discarded – undo
3133 3512
 			}
3134 3513
 			$destination = $content['FOLDER'][0];
3135 3514
 
3136
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3515
+			if (stripos($destination,self::$delimiter)!==false)
3516
+			{
3517
+				list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3518
+			}
3137 3519
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3138 3520
 			{
3139 3521
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3158,14 +3540,26 @@  discard block
 block discarded – undo
3158 3540
 			if (!$importFailed)
3159 3541
 			{
3160 3542
 				list($width, $height) = explode('x', egw_link::get_registry('mail', 'add_popup'));
3161
-				if ($width > 0 && $height > 0) egw_json_response::get()->call('resizeTo', $width, $height);
3543
+				if ($width > 0 && $height > 0)
3544
+				{
3545
+					egw_json_response::get()->call('resizeTo', $width, $height);
3546
+				}
3162 3547
 				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3163 3548
 				return;
3164 3549
 			}
3165 3550
 		}
3166
-		if (!is_array($content)) $content = array();
3167
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3168
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3551
+		if (!is_array($content))
3552
+		{
3553
+			$content = array();
3554
+		}
3555
+		if (empty($content['FOLDER']))
3556
+		{
3557
+			$content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3558
+		}
3559
+		if (!empty($content['FOLDER']))
3560
+		{
3561
+			$sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3562
+		}
3169 3563
 
3170 3564
 		$etpl = new etemplate_new('mail.importMessage');
3171 3565
 		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
@@ -3185,7 +3579,10 @@  discard block
 block discarded – undo
3185 3579
 	{
3186 3580
 		$importfailed = false;
3187 3581
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
3188
-		if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name'];
3582
+		if (empty($_formData['file']))
3583
+		{
3584
+			$_formData['file'] = $_formData['tmp_name'];
3585
+		}
3189 3586
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3190 3587
 		try
3191 3588
 		{
@@ -3216,10 +3613,14 @@  discard block
 block discarded – undo
3216 3613
 				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3217 3614
 			}
3218 3615
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3219
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3616
+			if($_folder=='INBOX'.$delimiter)
3617
+			{
3618
+				$_folder='INBOX';
3619
+			}
3220 3620
 			if ($importfailed === false)
3221 3621
 			{
3222
-				if ($this->mail_bo->folderExists($_folder,true)) {
3622
+				if ($this->mail_bo->folderExists($_folder,true))
3623
+				{
3223 3624
 					try
3224 3625
 					{
3225 3626
 						$messageUid = $this->mail_bo->appendMessage($_folder,
@@ -3280,7 +3681,10 @@  discard block
 block discarded – undo
3280 3681
 	 */
3281 3682
 	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3282 3683
 	{
3283
-		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3684
+		if (empty($formData))
3685
+		{
3686
+			if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3687
+		}
3284 3688
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
3285 3689
 		$draftFolder = $this->mail_bo->getDraftFolder(false);
3286 3690
 		$importID = mail_bo::getRandomString();
@@ -3294,15 +3698,26 @@  discard block
 block discarded – undo
3294 3698
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3295 3699
 		{
3296 3700
 			$buff = explode('/',$formData['file']);
3297
-			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3701
+			if (is_array($buff))
3702
+			{
3703
+				$formData['name'] = array_pop($buff);
3704
+			}
3705
+			// take the last part as name
3298 3706
 		}
3299 3707
 		// type should be set to meet the requirements of checkFileBasics
3300 3708
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3301 3709
 		{
3302 3710
 			$buff = explode('.',$formData['file']);
3303 3711
 			$suffix = '';
3304
-			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3305
-			if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix);
3712
+			if (is_array($buff))
3713
+			{
3714
+				$suffix = array_pop($buff);
3715
+			}
3716
+			// take the last extension to check with ext2mime
3717
+			if (!empty($suffix))
3718
+			{
3719
+				$formData['type'] = mime_magic::ext2mime($suffix);
3720
+			}
3306 3721
 		}
3307 3722
 		// size should be set to meet the requirements of checkFileBasics
3308 3723
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3345,17 +3760,35 @@  discard block
 block discarded – undo
3345 3760
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3346 3761
 	{
3347 3762
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3348
-		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3349
-		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3350
-		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3351
-		if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3352
-		if (empty($_messageID)) return "";
3763
+		if (!$_messageID && !empty($_GET['_messageID']))
3764
+		{
3765
+			$_messageID = $_GET['_messageID'];
3766
+		}
3767
+		if (!$_partID && !empty($_GET['_partID']))
3768
+		{
3769
+			$_partID = $_GET['_partID'];
3770
+		}
3771
+		if (!$_htmloptions && !empty($_GET['_htmloptions']))
3772
+		{
3773
+			$_htmloptions = $_GET['_htmloptions'];
3774
+		}
3775
+		if(mail_bo::$debug)
3776
+		{
3777
+			error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3778
+		}
3779
+		if (empty($_messageID))
3780
+		{
3781
+			return "";
3782
+		}
3353 3783
 		$uidA = self::splitRowID($_messageID);
3354 3784
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
3355 3785
 		$messageID = $uidA['msgUID'];
3356 3786
 		$icServerID = $uidA['profileID'];
3357 3787
 		//something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled
3358
-		if (empty($messageID)) return "";
3788
+		if (empty($messageID))
3789
+		{
3790
+			return "";
3791
+		}
3359 3792
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
3360 3793
 		{
3361 3794
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3388,11 +3821,18 @@  discard block
 block discarded – undo
3388 3821
 				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3389 3822
 				if (is_numeric($profileID))
3390 3823
 				{
3391
-					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
3824
+					if ($profileID != $this->mail_bo->profileID)
3825
+					{
3826
+						continue;
3827
+					}
3828
+					// only current connection
3392 3829
 					if ($folderName)
3393 3830
 					{
3394 3831
 						$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3395
-						if (in_array($fS['shortDisplayName'],mail_bo::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3832
+						if (in_array($fS['shortDisplayName'],mail_bo::$autoFolders))
3833
+						{
3834
+							$fS['shortDisplayName']=lang($fS['shortDisplayName']);
3835
+						}
3396 3836
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3397 3837
 						if ($fS['unseen'])
3398 3838
 						{
@@ -3433,7 +3873,11 @@  discard block
 block discarded – undo
3433 3873
 			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3434 3874
 			if (is_numeric($profileID))
3435 3875
 			{
3436
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
3876
+				if ($profileID != $this->mail_bo->profileID)
3877
+				{
3878
+					return;
3879
+				}
3880
+				// only current connection
3437 3881
 				$del = $this->mail_bo->getHierarchyDelimiter(false);
3438 3882
 				//$del = $prefix = '';
3439 3883
 				//$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -3473,7 +3917,10 @@  discard block
 block discarded – undo
3473 3917
 				$nA = explode($del,$_newName);
3474 3918
 
3475 3919
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3476
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3920
+				if (!!empty($parentFolderName))
3921
+				{
3922
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3923
+				}
3477 3924
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3478 3925
 
3479 3926
 				$this->mail_bo->reopen('INBOX');
@@ -3494,9 +3941,15 @@  discard block
 block discarded – undo
3494 3941
 							$errorMessage .= $error;
3495 3942
 						}
3496 3943
 					}
3497
-					if ($c==count($nA)) $created=true;
3944
+					if ($c==count($nA))
3945
+					{
3946
+						$created=true;
3947
+					}
3948
+				}
3949
+				if (!empty($parentName))
3950
+				{
3951
+					$this->mail_bo->reopen($parentName);
3498 3952
 				}
3499
-				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3500 3953
 			}
3501 3954
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3502 3955
 			if ($created===true)
@@ -3532,7 +3985,10 @@  discard block
 block discarded – undo
3532 3985
 	 */
3533 3986
 	function ajax_renameFolder($_folderName, $_newName)
3534 3987
 	{
3535
-		if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
3988
+		if (mail_bo::$debug)
3989
+		{
3990
+			error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
3991
+		}
3536 3992
 		if ($_folderName)
3537 3993
 		{
3538 3994
 			translation::add_app('mail');
@@ -3544,7 +4000,11 @@  discard block
 block discarded – undo
3544 4000
 			$hasChildren = false;
3545 4001
 			if (is_numeric($profileID))
3546 4002
 			{
3547
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4003
+				if ($profileID != $this->mail_bo->profileID)
4004
+				{
4005
+					return;
4006
+				}
4007
+				// only current connection
3548 4008
 				$pA = explode($del,$folderName);
3549 4009
 				array_pop($pA);
3550 4010
 				$parentFolder = implode($del,$pA);
@@ -3685,8 +4145,15 @@  discard block
 block discarded – undo
3685 4145
 		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3686 4146
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3687 4147
 		// that we get what we request
3688
-		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3689
-		if ($profileID != $this->mail_bo->profileID) return; // only current connection
4148
+		if ($_subscribedOnly != $oldPrefForSubscribedOnly)
4149
+		{
4150
+			$this->mail_bo->resetFolderObjectCache($profileID);
4151
+		}
4152
+		if ($profileID != $this->mail_bo->profileID)
4153
+		{
4154
+			return;
4155
+		}
4156
+		// only current connection
3690 4157
 		if (!empty($folderName))
3691 4158
 		{
3692 4159
 			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
@@ -3761,7 +4228,10 @@  discard block
 block discarded – undo
3761 4228
 	 */
3762 4229
 	function ajax_MoveFolder($_folderName, $_target)
3763 4230
 	{
3764
-		if (mail_bo::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4231
+		if (mail_bo::$debug)
4232
+		{
4233
+			error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4234
+		}
3765 4235
 		if ($_folderName)
3766 4236
 		{
3767 4237
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
@@ -3772,7 +4242,11 @@  discard block
 block discarded – undo
3772 4242
 			$hasChildren = false;
3773 4243
 			if (is_numeric($profileID))
3774 4244
 			{
3775
-				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
4245
+				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID)
4246
+				{
4247
+					return;
4248
+				}
4249
+				// only current connection
3776 4250
 				$pA = explode($del,$folderName);
3777 4251
 				$namePart = array_pop($pA);
3778 4252
 				$_newName = $namePart;
@@ -3783,10 +4257,13 @@  discard block
 block discarded – undo
3783 4257
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3784 4258
 					(($oldParentFolder != $parentFolder &&
3785 4259
 					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3786
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4260
+					strpos($parentFolder,$folderName)===false))))
4261
+				{
4262
+					// indicates that we move the older up the tree within its own branch
3787 4263
 				{
3788 4264
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3789 4265
 					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4266
+				}
3790 4267
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3791 4268
 					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3792 4269
 					{
@@ -3869,8 +4346,14 @@  discard block
 block discarded – undo
3869 4346
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
3870 4347
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
3871 4348
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
3872
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
3873
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4349
+				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false)
4350
+				{
4351
+					unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4352
+				}
4353
+				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false)
4354
+				{
4355
+					unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4356
+				}
3874 4357
 
3875 4358
 				// Send full info back in the response
3876 4359
 				foreach($refreshData as $folder => &$name)
@@ -3906,7 +4389,11 @@  discard block
 block discarded – undo
3906 4389
 			$hasChildren = false;
3907 4390
 			if (is_numeric($profileID))
3908 4391
 			{
3909
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4392
+				if ($profileID != $this->mail_bo->profileID)
4393
+				{
4394
+					return;
4395
+				}
4396
+				// only current connection
3910 4397
 				$pA = explode($del,$folderName);
3911 4398
 				array_pop($pA);
3912 4399
 				if (strtoupper($folderName)!= 'INBOX')
@@ -3932,7 +4419,9 @@  discard block
 block discarded – undo
3932 4419
 						}
3933 4420
 						krsort($ftD,SORT_NUMERIC);//sort per level
3934 4421
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
3935
-						foreach($ftD as $k => $lc)//collection per level
4422
+						foreach($ftD as $k => $lc)
4423
+						{
4424
+							//collection per level
3936 4425
 						{
3937 4426
 							foreach($lc as $i => $f)//folders contained in that level
3938 4427
 							{
@@ -3940,8 +4429,12 @@  discard block
 block discarded – undo
3940 4429
 								{
3941 4430
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
3942 4431
 									$this->mail_bo->deleteFolder($f);
4432
+						}
3943 4433
 									$success = true;
3944
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4434
+									if ($f==$folderName)
4435
+									{
4436
+										$oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4437
+									}
3945 4438
 								}
3946 4439
 								catch (Exception $e)
3947 4440
 								{
@@ -3971,7 +4464,10 @@  discard block
 block discarded – undo
3971 4464
 					$msg = lang("refused to delete folder INBOX");
3972 4465
 				}
3973 4466
 			}
3974
-			if ($_return) return $success;
4467
+			if ($_return)
4468
+			{
4469
+				return $success;
4470
+			}
3975 4471
 			$response = egw_json_response::get();
3976 4472
 			if ($success)
3977 4473
 			{
@@ -4056,19 +4552,29 @@  discard block
 block discarded – undo
4056 4552
 			// Create mail app object
4057 4553
 			$mail = new mail_ui();
4058 4554
 
4059
-			if (empty($icServerID)) $icServerID = $mail->mail_bo->profileID;
4060
-			if ($icServerID != $mail->mail_bo->profileID) return;
4555
+			if (empty($icServerID))
4556
+			{
4557
+				$icServerID = $mail->mail_bo->profileID;
4558
+			}
4559
+			if ($icServerID != $mail->mail_bo->profileID)
4560
+			{
4561
+				return;
4562
+			}
4061 4563
 
4062 4564
 			$vacation = $mail->gatherVacation($cachedVacations);
4063 4565
 		}
4064 4566
 
4065
-		if($vacation) {
4567
+		if($vacation)
4568
+		{
4066 4569
 			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4067 4570
 			{
4068 4571
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4069 4572
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4070 4573
 				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4071
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4574
+				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())
4575
+				{
4576
+					$refreshData = '';
4577
+				}
4072 4578
 			}
4073 4579
 		}
4074 4580
 		if ($vacation==false)
@@ -4090,11 +4596,17 @@  discard block
 block discarded – undo
4090 4596
 	function ajax_refreshFilters($icServerID=null)
4091 4597
 	{
4092 4598
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4093
-		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4599
+		if (empty($icServerID))
4600
+		{
4601
+			$icServerID = $this->mail_bo->profileID;
4602
+		}
4094 4603
 		if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4095 4604
 		{
4096 4605
 			emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4097
-			if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
4606
+			if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4607
+			{
4608
+				emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
4609
+			}
4098 4610
 		}
4099 4611
 		if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])
4100 4612
 		{
@@ -4115,7 +4627,10 @@  discard block
 block discarded – undo
4115 4627
 			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4116 4628
 			foreach($keywords as &$k)
4117 4629
 			{
4118
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4630
+				if (array_key_exists($k,$this->statusTypes))
4631
+				{
4632
+					unset($this->statusTypes[$k]);
4633
+				}
4119 4634
 			}
4120 4635
 		}
4121 4636
 
@@ -4134,7 +4649,10 @@  discard block
 block discarded – undo
4134 4649
 	{
4135 4650
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4136 4651
 		translation::add_app('mail');
4137
-		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
4652
+		if (is_null($icServerID))
4653
+		{
4654
+			$icServerID = $this->mail_bo->profileID;
4655
+		}
4138 4656
 		$rememberServerID = $this->mail_bo->profileID;
4139 4657
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
4140 4658
 		{
@@ -4144,18 +4662,22 @@  discard block
 block discarded – undo
4144 4662
 		try
4145 4663
 		{
4146 4664
 			$quota = $this->mail_bo->getQuotaRoot();
4147
-		} catch (Exception $e) {
4665
+		}
4666
+		catch (Exception $e) {
4148 4667
 			$quota['limit'] = 'NOT SET';
4149 4668
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4150 4669
 		}
4151 4670
 
4152
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4671
+		if($quota !== false && $quota['limit'] != 'NOT SET')
4672
+		{
4153 4673
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4154 4674
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4155 4675
 			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4156 4676
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4157 4677
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4158
-		} else {
4678
+		}
4679
+		else
4680
+		{
4159 4681
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
4160 4682
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
4161 4683
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -4188,7 +4710,8 @@  discard block
 block discarded – undo
4188 4710
 			$this->changeProfile($icServerID);
4189 4711
 		}
4190 4712
 		$junkFolder = $this->mail_bo->getJunkFolder();
4191
-		if(!empty($junkFolder)) {
4713
+		if(!empty($junkFolder))
4714
+		{
4192 4715
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4193 4716
 			{
4194 4717
 				// Lock the tree if the active folder is junk folder
@@ -4238,7 +4761,8 @@  discard block
 block discarded – undo
4238 4761
 			$this->changeProfile($icServerID);
4239 4762
 		}
4240 4763
 		$trashFolder = $this->mail_bo->getTrashFolder();
4241
-		if(!empty($trashFolder)) {
4764
+		if(!empty($trashFolder))
4765
+		{
4242 4766
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4243 4767
 			{
4244 4768
 				// Lock the tree if the active folder is Trash folder
@@ -4284,7 +4808,10 @@  discard block
 block discarded – undo
4284 4808
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4285 4809
 		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4286 4810
 
4287
-		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4811
+		if (empty($folderName))
4812
+		{
4813
+			$folderName = $this->mail_bo->sessionData['mailbox'];
4814
+		}
4288 4815
 		if ($this->mail_bo->folderExists($folderName))
4289 4816
 		{
4290 4817
 			$rememberServerID = $this->mail_bo->profileID;
@@ -4293,7 +4820,8 @@  discard block
 block discarded – undo
4293 4820
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4294 4821
 				$this->changeProfile($icServerID);
4295 4822
 			}
4296
-			if(!empty($_folderName)) {
4823
+			if(!empty($_folderName))
4824
+			{
4297 4825
 				$this->mail_bo->compressFolder($folderName);
4298 4826
 			}
4299 4827
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4315,7 +4843,10 @@  discard block
 block discarded – undo
4315 4843
 	 */
4316 4844
 	function ajax_sendMDN($_messageList)
4317 4845
 	{
4318
-		if(mail_bo::$debug) error_log(__METHOD__."->".array2string($_messageList));
4846
+		if(mail_bo::$debug)
4847
+		{
4848
+			error_log(__METHOD__."->".array2string($_messageList));
4849
+		}
4319 4850
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4320 4851
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4321 4852
 		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
@@ -4332,7 +4863,10 @@  discard block
 block discarded – undo
4332 4863
 	 */
4333 4864
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4334 4865
 	{
4335
-		if(mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4866
+		if(mail_bo::$debug)
4867
+		{
4868
+			error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4869
+		}
4336 4870
 		translation::add_app('mail');
4337 4871
 		$alreadyFlagged=false;
4338 4872
 		$flag2check='';
@@ -4353,7 +4887,10 @@  discard block
 block discarded – undo
4353 4887
 						if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4354 4888
 						{
4355 4889
 							emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4356
-							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
4890
+							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4891
+							{
4892
+								emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
4893
+							}
4357 4894
 						}
4358 4895
 						$filter = $filter2toggle = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => 'any');
4359 4896
 					}
@@ -4399,13 +4936,19 @@  discard block
 block discarded – undo
4399 4936
 						if (count($messageListForToggle)>0)
4400 4937
 						{
4401 4938
 							$flag2set = (strtolower($_flag));
4402
-							if(mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4939
+							if(mail_bo::$debug)
4940
+							{
4941
+								error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4942
+							}
4403 4943
 							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4404 4944
 						}
4405 4945
 						if (count($messageList)>0)
4406 4946
 						{
4407 4947
 							$flag2set = 'un'.$_flag;
4408
-							if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4948
+							if(mail_bo::$debug)
4949
+							{
4950
+								error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4951
+							}
4409 4952
 							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4410 4953
 						}
4411 4954
 						$alreadyFlagged=true;
@@ -4421,7 +4964,10 @@  discard block
 block discarded – undo
4421 4964
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4422 4965
 							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4423 4966
 						}
4424
-						if(mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4967
+						if(mail_bo::$debug)
4968
+						{
4969
+							error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4970
+						}
4425 4971
 						$_sR = $this->mail_bo->getSortedList(
4426 4972
 							$folder,
4427 4973
 							$sort=0,
@@ -4436,7 +4982,10 @@  discard block
 block discarded – undo
4436 4982
 					}
4437 4983
 					else
4438 4984
 					{
4439
-						if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4985
+						if(mail_bo::$debug)
4986
+						{
4987
+							error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4988
+						}
4440 4989
 						$alreadyFlagged=true;
4441 4990
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4442 4991
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -4456,13 +5005,19 @@  discard block
 block discarded – undo
4456 5005
 					$hA = self::splitRowID($rowID);
4457 5006
 					$messageList[] = $hA['msgUID'];
4458 5007
 				}
4459
-				if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5008
+				if(mail_bo::$debug)
5009
+				{
5010
+					error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5011
+				}
4460 5012
 				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4461 5013
 			}
4462 5014
 		}
4463 5015
 		else
4464 5016
 		{
4465
-			if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
5017
+			if(mail_bo::$debug)
5018
+			{
5019
+				error_log(__METHOD__."-> No messages selected.");
5020
+			}
4466 5021
 		}
4467 5022
 
4468 5023
 		if ($_sendJsonResponse)
@@ -4499,7 +5054,10 @@  discard block
 block discarded – undo
4499 5054
 	 */
4500 5055
 	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4501 5056
 	{
4502
-		if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5057
+		if(mail_bo::$debug)
5058
+		{
5059
+			error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5060
+		}
4503 5061
 		$error = null;
4504 5062
 		$filtered =  false;
4505 5063
 		if ($_messageList=='all' || !empty($_messageList['msg']))
@@ -4518,7 +5076,10 @@  discard block
 block discarded – undo
4518 5076
 						if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4519 5077
 						{
4520 5078
 							emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4521
-							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
5079
+							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
5080
+							{
5081
+								emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
5082
+							}
4522 5083
 						}
4523 5084
 						$filtered =  true;
4524 5085
 						$filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => (!empty($query['filter'])?$query['filter']:'any'));
@@ -4587,7 +5148,10 @@  discard block
 block discarded – undo
4587 5148
 		}
4588 5149
 		else
4589 5150
 		{
4590
-			if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
5151
+			if(mail_bo::$debug)
5152
+			{
5153
+				error_log(__METHOD__."-> No messages selected.");
5154
+			}
4591 5155
 		}
4592 5156
 	}
4593 5157
 
@@ -4602,11 +5166,17 @@  discard block
 block discarded – undo
4602 5166
 	 */
4603 5167
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy')
4604 5168
 	{
4605
-		if(mail_bo::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove);
5169
+		if(mail_bo::$debug)
5170
+		{
5171
+			error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove);
5172
+		}
4606 5173
 		translation::add_app('mail');
4607 5174
 		$_folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4608 5175
 		// only copy or move are supported as method
4609
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5176
+		if (!($_copyOrMove=='copy' || $_copyOrMove=='move'))
5177
+		{
5178
+			$_copyOrMove='copy';
5179
+		}
4610 5180
 		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2);
4611 5181
 		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
4612 5182
 		$changeFolderActions = false;
@@ -4617,8 +5187,13 @@  discard block
 block discarded – undo
4617 5187
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4618 5188
 				foreach( $keys as &$f)
4619 5189
 				{
4620
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4621
-					else break;
5190
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9)
5191
+					{
5192
+						unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5193
+					}
5194
+					else {
5195
+						break;
5196
+					}
4622 5197
 				}
4623 5198
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4624 5199
 			}
@@ -4644,7 +5219,10 @@  discard block
 block discarded – undo
4644 5219
 						if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4645 5220
 						{
4646 5221
 							emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4647
-							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
5222
+							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
5223
+							{
5224
+								emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
5225
+							}
4648 5226
 						}
4649 5227
 						$filtered = true;
4650 5228
 						$filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => (!empty($query['filter'])?$query['filter']:'any'));
@@ -4702,7 +5280,10 @@  discard block
 block discarded – undo
4702 5280
 						$hA = self::splitRowID($rowID);
4703 5281
 
4704 5282
 						// If folder changes, stop and move what we've got
4705
-						if($hA['folder'] != $folder) break;
5283
+						if($hA['folder'] != $folder)
5284
+						{
5285
+							break;
5286
+						}
4706 5287
 
4707 5288
 						array_shift($_messageList['msg']);
4708 5289
 						$messageList[] = $hA['msgUID'];
@@ -4757,7 +5338,10 @@  discard block
 block discarded – undo
4757 5338
 		}
4758 5339
 		else
4759 5340
 		{
4760
-			if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
5341
+			if(mail_bo::$debug)
5342
+			{
5343
+				error_log(__METHOD__."-> No messages selected.");
5344
+			}
4761 5345
 		}
4762 5346
 	}
4763 5347
 
Please login to merge, or discard this patch.