Completed
Push — 16.1 ( 3d52b1...edadaa )
by Hadi
39:13 queued 22:22
created
mail/inc/class.mail_ui.inc.php 1 patch
Spacing   +828 added lines, -835 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @var array
42 42
 	 */
43
-	var $public_functions = array
44
-	(
43
+	var $public_functions = array(
45 44
 		'index' => True,
46 45
 		'displayHeader'	=> True,
47 46
 		'displayMessage'	=> True,
@@ -92,17 +91,17 @@  discard block
 block discarded – undo
92 91
 	 * @var array
93 92
 	 */
94 93
 	var $searchTypes = array(
95
-		'quick'		=> 'quicksearch',	// lang('quicksearch')
96
-		'quickwithcc'=> 'quicksearch (with cc)',	// lang('quicksearch (with cc)')
97
-		'subject'	=> 'subject',		// lang('subject')
98
-		'body'		=> 'message body',	// lang('message body')
99
-		'from'		=> 'from',			// lang('from')
100
-		'to'		=> 'to',			// lang('to')
101
-		'cc'		=> 'cc',			// lang('cc')
102
-		'text'		=> 'whole message',	// lang('whole message')
103
-		'larger'		=> 'greater than',	// lang('greater than')
104
-		'smaller'		=> 'less than',	// lang('less than')
105
-		'bydate' 	=> 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)')
94
+		'quick'		=> 'quicksearch', // lang('quicksearch')
95
+		'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)')
96
+		'subject'	=> 'subject', // lang('subject')
97
+		'body'		=> 'message body', // lang('message body')
98
+		'from'		=> 'from', // lang('from')
99
+		'to'		=> 'to', // lang('to')
100
+		'cc'		=> 'cc', // lang('cc')
101
+		'text'		=> 'whole message', // lang('whole message')
102
+		'larger'		=> 'greater than', // lang('greater than')
103
+		'smaller'		=> 'less than', // lang('less than')
104
+		'bydate' 	=> 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)')
106 105
 	);
107 106
 
108 107
 	/**
@@ -111,12 +110,12 @@  discard block
 block discarded – undo
111 110
 	 * @var array
112 111
 	 */
113 112
 	var $statusTypes = array(
114
-		'any'		=> 'any status',// lang('any status')
115
-		'flagged'	=> 'flagged',	// lang('flagged')
116
-		'unseen'	=> 'unread',	// lang('unread')
117
-		'answered'	=> 'replied',	// lang('replied')
118
-		'seen'		=> 'read',		// lang('read')
119
-		'deleted'	=> 'deleted',	// lang('deleted')
113
+		'any'		=> 'any status', // lang('any status')
114
+		'flagged'	=> 'flagged', // lang('flagged')
115
+		'unseen'	=> 'unread', // lang('unread')
116
+		'answered'	=> 'replied', // lang('replied')
117
+		'seen'		=> 'read', // lang('read')
118
+		'deleted'	=> 'deleted', // lang('deleted')
120 119
 	);
121 120
 
122 121
 	/**
@@ -124,12 +123,12 @@  discard block
 block discarded – undo
124 123
 	 *
125 124
 	 * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server
126 125
 	 */
127
-	function __construct($run_constructor=true)
126
+	function __construct($run_constructor = true)
128 127
 	{
129 128
 		$this->mail_tree = new mail_tree($this);
130 129
 		if (!$run_constructor) return;
131 130
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
131
+		if (Mail::$debugTimes) $starttime = microtime(true);
133 132
 		// no autohide of the sidebox, as we use it for folderlist now.
134 133
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 134
 
@@ -145,13 +144,13 @@  discard block
 block discarded – undo
145 144
 		}
146 145
 
147 146
 		try {
148
-			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
147
+			$this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true);
149 148
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
150 149
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 150
 
152 151
 			// RegEx to minimize extra openConnection
153 152
 			$needle = '/^(?!mail)/';
154
-			if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
153
+			if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
155 154
 			{
156 155
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
157 156
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -164,12 +163,12 @@  discard block
 block discarded – undo
164 163
 			if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index')
165 164
 			{
166 165
 				$response = Api\Json\Response::get();
167
-				$response->call('egw.message',$e->getMessage(),'error');
166
+				$response->call('egw.message', $e->getMessage(), 'error');
168 167
 			}
169 168
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
169
+			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false);
171 170
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
173 172
 	}
174 173
 
175 174
 	/**
@@ -179,10 +178,10 @@  discard block
 block discarded – undo
179 178
 	 * @param boolean $exit If true, will call exit() after opening the wizardpopup
180 179
 	 * @param string $msg_type = 'success' message type
181 180
 	 */
182
-	static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true)
181
+	static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true)
183 182
 	{
184 183
 		//error_log(__METHOD__."('$message', $exit) ".function_backtrace());
185
-		$linkData=(self::$icServerID ? array(
184
+		$linkData = (self::$icServerID ? array(
186 185
 				'menuaction' => 'mail.mail_wizard.edit',
187 186
 				'acc_id' => self::$icServerID,
188 187
 			) : array(
@@ -196,11 +195,11 @@  discard block
 block discarded – undo
196 195
 		{
197 196
 			$response = Api\Json\Response::get();
198 197
 			$windowName = "editMailAccount".self::$icServerID;
199
-			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
198
+			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true);
200 199
 			Framework::message($message, 'error');
201 200
 			if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index)
202 201
 			{
203
-				$response->call('framework.setSidebox','mail',array(),'md5');
202
+				$response->call('framework.setSidebox', 'mail', array(), 'md5');
204 203
 			}
205 204
 			if ($exit)
206 205
 			{
@@ -210,8 +209,8 @@  discard block
 block discarded – undo
210 209
 		else	// regular GET request eg. in idots template
211 210
 		{
212 211
 			$windowName = "editMailAccount".self::$icServerID;
213
-			Framework::popup(Framework::link('/index.php',$linkData),$windowName);
214
-			$GLOBALS['egw']->framework->render($message,'',true);
212
+			Framework::popup(Framework::link('/index.php', $linkData), $windowName);
213
+			$GLOBALS['egw']->framework->render($message, '', true);
215 214
 			if ($exit)
216 215
 			{
217 216
 				exit();
@@ -227,9 +226,9 @@  discard block
 block discarded – undo
227 226
 	 *
228 227
 	 * @throws Api\Exception
229 228
 	 */
230
-	function changeProfile($_icServerID,$unsetCache=false)
229
+	function changeProfile($_icServerID, $unsetCache = false)
231 230
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
231
+		if (Mail::$debugTimes) $starttime = microtime(true);
233 232
 		if (self::$icServerID != $_icServerID)
234 233
 		{
235 234
 			self::$icServerID = $_icServerID;
@@ -237,35 +236,35 @@  discard block
 block discarded – undo
237 236
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
238 237
 
239 238
 		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
240
-		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
239
+		$this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true);
241 240
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
242 241
 		// no icServer Object: something failed big time
243
-		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
242
+		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID)
244 243
 		{
245 244
 			self::$icServerID = $_icServerID;
246 245
 			throw new Api\Exception('Profile change failed!');
247 246
 		}
248 247
 
249 248
 		// save session varchar
250
-		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
249
+		$oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID');
251 250
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252 251
 		if (true) $oldicServerID = self::$icServerID;
253
-		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
252
+		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true))
254 253
 		{
255 254
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 255
 		}
257 256
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
257
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
259 258
 	}
260 259
 
261 260
 	/**
262 261
 	 * Ajax function to request next branch of a tree branch
263 262
 	 */
264
-	static function ajax_tree_autoloading ($_id = null)
263
+	static function ajax_tree_autoloading($_id = null)
265 264
 	{
266 265
 		$mail_ui = new mail_ui();
267 266
 		$id = $_id ? $_id : $_GET['id'];
268
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
267
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false));
269 268
 	}
270 269
 
271 270
 	/**
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 	 * @param array $content
275 274
 	 * @param type $msg
276 275
 	 */
277
-	function subscription(array $content=null ,$msg=null)
276
+	function subscription(array $content = null, $msg = null)
278 277
 	{
279 278
 		$stmpl = new Etemplate('mail.subscribe');
280 279
 
281
-		if(is_array($content))
280
+		if (is_array($content))
282 281
 		{
283 282
 			$profileId = $content['profileId'];
284 283
 		}
@@ -288,14 +287,14 @@  discard block
 block discarded – undo
288 287
 		}
289 288
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
290 289
 		// triggered from client-side. Also, we keep this here as
291
-		$sel_options['foldertree'] =  $this->mail_tree->getTree(null,$profileId,1,true,false,true);
290
+		$sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true);
292 291
 
293 292
 		//Get all subscribed folders
294 293
 		// as getting all subscribed folders is very fast operation
295 294
 		// we can use it to get a comparison base for folders which
296 295
 		// got subscribed or unsubscribed by the user
297 296
 		try {
298
-			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
297
+			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true);
299 298
 		} catch (Exception $ex) {
300 299
 			Framework::message($ex->getMessage());
301 300
 		}
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
 
307 306
 			foreach ($subscribed as $folder)
308 307
 			{
309
-				$folderName = $profileId . self::$delimiter . $folder['MAILBOX'];
308
+				$folderName = $profileId.self::$delimiter.$folder['MAILBOX'];
310 309
 				array_push($content['foldertree'], $folderName);
311 310
 			}
312 311
 		}
@@ -320,9 +319,9 @@  discard block
 block discarded – undo
320 319
 				{
321 320
 					// do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
322 321
 					$namespace_roots = array($profileId);
323
-					foreach($this->mail_bo->_getNameSpaces() as $namespace)
322
+					foreach ($this->mail_bo->_getNameSpaces() as $namespace)
324 323
 					{
325
-						$namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
324
+						$namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']);
326 325
 					}
327 326
 					$to_unsubscribe = $to_subscribe = array();
328 327
 					foreach ($content['foldertree'] as $path => $value)
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 330
 						if ($node)
332 331
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
332
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node;
334 333
 							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335 334
 							if ($value['value']) $cont[] = $path;
336 335
 						}
@@ -340,7 +339,7 @@  discard block
 block discarded – undo
340 339
 					// set foldertree options to basic node in order to avoid initial autoloading
341 340
 					// from client side, as no options would trigger that.
342 341
 					$sel_options['foldertree'] = array('id' => '0', 'item'=> array());
343
-					foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
342
+					foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
344 343
 					{
345 344
 						if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true))
346 345
 						{
@@ -376,18 +375,18 @@  discard block
 block discarded – undo
376 375
 						}
377 376
 					}
378 377
 					// update foldertree in main window
379
-					$parentFolder='INBOX';
378
+					$parentFolder = 'INBOX';
380 379
 					$refreshData = array(
381 380
 						$profileId => lang($parentFolder),
382 381
 					);
383 382
 					$response = Api\Json\Response::get();
384
-					foreach($refreshData as $folder => &$name)
383
+					foreach ($refreshData as $folder => &$name)
385 384
 					{
386
-						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
385
+						$name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true);
387 386
 					}
388 387
 					// give success/error message to opener and popup itself
389 388
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
390
-					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
389
+					$response->call('opener.app.mail.mail_reloadNode', $refreshData);
391 390
 
392 391
 					Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
393 392
 					if ($button == 'apply')
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 
408 407
 		$readonlys = array();
409 408
 
410
-		$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
409
+		$stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2);
411 410
 	}
412 411
 
413 412
 	/**
@@ -416,13 +415,13 @@  discard block
 block discarded – undo
416 415
 	 * @param array $content
417 416
 	 * @param string $msg
418 417
 	 */
419
-	function index(array $content=null,$msg=null)
418
+	function index(array $content = null, $msg = null)
420 419
 	{
421 420
 		//error_log(__METHOD__.__LINE__.array2string($content));
422
-		try	{
421
+		try {
423 422
 				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
424 423
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
424
+				if (Mail::$debugTimes) $starttime = microtime(true);
426 425
 				$this->mail_bo->restoreSessionData();
427 426
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 427
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -443,26 +442,26 @@  discard block
 block discarded – undo
443 442
 					{
444 443
 						// These only set on first load
445 444
 						$content[self::$nm_index] = array(
446
-							'filter'         => 'any',	// filter is used to choose the mailbox
447
-							'lettersearch'   => false,	// I  show a lettersearch
448
-							'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
449
-							'start'          =>	0,		// IO position in list
450
-							'order'          =>	'date',	// IO name of the column to sort after (optional for the sortheaders)
451
-							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
445
+							'filter'         => 'any', // filter is used to choose the mailbox
446
+							'lettersearch'   => false, // I  show a lettersearch
447
+							'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
448
+							'start'          =>	0, // IO position in list
449
+							'order'          =>	'date', // IO name of the column to sort after (optional for the sortheaders)
450
+							'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
452 451
 						);
453 452
 					}
454 453
 					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
455 454
 				}
456 455
 
457 456
 				// These must always be set, even if $content is an array
458
-				$content[self::$nm_index]['cat_is_select'] = true;    // Category select is just a normal selectbox
459
-				$content[self::$nm_index]['no_filter2'] = false;       // Disable second filter
457
+				$content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox
458
+				$content[self::$nm_index]['no_filter2'] = false; // Disable second filter
460 459
 				$content[self::$nm_index]['actions'] = self::get_actions();
461
-				$content[self::$nm_index]['row_id'] = 'row_id';	     // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
460
+				$content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
462 461
 				$content[self::$nm_index]['placeholder_actions'] = array('composeasnew');
463 462
 				$content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows';
464
-				$content[self::$nm_index]['num_rows'] = 0;      // Do not send any rows with initial request
465
-				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size';	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
463
+				$content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request
464
+				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
466 465
 				$content[self::$nm_index]['csv_fields'] = false;
467 466
 				if ($msg)
468 467
 				{
@@ -474,11 +473,11 @@  discard block
 block discarded – undo
474 473
 					unset($content['msg']);
475 474
 				}
476 475
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477
-				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
476
+				$quota = false; //$this->mail_bo->getQuotaRoot();
477
+				if ($quota !== false && $quota['limit'] != 'NOT SET') {
479 478
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 479
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481
-					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
480
+					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
482 481
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 482
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484 483
 				} else {
@@ -487,43 +486,43 @@  discard block
 block discarded – undo
487 486
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
488 487
 				}
489 488
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
490
-				$vacation = false;//$this->gatherVacation();
489
+				$vacation = false; //$this->gatherVacation();
491 490
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
492
-				if($vacation) {
493
-					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
491
+				if ($vacation) {
492
+					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time()))
494 493
 					{
495 494
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
496 495
 						$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
497
-						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
496
+						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
498 497
 					}
499 498
 				}
500
-				if ($vacation==false)
499
+				if ($vacation == false)
501 500
 				{
502 501
 					$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = '';
503 502
 					$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = '';
504 503
 				}
505 504
 				//$zstarttime = microtime (true);
506
-				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
505
+				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
507 506
 				//$zendtime = microtime(true) - $zstarttime;
508 507
 				//error_log(__METHOD__.__LINE__. " time used: ".$zendtime);
509
-				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX');
508
+				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX');
510 509
 				// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
511
-				if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
510
+				if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
512 511
 				{
513
-					$this->statusTypes = array_merge($this->statusTypes,array(
514
-						'keyword1'	=> 'important',//lang('important'),
515
-						'keyword2'	=> 'job',	//lang('job'),
516
-						'keyword3'	=> 'personal',//lang('personal'),
517
-						'keyword4'	=> 'to do',	//lang('to do'),
518
-						'keyword5'	=> 'later',	//lang('later'),
512
+					$this->statusTypes = array_merge($this->statusTypes, array(
513
+						'keyword1'	=> 'important', //lang('important'),
514
+						'keyword2'	=> 'job', //lang('job'),
515
+						'keyword3'	=> 'personal', //lang('personal'),
516
+						'keyword4'	=> 'to do', //lang('to do'),
517
+						'keyword5'	=> 'later', //lang('later'),
519 518
 					));
520 519
 				}
521 520
 				else
522 521
 				{
523
-					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
524
-					foreach($keywords as &$k)
522
+					$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
523
+					foreach ($keywords as &$k)
525 524
 					{
526
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
525
+						if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
527 526
 					}
528 527
 				}
529 528
 
@@ -534,8 +533,8 @@  discard block
 block discarded – undo
534 533
 
535 534
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
536 535
 				{
537
-					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
538
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
536
+					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
537
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
539 538
 				}
540 539
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
541 540
 				{
@@ -547,14 +546,14 @@  discard block
 block discarded – undo
547 546
 				//error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']));
548 547
 				$content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'];
549 548
 				$sel_options['filter'] = $this->statusTypes;
550
-				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'));
549
+				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'));
551 550
 				$content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'];
552 551
 
553 552
 				$etpl = new Etemplate('mail.index');
554 553
 				//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
555 554
 				$content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()";
556 555
 				// set the actions on tree
557
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
556
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions());
558 557
 
559 558
 				// sending preview toolbar actions
560 559
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
@@ -565,28 +564,28 @@  discard block
 block discarded – undo
565 564
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
566 565
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
567 566
 				{
568
-					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
567
+					$content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject'));
569 568
 				}
570 569
 				$readonlys = $preserv = array();
571
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
570
+				if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
572 571
 		}
573 572
 		catch (Exception $e)
574 573
 		{
575 574
 			// do not exit here. mail-tree should be build. if we exit here, we never get there.
576
-			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
575
+			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
577 576
 			if (isset($this->mail_bo))
578 577
 			{
579 578
 				if (empty($etpl))
580 579
 				{
581
-					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
580
+					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
582 581
 					$etpl = new Etemplate('mail.index');
583 582
 				}
584
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
583
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false));
585 584
 			}
586 585
 			$readonlys = $preserv = array();
587
-			if (empty($content)) $content=array();
586
+			if (empty($content)) $content = array();
588 587
 
589
-			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
588
+			self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ? false : true), 'error', false);
590 589
 			//return false;
591 590
 		}
592 591
 		// Check preview pane is enabled, then show splitter - preference used to be '1', now 'hide'
@@ -595,7 +594,7 @@  discard block
 block discarded – undo
595 594
 			$etpl->setElementAttribute('splitter', 'template', 'mail.index.nosplitter');
596 595
 		}
597 596
 
598
-		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
597
+		return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv);
599 598
 	}
600 599
 
601 600
 	/**
@@ -605,11 +604,11 @@  discard block
 block discarded – undo
605 604
 	 * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server
606 605
 	 * @return array
607 606
 	 */
608
-	function get_tree_actions($imap_actions=true)
607
+	function get_tree_actions($imap_actions = true)
609 608
 	{
610 609
 		// Start at 2 so auto-added copy+paste actions show up as second group
611 610
 		// Needed because there's no 'select all' action to push things down
612
-		$group=1;
611
+		$group = 1;
613 612
 		// Set tree actions
614 613
 		$tree_actions = array(
615 614
 			'drop_move_mail' => array(
@@ -691,12 +690,12 @@  discard block
 block discarded – undo
691 690
 				'onExecute' => 'javaScript:app.mail.edit_sieve',
692 691
 
693 692
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
694
-				'icon' => 'mail/filter',	// funnel
693
+				'icon' => 'mail/filter', // funnel
695 694
 				'hideOnMobile' => true
696 695
 			),
697 696
 			'vacation' => array(
698 697
 				'caption' => 'Vacation notice',
699
-				'icon' => 'mail/navbar',	// mail as in admin
698
+				'icon' => 'mail/navbar', // mail as in admin
700 699
 				'onExecute' => 'javaScript:app.mail.edit_vacation',
701 700
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
702 701
 			),
@@ -737,8 +736,8 @@  discard block
 block discarded – undo
737 736
 			unset($tree_actions['subscribe']);
738 737
 			unset($tree_actions['unsubscribe']);
739 738
 		}
740
-		++$group;	// put delete in own group
741
-		switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
739
+		++$group; // put delete in own group
740
+		switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
742 741
 		{
743 742
 			case 'move_to_trash':
744 743
 				$tree_actions['empty_trash'] = array(
@@ -757,7 +756,7 @@  discard block
 block discarded – undo
757 756
 				);
758 757
 				break;
759 758
 		}
760
-		$junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null);
759
+		$junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null);
761 760
 
762 761
 		//error_log(__METHOD__.__LINE__.$junkFolder);
763 762
 		if ($junkFolder && !empty($junkFolder))
@@ -770,8 +769,8 @@  discard block
 block discarded – undo
770 769
 				'group'	=> $group,
771 770
 			);
772 771
 		}
773
-		$tree_actions['sieve']['group']	= $tree_actions['vacation']['group'] = ++$group;	// new group for filter
774
-		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group']	= ++$group;
772
+		$tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter
773
+		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group;
775 774
 
776 775
 
777 776
 		// enforce global (group-specific) ACL
@@ -806,17 +805,17 @@  discard block
 block discarded – undo
806 805
 	 * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed
807 806
 	 * @param {boolean} $_status set true for subscribe and false to unsubscribe
808 807
 	 */
809
-	public function ajax_foldersubscription($_acc_id,$_folderName, $_status)
808
+	public function ajax_foldersubscription($_acc_id, $_folderName, $_status)
810 809
 	{
811 810
 		//Change the Mail object to related profileId
812 811
 		$this->changeProfile($_acc_id);
813
-		try{
812
+		try {
814 813
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
815 814
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
816
-			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
815
+			$this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
817 816
 		} catch (Horde_Imap_Client_Exception $ex) {
818
-			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
819
-			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
817
+			error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex));
818
+			Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status));
820 819
 		}
821 820
 	}
822 821
 
@@ -828,25 +827,25 @@  discard block
 block discarded – undo
828 827
 	 * @param string $_nodeID if of node whose children are requested
829 828
 	 * @param boolean $_subscribedOnly flag to tell whether to fetch all or only subscribed (default)
830 829
 	 */
831
-	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
830
+	public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null)
832 831
 	{
833 832
 		$nodeID = $_GET['id'];
834 833
 		if (!is_null($_nodeID)) $nodeID = $_nodeID;
835
-		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
834
+		$subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
836 835
 		$fetchCounters = !is_null($_nodeID);
837
-		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
836
+		list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2);
838 837
 
839 838
 		if (!empty($_folderName)) $fetchCounters = true;
840 839
 
841 840
 		// Check if it is called for refresh root
842 841
 		// then we need to reinitialized the index tree
843
-		if(!$nodeID && !$_profileID)
842
+		if (!$nodeID && !$_profileID)
844 843
 		{
845
-			$data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
844
+			$data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
846 845
 		}
847 846
 		else
848 847
 		{
849
-			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
848
+			$data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
850 849
 		}
851 850
 		if (!is_null($_nodeID)) return $data;
852 851
 		Etemplate\Widget\Tree::send_quote_json($data);
@@ -862,17 +861,17 @@  discard block
 block discarded – undo
862 861
 	 */
863 862
 	static function findNode($_out, $_nodeID, $childElements = false)
864 863
 	{
865
-		foreach($_out['item'] as $node)
864
+		foreach ($_out['item'] as $node)
866 865
 		{
867
-			if (strcmp($node['id'],$_nodeID)===0)
866
+			if (strcmp($node['id'], $_nodeID) === 0)
868 867
 			{
869 868
 				//error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']);
870
-				return ($childElements?$node['item']:$node);
869
+				return ($childElements ? $node['item'] : $node);
871 870
 			}
872
-			elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id']))
871
+			elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id']))
873 872
 			{
874 873
 				//error_log(__METHOD__.__LINE__.' descend into '.$node['id']);
875
-				return self::findNode($node,$_nodeID,$childElements);
874
+				return self::findNode($node, $_nodeID, $childElements);
876 875
 			}
877 876
 		}
878 877
 	}
@@ -943,11 +942,11 @@  discard block
 block discarded – undo
943 942
 		}
944 943
 		if ($refresh)
945 944
 		{
946
-			$response->apply('egw.refresh',[implode('\n',$msg),'mail',$_params['row_id'],'delete']);
945
+			$response->apply('egw.refresh', [implode('\n', $msg), 'mail', $_params['row_id'], 'delete']);
947 946
 		}
948 947
 		else
949 948
 		{
950
-			$response->apply('egw.message',[implode('\n',$msg)]);
949
+			$response->apply('egw.message', [implode('\n', $msg)]);
951 950
 		}
952 951
 	}
953 952
 
@@ -956,21 +955,21 @@  discard block
 block discarded – undo
956 955
 	 *
957 956
 	 * @return array actions
958 957
 	 */
959
-	public function getSpamActions ()
958
+	public function getSpamActions()
960 959
 	{
961
-		$actions = array (
962
-			'spamfilter' => array (
960
+		$actions = array(
961
+			'spamfilter' => array(
963 962
 				'caption'	=> 'Spam',
964 963
 				'icon'		=> 'dhtmlxtree/MailFolderJunk',
965
-				'children'	=> array (
966
-					'spam' => array (
964
+				'children'	=> array(
965
+					'spam' => array(
967 966
 						'caption'	=> 'Report as Spam',
968 967
 						'icon'		=> 'dhtmlxtree/MailFolderJunk',
969 968
 						'onExecute' => 'javaScript:app.mail.spam_actions',
970 969
 						'hint'		=> 'Report this email content as Spam - spam solutions like spamTitan will learn',
971 970
 						'allowOnMultiple' => false
972 971
 					),
973
-					'ham' => array (
972
+					'ham' => array(
974 973
 						'caption'	=> 'Report as Ham',
975 974
 						'icon'		=> 'ham',
976 975
 						'onExecute' => 'javaScript:app.mail.spam_actions',
@@ -997,7 +996,7 @@  discard block
 block discarded – undo
997 996
 	 */
998 997
 	private function get_actions()
999 998
 	{
1000
-		static $accArray=array(); // buffer identity names on single request
999
+		static $accArray = array(); // buffer identity names on single request
1001 1000
 		// duplicated from mail_hooks
1002 1001
 		static $deleteOptions = array(
1003 1002
 			'move_to_trash'		=> 'move to trash',
@@ -1008,12 +1007,12 @@  discard block
 block discarded – undo
1008 1007
 		$lastFolderUsedForMove = null;
1009 1008
 		$moveactions = array();
1010 1009
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
1011
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
1010
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
1012 1011
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
1013 1012
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
1014 1013
 		if (is_null($accArray))
1015 1014
 		{
1016
-			foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj)
1015
+			foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj)
1017 1016
 			{
1018 1017
 				//error_log(__METHOD__.__LINE__.array2string($accountObj));
1019 1018
 				if (!$accountObj->is_imap())
@@ -1021,22 +1020,22 @@  discard block
 block discarded – undo
1021 1020
 					// not to be used for IMAP Foldertree, as there is no Imap host
1022 1021
 					continue;
1023 1022
 				}
1024
-				$identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']);
1025
-				$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
1023
+				$identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']);
1024
+				$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
1026 1025
 			}
1027 1026
 		}
1028
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
1027
+		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array();
1029 1028
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
1030 1029
 		{
1031
-			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
1030
+			if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
1032 1031
 			{
1033 1032
 				$_folder = $this->mail_bo->icServer->getCurrentMailbox();
1034 1033
 				//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace());
1035
-				$counter =1;
1034
+				$counter = 1;
1036 1035
 				foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont)
1037 1036
 				{
1038 1037
 					$moveaction = 'move_';
1039
-					if ($_folder!=$i)
1038
+					if ($_folder != $i)
1040 1039
 					{
1041 1040
 						$moveaction .= $lastFolderUsedForMoveCont;
1042 1041
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
@@ -1047,7 +1046,7 @@  discard block
 block discarded – undo
1047 1046
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
1048 1047
 							$fS['shortDisplayName'] = $i;
1049 1048
 							$moveactions[$moveaction] = $fS;
1050
-							$counter ++;
1049
+							$counter++;
1051 1050
 						}
1052 1051
 						else
1053 1052
 						{
@@ -1057,9 +1056,9 @@  discard block
 block discarded – undo
1057 1056
 					}
1058 1057
 				}
1059 1058
 			}
1060
-			elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
1059
+			elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
1061 1060
 			{
1062
-				$counter =1;
1061
+				$counter = 1;
1063 1062
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
1064 1063
 				{
1065 1064
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
@@ -1072,19 +1071,19 @@  discard block
 block discarded – undo
1072 1071
 						$fS['profileName'] = $accArray[$pid];
1073 1072
 						$fS['shortDisplayName'] = $i;
1074 1073
 						$moveactions[$moveaction] = $fS;
1075
-						$counter ++;
1074
+						$counter++;
1076 1075
 					}
1077 1076
 				}
1078 1077
 			}
1079 1078
 		}
1080
-		Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
1079
+		Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
1081 1080
 		$group = 0;
1082
-		$actions =  array(
1081
+		$actions = array(
1083 1082
 			'open' => array(
1084 1083
 				'caption' => lang('Open'),
1085 1084
 				'icon' => 'view',
1086 1085
 				'group' => ++$group,
1087
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
1086
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open',
1088 1087
 				'allowOnMultiple' => false,
1089 1088
 				'default' => true,
1090 1089
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet'))
@@ -1137,20 +1136,20 @@  discard block
 block discarded – undo
1137 1136
 				'allowOnMultiple' => false,
1138 1137
 			)
1139 1138
 		);
1140
-		$macounter=0;
1139
+		$macounter = 0;
1141 1140
 		if (!empty($moveactions))
1142 1141
 		{
1143 1142
 			//error_log(__METHOD__.__LINE__.array2string($moveactions));
1144
-			$children=array();
1145
-			$pID=0;
1143
+			$children = array();
1144
+			$pID = 0;
1146 1145
 			foreach ($moveactions as $moveaction => $lastFolderUsedForMove)
1147 1146
 			{
1148
-				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group);
1147
+				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group);
1149 1148
 				//error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#');
1150 1149
 				$children = array_merge($children,
1151 1150
 					array(
1152 1151
 						$moveaction => array(
1153
-							'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
1152
+							'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''),
1154 1153
 							'icon' => 'move',
1155 1154
 							'group' => $group,
1156 1155
 							'onExecute' => 'javaScript:app.mail.mail_move2folder',
@@ -1161,7 +1160,7 @@  discard block
 block discarded – undo
1161 1160
 				$pID = $lastFolderUsedForMove['profileID'];
1162 1161
 				$macounter++;
1163 1162
 			}
1164
-			$actions['moveto'] =	array(
1163
+			$actions['moveto'] = array(
1165 1164
 				'caption' => lang('Move selected to'),
1166 1165
 				'icon' => 'move',
1167 1166
 				'group' => $group,
@@ -1209,7 +1208,7 @@  discard block
 block discarded – undo
1209 1208
 				'icon' => 'tracker/navbar',
1210 1209
 				'onExecute' => 'javaScript:app.mail.mail_integrate',
1211 1210
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1212
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
1211
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
1213 1212
 				'allowOnMultiple' => false,
1214 1213
 			),
1215 1214
 			'calendar' => array(
@@ -1433,25 +1432,25 @@  discard block
 block discarded – undo
1433 1432
 	 * @param array &$rows
1434 1433
 	 * @param array &$readonlys
1435 1434
 	 */
1436
-	public static function get_rows(&$query,&$rows,&$readonlys)
1435
+	public static function get_rows(&$query, &$rows, &$readonlys)
1437 1436
 	{
1438
-		unset($readonlys);	// not used, but required by function signature
1437
+		unset($readonlys); // not used, but required by function signature
1439 1438
 
1440 1439
 		// handle possible profile change in get_rows
1441 1440
 		if (!empty($query['selectedFolder']))
1442 1441
 		{
1443
-			list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1442
+			list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1444 1443
 			if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])
1445 1444
 			{
1446 1445
 				try {
1447
-					$mail_ui = new mail_ui(false);	// do NOT run constructor, as we change profile anyway
1446
+					$mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway
1448 1447
 					$mail_ui->changeProfile($_profileID);
1449 1448
 					$query['actions'] = $mail_ui->get_actions();
1450 1449
 				}
1451
-				catch(Exception $e)
1450
+				catch (Exception $e)
1452 1451
 				{
1453 1452
 					unset($e);
1454
-					$rows=array();
1453
+					$rows = array();
1455 1454
 					return 0;
1456 1455
 				}
1457 1456
 				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
@@ -1461,12 +1460,12 @@  discard block
 block discarded – undo
1461 1460
 		{
1462 1461
 			try
1463 1462
 			{
1464
-				$mail_ui = new mail_ui(true);	// run constructor for current profile
1463
+				$mail_ui = new mail_ui(true); // run constructor for current profile
1465 1464
 			}
1466
-			catch(Exception $e)
1465
+			catch (Exception $e)
1467 1466
 			{
1468 1467
 				unset($e);
1469
-				$rows=array();
1468
+				$rows = array();
1470 1469
 				return 0;
1471 1470
 			}
1472 1471
 			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
@@ -1477,66 +1476,66 @@  discard block
 block discarded – undo
1477 1476
 		//$query['search'] is the phrase in the searchbox
1478 1477
 
1479 1478
 		$mail_ui->mail_bo->restoreSessionData();
1480
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1479
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder'];
1481 1480
 
1482 1481
 		$sRToFetch = null;
1483
-		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
1484
-		if (strpos($_folderName,self::$delimiter)!==false)
1482
+		list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1483
+		if (strpos($_folderName, self::$delimiter) !== false)
1485 1484
 		{
1486
-			list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3);
1485
+			list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3);
1487 1486
 			unset($app);
1488 1487
 		}
1489 1488
 		//save selected Folder to sessionData (mailbox)->currentFolder
1490
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1491
-		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1489
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName;
1490
+		$toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default)
1492 1491
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1493 1492
 		{
1494
-			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false);
1493
+			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false);
1495 1494
 		}
1496 1495
 		else
1497 1496
 		{
1498 1497
 			// take the extra time on failure
1499
-			if (!$mail_ui->mail_bo->folderExists($_folderName,true))
1498
+			if (!$mail_ui->mail_bo->folderExists($_folderName, true))
1500 1499
 			{
1501 1500
 				//error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead');
1502
-				$query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX';
1501
+				$query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX';
1503 1502
 			}
1504 1503
 		}
1505 1504
 		$rowsFetched['messages'] = null;
1506
-		$offset = $query['start']+1; // we always start with 1
1505
+		$offset = $query['start'] + 1; // we always start with 1
1507 1506
 		$maxMessages = $query['num_rows'];
1508 1507
 		//error_log(__METHOD__.__LINE__.array2string($query));
1509
-		$sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']);
1510
-		if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
1508
+		$sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']);
1509
+		if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
1511 1510
 		{
1512 1511
 			if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1513 1512
 			{
1514
-				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
1513
+				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1515 1514
 				if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1516 1515
 				{
1517
-					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
1516
+					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true;
1518 1517
 				}
1519 1518
 			}
1520 1519
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1521 1520
 			$cutoffdate = $cutoffdate2 = null;
1522
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1523
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1521
+			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
1522
+			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
1524 1523
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1525 1524
 			$filter = array(
1526
-				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
1527
-				'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
1525
+				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
1526
+				'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
1528 1527
 				'string' => $query['search'],
1529 1528
 				'status' => 'any',
1530 1529
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1531 1530
 			);
1532
-			if ($query['enddate']||$query['startdate']) {
1531
+			if ($query['enddate'] || $query['startdate']) {
1533 1532
 				$filter['range'] = "BETWEEN";
1534 1533
 				if ($cutoffdate) {
1535
-					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1534
+					$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
1536 1535
 					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1537 1536
 				}
1538 1537
 				if ($cutoffdate2) {
1539
-					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1538
+					$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
1540 1539
 					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1541 1540
 				}
1542 1541
 			}
@@ -1549,17 +1548,17 @@  discard block
 block discarded – undo
1549 1548
 		{
1550 1549
 			$filter['status'] = $query['filter'];
1551 1550
 		}
1552
-		$reverse = ($query['sort']=='ASC'?false:true);
1551
+		$reverse = ($query['sort'] == 'ASC' ? false : true);
1553 1552
 		$prefchanged = false;
1554
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1553
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1555 1554
 		{
1556 1555
 			//error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']);
1557
-			$GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user');
1556
+			$GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user');
1558 1557
 			$prefchanged = true;
1559 1558
 		}
1560
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1559
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1561 1560
 		{
1562
-			$GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user');
1561
+			$GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user');
1563 1562
 			$prefchanged = true;
1564 1563
 		}
1565 1564
 		if ($prefchanged)
@@ -1590,13 +1589,13 @@  discard block
 block discarded – undo
1590 1589
 				$rowsFetched['messages'] = $_sR['count'];
1591 1590
 				$ids = $_sR['match']->ids;
1592 1591
 				// if $sR is false, something failed fundamentally
1593
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1594
-				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1595
-				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1592
+				if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids));
1593
+				$sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids
1594
+				$sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1596 1595
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
1597 1596
 				$maxMessages = 75;
1598 1597
 				$sortResultwH['header'] = array();
1599
-				if (count($sRToFetch)>0)
1598
+				if (count($sRToFetch) > 0)
1600 1599
 				{
1601 1600
 					//error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch));
1602 1601
 					$sortResult = array();
@@ -1610,7 +1609,7 @@  discard block
 block discarded – undo
1610 1609
 						$filter,
1611 1610
 						$sRToFetch,
1612 1611
 						true, //cacheResult
1613
-						($query['filter2']?true:false) // fetchPreview
1612
+						($query['filter2'] ? true : false) // fetchPreview
1614 1613
 					);
1615 1614
 				}
1616 1615
 			}
@@ -1627,30 +1626,30 @@  discard block
 block discarded – undo
1627 1626
 					$filter,
1628 1627
 					null, // this uids only
1629 1628
 					true, // cacheResult
1630
-					($query['filter2']?true:false) // fetchPreview
1629
+					($query['filter2'] ? true : false) // fetchPreview
1631 1630
 				);
1632 1631
 				$rowsFetched['messages'] = $sortResultwH['info']['total'];
1633 1632
 			}
1634 1633
 		}
1635 1634
 		catch (Exception $e)
1636 1635
 		{
1637
-			$sortResultwH=array();
1638
-			$sR=array();
1636
+			$sortResultwH = array();
1637
+			$sR = array();
1639 1638
 			self::callWizard($e->getMessage(), false, 'error');
1640 1639
 		}
1641 1640
 		$response = Api\Json\Response::get();
1642 1641
 		// unlock immediately after fetching the rows
1643
-		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
1642
+		if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false)
1644 1643
 		{
1645 1644
 			//error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']);
1646 1645
 			$response->call('app.mail.unlock_tree');
1647 1646
 		}
1648 1647
 
1649
-		if (is_array($sR) && count($sR)>0)
1648
+		if (is_array($sR) && count($sR) > 0)
1650 1649
 		{
1651 1650
 			foreach ((array)$sR as $key => $v)
1652 1651
 			{
1653
-				if (array_key_exists($key,(array)$sortResultwH['header'])==true)
1652
+				if (array_key_exists($key, (array)$sortResultwH['header']) == true)
1654 1653
 				{
1655 1654
 					$sortResult['header'][] = $sortResultwH['header'][$key];
1656 1655
 				}
@@ -1668,16 +1667,16 @@  discard block
 block discarded – undo
1668 1667
 		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1669 1668
 
1670 1669
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1671
-		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1672
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1673
-		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1670
+		$cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview');
1671
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1672
+		$rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema);
1674 1673
 
1675 1674
 		// Save the session (since we are committing session) at the end
1676 1675
 		// to make sure all necessary data are stored in session.
1677 1676
 		// e.g.: Link:: get_data which is used to read attachments data.
1678 1677
 		$mail_ui->mail_bo->saveSessionData();
1679 1678
 
1680
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1679
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__);
1681 1680
 		return $rowsFetched['messages'];
1682 1681
 	}
1683 1682
 
@@ -1689,7 +1688,7 @@  discard block
 block discarded – undo
1689 1688
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1690 1689
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1691 1690
 	 */
1692
-	function createRowID($_folderName, $message_uid, $_prependApp=false)
1691
+	function createRowID($_folderName, $message_uid, $_prependApp = false)
1693 1692
 	{
1694 1693
 		return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp);
1695 1694
 	}
@@ -1703,9 +1702,9 @@  discard block
 block discarded – undo
1703 1702
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1704 1703
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1705 1704
 	 */
1706
-	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false)
1705
+	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false)
1707 1706
 	{
1708
-		return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1707
+		return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1709 1708
 	}
1710 1709
 
1711 1710
 	/**
@@ -1716,13 +1715,13 @@  discard block
 block discarded – undo
1716 1715
 	 */
1717 1716
 	static function splitRowID($_rowID)
1718 1717
 	{
1719
-		$res = explode(self::$delimiter,$_rowID);
1718
+		$res = explode(self::$delimiter, $_rowID);
1720 1719
 		// as a rowID is perceeded by app::, should be mail!
1721 1720
 		//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));
1722
-		if (count($res)==4 && is_numeric($res[0]) )
1721
+		if (count($res) == 4 && is_numeric($res[0]))
1723 1722
 		{
1724 1723
 			// we have an own created rowID; prepend app=mail
1725
-			array_unshift($res,'mail');
1724
+			array_unshift($res, 'mail');
1726 1725
 		}
1727 1726
 		return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]);
1728 1727
 	}
@@ -1736,60 +1735,60 @@  discard block
 block discarded – undo
1736 1735
 	{
1737 1736
 		$actions = $this->get_actions();
1738 1737
 		$arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print',
1739
-			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1',	'label2', 'label3',	'label4', 'label5','spam', 'ham');
1740
-		foreach( $arrActions as &$act)
1738
+			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5', 'spam', 'ham');
1739
+		foreach ($arrActions as &$act)
1741 1740
 		{
1742 1741
 			//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
1743 1742
 			switch ($act)
1744 1743
 			{
1745 1744
 				case 'forward':
1746
-					$actionsenabled[$act]=$actions[$act];
1745
+					$actionsenabled[$act] = $actions[$act];
1747 1746
 					break;
1748 1747
 				case 'save':
1749
-					$actionsenabled[$act]=$actions[$act];
1748
+					$actionsenabled[$act] = $actions[$act];
1750 1749
 
1751 1750
 					break;
1752 1751
 				case 'view':
1753
-					$actionsenabled[$act]=$actions[$act];
1752
+					$actionsenabled[$act] = $actions[$act];
1754 1753
 					break;
1755 1754
 				case 'flagged':
1756
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1755
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1757 1756
 					break;
1758 1757
 				case 'read':
1759
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1758
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1760 1759
 					break;
1761 1760
 				case 'label1':
1762 1761
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important');
1763
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1762
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1764 1763
 					break;
1765 1764
 				case 'label2':
1766 1765
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job');
1767
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1766
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1768 1767
 					break;
1769 1768
 				case 'label3':
1770 1769
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal');
1771
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1770
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1772 1771
 					break;
1773 1772
 				case 'label4':
1774 1773
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do');
1775
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1774
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1776 1775
 					break;
1777 1776
 				case 'label5':
1778 1777
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later');
1779
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1778
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1780 1779
 					break;
1781 1780
 				case 'ham':
1782 1781
 				case 'spam':
1783
-					$actionsenabled[$act]= $actions['spamfilter']['children'][$act];
1782
+					$actionsenabled[$act] = $actions['spamfilter']['children'][$act];
1784 1783
 					break;
1785 1784
 				default:
1786
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1785
+					if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act];
1787 1786
 			}
1788 1787
 		}
1789 1788
 		unset($actionsenabled['drag_mail']);
1790 1789
 		//error_log(array2string($actionsenabled['view']));
1791
-		unset($actionsenabled['view']['children']['openastext']);//not supported in preview
1792
-		unset($actionsenabled['view']['children']['openashtml']);//not supported in preview
1790
+		unset($actionsenabled['view']['children']['openastext']); //not supported in preview
1791
+		unset($actionsenabled['view']['children']['openashtml']); //not supported in preview
1793 1792
 
1794 1793
 		return $actionsenabled;
1795 1794
 	}
@@ -1803,45 +1802,45 @@  discard block
 block discarded – undo
1803 1802
 	 * @param array $_folderType used to determine if we need to populate from/to
1804 1803
 	 * @return array populated result array
1805 1804
 	 */
1806
-	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1805
+	public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0)
1807 1806
 	{
1808 1807
 		if (Mail::$debugTimes) $starttime = microtime(true);
1809 1808
 		$rv = array();
1810
-		$i=0;
1811
-		foreach((array)$_headers as $header)
1809
+		$i = 0;
1810
+		foreach ((array)$_headers as $header)
1812 1811
 		{
1813 1812
 			$i++;
1814 1813
 			$data = array();
1815 1814
 			//error_log(__METHOD__.array2string($header));
1816 1815
 			$message_uid = $header['uid'];
1817 1816
 			$data['uid'] = $message_uid;
1818
-			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1817
+			$data['row_id'] = $this->createRowID($_folderName, $message_uid);
1819 1818
 
1820 1819
 			$flags = "";
1821
-			if(!empty($header['recent'])) $flags .= "R";
1822
-			if(!empty($header['flagged'])) $flags .= "F";
1823
-			if(!empty($header['answered'])) $flags .= "A";
1824
-			if(!empty($header['forwarded'])) $flags .= "W";
1825
-			if(!empty($header['deleted'])) $flags .= "D";
1826
-			if(!empty($header['seen'])) $flags .= "S";
1827
-			if(!empty($header['label1'])) $flags .= "1";
1828
-			if(!empty($header['label2'])) $flags .= "2";
1829
-			if(!empty($header['label3'])) $flags .= "3";
1830
-			if(!empty($header['label4'])) $flags .= "4";
1831
-			if(!empty($header['label5'])) $flags .= "5";
1820
+			if (!empty($header['recent'])) $flags .= "R";
1821
+			if (!empty($header['flagged'])) $flags .= "F";
1822
+			if (!empty($header['answered'])) $flags .= "A";
1823
+			if (!empty($header['forwarded'])) $flags .= "W";
1824
+			if (!empty($header['deleted'])) $flags .= "D";
1825
+			if (!empty($header['seen'])) $flags .= "S";
1826
+			if (!empty($header['label1'])) $flags .= "1";
1827
+			if (!empty($header['label2'])) $flags .= "2";
1828
+			if (!empty($header['label3'])) $flags .= "3";
1829
+			if (!empty($header['label4'])) $flags .= "4";
1830
+			if (!empty($header['label5'])) $flags .= "5";
1832 1831
 
1833 1832
 			$data["status"] = "<span class=\"status_img\"></span>";
1834 1833
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
1835 1834
 
1836 1835
 			// the css for this row
1837
-			$is_recent=false;
1836
+			$is_recent = false;
1838 1837
 			$css_styles = array("mail");
1839 1838
 			if ($header['deleted']) {
1840 1839
 				$css_styles[] = 'deleted';
1841 1840
 			}
1842 1841
 			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1843 1842
 				$css_styles[] = 'recent';
1844
-				$is_recent=true;
1843
+				$is_recent = true;
1845 1844
 			}
1846 1845
 			if ($header['priority'] < 3) {
1847 1846
 				$css_styles[] = 'prio_high';
@@ -1879,19 +1878,19 @@  discard block
 block discarded – undo
1879 1878
 			if (in_array("subject", $cols))
1880 1879
 			{
1881 1880
 				// filter out undisplayable characters
1882
-				$search = array('[\016]','[\017]',
1883
-					'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1884
-					'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1881
+				$search = array('[\016]', '[\017]',
1882
+					'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1883
+					'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1885 1884
 				$replace = '';
1886 1885
 
1887
-				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1886
+				$header['subject'] = preg_replace($search, $replace, $header['subject']);
1888 1887
 				// curly brackets get messed up by the template!
1889 1888
 
1890 1889
 				if (!empty($header['subject'])) {
1891 1890
 					// make the subject shorter if it is to long
1892 1891
 					$subject = $header['subject'];
1893 1892
 				} else {
1894
-					$subject = '('. lang('no subject') .')';
1893
+					$subject = '('.lang('no subject').')';
1895 1894
 				}
1896 1895
 
1897 1896
 				$data["subject"] = $subject; // the mailsubject
@@ -1901,53 +1900,53 @@  discard block
 block discarded – undo
1901 1900
 			//error_log(__METHOD__.__LINE__.array2string($header));
1902 1901
 			if (in_array("attachments", $cols))
1903 1902
 			{
1904
-				if($header['mimetype'] == 'multipart/mixed' ||
1903
+				if ($header['mimetype'] == 'multipart/mixed' ||
1905 1904
 					$header['mimetype'] == 'multipart/signed' ||
1906 1905
 					$header['mimetype'] == 'multipart/related' ||
1907 1906
 					$header['mimetype'] == 'multipart/report' ||
1908 1907
 					$header['mimetype'] == 'text/calendar' ||
1909 1908
 					$header['mimetype'] == 'text/html' ||
1910
-					substr($header['mimetype'],0,11) == 'application' ||
1911
-					substr($header['mimetype'],0,5) == 'audio' ||
1912
-					substr($header['mimetype'],0,5) == 'video' ||
1909
+					substr($header['mimetype'], 0, 11) == 'application' ||
1910
+					substr($header['mimetype'], 0, 5) == 'audio' ||
1911
+					substr($header['mimetype'], 0, 5) == 'video' ||
1913 1912
 					$header['mimetype'] == 'multipart/alternative')
1914 1913
 				{
1915
-					$image = Api\Html::image('mail','attach');
1914
+					$image = Api\Html::image('mail', 'attach');
1916 1915
 					$imageHTMLBlock = '';
1917
-					$datarowid = $this->createRowID($_folderName,$message_uid,true);
1916
+					$datarowid = $this->createRowID($_folderName, $message_uid, true);
1918 1917
 					$attachments = $header['attachments'];
1919
-					if (count($attachments)<1)
1918
+					if (count($attachments) < 1)
1920 1919
 					{
1921 1920
 						$image = '&nbsp;';
1922 1921
 					}
1923
-					if (count($attachments)==1)
1922
+					if (count($attachments) == 1)
1924 1923
 					{
1925
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1926
-						$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
1924
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1925
+						$image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : ''));
1927 1926
 					}
1928
-					if (count($attachments)>1)
1927
+					if (count($attachments) > 1)
1929 1928
 					{
1930
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1931
-						$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
1929
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1930
+						$image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments)));
1932 1931
 					}
1933 1932
 
1934 1933
 					$attachmentFlag = $image;
1935 1934
 				} else {
1936
-					$attachmentFlag ='&nbsp;';
1935
+					$attachmentFlag = '&nbsp;';
1937 1936
 				}
1938 1937
 				// show priority flag
1939 1938
 				if ($header['priority'] < 3) {
1940
-					 $image = Api\Html::image('mail','prio_high');
1939
+					 $image = Api\Html::image('mail', 'prio_high');
1941 1940
 				} elseif ($header['priority'] > 3) {
1942
-					$image = Api\Html::image('mail','prio_low');
1941
+					$image = Api\Html::image('mail', 'prio_low');
1943 1942
 				} else {
1944 1943
 					$image = '';
1945 1944
 				}
1946 1945
 				// show a flag for flagged messages
1947
-				$imageflagged ='';
1946
+				$imageflagged = '';
1948 1947
 				if ($header['flagged'])
1949 1948
 				{
1950
-					$imageflagged = Api\Html::image('mail','unread_flagged_small');
1949
+					$imageflagged = Api\Html::image('mail', 'unread_flagged_small');
1951 1950
 				}
1952 1951
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
1953 1952
 			}
@@ -1956,7 +1955,7 @@  discard block
 block discarded – undo
1956 1955
 			if (in_array("toaddress", $cols))
1957 1956
 			{
1958 1957
 				// sent or drafts or template folder means foldertype > 0, use to address instead of from
1959
-				$data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset);
1958
+				$data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset);
1960 1959
 			}
1961 1960
 
1962 1961
 			if (in_array("additionaltoaddress", $cols))
@@ -1989,29 +1988,29 @@  discard block
 block discarded – undo
1989 1988
 			$data['flags'] = Array();
1990 1989
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1991 1990
 			foreach ($css_styles as &$flag) {
1992
-				if ($flag!='mail')
1991
+				if ($flag != 'mail')
1993 1992
 				{
1994
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1995
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1996
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1997
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1998
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1999
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1993
+					if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; }
1994
+					elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; }
1995
+					elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; }
1996
+					elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; }
1997
+					elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; }
1998
+					elseif ($flag == 'unseen') {unset($data["flags"]['read']); }
2000 1999
 					else $data["flags"][$flag] = $flag;
2001 2000
 				}
2002 2001
 			}
2003 2002
 			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
2004
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2003
+			if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2005 2004
 			$data['attachmentsBlock'] = $imageHTMLBlock;
2006
-			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
2007
-			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
2005
+			$data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]);
2006
+			if (in_array("bodypreview", $cols) && $header['bodypreview'])
2008 2007
 			{
2009 2008
 				$data["bodypreview"] = $header['bodypreview'];
2010 2009
 			}
2011 2010
 			$rv[] = $data;
2012 2011
 			//error_log(__METHOD__.__LINE__.array2string($data));
2013 2012
 		}
2014
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2013
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__);
2015 2014
 
2016 2015
 		// ToDo: call this ONLY if labels change
2017 2016
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -2026,8 +2025,8 @@  discard block
 block discarded – undo
2026 2025
 	 */
2027 2026
 	function displayHeader()
2028 2027
 	{
2029
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2030
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2028
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2029
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2031 2030
 
2032 2031
 		$hA = self::splitRowID($rowID);
2033 2032
 		$uid = $hA['msgUID'];
@@ -2041,17 +2040,17 @@  discard block
 block discarded – undo
2041 2040
 		}
2042 2041
 
2043 2042
 		$this->mail_bo->reopen($mailbox);
2044
-		$headers_in	= $this->mail_bo->getMessageRawHeader($uid, $partID);
2043
+		$headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID);
2045 2044
 
2046 2045
 		// add line breaks to $rawheaders
2047
-		$newRawHeaders = explode("\n",$headers_in);
2046
+		$newRawHeaders = explode("\n", $headers_in);
2048 2047
 		reset($newRawHeaders);
2049 2048
 
2050 2049
 		// reset $rawheaders
2051
-		$rawheaders 	= "";
2050
+		$rawheaders = "";
2052 2051
 		// create it new, with good line breaks
2053 2052
 		reset($newRawHeaders);
2054
-		while(list($key,$value) = @each($newRawHeaders)) {
2053
+		while (list($key, $value) = @each($newRawHeaders)) {
2055 2054
 			$rawheaders .= wordwrap($value, 90, "\n     ");
2056 2055
 		}
2057 2056
 
@@ -2063,7 +2062,7 @@  discard block
 block discarded – undo
2063 2062
 		}
2064 2063
 
2065 2064
 		header('Content-type: text/html; charset=iso-8859-1');
2066
-		print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
2065
+		print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>';
2067 2066
 
2068 2067
 	}
2069 2068
 
@@ -2076,10 +2075,10 @@  discard block
 block discarded – undo
2076 2075
 	{
2077 2076
 		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2078 2077
 
2079
-		$preventRedirect=false;
2080
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
2081
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2082
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2078
+		$preventRedirect = false;
2079
+		if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id'];
2080
+		if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null;
2081
+		if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false);
2083 2082
 
2084 2083
 		$hA = self::splitRowID($rowID);
2085 2084
 		$uid = $hA['msgUID'];
@@ -2103,79 +2102,79 @@  discard block
 block discarded – undo
2103 2102
 		}
2104 2103
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
2105 2104
 		{
2106
-			Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
2105
+			Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft'));
2107 2106
 		}
2108 2107
 		$this->mail_bo->reopen($mailbox);
2109 2108
 		// retrieve the flags of the message, before touching it.
2110 2109
 		try
2111 2110
 		{
2112
-			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
2111
+			$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox);
2113 2112
 		}
2114 2113
 		catch (Api\Exception $e)
2115 2114
 		{
2116 2115
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
2117
-			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
2116
+			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID);
2118 2117
 			Framework::message($e->getMessage(), 'error');
2119 2118
 		}
2120 2119
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2121
-		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
2120
+		$envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox);
2122 2121
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
2123
-		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
2122
+		$this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox);
2124 2123
 		$fetchEmbeddedImages = false;
2125 2124
 		// if we are in HTML so its likely that we should show the embedded images; as a result
2126 2125
 		// we do NOT want to see those, that are embedded in the list of attachments
2127
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2128
-		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
2126
+		if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true;
2127
+		$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox);
2129 2128
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2130 2129
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
2131 2130
 
2132
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2133
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2134
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2131
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2132
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2133
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2135 2134
 
2136 2135
 		//error_log(__METHOD__.__LINE__.$mailBody);
2137 2136
 		$this->mail_bo->closeConnection();
2138 2137
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
2139 2138
 		$etpl = new Etemplate('mail.display');
2140
-		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2139
+		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false);
2141 2140
 
2142 2141
 		// Set up data for taglist widget(s)
2143
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2142
+		if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']);
2144 2143
 		$sel_options = array();
2145
-		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2144
+		foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field)
2146 2145
 		{
2147 2146
 			if (!isset($envelope[$field])) continue;
2148
-			foreach($envelope[$field] as $field_data)
2147
+			foreach ($envelope[$field] as $field_data)
2149 2148
 			{
2150 2149
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
2151 2150
 				$content[$field][] = $field_data;
2152 2151
 				$sel_options[$field][] = array(
2153 2152
 					// taglist requires these - not optional
2154 2153
 					'id' => $field_data,
2155
-					'label' => str_replace('"',"'",$field_data),
2154
+					'label' => str_replace('"', "'", $field_data),
2156 2155
 				);
2157 2156
 			}
2158 2157
 		}
2159 2158
 		$actionsenabled = $this->getDisplayToolbarActions();
2160 2159
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2161 2160
 		if (empty($subject)) $subject = lang('no subject');
2162
-		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2161
+		$content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg);
2163 2162
 		// Send mail ID so we can use it for actions
2164 2163
 		$content['mail_id'] = $rowID;
2165 2164
 		if (!is_array($headers) || !isset($headers['DATE']))
2166 2165
 		{
2167
-			$headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:'');
2166
+			$headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : '');
2168 2167
 		}
2169
-		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2168
+		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true);
2170 2169
 		$content['mail_displaysubject'] = $subject;
2171
-		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2172
-		if (!empty($partID)) $linkData['_partID']=$partID;
2173
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2174
-		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2170
+		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID);
2171
+		if (!empty($partID)) $linkData['_partID'] = $partID;
2172
+		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions;
2173
+		$content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData);
2175 2174
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2176
-		$content['mail_id']=$rowID;
2177
-		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
2178
-		$content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone");
2175
+		$content['mail_id'] = $rowID;
2176
+		$content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight");
2177
+		$content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone");
2179 2178
 
2180 2179
 		// DRAG attachments actions
2181 2180
 		$etpl->setElementAttribute('mail_displayattachments', 'actions', array(
@@ -2192,22 +2191,22 @@  discard block
 block discarded – undo
2192 2191
 			$this->changeProfile($rememberServerID);
2193 2192
 		}
2194 2193
 
2195
-		$etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
2194
+		$etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2);
2196 2195
 	}
2197 2196
 
2198 2197
 	/**
2199 2198
 	 * Build actions for display toolbar
2200 2199
 	 */
2201
-	function getDisplayToolbarActions ()
2200
+	function getDisplayToolbarActions()
2202 2201
 	{
2203 2202
 		$actions = $this->get_toolbar_actions();
2204
-		$actions['mark']['children']['flagged']=array(
2203
+		$actions['mark']['children']['flagged'] = array(
2205 2204
 			'group' => $actions['mark']['children']['flagged']['group'],
2206 2205
 			'caption' => 'Flagged',
2207 2206
 			'icon' => 'unread_flagged_small',
2208 2207
 			'onExecute' => 'javaScript:app.mail.mail_flag',
2209 2208
 		);
2210
-		$actions['mark']['children']['unflagged']=array(
2209
+		$actions['mark']['children']['unflagged'] = array(
2211 2210
 			'group' => $actions['mark']['children']['flagged']['group'],
2212 2211
 			'caption' => 'Unflagged',
2213 2212
 			'icon' => 'read_flagged_small',
@@ -2219,9 +2218,9 @@  discard block
 block discarded – undo
2219 2218
 		$compose = $actions['composeasnew'];
2220 2219
 		unset($actions['composeasnew']);
2221 2220
 
2222
-		$actions2 = array_reverse($actions,true);
2223
-		$actions2['composeasnew']= $compose;
2224
-		return array_reverse($actions2,true);
2221
+		$actions2 = array_reverse($actions, true);
2222
+		$actions2['composeasnew'] = $compose;
2223
+		return array_reverse($actions2, true);
2225 2224
 	}
2226 2225
 
2227 2226
 	/**
@@ -2234,22 +2233,22 @@  discard block
 block discarded – undo
2234 2233
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
2235 2234
 	 * @return array|string data array or html or empty string
2236 2235
 	 */
2237
-	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
2236
+	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false)
2238 2237
 	{
2239
-		$attachmentHTMLBlock='';
2238
+		$attachmentHTMLBlock = '';
2240 2239
 		$attachmentHTML = array();
2241 2240
 		if (is_array($attachments) && count($attachments) > 0) {
2242
-			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2243
-			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2241
+			$url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"');
2242
+			$url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all'));
2244 2243
 
2245 2244
 			foreach ($attachments as $key => $value)
2246 2245
 			{
2247
-				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
2248
-				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2246
+				$attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)'));
2247
+				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8');
2249 2248
 				//error_log(array2string($value));
2250 2249
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2251
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2252
-				$attachmentHTML[$key]['type']=$value['mimeType'];
2250
+				if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2251
+				$attachmentHTML[$key]['type'] = $value['mimeType'];
2253 2252
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2254 2253
 				$hA = self::splitRowID($rowID);
2255 2254
 				$uid = $hA['msgUID'];
@@ -2259,28 +2258,27 @@  discard block
 block discarded – undo
2259 2258
 				$attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
2260 2259
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
2261 2260
 				));
2262
-				$attachmentHTML[$key]['size']=Vfs::hsize($value['size']);
2263
-				$attachmentHTML[$key]['attachment_number']=$key;
2264
-				$attachmentHTML[$key]['partID']=$value['partID'];
2261
+				$attachmentHTML[$key]['size'] = Vfs::hsize($value['size']);
2262
+				$attachmentHTML[$key]['attachment_number'] = $key;
2263
+				$attachmentHTML[$key]['partID'] = $value['partID'];
2265 2264
 				$attachmentHTML[$key]['mail_id'] = $rowID;
2266
-				$attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
2265
+				$attachmentHTML[$key]['winmailFlag'] = $value['is_winmail'];
2267 2266
 				$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
2268 2267
 				// reset mode array as it should be considered differently for
2269 2268
 				// each attachment
2270 2269
 				$mode = array();
2271
-				switch(strtoupper($value['mimeType']))
2270
+				switch (strtoupper($value['mimeType']))
2272 2271
 				{
2273 2272
 					case 'MESSAGE/RFC822':
2274
-						$linkData = array
2275
-						(
2273
+						$linkData = array(
2276 2274
 							'menuaction'	=> 'mail.mail_ui.displayMessage',
2277 2275
 							'mode'		=> 'display', //message/rfc822 attachments should be opened in display mode
2278 2276
 							'id'		=> $rowID,
2279 2277
 							'part'		=> $value['partID'],
2280 2278
 							'is_winmail'    => $value['is_winmail']
2281 2279
 						);
2282
-						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
2283
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2280
+						$windowName = 'displayMessage_'.$rowID.'_'.$value['partID'];
2281
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2284 2282
 						break;
2285 2283
 					case 'IMAGE/JPEG':
2286 2284
 					case 'IMAGE/PNG':
@@ -2296,7 +2294,7 @@  discard block
 block discarded – undo
2296 2294
 					case 'TEXT/HTML':
2297 2295
 					case 'TEXT/DIRECTORY':
2298 2296
 						$sfxMimeType = $value['mimeType'];
2299
-						$buff = explode('.',$value['name']);
2297
+						$buff = explode('.', $value['name']);
2300 2298
 						$suffix = '';
2301 2299
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2302 2300
 						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2309,49 +2307,47 @@  discard block
 block discarded – undo
2309 2307
 					case 'TEXT/VCARD':
2310 2308
 					case 'TEXT/CALENDAR':
2311 2309
 					case 'TEXT/X-VCALENDAR':
2312
-						$linkData = array_merge(array
2313
-						(
2310
+						$linkData = array_merge(array(
2314 2311
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2315 2312
 							'id'		=> $rowID,
2316 2313
 							'part'		=> $value['partID'],
2317 2314
 							'is_winmail'    => $value['is_winmail'],
2318 2315
 							'mailbox'   => base64_encode($mailbox),
2319
-						) , $mode);
2320
-						$windowName = 'displayAttachment_'. $uid;
2316
+						), $mode);
2317
+						$windowName = 'displayAttachment_'.$uid;
2321 2318
 						$reg = '800x600';
2322 2319
 						// handle calendar/vcard
2323
-						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
2320
+						if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR')
2324 2321
 						{
2325
-							$windowName = 'displayEvent_'. $rowID;
2326
-							$reg2 = Link::get_registry('calendar','view_popup');
2327
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2322
+							$windowName = 'displayEvent_'.$rowID;
2323
+							$reg2 = Link::get_registry('calendar', 'view_popup');
2324
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2328 2325
 						}
2329
-						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
2326
+						if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD')
2330 2327
 						{
2331
-							$windowName = 'displayContact_'. $rowID;
2332
-							$reg2 = Link::get_registry('addressbook','add_popup');
2333
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2328
+							$windowName = 'displayContact_'.$rowID;
2329
+							$reg2 = Link::get_registry('addressbook', 'add_popup');
2330
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2334 2331
 						}
2335 2332
 						// apply to action
2336
-						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
2337
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
2333
+						list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg));
2334
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);";
2338 2335
 						break;
2339 2336
 					default:
2340
-						$linkData = array
2341
-						(
2337
+						$linkData = array(
2342 2338
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2343 2339
 							'id'		=> $rowID,
2344 2340
 							'part'		=> $value['partID'],
2345 2341
 							'is_winmail'    => $value['is_winmail'],
2346 2342
 							'mailbox'   => base64_encode($mailbox),
2347 2343
 						);
2348
-						$linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';";
2344
+						$linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';";
2349 2345
 						break;
2350 2346
 				}
2351 2347
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
2352 2348
 				if (empty($attachmentHTML[$key]['mime_data']))
2353 2349
 				{
2354
-					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData);
2350
+					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData);
2355 2351
 					unset($attachmentHTML[$key]['mime_data']);
2356 2352
 				}
2357 2353
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2361,8 +2357,7 @@  discard block
 block discarded – undo
2361 2357
 					($value['name'] ? $value['name'] : lang('(no subject)')).
2362 2358
 					'</b></a>';
2363 2359
 
2364
-				$linkData = array
2365
-				(
2360
+				$linkData = array(
2366 2361
 					'menuaction'	=> 'mail.mail_ui.getAttachment',
2367 2362
 					'mode'		=> 'save',
2368 2363
 					'id'		=> $rowID,
@@ -2370,11 +2365,11 @@  discard block
 block discarded – undo
2370 2365
 					'is_winmail'    => $value['is_winmail'],
2371 2366
 					'mailbox'   => base64_encode($mailbox),
2372 2367
 				);
2373
-				$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
2368
+				$attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>";
2374 2369
 
2375 2370
 				if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
2376 2371
 				{
2377
-					$link_vfs_save = Egw::link('/index.php',array(
2372
+					$link_vfs_save = Egw::link('/index.php', array(
2378 2373
 						'menuaction' => 'filemanager.filemanager_select.select',
2379 2374
 						'mode' => 'saveas',
2380 2375
 						'name' => $value['name'],
@@ -2393,19 +2388,19 @@  discard block
 block discarded – undo
2393 2388
 							//$rowID
2394 2389
 							$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
2395 2390
 						}
2396
-						$link_vfs_save = Egw::link('/index.php',array(
2391
+						$link_vfs_save = Egw::link('/index.php', array(
2397 2392
 							'menuaction' => 'filemanager.filemanager_select.select',
2398 2393
 							'mode' => 'select-dir',
2399 2394
 							'method' => 'mail.mail_ui.vfsSaveAttachment',
2400 2395
 							'label' => lang('Save all'),
2401
-						)+$ids);
2396
+						) + $ids);
2402 2397
 						$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>";
2403 2398
 					}
2404 2399
 					$attachmentHTML[$key]['link_save'] .= $vfs_save;
2405 2400
 					//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
2406 2401
 				}
2407 2402
 			}
2408
-			$attachmentHTMLBlock="<table width='100%'>";
2403
+			$attachmentHTMLBlock = "<table width='100%'>";
2409 2404
 			foreach ((array)$attachmentHTML as $row)
2410 2405
 			{
2411 2406
 				$attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>';
@@ -2423,7 +2418,7 @@  discard block
 block discarded – undo
2423 2418
 				unset($attachmentHTML[$ikey]['link_save']);
2424 2419
 			}
2425 2420
 		}
2426
-		return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML);
2421
+		return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML);
2427 2422
 	}
2428 2423
 
2429 2424
 	/**
@@ -2434,7 +2429,7 @@  discard block
 block discarded – undo
2434 2429
 	 */
2435 2430
 	function gatherVacation($cachedVacations = array())
2436 2431
 	{
2437
-		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host);
2432
+		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host);
2438 2433
 		//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
2439 2434
 
2440 2435
 		if ($isVacationEnabled)
@@ -2447,7 +2442,7 @@  discard block
 block discarded – undo
2447 2442
 
2448 2443
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
2449 2444
 				// Set vacation to the instance cache for particular account with expiration of one day
2450
-				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
2445
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24);
2451 2446
 			}
2452 2447
 			catch (PEAR_Exception $ex)
2453 2448
 			{
@@ -2473,35 +2468,35 @@  discard block
 block discarded – undo
2473 2468
 	 */
2474 2469
 	function quotaDisplay($_usage, $_limit)
2475 2470
 	{
2476
-		$percent = $_limit == 0 ? 100 : round(($_usage*100)/$_limit);
2477
-		$limit = Mail::show_readable_size($_limit*1024);
2478
-		$usage = Mail::show_readable_size($_usage*1024);
2471
+		$percent = $_limit == 0 ? 100 : round(($_usage * 100) / $_limit);
2472
+		$limit = Mail::show_readable_size($_limit * 1024);
2473
+		$usage = Mail::show_readable_size($_usage * 1024);
2479 2474
 
2480 2475
 		if ($_limit > 0)
2481 2476
 		{
2482
-			$text = $usage .'/'.$limit;
2477
+			$text = $usage.'/'.$limit;
2483 2478
 			switch ($percent)
2484 2479
 			{
2485 2480
 				case 90:
2486
-					$class ='mail-index_QuotaRed';
2481
+					$class = 'mail-index_QuotaRed';
2487 2482
 					break;
2488 2483
 				case 80:
2489
-					$class ='mail-index_QuotaYellow';
2484
+					$class = 'mail-index_QuotaYellow';
2490 2485
 					break;
2491 2486
 				default:
2492
-					$class ='mail-index_QuotaGreen';
2487
+					$class = 'mail-index_QuotaGreen';
2493 2488
 			}
2494 2489
 		}
2495 2490
 		else
2496 2491
 		{
2497 2492
 			$text = $usage;
2498
-			$class ='mail-index_QuotaGreen';
2493
+			$class = 'mail-index_QuotaGreen';
2499 2494
 		}
2500
-		return array (
2495
+		return array(
2501 2496
 			'class'		=> $class,
2502
-			'text'		=> lang('Quota: %1',$text),
2497
+			'text'		=> lang('Quota: %1', $text),
2503 2498
 			'percent'	=> $percent,
2504
-			'freespace'	=> $_limit*1024 - $_usage*1024
2499
+			'freespace'	=> $_limit * 1024 - $_usage * 1024
2505 2500
 		);
2506 2501
 	}
2507 2502
 
@@ -2515,12 +2510,12 @@  discard block
 block discarded – undo
2515 2510
 		$uid	= $_GET['uid'];
2516 2511
 		$cid	= base64_decode($_GET['cid']);
2517 2512
 		$partID = urldecode($_GET['partID']);
2518
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2513
+		if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']);
2519 2514
 
2520 2515
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2521 2516
 		$this->mail_bo->reopen($mailbox);
2522 2517
 
2523
-		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true);	// true get contents as stream
2518
+		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream
2524 2519
 
2525 2520
 		$this->mail_bo->closeConnection();
2526 2521
 
@@ -2528,8 +2523,8 @@  discard block
 block discarded – undo
2528 2523
 
2529 2524
 		if ($attachment)
2530 2525
 		{
2531
-			header("Content-Type: ". $attachment->getType());
2532
-			header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"');
2526
+			header("Content-Type: ".$attachment->getType());
2527
+			header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"');
2533 2528
 			//header("Expires: 0");
2534 2529
 			// the next headers are for IE and SSL
2535 2530
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -2547,7 +2542,7 @@  discard block
 block discarded – undo
2547 2542
 
2548 2543
 	function getAttachment()
2549 2544
 	{
2550
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2545
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2551 2546
 
2552 2547
 		$hA = self::splitRowID($rowID);
2553 2548
 		$uid = $hA['msgUID'];
@@ -2559,11 +2554,11 @@  discard block
 block discarded – undo
2559 2554
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2560 2555
 			$this->changeProfile($icServerID);
2561 2556
 		}
2562
-		$part		= $_GET['part'];
2557
+		$part = $_GET['part'];
2563 2558
 		$is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0;
2564 2559
 
2565 2560
 		$this->mail_bo->reopen($mailbox);
2566
-		$attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false);
2561
+		$attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false);
2567 2562
 		$this->mail_bo->closeConnection();
2568 2563
 		if ($rememberServerID != $this->mail_bo->profileID)
2569 2564
 		{
@@ -2578,7 +2573,7 @@  discard block
 block discarded – undo
2578 2573
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type']))
2579 2574
 			{
2580 2575
 				$sfxMimeType = $attachment['type'];
2581
-				$buff = explode('.',$attachment['filename']);
2576
+				$buff = explode('.', $attachment['filename']);
2582 2577
 				$suffix = '';
2583 2578
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2584 2579
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2590,10 +2585,10 @@  discard block
 block discarded – undo
2590 2585
 			{
2591 2586
 				//error_log(__METHOD__."about to call calendar_ical");
2592 2587
 				$calendar_ical = new calendar_ical();
2593
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2588
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2594 2589
 				//error_log(__METHOD__.array2string($eventid));
2595 2590
 				if (!$eventid) $eventid = -1;
2596
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2591
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']);
2597 2592
 				//error_log(__METHOD__.$event);
2598 2593
 				if ((int)$event > 0)
2599 2594
 				{
@@ -2601,7 +2596,7 @@  discard block
 block discarded – undo
2601 2596
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2602 2597
 						'cal_id'      => $event,
2603 2598
 					);
2604
-					Egw::redirect_link('../index.php',$vars);
2599
+					Egw::redirect_link('../index.php', $vars);
2605 2600
 				}
2606 2601
 				//Import failed, download content anyway
2607 2602
 			}
@@ -2616,13 +2611,13 @@  discard block
 block discarded – undo
2616 2611
 				{
2617 2612
 					$vcard['uid'] = trim($vcard['uid']);
2618 2613
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2619
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2614
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2620 2615
 				}
2621 2616
 				if (!$contact) $contact = null;
2622 2617
 				// 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))
2623
-				if ($contact || count($vcard)>2)
2618
+				if ($contact || count($vcard) > 2)
2624 2619
 				{
2625
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2620
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']);
2626 2621
 				}
2627 2622
 				if ((int)$contact > 0)
2628 2623
 				{
@@ -2630,14 +2625,14 @@  discard block
 block discarded – undo
2630 2625
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2631 2626
 						'contact_id'	=> $contact,
2632 2627
 					);
2633
-					Egw::redirect_link('../index.php',$vars);
2628
+					Egw::redirect_link('../index.php', $vars);
2634 2629
 				}
2635 2630
 				//Import failed, download content anyway
2636 2631
 			}
2637 2632
 		}
2638 2633
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2639
-		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
2640
-		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
2634
+		$filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part));
2635
+		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save");
2641 2636
 		echo $attachment['attachment'];
2642 2637
 
2643 2638
 		exit();
@@ -2652,9 +2647,9 @@  discard block
 block discarded – undo
2652 2647
 	function saveMessage()
2653 2648
 	{
2654 2649
 		$display = false;
2655
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2656
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2657
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2650
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2651
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2652
+		if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location'];
2658 2653
 
2659 2654
 		$hA = self::splitRowID($rowID);
2660 2655
 		$uid = $hA['msgUID'];
@@ -2682,14 +2677,14 @@  discard block
 block discarded – undo
2682 2677
 		if (!$display)
2683 2678
 		{
2684 2679
 			$headers = Horde_Mime_Headers::parseHeaders($message);
2685
-			$subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT']));
2686
-			Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
2680
+			$subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT']));
2681
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true);
2687 2682
 			echo $message;
2688 2683
 		}
2689 2684
 		else
2690 2685
 		{
2691
-			Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false);
2692
-			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
2686
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false);
2687
+			print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>';
2693 2688
 		}
2694 2689
 	}
2695 2690
 
@@ -2701,18 +2696,18 @@  discard block
 block discarded – undo
2701 2696
 	 * @param boolean $close Return javascript to close the window
2702 2697
 	 * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
2703 2698
 	 */
2704
-	function vfsSaveMessage($ids,$path, $close = true)
2699
+	function vfsSaveMessage($ids, $path, $close = true)
2705 2700
 	{
2706 2701
 		//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
2707 2702
 
2708 2703
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2709 2704
 		{
2710
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2705
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2711 2706
 		}
2712 2707
 		Api\Translation::add_app('mail');
2713 2708
 
2714 2709
 		$rememberServerID = $this->mail_bo->profileID;
2715
-		foreach((array)$ids as $id)
2710
+		foreach ((array)$ids as $id)
2716 2711
 		{
2717 2712
 			$hA = self::splitRowID($id);
2718 2713
 			$uid = $hA['msgUID'];
@@ -2723,20 +2718,20 @@  discard block
 block discarded – undo
2723 2718
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2724 2719
 				$this->changeProfile($icServerID);
2725 2720
 			}
2726
-			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
2727
-			$err=null;
2728
-			if(Vfs::is_dir($path))
2721
+			$message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox);
2722
+			$err = null;
2723
+			if (Vfs::is_dir($path))
2729 2724
 			{
2730
-				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
2731
-				$file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml';
2725
+				$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2726
+				$file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml';
2732 2727
 			}
2733 2728
 			else
2734 2729
 			{
2735 2730
 				$file = $path;
2736 2731
 			}
2737
-			if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message))
2732
+			if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message))
2738 2733
 			{
2739
-				$err .= lang('Error saving %1!',$file);
2734
+				$err .= lang('Error saving %1!', $file);
2740 2735
 				$succeeded = false;
2741 2736
 			}
2742 2737
 			else
@@ -2746,10 +2741,10 @@  discard block
 block discarded – undo
2746 2741
 			if ($fp) fclose($fp);
2747 2742
 			if ($succeeded)
2748 2743
 			{
2749
-				unset($headers['SUBJECT']);//already in filename
2744
+				unset($headers['SUBJECT']); //already in filename
2750 2745
 				$infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false);
2751
-				$props = array(array('name' => 'comment','val' => $infoSection));
2752
-				Vfs::proppatch($file,$props);
2746
+				$props = array(array('name' => 'comment', 'val' => $infoSection));
2747
+				Vfs::proppatch($file, $props);
2753 2748
 			}
2754 2749
 		}
2755 2750
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2758,9 +2753,9 @@  discard block
 block discarded – undo
2758 2753
 			$this->changeProfile($rememberServerID);
2759 2754
 		}
2760 2755
 
2761
-		if($close)
2756
+		if ($close)
2762 2757
 		{
2763
-			Framework::window_close(($err?$err:null));
2758
+			Framework::window_close(($err ? $err : null));
2764 2759
 		}
2765 2760
 		else
2766 2761
 		{
@@ -2775,15 +2770,15 @@  discard block
 block discarded – undo
2775 2770
 	 * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
2776 2771
 	 * @return string javascript eg. to close the selector window
2777 2772
 	 */
2778
-	function vfsSaveAttachment($ids,$path)
2773
+	function vfsSaveAttachment($ids, $path)
2779 2774
 	{
2780 2775
 		//error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');");
2781 2776
 
2782 2777
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2783 2778
 		{
2784
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2779
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2785 2780
 		}
2786
-		$err=null;
2781
+		$err = null;
2787 2782
 		$dupe_count = array();
2788 2783
 		$rememberServerID = $this->mail_bo->profileID;
2789 2784
 
@@ -2793,12 +2788,12 @@  discard block
 block discarded – undo
2793 2788
 		 *
2794 2789
 		 * @return array an array of parameters
2795 2790
 		 */
2796
-		$getParams = function ($id) {
2797
-			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2798
-			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2791
+		$getParams = function($id) {
2792
+			list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8);
2793
+			$lId = implode('::', array($app, $user, $serverID, $mailbox, $uid));
2799 2794
 			$hA = mail_ui::splitRowID($lId);
2800 2795
 			return array(
2801
-				'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail,
2796
+				'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail,
2802 2797
 				'user' => $user,
2803 2798
 				'name' => $name,
2804 2799
 				'part' => $part,
@@ -2810,8 +2805,8 @@  discard block
 block discarded – undo
2810 2805
 
2811 2806
 		//Examine the first attachment to see if attachment
2812 2807
 		//is winmail.dat embedded attachments.
2813
-		$isMultipleDownload=is_array($ids);
2814
-		$p = $getParams((is_array($ids)?$ids[0]:$ids));
2808
+		$isMultipleDownload = is_array($ids);
2809
+		$p = $getParams((is_array($ids) ? $ids[0] : $ids));
2815 2810
 		if ($p['is_winmail'])
2816 2811
 		{
2817 2812
 			if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID)
@@ -2822,14 +2817,14 @@  discard block
 block discarded – undo
2822 2817
 			// retrieve all embedded attachments at once
2823 2818
 			// avoids to fetch heavy winmail.dat content
2824 2819
 			// for each file.
2825
-			$attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']);
2820
+			$attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']);
2826 2821
 		}
2827 2822
 
2828
-		foreach((array)$ids as $id)
2823
+		foreach ((array)$ids as $id)
2829 2824
 		{
2830 2825
 			$params = $getParams($id);
2831 2826
 			// when downloading a single file, name is not set
2832
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
2827
+			if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name'];
2833 2828
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2834 2829
 			{
2835 2830
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2847,25 +2842,25 @@  discard block
 block discarded – undo
2847 2842
 			}
2848 2843
 			else
2849 2844
 			{
2850
-				$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
2845
+				$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
2851 2846
 			}
2852 2847
 
2853 2848
 			$file = $params['name'];
2854 2849
 			// when $isMultipleDownload the path holds no filename
2855
-			while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2850
+			while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2856 2851
 			{
2857 2852
 				$dupe_count[$params['name']]++;
2858
-				$file = pathinfo($params['name'], PATHINFO_FILENAME) .
2859
-					' ('.($dupe_count[$params['name']] + 1).')' . '.' .
2853
+				$file = pathinfo($params['name'], PATHINFO_FILENAME).
2854
+					' ('.($dupe_count[$params['name']] + 1).')'.'.'.
2860 2855
 					pathinfo($params['name'], PATHINFO_EXTENSION);
2861 2856
 			}
2862 2857
 			$params['name'] = $file;
2863 2858
 			//error_log(__METHOD__.__LINE__.array2string($attachment));
2864 2859
 			// when $isMultipleDownload the path holds no filename
2865
-			if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
2866
-				!fwrite($fp,$attachment['attachment']))
2860
+			if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) ||
2861
+				!fwrite($fp, $attachment['attachment']))
2867 2862
 			{
2868
-				$err .= lang('Error saving %1!',$file);
2863
+				$err .= lang('Error saving %1!', $file);
2869 2864
 			}
2870 2865
 			if ($fp)
2871 2866
 			{
@@ -2878,21 +2873,21 @@  discard block
 block discarded – undo
2878 2873
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
2879 2874
 			$this->changeProfile($rememberServerID);
2880 2875
 		}
2881
-		Framework::window_close(($err?$err:null));
2876
+		Framework::window_close(($err ? $err : null));
2882 2877
 	}
2883 2878
 
2884 2879
 	/**
2885 2880
 	 * Zip all attachments and send to user
2886 2881
 	 * @param string $message_id = null
2887 2882
 	 */
2888
-	function download_zip($message_id=null)
2883
+	function download_zip($message_id = null)
2889 2884
 	{
2890 2885
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2891 2886
 		// First, get all attachment IDs
2892
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
2887
+		if (isset($_GET['id'])) $message_id = $_GET['id'];
2893 2888
 		//error_log(__METHOD__.__LINE__.$message_id);
2894 2889
 		$rememberServerID = $this->mail_bo->profileID;
2895
-		if(!is_numeric($message_id))
2890
+		if (!is_numeric($message_id))
2896 2891
 		{
2897 2892
 			$hA = self::splitRowID($message_id);
2898 2893
 			$message_id = $hA['msgUID'];
@@ -2910,18 +2905,18 @@  discard block
 block discarded – undo
2910 2905
 		}
2911 2906
 		// always fetch all, even inline (images)
2912 2907
 		$fetchEmbeddedImages = true;
2913
-		$attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox);
2908
+		$attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox);
2914 2909
 		// put them in VFS so they can be zipped
2915
-		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
2910
+		$header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox);
2916 2911
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2917 2912
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2918
-		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2919
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
2913
+		$temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id";
2914
+		if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path);
2920 2915
 
2921 2916
 		// Add subject to path, so it gets used as the file name, replacing ':'
2922 2917
 		// as it seems to cause an error
2923
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent(str_replace(':','-', $header['SUBJECT'])) : lang('mail')) .'/';
2924
-		if(!Vfs::mkdir($path, 0700, true))
2918
+		$path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent(str_replace(':', '-', $header['SUBJECT'])) : lang('mail')).'/';
2919
+		if (!Vfs::mkdir($path, 0700, true))
2925 2920
 		{
2926 2921
 			echo "Unable to open temp directory $path";
2927 2922
 			return;
@@ -2930,11 +2925,11 @@  discard block
 block discarded – undo
2930 2925
 		$file_list = array();
2931 2926
 		$dupe_count = array();
2932 2927
 		$this->mail_bo->reopen($mailbox);
2933
-		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null')
2928
+		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null')
2934 2929
 		{
2935
-			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true);
2930
+			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true);
2936 2931
 		}
2937
-		foreach($attachments as $file)
2932
+		foreach ($attachments as $file)
2938 2933
 		{
2939 2934
 			if ($file['is_winmail'])
2940 2935
 			{
@@ -2947,25 +2942,25 @@  discard block
 block discarded – undo
2947 2942
 			}
2948 2943
 			else
2949 2944
 			{
2950
-				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2945
+				$attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true);
2951 2946
 			}
2952
-			$success=true;
2947
+			$success = true;
2953 2948
 			if (empty($file['filename'])) $file['filename'] = $file['name'];
2954
-			if(in_array($path.$file['filename'], $file_list))
2949
+			if (in_array($path.$file['filename'], $file_list))
2955 2950
 			{
2956 2951
 				$dupe_count[$path.$file['filename']]++;
2957
-				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) .
2958
-					' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
2952
+				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME).
2953
+					' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'.
2959 2954
 					pathinfo($file['filename'], PATHINFO_EXTENSION);
2960 2955
 			}
2961 2956
 			// Strip special characters to make sure the files are visible for all OS (windows has issues)
2962 2957
 			$target_name = iconv($file['charset'] ? $file['charset'] : $GLOBALS['egw_info']['server']['system_charset'], 'ASCII//IGNORE', $file['filename']);
2963 2958
 			
2964
-			if (!($fp = Vfs::fopen($path.$target_name,'wb')) ||
2959
+			if (!($fp = Vfs::fopen($path.$target_name, 'wb')) ||
2965 2960
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
2966 2961
 			{
2967
-				$success=false;
2968
-				Framework::message("Unable to zip {$target_name}",'error');
2962
+				$success = false;
2963
+				Framework::message("Unable to zip {$target_name}", 'error');
2969 2964
 			}
2970 2965
 			if ($success) $file_list[] = $path.$target_name;
2971 2966
 			if ($fp) fclose($fp);
@@ -2986,7 +2981,7 @@  discard block
 block discarded – undo
2986 2981
 		exit();
2987 2982
 	}
2988 2983
 
2989
-	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
2984
+	function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null)
2990 2985
 	{
2991 2986
 		// seems to be needed, as if we open a mail from notification popup that is
2992 2987
 		// located in a different folder, we experience: could not parse message
@@ -2999,7 +2994,7 @@  discard block
 block discarded – undo
2999 2994
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
3000 2995
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
3001 2996
 		$calendar_part = null;
3002
-		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox, $calendar_part);
2997
+		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox, $calendar_part);
3003 2998
 
3004 2999
 		// for meeting requests (multipart alternative with text/calendar part) let calendar render it
3005 3000
 		if ($calendar_part && isset($GLOBALS['egw_info']['user']['apps']['calendar']))
@@ -3014,26 +3009,26 @@  discard block
 block discarded – undo
3014 3009
 			$this->mail_bo->htmlOptions = $bufferHtmlOptions;
3015 3010
 			Api\Translation::add_app('calendar');
3016 3011
 			return ExecMethod('calendar.calendar_uiforms.meeting',
3017
-				array('event'=>null,'msg'=>'','useSession'=>true)
3012
+				array('event'=>null, 'msg'=>'', 'useSession'=>true)
3018 3013
 			);
3019 3014
 		}
3020 3015
 		// Compose the content of the frame
3021 3016
 		$frameHtml =
3022 3017
 			$this->get_email_header($this->mail_bo->getStyles($bodyParts)).
3023
-			$this->showBody($this->getdisplayableBody($bodyParts,true,false), false);
3018
+			$this->showBody($this->getdisplayableBody($bodyParts, true, false), false);
3024 3019
 		//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
3025
-		$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
3020
+		$frameHtml = str_replace(" \r\n", "\r\n", $frameHtml);
3026 3021
 		$this->mail_bo->htmlOptions = $bufferHtmlOptions;
3027 3022
 
3028 3023
 		return $frameHtml;
3029 3024
 	}
3030 3025
 
3031
-	static function get_email_header($additionalStyle='')
3026
+	static function get_email_header($additionalStyle = '')
3032 3027
 	{
3033 3028
 		// egw_info[flags][css] already include <style> tags
3034 3029
 		$GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle);
3035
-		$GLOBALS['egw_info']['flags']['nofooter']=true;
3036
-		$GLOBALS['egw_info']['flags']['nonavbar']=true;
3030
+		$GLOBALS['egw_info']['flags']['nofooter'] = true;
3031
+		$GLOBALS['egw_info']['flags']['nonavbar'] = true;
3037 3032
 		// do NOT include any default CSS
3038 3033
 		Framework::includeCSS('mail', 'preview', true, true);
3039 3034
 
@@ -3044,35 +3039,35 @@  discard block
 block discarded – undo
3044 3039
 		return $GLOBALS['egw']->framework->header();
3045 3040
 	}
3046 3041
 
3047
-	function showBody(&$body, $print=true,$fullPageTags=true)
3042
+	function showBody(&$body, $print = true, $fullPageTags = true)
3048 3043
 	{
3049 3044
 		$BeginBody = '<div class="mailDisplayBody">
3050 3045
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
3051 3046
 
3052 3047
 		$EndBody = '</td></tr></table></div>';
3053 3048
 		if ($fullPageTags) $EndBody .= "</body></html>";
3054
-		if ($print)	{
3055
-			print $BeginBody. $body .$EndBody;
3049
+		if ($print) {
3050
+			print $BeginBody.$body.$EndBody;
3056 3051
 		} else {
3057
-			return $BeginBody. $body .$EndBody;
3052
+			return $BeginBody.$body.$EndBody;
3058 3053
 		}
3059 3054
 	}
3060 3055
 
3061
-	function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true)
3056
+	function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true)
3062 3057
 	{
3063
-		$bodyParts	= $_bodyParts;
3058
+		$bodyParts = $_bodyParts;
3064 3059
 
3065
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
3066
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
3067
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
3060
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
3061
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
3062
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
3068 3063
 
3069 3064
 		$body = '';
3070 3065
 
3071 3066
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
3072 3067
 		if (empty($bodyParts)) return "";
3073
-		foreach((array)$bodyParts as $singleBodyPart) {
3068
+		foreach ((array)$bodyParts as $singleBodyPart) {
3074 3069
 			if (!isset($singleBodyPart['body'])) {
3075
-				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
3070
+				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy);
3076 3071
 				$body .= $singleBodyPart['body'];
3077 3072
 				continue;
3078 3073
 			}
@@ -3082,7 +3077,7 @@  discard block
 block discarded – undo
3082 3077
 				$body .= '';
3083 3078
 				continue;
3084 3079
 			}
3085
-			if(!empty($body)) {
3080
+			if (!empty($body)) {
3086 3081
 				$body .= '<hr style="border:dotted 1px silver;">';
3087 3082
 			}
3088 3083
 			//error_log($singleBodyPart['body']);
@@ -3107,28 +3102,28 @@  discard block
 block discarded – undo
3107 3102
 				'(R)',
3108 3103
 			);
3109 3104
 
3110
-			if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
3105
+			if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
3111 3106
 				strtoupper($singleBodyPart['charSet']) != 'UTF-8')
3112 3107
 			{
3113
-				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
3108
+				$singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']);
3114 3109
 			}
3115 3110
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
3116
-			if ($singleBodyPart['charSet']=='us-ascii')
3111
+			if ($singleBodyPart['charSet'] == 'us-ascii')
3117 3112
 			{
3118
-				$orgCharSet=$singleBodyPart['charSet'];
3113
+				$orgCharSet = $singleBodyPart['charSet'];
3119 3114
 				$singleBodyPart['charSet'] = Api\Translation::detect_encoding($singleBodyPart['body']);
3120 3115
 				error_log(__METHOD__.__LINE__.'reports:'.$orgCharSet.' but seems to be:'.$singleBodyPart['charSet']);
3121 3116
 			}
3122
-			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
3117
+			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']);
3123 3118
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
3124
-			if($singleBodyPart['mimeType'] == 'text/plain')
3119
+			if ($singleBodyPart['mimeType'] == 'text/plain')
3125 3120
 			{
3126
-				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
3121
+				$newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset));
3127 3122
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3128 3123
 				// if empty and charset is utf8 try sanitizing the string in question
3129
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3124
+				if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset));
3130 3125
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
3131
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3126
+				if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
3132 3127
 
3133 3128
 				// search http[s] links and make them as links available again
3134 3129
 				// to understand what's going on here, have a look at
@@ -3156,20 +3151,20 @@  discard block
 block discarded – undo
3156 3151
 				// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
3157 3152
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3158 3153
 				// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
3159
-				$newBody	= "<pre>".Mail::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
3154
+				$newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '&gt;')."</pre>";
3160 3155
 			}
3161 3156
 			else
3162 3157
 			{
3163
-				$alreadyHtmlLawed=false;
3164
-				$newBody	= $singleBodyPart['body'];
3158
+				$alreadyHtmlLawed = false;
3159
+				$newBody = $singleBodyPart['body'];
3165 3160
 				//TODO:$newBody	= $this->highlightQuotes($newBody);
3166 3161
 				#error_log(print_r($newBody,true));
3167 3162
 				if ($useTidy && extension_loaded('tidy'))
3168 3163
 				{
3169 3164
 					$tidy = new tidy();
3170
-					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8');
3165
+					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8');
3171 3166
 					// Found errors. Strip it all so there's some output
3172
-					if($tidy->getStatus() == 2)
3167
+					if ($tidy->getStatus() == 2)
3173 3168
 					{
3174 3169
 						error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
3175 3170
 					}
@@ -3180,7 +3175,7 @@  discard block
 block discarded – undo
3180 3175
 					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3181 3176
 					{
3182 3177
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3183
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3178
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3184 3179
 						if ($matches[2])
3185 3180
 						{
3186 3181
 							$hasOther = true;
@@ -3191,7 +3186,7 @@  discard block
 block discarded – undo
3191 3186
 				else
3192 3187
 				{
3193 3188
 					// htmLawed filter only the 'body'
3194
-					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3189
+					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3195 3190
 					if ($matches[2])
3196 3191
 					{
3197 3192
 						$hasOther = true;
@@ -3200,10 +3195,10 @@  discard block
 block discarded – undo
3200 3195
 					$htmLawed = new Api\Html\HtmLawed();
3201 3196
 					// the next line should not be needed, but produces better results on HTML 2 Text conversion,
3202 3197
 					// as we switched off HTMLaweds tidy functionality
3203
-					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3204
-					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3205
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3206
-					$alreadyHtmlLawed=true;
3198
+					$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
3199
+					$newBody = $htmLawed->run($newBody, Mail::$htmLawed_config);
3200
+					if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
3201
+					$alreadyHtmlLawed = true;
3207 3202
 				}
3208 3203
 				// do the cleanup, set for the use of purifier
3209 3204
 				//$newBodyBuff = $newBody;
@@ -3225,8 +3220,8 @@  discard block
 block discarded – undo
3225 3220
 				}
3226 3221
 */
3227 3222
 				// removes stuff between http and ?http
3228
-				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';    // only http:// gets removed, other protocolls are shown
3229
-				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http://
3223
+				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
3224
+				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http://
3230 3225
 				// TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK
3231 3226
 				$newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
3232 3227
 					"\\1@\\2.\\3",
@@ -3239,7 +3234,7 @@  discard block
 block discarded – undo
3239 3234
 				// create links for inline images
3240 3235
 				if ($modifyURI)
3241 3236
 				{
3242
-					$newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID);
3237
+					$newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID);
3243 3238
 				}
3244 3239
 				// email addresses / mailto links get now activated on client-side
3245 3240
 			}
@@ -3251,7 +3246,7 @@  discard block
 block discarded – undo
3251 3246
 		$body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
3252 3247
 			"<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body);
3253 3248
 
3254
-		$body = preg_replace($nonDisplayAbleCharacters,'',$body);
3249
+		$body = preg_replace($nonDisplayAbleCharacters, '', $body);
3255 3250
 
3256 3251
 		return $body;
3257 3252
 	}
@@ -3266,7 +3261,7 @@  discard block
 block discarded – undo
3266 3261
 	 * @param string $_messageType = 'html', message type is either html or plain
3267 3262
 	 * @return string message body including all CID images replaced
3268 3263
 	 */
3269
-	public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html')
3264
+	public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html')
3270 3265
 	{
3271 3266
 		if ($_messageType === 'plain')
3272 3267
 		{
@@ -3274,7 +3269,7 @@  discard block
 block discarded – undo
3274 3269
 		}
3275 3270
 		else
3276 3271
 		{
3277
-			foreach(array('src','url','background') as $type)
3272
+			foreach (array('src', 'url', 'background') as $type)
3278 3273
 			{
3279 3274
 				$_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type);
3280 3275
 			}
@@ -3293,7 +3288,7 @@  discard block
 block discarded – undo
3293 3288
 	 *	- types: {plain|src|url|background}
3294 3289
 	 * @return string returns body content including all CID replacements
3295 3290
 	 */
3296
-	public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src')
3291
+	public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src')
3297 3292
 	{
3298 3293
 		/**
3299 3294
 		 * Callback for preg_replace_callback function
@@ -3305,7 +3300,7 @@  discard block
 block discarded – undo
3305 3300
 		 * @param string $_type
3306 3301
 		 * @return string|boolean returns the replace
3307 3302
 		*/
3308
-		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3303
+		$replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type)
3309 3304
 		{
3310 3305
 			if (!$_type)	return false;
3311 3306
 			$CID = '';
@@ -3327,11 +3322,11 @@  discard block
 block discarded – undo
3327 3322
 					break;
3328 3323
 			}
3329 3324
 
3330
-			static $cache = array();	// some caching, if mails containing the same image multiple times
3325
+			static $cache = array(); // some caching, if mails containing the same image multiple times
3331 3326
 
3332 3327
 			if (is_array($matches) && $CID)
3333 3328
 			{
3334
-				$linkData = array (
3329
+				$linkData = array(
3335 3330
 					'menuaction'    => 'mail.mail_ui.displayImage',
3336 3331
 					'uid'		=> $_uid,
3337 3332
 					'mailbox'	=> base64_encode($_mailbox),
@@ -3344,7 +3339,7 @@  discard block
 block discarded – undo
3344 3339
 				{
3345 3340
 					if (!isset($cache[$imageURL]))
3346 3341
 					{
3347
-						if ($_type !="background")
3342
+						if ($_type != "background")
3348 3343
 						{
3349 3344
 							$bo = Mail::getInstance(false, mail_ui::$icServerID);
3350 3345
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
@@ -3385,16 +3380,16 @@  discard block
 block discarded – undo
3385 3380
 		};
3386 3381
 
3387 3382
 		// return new body content base on chosen type
3388
-		switch($_type)
3383
+		switch ($_type)
3389 3384
 		{
3390 3385
 			case"plain":
3391
-				return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body);
3386
+				return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body);
3392 3387
 			case "src":
3393
-				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3388
+				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3394 3389
 			case "url":
3395
-				return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body);
3390
+				return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body);
3396 3391
 			case "background":
3397
-				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3392
+				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3398 3393
 		}
3399 3394
 	}
3400 3395
 
@@ -3402,7 +3397,7 @@  discard block
 block discarded – undo
3402 3397
 	 * importMessage
3403 3398
 	 * @param array $content = null an array of content
3404 3399
 	 */
3405
-	function importMessage($content=null)
3400
+	function importMessage($content = null)
3406 3401
 	{
3407 3402
 		//error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder());
3408 3403
 
@@ -3424,7 +3419,7 @@  discard block
 block discarded – undo
3424 3419
 			}
3425 3420
 			$destination = $content['FOLDER'][0];
3426 3421
 
3427
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3422
+			if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2);
3428 3423
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3429 3424
 			{
3430 3425
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3435,36 +3430,35 @@  discard block
 block discarded – undo
3435 3430
 			$importFailed = false;
3436 3431
 			try
3437 3432
 			{
3438
-				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3439
-			    $linkData = array
3440
-			    (
3433
+				$messageUid = $this->importMessageToFolder($file, $destination, $importID);
3434
+			    $linkData = array(
3441 3435
 					'id' => $this->createRowID($destination, $messageUid, true),
3442 3436
 			    );
3443 3437
 			}
3444 3438
 			catch (Api\Exception\WrongUserinput $e)
3445 3439
 			{
3446
-					$importFailed=true;
3447
-					$content['msg']		= $e->getMessage();
3440
+					$importFailed = true;
3441
+					$content['msg'] = $e->getMessage();
3448 3442
 			}
3449 3443
 			if (!$importFailed)
3450 3444
 			{
3451 3445
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3452 3446
 				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3453
-				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3447
+				ExecMethod2('mail.mail_ui.displayMessage', $linkData);
3454 3448
 				return;
3455 3449
 			}
3456 3450
 		}
3457 3451
 		if (!is_array($content)) $content = array();
3458
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3452
+		if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder();
3459 3453
 		if (!empty($content['FOLDER']))
3460 3454
 		{
3461 3455
 			$compose = new mail_compose();
3462
-			$sel_options['FOLDER'] = $compose->ajax_searchFolder(0,true);
3456
+			$sel_options['FOLDER'] = $compose->ajax_searchFolder(0, true);
3463 3457
 		}
3464 3458
 
3465 3459
 		$etpl = new Etemplate('mail.importMessage');
3466
-		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
3467
-		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
3460
+		$etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport');
3461
+		$etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2);
3468 3462
 	}
3469 3463
 
3470 3464
 	/**
@@ -3476,7 +3470,7 @@  discard block
 block discarded – undo
3476 3470
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3477 3471
 	 * @return mixed $messageUID or exception
3478 3472
 	 */
3479
-	function importMessageToFolder($_formData,&$_folder,$importID='')
3473
+	function importMessageToFolder($_formData, &$_folder, $importID = '')
3480 3474
 	{
3481 3475
 		$importfailed = false;
3482 3476
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -3484,7 +3478,7 @@  discard block
 block discarded – undo
3484 3478
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3485 3479
 		try
3486 3480
 		{
3487
-			$tmpFileName = Mail::checkFileBasics($_formData,$importID);
3481
+			$tmpFileName = Mail::checkFileBasics($_formData, $importID);
3488 3482
 		}
3489 3483
 		catch (Api\Exception\WrongUserinput $e)
3490 3484
 		{
@@ -3508,29 +3502,29 @@  discard block
 block discarded – undo
3508 3502
 			if (empty($_folder))
3509 3503
 			{
3510 3504
 				$importfailed = true;
3511
-				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3505
+				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']);
3512 3506
 			}
3513 3507
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3514
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3508
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
3515 3509
 			if ($importfailed === false)
3516 3510
 			{
3517
-				if ($this->mail_bo->folderExists($_folder,true)) {
3511
+				if ($this->mail_bo->folderExists($_folder, true)) {
3518 3512
 					try
3519 3513
 					{
3520 3514
 						$messageUid = $this->mail_bo->appendMessage($_folder,
3521 3515
 							$mailObject->getRaw(),
3522
-							null,'\\Seen');
3516
+							null, '\\Seen');
3523 3517
 					}
3524 3518
 					catch (Api\Exception\WrongUserinput $e)
3525 3519
 					{
3526 3520
 						$importfailed = true;
3527
-						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
3521
+						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage());
3528 3522
 					}
3529 3523
 				}
3530 3524
 				else
3531 3525
 				{
3532 3526
 					$importfailed = true;
3533
-					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder);
3527
+					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder);
3534 3528
 				}
3535 3529
 			}
3536 3530
 		}
@@ -3556,9 +3550,9 @@  discard block
 block discarded – undo
3556 3550
 	 *								 $formData['size']	= 2136;
3557 3551
 	 * @return void
3558 3552
 	 */
3559
-	function importMessageFromVFS2DraftAndEdit($formData='')
3553
+	function importMessageFromVFS2DraftAndEdit($formData = '')
3560 3554
 	{
3561
-		$this->importMessageFromVFS2DraftAndDisplay($formData,'edit');
3555
+		$this->importMessageFromVFS2DraftAndDisplay($formData, 'edit');
3562 3556
 	}
3563 3557
 
3564 3558
 	/**
@@ -3573,7 +3567,7 @@  discard block
 block discarded – undo
3573 3567
 	 * @param string $mode mode to open ImportedMessage display and edit are supported
3574 3568
 	 * @return void
3575 3569
 	 */
3576
-	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3570
+	function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display')
3577 3571
 	{
3578 3572
 		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3579 3573
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
@@ -3586,43 +3580,42 @@  discard block
 block discarded – undo
3586 3580
 			$formData['file'] = 'egw-data://'.$formData['data'];
3587 3581
 		}
3588 3582
 		// name should be set to meet the requirements of checkFileBasics
3589
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3583
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3590 3584
 		{
3591
-			$buff = explode('/',$formData['file']);
3585
+			$buff = explode('/', $formData['file']);
3592 3586
 			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3593 3587
 		}
3594 3588
 		// type should be set to meet the requirements of checkFileBasics
3595
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3589
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3596 3590
 		{
3597
-			$buff = explode('.',$formData['file']);
3591
+			$buff = explode('.', $formData['file']);
3598 3592
 			$suffix = '';
3599 3593
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3600 3594
 			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3601 3595
 		}
3602 3596
 		// size should be set to meet the requirements of checkFileBasics
3603
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3597
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3604 3598
 		{
3605 3599
 			$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
3606 3600
 		}
3607 3601
 		try
3608 3602
 		{
3609
-			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3610
-			$linkData = array
3611
-			(
3612
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3613
-				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3603
+			$messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID);
3604
+			$linkData = array(
3605
+		        'menuaction'    => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'),
3606
+				'id'		=> $this->createRowID($draftFolder, $messageUid, true),
3614 3607
 				'deleteDraftOnClose' => 1,
3615 3608
 			);
3616
-			if ($mode!='display')
3609
+			if ($mode != 'display')
3617 3610
 			{
3618 3611
 				unset($linkData['deleteDraftOnClose']);
3619
-				$linkData['method']	='importMessageToMergeAndSend';
3612
+				$linkData['method'] = 'importMessageToMergeAndSend';
3620 3613
 			}
3621 3614
 			else
3622 3615
 			{
3623
-				$linkData['mode']=$mode;
3616
+				$linkData['mode'] = $mode;
3624 3617
 			}
3625
-			Egw::redirect_link('/index.php',$linkData);
3618
+			Egw::redirect_link('/index.php', $linkData);
3626 3619
 		}
3627 3620
 		catch (Api\Exception\WrongUserinput $e)
3628 3621
 		{
@@ -3637,13 +3630,13 @@  discard block
 block discarded – undo
3637 3630
 	 *
3638 3631
 	 * @return xajax response
3639 3632
 	 */
3640
-	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3633
+	function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null)
3641 3634
 	{
3642 3635
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3643 3636
 		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3644 3637
 		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3645 3638
 		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3646
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3639
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions");
3647 3640
 		if (empty($_messageID)) return "";
3648 3641
 		$uidA = self::splitRowID($_messageID);
3649 3642
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -3657,7 +3650,7 @@  discard block
 block discarded – undo
3657 3650
 			$this->changeProfile($icServerID);
3658 3651
 		}
3659 3652
 
3660
-		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions);
3653
+		$bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions);
3661 3654
 		Api\Session::cache_control(true);
3662 3655
 		//error_log(array2string($bodyResponse));
3663 3656
 		echo $bodyResponse;
@@ -3680,7 +3673,7 @@  discard block
 block discarded – undo
3680 3673
 			$oA = array();
3681 3674
 			foreach ($_folder as $_folderName)
3682 3675
 			{
3683
-				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3676
+				list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2);
3684 3677
 				if (is_numeric($profileID))
3685 3678
 				{
3686 3679
 					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
@@ -3688,20 +3681,20 @@  discard block
 block discarded – undo
3688 3681
 					{
3689 3682
 						try
3690 3683
 						{
3691
-							$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3684
+							$fS = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3692 3685
 						}
3693 3686
 						catch (Exception $e)
3694 3687
 						{
3695
-							if (Mail::$debug) error_log(__METHOD__,' ()'.$e->getMessage ());
3688
+							if (Mail::$debug) error_log(__METHOD__, ' ()'.$e->getMessage());
3696 3689
 							continue;
3697 3690
 						}
3698
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3691
+						if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']);
3699 3692
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3700 3693
 						if ($fS['unseen'])
3701 3694
 						{
3702 3695
 							$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
3703 3696
 						}
3704
-						if ($fS['unseen']==0 && $fS['shortDisplayName'])
3697
+						if ($fS['unseen'] == 0 && $fS['shortDisplayName'])
3705 3698
 						{
3706 3699
 							$oA[$_folderName] = $fS['shortDisplayName'];
3707 3700
 						}
@@ -3712,7 +3705,7 @@  discard block
 block discarded – undo
3712 3705
 			if ($oA)
3713 3706
 			{
3714 3707
 				$response = Api\Json\Response::get();
3715
-				$response->call('app.mail.mail_setFolderStatus',$oA);
3708
+				$response->call('app.mail.mail_setFolderStatus', $oA);
3716 3709
 			}
3717 3710
 		}
3718 3711
 	}
@@ -3726,14 +3719,14 @@  discard block
 block discarded – undo
3726 3719
 	function ajax_addFolder($_parentFolderName, $_newName)
3727 3720
 	{
3728 3721
 		//error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName));
3729
-		$errorMessage='';
3722
+		$errorMessage = '';
3730 3723
 		if ($_parentFolderName)
3731 3724
 		{
3732 3725
 			$created = false;
3733 3726
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName);
3734 3727
 			//the conversion is handeled by horde, frontend interaction is all utf-8
3735 3728
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3736
-			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3729
+			list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2);
3737 3730
 			if (is_numeric($profileID))
3738 3731
 			{
3739 3732
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
@@ -3773,10 +3766,10 @@  discard block
 block discarded – undo
3773 3766
 
3774 3767
 				if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false);
3775 3768
 				*/
3776
-				$nA = explode($del,$_newName);
3769
+				$nA = explode($del, $_newName);
3777 3770
 
3778 3771
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3779
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3772
+				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false);
3780 3773
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3781 3774
 
3782 3775
 				$this->mail_bo->reopen('INBOX');
@@ -3784,11 +3777,11 @@  discard block
 block discarded – undo
3784 3777
 				// if newName has delimiter ($del) in it, we need to create the subtree
3785 3778
 				if (!empty($nA))
3786 3779
 				{
3787
-					$c=0;
3788
-					foreach($nA as $sTName)
3780
+					$c = 0;
3781
+					foreach ($nA as $sTName)
3789 3782
 					{
3790
-						$error=null;
3791
-						if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3783
+						$error = null;
3784
+						if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3792 3785
 						{
3793 3786
 							$c++;
3794 3787
 						}
@@ -3797,16 +3790,16 @@  discard block
 block discarded – undo
3797 3790
 							$errorMessage .= $error;
3798 3791
 						}
3799 3792
 					}
3800
-					if ($c==count($nA)) $created=true;
3793
+					if ($c == count($nA)) $created = true;
3801 3794
 				}
3802 3795
 				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3803 3796
 			}
3804 3797
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3805
-			if ($created===true)
3798
+			if ($created === true)
3806 3799
 			{
3807 3800
 				$this->mail_bo->resetFolderObjectCache($profileID);
3808 3801
 				$response = Api\Json\Response::get();
3809
-				if ( $oldFolderInfo['shortDisplayName'])
3802
+				if ($oldFolderInfo['shortDisplayName'])
3810 3803
 				{
3811 3804
 					$nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']);
3812 3805
 				}
@@ -3814,14 +3807,14 @@  discard block
 block discarded – undo
3814 3807
 				{
3815 3808
 					$nodeInfo = array($profileID=>lang('INBOX'));
3816 3809
 				}
3817
-				$response->call('app.mail.mail_reloadNode',$nodeInfo);
3810
+				$response->call('app.mail.mail_reloadNode', $nodeInfo);
3818 3811
 			}
3819 3812
 			else
3820 3813
 			{
3821 3814
 				if ($errorMessage)
3822 3815
 				{
3823 3816
 					$response = Api\Json\Response::get();
3824
-					$response->call('egw.message',$errorMessage);
3817
+					$response->call('egw.message', $errorMessage);
3825 3818
 				}
3826 3819
 			}
3827 3820
 		}
@@ -3843,22 +3836,22 @@  discard block
 block discarded – undo
3843 3836
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3844 3837
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3845 3838
 			$oA = array();
3846
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3839
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3847 3840
 			$hasChildren = false;
3848 3841
 			if (is_numeric($profileID))
3849 3842
 			{
3850
-				if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
3851
-				$pA = explode($del,$folderName);
3843
+				if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
3844
+				$pA = explode($del, $folderName);
3852 3845
 				array_pop($pA);
3853
-				$parentFolder = implode($del,$pA);
3854
-				if (strtoupper($folderName)!= 'INBOX')
3846
+				$parentFolder = implode($del, $pA);
3847
+				if (strtoupper($folderName) != 'INBOX')
3855 3848
 				{
3856 3849
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3857
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false);
3850
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false);
3858 3851
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3859
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3852
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3860 3853
 					{
3861
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3854
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3862 3855
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3863 3856
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3864 3857
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3875,7 +3868,7 @@  discard block
 block discarded – undo
3875 3868
 							else
3876 3869
 							{
3877 3870
 								$rv = $this->mail_bo->icServer->subscribeMailbox($folder, false);
3878
-								$fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName));
3871
+								$fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName));
3879 3872
 							}
3880 3873
 						}
3881 3874
 						//error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments));
@@ -3885,7 +3878,7 @@  discard block
 block discarded – undo
3885 3878
 					$success = false;
3886 3879
 					try
3887 3880
 					{
3888
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3881
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3889 3882
 						{
3890 3883
 							$this->mail_bo->resetFolderObjectCache($profileID);
3891 3884
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3896,11 +3889,11 @@  discard block
 block discarded – undo
3896 3889
 					}
3897 3890
 					catch (Exception $e)
3898 3891
 					{
3899
-						$newFolderName=$folderName;
3892
+						$newFolderName = $folderName;
3900 3893
 						$msg = $e->getMessage();
3901 3894
 					}
3902 3895
 					$this->mail_bo->reopen($newFolderName);
3903
-					$fS = $this->mail_bo->getFolderStatus($newFolderName,false);
3896
+					$fS = $this->mail_bo->getFolderStatus($newFolderName, false);
3904 3897
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3905 3898
 					if ($hasChildren)
3906 3899
 					{
@@ -3931,12 +3924,12 @@  discard block
 block discarded – undo
3931 3924
 					{
3932 3925
 						$oA[$_folderName]['desc'] = $fS['shortDisplayName'];
3933 3926
 					}
3934
-					foreach($fragments as $oldFolderName => $fragment)
3927
+					foreach ($fragments as $oldFolderName => $fragment)
3935 3928
 					{
3936 3929
 						//error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment);
3937 3930
 						$oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment;
3938 3931
 						$oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#';
3939
-						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
3932
+						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false);
3940 3933
 						if ($fS['unseen'])
3941 3934
 						{
3942 3935
 							$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
@@ -3949,20 +3942,20 @@  discard block
 block discarded – undo
3949 3942
 					}
3950 3943
 				}
3951 3944
 			}
3952
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
3945
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
3953 3946
 			{
3954
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
3947
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
3955 3948
 				$this->mail_bo->saveSessionData();
3956 3949
 			}
3957 3950
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3958 3951
 			$response = Api\Json\Response::get();
3959 3952
 			if ($oA && $success)
3960 3953
 			{
3961
-				$response->call('app.mail.mail_setLeaf',$oA);
3954
+				$response->call('app.mail.mail_setLeaf', $oA);
3962 3955
 			}
3963 3956
 			else
3964 3957
 			{
3965
-				$response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail');
3958
+				$response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail');
3966 3959
 			}
3967 3960
 		}
3968 3961
 	}
@@ -3974,12 +3967,12 @@  discard block
 block discarded – undo
3974 3967
 	 * @param boolean $_subscribedOnly = true
3975 3968
 	 * @return void
3976 3969
 	 */
3977
-	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
3970
+	function ajax_reloadNode($_folderName, $_subscribedOnly = true)
3978 3971
 	{
3979 3972
 		Api\Translation::add_app('mail');
3980 3973
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
3981 3974
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3982
-		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3975
+		list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3983 3976
 		if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
3984 3977
 
3985 3978
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
@@ -3988,13 +3981,13 @@  discard block
 block discarded – undo
3988 3981
 
3989 3982
 		if (!empty($folderName))
3990 3983
 		{
3991
-			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
3992
-			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3984
+			$parentFolder = (!empty($folderName) ? $folderName : 'INBOX');
3985
+			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3993 3986
 			if ($folderInfo['unseen'])
3994 3987
 			{
3995 3988
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')';
3996 3989
 			}
3997
-			if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName'])
3990
+			if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName'])
3998 3991
 			{
3999 3992
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'];
4000 3993
 			}
@@ -4010,11 +4003,11 @@  discard block
 block discarded – undo
4010 4003
 		}
4011 4004
 		// Send full info back in the response
4012 4005
 		$response = Api\Json\Response::get();
4013
-		foreach($refreshData as $folder => &$name)
4006
+		foreach ($refreshData as $folder => &$name)
4014 4007
 		{
4015
-			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
4008
+			$name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true);
4016 4009
 		}
4017
-		$response->call('app.mail.mail_reloadNode',$refreshData);
4010
+		$response->call('app.mail.mail_reloadNode', $refreshData);
4018 4011
 
4019 4012
 	}
4020 4013
 
@@ -4030,7 +4023,7 @@  discard block
 block discarded – undo
4030 4023
 	 * @param type $_rowid row id from nm
4031 4024
 	 *
4032 4025
 	 */
4033
-	function ajax_resolveWinmail ($_rowid)
4026
+	function ajax_resolveWinmail($_rowid)
4034 4027
 	{
4035 4028
 		$response = Api\Json\Response::get();
4036 4029
 
@@ -4038,7 +4031,7 @@  discard block
 block discarded – undo
4038 4031
 		$uid = $idParts['msgUID'];
4039 4032
 		$mbox = $idParts['folder'];
4040 4033
 
4041
-		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
4034
+		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox);
4042 4035
 		if (is_array($attachments))
4043 4036
 		{
4044 4037
 			$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
@@ -4065,31 +4058,31 @@  discard block
 block discarded – undo
4065 4058
 		{
4066 4059
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4067 4060
 			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
4068
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4069
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
4061
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4062
+			list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2);
4070 4063
 			if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) $this->changeProfile($profileID);
4071 4064
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4072 4065
 			$hasChildren = false;
4073 4066
 			if (is_numeric($profileID))
4074 4067
 			{
4075
-				$pA = explode($del,$folderName);
4068
+				$pA = explode($del, $folderName);
4076 4069
 				$namePart = array_pop($pA);
4077 4070
 				$_newName = $namePart;
4078
-				$oldParentFolder = implode($del,$pA);
4071
+				$oldParentFolder = implode($del, $pA);
4079 4072
 				$parentFolder = $_newLocation;
4080 4073
 
4081
-				if (strtoupper($folderName)!= 'INBOX' &&
4074
+				if (strtoupper($folderName) != 'INBOX' &&
4082 4075
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
4083 4076
 					(($oldParentFolder != $parentFolder &&
4084
-					strlen($parentFolder)>0 && strlen($folderName)>0 &&
4085
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4077
+					strlen($parentFolder) > 0 && strlen($folderName) > 0 &&
4078
+					strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch
4086 4079
 				{
4087 4080
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
4088
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4081
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4089 4082
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4090
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4083
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4091 4084
 					{
4092
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4085
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4093 4086
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4094 4087
 						$nameSpace = $this->mail_bo->_getNameSpaces();
4095 4088
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -4114,7 +4107,7 @@  discard block
 block discarded – undo
4114 4107
 					$success = false;
4115 4108
 					try
4116 4109
 					{
4117
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
4110
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
4118 4111
 						{
4119 4112
 							$this->mail_bo->resetFolderObjectCache($profileID);
4120 4113
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -4126,11 +4119,11 @@  discard block
 block discarded – undo
4126 4119
 					}
4127 4120
 					catch (Exception $e)
4128 4121
 					{
4129
-						$newFolderName=$folderName;
4122
+						$newFolderName = $folderName;
4130 4123
 						$msg = $e->getMessage();
4131 4124
 					}
4132 4125
 					$this->mail_bo->reopen($parentFolder);
4133
-					$this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4126
+					$this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4134 4127
 					//error_log(__METHOD__.__LINE__.array2string($fS));
4135 4128
 					if ($hasChildren)
4136 4129
 					{
@@ -4151,9 +4144,9 @@  discard block
 block discarded – undo
4151 4144
 					}
4152 4145
 				}
4153 4146
 			}
4154
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
4147
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
4155 4148
 			{
4156
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
4149
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
4157 4150
 				$this->mail_bo->saveSessionData();
4158 4151
 			}
4159 4152
 			//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -4162,26 +4155,26 @@  discard block
 block discarded – undo
4162 4155
 			{
4163 4156
 				Api\Translation::add_app('mail');
4164 4157
 
4165
-				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
4166
-				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4158
+				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false);
4159
+				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4167 4160
 				$refreshData = array(
4168 4161
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4169 4162
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4170 4163
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4171
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4172
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4164
+				if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4165
+				if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4173 4166
 
4174 4167
 				// Send full info back in the response
4175
-				foreach($refreshData as $folder => &$name)
4168
+				foreach ($refreshData as $folder => &$name)
4176 4169
 				{
4177
-					$name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true);
4170
+					$name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true);
4178 4171
 				}
4179
-				$response->call('app.mail.mail_reloadNode',$refreshData);
4172
+				$response->call('app.mail.mail_reloadNode', $refreshData);
4180 4173
 
4181 4174
 			}
4182 4175
 			else
4183 4176
 			{
4184
-				$response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail');
4177
+				$response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail');
4185 4178
 			}
4186 4179
 		}
4187 4180
 	}
@@ -4200,24 +4193,24 @@  discard block
 block discarded – undo
4200 4193
 		{
4201 4194
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4202 4195
 			$oA = array();
4203
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4204
-			if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
4196
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4197
+			if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
4205 4198
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4206 4199
 			$hasChildren = false;
4207 4200
 			if (is_numeric($profileID))
4208 4201
 			{
4209
-				$pA = explode($del,$folderName);
4202
+				$pA = explode($del, $folderName);
4210 4203
 				array_pop($pA);
4211
-				if (strtoupper($folderName)!= 'INBOX')
4204
+				if (strtoupper($folderName) != 'INBOX')
4212 4205
 				{
4213 4206
 					//error_log(__METHOD__.__LINE__."$folderName,  implode($del,$pA), $_newName");
4214 4207
 					$oA = array();
4215 4208
 					$subFolders = array();
4216
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4209
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4217 4210
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4218
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4211
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4219 4212
 					{
4220
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4213
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4221 4214
 						$ftD = array();
4222 4215
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4223 4216
 						$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -4227,24 +4220,24 @@  discard block
 block discarded – undo
4227 4220
 						//error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix");
4228 4221
 						foreach ($subFolders as $k => $f)
4229 4222
 						{
4230
-							$ftD[substr_count($f,$delimiter)][]=$f;
4223
+							$ftD[substr_count($f, $delimiter)][] = $f;
4231 4224
 						}
4232
-						krsort($ftD,SORT_NUMERIC);//sort per level
4225
+						krsort($ftD, SORT_NUMERIC); //sort per level
4233 4226
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4234
-						foreach($ftD as $k => $lc)//collection per level
4227
+						foreach ($ftD as $k => $lc)//collection per level
4235 4228
 						{
4236
-							foreach($lc as $f)//folders contained in that level
4229
+							foreach ($lc as $f)//folders contained in that level
4237 4230
 							{
4238 4231
 								try
4239 4232
 								{
4240 4233
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4241 4234
 									$this->mail_bo->deleteFolder($f);
4242 4235
 									$success = true;
4243
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4236
+									if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4244 4237
 								}
4245 4238
 								catch (Exception $e)
4246 4239
 								{
4247
-									$msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage();
4240
+									$msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage();
4248 4241
 									$success = false;
4249 4242
 								}
4250 4243
 							}
@@ -4275,11 +4268,11 @@  discard block
 block discarded – undo
4275 4268
 			if ($success)
4276 4269
 			{
4277 4270
 				//error_log(__METHOD__.__LINE__.array2string($oA));
4278
-				$response->call('app.mail.mail_removeLeaf',$oA);
4271
+				$response->call('app.mail.mail_removeLeaf', $oA);
4279 4272
 			}
4280 4273
 			else
4281 4274
 			{
4282
-				$response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail');
4275
+				$response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail');
4283 4276
 			}
4284 4277
 		}
4285 4278
 	}
@@ -4293,7 +4286,7 @@  discard block
 block discarded – undo
4293 4286
 	 * @param bool $getFolders The client needs the folders for the profile
4294 4287
 	 * @return nothing
4295 4288
 	 */
4296
-	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
4289
+	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null)
4297 4290
 	{
4298 4291
 		$response = Api\Json\Response::get();
4299 4292
 
@@ -4301,7 +4294,7 @@  discard block
 block discarded – undo
4301 4294
 
4302 4295
 		if ($icServerID && $icServerID != $previous_id)
4303 4296
 		{
4304
-			$mail_ui = new mail_ui(false);	// do NOT run constructor, as we call changeProfile anyway
4297
+			$mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway
4305 4298
 			try
4306 4299
 			{
4307 4300
 				$mail_ui->changeProfile($icServerID);
@@ -4317,12 +4310,12 @@  discard block
 block discarded – undo
4317 4310
 				}
4318 4311
 			}
4319 4312
 			catch (Exception $e) {
4320
-				self::callWizard($e->getMessage(),true, 'error');
4313
+				self::callWizard($e->getMessage(), true, 'error');
4321 4314
 			}
4322 4315
 		}
4323 4316
 		else
4324 4317
 		{
4325
-			$mail_ui = new mail_ui(true);	// run constructor
4318
+			$mail_ui = new mail_ui(true); // run constructor
4326 4319
 		}
4327 4320
 	}
4328 4321
 
@@ -4333,7 +4326,7 @@  discard block
 block discarded – undo
4333 4326
 	 *						if other than active profile; nothing is done!
4334 4327
 	 * @return nothing
4335 4328
 	 */
4336
-	public static function ajax_refreshVacationNotice($icServerID=null)
4329
+	public static function ajax_refreshVacationNotice($icServerID = null)
4337 4330
 	{
4338 4331
 		//Get vacation from cache if it's available
4339 4332
 		$cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
@@ -4351,28 +4344,28 @@  discard block
 block discarded – undo
4351 4344
 
4352 4345
 				$vacation = $mail->gatherVacation($cachedVacations);
4353 4346
 			} catch (Exception $e) {
4354
-				$vacation=false;
4347
+				$vacation = false;
4355 4348
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4356 4349
 				unset($e);
4357 4350
 			}
4358 4351
 		}
4359 4352
 
4360
-		if($vacation) {
4361
-			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4353
+		if ($vacation) {
4354
+			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date'))
4362 4355
 			{
4363 4356
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4364 4357
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4365
-				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4366
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4358
+				$refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
4359
+				if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = '';
4367 4360
 			}
4368 4361
 		}
4369
-		if ($vacation==false)
4362
+		if ($vacation == false)
4370 4363
 		{
4371
-			$refreshData['vacationnotice'] =  '';
4372
-			$refreshData['vacationrange'] =  '';
4364
+			$refreshData['vacationnotice'] = '';
4365
+			$refreshData['vacationrange'] = '';
4373 4366
 		}
4374 4367
 		$response = Api\Json\Response::get();
4375
-		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
4368
+		$response->call('app.mail.mail_refreshVacationNotice', $refreshData);
4376 4369
 	}
4377 4370
 
4378 4371
 	/**
@@ -4382,43 +4375,43 @@  discard block
 block discarded – undo
4382 4375
 	 *						if other than active profile; nothing is done!
4383 4376
 	 * @return nothing
4384 4377
 	 */
4385
-	function ajax_refreshFilters($icServerID=null)
4378
+	function ajax_refreshFilters($icServerID = null)
4386 4379
 	{
4387 4380
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4388 4381
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4389 4382
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4390 4383
 		{
4391
-			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4392
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4384
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4385
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4393 4386
 		}
4394 4387
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4395 4388
 		{
4396 4389
 			unset($this->searchTypes['quick']);
4397 4390
 			unset($this->searchTypes['quickwithcc']);
4398 4391
 		}
4399
-		if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4392
+		if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4400 4393
 		{
4401
-			$this->statusTypes = array_merge($this->statusTypes,array(
4402
-				'keyword1'	=> 'important',//lang('important'),
4403
-				'keyword2'	=> 'job',	//lang('job'),
4404
-				'keyword3'	=> 'personal',//lang('personal'),
4405
-				'keyword4'	=> 'to do',	//lang('to do'),
4406
-				'keyword5'	=> 'later',	//lang('later'),
4394
+			$this->statusTypes = array_merge($this->statusTypes, array(
4395
+				'keyword1'	=> 'important', //lang('important'),
4396
+				'keyword2'	=> 'job', //lang('job'),
4397
+				'keyword3'	=> 'personal', //lang('personal'),
4398
+				'keyword4'	=> 'to do', //lang('to do'),
4399
+				'keyword5'	=> 'later', //lang('later'),
4407 4400
 			));
4408 4401
 		}
4409 4402
 		else
4410 4403
 		{
4411
-			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4412
-			foreach($keywords as &$k)
4404
+			$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
4405
+			foreach ($keywords as &$k)
4413 4406
 			{
4414
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4407
+				if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
4415 4408
 			}
4416 4409
 		}
4417 4410
 
4418 4411
 		$response = Api\Json\Response::get();
4419
-		$response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes);
4420
-		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
4421
-		$response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')));
4412
+		$response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes);
4413
+		$response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes);
4414
+		$response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')));
4422 4415
 
4423 4416
 	}
4424 4417
 
@@ -4430,7 +4423,7 @@  discard block
 block discarded – undo
4430 4423
 	 * @param string $icServerID = null
4431 4424
 	 *
4432 4425
 	 */
4433
-	function ajax_refreshQuotaDisplay($icServerID=null)
4426
+	function ajax_refreshQuotaDisplay($icServerID = null)
4434 4427
 	{
4435 4428
 		Api\Translation::add_app('mail');
4436 4429
 		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
@@ -4448,10 +4441,10 @@  discard block
 block discarded – undo
4448 4441
 			unset($e);
4449 4442
 		}
4450 4443
 
4451
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4444
+		if ($quota !== false && $quota['limit'] != 'NOT SET') {
4452 4445
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4453
-			$quotaMin = $quotainfo['freespace']/pow(1024, 2);
4454
-			$content = array (
4446
+			$quotaMin = $quotainfo['freespace'] / pow(1024, 2);
4447
+			$content = array(
4455 4448
 				'quota'				=> $quotainfo['text'],
4456 4449
 				'quotainpercent'	=> (string)$quotainfo['percent'],
4457 4450
 				'quotaclass'		=> $quotainfo['class'],
@@ -4462,7 +4455,7 @@  discard block
 block discarded – undo
4462 4455
 		}
4463 4456
 		else
4464 4457
 		{
4465
-			$content = array (
4458
+			$content = array(
4466 4459
 				'quota'				=> lang("Quota not provided by server"),
4467 4460
 				'quotaclass'		=> "mail_DisplayNone",
4468 4461
 				'quotanotsupported'	=> "mail_DisplayNone"
@@ -4478,7 +4471,7 @@  discard block
 block discarded – undo
4478 4471
 			}
4479 4472
 		}
4480 4473
 		$response = Api\Json\Response::get();
4481
-		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
4474
+		$response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content));
4482 4475
 	}
4483 4476
 
4484 4477
 	/**
@@ -4500,34 +4493,34 @@  discard block
 block discarded – undo
4500 4493
 			$this->changeProfile($icServerID);
4501 4494
 		}
4502 4495
 		$junkFolder = $this->mail_bo->getJunkFolder();
4503
-		if(!empty($junkFolder)) {
4496
+		if (!empty($junkFolder)) {
4504 4497
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4505 4498
 			{
4506 4499
 				// Lock the tree if the active folder is junk folder
4507 4500
 				$response->call('app.mail.lock_tree');
4508 4501
 			}
4509
-			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4502
+			$this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately');
4510 4503
 
4511 4504
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4512
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4505
+			$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
4513 4506
 			$fStatus = array(
4514 4507
 				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4515 4508
 			);
4516 4509
 			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4517 4510
 			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4518
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4511
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4519 4512
 		}
4520 4513
 		if ($rememberServerID != $this->mail_bo->profileID)
4521 4514
 		{
4522
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4523
-			$response->call('egw.message',lang('empty junk'));
4524
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4515
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false);
4516
+			$response->call('egw.message', lang('empty junk'));
4517
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4525 4518
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4526 4519
 			$this->changeProfile($rememberServerID);
4527 4520
 		}
4528 4521
 		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4529 4522
 		{
4530
-			$response->call('egw.refresh',lang('empty junk'),'mail');
4523
+			$response->call('egw.refresh', lang('empty junk'), 'mail');
4531 4524
 		}
4532 4525
 	}
4533 4526
 
@@ -4550,7 +4543,7 @@  discard block
 block discarded – undo
4550 4543
 			$this->changeProfile($icServerID);
4551 4544
 		}
4552 4545
 		$trashFolder = $this->mail_bo->getTrashFolder();
4553
-		if(!empty($trashFolder)) {
4546
+		if (!empty($trashFolder)) {
4554 4547
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4555 4548
 			{
4556 4549
 				// Lock the tree if the active folder is Trash folder
@@ -4559,25 +4552,25 @@  discard block
 block discarded – undo
4559 4552
 			$this->mail_bo->compressFolder($trashFolder);
4560 4553
 
4561 4554
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4562
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4555
+			$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
4563 4556
 			$fStatus = array(
4564 4557
 				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4565 4558
 			);
4566 4559
 			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4567 4560
 			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4568
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4561
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4569 4562
 		}
4570 4563
 		if ($rememberServerID != $this->mail_bo->profileID)
4571 4564
 		{
4572
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4573
-			$response->call('egw.message',lang('empty trash'));
4574
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4565
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false);
4566
+			$response->call('egw.message', lang('empty trash'));
4567
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4575 4568
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4576 4569
 			$this->changeProfile($rememberServerID);
4577 4570
 		}
4578 4571
 		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4579 4572
 		{
4580
-			$response->call('egw.refresh',lang('empty trash'),'mail');
4573
+			$response->call('egw.refresh', lang('empty trash'), 'mail');
4581 4574
 		}
4582 4575
 	}
4583 4576
 
@@ -4594,7 +4587,7 @@  discard block
 block discarded – undo
4594 4587
 
4595 4588
 		$this->mail_bo->restoreSessionData();
4596 4589
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4597
-		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4590
+		list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4598 4591
 
4599 4592
 		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4600 4593
 		if ($this->mail_bo->folderExists($folderName))
@@ -4605,7 +4598,7 @@  discard block
 block discarded – undo
4605 4598
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4606 4599
 				$this->changeProfile($icServerID);
4607 4600
 			}
4608
-			if(!empty($_folderName)) {
4601
+			if (!empty($_folderName)) {
4609 4602
 				$this->mail_bo->compressFolder($folderName);
4610 4603
 			}
4611 4604
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4614,7 +4607,7 @@  discard block
 block discarded – undo
4614 4607
 				$this->changeProfile($rememberServerID);
4615 4608
 			}
4616 4609
 			$response = Api\Json\Response::get();
4617
-			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
4610
+			$response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail');
4618 4611
 		}
4619 4612
 	}
4620 4613
 
@@ -4627,10 +4620,10 @@  discard block
 block discarded – undo
4627 4620
 	 */
4628 4621
 	function ajax_sendMDN($_messageList)
4629 4622
 	{
4630
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4623
+		if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4631 4624
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4632 4625
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4633
-		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
4626
+		$this->mail_bo->sendMDN($uidA['msgUID'], $folder);
4634 4627
 	}
4635 4628
 
4636 4629
 	/**
@@ -4642,14 +4635,14 @@  discard block
 block discarded – undo
4642 4635
 	 *
4643 4636
 	 * @return xajax response
4644 4637
 	 */
4645
-	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4638
+	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true)
4646 4639
 	{
4647
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4640
+		if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4648 4641
 		Api\Translation::add_app('mail');
4649
-		$alreadyFlagged=false;
4650
-		$flag2check='';
4642
+		$alreadyFlagged = false;
4643
+		$flag2check = '';
4651 4644
 		$filter2toggle = $query = array();
4652
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4645
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4653 4646
 		{
4654 4647
 			if (isset($_messageList['all']) && $_messageList['all'])
4655 4648
 			{
@@ -4659,34 +4652,34 @@  discard block
 block discarded – undo
4659 4652
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4660 4653
 				{
4661 4654
 					$query = $_messageList['activeFilters'];
4662
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4655
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4663 4656
 					{
4664 4657
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4665 4658
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4666 4659
 						{
4667
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4668
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4660
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4661
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4669 4662
 						}
4670 4663
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4671 4664
 						$cutoffdate = $cutoffdate2 = null;
4672
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4673
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4665
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4666
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4674 4667
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4675 4668
 						$filter = array(
4676
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4677
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4669
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4670
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4678 4671
 							'string' => $query['search'],
4679
-							'status' => 'any',//this is a status change. status will be manipulated later on
4672
+							'status' => 'any', //this is a status change. status will be manipulated later on
4680 4673
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4681 4674
 						);
4682
-						if ($query['enddate']||$query['startdate']) {
4675
+						if ($query['enddate'] || $query['startdate']) {
4683 4676
 							$filter['range'] = "BETWEEN";
4684 4677
 							if ($cutoffdate) {
4685
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4678
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4686 4679
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4687 4680
 							}
4688 4681
 							if ($cutoffdate2) {
4689
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4682
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4690 4683
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4691 4684
 							}
4692 4685
 						}
@@ -4699,12 +4692,12 @@  discard block
 block discarded – undo
4699 4692
 					// flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder
4700 4693
 					// should be affected serverside. here.
4701 4694
 					$messageList = $messageListForToggle = array();
4702
-					$flag2check = ($_flag=='read'?'seen':$_flag);
4703
-					if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4704
-						!($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))
4695
+					$flag2check = ($_flag == 'read' ? 'seen' : $_flag);
4696
+					if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4697
+						!($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))
4705 4698
 					{
4706 4699
 						$filter2toggle['status'] = array('un'.$_flag);
4707
-						if ($query['filter'] && $query['filter']!='any')
4700
+						if ($query['filter'] && $query['filter'] != 'any')
4708 4701
 						{
4709 4702
 							$filter2toggle['status'][] = $query['filter'];
4710 4703
 						}
@@ -4712,7 +4705,7 @@  discard block
 block discarded – undo
4712 4705
 						$reverse = 1;
4713 4706
 						$_sRt = $this->mail_bo->getSortedList(
4714 4707
 							$folder,
4715
-							$sort=0,
4708
+							$sort = 0,
4716 4709
 							$reverse,
4717 4710
 							$filter2toggle,
4718 4711
 							$rByUid,
@@ -4720,52 +4713,52 @@  discard block
 block discarded – undo
4720 4713
 						);
4721 4714
 						$messageListForToggle = $_sRt['match']->ids;
4722 4715
 						$filter['status'] = array($_flag);
4723
-						if ($query['filter'] && $query['filter'] !='any')
4716
+						if ($query['filter'] && $query['filter'] != 'any')
4724 4717
 						{
4725 4718
 							$filter['status'][] = $query['filter'];
4726 4719
 						}
4727
-						$rByUid=true;
4720
+						$rByUid = true;
4728 4721
 						$reverse = 1;
4729 4722
 						$_sR = $this->mail_bo->getSortedList(
4730 4723
 							$folder,
4731
-							$sort=0,
4724
+							$sort = 0,
4732 4725
 							$reverse,
4733 4726
 							$filter,
4734 4727
 							$rByUid,
4735 4728
 							false
4736 4729
 						);
4737 4730
 						$messageList = $_sR['match']->ids;
4738
-						if (count($messageListForToggle)>0)
4731
+						if (count($messageListForToggle) > 0)
4739 4732
 						{
4740 4733
 							$flag2set = (strtolower($_flag));
4741
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4742
-							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4734
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4735
+							$this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder);
4743 4736
 						}
4744
-						if (count($messageList)>0)
4737
+						if (count($messageList) > 0)
4745 4738
 						{
4746 4739
 							$flag2set = 'un'.$_flag;
4747
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4748
-							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4740
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4741
+							$this->mail_bo->flagMessages($flag2set, $messageList, $folder);
4749 4742
 						}
4750
-						$alreadyFlagged=true;
4743
+						$alreadyFlagged = true;
4751 4744
 					}
4752 4745
 					elseif (!empty($filter) &&
4753
-						(!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) ||
4754
-						(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4755
-						($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
4746
+						(!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) ||
4747
+						(in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4748
+						($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))))
4756 4749
 					{
4757
-						if ($query['filter'] && $query['filter'] !='any')
4750
+						if ($query['filter'] && $query['filter'] != 'any')
4758 4751
 						{
4759 4752
 							$filter['status'] = $query['filter'];
4760 4753
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4761
-							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4754
+							$_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag)));
4762 4755
 						}
4763
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4756
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4764 4757
 						$rByUid = true;
4765 4758
 						$reverse = 1;
4766 4759
 						$_sR = $this->mail_bo->getSortedList(
4767 4760
 							$folder,
4768
-							$sort=0,
4761
+							$sort = 0,
4769 4762
 							$reverse,
4770 4763
 							$filter,
4771 4764
 							$rByUid,
@@ -4777,8 +4770,8 @@  discard block
 block discarded – undo
4777 4770
 					}
4778 4771
 					else
4779 4772
 					{
4780
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4781
-						$alreadyFlagged=true;
4773
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4774
+						$alreadyFlagged = true;
4782 4775
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4783 4776
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4784 4777
 						$this->mail_bo->flagMessages($_flag, 'all', $folder);
@@ -4792,41 +4785,41 @@  discard block
 block discarded – undo
4792 4785
 			}
4793 4786
 			if (!$alreadyFlagged)
4794 4787
 			{
4795
-				foreach($_messageList['msg'] as $rowID)
4788
+				foreach ($_messageList['msg'] as $rowID)
4796 4789
 				{
4797 4790
 					$hA = self::splitRowID($rowID);
4798 4791
 					$messageList[] = $hA['msgUID'];
4799 4792
 				}
4800
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
4801
-				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4793
+				if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList)));
4794
+				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder);
4802 4795
 			}
4803 4796
 		}
4804 4797
 		else
4805 4798
 		{
4806
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4799
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4807 4800
 		}
4808 4801
 
4809 4802
 		if ($_sendJsonResponse)
4810 4803
 		{
4811
-			$flag=array(
4812
-				'label1'	=> 'important',//lang('important'),
4813
-				'label2'	=> 'job',	//lang('job'),
4814
-				'label3'	=> 'personal',//lang('personal'),
4815
-				'label4'	=> 'to do',	//lang('to do'),
4816
-				'label5'	=> 'later',	//lang('later'),
4804
+			$flag = array(
4805
+				'label1'	=> 'important', //lang('important'),
4806
+				'label2'	=> 'job', //lang('job'),
4807
+				'label3'	=> 'personal', //lang('personal'),
4808
+				'label4'	=> 'to do', //lang('to do'),
4809
+				'label5'	=> 'later', //lang('later'),
4817 4810
 			);
4818 4811
 			$response = Api\Json\Response::get();
4819 4812
 			if (isset($_messageList['msg']) && $_messageList['popup'])
4820 4813
 			{
4821
-				$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');
4814
+				$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');
4822 4815
 			}
4823
-			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
4816
+			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))
4824 4817
 			{
4825
-				$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');
4818
+				$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');
4826 4819
 			}
4827 4820
 			else
4828 4821
 			{
4829
-				$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));
4822
+				$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));
4830 4823
 			}
4831 4824
 		}
4832 4825
 	}
@@ -4838,12 +4831,12 @@  discard block
 block discarded – undo
4838 4831
 	 * @param string _forceDeleteMethod - method of deletion to be enforced
4839 4832
 	 * @return xajax response
4840 4833
 	 */
4841
-	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4834
+	function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null)
4842 4835
 	{
4843
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
4836
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod);
4844 4837
 		$error = null;
4845
-		$filtered =  false;
4846
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4838
+		$filtered = false;
4839
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4847 4840
 		{
4848 4841
 			if (isset($_messageList['all']) && $_messageList['all'])
4849 4842
 			{
@@ -4853,34 +4846,34 @@  discard block
 block discarded – undo
4853 4846
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4854 4847
 				{
4855 4848
 					$query = $_messageList['activeFilters'];
4856
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4849
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4857 4850
 					{
4858 4851
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4859 4852
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4860 4853
 						{
4861
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4862
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4854
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4855
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4863 4856
 						}
4864
-						$filtered =  true;
4857
+						$filtered = true;
4865 4858
 						$cutoffdate = $cutoffdate2 = null;
4866
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4867
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4859
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4860
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4868 4861
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4869 4862
 						$filter = array(
4870
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4871
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4863
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4864
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4872 4865
 							'string' => $query['search'],
4873
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4866
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4874 4867
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4875 4868
 						);
4876
-						if ($query['enddate']||$query['startdate']) {
4869
+						if ($query['enddate'] || $query['startdate']) {
4877 4870
 							$filter['range'] = "BETWEEN";
4878 4871
 							if ($cutoffdate) {
4879
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4872
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4880 4873
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4881 4874
 							}
4882 4875
 							if ($cutoffdate2) {
4883
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4876
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4884 4877
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4885 4878
 							}
4886 4879
 						}
@@ -4894,7 +4887,7 @@  discard block
 block discarded – undo
4894 4887
 					$rByUid = true;
4895 4888
 					$_sR = $this->mail_bo->getSortedList(
4896 4889
 						$folder,
4897
-						$sort=0,
4890
+						$sort = 0,
4898 4891
 						$reverse,
4899 4892
 						$filter,
4900 4893
 						$rByUid,
@@ -4904,23 +4897,23 @@  discard block
 block discarded – undo
4904 4897
 				}
4905 4898
 				else
4906 4899
 				{
4907
-					$messageList='all';
4900
+					$messageList = 'all';
4908 4901
 				}
4909 4902
 				try
4910 4903
 				{
4911 4904
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4912
-					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4905
+					$this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4913 4906
 				}
4914 4907
 				catch (Api\Exception $e)
4915 4908
 				{
4916
-					$error = str_replace('"',"'",$e->getMessage());
4909
+					$error = str_replace('"', "'", $e->getMessage());
4917 4910
 				}
4918 4911
 			}
4919 4912
 			else
4920 4913
 			{
4921 4914
 				$uidA = self::splitRowID($_messageList['msg'][0]);
4922 4915
 				$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4923
-				foreach($_messageList['msg'] as $rowID)
4916
+				foreach ($_messageList['msg'] as $rowID)
4924 4917
 				{
4925 4918
 					$hA = self::splitRowID($rowID);
4926 4919
 					$messageList[] = $hA['msgUID'];
@@ -4928,27 +4921,27 @@  discard block
 block discarded – undo
4928 4921
 				try
4929 4922
 				{
4930 4923
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4931
-					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4924
+					$this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4932 4925
 				}
4933 4926
 				catch (Api\Exception $e)
4934 4927
 				{
4935
-					$error = str_replace('"',"'",$e->getMessage());
4928
+					$error = str_replace('"', "'", $e->getMessage());
4936 4929
 				}
4937 4930
 			}
4938 4931
 			$response = Api\Json\Response::get();
4939 4932
 			if (empty($error))
4940 4933
 			{
4941
-				$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']));
4934
+				$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']));
4942 4935
 			}
4943 4936
 			else
4944 4937
 			{
4945
-				$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));
4946
-				$response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList));
4938
+				$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));
4939
+				$response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList));
4947 4940
 			}
4948 4941
 		}
4949 4942
 		else
4950 4943
 		{
4951
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4944
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4952 4945
 		}
4953 4946
 	}
4954 4947
 
@@ -4962,48 +4955,48 @@  discard block
 block discarded – undo
4962 4955
 	 *
4963 4956
 	 * @return xajax response
4964 4957
 	 */
4965
-	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4958
+	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_')
4966 4959
 	{
4967
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4960
+		if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4968 4961
 		Api\Translation::add_app('mail');
4969 4962
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4970 4963
 		// only copy or move are supported as method
4971
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
4972
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4964
+		if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy';
4965
+		list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2);
4973 4966
 		// check if move2archive was called with the correct archiveFolder
4974 4967
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
4975
-		if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder)
4968
+		if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder)
4976 4969
 		{
4977 4970
 			error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder");
4978 4971
 			$targetProfileID = $this->mail_bo->profileID;
4979 4972
 			$targetFolder = $archiveFolder;
4980 4973
 			error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder");
4981 4974
 		}
4982
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
4975
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
4983 4976
 		$changeFolderActions = false;
4984 4977
 		//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
4985 4978
 		//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
4986 4979
 		if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
4987 4980
 		{
4988 4981
 			//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]));
4989
-			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
4982
+			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3)
4990 4983
 			{
4991 4984
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4992
-				foreach( $keys as &$f)
4985
+				foreach ($keys as &$f)
4993 4986
 				{
4994
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4987
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4995 4988
 					else break;
4996 4989
 				}
4997 4990
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4998 4991
 			}
4999 4992
 			//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
5000
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName;
4993
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName;
5001 4994
 			$changeFolderActions = true;
5002 4995
 		}
5003 4996
 		$filtered = false;
5004
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4997
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
5005 4998
 		{
5006
-			$error=false;
4999
+			$error = false;
5007 5000
 			if (isset($_messageList['all']) && $_messageList['all'])
5008 5001
 			{
5009 5002
 				// we have both messageIds AND allFlag folder information
@@ -5013,34 +5006,34 @@  discard block
 block discarded – undo
5013 5006
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
5014 5007
 				{
5015 5008
 					$query = $_messageList['activeFilters'];
5016
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
5009
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
5017 5010
 					{
5018 5011
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
5019 5012
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5020 5013
 						{
5021
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
5022
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5014
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
5015
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
5023 5016
 						}
5024 5017
 						$filtered = true;
5025 5018
 						$cutoffdate = $cutoffdate2 = null;
5026
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
5027
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5019
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
5020
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
5028 5021
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
5029 5022
 						$filter = array(
5030
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
5031
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
5023
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
5024
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
5032 5025
 							'string' => $query['search'],
5033
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
5026
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
5034 5027
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
5035 5028
 						);
5036
-						if ($query['enddate']||$query['startdate']) {
5029
+						if ($query['enddate'] || $query['startdate']) {
5037 5030
 							$filter['range'] = "BETWEEN";
5038 5031
 							if ($cutoffdate) {
5039
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
5032
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
5040 5033
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5041 5034
 							}
5042 5035
 							if ($cutoffdate2) {
5043
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
5036
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
5044 5037
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5045 5038
 							}
5046 5039
 						}
@@ -5053,70 +5046,70 @@  discard block
 block discarded – undo
5053 5046
 					$rByUid = true;
5054 5047
 					$_sR = $this->mail_bo->getSortedList(
5055 5048
 						$folder,
5056
-						$sort=0,
5049
+						$sort = 0,
5057 5050
 						$reverse,
5058 5051
 						$filter,
5059
-						$rByUid=true,
5052
+						$rByUid = true,
5060 5053
 						false
5061 5054
 					);
5062 5055
 					$messageList = $_sR['match']->ids;
5063
-					foreach($messageList as $uID)
5056
+					foreach ($messageList as $uID)
5064 5057
 					{
5065 5058
 						//error_log(__METHOD__.__LINE__.$uID);
5066
-						if ($_copyOrMove=='move')
5059
+						if ($_copyOrMove == 'move')
5067 5060
 						{
5068
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false);
5061
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false);
5069 5062
 						}
5070 5063
 					}
5071 5064
 				}
5072 5065
 				else
5073 5066
 				{
5074
-					$messageList='all';
5067
+					$messageList = 'all';
5075 5068
 				}
5076 5069
 				try
5077 5070
 				{
5078 5071
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
5079
-					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
5072
+					$this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
5080 5073
 				}
5081 5074
 				catch (Api\Exception $e)
5082 5075
 				{
5083
-					$error = str_replace('"',"'",$e->getMessage());
5076
+					$error = str_replace('"', "'", $e->getMessage());
5084 5077
 				}
5085 5078
 			}
5086 5079
 			else
5087 5080
 			{
5088 5081
 				$messageList = array();
5089
-				while(count($_messageList['msg']) > 0)
5082
+				while (count($_messageList['msg']) > 0)
5090 5083
 				{
5091 5084
 					$uidA = self::splitRowID($_messageList['msg'][0]);
5092 5085
 					$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
5093 5086
 					$sourceProfileID = $uidA['profileID'];
5094 5087
 					$moveList = array();
5095
-					foreach($_messageList['msg'] as $rowID)
5088
+					foreach ($_messageList['msg'] as $rowID)
5096 5089
 					{
5097 5090
 						$hA = self::splitRowID($rowID);
5098 5091
 
5099 5092
 						// If folder changes, stop and move what we've got
5100
-						if($hA['folder'] != $folder) break;
5093
+						if ($hA['folder'] != $folder) break;
5101 5094
 
5102 5095
 						array_shift($_messageList['msg']);
5103 5096
 						$messageList[] = $hA['msgUID'];
5104 5097
 						$moveList[] = $hA['msgUID'];
5105
-						if ($_copyOrMove=='move')
5098
+						if ($_copyOrMove == 'move')
5106 5099
 						{
5107
-							$helpvar = explode(self::$delimiter,$rowID);
5100
+							$helpvar = explode(self::$delimiter, $rowID);
5108 5101
 							array_shift($helpvar);
5109
-							$messageListForRefresh[]= implode(self::$delimiter,$helpvar);
5102
+							$messageListForRefresh[] = implode(self::$delimiter, $helpvar);
5110 5103
 						}
5111 5104
 					}
5112 5105
 					try
5113 5106
 					{
5114 5107
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
5115
-						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
5108
+						$this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
5116 5109
 					}
5117 5110
 					catch (Api\Exception $e)
5118 5111
 					{
5119
-						$error = str_replace('"',"'",$e->getMessage());
5112
+						$error = str_replace('"', "'", $e->getMessage());
5120 5113
 					}
5121 5114
 				}
5122 5115
 			}
@@ -5129,30 +5122,30 @@  discard block
 block discarded – undo
5129 5122
 					unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]);
5130 5123
 					$changeFolderActions = true;
5131 5124
 				}
5132
-				$response->call('egw.message',$error,"error");
5125
+				$response->call('egw.message', $error, "error");
5133 5126
 			}
5134 5127
 			else
5135 5128
 			{
5136
-				if ($_copyOrMove=='copy')
5129
+				if ($_copyOrMove == 'copy')
5137 5130
 				{
5138
-					$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));
5131
+					$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));
5139 5132
 				}
5140 5133
 				else
5141 5134
 				{
5142
-					$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');
5135
+					$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');
5143 5136
 				}
5144 5137
 			}
5145 5138
 			if ($changeFolderActions == true)
5146 5139
 			{
5147 5140
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
5148
-				Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
5141
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
5149 5142
 				$actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions());
5150
-				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
5143
+				$response->call('app.mail.mail_rebuildActionsOnList', $actionsnew);
5151 5144
 			}
5152 5145
 		}
5153 5146
 		else
5154 5147
 		{
5155
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5148
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5156 5149
 		}
5157 5150
 	}
5158 5151
 
@@ -5162,11 +5155,11 @@  discard block
 block discarded – undo
5162 5155
 	 *
5163 5156
 	 * @param type $_id
5164 5157
 	 */
5165
-	function ajax_folderMgmtTree_autoloading ($_id = null)
5158
+	function ajax_folderMgmtTree_autoloading($_id = null)
5166 5159
 	{
5167 5160
 		$mail_ui = new mail_ui();
5168
-		$id = $_id? $_id : $_GET['id'];
5169
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false));
5161
+		$id = $_id ? $_id : $_GET['id'];
5162
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false));
5170 5163
 	}
5171 5164
 
5172 5165
 	/**
@@ -5174,15 +5167,15 @@  discard block
 block discarded – undo
5174 5167
 	 *
5175 5168
 	 * @param array $content content of dialog
5176 5169
 	 */
5177
-	function folderManagement (array $content = null)
5170
+	function folderManagement(array $content = null)
5178 5171
 	{
5179 5172
 		$dtmpl = new Etemplate('mail.folder_management');
5180
-		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
5181
-		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
5173
+		$profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id'];
5174
+		$sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false);
5182 5175
 
5183 5176
 		if (!is_array($content))
5184 5177
 		{
5185
-			$content = array ('acc_id' => $profileID);
5178
+			$content = array('acc_id' => $profileID);
5186 5179
 		}
5187 5180
 
5188 5181
 		$readonlys = array();
@@ -5190,7 +5183,7 @@  discard block
 block discarded – undo
5190 5183
 		$preserv = array(
5191 5184
 			'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side
5192 5185
 		);
5193
-		$dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2);
5186
+		$dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2);
5194 5187
 	}
5195 5188
 
5196 5189
 	/**
@@ -5200,11 +5193,11 @@  discard block
 block discarded – undo
5200 5193
 	 *
5201 5194
 	 * @param type $_folderName
5202 5195
 	 */
5203
-	function ajax_folderMgmt_delete ($_folderName)
5196
+	function ajax_folderMgmt_delete($_folderName)
5204 5197
 	{
5205 5198
 		if ($_folderName)
5206 5199
 		{
5207
-			$success = $this->ajax_deleteFolder($_folderName,true);
5200
+			$success = $this->ajax_deleteFolder($_folderName, true);
5208 5201
 			$response = Api\Json\Response::get();
5209 5202
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
5210 5203
 			if ($success)
@@ -5213,7 +5206,7 @@  discard block
 block discarded – undo
5213 5206
 			}
5214 5207
 			else
5215 5208
 			{
5216
-				$res = lang("Failed to delete %1",$folderName);
5209
+				$res = lang("Failed to delete %1", $folderName);
5217 5210
 			}
5218 5211
 			$response->data($res);
5219 5212
 		}
Please login to merge, or discard this patch.