Completed
Push — 14.2 ( ebfddb...2a0133 )
by Hadi
130:14 queued 111:10
created
mail/inc/class.mail_ui.inc.php 2 patches
Spacing   +773 added lines, -780 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @var array
33 33
 	 */
34
-	var $public_functions = array
35
-	(
34
+	var $public_functions = array(
36 35
 		'index' => True,
37 36
 		'displayHeader'	=> True,
38 37
 		'displayMessage'	=> True,
@@ -83,12 +82,12 @@  discard block
 block discarded – undo
83 82
 	 * @var array
84 83
 	 */
85 84
 	var $searchTypes = array(
86
-		'quick'		=> 'quicksearch',	// lang('quicksearch')
87
-		'subject'	=> 'subject',		// lang('subject')
88
-		'body'		=> 'message body',	// lang('message body')
89
-		'from'		=> 'from',			// lang('from')
90
-		'to'		=> 'to',			// lang('to')
91
-		'cc'		=> 'cc',			// lang('cc')
85
+		'quick'		=> 'quicksearch', // lang('quicksearch')
86
+		'subject'	=> 'subject', // lang('subject')
87
+		'body'		=> 'message body', // lang('message body')
88
+		'from'		=> 'from', // lang('from')
89
+		'to'		=> 'to', // lang('to')
90
+		'cc'		=> 'cc', // lang('cc')
92 91
 		'text'		=> 'whole message'	// lang('whole message')
93 92
 	);
94 93
 
@@ -98,12 +97,12 @@  discard block
 block discarded – undo
98 97
 	 * @var array
99 98
 	 */
100 99
 	var $statusTypes = array(
101
-		'any'		=> 'any status',// lang('any status')
102
-		'flagged'	=> 'flagged',	// lang('flagged')
103
-		'unseen'	=> 'unread',	// lang('unread')
104
-		'answered'	=> 'replied',	// lang('replied')
105
-		'seen'		=> 'read',		// lang('read')
106
-		'deleted'	=> 'deleted',	// lang('deleted')
100
+		'any'		=> 'any status', // lang('any status')
101
+		'flagged'	=> 'flagged', // lang('flagged')
102
+		'unseen'	=> 'unread', // lang('unread')
103
+		'answered'	=> 'replied', // lang('replied')
104
+		'seen'		=> 'read', // lang('read')
105
+		'deleted'	=> 'deleted', // lang('deleted')
107 106
 	);
108 107
 
109 108
 	/**
@@ -111,12 +110,12 @@  discard block
 block discarded – undo
111 110
 	 *
112 111
 	 * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server
113 112
 	 */
114
-	function __construct($run_constructor=true)
113
+	function __construct($run_constructor = true)
115 114
 	{
116 115
 		$this->mail_tree = new mail_tree($this);
117 116
 		if (!$run_constructor) return;
118 117
 
119
-		if (mail_bo::$debugTimes) $starttime = microtime (true);
118
+		if (mail_bo::$debugTimes) $starttime = microtime(true);
120 119
 		// no autohide of the sidebox, as we use it for folderlist now.
121 120
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
122 121
 
@@ -132,13 +131,13 @@  discard block
 block discarded – undo
132 131
 		}
133 132
 
134 133
 		try {
135
-			$this->mail_bo = mail_bo::getInstance(true,self::$icServerID, true, false, true);
134
+			$this->mail_bo = mail_bo::getInstance(true, self::$icServerID, true, false, true);
136 135
 			if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
137 136
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
138 137
 
139 138
 			// RegEx to minimize extra openConnection
140 139
 			$needle = '/^(?!mail)/';
141
-			if (!preg_match($needle,$_GET['menuaction']) && !egw_json_request::isJSONRequest())
140
+			if (!preg_match($needle, $_GET['menuaction']) && !egw_json_request::isJSONRequest())
142 141
 			{
143 142
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
144 143
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -148,9 +147,9 @@  discard block
 block discarded – undo
148 147
 		catch (Exception $e)
149 148
 		{
150 149
 			// redirect to mail wizard to handle it (redirect works for ajax too)
151
-			self::callWizard($e->getMessage(),true,'error');
150
+			self::callWizard($e->getMessage(), true, 'error');
152 151
 		}
153
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
152
+		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
154 153
 	}
155 154
 
156 155
 	/**
@@ -160,10 +159,10 @@  discard block
 block discarded – undo
160 159
 	 * @param boolean $exit If true, will call common::egw_exit() after opening the wizardpopup
161 160
 	 * @param string $msg_type = 'success' message type
162 161
 	 */
163
-	static function callWizard($message, $exit=true, $msg_type='success')
162
+	static function callWizard($message, $exit = true, $msg_type = 'success')
164 163
 	{
165 164
 		//error_log(__METHOD__."('$message', $exit) ".function_backtrace());
166
-		$linkData=(self::$icServerID ? array(
165
+		$linkData = (self::$icServerID ? array(
167 166
 				'menuaction' => 'mail.mail_wizard.edit',
168 167
 				'acc_id' => self::$icServerID,
169 168
 			) : array(
@@ -177,11 +176,11 @@  discard block
 block discarded – undo
177 176
 		{
178 177
 			$response = egw_json_response::get();
179 178
 			$windowName = "editMailAccount".self::$icServerID;
180
-			$response->call("egw.open_link", egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
179
+			$response->call("egw.open_link", egw::link('/index.php', $linkData), $windowName, "600x480", null, true);
181 180
 			egw_framework::message($message, 'error');
182 181
 			if ($_GET['menuaction'] == 'mail.mail_ui.index')
183 182
 			{
184
-				$response->call('framework.setSidebox','mail',array(),'md5');
183
+				$response->call('framework.setSidebox', 'mail', array(), 'md5');
185 184
 			}
186 185
 			if ($exit)
187 186
 			{
@@ -190,8 +189,8 @@  discard block
 block discarded – undo
190 189
 		}
191 190
 		else	// regular GET request eg. in idots template
192 191
 		{
193
-			egw_framework::popup(egw_framework::link('/index.php',$linkData));
194
-			$GLOBALS['egw']->framework->render($message,'',true);
192
+			egw_framework::popup(egw_framework::link('/index.php', $linkData));
193
+			$GLOBALS['egw']->framework->render($message, '', true);
195 194
 			if ($exit)
196 195
 			{
197 196
 				common::egw_exit();
@@ -207,9 +206,9 @@  discard block
 block discarded – undo
207 206
 	 *
208 207
 	 * @throws egw_exception
209 208
 	 */
210
-	function changeProfile($_icServerID,$unsetCache=false)
209
+	function changeProfile($_icServerID, $unsetCache = false)
211 210
 	{
212
-		if (mail_bo::$debugTimes) $starttime = microtime (true);
211
+		if (mail_bo::$debugTimes) $starttime = microtime(true);
213 212
 		if (self::$icServerID != $_icServerID)
214 213
 		{
215 214
 			self::$icServerID = $_icServerID;
@@ -217,35 +216,35 @@  discard block
 block discarded – undo
217 216
 		if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
218 217
 
219 218
 		if ($unsetCache) emailadmin_imapbase::unsetCachedObjects(self::$icServerID);
220
-		$this->mail_bo = mail_bo::getInstance(false,self::$icServerID,true, false, true);
219
+		$this->mail_bo = mail_bo::getInstance(false, self::$icServerID, true, false, true);
221 220
 		if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
222 221
 		// no icServer Object: something failed big time
223
-		if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
222
+		if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID)
224 223
 		{
225 224
 			self::$icServerID = $_icServerID;
226 225
 			throw new egw_exception('Profile change failed!');
227 226
 		}
228 227
 
229 228
 		// save session varchar
230
-		$oldicServerID =& egw_cache::getSession('mail','activeProfileID');
229
+		$oldicServerID = & egw_cache::getSession('mail', 'activeProfileID');
231 230
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
232 231
 		$oldicServerID = self::$icServerID;
233
-		if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
232
+		if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true))
234 233
 		{
235 234
 			throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID");
236 235
 		}
237 236
 
238
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
237
+		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
239 238
 	}
240 239
 
241 240
 	/**
242 241
 	 * Ajax function to request next branch of a tree branch
243 242
 	 */
244
-	static function ajax_tree_autoloading ($_id = null)
243
+	static function ajax_tree_autoloading($_id = null)
245 244
 	{
246 245
 		$mail_ui = new mail_ui();
247
-		$_id = $_id? $_id:$_GET['id'];
248
-		etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id,'',1,false));
246
+		$_id = $_id ? $_id : $_GET['id'];
247
+		etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id, '', 1, false));
249 248
 	}
250 249
 
251 250
 	/**
@@ -254,11 +253,11 @@  discard block
 block discarded – undo
254 253
 	 * @param array $content
255 254
 	 * @param type $msg
256 255
 	 */
257
-	function subscription(array $content=null ,$msg=null)
256
+	function subscription(array $content = null, $msg = null)
258 257
 	{
259 258
 		$stmpl = new etemplate_new('mail.subscribe');
260 259
 
261
-		if(is_array($content))
260
+		if (is_array($content))
262 261
 		{
263 262
 			$profileId = $content['profileId'];
264 263
 		}
@@ -268,14 +267,14 @@  discard block
 block discarded – undo
268 267
 		}
269 268
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
270 269
 		// triggered from client-side. Also, we keep this here as
271
-		$sel_options['foldertree'] =  $this->mail_tree->getTree(null,$profileId,1,true,false,true);
270
+		$sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true);
272 271
 
273 272
 		//Get all subscribed folders
274 273
 		// as getting all subscribed folders is very fast operation
275 274
 		// we can use it to get a comparison base for folders which
276 275
 		// got subscribed or unsubscribed by the user
277 276
 		try {
278
-			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
277
+			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true);
279 278
 		} catch (Exception $ex) {
280 279
 			egw_framework::message($ex->getMessage());
281 280
 		}
@@ -286,7 +285,7 @@  discard block
 block discarded – undo
286 285
 
287 286
 			foreach ($subscribed as $folder)
288 287
 			{
289
-				$folderName = $profileId . self::$delimiter . $folder['MAILBOX'];
288
+				$folderName = $profileId.self::$delimiter.$folder['MAILBOX'];
290 289
 				array_push($content['foldertree'], $folderName);
291 290
 			}
292 291
 		}
@@ -300,9 +299,9 @@  discard block
 block discarded – undo
300 299
 				{
301 300
 					// do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
302 301
 					$namespace_roots = array($profileId);
303
-					foreach($this->mail_bo->_getNameSpaces() as $namespace)
302
+					foreach ($this->mail_bo->_getNameSpaces() as $namespace)
304 303
 					{
305
-						$namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
304
+						$namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']);
306 305
 					}
307 306
 					$to_unsubscribe = $to_subscribe = array();
308 307
 					foreach ($content['foldertree'] as $path => $value)
@@ -310,7 +309,7 @@  discard block
 block discarded – undo
310 309
 						list(,$node) = explode($profileId.self::$delimiter, $path);
311 310
 						if ($node)
312 311
 						{
313
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
312
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node;
314 313
 							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
315 314
 							if ($value['value']) $cont[] = $path;
316 315
 						}
@@ -320,7 +319,7 @@  discard block
 block discarded – undo
320 319
 					// set foldertree options to basic node in order to avoid initial autoloading
321 320
 					// from client side, as no options would trigger that.
322 321
 					$sel_options['foldertree'] = array('id' => '0', 'item'=> array());
323
-					foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
322
+					foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
324 323
 					{
325 324
 						if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true))
326 325
 						{
@@ -356,18 +355,18 @@  discard block
 block discarded – undo
356 355
 						}
357 356
 					}
358 357
 					// update foldertree in main window
359
-					$parentFolder='INBOX';
358
+					$parentFolder = 'INBOX';
360 359
 					$refreshData = array(
361 360
 						$profileId => lang($parentFolder),
362 361
 					);
363 362
 					$response = egw_json_response::get();
364
-					foreach($refreshData as $folder => &$name)
363
+					foreach ($refreshData as $folder => &$name)
365 364
 					{
366
-						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
365
+						$name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true);
367 366
 					}
368 367
 					// give success/error message to opener and popup itself
369 368
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
370
-					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
369
+					$response->call('opener.app.mail.mail_reloadNode', $refreshData);
371 370
 
372 371
 					egw_framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
373 372
 					if ($button == 'apply')
@@ -387,7 +386,7 @@  discard block
 block discarded – undo
387 386
 
388 387
 		$readonlys = array();
389 388
 
390
-		$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
389
+		$stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2);
391 390
 	}
392 391
 
393 392
 	/**
@@ -396,11 +395,11 @@  discard block
 block discarded – undo
396 395
 	 * @param array $content
397 396
 	 * @param string $msg
398 397
 	 */
399
-	function index(array $content=null,$msg=null)
398
+	function index(array $content = null, $msg = null)
400 399
 	{
401
-		try	{
400
+		try {
402 401
 				//error_log(__METHOD__.__LINE__.function_backtrace());
403
-				if (mail_bo::$debugTimes) $starttime = microtime (true);
402
+				if (mail_bo::$debugTimes) $starttime = microtime(true);
404 403
 				$this->mail_bo->restoreSessionData();
405 404
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
406 405
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -415,20 +414,20 @@  discard block
 block discarded – undo
415 414
 				if (!is_array($content))
416 415
 				{
417 416
 					$content = array(
418
-						self::$nm_index => egw_session::appsession('index','mail'),
417
+						self::$nm_index => egw_session::appsession('index', 'mail'),
419 418
 					);
420 419
 					if (!is_array($content[self::$nm_index]))
421 420
 					{
422 421
 						$content[self::$nm_index] = array(
423
-							'filter'         => 'any',	// filter is used to choose the mailbox
424
-							'no_filter2'     => false,	// I  disable the 2. filter (params are the same as for filter)
425
-							'no_cat'         => true,	// I  disable the cat-selectbox
422
+							'filter'         => 'any', // filter is used to choose the mailbox
423
+							'no_filter2'     => false, // I  disable the 2. filter (params are the same as for filter)
424
+							'no_cat'         => true, // I  disable the cat-selectbox
426 425
 							//'cat_is_select'	 => 'no_lang', // true or no_lang
427
-							'lettersearch'   => false,	// I  show a lettersearch
428
-							'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
429
-							'start'          =>	0,		// IO position in list
430
-							'order'          =>	'date',	// IO name of the column to sort after (optional for the sortheaders)
431
-							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
426
+							'lettersearch'   => false, // I  show a lettersearch
427
+							'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
428
+							'start'          =>	0, // IO position in list
429
+							'order'          =>	'date', // IO name of the column to sort after (optional for the sortheaders)
430
+							'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
432 431
 							//'default_cols'   => 'status,attachments,subject,'.($toSchema?'toaddress':'fromaddress').',date,size',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
433 432
 							//'default_cols'   => 'status,attachments,subject,address,date,size',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
434 433
 							//'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
@@ -441,8 +440,8 @@  discard block
 block discarded – undo
441 440
 				}
442 441
 
443 442
 				$content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows';
444
-				$content[self::$nm_index]['num_rows'] = 0;      // Do not send any rows with initial request
445
-				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size';	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
443
+				$content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request
444
+				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
446 445
 				$content[self::$nm_index]['csv_fields'] = false;
447 446
 				if ($msg)
448 447
 				{
@@ -454,11 +453,11 @@  discard block
 block discarded – undo
454 453
 					unset($content['msg']);
455 454
 				}
456 455
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
457
-				$quota = false;//$this->mail_bo->getQuotaRoot();
458
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
456
+				$quota = false; //$this->mail_bo->getQuotaRoot();
457
+				if ($quota !== false && $quota['limit'] != 'NOT SET') {
459 458
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
460 459
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
461
-					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
460
+					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
462 461
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
463 462
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
464 463
 				} else {
@@ -467,43 +466,43 @@  discard block
 block discarded – undo
467 466
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
468 467
 				}
469 468
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
470
-				$vacation = false;//$this->gatherVacation();
469
+				$vacation = false; //$this->gatherVacation();
471 470
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
472
-				if($vacation) {
473
-					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
471
+				if ($vacation) {
472
+					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time()))
474 473
 					{
475 474
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
476 475
 						$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
477
-						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['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):''):'');
476
+						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['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) : '') : '');
478 477
 					}
479 478
 				}
480
-				if ($vacation==false)
479
+				if ($vacation == false)
481 480
 				{
482 481
 					$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = '';
483 482
 					$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = '';
484 483
 				}
485 484
 				//$zstarttime = microtime (true);
486
-				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
485
+				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
487 486
 				//$zendtime = microtime(true) - $zstarttime;
488 487
 				//error_log(__METHOD__.__LINE__. " time used: ".$zendtime);
489
-				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX');
488
+				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX');
490 489
 				// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
491
-				if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
490
+				if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
492 491
 				{
493
-					$this->statusTypes = array_merge($this->statusTypes,array(
494
-						'keyword1'	=> 'important',//lang('important'),
495
-						'keyword2'	=> 'job',	//lang('job'),
496
-						'keyword3'	=> 'personal',//lang('personal'),
497
-						'keyword4'	=> 'to do',	//lang('to do'),
498
-						'keyword5'	=> 'later',	//lang('later'),
492
+					$this->statusTypes = array_merge($this->statusTypes, array(
493
+						'keyword1'	=> 'important', //lang('important'),
494
+						'keyword2'	=> 'job', //lang('job'),
495
+						'keyword3'	=> 'personal', //lang('personal'),
496
+						'keyword4'	=> 'to do', //lang('to do'),
497
+						'keyword5'	=> 'later', //lang('later'),
499 498
 					));
500 499
 				}
501 500
 				else
502 501
 				{
503
-					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
504
-					foreach($keywords as &$k)
502
+					$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
503
+					foreach ($keywords as &$k)
505 504
 					{
506
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
505
+						if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
507 506
 					}
508 507
 				}
509 508
 
@@ -514,17 +513,17 @@  discard block
 block discarded – undo
514 513
 
515 514
 				if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
516 515
 				{
517
-					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;
516
+					emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
517
+					if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true;
519 518
 				}
520 519
 				if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) unset($this->searchTypes['quick']);
521 520
 				$sel_options['filter2'] = $this->searchTypes;
522 521
 				$sel_options['filter'] = $this->statusTypes;
523 522
 
524
-				$etpl = new etemplate_new(html::$ua_mobile?'mail.mobile_index':'mail.index');
523
+				$etpl = new etemplate_new(html::$ua_mobile ? 'mail.mobile_index' : 'mail.index');
525 524
 				// Start at 2 so auto-added copy+paste actions show up as second group
526 525
 				// Needed because there's no 'select all' action to push things down
527
-				$group=2;
526
+				$group = 2;
528 527
 				// Set tree actions
529 528
 				$tree_actions = array(
530 529
 					'drop_move_mail' => array(
@@ -602,13 +601,13 @@  discard block
 block discarded – undo
602 601
 					'sieve' => array(
603 602
 						'caption' => 'Mail filter',
604 603
 						'onExecute' => 'javaScript:app.mail.edit_sieve',
605
-						'group'	=> ++$group,	// new group for filter
604
+						'group'	=> ++$group, // new group for filter
606 605
 						'enabled'	=> 'javaScript:app.mail.sieve_enabled',
607
-						'icon' => 'etemplate/fav_filter',	// funnel
606
+						'icon' => 'etemplate/fav_filter', // funnel
608 607
 					),
609 608
 					'vacation' => array(
610 609
 						'caption' => 'Vacation notice',
611
-						'icon' => 'mail/navbar',	// mail as in admin
610
+						'icon' => 'mail/navbar', // mail as in admin
612 611
 						'onExecute' => 'javaScript:app.mail.edit_vacation',
613 612
 						'group'	=> $group,
614 613
 						'enabled'	=> 'javaScript:app.mail.sieve_enabled',
@@ -617,7 +616,7 @@  discard block
 block discarded – undo
617 616
 						'caption' => 'Edit account ...',
618 617
 						'icon' => 'configure',
619 618
 						'onExecute' => 'javaScript:app.mail.edit_account',
620
-						'group'	=> ++$group,	// new groups for account & acl
619
+						'group'	=> ++$group, // new groups for account & acl
621 620
 					),
622 621
 					'edit_acl'	=> array(
623 622
 						'caption' => 'Edit folder ACL ...',
@@ -652,8 +651,8 @@  discard block
 block discarded – undo
652 651
 					unset($tree_actions['subscribe']);
653 652
 					unset($tree_actions['unsubscribe']);
654 653
 				}
655
-				++$group;	// put delete in own group
656
-				switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
654
+				++$group; // put delete in own group
655
+				switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
657 656
 				{
658 657
 					case 'move_to_trash':
659 658
 						$tree_actions['empty_trash'] = array(
@@ -672,7 +671,7 @@  discard block
 block discarded – undo
672 671
 						);
673 672
 						break;
674 673
 				}
675
-				++$group;	// put empty spam immediately in own group
674
+				++$group; // put empty spam immediately in own group
676 675
 				$junkFolder = $this->mail_bo->getJunkFolder();
677 676
 				//error_log(__METHOD__.__LINE__.$junkFolder);
678 677
 				if ($junkFolder && !empty($junkFolder))
@@ -709,23 +708,23 @@  discard block
 block discarded – undo
709 708
 					// to existing folders, it should only affect add/rename/move/delete
710 709
 				}
711 710
 
712
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions);
711
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $tree_actions);
713 712
 
714 713
 				// sending preview toolbar actions
715 714
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
716 715
 
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');
716
+				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');
718 717
 				$readonlys = $preserv = array();
719
-				if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
718
+				if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
720 719
 		}
721 720
 		catch (Exception $e)
722 721
 		{
723
-			self::callWizard($e->getMessage(),true, 'error');
722
+			self::callWizard($e->getMessage(), true, 'error');
724 723
 		}
725 724
 		// Check preview pane is enabled, then show spliter
726 725
 		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
727 726
 
728
-		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
727
+		return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv);
729 728
 	}
730 729
 
731 730
 	/**
@@ -735,19 +734,19 @@  discard block
 block discarded – undo
735 734
 	 * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed
736 735
 	 * @param {boolean} $_status set true for subscribe and false to unsubscribe
737 736
 	 */
738
-	public function ajax_foldersubscription($_acc_id,$_folderName, $_status)
737
+	public function ajax_foldersubscription($_acc_id, $_folderName, $_status)
739 738
 	{
740 739
 		//Change the mail_bo object to related profileId
741 740
 		$this->changeProfile($_acc_id);
742 741
 
743
-		if($this->mail_bo->icServer->subscribeMailbox($_folderName, $_status))
742
+		if ($this->mail_bo->icServer->subscribeMailbox($_folderName, $_status))
744 743
 		{
745 744
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
746
-			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
745
+			$this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
747 746
 		}
748 747
 		else
749 748
 		{
750
-			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed!',$_folderName,$_status?'subscribed':'unsubscribed'));
749
+			error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed!', $_folderName, $_status ? 'subscribed' : 'unsubscribed'));
751 750
 		}
752 751
 	}
753 752
 
@@ -759,25 +758,25 @@  discard block
 block discarded – undo
759 758
 	 * @param string $_nodeID if of node whos children are requested
760 759
 	 * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default)
761 760
 	 */
762
-	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
761
+	public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null)
763 762
 	{
764 763
 		$nodeID = $_GET['id'];
765 764
 		if (!is_null($_nodeID)) $nodeID = $_nodeID;
766
-		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
765
+		$subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
767 766
 		$fetchCounters = !is_null($_nodeID);
768
-		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
767
+		list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2);
769 768
 
770 769
 		if (!empty($_folderName)) $fetchCounters = true;
771 770
 
772 771
 		// Check if it is called for refresh root
773 772
 		// then we need to reinitialized the index tree
774
-		if(!$nodeID && !$_profileID)
773
+		if (!$nodeID && !$_profileID)
775 774
 		{
776
-			$data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
775
+			$data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
777 776
 		}
778 777
 		else
779 778
 		{
780
-			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
779
+			$data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
781 780
 		}
782 781
 		if (!is_null($_nodeID)) return $data;
783 782
 		etemplate_widget_tree::send_quote_json($data);
@@ -793,17 +792,17 @@  discard block
 block discarded – undo
793 792
 	 */
794 793
 	static function findNode($_out, $_nodeID, $childElements = false)
795 794
 	{
796
-		foreach($_out['item'] as $node)
795
+		foreach ($_out['item'] as $node)
797 796
 		{
798
-			if (strcmp($node['id'],$_nodeID)===0)
797
+			if (strcmp($node['id'], $_nodeID) === 0)
799 798
 			{
800 799
 				//error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']);
801
-				return ($childElements?$node['item']:$node);
800
+				return ($childElements ? $node['item'] : $node);
802 801
 			}
803
-			elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id']))
802
+			elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id']))
804 803
 			{
805 804
 				//error_log(__METHOD__.__LINE__.' descend into '.$node['id']);
806
-				return self::findNode($node,$_nodeID,$childElements);
805
+				return self::findNode($node, $_nodeID, $childElements);
807 806
 			}
808 807
 		}
809 808
 	}
@@ -817,7 +816,7 @@  discard block
 block discarded – undo
817 816
 	 */
818 817
 	private function get_actions()
819 818
 	{
820
-		static $accArray=array(); // buffer identity names on single request
819
+		static $accArray = array(); // buffer identity names on single request
821 820
 		// duplicated from mail_hooks
822 821
 		static $deleteOptions = array(
823 822
 			'move_to_trash'		=> 'move to trash',
@@ -827,12 +826,12 @@  discard block
 block discarded – undo
827 826
 		// todo: real hierarchical folder list
828 827
 		$lastFolderUsedForMove = null;
829 828
 		$moveactions = array();
830
-		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
829
+		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
831 830
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
832 831
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
833 832
 		if (is_null($accArray))
834 833
 		{
835
-			foreach(emailadmin_account::search($only_current_user=true, false) as $acc_id => $accountObj)
834
+			foreach (emailadmin_account::search($only_current_user = true, false) as $acc_id => $accountObj)
836 835
 			{
837 836
 				//error_log(__METHOD__.__LINE__.array2string($accountObj));
838 837
 				if (!$accountObj->is_imap())
@@ -840,22 +839,22 @@  discard block
 block discarded – undo
840 839
 					// not to be used for IMAP Foldertree, as there is no Imap host
841 840
 					continue;
842 841
 				}
843
-				$identity_name = emailadmin_account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']);
844
-				$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
842
+				$identity_name = emailadmin_account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']);
843
+				$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 844
 			}
846 845
 		}
847
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
846
+		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array();
848 847
 		foreach ($lastFoldersUsedForMoveCont as $pid => $info)
849 848
 		{
850
-			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
849
+			if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
851 850
 			{
852 851
 				$_folder = $this->mail_bo->icServer->getCurrentMailbox();
853 852
 				//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace());
854
-				$counter =1;
853
+				$counter = 1;
855 854
 				foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont)
856 855
 				{
857 856
 					$moveaction = 'move_';
858
-					if ($_folder!=$i)
857
+					if ($_folder != $i)
859 858
 					{
860 859
 						$moveaction .= $lastFolderUsedForMoveCont;
861 860
 
@@ -865,7 +864,7 @@  discard block
 block discarded – undo
865 864
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
866 865
 							$fS['shortDisplayName'] = $i;
867 866
 							$moveactions[$moveaction] = $fS;
868
-							$counter ++;
867
+							$counter++;
869 868
 						}
870 869
 						else
871 870
 						{
@@ -875,9 +874,9 @@  discard block
 block discarded – undo
875 874
 					}
876 875
 				}
877 876
 			}
878
-			elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
877
+			elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
879 878
 			{
880
-				$counter =1;
879
+				$counter = 1;
881 880
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
882 881
 				{
883 882
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
@@ -889,14 +888,14 @@  discard block
 block discarded – undo
889 888
 						$fS['profileName'] = $accArray[$pid];
890 889
 						$fS['shortDisplayName'] = $i;
891 890
 						$moveactions[$moveaction] = $fS;
892
-						$counter ++;
891
+						$counter++;
893 892
 					}
894 893
 				}
895 894
 			}
896 895
 		}
897
-		egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
896
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
898 897
 		$group = 0;
899
-		$actions =  array(
898
+		$actions = array(
900 899
 			'open' => array(
901 900
 				'caption' => lang('Open'),
902 901
 				'icon' => 'view',
@@ -952,20 +951,20 @@  discard block
 block discarded – undo
952 951
 				'allowOnMultiple' => false,
953 952
 			)
954 953
 		);
955
-		$macounter=0;
954
+		$macounter = 0;
956 955
 		if (!empty($moveactions))
957 956
 		{
958 957
 			//error_log(__METHOD__.__LINE__.array2string($moveactions));
959
-			$children=array();
960
-			$pID=0;
958
+			$children = array();
959
+			$pID = 0;
961 960
 			foreach ($moveactions as $moveaction => $lastFolderUsedForMove)
962 961
 			{
963
-				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group);
962
+				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group);
964 963
 				//error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#');
965 964
 				$children = array_merge($children,
966 965
 					array(
967 966
 						$moveaction => array(
968
-							'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
967
+							'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''),
969 968
 							'icon' => 'move',
970 969
 							'group' => $group,
971 970
 							'onExecute' => 'javaScript:app.mail.mail_move2folder',
@@ -976,7 +975,7 @@  discard block
 block discarded – undo
976 975
 				$pID = $lastFolderUsedForMove['profileID'];
977 976
 				$macounter++;
978 977
 			}
979
-			$actions = array_merge($actions,array('moveto' =>
978
+			$actions = array_merge($actions, array('moveto' =>
980 979
 				array(
981 980
 					'caption' => lang('Move selected to'),
982 981
 					'icon' => 'move',
@@ -1007,7 +1006,7 @@  discard block
 block discarded – undo
1007 1006
 					'icon' => 'tracker/navbar',
1008 1007
 					'onExecute' => 'javaScript:app.mail.mail_integrate',
1009 1008
 					'popup' => egw_link::get_registry('tracker', 'add_popup'),
1010
-					'mail_import' => $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),'tracker'),
1009
+					'mail_import' => $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'), 'tracker'),
1011 1010
 					'allowOnMultiple' => false,
1012 1011
 				),
1013 1012
 				'calendar' => array(
@@ -1223,22 +1222,22 @@  discard block
 block discarded – undo
1223 1222
 	 * @param array &$rows
1224 1223
 	 * @param array &$readonlys
1225 1224
 	 */
1226
-	public static function get_rows(&$query,&$rows,&$readonlys)
1225
+	public static function get_rows(&$query, &$rows, &$readonlys)
1227 1226
 	{
1228 1227
 		// handle possible profile change in get_rows
1229 1228
 		if (!empty($query['selectedFolder']))
1230 1229
 		{
1231
-			list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1230
+			list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1232 1231
 			if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])
1233 1232
 			{
1234 1233
 				try {
1235
-					$mail_ui = new mail_ui(false);	// do NOT run constructor, as we change profile anyway
1234
+					$mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway
1236 1235
 					$mail_ui->changeProfile($_profileID);
1237 1236
 					$query['actions'] = $mail_ui->get_actions();
1238 1237
 				}
1239
-				catch(Exception $e)
1238
+				catch (Exception $e)
1240 1239
 				{
1241
-					$rows=array();
1240
+					$rows = array();
1242 1241
 					return 0;
1243 1242
 				}
1244 1243
 				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
@@ -1246,7 +1245,7 @@  discard block
 block discarded – undo
1246 1245
 		}
1247 1246
 		if (!isset($mail_ui))
1248 1247
 		{
1249
-			$mail_ui = new mail_ui(true);	// run constructor for current profile
1248
+			$mail_ui = new mail_ui(true); // run constructor for current profile
1250 1249
 			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1251 1250
 		}
1252 1251
 
@@ -1256,50 +1255,50 @@  discard block
 block discarded – undo
1256 1255
 		//$query['search'] is the phrase in the searchbox
1257 1256
 
1258 1257
 		$mail_ui->mail_bo->restoreSessionData();
1259
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1258
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder'];
1260 1259
 
1261 1260
 		$sRToFetch = null;
1262
-		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
1263
-		if (strpos($_folderName,self::$delimiter)!==false)
1261
+		list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1262
+		if (strpos($_folderName, self::$delimiter) !== false)
1264 1263
 		{
1265
-			list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3);
1264
+			list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3);
1266 1265
 			unset($app);
1267 1266
 		}
1268 1267
 		//save selected Folder to sessionData (mailbox)->currentFolder
1269
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1270
-		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1268
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName;
1269
+		$toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default)
1271 1270
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1272 1271
 		{
1273
-			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false);
1272
+			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false);
1274 1273
 		}
1275 1274
 		else
1276 1275
 		{
1277 1276
 			// take the extra time on failure
1278
-			if (!$mail_ui->mail_bo->folderExists($_folderName,true))
1277
+			if (!$mail_ui->mail_bo->folderExists($_folderName, true))
1279 1278
 			{
1280 1279
 				//error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead');
1281
-				$query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX';
1280
+				$query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX';
1282 1281
 			}
1283 1282
 		}
1284 1283
 		$mail_ui->mail_bo->saveSessionData();
1285 1284
 		$rowsFetched['messages'] = null;
1286
-		$offset = $query['start']+1; // we always start with 1
1285
+		$offset = $query['start'] + 1; // we always start with 1
1287 1286
 		$maxMessages = $query['num_rows'];
1288 1287
 		//error_log(__METHOD__.__LINE__.$query['order']);
1289
-		$sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']);
1288
+		$sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']);
1290 1289
 		if (!empty($query['search']))
1291 1290
 		{
1292 1291
 			if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1293 1292
 			{
1294
-				emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
1293
+				emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1295 1294
 				if (!isset(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1296 1295
 				{
1297
-					emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
1296
+					emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true;
1298 1297
 				}
1299 1298
 			}
1300 1299
 			$filter = array(
1301
-				'filterName' => (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
1302
-				'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
1300
+				'filterName' => (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
1301
+				'type' => ($query['filter2'] ? $query['filter2'] : (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
1303 1302
 				'string' => $query['search'],
1304 1303
 				'status' => 'any');
1305 1304
 		}
@@ -1311,7 +1310,7 @@  discard block
 block discarded – undo
1311 1310
 		{
1312 1311
 			$filter['status'] = $query['filter'];
1313 1312
 		}
1314
-		$reverse = ($query['sort']=='ASC'?false:true);
1313
+		$reverse = ($query['sort'] == 'ASC' ? false : true);
1315 1314
 		//error_log(__METHOD__.__LINE__.' maxMessages:'.$maxMessages.' Offset:'.$offset.' Filter:'.array2string($mail_ui->sessionData['messageFilter']));
1316 1315
 		try
1317 1316
 		{
@@ -1322,18 +1321,18 @@  discard block
 block discarded – undo
1322 1321
 					$sort,
1323 1322
 					$reverse,
1324 1323
 					$filter,
1325
-					$rByUid=true
1324
+					$rByUid = true
1326 1325
 				);
1327 1326
 				$rowsFetched['messages'] = $_sR['count'];
1328 1327
 				$sR = $_sR['match']->ids;
1329 1328
 				// if $sR is false, something failed fundamentally
1330
-				if($reverse === true) $sR = ($sR===false?array():array_reverse((array)$sR));
1331
-				$sR = array_slice((array)$sR,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1332
-				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1329
+				if ($reverse === true) $sR = ($sR === false ? array() : array_reverse((array)$sR));
1330
+				$sR = array_slice((array)$sR, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids
1331
+				$sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1333 1332
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
1334 1333
 				$maxMessages = 75;
1335 1334
 				$sortResultwH['header'] = array();
1336
-				if (count($sRToFetch)>0)
1335
+				if (count($sRToFetch) > 0)
1337 1336
 				{
1338 1337
 					//error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch));
1339 1338
 					$sortResult = array();
@@ -1371,23 +1370,23 @@  discard block
 block discarded – undo
1371 1370
 		}
1372 1371
 		catch (Exception $e)
1373 1372
 		{
1374
-			$sortResultwH=array();
1375
-			$sR=array();
1373
+			$sortResultwH = array();
1374
+			$sR = array();
1376 1375
 			self::callWizard($e->getMessage(), false, 'error');
1377 1376
 		}
1378 1377
 		$response = egw_json_response::get();
1379 1378
 		// unlock immediately after fetching the rows
1380
-		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
1379
+		if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false)
1381 1380
 		{
1382 1381
 			//error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']);
1383 1382
 			$response->call('app.mail.unlock_tree');
1384 1383
 		}
1385 1384
 
1386
-		if (is_array($sR) && count($sR)>0)
1385
+		if (is_array($sR) && count($sR) > 0)
1387 1386
 		{
1388 1387
 			foreach ((array)$sR as $key => $v)
1389 1388
 			{
1390
-				if (array_key_exists($key,(array)$sortResultwH['header'])==true)
1389
+				if (array_key_exists($key, (array)$sortResultwH['header']) == true)
1391 1390
 				{
1392 1391
 					$sortResult['header'][] = $sortResultwH['header'][$key];
1393 1392
 				}
@@ -1405,12 +1404,12 @@  discard block
 block discarded – undo
1405 1404
 		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1406 1405
 
1407 1406
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1408
-		$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]);
1410
-		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1407
+		$cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview');
1408
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1409
+		$rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema);
1411 1410
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1412 1411
 
1413
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1412
+		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__);
1414 1413
 		return $rowsFetched['messages'];
1415 1414
 	}
1416 1415
 
@@ -1422,7 +1421,7 @@  discard block
 block discarded – undo
1422 1421
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1423 1422
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1424 1423
 	 */
1425
-	function createRowID($_folderName, $message_uid, $_prependApp=false)
1424
+	function createRowID($_folderName, $message_uid, $_prependApp = false)
1426 1425
 	{
1427 1426
 		return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp);
1428 1427
 	}
@@ -1436,9 +1435,9 @@  discard block
 block discarded – undo
1436 1435
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1437 1436
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1438 1437
 	 */
1439
-	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false)
1438
+	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false)
1440 1439
 	{
1441
-		return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1440
+		return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1442 1441
 	}
1443 1442
 
1444 1443
 	/**
@@ -1449,13 +1448,13 @@  discard block
 block discarded – undo
1449 1448
 	 */
1450 1449
 	static function splitRowID($_rowID)
1451 1450
 	{
1452
-		$res = explode(self::$delimiter,$_rowID);
1451
+		$res = explode(self::$delimiter, $_rowID);
1453 1452
 		// as a rowID is perceeded by app::, should be mail!
1454 1453
 		//error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res));
1455
-		if (count($res)==4 && is_numeric($res[0]) )
1454
+		if (count($res) == 4 && is_numeric($res[0]))
1456 1455
 		{
1457 1456
 			// we have an own created rowID; prepend app=mail
1458
-			array_unshift($res,'mail');
1457
+			array_unshift($res, 'mail');
1459 1458
 		}
1460 1459
 		return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]);
1461 1460
 	}
@@ -1469,56 +1468,56 @@  discard block
 block discarded – undo
1469 1468
 	{
1470 1469
 		$actions = $this->get_actions();
1471 1470
 		$arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print',
1472
-			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1',	'label2', 'label3',	'label4', 'label5');
1473
-		foreach( $arrActions as &$act)
1471
+			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5');
1472
+		foreach ($arrActions as &$act)
1474 1473
 		{
1475 1474
 			//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
1476 1475
 			switch ($act)
1477 1476
 			{
1478 1477
 				case 'forward':
1479
-					$actionsenabled[$act]=$actions[$act];
1478
+					$actionsenabled[$act] = $actions[$act];
1480 1479
 					break;
1481 1480
 				case 'save':
1482
-					$actionsenabled[$act]=$actions[$act];
1481
+					$actionsenabled[$act] = $actions[$act];
1483 1482
 
1484 1483
 					break;
1485 1484
 				case 'view':
1486
-					$actionsenabled[$act]=$actions[$act];
1485
+					$actionsenabled[$act] = $actions[$act];
1487 1486
 					break;
1488 1487
 				case 'flagged':
1489
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1488
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1490 1489
 					break;
1491 1490
 				case 'read':
1492
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1491
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1493 1492
 					break;
1494 1493
 				case 'label1':
1495 1494
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important');
1496
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1495
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1497 1496
 					break;
1498 1497
 				case 'label2':
1499 1498
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job');
1500
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1499
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1501 1500
 					break;
1502 1501
 				case 'label3':
1503 1502
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal');
1504
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1503
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1505 1504
 					break;
1506 1505
 				case 'label4':
1507 1506
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do');
1508
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1507
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1509 1508
 					break;
1510 1509
 				case 'label5':
1511 1510
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later');
1512
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1511
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1513 1512
 					break;
1514 1513
 				default:
1515
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1514
+					if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act];
1516 1515
 			}
1517 1516
 		}
1518 1517
 		unset($actionsenabled['drag_mail']);
1519 1518
 		//error_log(array2string($actionsenabled['view']));
1520
-		unset($actionsenabled['view']['children']['openastext']);//not supported in preview
1521
-		unset($actionsenabled['view']['children']['openashtml']);//not supported in preview
1519
+		unset($actionsenabled['view']['children']['openastext']); //not supported in preview
1520
+		unset($actionsenabled['view']['children']['openashtml']); //not supported in preview
1522 1521
 
1523 1522
 		return $actionsenabled;
1524 1523
 	}
@@ -1532,45 +1531,45 @@  discard block
 block discarded – undo
1532 1531
 	 * @param array $_folderType used to determine if we need to populate from/to
1533 1532
 	 * @return array populated result array
1534 1533
 	 */
1535
-	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1534
+	public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0)
1536 1535
 	{
1537 1536
 		if (mail_bo::$debugTimes) $starttime = microtime(true);
1538 1537
 		$rv = array();
1539
-		$i=0;
1540
-		foreach((array)$_headers as $header)
1538
+		$i = 0;
1539
+		foreach ((array)$_headers as $header)
1541 1540
 		{
1542 1541
 			$i++;
1543 1542
 			$data = array();
1544 1543
 			//error_log(__METHOD__.array2string($header));
1545 1544
 			$message_uid = $header['uid'];
1546 1545
 			$data['uid'] = $message_uid;
1547
-			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1546
+			$data['row_id'] = $this->createRowID($_folderName, $message_uid);
1548 1547
 
1549 1548
 			$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";
1549
+			if (!empty($header['recent'])) $flags .= "R";
1550
+			if (!empty($header['flagged'])) $flags .= "F";
1551
+			if (!empty($header['answered'])) $flags .= "A";
1552
+			if (!empty($header['forwarded'])) $flags .= "W";
1553
+			if (!empty($header['deleted'])) $flags .= "D";
1554
+			if (!empty($header['seen'])) $flags .= "S";
1555
+			if (!empty($header['label1'])) $flags .= "1";
1556
+			if (!empty($header['label2'])) $flags .= "2";
1557
+			if (!empty($header['label3'])) $flags .= "3";
1558
+			if (!empty($header['label4'])) $flags .= "4";
1559
+			if (!empty($header['label5'])) $flags .= "5";
1561 1560
 
1562 1561
 			$data["status"] = "<span class=\"status_img\"></span>";
1563 1562
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
1564 1563
 
1565 1564
 			// the css for this row
1566
-			$is_recent=false;
1565
+			$is_recent = false;
1567 1566
 			$css_styles = array("mail");
1568 1567
 			if ($header['deleted']) {
1569 1568
 				$css_styles[] = 'deleted';
1570 1569
 			}
1571 1570
 			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1572 1571
 				$css_styles[] = 'recent';
1573
-				$is_recent=true;
1572
+				$is_recent = true;
1574 1573
 			}
1575 1574
 			if ($header['priority'] < 3) {
1576 1575
 				$css_styles[] = 'prio_high';
@@ -1608,19 +1607,19 @@  discard block
 block discarded – undo
1608 1607
 			if (in_array("subject", $cols))
1609 1608
 			{
1610 1609
 				// filter out undisplayable characters
1611
-				$search = array('[\016]','[\017]',
1612
-					'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1613
-					'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1610
+				$search = array('[\016]', '[\017]',
1611
+					'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1612
+					'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1614 1613
 				$replace = '';
1615 1614
 
1616
-				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1615
+				$header['subject'] = preg_replace($search, $replace, $header['subject']);
1617 1616
 				// curly brackets get messed up by the template!
1618 1617
 
1619 1618
 				if (!empty($header['subject'])) {
1620 1619
 					// make the subject shorter if it is to long
1621 1620
 					$subject = $header['subject'];
1622 1621
 				} else {
1623
-					$subject = '('. lang('no subject') .')';
1622
+					$subject = '('.lang('no subject').')';
1624 1623
 				}
1625 1624
 
1626 1625
 				$data["subject"] = $subject; // the mailsubject
@@ -1630,53 +1629,53 @@  discard block
 block discarded – undo
1630 1629
 			//error_log(__METHOD__.__LINE__.array2string($header));
1631 1630
 			if (in_array("attachments", $cols))
1632 1631
 			{
1633
-				if($header['mimetype'] == 'multipart/mixed' ||
1632
+				if ($header['mimetype'] == 'multipart/mixed' ||
1634 1633
 					$header['mimetype'] == 'multipart/signed' ||
1635 1634
 					$header['mimetype'] == 'multipart/related' ||
1636 1635
 					$header['mimetype'] == 'multipart/report' ||
1637 1636
 					$header['mimetype'] == 'text/calendar' ||
1638 1637
 					$header['mimetype'] == 'text/html' ||
1639
-					substr($header['mimetype'],0,11) == 'application' ||
1640
-					substr($header['mimetype'],0,5) == 'audio' ||
1641
-					substr($header['mimetype'],0,5) == 'video' ||
1638
+					substr($header['mimetype'], 0, 11) == 'application' ||
1639
+					substr($header['mimetype'], 0, 5) == 'audio' ||
1640
+					substr($header['mimetype'], 0, 5) == 'video' ||
1642 1641
 					$header['mimetype'] == 'multipart/alternative')
1643 1642
 				{
1644
-					$image = html::image('mail','attach');
1643
+					$image = html::image('mail', 'attach');
1645 1644
 					$imageHTMLBlock = '';
1646
-					$datarowid = $this->createRowID($_folderName,$message_uid,true);
1645
+					$datarowid = $this->createRowID($_folderName, $message_uid, true);
1647 1646
 					$attachments = $header['attachments'];
1648
-					if (count($attachments)<1)
1647
+					if (count($attachments) < 1)
1649 1648
 					{
1650 1649
 						$image = '&nbsp;';
1651 1650
 					}
1652
-					if (count($attachments)==1)
1651
+					if (count($attachments) == 1)
1653 1652
 					{
1654
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1655
-						$image = html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
1653
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1654
+						$image = html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : ''));
1656 1655
 					}
1657
-					if (count($attachments)>1)
1656
+					if (count($attachments) > 1)
1658 1657
 					{
1659
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1660
-						$image = html::image('mail','attach',lang('%1 attachments',count($attachments)));
1658
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1659
+						$image = html::image('mail', 'attach', lang('%1 attachments', count($attachments)));
1661 1660
 					}
1662 1661
 
1663 1662
 					$attachmentFlag = $image;
1664 1663
 				} else {
1665
-					$attachmentFlag ='&nbsp;';
1664
+					$attachmentFlag = '&nbsp;';
1666 1665
 				}
1667 1666
 				// show priority flag
1668 1667
 				if ($header['priority'] < 3) {
1669
-					 $image = html::image('mail','prio_high');
1668
+					 $image = html::image('mail', 'prio_high');
1670 1669
 				} elseif ($header['priority'] > 3) {
1671
-					$image = html::image('mail','prio_low');
1670
+					$image = html::image('mail', 'prio_low');
1672 1671
 				} else {
1673 1672
 					$image = '';
1674 1673
 				}
1675 1674
 				// show a flag for flagged messages
1676
-				$imageflagged ='';
1675
+				$imageflagged = '';
1677 1676
 				if ($header['flagged'])
1678 1677
 				{
1679
-					$imageflagged = html::image('mail','unread_flagged_small');
1678
+					$imageflagged = html::image('mail', 'unread_flagged_small');
1680 1679
 				}
1681 1680
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
1682 1681
 			}
@@ -1685,7 +1684,7 @@  discard block
 block discarded – undo
1685 1684
 			if (in_array("toaddress", $cols))
1686 1685
 			{
1687 1686
 				// sent or drafts or template folder means foldertype > 0, use to address instead of from
1688
-				$data["toaddress"] = $header['to_address'];//mail_bo::htmlentities($header['to_address'],$this->charset);
1687
+				$data["toaddress"] = $header['to_address']; //mail_bo::htmlentities($header['to_address'],$this->charset);
1689 1688
 			}
1690 1689
 
1691 1690
 			if (in_array("additionaltoaddress", $cols))
@@ -1718,29 +1717,29 @@  discard block
 block discarded – undo
1718 1717
 			$data['flags'] = Array();
1719 1718
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1720 1719
 			foreach ($css_styles as &$flag) {
1721
-				if ($flag!='mail')
1720
+				if ($flag != 'mail')
1722 1721
 				{
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']);}
1722
+					if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; }
1723
+					elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; }
1724
+					elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; }
1725
+					elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; }
1726
+					elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; }
1727
+					elseif ($flag == 'unseen') {unset($data["flags"]['read']); }
1729 1728
 					else $data["flags"][$flag] = $flag;
1730 1729
 				}
1731 1730
 			}
1732 1731
 			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']);
1732
+			if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1734 1733
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1735
-			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1736
-			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
1734
+			$data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]);
1735
+			if (in_array("bodypreview", $cols) && $header['bodypreview'])
1737 1736
 			{
1738 1737
 				$data["bodypreview"] = $header['bodypreview'];
1739 1738
 			}
1740 1739
 			$rv[] = $data;
1741 1740
 			//error_log(__METHOD__.__LINE__.array2string($data));
1742 1741
 		}
1743
-		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
1742
+		if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__);
1744 1743
 
1745 1744
 		// ToDo: call this ONLY if labels change
1746 1745
 		etemplate_widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1755,8 +1754,8 @@  discard block
 block discarded – undo
1755 1754
 	 */
1756 1755
 	function displayHeader()
1757 1756
 	{
1758
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1759
-		if(isset($_GET['part'])) $partID = $_GET['part'];
1757
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
1758
+		if (isset($_GET['part'])) $partID = $_GET['part'];
1760 1759
 
1761 1760
 		$hA = self::splitRowID($rowID);
1762 1761
 		$uid = $hA['msgUID'];
@@ -1770,17 +1769,17 @@  discard block
 block discarded – undo
1770 1769
 		}
1771 1770
 
1772 1771
 		$this->mail_bo->reopen($mailbox);
1773
-		$rawheaders	= $this->mail_bo->getMessageRawHeader($uid, $partID);
1772
+		$rawheaders = $this->mail_bo->getMessageRawHeader($uid, $partID);
1774 1773
 
1775 1774
 		// add line breaks to $rawheaders
1776
-		$newRawHeaders = explode("\n",$rawheaders);
1775
+		$newRawHeaders = explode("\n", $rawheaders);
1777 1776
 		reset($newRawHeaders);
1778 1777
 
1779 1778
 		// reset $rawheaders
1780
-		$rawheaders 	= "";
1779
+		$rawheaders = "";
1781 1780
 		// create it new, with good line breaks
1782 1781
 		reset($newRawHeaders);
1783
-		while(list($key,$value) = @each($newRawHeaders)) {
1782
+		while (list($key, $value) = @each($newRawHeaders)) {
1784 1783
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1785 1784
 		}
1786 1785
 
@@ -1792,7 +1791,7 @@  discard block
 block discarded – undo
1792 1791
 		}
1793 1792
 
1794 1793
 		header('Content-type: text/html; charset=iso-8859-1');
1795
-		print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
1794
+		print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>';
1796 1795
 
1797 1796
 	}
1798 1797
 
@@ -1805,10 +1804,10 @@  discard block
 block discarded – undo
1805 1804
 	{
1806 1805
 		if (is_null($_requesteddata)) $_requesteddata = $_GET;
1807 1806
 
1808
-		$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);
1807
+		$preventRedirect = false;
1808
+		if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id'];
1809
+		if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null;
1810
+		if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false);
1812 1811
 
1813 1812
 		$hA = self::splitRowID($rowID);
1814 1813
 		$uid = $hA['msgUID'];
@@ -1832,78 +1831,78 @@  discard block
 block discarded – undo
1832 1831
 		}
1833 1832
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
1834 1833
 		{
1835
-			egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
1834
+			egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft'));
1836 1835
 		}
1837 1836
 		$this->mail_bo->reopen($mailbox);
1838 1837
 		// retrieve the flags of the message, before touching it.
1839 1838
 		try
1840 1839
 		{
1841
-			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
1840
+			$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox);
1842 1841
 		}
1843 1842
 		catch (egw_exception $e)
1844 1843
 		{
1845 1844
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
1846
-			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1845
+			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID);
1847 1846
 			egw_framework::message($e->getMessage(), 'error');
1848 1847
 		}
1849 1848
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
1850
-		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1849
+		$envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox);
1851 1850
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1852
-		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1851
+		$this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox);
1853 1852
 		$fetchEmbeddedImages = false;
1854 1853
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1855 1854
 		// we do NOT want to see those, that are embedded in the list of attachments
1856
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
1857
-		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1855
+		if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true;
1856
+		$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox);
1858 1857
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
1859 1858
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
1860 1859
 		//error_log(__METHOD__.__LINE__.array2string($attachmentHTMLBlock));
1861
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
1862
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1863
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1860
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
1861
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1862
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1864 1863
 
1865 1864
 		//error_log(__METHOD__.__LINE__.$mailBody);
1866 1865
 		$this->mail_bo->closeConnection();
1867 1866
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1868 1867
 		$etpl = new etemplate_new('mail.display');
1869
-		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
1868
+		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false);
1870 1869
 
1871 1870
 		// Set up data for taglist widget(s)
1872
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
1873
-		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
1871
+		if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']);
1872
+		foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field)
1874 1873
 		{
1875 1874
 			if (!isset($envelope[$field])) continue;
1876
-			foreach($envelope[$field] as $field_data)
1875
+			foreach ($envelope[$field] as $field_data)
1877 1876
 			{
1878 1877
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
1879 1878
 				$content[$field][] = $field_data;
1880 1879
 				$sel_options[$field][] = array(
1881 1880
 					// taglist requires these - not optional
1882 1881
 					'id' => $field_data,
1883
-					'label' => str_replace('"',"'",$field_data),
1882
+					'label' => str_replace('"', "'", $field_data),
1884 1883
 				);
1885 1884
 			}
1886 1885
 		}
1887 1886
 		$actionsenabled = $this->getDisplayToolbarActions();
1888 1887
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
1889 1888
 		if (empty($subject)) $subject = lang('no subject');
1890
-		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
1889
+		$content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg);
1891 1890
 		// Send mail ID so we can use it for actions
1892 1891
 		$content['mail_id'] = $rowID;
1893 1892
 		if (!is_array($headers) || !isset($headers['DATE']))
1894 1893
 		{
1895
-			$headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:'');
1894
+			$headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : '');
1896 1895
 		}
1897
-		$content['mail_displaydate'] = mail_bo::_strtotime($headers['DATE'],'ts',true);
1896
+		$content['mail_displaydate'] = mail_bo::_strtotime($headers['DATE'], 'ts', true);
1898 1897
 		$content['mail_displaysubject'] = $subject;
1899
-		$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;
1902
-		$content['mailDisplayBodySrc'] = egw::link('/index.php',$linkData);
1898
+		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID);
1899
+		if (!empty($partID)) $linkData['_partID'] = $partID;
1900
+		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions;
1901
+		$content['mailDisplayBodySrc'] = egw::link('/index.php', $linkData);
1903 1902
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
1904
-		$content['mail_id']=$rowID;
1905
-		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
1906
-		$content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone");
1903
+		$content['mail_id'] = $rowID;
1904
+		$content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight");
1905
+		$content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone");
1907 1906
 
1908 1907
 		// DRAG attachments actions
1909 1908
 		$etpl->setElementAttribute('mail_displayattachments', 'actions', array(
@@ -1920,22 +1919,22 @@  discard block
 block discarded – undo
1920 1919
 			$this->changeProfile($rememberServerID);
1921 1920
 		}
1922 1921
 
1923
-		$etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
1922
+		$etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2);
1924 1923
 	}
1925 1924
 
1926 1925
 	/**
1927 1926
 	 * Build actions for display toolbar
1928 1927
 	 */
1929
-	function getDisplayToolbarActions ()
1928
+	function getDisplayToolbarActions()
1930 1929
 	{
1931 1930
 		$actions = $this->get_toolbar_actions();
1932
-		$actions['mark']['children']['flagged']=array(
1931
+		$actions['mark']['children']['flagged'] = array(
1933 1932
 			'group' => $actions['mark']['children']['flagged']['group'],
1934 1933
 			'caption' => 'Flagged',
1935 1934
 			'icon' => 'unread_flagged_small',
1936 1935
 			'onExecute' => 'javaScript:app.mail.mail_flag',
1937 1936
 		);
1938
-		$actions['mark']['children']['unflagged']=array(
1937
+		$actions['mark']['children']['unflagged'] = array(
1939 1938
 			'group' => $actions['mark']['children']['flagged']['group'],
1940 1939
 			'caption' => 'Unflagged',
1941 1940
 			'icon' => 'read_flagged_small',
@@ -1945,9 +1944,9 @@  discard block
 block discarded – undo
1945 1944
 		$actions['forward']['toolbarDefault'] = true;
1946 1945
 		$compose = $actions['composeasnew'];
1947 1946
 		unset($actions['composeasnew']);
1948
-		$actions = array_reverse($actions,true);
1949
-		$actions['composeasnew']= $compose;
1950
-		$actions = array_reverse($actions,true);
1947
+		$actions = array_reverse($actions, true);
1948
+		$actions['composeasnew'] = $compose;
1949
+		$actions = array_reverse($actions, true);
1951 1950
 		return $actions;
1952 1951
 	}
1953 1952
 
@@ -1962,23 +1961,23 @@  discard block
 block discarded – undo
1962 1961
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
1963 1962
 	 * @return mixed array/string data array or html or empty string
1964 1963
 	 */
1965
-	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
1964
+	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false)
1966 1965
 	{
1967
-		$attachmentHTMLBlock='';
1966
+		$attachmentHTMLBlock = '';
1968 1967
 		$attachmentHTML = array();
1969 1968
 		if (is_array($attachments) && count($attachments) > 0) {
1970
-			$url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
1971
-			$url_img_vfs_save_all = html::image('mail','save_all', lang('Save all'));
1969
+			$url_img_vfs = html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"');
1970
+			$url_img_vfs_save_all = html::image('mail', 'save_all', lang('Save all'));
1972 1971
 
1973 1972
 			foreach ($attachments as $key => $value)
1974 1973
 			{
1975
-				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
1976
-				$attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
1974
+				$attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)'));
1975
+				$attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8');
1977 1976
 				//error_log(array2string($value));
1978 1977
 				//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']);
1980
-				$attachmentHTML[$key]['type']=$value['mimeType'];
1981
-				$attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']);
1978
+				if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']);
1979
+				$attachmentHTML[$key]['type'] = $value['mimeType'];
1980
+				$attachmentHTML[$key]['mimetype'] = mime_magic::mime2label($value['mimeType']);
1982 1981
 				$hA = self::splitRowID($rowID);
1983 1982
 				$uid = $hA['msgUID'];
1984 1983
 				$mailbox = $hA['folder'];
@@ -1987,26 +1986,25 @@  discard block
 block discarded – undo
1987 1986
 				$attachmentHTML[$key]['mime_data'] = egw_link::set_data($value['mimeType'], 'emailadmin_imapbase::getAttachmentAccount', array(
1988 1987
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
1989 1988
 				));
1990
-				$attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']);
1991
-				$attachmentHTML[$key]['attachment_number']=$key;
1992
-				$attachmentHTML[$key]['partID']=$value['partID'];
1989
+				$attachmentHTML[$key]['size'] = egw_vfs::hsize($value['size']);
1990
+				$attachmentHTML[$key]['attachment_number'] = $key;
1991
+				$attachmentHTML[$key]['partID'] = $value['partID'];
1993 1992
 				$attachmentHTML[$key]['mail_id'] = $rowID;
1994
-				$attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
1993
+				$attachmentHTML[$key]['winmailFlag'] = $value['is_winmail'];
1995 1994
 				$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
1996 1995
 
1997
-				switch(strtoupper($value['mimeType']))
1996
+				switch (strtoupper($value['mimeType']))
1998 1997
 				{
1999 1998
 					case 'MESSAGE/RFC822':
2000
-						$linkData = array
2001
-						(
1999
+						$linkData = array(
2002 2000
 							'menuaction'	=> 'mail.mail_ui.displayMessage',
2003 2001
 							'mode'		=> 'display', //message/rfc822 attachments should be opened in display mode
2004 2002
 							'id'		=> $rowID,
2005 2003
 							'part'		=> $value['partID'],
2006 2004
 							'is_winmail'    => $value['is_winmail']
2007 2005
 						);
2008
-						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
2009
-						$linkView = "egw_openWindowCentered('".egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2006
+						$windowName = 'displayMessage_'.$rowID.'_'.$value['partID'];
2007
+						$linkView = "egw_openWindowCentered('".egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2010 2008
 						break;
2011 2009
 					case 'IMAGE/JPEG':
2012 2010
 					case 'IMAGE/PNG':
@@ -2017,7 +2015,7 @@  discard block
 block discarded – undo
2017 2015
 					case 'TEXT/HTML':
2018 2016
 					case 'TEXT/DIRECTORY':
2019 2017
 						$sfxMimeType = $value['mimeType'];
2020
-						$buff = explode('.',$value['name']);
2018
+						$buff = explode('.', $value['name']);
2021 2019
 						$suffix = '';
2022 2020
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2023 2021
 						if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
@@ -2030,49 +2028,47 @@  discard block
 block discarded – undo
2030 2028
 					case 'TEXT/VCARD':
2031 2029
 					case 'TEXT/CALENDAR':
2032 2030
 					case 'TEXT/X-VCALENDAR':
2033
-						$linkData = array
2034
-						(
2031
+						$linkData = array(
2035 2032
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2036 2033
 							'id'		=> $rowID,
2037 2034
 							'part'		=> $value['partID'],
2038 2035
 							'is_winmail'    => $value['is_winmail'],
2039 2036
 							'mailbox'   => base64_encode($mailbox),
2040 2037
 						);
2041
-						$windowName = 'displayAttachment_'. $uid;
2038
+						$windowName = 'displayAttachment_'.$uid;
2042 2039
 						$reg = '800x600';
2043 2040
 						// handle calendar/vcard
2044
-						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
2041
+						if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR')
2045 2042
 						{
2046
-							$windowName = 'displayEvent_'. $rowID;
2047
-							$reg2 = egw_link::get_registry('calendar','view_popup');
2048
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2043
+							$windowName = 'displayEvent_'.$rowID;
2044
+							$reg2 = egw_link::get_registry('calendar', 'view_popup');
2045
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2049 2046
 						}
2050
-						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
2047
+						if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD')
2051 2048
 						{
2052
-							$windowName = 'displayContact_'. $rowID;
2053
-							$reg2 = egw_link::get_registry('addressbook','add_popup');
2054
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2049
+							$windowName = 'displayContact_'.$rowID;
2050
+							$reg2 = egw_link::get_registry('addressbook', 'add_popup');
2051
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2055 2052
 						}
2056 2053
 						// apply to action
2057
-						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
2058
-						$linkView = "egw_openWindowCentered('".egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
2054
+						list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg));
2055
+						$linkView = "egw_openWindowCentered('".egw::link('/index.php', $linkData)."','$windowName',$width,$height);";
2059 2056
 						break;
2060 2057
 					default:
2061
-						$linkData = array
2062
-						(
2058
+						$linkData = array(
2063 2059
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2064 2060
 							'id'		=> $rowID,
2065 2061
 							'part'		=> $value['partID'],
2066 2062
 							'is_winmail'    => $value['is_winmail'],
2067 2063
 							'mailbox'   => base64_encode($mailbox),
2068 2064
 						);
2069
-						$linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';";
2065
+						$linkView = "window.location.href = '".egw::link('/index.php', $linkData)."';";
2070 2066
 						break;
2071 2067
 				}
2072 2068
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
2073 2069
 				if (empty($attachmentHTML[$key]['mime_data']))
2074 2070
 				{
2075
-					$attachmentHTML[$key]['mime_url'] = egw::link('/index.php',$linkData);
2071
+					$attachmentHTML[$key]['mime_url'] = egw::link('/index.php', $linkData);
2076 2072
 					unset($attachmentHTML[$key]['mime_data']);
2077 2073
 				}
2078 2074
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2082,8 +2078,7 @@  discard block
 block discarded – undo
2082 2078
 					($value['name'] ? $value['name'] : lang('(no subject)')).
2083 2079
 					'</b></a>';
2084 2080
 
2085
-				$linkData = array
2086
-				(
2081
+				$linkData = array(
2087 2082
 					'menuaction'	=> 'mail.mail_ui.getAttachment',
2088 2083
 					'mode'		=> 'save',
2089 2084
 					'id'		=> $rowID,
@@ -2091,11 +2086,11 @@  discard block
 block discarded – undo
2091 2086
 					'is_winmail'    => $value['is_winmail'],
2092 2087
 					'mailbox'   => base64_encode($mailbox),
2093 2088
 				);
2094
-				$attachmentHTML[$key]['link_save'] ="<a href='".egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".html::image('mail','fileexport')."</a>";
2089
+				$attachmentHTML[$key]['link_save'] = "<a href='".egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".html::image('mail', 'fileexport')."</a>";
2095 2090
 
2096 2091
 				if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
2097 2092
 				{
2098
-					$link_vfs_save = egw::link('/index.php',array(
2093
+					$link_vfs_save = egw::link('/index.php', array(
2099 2094
 						'menuaction' => 'filemanager.filemanager_select.select',
2100 2095
 						'mode' => 'saveas',
2101 2096
 						'name' => $value['name'],
@@ -2114,19 +2109,19 @@  discard block
 block discarded – undo
2114 2109
 							//$rowID
2115 2110
 							$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
2116 2111
 						}
2117
-						$link_vfs_save = egw::link('/index.php',array(
2112
+						$link_vfs_save = egw::link('/index.php', array(
2118 2113
 							'menuaction' => 'filemanager.filemanager_select.select',
2119 2114
 							'mode' => 'select-dir',
2120 2115
 							'method' => 'mail.mail_ui.vfsSaveAttachment',
2121 2116
 							'label' => lang('Save all'),
2122
-						)+$ids);
2117
+						) + $ids);
2123 2118
 						$vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>";
2124 2119
 					}
2125 2120
 					$attachmentHTML[$key]['link_save'] .= $vfs_save;
2126 2121
 					//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
2127 2122
 				}
2128 2123
 			}
2129
-			$attachmentHTMLBlock="<table width='100%'>";
2124
+			$attachmentHTMLBlock = "<table width='100%'>";
2130 2125
 			foreach ((array)$attachmentHTML as $row)
2131 2126
 			{
2132 2127
 				$attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>';
@@ -2145,7 +2140,7 @@  discard block
 block discarded – undo
2145 2140
 				unset($attachmentHTML[$ikey]['link_save']);
2146 2141
 			}
2147 2142
 		}
2148
-		return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML);
2143
+		return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML);
2149 2144
 	}
2150 2145
 
2151 2146
 	/**
@@ -2156,7 +2151,7 @@  discard block
 block discarded – undo
2156 2151
 	 */
2157 2152
 	function gatherVacation($cachedVacations = array())
2158 2153
 	{
2159
-		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host);
2154
+		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host);
2160 2155
 		//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
2161 2156
 
2162 2157
 		if ($isVacationEnabled)
@@ -2169,7 +2164,7 @@  discard block
 block discarded – undo
2169 2164
 
2170 2165
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
2171 2166
 				// Set vacation to the instance cache for particular account with expiration of one day
2172
-				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
2167
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24);
2173 2168
 			}
2174 2169
 			catch (PEAR_Exception $ex)
2175 2170
 			{
@@ -2190,36 +2185,36 @@  discard block
 block discarded – undo
2190 2185
 	function quotaDisplay($_usage, $_limit)
2191 2186
 	{
2192 2187
 
2193
-		if($_limit == 0) {
2194
-			$quotaPercent=100;
2188
+		if ($_limit == 0) {
2189
+			$quotaPercent = 100;
2195 2190
 		} else {
2196
-			$quotaPercent=round(($_usage*100)/$_limit);
2191
+			$quotaPercent = round(($_usage * 100) / $_limit);
2197 2192
 		}
2198 2193
 
2199
-		$quotaLimit=mail_bo::show_readable_size($_limit*1024);
2200
-		$quotaUsage=mail_bo::show_readable_size($_usage*1024);
2194
+		$quotaLimit = mail_bo::show_readable_size($_limit * 1024);
2195
+		$quotaUsage = mail_bo::show_readable_size($_usage * 1024);
2201 2196
 
2202 2197
 
2203
-		if($quotaPercent > 90 && $_limit>0) {
2204
-			$quotaBG='mail-index_QuotaRed';
2205
-		} elseif($quotaPercent > 80 && $_limit>0) {
2206
-			$quotaBG='mail-index_QuotaYellow';
2198
+		if ($quotaPercent > 90 && $_limit > 0) {
2199
+			$quotaBG = 'mail-index_QuotaRed';
2200
+		} elseif ($quotaPercent > 80 && $_limit > 0) {
2201
+			$quotaBG = 'mail-index_QuotaYellow';
2207 2202
 		} else {
2208
-			$quotaBG='mail-index_QuotaGreen';
2203
+			$quotaBG = 'mail-index_QuotaGreen';
2209 2204
 		}
2210 2205
 
2211
-		if($_limit > 0) {
2212
-			$quotaText = $quotaUsage .'/'.$quotaLimit;
2206
+		if ($_limit > 0) {
2207
+			$quotaText = $quotaUsage.'/'.$quotaLimit;
2213 2208
 		} else {
2214 2209
 			$quotaText = $quotaUsage;
2215 2210
 		}
2216 2211
 
2217
-		if($quotaPercent > 50) {
2212
+		if ($quotaPercent > 50) {
2218 2213
 		} else {
2219 2214
 		}
2220 2215
 		$quota['class'] = $quotaBG;
2221
-		$quota['text'] = lang('Quota: %1',$quotaText);
2222
-		$quota['percent'] = (string)round(($_usage*100)/$_limit);
2216
+		$quota['text'] = lang('Quota: %1', $quotaText);
2217
+		$quota['percent'] = (string)round(($_usage * 100) / $_limit);
2223 2218
 		return $quota;
2224 2219
 	}
2225 2220
 
@@ -2233,12 +2228,12 @@  discard block
 block discarded – undo
2233 2228
 		$uid	= $_GET['uid'];
2234 2229
 		$cid	= base64_decode($_GET['cid']);
2235 2230
 		$partID = urldecode($_GET['partID']);
2236
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2231
+		if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']);
2237 2232
 
2238 2233
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2239 2234
 		$this->mail_bo->reopen($mailbox);
2240 2235
 
2241
-		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true);	// true get contents as stream
2236
+		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream
2242 2237
 
2243 2238
 		$this->mail_bo->closeConnection();
2244 2239
 
@@ -2246,8 +2241,8 @@  discard block
 block discarded – undo
2246 2241
 
2247 2242
 		if ($attachment)
2248 2243
 		{
2249
-			header("Content-Type: ". $attachment->getType());
2250
-			header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"');
2244
+			header("Content-Type: ".$attachment->getType());
2245
+			header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"');
2251 2246
 			//header("Expires: 0");
2252 2247
 			// the next headers are for IE and SSL
2253 2248
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -2265,7 +2260,7 @@  discard block
 block discarded – undo
2265 2260
 
2266 2261
 	function getAttachment()
2267 2262
 	{
2268
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2263
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2269 2264
 
2270 2265
 		$hA = self::splitRowID($rowID);
2271 2266
 		$uid = $hA['msgUID'];
@@ -2277,11 +2272,11 @@  discard block
 block discarded – undo
2277 2272
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2278 2273
 			$this->changeProfile($icServerID);
2279 2274
 		}
2280
-		$part		= $_GET['part'];
2275
+		$part = $_GET['part'];
2281 2276
 		$is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0;
2282 2277
 
2283 2278
 		$this->mail_bo->reopen($mailbox);
2284
-		$attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false);
2279
+		$attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false);
2285 2280
 		$this->mail_bo->closeConnection();
2286 2281
 		if ($rememberServerID != $this->mail_bo->profileID)
2287 2282
 		{
@@ -2296,7 +2291,7 @@  discard block
 block discarded – undo
2296 2291
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type']))
2297 2292
 			{
2298 2293
 				$sfxMimeType = $attachment['type'];
2299
-				$buff = explode('.',$attachment['filename']);
2294
+				$buff = explode('.', $attachment['filename']);
2300 2295
 				$suffix = '';
2301 2296
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2302 2297
 				if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
@@ -2308,10 +2303,10 @@  discard block
 block discarded – undo
2308 2303
 			{
2309 2304
 				//error_log(__METHOD__."about to call calendar_ical");
2310 2305
 				$calendar_ical = new calendar_ical();
2311
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2306
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2312 2307
 				//error_log(__METHOD__.array2string($eventid));
2313 2308
 				if (!$eventid) $eventid = -1;
2314
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2309
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']);
2315 2310
 				//error_log(__METHOD__.$event);
2316 2311
 				if ((int)$event > 0)
2317 2312
 				{
@@ -2319,7 +2314,7 @@  discard block
 block discarded – undo
2319 2314
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2320 2315
 						'cal_id'      => $event,
2321 2316
 					);
2322
-					egw::redirect_link('../index.php',$vars);
2317
+					egw::redirect_link('../index.php', $vars);
2323 2318
 				}
2324 2319
 				//Import failed, download content anyway
2325 2320
 			}
@@ -2334,13 +2329,13 @@  discard block
 block discarded – undo
2334 2329
 				{
2335 2330
 					$vcard['uid'] = trim($vcard['uid']);
2336 2331
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2337
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2332
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2338 2333
 				}
2339 2334
 				if (!$contact) $contact = null;
2340 2335
 				// 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
-				if ($contact || count($vcard)>2)
2336
+				if ($contact || count($vcard) > 2)
2342 2337
 				{
2343
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2338
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']);
2344 2339
 				}
2345 2340
 				if ((int)$contact > 0)
2346 2341
 				{
@@ -2348,14 +2343,14 @@  discard block
 block discarded – undo
2348 2343
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2349 2344
 						'contact_id'	=> $contact,
2350 2345
 					);
2351
-					egw::redirect_link('../index.php',$vars);
2346
+					egw::redirect_link('../index.php', $vars);
2352 2347
 				}
2353 2348
 				//Import failed, download content anyway
2354 2349
 			}
2355 2350
 		}
2356 2351
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2357
-		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
2358
-		html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
2352
+		$filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part));
2353
+		html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save");
2359 2354
 		echo $attachment['attachment'];
2360 2355
 
2361 2356
 		common::egw_exit();
@@ -2370,9 +2365,9 @@  discard block
 block discarded – undo
2370 2365
 	function saveMessage()
2371 2366
 	{
2372 2367
 		$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'];
2368
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2369
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2370
+		if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location'];
2376 2371
 
2377 2372
 		$hA = self::splitRowID($rowID);
2378 2373
 		$uid = $hA['msgUID'];
@@ -2388,7 +2383,7 @@  discard block
 block discarded – undo
2388 2383
 		$this->mail_bo->reopen($mailbox);
2389 2384
 
2390 2385
 		$message = $this->mail_bo->getMessageRawBody($uid, $partID, $mailbox);
2391
-		$headers = $this->mail_bo->getMessageHeader($uid, $partID, true,false, $mailbox);
2386
+		$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2392 2387
 
2393 2388
 		$this->mail_bo->closeConnection();
2394 2389
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2400,14 +2395,14 @@  discard block
 block discarded – undo
2400 2395
 		$GLOBALS['egw']->session->commit_session();
2401 2396
 		if (!$display)
2402 2397
 		{
2403
-			$subject = str_replace('$$','__',mail_bo::decode_header($headers['SUBJECT']));
2404
-			html::safe_content_header($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
2398
+			$subject = str_replace('$$', '__', mail_bo::decode_header($headers['SUBJECT']));
2399
+			html::safe_content_header($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true);
2405 2400
 			echo $message;
2406 2401
 		}
2407 2402
 		else
2408 2403
 		{
2409
-			html::safe_content_header($message, $subject.".eml", $mime='text/html', $size=0, true, false);
2410
-			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
2404
+			html::safe_content_header($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false);
2405
+			print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>';
2411 2406
 		}
2412 2407
 	}
2413 2408
 
@@ -2419,18 +2414,18 @@  discard block
 block discarded – undo
2419 2414
 	 * @param boolean $close Return javascript to close the window
2420 2415
 	 * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
2421 2416
 	 */
2422
-	function vfsSaveMessage($ids,$path, $close = true)
2417
+	function vfsSaveMessage($ids, $path, $close = true)
2423 2418
 	{
2424 2419
 		//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
2425 2420
 
2426 2421
 		if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path)))
2427 2422
 		{
2428
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); egw(window).close();';
2423
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); egw(window).close();';
2429 2424
 		}
2430 2425
 		translation::add_app('mail');
2431 2426
 
2432 2427
 		$rememberServerID = $this->mail_bo->profileID;
2433
-		foreach((array)$ids as $id)
2428
+		foreach ((array)$ids as $id)
2434 2429
 		{
2435 2430
 			$hA = self::splitRowID($id);
2436 2431
 			$uid = $hA['msgUID'];
@@ -2441,20 +2436,20 @@  discard block
 block discarded – undo
2441 2436
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2442 2437
 				$this->changeProfile($icServerID);
2443 2438
 			}
2444
-			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
2445
-			$err=null;
2446
-			if(egw_vfs::is_dir($path))
2439
+			$message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox);
2440
+			$err = null;
2441
+			if (egw_vfs::is_dir($path))
2447 2442
 			{
2448
-				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
2449
-				$file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml';
2443
+				$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2444
+				$file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml';
2450 2445
 			}
2451 2446
 			else
2452 2447
 			{
2453 2448
 				$file = $path;
2454 2449
 			}
2455
-			if (!($fp = egw_vfs::fopen($file,'wb')) || !fwrite($fp,$message))
2450
+			if (!($fp = egw_vfs::fopen($file, 'wb')) || !fwrite($fp, $message))
2456 2451
 			{
2457
-				$err .= lang('Error saving %1!',$file);
2452
+				$err .= lang('Error saving %1!', $file);
2458 2453
 				$succeeded = false;
2459 2454
 			}
2460 2455
 			else
@@ -2464,10 +2459,10 @@  discard block
 block discarded – undo
2464 2459
 			if ($fp) fclose($fp);
2465 2460
 			if ($succeeded)
2466 2461
 			{
2467
-				unset($headers['SUBJECT']);//already in filename
2462
+				unset($headers['SUBJECT']); //already in filename
2468 2463
 				$infoSection = mail_bo::createHeaderInfoSection($headers, 'SUPPRESS', false);
2469
-				$props = array(array('name' => 'comment','val' => $infoSection));
2470
-				egw_vfs::proppatch($file,$props);
2464
+				$props = array(array('name' => 'comment', 'val' => $infoSection));
2465
+				egw_vfs::proppatch($file, $props);
2471 2466
 			}
2472 2467
 		}
2473 2468
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2476,9 +2471,9 @@  discard block
 block discarded – undo
2476 2471
 			$this->changeProfile($rememberServerID);
2477 2472
 		}
2478 2473
 
2479
-		if($close)
2474
+		if ($close)
2480 2475
 		{
2481
-			egw_framework::window_close(($err?$err:null));
2476
+			egw_framework::window_close(($err ? $err : null));
2482 2477
 		}
2483 2478
 		else
2484 2479
 		{
@@ -2493,15 +2488,15 @@  discard block
 block discarded – undo
2493 2488
 	 * @param string $path path in vfs (no egw_vfs::PREFIX!), only directory for multiple id's ($ids is an array)
2494 2489
 	 * @return string javascript eg. to close the selector window
2495 2490
 	 */
2496
-	function vfsSaveAttachment($ids,$path)
2491
+	function vfsSaveAttachment($ids, $path)
2497 2492
 	{
2498 2493
 		//error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');");
2499 2494
 
2500 2495
 		if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path)))
2501 2496
 		{
2502
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); egw(window).close();';
2497
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); egw(window).close();';
2503 2498
 		}
2504
-		$err=null;
2499
+		$err = null;
2505 2500
 		$dupe_count = array();
2506 2501
 		$rememberServerID = $this->mail_bo->profileID;
2507 2502
 
@@ -2511,12 +2506,12 @@  discard block
 block discarded – undo
2511 2506
 		 *
2512 2507
 		 * @return array an array of parameters
2513 2508
 		 */
2514
-		$getParams = function ($id) {
2515
-			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2516
-			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2509
+		$getParams = function($id) {
2510
+			list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8);
2511
+			$lId = implode('::', array($app, $user, $serverID, $mailbox, $uid));
2517 2512
 			$hA = mail_ui::splitRowID($lId);
2518 2513
 			return array(
2519
-				'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail,
2514
+				'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail,
2520 2515
 				'user' => $user,
2521 2516
 				'name' => $name,
2522 2517
 				'part' => $part,
@@ -2528,8 +2523,8 @@  discard block
 block discarded – undo
2528 2523
 
2529 2524
 		//Examine the first attachment to see if attachment
2530 2525
 		//is winmail.dat embedded attachments.
2531
-		$isMultipleDownload=is_array($ids);
2532
-		$p = $getParams((is_array($ids)?$ids[0]:$ids));
2526
+		$isMultipleDownload = is_array($ids);
2527
+		$p = $getParams((is_array($ids) ? $ids[0] : $ids));
2533 2528
 		if ($p['is_winmail'])
2534 2529
 		{
2535 2530
 			if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID)
@@ -2540,14 +2535,14 @@  discard block
 block discarded – undo
2540 2535
 			// Retrive all embedded attachments at once
2541 2536
 			// avoids to fetch heavy winmail.dat content
2542 2537
 			// for each file.
2543
-			$attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']);
2538
+			$attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']);
2544 2539
 		}
2545 2540
 
2546
-		foreach((array)$ids as $id)
2541
+		foreach ((array)$ids as $id)
2547 2542
 		{
2548 2543
 			$params = $getParams($id);
2549 2544
 			// when downloading a single file, name is not set
2550
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
2545
+			if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name'];
2551 2546
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2552 2547
 			{
2553 2548
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2565,25 +2560,25 @@  discard block
 block discarded – undo
2565 2560
 			}
2566 2561
 			else
2567 2562
 			{
2568
-				$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
2563
+				$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
2569 2564
 			}
2570 2565
 
2571 2566
 			$file = $params['name'];
2572 2567
 			// when $isMultipleDownload the path holds no filename
2573
-			while(egw_vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2568
+			while (egw_vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2574 2569
 			{
2575 2570
 				$dupe_count[$params['name']]++;
2576
-				$file = pathinfo($params['name'], PATHINFO_FILENAME) .
2577
-					' ('.($dupe_count[$params['name']] + 1).')' . '.' .
2571
+				$file = pathinfo($params['name'], PATHINFO_FILENAME).
2572
+					' ('.($dupe_count[$params['name']] + 1).')'.'.'.
2578 2573
 					pathinfo($params['name'], PATHINFO_EXTENSION);
2579 2574
 			}
2580 2575
 			$params['name'] = $file;
2581 2576
 			//error_log(__METHOD__.__LINE__.array2string($attachment));
2582 2577
 			// when $isMultipleDownload the path holds no filename
2583
-			if (!($fp = egw_vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
2584
-				!fwrite($fp,$attachment['attachment']))
2578
+			if (!($fp = egw_vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) ||
2579
+				!fwrite($fp, $attachment['attachment']))
2585 2580
 			{
2586
-				$err .= lang('Error saving %1!',$file);
2581
+				$err .= lang('Error saving %1!', $file);
2587 2582
 			}
2588 2583
 			if ($fp)
2589 2584
 			{
@@ -2596,21 +2591,21 @@  discard block
 block discarded – undo
2596 2591
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
2597 2592
 			$this->changeProfile($rememberServerID);
2598 2593
 		}
2599
-		egw_framework::window_close(($err?$err:null));
2594
+		egw_framework::window_close(($err ? $err : null));
2600 2595
 	}
2601 2596
 
2602 2597
 	/**
2603 2598
 	 * Zip all attachments and send to user
2604 2599
 	 * @param string $message_id = null
2605 2600
 	 */
2606
-	function download_zip($message_id=null)
2601
+	function download_zip($message_id = null)
2607 2602
 	{
2608 2603
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2609 2604
 		// First, get all attachment IDs
2610
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
2605
+		if (isset($_GET['id'])) $message_id = $_GET['id'];
2611 2606
 		//error_log(__METHOD__.__LINE__.$message_id);
2612 2607
 		$rememberServerID = $this->mail_bo->profileID;
2613
-		if(!is_numeric($message_id))
2608
+		if (!is_numeric($message_id))
2614 2609
 		{
2615 2610
 			$hA = self::splitRowID($message_id);
2616 2611
 			$message_id = $hA['msgUID'];
@@ -2628,29 +2623,29 @@  discard block
 block discarded – undo
2628 2623
 		}
2629 2624
 		// always fetch all, even inline (images)
2630 2625
 		$fetchEmbeddedImages = true;
2631
-		$attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox);
2626
+		$attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox);
2632 2627
 		// put them in VFS so they can be zipped
2633
-		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
2628
+		$header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox);
2634 2629
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2635 2630
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2636
-		$temp_path = $homedir/*egw_vfs::get_home_dir()*/ . "/.mail_$message_id";
2637
-		if(egw_vfs::is_dir($temp_path)) egw_vfs::remove ($temp_path);
2631
+		$temp_path = $homedir/*egw_vfs::get_home_dir()*/."/.mail_$message_id";
2632
+		if (egw_vfs::is_dir($temp_path)) egw_vfs::remove($temp_path);
2638 2633
 
2639 2634
 		// Add subject to path, so it gets used as the file name
2640
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
2641
-		if(!egw_vfs::mkdir($path, 0700, true))
2635
+		$path = $temp_path.'/'.($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/';
2636
+		if (!egw_vfs::mkdir($path, 0700, true))
2642 2637
 		{
2643
-			egw_framework::message("Unable to open temp directory $path",'error');
2638
+			egw_framework::message("Unable to open temp directory $path", 'error');
2644 2639
 			return;
2645 2640
 		}
2646 2641
 
2647 2642
 		$file_list = array();
2648 2643
 		$this->mail_bo->reopen($mailbox);
2649
-		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null')
2644
+		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null')
2650 2645
 		{
2651
-			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true);
2646
+			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true);
2652 2647
 		}
2653
-		foreach($attachments as $file)
2648
+		foreach ($attachments as $file)
2654 2649
 		{
2655 2650
 			if ($file['is_winmail'])
2656 2651
 			{
@@ -2663,15 +2658,15 @@  discard block
 block discarded – undo
2663 2658
 			}
2664 2659
 			else
2665 2660
 			{
2666
-				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2661
+				$attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true);
2667 2662
 			}
2668
-			$success=true;
2663
+			$success = true;
2669 2664
 			if (empty($file['filename'])) $file['filename'] = $file['name'];
2670
-			if (!($fp = egw_vfs::fopen($path.$file['filename'],'wb')) ||
2665
+			if (!($fp = egw_vfs::fopen($path.$file['filename'], 'wb')) ||
2671 2666
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
2672 2667
 			{
2673
-				$success=false;
2674
-				egw_framework::message("Unable to zip {$file['filename']}",'error');
2668
+				$success = false;
2669
+				egw_framework::message("Unable to zip {$file['filename']}", 'error');
2675 2670
 			}
2676 2671
 			if ($success) $file_list[] = $path.$file['filename'];
2677 2672
 			if ($fp) fclose($fp);
@@ -2692,7 +2687,7 @@  discard block
 block discarded – undo
2692 2687
 		common::egw_exit();
2693 2688
 	}
2694 2689
 
2695
-	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
2690
+	function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null)
2696 2691
 	{
2697 2692
 		// seems to be needed, as if we open a mail from notification popup that is
2698 2693
 		// located in a different folder, we experience: could not parse message
@@ -2704,19 +2699,19 @@  discard block
 block discarded – undo
2704 2699
 		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
2705 2700
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2706 2701
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2707
-		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
2702
+		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox);
2708 2703
 
2709 2704
 		//error_log(__METHOD__.__LINE__.array2string($bodyParts));
2710 2705
 		// attachments here are only fetched to determine if there is a meeting request
2711 2706
 		// and if. use the appropriate action. so we do not need embedded images
2712 2707
 		$fetchEmbeddedImages = false;
2713
-		$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox);
2708
+		$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true, true, $mailbox);
2714 2709
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2715 2710
 		foreach ($attachments as &$attach)
2716 2711
 		{
2717 2712
 			if (strtolower($attach['mimeType']) == 'text/calendar' &&
2718 2713
 				isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
2719
-				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true))))
2714
+				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'], $attach['is_winmail'], (strtolower($attach['mimeType']) == 'text/calendar' ? false : true))))
2720 2715
 			{
2721 2716
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2722 2717
 				egw_cache::setSession('calendar', 'ical', array(
@@ -2727,28 +2722,28 @@  discard block
 block discarded – undo
2727 2722
 				));
2728 2723
 				$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2729 2724
 				translation::add_app('calendar');
2730
-				return ExecMethod( 'calendar.calendar_uiforms.meeting',
2731
-					array('event'=>null,'msg'=>'','useSession'=>true)
2725
+				return ExecMethod('calendar.calendar_uiforms.meeting',
2726
+					array('event'=>null, 'msg'=>'', 'useSession'=>true)
2732 2727
 				);
2733 2728
 			}
2734 2729
 		}
2735 2730
 		// Compose the content of the frame
2736 2731
 		$frameHtml =
2737 2732
 			$this->get_email_header($this->mail_bo->getStyles($bodyParts)).
2738
-			$this->showBody($this->getdisplayableBody($bodyParts,true,false), false);
2733
+			$this->showBody($this->getdisplayableBody($bodyParts, true, false), false);
2739 2734
 		//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
2740
-		$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
2735
+		$frameHtml = str_replace(" \r\n", "\r\n", $frameHtml);
2741 2736
 		$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2742 2737
 
2743 2738
 		return $frameHtml;
2744 2739
 	}
2745 2740
 
2746
-	static function get_email_header($additionalStyle='')
2741
+	static function get_email_header($additionalStyle = '')
2747 2742
 	{
2748 2743
 		// egw_info[flags][css] already include <style> tags
2749 2744
 		$GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle);
2750
-		$GLOBALS['egw_info']['flags']['nofooter']=true;
2751
-		$GLOBALS['egw_info']['flags']['nonavbar']=true;
2745
+		$GLOBALS['egw_info']['flags']['nofooter'] = true;
2746
+		$GLOBALS['egw_info']['flags']['nonavbar'] = true;
2752 2747
 		// do NOT include any default CSS
2753 2748
 		egw_framework::includeCSS('mail', 'preview', true, true);
2754 2749
 
@@ -2759,35 +2754,35 @@  discard block
 block discarded – undo
2759 2754
 		return $GLOBALS['egw']->framework->header();
2760 2755
 	}
2761 2756
 
2762
-	function showBody(&$body, $print=true,$fullPageTags=true)
2757
+	function showBody(&$body, $print = true, $fullPageTags = true)
2763 2758
 	{
2764 2759
 		$BeginBody = '<div class="mailDisplayBody">
2765 2760
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2766 2761
 
2767 2762
 		$EndBody = '</td></tr></table></div>';
2768 2763
 		if ($fullPageTags) $EndBody .= "</body></html>";
2769
-		if ($print)	{
2770
-			print $BeginBody. $body .$EndBody;
2764
+		if ($print) {
2765
+			print $BeginBody.$body.$EndBody;
2771 2766
 		} else {
2772
-			return $BeginBody. $body .$EndBody;
2767
+			return $BeginBody.$body.$EndBody;
2773 2768
 		}
2774 2769
 	}
2775 2770
 
2776
-	function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true)
2771
+	function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true)
2777 2772
 	{
2778
-		$bodyParts	= $_bodyParts;
2773
+		$bodyParts = $_bodyParts;
2779 2774
 
2780
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2781
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2782
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2775
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2776
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2777
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2783 2778
 
2784 2779
 		$body = '';
2785 2780
 
2786 2781
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2787 2782
 		if (empty($bodyParts)) return "";
2788
-		foreach((array)$bodyParts as $singleBodyPart) {
2783
+		foreach ((array)$bodyParts as $singleBodyPart) {
2789 2784
 			if (!isset($singleBodyPart['body'])) {
2790
-				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2785
+				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy);
2791 2786
 				$body .= $singleBodyPart['body'];
2792 2787
 				continue;
2793 2788
 			}
@@ -2797,7 +2792,7 @@  discard block
 block discarded – undo
2797 2792
 				$body .= '';
2798 2793
 				continue;
2799 2794
 			}
2800
-			if(!empty($body)) {
2795
+			if (!empty($body)) {
2801 2796
 				$body .= '<hr style="border:dotted 1px silver;">';
2802 2797
 			}
2803 2798
 			//error_log($singleBodyPart['body']);
@@ -2822,22 +2817,22 @@  discard block
 block discarded – undo
2822 2817
 				'(R)',
2823 2818
 			);
2824 2819
 
2825
-			if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2820
+			if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2826 2821
 				strtoupper($singleBodyPart['charSet']) != 'UTF-8')
2827 2822
 			{
2828
-				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
2823
+				$singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']);
2829 2824
 			}
2830 2825
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
2831
-			$singleBodyPart['body'] = translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
2826
+			$singleBodyPart['body'] = translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']);
2832 2827
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
2833
-			if($singleBodyPart['mimeType'] == 'text/plain')
2828
+			if ($singleBodyPart['mimeType'] == 'text/plain')
2834 2829
 			{
2835
-				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
2830
+				$newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
2836 2831
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2837 2832
 				// 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));
2833
+				if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
2839 2834
 				// 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);
2835
+				if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
2841 2836
 
2842 2837
 				// search http[s] links and make them as links available again
2843 2838
 				// to understand what's going on here, have a look at
@@ -2865,20 +2860,20 @@  discard block
 block discarded – undo
2865 2860
 				// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
2866 2861
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2867 2862
 				// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
2868
-				$newBody	= "<pre>".mail_bo::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
2863
+				$newBody = "<pre>".mail_bo::wordwrap($newBody, 90, "\n", '&gt;')."</pre>";
2869 2864
 			}
2870 2865
 			else
2871 2866
 			{
2872
-				$alreadyHtmlLawed=false;
2873
-				$newBody	= $singleBodyPart['body'];
2867
+				$alreadyHtmlLawed = false;
2868
+				$newBody = $singleBodyPart['body'];
2874 2869
 				//TODO:$newBody	= $this->highlightQuotes($newBody);
2875 2870
 				#error_log(print_r($newBody,true));
2876 2871
 				if ($useTidy && extension_loaded('tidy'))
2877 2872
 				{
2878 2873
 					$tidy = new tidy();
2879
-					$cleaned = $tidy->repairString($newBody, mail_bo::$tidy_config,'utf8');
2874
+					$cleaned = $tidy->repairString($newBody, mail_bo::$tidy_config, 'utf8');
2880 2875
 					// Found errors. Strip it all so there's some output
2881
-					if($tidy->getStatus() == 2)
2876
+					if ($tidy->getStatus() == 2)
2882 2877
 					{
2883 2878
 						error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
2884 2879
 					}
@@ -2889,7 +2884,7 @@  discard block
 block discarded – undo
2889 2884
 					if (!$preserveHTML)
2890 2885
 					{
2891 2886
 						// filter only the 'body', as we only want that part, if we throw away the html
2892
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
2887
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
2893 2888
 						if ($matches[2])
2894 2889
 						{
2895 2890
 							$hasOther = true;
@@ -2900,7 +2895,7 @@  discard block
 block discarded – undo
2900 2895
 				else
2901 2896
 				{
2902 2897
 					// htmLawed filter only the 'body'
2903
-					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
2898
+					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
2904 2899
 					if ($matches[2])
2905 2900
 					{
2906 2901
 						$hasOther = true;
@@ -2909,10 +2904,10 @@  discard block
 block discarded – undo
2909 2904
 					$htmLawed = new egw_htmLawed();
2910 2905
 					// the next line should not be needed, but produces better results on HTML 2 Text conversion,
2911 2906
 					// as we switched off HTMLaweds tidy functionality
2912
-					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
2913
-					$newBody = $htmLawed->egw_htmLawed($newBody,mail_bo::$htmLawed_config);
2914
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
2915
-					$alreadyHtmlLawed=true;
2907
+					$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
2908
+					$newBody = $htmLawed->egw_htmLawed($newBody, mail_bo::$htmLawed_config);
2909
+					if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
2910
+					$alreadyHtmlLawed = true;
2916 2911
 				}
2917 2912
 				// do the cleanup, set for the use of purifier
2918 2913
 				//$newBodyBuff = $newBody;
@@ -2934,8 +2929,8 @@  discard block
 block discarded – undo
2934 2929
 				}
2935 2930
 */
2936 2931
 				// removes stuff between http and ?http
2937
-				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';    // only http:// gets removed, other protocolls are shown
2938
-				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http://
2932
+				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
2933
+				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http://
2939 2934
 				// TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK
2940 2935
 				$newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
2941 2936
 					"\\1@\\2.\\3",
@@ -2948,7 +2943,7 @@  discard block
 block discarded – undo
2948 2943
 				// create links for inline images
2949 2944
 				if ($modifyURI)
2950 2945
 				{
2951
-					$newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID);
2946
+					$newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID);
2952 2947
 				}
2953 2948
 				// email addresses / mailto links get now activated on client-side
2954 2949
 			}
@@ -2960,7 +2955,7 @@  discard block
 block discarded – undo
2960 2955
 		$body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
2961 2956
 			"<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body);
2962 2957
 
2963
-		$body = preg_replace($nonDisplayAbleCharacters,'',$body);
2958
+		$body = preg_replace($nonDisplayAbleCharacters, '', $body);
2964 2959
 
2965 2960
 		return $body;
2966 2961
 	}
@@ -2975,7 +2970,7 @@  discard block
 block discarded – undo
2975 2970
 	 * @param string $_messageType = 'html', message type is either html or plain
2976 2971
 	 * @return string message body including all CID images replaced
2977 2972
 	 */
2978
-	public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html')
2973
+	public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html')
2979 2974
 	{
2980 2975
 		if ($_messageType === 'plain')
2981 2976
 		{
@@ -2983,7 +2978,7 @@  discard block
 block discarded – undo
2983 2978
 		}
2984 2979
 		else
2985 2980
 		{
2986
-			foreach(array('src','url','background') as $type)
2981
+			foreach (array('src', 'url', 'background') as $type)
2987 2982
 			{
2988 2983
 				$_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type);
2989 2984
 			}
@@ -3002,7 +2997,7 @@  discard block
 block discarded – undo
3002 2997
 	 *	- types: {plain|src|url|background}
3003 2998
 	 * @return string returns body content including all CID replacements
3004 2999
 	 */
3005
-	public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src')
3000
+	public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src')
3006 3001
 	{
3007 3002
 		/**
3008 3003
 		 * Callback for preg_replace_callback function
@@ -3014,7 +3009,7 @@  discard block
 block discarded – undo
3014 3009
 		 * @param string $_type
3015 3010
 		 * @return string|boolean returns the replace
3016 3011
 		*/
3017
-		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3012
+		$replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type)
3018 3013
 		{
3019 3014
 			if (!$_type)	return false;
3020 3015
 			$CID = '';
@@ -3036,11 +3031,11 @@  discard block
 block discarded – undo
3036 3031
 					break;
3037 3032
 			}
3038 3033
 
3039
-			static $cache = array();	// some caching, if mails containing the same image multiple times
3034
+			static $cache = array(); // some caching, if mails containing the same image multiple times
3040 3035
 
3041 3036
 			if (is_array($matches) && $CID)
3042 3037
 			{
3043
-				$linkData = array (
3038
+				$linkData = array(
3044 3039
 					'menuaction'    => 'mail.mail_ui.displayImage',
3045 3040
 					'uid'		=> $_uid,
3046 3041
 					'mailbox'	=> base64_encode($_mailbox),
@@ -3053,7 +3048,7 @@  discard block
 block discarded – undo
3053 3048
 				{
3054 3049
 					if (!isset($cache[$imageURL]))
3055 3050
 					{
3056
-						if ($_type !="background")
3051
+						if ($_type != "background")
3057 3052
 						{
3058 3053
 							$bo = emailadmin_imapbase::getInstance(false, mail_ui::$icServerID);
3059 3054
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
@@ -3094,16 +3089,16 @@  discard block
 block discarded – undo
3094 3089
 		};
3095 3090
 
3096 3091
 		// return new body content base on chosen type
3097
-		switch($_type)
3092
+		switch ($_type)
3098 3093
 		{
3099 3094
 			case"plain":
3100
-				return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body);
3095
+				return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body);
3101 3096
 			case "src":
3102
-				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3097
+				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3103 3098
 			case "url":
3104
-				return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body);
3099
+				return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body);
3105 3100
 			case "background":
3106
-				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3101
+				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3107 3102
 		}
3108 3103
 	}
3109 3104
 
@@ -3111,7 +3106,7 @@  discard block
 block discarded – undo
3111 3106
 	 * importMessage
3112 3107
 	 * @param array $content = null an array of content
3113 3108
 	 */
3114
-	function importMessage($content=null)
3109
+	function importMessage($content = null)
3115 3110
 	{
3116 3111
 		//error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder());
3117 3112
 
@@ -3133,7 +3128,7 @@  discard block
 block discarded – undo
3133 3128
 			}
3134 3129
 			$destination = $content['FOLDER'][0];
3135 3130
 
3136
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3131
+			if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2);
3137 3132
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3138 3133
 			{
3139 3134
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3144,32 +3139,31 @@  discard block
 block discarded – undo
3144 3139
 			$importFailed = false;
3145 3140
 			try
3146 3141
 			{
3147
-				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3148
-			    $linkData = array
3149
-			    (
3142
+				$messageUid = $this->importMessageToFolder($file, $destination, $importID);
3143
+			    $linkData = array(
3150 3144
 					'id' => $this->createRowID($destination, $messageUid, true),
3151 3145
 			    );
3152 3146
 			}
3153 3147
 			catch (egw_exception_wrong_userinput $e)
3154 3148
 			{
3155
-					$importFailed=true;
3156
-					$content['msg']		= $e->getMessage();
3149
+					$importFailed = true;
3150
+					$content['msg'] = $e->getMessage();
3157 3151
 			}
3158 3152
 			if (!$importFailed)
3159 3153
 			{
3160 3154
 				list($width, $height) = explode('x', egw_link::get_registry('mail', 'add_popup'));
3161 3155
 				if ($width > 0 && $height > 0) egw_json_response::get()->call('resizeTo', $width, $height);
3162
-				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3156
+				ExecMethod2('mail.mail_ui.displayMessage', $linkData);
3163 3157
 				return;
3164 3158
 			}
3165 3159
 		}
3166 3160
 		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);
3161
+		if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder();
3162
+		if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true);
3169 3163
 
3170 3164
 		$etpl = new etemplate_new('mail.importMessage');
3171
-		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
3172
-		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
3165
+		$etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport');
3166
+		$etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2);
3173 3167
 	}
3174 3168
 
3175 3169
 	/**
@@ -3181,7 +3175,7 @@  discard block
 block discarded – undo
3181 3175
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3182 3176
 	 * @return mixed $messageUID or exception
3183 3177
 	 */
3184
-	function importMessageToFolder($_formData,&$_folder,$importID='')
3178
+	function importMessageToFolder($_formData, &$_folder, $importID = '')
3185 3179
 	{
3186 3180
 		$importfailed = false;
3187 3181
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -3189,7 +3183,7 @@  discard block
 block discarded – undo
3189 3183
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3190 3184
 		try
3191 3185
 		{
3192
-			$tmpFileName = mail_bo::checkFileBasics($_formData,$importID);
3186
+			$tmpFileName = mail_bo::checkFileBasics($_formData, $importID);
3193 3187
 		}
3194 3188
 		catch (egw_exception_wrong_userinput $e)
3195 3189
 		{
@@ -3213,29 +3207,29 @@  discard block
 block discarded – undo
3213 3207
 			if (empty($_folder))
3214 3208
 			{
3215 3209
 				$importfailed = true;
3216
-				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3210
+				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']);
3217 3211
 			}
3218 3212
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3219
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3213
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
3220 3214
 			if ($importfailed === false)
3221 3215
 			{
3222
-				if ($this->mail_bo->folderExists($_folder,true)) {
3216
+				if ($this->mail_bo->folderExists($_folder, true)) {
3223 3217
 					try
3224 3218
 					{
3225 3219
 						$messageUid = $this->mail_bo->appendMessage($_folder,
3226 3220
 							$mailObject->getRaw(),
3227
-							null,'\\Seen');
3221
+							null, '\\Seen');
3228 3222
 					}
3229 3223
 					catch (egw_exception_wrong_userinput $e)
3230 3224
 					{
3231 3225
 						$importfailed = true;
3232
-						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
3226
+						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage());
3233 3227
 					}
3234 3228
 				}
3235 3229
 				else
3236 3230
 				{
3237 3231
 					$importfailed = true;
3238
-					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder);
3232
+					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder);
3239 3233
 				}
3240 3234
 			}
3241 3235
 		}
@@ -3261,9 +3255,9 @@  discard block
 block discarded – undo
3261 3255
 	 *								 $formData['size']	= 2136;
3262 3256
 	 * @return void
3263 3257
 	 */
3264
-	function importMessageFromVFS2DraftAndEdit($formData='')
3258
+	function importMessageFromVFS2DraftAndEdit($formData = '')
3265 3259
 	{
3266
-		$this->importMessageFromVFS2DraftAndDisplay($formData,'edit');
3260
+		$this->importMessageFromVFS2DraftAndDisplay($formData, 'edit');
3267 3261
 	}
3268 3262
 
3269 3263
 	/**
@@ -3278,7 +3272,7 @@  discard block
 block discarded – undo
3278 3272
 	 * @param string $mode mode to open ImportedMessage display and edit are supported
3279 3273
 	 * @return void
3280 3274
 	 */
3281
-	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3275
+	function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display')
3282 3276
 	{
3283 3277
 		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3284 3278
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
@@ -3291,43 +3285,42 @@  discard block
 block discarded – undo
3291 3285
 			$formData['file'] = 'egw-data://'.$formData['data'];
3292 3286
 		}
3293 3287
 		// name should be set to meet the requirements of checkFileBasics
3294
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3288
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3295 3289
 		{
3296
-			$buff = explode('/',$formData['file']);
3290
+			$buff = explode('/', $formData['file']);
3297 3291
 			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3298 3292
 		}
3299 3293
 		// type should be set to meet the requirements of checkFileBasics
3300
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3294
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3301 3295
 		{
3302
-			$buff = explode('.',$formData['file']);
3296
+			$buff = explode('.', $formData['file']);
3303 3297
 			$suffix = '';
3304 3298
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3305 3299
 			if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix);
3306 3300
 		}
3307 3301
 		// size should be set to meet the requirements of checkFileBasics
3308
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3302
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3309 3303
 		{
3310 3304
 			$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
3311 3305
 		}
3312 3306
 		try
3313 3307
 		{
3314
-			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3315
-			$linkData = array
3316
-			(
3317
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3318
-				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3308
+			$messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID);
3309
+			$linkData = array(
3310
+		        'menuaction'    => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'),
3311
+				'id'		=> $this->createRowID($draftFolder, $messageUid, true),
3319 3312
 				'deleteDraftOnClose' => 1,
3320 3313
 			);
3321
-			if ($mode!='display')
3314
+			if ($mode != 'display')
3322 3315
 			{
3323 3316
 				unset($linkData['deleteDraftOnClose']);
3324
-				$linkData['method']	='importMessageToMergeAndSend';
3317
+				$linkData['method'] = 'importMessageToMergeAndSend';
3325 3318
 			}
3326 3319
 			else
3327 3320
 			{
3328
-				$linkData['mode']=$mode;
3321
+				$linkData['mode'] = $mode;
3329 3322
 			}
3330
-			egw::redirect_link('/index.php',$linkData);
3323
+			egw::redirect_link('/index.php', $linkData);
3331 3324
 		}
3332 3325
 		catch (egw_exception_wrong_userinput $e)
3333 3326
 		{
@@ -3342,13 +3335,13 @@  discard block
 block discarded – undo
3342 3335
 	 *
3343 3336
 	 * @return xajax response
3344 3337
 	 */
3345
-	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3338
+	function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null)
3346 3339
 	{
3347 3340
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3348 3341
 		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3349 3342
 		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3350 3343
 		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3351
-		if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3344
+		if (mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions");
3352 3345
 		if (empty($_messageID)) return "";
3353 3346
 		$uidA = self::splitRowID($_messageID);
3354 3347
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -3362,7 +3355,7 @@  discard block
 block discarded – undo
3362 3355
 			$this->changeProfile($icServerID);
3363 3356
 		}
3364 3357
 
3365
-		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions);
3358
+		$bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions);
3366 3359
 		egw_session::cache_control(true);
3367 3360
 		//error_log(array2string($bodyResponse));
3368 3361
 		echo $bodyResponse;
@@ -3385,20 +3378,20 @@  discard block
 block discarded – undo
3385 3378
 			$oA = array();
3386 3379
 			foreach ($_folder as $_folderName)
3387 3380
 			{
3388
-				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3381
+				list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2);
3389 3382
 				if (is_numeric($profileID))
3390 3383
 				{
3391 3384
 					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
3392 3385
 					if ($folderName)
3393 3386
 					{
3394
-						$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3395
-						if (in_array($fS['shortDisplayName'],mail_bo::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3387
+						$fS = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3388
+						if (in_array($fS['shortDisplayName'], mail_bo::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']);
3396 3389
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3397 3390
 						if ($fS['unseen'])
3398 3391
 						{
3399 3392
 							$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
3400 3393
 						}
3401
-						if ($fS['unseen']==0 && $fS['shortDisplayName'])
3394
+						if ($fS['unseen'] == 0 && $fS['shortDisplayName'])
3402 3395
 						{
3403 3396
 							$oA[$_folderName] = $fS['shortDisplayName'];
3404 3397
 						}
@@ -3409,7 +3402,7 @@  discard block
 block discarded – undo
3409 3402
 			if ($oA)
3410 3403
 			{
3411 3404
 				$response = egw_json_response::get();
3412
-				$response->call('app.mail.mail_setFolderStatus',$oA);
3405
+				$response->call('app.mail.mail_setFolderStatus', $oA);
3413 3406
 			}
3414 3407
 		}
3415 3408
 	}
@@ -3423,14 +3416,14 @@  discard block
 block discarded – undo
3423 3416
 	function ajax_addFolder($_parentFolderName, $_newName)
3424 3417
 	{
3425 3418
 		//error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName));
3426
-		$errorMessage='';
3419
+		$errorMessage = '';
3427 3420
 		if ($_parentFolderName)
3428 3421
 		{
3429 3422
 			$created = false;
3430 3423
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName);
3431 3424
 			//the conversion is handeled by horde, frontend interaction is all utf-8
3432 3425
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3433
-			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3426
+			list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2);
3434 3427
 			if (is_numeric($profileID))
3435 3428
 			{
3436 3429
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
@@ -3470,10 +3463,10 @@  discard block
 block discarded – undo
3470 3463
 
3471 3464
 				if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false);
3472 3465
 				*/
3473
-				$nA = explode($del,$_newName);
3466
+				$nA = explode($del, $_newName);
3474 3467
 
3475 3468
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3476
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3469
+				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false);
3477 3470
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3478 3471
 
3479 3472
 				$this->mail_bo->reopen('INBOX');
@@ -3481,11 +3474,11 @@  discard block
 block discarded – undo
3481 3474
 				// if newName has delimiter ($del) in it, we need to create the subtree
3482 3475
 				if (!empty($nA))
3483 3476
 				{
3484
-					$c=0;
3485
-					foreach($nA as $sTName)
3477
+					$c = 0;
3478
+					foreach ($nA as $sTName)
3486 3479
 					{
3487
-						$error=null;
3488
-						if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3480
+						$error = null;
3481
+						if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3489 3482
 						{
3490 3483
 							$c++;
3491 3484
 						}
@@ -3494,16 +3487,16 @@  discard block
 block discarded – undo
3494 3487
 							$errorMessage .= $error;
3495 3488
 						}
3496 3489
 					}
3497
-					if ($c==count($nA)) $created=true;
3490
+					if ($c == count($nA)) $created = true;
3498 3491
 				}
3499 3492
 				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3500 3493
 			}
3501 3494
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3502
-			if ($created===true)
3495
+			if ($created === true)
3503 3496
 			{
3504 3497
 				$this->mail_bo->resetFolderObjectCache($profileID);
3505 3498
 				$response = egw_json_response::get();
3506
-				if ( $oldFolderInfo['shortDisplayName'])
3499
+				if ($oldFolderInfo['shortDisplayName'])
3507 3500
 				{
3508 3501
 					$nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']);
3509 3502
 				}
@@ -3511,14 +3504,14 @@  discard block
 block discarded – undo
3511 3504
 				{
3512 3505
 					$nodeInfo = array($profileID=>lang('INBOX'));
3513 3506
 				}
3514
-				$response->call('app.mail.mail_reloadNode',$nodeInfo);
3507
+				$response->call('app.mail.mail_reloadNode', $nodeInfo);
3515 3508
 			}
3516 3509
 			else
3517 3510
 			{
3518 3511
 				if ($errorMessage)
3519 3512
 				{
3520 3513
 					$response = egw_json_response::get();
3521
-					$response->call('egw.message',$errorMessage);
3514
+					$response->call('egw.message', $errorMessage);
3522 3515
 				}
3523 3516
 			}
3524 3517
 		}
@@ -3540,22 +3533,22 @@  discard block
 block discarded – undo
3540 3533
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3541 3534
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3542 3535
 			$oA = array();
3543
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3536
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3544 3537
 			$hasChildren = false;
3545 3538
 			if (is_numeric($profileID))
3546 3539
 			{
3547 3540
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
3548
-				$pA = explode($del,$folderName);
3541
+				$pA = explode($del, $folderName);
3549 3542
 				array_pop($pA);
3550
-				$parentFolder = implode($del,$pA);
3551
-				if (strtoupper($folderName)!= 'INBOX')
3543
+				$parentFolder = implode($del, $pA);
3544
+				if (strtoupper($folderName) != 'INBOX')
3552 3545
 				{
3553 3546
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3554
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false);
3547
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false);
3555 3548
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3556
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3549
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3557 3550
 					{
3558
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3551
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3559 3552
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3560 3553
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3561 3554
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3572,7 +3565,7 @@  discard block
 block discarded – undo
3572 3565
 							else
3573 3566
 							{
3574 3567
 								$rv = $this->mail_bo->icServer->subscribeMailbox($folder, false);
3575
-								$fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName));
3568
+								$fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName));
3576 3569
 							}
3577 3570
 						}
3578 3571
 						//error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments));
@@ -3582,7 +3575,7 @@  discard block
 block discarded – undo
3582 3575
 					$success = false;
3583 3576
 					try
3584 3577
 					{
3585
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3578
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3586 3579
 						{
3587 3580
 							$this->mail_bo->resetFolderObjectCache($profileID);
3588 3581
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3593,11 +3586,11 @@  discard block
 block discarded – undo
3593 3586
 					}
3594 3587
 					catch (Exception $e)
3595 3588
 					{
3596
-						$newFolderName=$folderName;
3589
+						$newFolderName = $folderName;
3597 3590
 						$msg = $e->getMessage();
3598 3591
 					}
3599 3592
 					$this->mail_bo->reopen($newFolderName);
3600
-					$fS = $this->mail_bo->getFolderStatus($newFolderName,false);
3593
+					$fS = $this->mail_bo->getFolderStatus($newFolderName, false);
3601 3594
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3602 3595
 					if ($hasChildren)
3603 3596
 					{
@@ -3628,12 +3621,12 @@  discard block
 block discarded – undo
3628 3621
 					{
3629 3622
 						$oA[$_folderName]['desc'] = $fS['shortDisplayName'];
3630 3623
 					}
3631
-					foreach($fragments as $oldFolderName => $fragment)
3624
+					foreach ($fragments as $oldFolderName => $fragment)
3632 3625
 					{
3633 3626
 						//error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment);
3634 3627
 						$oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment;
3635 3628
 						$oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#';
3636
-						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
3629
+						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false);
3637 3630
 						if ($fS['unseen'])
3638 3631
 						{
3639 3632
 							$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
@@ -3646,20 +3639,20 @@  discard block
 block discarded – undo
3646 3639
 					}
3647 3640
 				}
3648 3641
 			}
3649
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
3642
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
3650 3643
 			{
3651
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
3644
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
3652 3645
 				$this->mail_bo->saveSessionData();
3653 3646
 			}
3654 3647
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3655 3648
 			$response = egw_json_response::get();
3656 3649
 			if ($oA && $success)
3657 3650
 			{
3658
-				$response->call('app.mail.mail_setLeaf',$oA);
3651
+				$response->call('app.mail.mail_setLeaf', $oA);
3659 3652
 			}
3660 3653
 			else
3661 3654
 			{
3662
-				$response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail');
3655
+				$response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail');
3663 3656
 			}
3664 3657
 		}
3665 3658
 	}
@@ -3671,7 +3664,7 @@  discard block
 block discarded – undo
3671 3664
 	 * @param boolean $_subscribedOnly = true
3672 3665
 	 * @return void
3673 3666
 	 */
3674
-	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
3667
+	function ajax_reloadNode($_folderName, $_subscribedOnly = true)
3675 3668
 	{
3676 3669
 		translation::add_app('mail');
3677 3670
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
@@ -3682,20 +3675,20 @@  discard block
 block discarded – undo
3682 3675
 
3683 3676
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3684 3677
 		$this->mail_bo->getHierarchyDelimiter(false);
3685
-		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3678
+		list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3686 3679
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3687 3680
 		// that we get what we request
3688 3681
 		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3689 3682
 		if ($profileID != $this->mail_bo->profileID) return; // only current connection
3690 3683
 		if (!empty($folderName))
3691 3684
 		{
3692
-			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
3693
-			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3685
+			$parentFolder = (!empty($folderName) ? $folderName : 'INBOX');
3686
+			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3694 3687
 			if ($folderInfo['unseen'])
3695 3688
 			{
3696 3689
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')';
3697 3690
 			}
3698
-			if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName'])
3691
+			if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName'])
3699 3692
 			{
3700 3693
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'];
3701 3694
 			}
@@ -3711,11 +3704,11 @@  discard block
 block discarded – undo
3711 3704
 		}
3712 3705
 		// Send full info back in the response
3713 3706
 		$response = egw_json_response::get();
3714
-		foreach($refreshData as $folder => &$name)
3707
+		foreach ($refreshData as $folder => &$name)
3715 3708
 		{
3716
-			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
3709
+			$name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true);
3717 3710
 		}
3718
-		$response->call('app.mail.mail_reloadNode',$refreshData);
3711
+		$response->call('app.mail.mail_reloadNode', $refreshData);
3719 3712
 
3720 3713
 	}
3721 3714
 
@@ -3731,7 +3724,7 @@  discard block
 block discarded – undo
3731 3724
 	 * @param type $_rowid row id from nm
3732 3725
 	 *
3733 3726
 	 */
3734
-	function ajax_resolveWinmail ($_rowid)
3727
+	function ajax_resolveWinmail($_rowid)
3735 3728
 	{
3736 3729
 		$response = egw_json_response::get();
3737 3730
 
@@ -3739,7 +3732,7 @@  discard block
 block discarded – undo
3739 3732
 		$uid = $idParts['msgUID'];
3740 3733
 		$mbox = $idParts['folder'];
3741 3734
 
3742
-		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
3735
+		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox);
3743 3736
 		if (is_array($attachments))
3744 3737
 		{
3745 3738
 			$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
@@ -3767,30 +3760,30 @@  discard block
 block discarded – undo
3767 3760
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3768 3761
 			$_newLocation = $this->mail_bo->decodeEntityFolderName($_target);
3769 3762
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3770
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3771
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation,2);
3763
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3764
+			list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation, 2);
3772 3765
 			$hasChildren = false;
3773 3766
 			if (is_numeric($profileID))
3774 3767
 			{
3775 3768
 				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
3776
-				$pA = explode($del,$folderName);
3769
+				$pA = explode($del, $folderName);
3777 3770
 				$namePart = array_pop($pA);
3778 3771
 				$_newName = $namePart;
3779
-				$oldParentFolder = implode($del,$pA);
3772
+				$oldParentFolder = implode($del, $pA);
3780 3773
 				$parentFolder = $_newLocation;
3781 3774
 
3782
-				if (strtoupper($folderName)!= 'INBOX' &&
3775
+				if (strtoupper($folderName) != 'INBOX' &&
3783 3776
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3784 3777
 					(($oldParentFolder != $parentFolder &&
3785
-					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3786
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
3778
+					strlen($parentFolder) > 0 && strlen($folderName) > 0 &&
3779
+					strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch
3787 3780
 				{
3788 3781
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3789
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3782
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3790 3783
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3791
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3784
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3792 3785
 					{
3793
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3786
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3794 3787
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3795 3788
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3796 3789
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3815,7 +3808,7 @@  discard block
 block discarded – undo
3815 3808
 					$success = false;
3816 3809
 					try
3817 3810
 					{
3818
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3811
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3819 3812
 						{
3820 3813
 							$this->mail_bo->resetFolderObjectCache($profileID);
3821 3814
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3827,11 +3820,11 @@  discard block
 block discarded – undo
3827 3820
 					}
3828 3821
 					catch (Exception $e)
3829 3822
 					{
3830
-						$newFolderName=$folderName;
3823
+						$newFolderName = $folderName;
3831 3824
 						$msg = $e->getMessage();
3832 3825
 					}
3833 3826
 					$this->mail_bo->reopen($parentFolder);
3834
-					$this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3827
+					$this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3835 3828
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3836 3829
 					if ($hasChildren)
3837 3830
 					{
@@ -3852,9 +3845,9 @@  discard block
 block discarded – undo
3852 3845
 					}
3853 3846
 				}
3854 3847
 			}
3855
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
3848
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
3856 3849
 			{
3857
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
3850
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
3858 3851
 				$this->mail_bo->saveSessionData();
3859 3852
 			}
3860 3853
 			//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -3863,26 +3856,26 @@  discard block
 block discarded – undo
3863 3856
 			{
3864 3857
 				translation::add_app('mail');
3865 3858
 
3866
-				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
3867
-				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3859
+				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false);
3860
+				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3868 3861
 				$refreshData = array(
3869 3862
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
3870 3863
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
3871 3864
 				// 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]);
3865
+				if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
3866
+				if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
3874 3867
 
3875 3868
 				// Send full info back in the response
3876
-				foreach($refreshData as $folder => &$name)
3869
+				foreach ($refreshData as $folder => &$name)
3877 3870
 				{
3878
-					$name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true);
3871
+					$name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true);
3879 3872
 				}
3880
-				$response->call('app.mail.mail_reloadNode',$refreshData);
3873
+				$response->call('app.mail.mail_reloadNode', $refreshData);
3881 3874
 
3882 3875
 			}
3883 3876
 			else
3884 3877
 			{
3885
-				$response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail');
3878
+				$response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail');
3886 3879
 			}
3887 3880
 		}
3888 3881
 	}
@@ -3902,23 +3895,23 @@  discard block
 block discarded – undo
3902 3895
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3903 3896
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3904 3897
 			$oA = array();
3905
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3898
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3906 3899
 			$hasChildren = false;
3907 3900
 			if (is_numeric($profileID))
3908 3901
 			{
3909 3902
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
3910
-				$pA = explode($del,$folderName);
3903
+				$pA = explode($del, $folderName);
3911 3904
 				array_pop($pA);
3912
-				if (strtoupper($folderName)!= 'INBOX')
3905
+				if (strtoupper($folderName) != 'INBOX')
3913 3906
 				{
3914 3907
 					//error_log(__METHOD__.__LINE__."$folderName,  implode($del,$pA), $_newName");
3915 3908
 					$oA = array();
3916 3909
 					$subFolders = array();
3917
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3910
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3918 3911
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3919
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3912
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3920 3913
 					{
3921
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3914
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3922 3915
 						$ftD = array();
3923 3916
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3924 3917
 						$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -3928,24 +3921,24 @@  discard block
 block discarded – undo
3928 3921
 						//error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix");
3929 3922
 						foreach ($subFolders as $k => $f)
3930 3923
 						{
3931
-							$ftD[substr_count($f,$delimiter)][]=$f;
3924
+							$ftD[substr_count($f, $delimiter)][] = $f;
3932 3925
 						}
3933
-						krsort($ftD,SORT_NUMERIC);//sort per level
3926
+						krsort($ftD, SORT_NUMERIC); //sort per level
3934 3927
 						//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
3928
+						foreach ($ftD as $k => $lc)//collection per level
3936 3929
 						{
3937
-							foreach($lc as $i => $f)//folders contained in that level
3930
+							foreach ($lc as $i => $f)//folders contained in that level
3938 3931
 							{
3939 3932
 								try
3940 3933
 								{
3941 3934
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
3942 3935
 									$this->mail_bo->deleteFolder($f);
3943 3936
 									$success = true;
3944
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
3937
+									if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
3945 3938
 								}
3946 3939
 								catch (Exception $e)
3947 3940
 								{
3948
-									$msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage();
3941
+									$msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage();
3949 3942
 									$success = false;
3950 3943
 								}
3951 3944
 							}
@@ -3976,11 +3969,11 @@  discard block
 block discarded – undo
3976 3969
 			if ($success)
3977 3970
 			{
3978 3971
 				//error_log(__METHOD__.__LINE__.array2string($oA));
3979
-				$response->call('app.mail.mail_removeLeaf',$oA);
3972
+				$response->call('app.mail.mail_removeLeaf', $oA);
3980 3973
 			}
3981 3974
 			else
3982 3975
 			{
3983
-				$response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail');
3976
+				$response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail');
3984 3977
 			}
3985 3978
 		}
3986 3979
 	}
@@ -3994,7 +3987,7 @@  discard block
 block discarded – undo
3994 3987
 	 * @param bool $getFolders The client needs the folders for the profile
3995 3988
 	 * @return nothing
3996 3989
 	 */
3997
-	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
3990
+	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null)
3998 3991
 	{
3999 3992
 		$response = egw_json_response::get();
4000 3993
 
@@ -4002,7 +3995,7 @@  discard block
 block discarded – undo
4002 3995
 
4003 3996
 		if ($icServerID && $icServerID != $previous_id)
4004 3997
 		{
4005
-			$mail_ui = new mail_ui(false);	// do NOT run constructor, as we call changeProfile anyway
3998
+			$mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway
4006 3999
 			try
4007 4000
 			{
4008 4001
 				$mail_ui->changeProfile($icServerID);
@@ -4018,23 +4011,23 @@  discard block
 block discarded – undo
4018 4011
 				}
4019 4012
 			}
4020 4013
 			catch (Exception $e) {
4021
-				self::callWizard($e->getMessage(),true, 'error');
4014
+				self::callWizard($e->getMessage(), true, 'error');
4022 4015
 			}
4023 4016
 		}
4024 4017
 		else
4025 4018
 		{
4026
-			$mail_ui = new mail_ui(true);	// run constructor
4019
+			$mail_ui = new mail_ui(true); // run constructor
4027 4020
 		}
4028 4021
 
4029 4022
 		// Send full info back in the response
4030
-		if($getFolders)
4023
+		if ($getFolders)
4031 4024
 		{
4032 4025
 			translation::add_app('mail');
4033 4026
 
4034 4027
 			$refreshData = array(
4035
-				$icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4028
+				$icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4036 4029
 			);
4037
-			$response->call('app.mail.mail_reloadNode',$refreshData);
4030
+			$response->call('app.mail.mail_reloadNode', $refreshData);
4038 4031
 		}
4039 4032
 	}
4040 4033
 
@@ -4045,7 +4038,7 @@  discard block
 block discarded – undo
4045 4038
 	 *						if other than active profile; nothing is done!
4046 4039
 	 * @return nothing
4047 4040
 	 */
4048
-	public static function ajax_refreshVacationNotice($icServerID=null)
4041
+	public static function ajax_refreshVacationNotice($icServerID = null)
4049 4042
 	{
4050 4043
 		//Get vacation from cache if it's available
4051 4044
 		$cachedVacations = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
@@ -4062,22 +4055,22 @@  discard block
 block discarded – undo
4062 4055
 			$vacation = $mail->gatherVacation($cachedVacations);
4063 4056
 		}
4064 4057
 
4065
-		if($vacation) {
4066
-			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4058
+		if ($vacation) {
4059
+			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date'))
4067 4060
 			{
4068 4061
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4069 4062
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4070
-				$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 = '';
4063
+				$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) : '') : '');
4064
+				if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = '';
4072 4065
 			}
4073 4066
 		}
4074
-		if ($vacation==false)
4067
+		if ($vacation == false)
4075 4068
 		{
4076
-			$refreshData['vacationnotice'] =  '';
4077
-			$refreshData['vacationrange'] =  '';
4069
+			$refreshData['vacationnotice'] = '';
4070
+			$refreshData['vacationrange'] = '';
4078 4071
 		}
4079 4072
 		$response = egw_json_response::get();
4080
-		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
4073
+		$response->call('app.mail.mail_refreshVacationNotice', $refreshData);
4081 4074
 	}
4082 4075
 
4083 4076
 	/**
@@ -4087,41 +4080,41 @@  discard block
 block discarded – undo
4087 4080
 	 *						if other than active profile; nothing is done!
4088 4081
 	 * @return nothing
4089 4082
 	 */
4090
-	function ajax_refreshFilters($icServerID=null)
4083
+	function ajax_refreshFilters($icServerID = null)
4091 4084
 	{
4092 4085
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4093 4086
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4094 4087
 		if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4095 4088
 		{
4096
-			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;
4089
+			emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4090
+			if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true;
4098 4091
 		}
4099 4092
 		if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])
4100 4093
 		{
4101 4094
 			unset($this->searchTypes['quick']);
4102 4095
 		}
4103
-		if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4096
+		if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4104 4097
 		{
4105
-			$this->statusTypes = array_merge($this->statusTypes,array(
4106
-				'keyword1'	=> 'important',//lang('important'),
4107
-				'keyword2'	=> 'job',	//lang('job'),
4108
-				'keyword3'	=> 'personal',//lang('personal'),
4109
-				'keyword4'	=> 'to do',	//lang('to do'),
4110
-				'keyword5'	=> 'later',	//lang('later'),
4098
+			$this->statusTypes = array_merge($this->statusTypes, array(
4099
+				'keyword1'	=> 'important', //lang('important'),
4100
+				'keyword2'	=> 'job', //lang('job'),
4101
+				'keyword3'	=> 'personal', //lang('personal'),
4102
+				'keyword4'	=> 'to do', //lang('to do'),
4103
+				'keyword5'	=> 'later', //lang('later'),
4111 4104
 			));
4112 4105
 		}
4113 4106
 		else
4114 4107
 		{
4115
-			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4116
-			foreach($keywords as &$k)
4108
+			$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
4109
+			foreach ($keywords as &$k)
4117 4110
 			{
4118
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4111
+				if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
4119 4112
 			}
4120 4113
 		}
4121 4114
 
4122 4115
 		$response = egw_json_response::get();
4123
-		$response->call('app.mail.mail_refreshFilter2Options',$this->searchTypes);
4124
-		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
4116
+		$response->call('app.mail.mail_refreshFilter2Options', $this->searchTypes);
4117
+		$response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes);
4125 4118
 
4126 4119
 	}
4127 4120
 
@@ -4130,7 +4123,7 @@  discard block
 block discarded – undo
4130 4123
 	 *
4131 4124
 	 * @return nothing
4132 4125
 	 */
4133
-	function ajax_refreshQuotaDisplay($icServerID=null)
4126
+	function ajax_refreshQuotaDisplay($icServerID = null)
4134 4127
 	{
4135 4128
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4136 4129
 		translation::add_app('mail');
@@ -4149,10 +4142,10 @@  discard block
 block discarded – undo
4149 4142
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4150 4143
 		}
4151 4144
 
4152
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4145
+		if ($quota !== false && $quota['limit'] != 'NOT SET') {
4153 4146
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4154 4147
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4155
-			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4148
+			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
4156 4149
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4157 4150
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4158 4151
 		} else {
@@ -4166,7 +4159,7 @@  discard block
 block discarded – undo
4166 4159
 			$this->changeProfile($rememberServerID);
4167 4160
 		}
4168 4161
 		$response = egw_json_response::get();
4169
-		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
4162
+		$response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content));
4170 4163
 	}
4171 4164
 
4172 4165
 	/**
@@ -4188,34 +4181,34 @@  discard block
 block discarded – undo
4188 4181
 			$this->changeProfile($icServerID);
4189 4182
 		}
4190 4183
 		$junkFolder = $this->mail_bo->getJunkFolder();
4191
-		if(!empty($junkFolder)) {
4184
+		if (!empty($junkFolder)) {
4192 4185
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4193 4186
 			{
4194 4187
 				// Lock the tree if the active folder is junk folder
4195 4188
 				$response->call('app.mail.lock_tree');
4196 4189
 			}
4197
-			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4190
+			$this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately');
4198 4191
 
4199 4192
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4200
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4193
+			$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
4201 4194
 			$fStatus = array(
4202 4195
 				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4203 4196
 			);
4204 4197
 			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4205 4198
 			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4206
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4199
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4207 4200
 		}
4208 4201
 		if ($rememberServerID != $this->mail_bo->profileID)
4209 4202
 		{
4210
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4211
-			$response->call('egw.message',lang('empty junk'));
4212
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4203
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false);
4204
+			$response->call('egw.message', lang('empty junk'));
4205
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4213 4206
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4214 4207
 			$this->changeProfile($rememberServerID);
4215 4208
 		}
4216 4209
 		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4217 4210
 		{
4218
-			$response->call('egw.refresh',lang('empty junk'),'mail');
4211
+			$response->call('egw.refresh', lang('empty junk'), 'mail');
4219 4212
 		}
4220 4213
 	}
4221 4214
 
@@ -4238,7 +4231,7 @@  discard block
 block discarded – undo
4238 4231
 			$this->changeProfile($icServerID);
4239 4232
 		}
4240 4233
 		$trashFolder = $this->mail_bo->getTrashFolder();
4241
-		if(!empty($trashFolder)) {
4234
+		if (!empty($trashFolder)) {
4242 4235
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4243 4236
 			{
4244 4237
 				// Lock the tree if the active folder is Trash folder
@@ -4247,25 +4240,25 @@  discard block
 block discarded – undo
4247 4240
 			$this->mail_bo->compressFolder($trashFolder);
4248 4241
 
4249 4242
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4250
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4243
+			$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
4251 4244
 			$fStatus = array(
4252 4245
 				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4253 4246
 			);
4254 4247
 			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4255 4248
 			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4256
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4249
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4257 4250
 		}
4258 4251
 		if ($rememberServerID != $this->mail_bo->profileID)
4259 4252
 		{
4260
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4261
-			$response->call('egw.message',lang('empty trash'));
4262
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4253
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false);
4254
+			$response->call('egw.message', lang('empty trash'));
4255
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4263 4256
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4264 4257
 			$this->changeProfile($rememberServerID);
4265 4258
 		}
4266 4259
 		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4267 4260
 		{
4268
-			$response->call('egw.refresh',lang('empty trash'),'mail');
4261
+			$response->call('egw.refresh', lang('empty trash'), 'mail');
4269 4262
 		}
4270 4263
 	}
4271 4264
 
@@ -4282,7 +4275,7 @@  discard block
 block discarded – undo
4282 4275
 
4283 4276
 		$this->mail_bo->restoreSessionData();
4284 4277
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4285
-		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4278
+		list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4286 4279
 
4287 4280
 		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4288 4281
 		if ($this->mail_bo->folderExists($folderName))
@@ -4293,7 +4286,7 @@  discard block
 block discarded – undo
4293 4286
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4294 4287
 				$this->changeProfile($icServerID);
4295 4288
 			}
4296
-			if(!empty($_folderName)) {
4289
+			if (!empty($_folderName)) {
4297 4290
 				$this->mail_bo->compressFolder($folderName);
4298 4291
 			}
4299 4292
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4302,7 +4295,7 @@  discard block
 block discarded – undo
4302 4295
 				$this->changeProfile($rememberServerID);
4303 4296
 			}
4304 4297
 			$response = egw_json_response::get();
4305
-			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
4298
+			$response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail');
4306 4299
 		}
4307 4300
 	}
4308 4301
 
@@ -4315,10 +4308,10 @@  discard block
 block discarded – undo
4315 4308
 	 */
4316 4309
 	function ajax_sendMDN($_messageList)
4317 4310
 	{
4318
-		if(mail_bo::$debug) error_log(__METHOD__."->".array2string($_messageList));
4311
+		if (mail_bo::$debug) error_log(__METHOD__."->".array2string($_messageList));
4319 4312
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4320 4313
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4321
-		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
4314
+		$this->mail_bo->sendMDN($uidA['msgUID'], $folder);
4322 4315
 	}
4323 4316
 
4324 4317
 	/**
@@ -4330,14 +4323,14 @@  discard block
 block discarded – undo
4330 4323
 	 *
4331 4324
 	 * @return xajax response
4332 4325
 	 */
4333
-	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4326
+	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true)
4334 4327
 	{
4335
-		if(mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4328
+		if (mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4336 4329
 		translation::add_app('mail');
4337
-		$alreadyFlagged=false;
4338
-		$flag2check='';
4330
+		$alreadyFlagged = false;
4331
+		$flag2check = '';
4339 4332
 		$filter2toggle = $query = array();
4340
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4333
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4341 4334
 		{
4342 4335
 			if (isset($_messageList['all']) && $_messageList['all'])
4343 4336
 			{
@@ -4352,10 +4345,10 @@  discard block
 block discarded – undo
4352 4345
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4353 4346
 						if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4354 4347
 						{
4355
-							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;
4348
+							emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4349
+							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true;
4357 4350
 						}
4358
-						$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');
4351
+						$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 4352
 					}
4360 4353
 					else
4361 4354
 					{
@@ -4364,70 +4357,70 @@  discard block
 block discarded – undo
4364 4357
 					// flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder
4365 4358
 					// should be affected serverside. here.
4366 4359
 					$messageList = $messageListForToggle = array();
4367
-					$flag2check = ($_flag=='read'?'seen':$_flag);
4368
-					if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4369
-						!($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))
4360
+					$flag2check = ($_flag == 'read' ? 'seen' : $_flag);
4361
+					if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4362
+						!($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))
4370 4363
 					{
4371 4364
 						$filter2toggle['status'] = array('un'.$_flag);
4372
-						if ($query['filter'] && $query['filter']!='any')
4365
+						if ($query['filter'] && $query['filter'] != 'any')
4373 4366
 						{
4374 4367
 							$filter2toggle['status'][] = $query['filter'];
4375 4368
 						}
4376 4369
 						$_sRt = $this->mail_bo->getSortedList(
4377 4370
 							$folder,
4378
-							$sort=0,
4379
-							$reverse=1,
4371
+							$sort = 0,
4372
+							$reverse = 1,
4380 4373
 							$filter2toggle,
4381
-							$rByUid=true,
4374
+							$rByUid = true,
4382 4375
 							false
4383 4376
 						);
4384 4377
 						$messageListForToggle = $_sRt['match']->ids;
4385 4378
 						$filter['status'] = array($_flag);
4386
-						if ($query['filter'] && $query['filter'] !='any')
4379
+						if ($query['filter'] && $query['filter'] != 'any')
4387 4380
 						{
4388 4381
 							$filter['status'][] = $query['filter'];
4389 4382
 						}
4390 4383
 						$_sR = $this->mail_bo->getSortedList(
4391 4384
 							$folder,
4392
-							$sort=0,
4393
-							$reverse=1,
4385
+							$sort = 0,
4386
+							$reverse = 1,
4394 4387
 							$filter,
4395
-							$rByUid=true,
4388
+							$rByUid = true,
4396 4389
 							false
4397 4390
 						);
4398 4391
 						$messageList = $_sR['match']->ids;
4399
-						if (count($messageListForToggle)>0)
4392
+						if (count($messageListForToggle) > 0)
4400 4393
 						{
4401 4394
 							$flag2set = (strtolower($_flag));
4402
-							if(mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4403
-							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4395
+							if (mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4396
+							$this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder);
4404 4397
 						}
4405
-						if (count($messageList)>0)
4398
+						if (count($messageList) > 0)
4406 4399
 						{
4407 4400
 							$flag2set = 'un'.$_flag;
4408
-							if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4409
-							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4401
+							if (mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4402
+							$this->mail_bo->flagMessages($flag2set, $messageList, $folder);
4410 4403
 						}
4411
-						$alreadyFlagged=true;
4404
+						$alreadyFlagged = true;
4412 4405
 					}
4413 4406
 					elseif (!empty($filter) &&
4414
-						(!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) ||
4415
-						(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4416
-						($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
4407
+						(!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) ||
4408
+						(in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4409
+						($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))))
4417 4410
 					{
4418
-						if ($query['filter'] && $query['filter'] !='any')
4411
+						if ($query['filter'] && $query['filter'] != 'any')
4419 4412
 						{
4420 4413
 							$filter['status'] = $query['filter'];
4421 4414
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4422
-							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4415
+							$_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag)));
4423 4416
 						}
4424
-						if(mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4417
+						if (mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4425 4418
 						$_sR = $this->mail_bo->getSortedList(
4426 4419
 							$folder,
4427
-							$sort=0,
4428
-							$reverse=1,
4420
+							$sort = 0,
4421
+							$reverse = 1,
4429 4422
 							$filter,
4430
-							$rByUid=true,
4423
+							$rByUid = true,
4431 4424
 							false
4432 4425
 						);
4433 4426
 						$messageList = $_sR['match']->ids;
@@ -4436,8 +4429,8 @@  discard block
 block discarded – undo
4436 4429
 					}
4437 4430
 					else
4438 4431
 					{
4439
-						if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4440
-						$alreadyFlagged=true;
4432
+						if (mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4433
+						$alreadyFlagged = true;
4441 4434
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4442 4435
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4443 4436
 						$this->mail_bo->flagMessages($_flag, 'all', $folder);
@@ -4451,41 +4444,41 @@  discard block
 block discarded – undo
4451 4444
 			}
4452 4445
 			if (!$alreadyFlagged)
4453 4446
 			{
4454
-				foreach($_messageList['msg'] as $rowID)
4447
+				foreach ($_messageList['msg'] as $rowID)
4455 4448
 				{
4456 4449
 					$hA = self::splitRowID($rowID);
4457 4450
 					$messageList[] = $hA['msgUID'];
4458 4451
 				}
4459
-				if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
4460
-				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4452
+				if (mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList)));
4453
+				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder);
4461 4454
 			}
4462 4455
 		}
4463 4456
 		else
4464 4457
 		{
4465
-			if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
4458
+			if (mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
4466 4459
 		}
4467 4460
 
4468 4461
 		if ($_sendJsonResponse)
4469 4462
 		{
4470
-			$flag=array(
4471
-				'label1'	=> 'important',//lang('important'),
4472
-				'label2'	=> 'job',	//lang('job'),
4473
-				'label3'	=> 'personal',//lang('personal'),
4474
-				'label4'	=> 'to do',	//lang('to do'),
4475
-				'label5'	=> 'later',	//lang('later'),
4463
+			$flag = array(
4464
+				'label1'	=> 'important', //lang('important'),
4465
+				'label2'	=> 'job', //lang('job'),
4466
+				'label3'	=> 'personal', //lang('personal'),
4467
+				'label4'	=> 'to do', //lang('to do'),
4468
+				'label5'	=> 'later', //lang('later'),
4476 4469
 			);
4477 4470
 			$response = egw_json_response::get();
4478 4471
 			if (isset($_messageList['msg']) && $_messageList['popup'])
4479 4472
 			{
4480
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update');
4473
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', $_messageList['msg'], lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail', $_messageList['msg'], 'update');
4481 4474
 			}
4482
-			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
4475
+			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))
4483 4476
 			{
4484
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail');
4477
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail');
4485 4478
 			}
4486 4479
 			else
4487 4480
 			{
4488
-				$response->call('egw.message',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder));
4481
+				$response->call('egw.message', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder));
4489 4482
 			}
4490 4483
 		}
4491 4484
 	}
@@ -4497,12 +4490,12 @@  discard block
 block discarded – undo
4497 4490
 	 * @param string _forceDeleteMethod - method of deletion to be enforced
4498 4491
 	 * @return xajax response
4499 4492
 	 */
4500
-	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4493
+	function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null)
4501 4494
 	{
4502
-		if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
4495
+		if (mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod);
4503 4496
 		$error = null;
4504
-		$filtered =  false;
4505
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4497
+		$filtered = false;
4498
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4506 4499
 		{
4507 4500
 			if (isset($_messageList['all']) && $_messageList['all'])
4508 4501
 			{
@@ -4517,11 +4510,11 @@  discard block
 block discarded – undo
4517 4510
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4518 4511
 						if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4519 4512
 						{
4520
-							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;
4513
+							emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4514
+							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true;
4522 4515
 						}
4523
-						$filtered =  true;
4524
-						$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'));
4516
+						$filtered = true;
4517
+						$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'));
4525 4518
 					}
4526 4519
 					else
4527 4520
 					{
@@ -4533,7 +4526,7 @@  discard block
 block discarded – undo
4533 4526
 					$rByUid = true;
4534 4527
 					$_sR = $this->mail_bo->getSortedList(
4535 4528
 						$folder,
4536
-						$sort=0,
4529
+						$sort = 0,
4537 4530
 						$reverse,
4538 4531
 						$filter,
4539 4532
 						$rByUid,
@@ -4543,23 +4536,23 @@  discard block
 block discarded – undo
4543 4536
 				}
4544 4537
 				else
4545 4538
 				{
4546
-					$messageList='all';
4539
+					$messageList = 'all';
4547 4540
 				}
4548 4541
 				try
4549 4542
 				{
4550 4543
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4551
-					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4544
+					$this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4552 4545
 				}
4553 4546
 				catch (egw_exception $e)
4554 4547
 				{
4555
-					$error = str_replace('"',"'",$e->getMessage());
4548
+					$error = str_replace('"', "'", $e->getMessage());
4556 4549
 				}
4557 4550
 			}
4558 4551
 			else
4559 4552
 			{
4560 4553
 				$uidA = self::splitRowID($_messageList['msg'][0]);
4561 4554
 				$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4562
-				foreach($_messageList['msg'] as $rowID)
4555
+				foreach ($_messageList['msg'] as $rowID)
4563 4556
 				{
4564 4557
 					$hA = self::splitRowID($rowID);
4565 4558
 					$messageList[] = $hA['msgUID'];
@@ -4567,27 +4560,27 @@  discard block
 block discarded – undo
4567 4560
 				try
4568 4561
 				{
4569 4562
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4570
-					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4563
+					$this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4571 4564
 				}
4572 4565
 				catch (egw_exception $e)
4573 4566
 				{
4574
-					$error = str_replace('"',"'",$e->getMessage());
4567
+					$error = str_replace('"', "'", $e->getMessage());
4575 4568
 				}
4576 4569
 			}
4577 4570
 			$response = egw_json_response::get();
4578 4571
 			if (empty($error))
4579 4572
 			{
4580
-				$response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg']));
4573
+				$response->call('app.mail.mail_deleteMessagesShowResult', array('egw_message'=>lang('deleted %1 messages in %2', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($_messageList['msg'])), $folder), 'msg'=>$_messageList['msg']));
4581 4574
 			}
4582 4575
 			else
4583 4576
 			{
4584
-				$error = str_replace('\n',"\n",lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)',$error));
4585
-				$response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList));
4577
+				$error = str_replace('\n', "\n", lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)', $error));
4578
+				$response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList));
4586 4579
 			}
4587 4580
 		}
4588 4581
 		else
4589 4582
 		{
4590
-			if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
4583
+			if (mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
4591 4584
 		}
4592 4585
 	}
4593 4586
 
@@ -4600,35 +4593,35 @@  discard block
 block discarded – undo
4600 4593
 	 *
4601 4594
 	 * @return xajax response
4602 4595
 	 */
4603
-	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy')
4596
+	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy')
4604 4597
 	{
4605
-		if(mail_bo::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove);
4598
+		if (mail_bo::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove);
4606 4599
 		translation::add_app('mail');
4607 4600
 		$_folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4608 4601
 		// only copy or move are supported as method
4609
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
4610
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2);
4611
-		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
4602
+		if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy';
4603
+		list($targetProfileID, $targetFolder) = explode(self::$delimiter, $_folderName, 2);
4604
+		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
4612 4605
 		$changeFolderActions = false;
4613 4606
 		if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
4614 4607
 		{
4615
-			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
4608
+			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3)
4616 4609
 			{
4617 4610
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4618
-				foreach( $keys as &$f)
4611
+				foreach ($keys as &$f)
4619 4612
 				{
4620
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4613
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4621 4614
 					else break;
4622 4615
 				}
4623 4616
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4624 4617
 			}
4625
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$_folderName;
4618
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $_folderName;
4626 4619
 			$changeFolderActions = true;
4627 4620
 		}
4628 4621
 		$filtered = false;
4629
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4622
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4630 4623
 		{
4631
-			$error=false;
4624
+			$error = false;
4632 4625
 			if (isset($_messageList['all']) && $_messageList['all'])
4633 4626
 			{
4634 4627
 				// we have both messageIds AND allFlag folder information
@@ -4643,11 +4636,11 @@  discard block
 block discarded – undo
4643 4636
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4644 4637
 						if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
4645 4638
 						{
4646
-							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;
4639
+							emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4640
+							if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true;
4648 4641
 						}
4649 4642
 						$filtered = true;
4650
-						$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'));
4643
+						$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'));
4651 4644
 					}
4652 4645
 					else
4653 4646
 					{
@@ -4658,70 +4651,70 @@  discard block
 block discarded – undo
4658 4651
 					$rByUid = true;
4659 4652
 					$_sR = $this->mail_bo->getSortedList(
4660 4653
 						$folder,
4661
-						$sort=0,
4654
+						$sort = 0,
4662 4655
 						$reverse,
4663 4656
 						$filter,
4664
-						$rByUid=true,
4657
+						$rByUid = true,
4665 4658
 						false
4666 4659
 					);
4667 4660
 					$messageList = $_sR['match']->ids;
4668
-					foreach($messageList as $uID)
4661
+					foreach ($messageList as $uID)
4669 4662
 					{
4670 4663
 						//error_log(__METHOD__.__LINE__.$uID);
4671
-						if ($_copyOrMove=='move')
4664
+						if ($_copyOrMove == 'move')
4672 4665
 						{
4673
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $_folderName, $uID, $_prependApp=false);
4666
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $_folderName, $uID, $_prependApp = false);
4674 4667
 						}
4675 4668
 					}
4676 4669
 				}
4677 4670
 				else
4678 4671
 				{
4679
-					$messageList='all';
4672
+					$messageList = 'all';
4680 4673
 				}
4681 4674
 				try
4682 4675
 				{
4683 4676
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4684
-					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4677
+					$this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4685 4678
 				}
4686 4679
 				catch (egw_exception $e)
4687 4680
 				{
4688
-					$error = str_replace('"',"'",$e->getMessage());
4681
+					$error = str_replace('"', "'", $e->getMessage());
4689 4682
 				}
4690 4683
 			}
4691 4684
 			else
4692 4685
 			{
4693 4686
 				$messageList = array();
4694
-				while(count($_messageList['msg']) > 0)
4687
+				while (count($_messageList['msg']) > 0)
4695 4688
 				{
4696 4689
 					$uidA = self::splitRowID($_messageList['msg'][0]);
4697 4690
 					$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4698 4691
 					$sourceProfileID = $uidA['profileID'];
4699 4692
 					$moveList = array();
4700
-					foreach($_messageList['msg'] as $rowID)
4693
+					foreach ($_messageList['msg'] as $rowID)
4701 4694
 					{
4702 4695
 						$hA = self::splitRowID($rowID);
4703 4696
 
4704 4697
 						// If folder changes, stop and move what we've got
4705
-						if($hA['folder'] != $folder) break;
4698
+						if ($hA['folder'] != $folder) break;
4706 4699
 
4707 4700
 						array_shift($_messageList['msg']);
4708 4701
 						$messageList[] = $hA['msgUID'];
4709 4702
 						$moveList[] = $hA['msgUID'];
4710
-						if ($_copyOrMove=='move')
4703
+						if ($_copyOrMove == 'move')
4711 4704
 						{
4712
-							$helpvar = explode(self::$delimiter,$rowID);
4705
+							$helpvar = explode(self::$delimiter, $rowID);
4713 4706
 							array_shift($helpvar);
4714
-							$messageListForRefresh[]= implode(self::$delimiter,$helpvar);
4707
+							$messageListForRefresh[] = implode(self::$delimiter, $helpvar);
4715 4708
 						}
4716 4709
 					}
4717 4710
 					try
4718 4711
 					{
4719 4712
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4720
-						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4713
+						$this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4721 4714
 					}
4722 4715
 					catch (egw_exception $e)
4723 4716
 					{
4724
-						$error = str_replace('"',"'",$e->getMessage());
4717
+						$error = str_replace('"', "'", $e->getMessage());
4725 4718
 					}
4726 4719
 				}
4727 4720
 			}
@@ -4734,30 +4727,30 @@  discard block
 block discarded – undo
4734 4727
 					unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]);
4735 4728
 					$changeFolderActions = true;
4736 4729
 				}
4737
-				$response->call('egw.message',$error,"error");
4730
+				$response->call('egw.message', $error, "error");
4738 4731
 			}
4739 4732
 			else
4740 4733
 			{
4741
-				if ($_copyOrMove=='copy')
4734
+				if ($_copyOrMove == 'copy')
4742 4735
 				{
4743
-					$response->call('egw.message',lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder));
4736
+					$response->call('egw.message', lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder));
4744 4737
 				}
4745 4738
 				else
4746 4739
 				{
4747
-					$response->call('egw.refresh',lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder),'mail',$messageListForRefresh,'delete');
4740
+					$response->call('egw.refresh', lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder), 'mail', $messageListForRefresh, 'delete');
4748 4741
 				}
4749 4742
 			}
4750 4743
 			if ($changeFolderActions == true)
4751 4744
 			{
4752
-				egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
4745
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
4753 4746
 				$actionsnew = self::get_actions();
4754 4747
 				$actionsnew = etemplate_widget_nextmatch::egw_actions($actionsnew);
4755
-				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
4748
+				$response->call('app.mail.mail_rebuildActionsOnList', $actionsnew);
4756 4749
 			}
4757 4750
 		}
4758 4751
 		else
4759 4752
 		{
4760
-			if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
4753
+			if (mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
4761 4754
 		}
4762 4755
 	}
4763 4756
 
@@ -4767,11 +4760,11 @@  discard block
 block discarded – undo
4767 4760
 	 *
4768 4761
 	 * @param type $_id
4769 4762
 	 */
4770
-	function ajax_folderMgmtTree_autoloading ($_id = null)
4763
+	function ajax_folderMgmtTree_autoloading($_id = null)
4771 4764
 	{
4772 4765
 		$mail_ui = new mail_ui();
4773
-		$_id = $_id? $_id:$_GET['id'];
4774
-		etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id,'',1,true,false,false,false));
4766
+		$_id = $_id ? $_id : $_GET['id'];
4767
+		etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id, '', 1, true, false, false, false));
4775 4768
 	}
4776 4769
 
4777 4770
 	/**
@@ -4779,15 +4772,15 @@  discard block
 block discarded – undo
4779 4772
 	 *
4780 4773
 	 * @param array $content content of dialog
4781 4774
 	 */
4782
-	function folderManagement (array $content = null)
4775
+	function folderManagement(array $content = null)
4783 4776
 	{
4784 4777
 		$dtmpl = new etemplate_new('mail.folder_management');
4785
-		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
4786
-		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
4778
+		$profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id'];
4779
+		$sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false);
4787 4780
 
4788 4781
 		if (!is_array($content))
4789 4782
 		{
4790
-			$content = array ('acc_id' => $profileID);
4783
+			$content = array('acc_id' => $profileID);
4791 4784
 		}
4792 4785
 
4793 4786
 		$readonlys = array();
@@ -4795,7 +4788,7 @@  discard block
 block discarded – undo
4795 4788
 		$preserv = array(
4796 4789
 			'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side
4797 4790
 		);
4798
-		$dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2);
4791
+		$dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2);
4799 4792
 	}
4800 4793
 
4801 4794
 	/**
@@ -4805,11 +4798,11 @@  discard block
 block discarded – undo
4805 4798
 	 *
4806 4799
 	 * @param type $_folderName
4807 4800
 	 */
4808
-	function ajax_folderMgmt_delete ($_folderName)
4801
+	function ajax_folderMgmt_delete($_folderName)
4809 4802
 	{
4810 4803
 		if ($_folderName)
4811 4804
 		{
4812
-			$success = $this->ajax_deleteFolder($_folderName,true);
4805
+			$success = $this->ajax_deleteFolder($_folderName, true);
4813 4806
 			$response = egw_json_response::get();
4814 4807
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
4815 4808
 			if ($success)
@@ -4818,7 +4811,7 @@  discard block
 block discarded – undo
4818 4811
 			}
4819 4812
 			else
4820 4813
 			{
4821
-				$res = lang("Failed to delete %1",$folderName);
4814
+				$res = lang("Failed to delete %1", $folderName);
4822 4815
 			}
4823 4816
 			$response->data($res);
4824 4817
 		}
Please login to merge, or discard this 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.