Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
mail/inc/class.mail_ui.inc.php 1 patch
Spacing   +822 added lines, -829 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @var array
42 42
 	 */
43
-	var $public_functions = array
44
-	(
43
+	var $public_functions = array(
45 44
 		'index' => True,
46 45
 		'displayHeader'	=> True,
47 46
 		'displayMessage'	=> True,
@@ -92,17 +91,17 @@  discard block
 block discarded – undo
92 91
 	 * @var array
93 92
 	 */
94 93
 	var $searchTypes = array(
95
-		'quick'		=> 'quicksearch',	// lang('quicksearch')
96
-		'quickwithcc'=> 'quicksearch (with cc)',	// lang('quicksearch (with cc)')
97
-		'subject'	=> 'subject',		// lang('subject')
98
-		'body'		=> 'message body',	// lang('message body')
99
-		'from'		=> 'from',			// lang('from')
100
-		'to'		=> 'to',			// lang('to')
101
-		'cc'		=> 'cc',			// lang('cc')
102
-		'text'		=> 'whole message',	// lang('whole message')
103
-		'larger'		=> 'greater than',	// lang('greater than')
104
-		'smaller'		=> 'less than',	// lang('less than')
105
-		'bydate' 	=> 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)')
94
+		'quick'		=> 'quicksearch', // lang('quicksearch')
95
+		'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)')
96
+		'subject'	=> 'subject', // lang('subject')
97
+		'body'		=> 'message body', // lang('message body')
98
+		'from'		=> 'from', // lang('from')
99
+		'to'		=> 'to', // lang('to')
100
+		'cc'		=> 'cc', // lang('cc')
101
+		'text'		=> 'whole message', // lang('whole message')
102
+		'larger'		=> 'greater than', // lang('greater than')
103
+		'smaller'		=> 'less than', // lang('less than')
104
+		'bydate' 	=> 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)')
106 105
 	);
107 106
 
108 107
 	/**
@@ -111,12 +110,12 @@  discard block
 block discarded – undo
111 110
 	 * @var array
112 111
 	 */
113 112
 	var $statusTypes = array(
114
-		'any'		=> 'any status',// lang('any status')
115
-		'flagged'	=> 'flagged',	// lang('flagged')
116
-		'unseen'	=> 'unread',	// lang('unread')
117
-		'answered'	=> 'replied',	// lang('replied')
118
-		'seen'		=> 'read',		// lang('read')
119
-		'deleted'	=> 'deleted',	// lang('deleted')
113
+		'any'		=> 'any status', // lang('any status')
114
+		'flagged'	=> 'flagged', // lang('flagged')
115
+		'unseen'	=> 'unread', // lang('unread')
116
+		'answered'	=> 'replied', // lang('replied')
117
+		'seen'		=> 'read', // lang('read')
118
+		'deleted'	=> 'deleted', // lang('deleted')
120 119
 	);
121 120
 
122 121
 	/**
@@ -124,12 +123,12 @@  discard block
 block discarded – undo
124 123
 	 *
125 124
 	 * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server
126 125
 	 */
127
-	function __construct($run_constructor=true)
126
+	function __construct($run_constructor = true)
128 127
 	{
129 128
 		$this->mail_tree = new mail_tree($this);
130 129
 		if (!$run_constructor) return;
131 130
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
131
+		if (Mail::$debugTimes) $starttime = microtime(true);
133 132
 		// no autohide of the sidebox, as we use it for folderlist now.
134 133
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 134
 
@@ -145,13 +144,13 @@  discard block
 block discarded – undo
145 144
 		}
146 145
 
147 146
 		try {
148
-			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
147
+			$this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true);
149 148
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
150 149
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 150
 
152 151
 			// RegEx to minimize extra openConnection
153 152
 			$needle = '/^(?!mail)/';
154
-			if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
153
+			if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
155 154
 			{
156 155
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
157 156
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -164,12 +163,12 @@  discard block
 block discarded – undo
164 163
 			if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index')
165 164
 			{
166 165
 				$response = Api\Json\Response::get();
167
-				$response->call('egw.message',$e->getMessage(),'error');
166
+				$response->call('egw.message', $e->getMessage(), 'error');
168 167
 			}
169 168
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
169
+			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false);
171 170
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
173 172
 	}
174 173
 
175 174
 	/**
@@ -179,10 +178,10 @@  discard block
 block discarded – undo
179 178
 	 * @param boolean $exit If true, will call exit() after opening the wizardpopup
180 179
 	 * @param string $msg_type = 'success' message type
181 180
 	 */
182
-	static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true)
181
+	static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true)
183 182
 	{
184 183
 		//error_log(__METHOD__."('$message', $exit) ".function_backtrace());
185
-		$linkData=(self::$icServerID ? array(
184
+		$linkData = (self::$icServerID ? array(
186 185
 				'menuaction' => 'mail.mail_wizard.edit',
187 186
 				'acc_id' => self::$icServerID,
188 187
 			) : array(
@@ -196,11 +195,11 @@  discard block
 block discarded – undo
196 195
 		{
197 196
 			$response = Api\Json\Response::get();
198 197
 			$windowName = "editMailAccount".self::$icServerID;
199
-			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
198
+			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true);
200 199
 			Framework::message($message, 'error');
201 200
 			if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index)
202 201
 			{
203
-				$response->call('framework.setSidebox','mail',array(),'md5');
202
+				$response->call('framework.setSidebox', 'mail', array(), 'md5');
204 203
 			}
205 204
 			if ($exit)
206 205
 			{
@@ -210,8 +209,8 @@  discard block
 block discarded – undo
210 209
 		else	// regular GET request eg. in idots template
211 210
 		{
212 211
 			$windowName = "editMailAccount".self::$icServerID;
213
-			Framework::popup(Framework::link('/index.php',$linkData),$windowName);
214
-			$GLOBALS['egw']->framework->render($message,'',true);
212
+			Framework::popup(Framework::link('/index.php', $linkData), $windowName);
213
+			$GLOBALS['egw']->framework->render($message, '', true);
215 214
 			if ($exit)
216 215
 			{
217 216
 				exit();
@@ -227,9 +226,9 @@  discard block
 block discarded – undo
227 226
 	 *
228 227
 	 * @throws Api\Exception
229 228
 	 */
230
-	function changeProfile($_icServerID,$unsetCache=false)
229
+	function changeProfile($_icServerID, $unsetCache = false)
231 230
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
231
+		if (Mail::$debugTimes) $starttime = microtime(true);
233 232
 		if (self::$icServerID != $_icServerID)
234 233
 		{
235 234
 			self::$icServerID = $_icServerID;
@@ -237,35 +236,35 @@  discard block
 block discarded – undo
237 236
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
238 237
 
239 238
 		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
240
-		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
239
+		$this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true);
241 240
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
242 241
 		// no icServer Object: something failed big time
243
-		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
242
+		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID)
244 243
 		{
245 244
 			self::$icServerID = $_icServerID;
246 245
 			throw new Api\Exception('Profile change failed!');
247 246
 		}
248 247
 
249 248
 		// save session varchar
250
-		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
249
+		$oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID');
251 250
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252 251
 		if (true) $oldicServerID = self::$icServerID;
253
-		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
252
+		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true))
254 253
 		{
255 254
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 255
 		}
257 256
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
257
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
259 258
 	}
260 259
 
261 260
 	/**
262 261
 	 * Ajax function to request next branch of a tree branch
263 262
 	 */
264
-	static function ajax_tree_autoloading ($_id = null)
263
+	static function ajax_tree_autoloading($_id = null)
265 264
 	{
266 265
 		$mail_ui = new mail_ui();
267 266
 		$id = $_id ? $_id : $_GET['id'];
268
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
267
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false));
269 268
 	}
270 269
 
271 270
 	/**
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 	 * @param array $content
275 274
 	 * @param type $msg
276 275
 	 */
277
-	function subscription(array $content=null ,$msg=null)
276
+	function subscription(array $content = null, $msg = null)
278 277
 	{
279 278
 		$stmpl = new Etemplate('mail.subscribe');
280 279
 
281
-		if(is_array($content))
280
+		if (is_array($content))
282 281
 		{
283 282
 			$profileId = $content['profileId'];
284 283
 		}
@@ -288,14 +287,14 @@  discard block
 block discarded – undo
288 287
 		}
289 288
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
290 289
 		// triggered from client-side. Also, we keep this here as
291
-		$sel_options['foldertree'] =  $this->mail_tree->getTree(null,$profileId,1,true,false,true);
290
+		$sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true);
292 291
 
293 292
 		//Get all subscribed folders
294 293
 		// as getting all subscribed folders is very fast operation
295 294
 		// we can use it to get a comparison base for folders which
296 295
 		// got subscribed or unsubscribed by the user
297 296
 		try {
298
-			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
297
+			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true);
299 298
 		} catch (Exception $ex) {
300 299
 			Framework::message($ex->getMessage());
301 300
 		}
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
 
307 306
 			foreach ($subscribed as $folder)
308 307
 			{
309
-				$folderName = $profileId . self::$delimiter . $folder['MAILBOX'];
308
+				$folderName = $profileId.self::$delimiter.$folder['MAILBOX'];
310 309
 				array_push($content['foldertree'], $folderName);
311 310
 			}
312 311
 		}
@@ -320,9 +319,9 @@  discard block
 block discarded – undo
320 319
 				{
321 320
 					// do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
322 321
 					$namespace_roots = array($profileId);
323
-					foreach($this->mail_bo->_getNameSpaces() as $namespace)
322
+					foreach ($this->mail_bo->_getNameSpaces() as $namespace)
324 323
 					{
325
-						$namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
324
+						$namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']);
326 325
 					}
327 326
 					$to_unsubscribe = $to_subscribe = array();
328 327
 					foreach ($content['foldertree'] as $path => $value)
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 330
 						if ($node)
332 331
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
332
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node;
334 333
 							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335 334
 							if ($value['value']) $cont[] = $path;
336 335
 						}
@@ -340,7 +339,7 @@  discard block
 block discarded – undo
340 339
 					// set foldertree options to basic node in order to avoid initial autoloading
341 340
 					// from client side, as no options would trigger that.
342 341
 					$sel_options['foldertree'] = array('id' => '0', 'item'=> array());
343
-					foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
342
+					foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
344 343
 					{
345 344
 						if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true))
346 345
 						{
@@ -376,18 +375,18 @@  discard block
 block discarded – undo
376 375
 						}
377 376
 					}
378 377
 					// update foldertree in main window
379
-					$parentFolder='INBOX';
378
+					$parentFolder = 'INBOX';
380 379
 					$refreshData = array(
381 380
 						$profileId => lang($parentFolder),
382 381
 					);
383 382
 					$response = Api\Json\Response::get();
384
-					foreach($refreshData as $folder => &$name)
383
+					foreach ($refreshData as $folder => &$name)
385 384
 					{
386
-						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
385
+						$name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true);
387 386
 					}
388 387
 					// give success/error message to opener and popup itself
389 388
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
390
-					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
389
+					$response->call('opener.app.mail.mail_reloadNode', $refreshData);
391 390
 
392 391
 					Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
393 392
 					if ($button == 'apply')
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 
408 407
 		$readonlys = array();
409 408
 
410
-		$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
409
+		$stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2);
411 410
 	}
412 411
 
413 412
 	/**
@@ -416,13 +415,13 @@  discard block
 block discarded – undo
416 415
 	 * @param array $content
417 416
 	 * @param string $msg
418 417
 	 */
419
-	function index(array $content=null,$msg=null)
418
+	function index(array $content = null, $msg = null)
420 419
 	{
421 420
 		//error_log(__METHOD__.__LINE__.array2string($content));
422
-		try	{
421
+		try {
423 422
 				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
424 423
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
424
+				if (Mail::$debugTimes) $starttime = microtime(true);
426 425
 				$this->mail_bo->restoreSessionData();
427 426
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 427
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -443,26 +442,26 @@  discard block
 block discarded – undo
443 442
 					{
444 443
 						// These only set on first load
445 444
 						$content[self::$nm_index] = array(
446
-							'filter'         => 'any',	// filter is used to choose the mailbox
447
-							'lettersearch'   => false,	// I  show a lettersearch
448
-							'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
449
-							'start'          =>	0,		// IO position in list
450
-							'order'          =>	'date',	// IO name of the column to sort after (optional for the sortheaders)
451
-							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
445
+							'filter'         => 'any', // filter is used to choose the mailbox
446
+							'lettersearch'   => false, // I  show a lettersearch
447
+							'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
448
+							'start'          =>	0, // IO position in list
449
+							'order'          =>	'date', // IO name of the column to sort after (optional for the sortheaders)
450
+							'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
452 451
 						);
453 452
 					}
454 453
 					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
455 454
 				}
456 455
 
457 456
 				// These must always be set, even if $content is an array
458
-				$content[self::$nm_index]['cat_is_select'] = true;    // Category select is just a normal selectbox
459
-				$content[self::$nm_index]['no_filter2'] = false;       // Disable second filter
457
+				$content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox
458
+				$content[self::$nm_index]['no_filter2'] = false; // Disable second filter
460 459
 				$content[self::$nm_index]['actions'] = self::get_actions();
461
-				$content[self::$nm_index]['row_id'] = 'row_id';	     // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
460
+				$content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
462 461
 				$content[self::$nm_index]['placeholder_actions'] = array('composeasnew');
463 462
 				$content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows';
464
-				$content[self::$nm_index]['num_rows'] = 0;      // Do not send any rows with initial request
465
-				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size';	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
463
+				$content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request
464
+				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
466 465
 				$content[self::$nm_index]['csv_fields'] = false;
467 466
 				if ($msg)
468 467
 				{
@@ -474,11 +473,11 @@  discard block
 block discarded – undo
474 473
 					unset($content['msg']);
475 474
 				}
476 475
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477
-				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
476
+				$quota = false; //$this->mail_bo->getQuotaRoot();
477
+				if ($quota !== false && $quota['limit'] != 'NOT SET') {
479 478
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 479
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481
-					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
480
+					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
482 481
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 482
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484 483
 				} else {
@@ -487,43 +486,43 @@  discard block
 block discarded – undo
487 486
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
488 487
 				}
489 488
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
490
-				$vacation = false;//$this->gatherVacation();
489
+				$vacation = false; //$this->gatherVacation();
491 490
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
492
-				if($vacation) {
493
-					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
491
+				if ($vacation) {
492
+					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time()))
494 493
 					{
495 494
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
496 495
 						$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
497
-						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
496
+						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
498 497
 					}
499 498
 				}
500
-				if ($vacation==false)
499
+				if ($vacation == false)
501 500
 				{
502 501
 					$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = '';
503 502
 					$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = '';
504 503
 				}
505 504
 				//$zstarttime = microtime (true);
506
-				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
505
+				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
507 506
 				//$zendtime = microtime(true) - $zstarttime;
508 507
 				//error_log(__METHOD__.__LINE__. " time used: ".$zendtime);
509
-				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX');
508
+				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX');
510 509
 				// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
511
-				if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
510
+				if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
512 511
 				{
513
-					$this->statusTypes = array_merge($this->statusTypes,array(
514
-						'keyword1'	=> 'important',//lang('important'),
515
-						'keyword2'	=> 'job',	//lang('job'),
516
-						'keyword3'	=> 'personal',//lang('personal'),
517
-						'keyword4'	=> 'to do',	//lang('to do'),
518
-						'keyword5'	=> 'later',	//lang('later'),
512
+					$this->statusTypes = array_merge($this->statusTypes, array(
513
+						'keyword1'	=> 'important', //lang('important'),
514
+						'keyword2'	=> 'job', //lang('job'),
515
+						'keyword3'	=> 'personal', //lang('personal'),
516
+						'keyword4'	=> 'to do', //lang('to do'),
517
+						'keyword5'	=> 'later', //lang('later'),
519 518
 					));
520 519
 				}
521 520
 				else
522 521
 				{
523
-					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
524
-					foreach($keywords as &$k)
522
+					$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
523
+					foreach ($keywords as &$k)
525 524
 					{
526
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
525
+						if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
527 526
 					}
528 527
 				}
529 528
 
@@ -534,8 +533,8 @@  discard block
 block discarded – undo
534 533
 
535 534
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
536 535
 				{
537
-					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
538
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
536
+					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
537
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
539 538
 				}
540 539
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
541 540
 				{
@@ -547,14 +546,14 @@  discard block
 block discarded – undo
547 546
 				//error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']));
548 547
 				$content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'];
549 548
 				$sel_options['filter'] = $this->statusTypes;
550
-				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'));
549
+				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'));
551 550
 				$content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'];
552 551
 
553 552
 				$etpl = new Etemplate('mail.index');
554 553
 				//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
555 554
 				$content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()";
556 555
 				// set the actions on tree
557
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
556
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions());
558 557
 
559 558
 				// sending preview toolbar actions
560 559
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
@@ -565,34 +564,34 @@  discard block
 block discarded – undo
565 564
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
566 565
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
567 566
 				{
568
-					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
567
+					$content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject'));
569 568
 				}
570 569
 				$readonlys = $preserv = array();
571
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
570
+				if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
572 571
 		}
573 572
 		catch (Exception $e)
574 573
 		{
575 574
 			// do not exit here. mail-tree should be build. if we exit here, we never get there.
576
-			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
575
+			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
577 576
 			if (isset($this->mail_bo))
578 577
 			{
579 578
 				if (empty($etpl))
580 579
 				{
581
-					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
580
+					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
582 581
 					$etpl = new Etemplate('mail.index');
583 582
 				}
584
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
583
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false));
585 584
 			}
586 585
 			$readonlys = $preserv = array();
587
-			if (empty($content)) $content=array();
586
+			if (empty($content)) $content = array();
588 587
 
589
-			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
588
+			self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ? false : true), 'error', false);
590 589
 			//return false;
591 590
 		}
592 591
 		// Check preview pane is enabled, then show spliter
593 592
 		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
594 593
 
595
-		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
594
+		return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv);
596 595
 	}
597 596
 
598 597
 	/**
@@ -602,11 +601,11 @@  discard block
 block discarded – undo
602 601
 	 * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server
603 602
 	 * @return array
604 603
 	 */
605
-	function get_tree_actions($imap_actions=true)
604
+	function get_tree_actions($imap_actions = true)
606 605
 	{
607 606
 		// Start at 2 so auto-added copy+paste actions show up as second group
608 607
 		// Needed because there's no 'select all' action to push things down
609
-		$group=1;
608
+		$group = 1;
610 609
 		// Set tree actions
611 610
 		$tree_actions = array(
612 611
 			'drop_move_mail' => array(
@@ -688,12 +687,12 @@  discard block
 block discarded – undo
688 687
 				'onExecute' => 'javaScript:app.mail.edit_sieve',
689 688
 
690 689
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
691
-				'icon' => 'mail/filter',	// funnel
690
+				'icon' => 'mail/filter', // funnel
692 691
 				'hideOnMobile' => true
693 692
 			),
694 693
 			'vacation' => array(
695 694
 				'caption' => 'Vacation notice',
696
-				'icon' => 'mail/navbar',	// mail as in admin
695
+				'icon' => 'mail/navbar', // mail as in admin
697 696
 				'onExecute' => 'javaScript:app.mail.edit_vacation',
698 697
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
699 698
 			),
@@ -734,8 +733,8 @@  discard block
 block discarded – undo
734 733
 			unset($tree_actions['subscribe']);
735 734
 			unset($tree_actions['unsubscribe']);
736 735
 		}
737
-		++$group;	// put delete in own group
738
-		switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
736
+		++$group; // put delete in own group
737
+		switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
739 738
 		{
740 739
 			case 'move_to_trash':
741 740
 				$tree_actions['empty_trash'] = array(
@@ -754,7 +753,7 @@  discard block
 block discarded – undo
754 753
 				);
755 754
 				break;
756 755
 		}
757
-		$junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null);
756
+		$junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null);
758 757
 
759 758
 		//error_log(__METHOD__.__LINE__.$junkFolder);
760 759
 		if ($junkFolder && !empty($junkFolder))
@@ -767,8 +766,8 @@  discard block
 block discarded – undo
767 766
 				'group'	=> $group,
768 767
 			);
769 768
 		}
770
-		$tree_actions['sieve']['group']	= $tree_actions['vacation']['group'] = ++$group;	// new group for filter
771
-		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group']	= ++$group;
769
+		$tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter
770
+		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group;
772 771
 
773 772
 
774 773
 		// enforce global (group-specific) ACL
@@ -803,17 +802,17 @@  discard block
 block discarded – undo
803 802
 	 * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed
804 803
 	 * @param {boolean} $_status set true for subscribe and false to unsubscribe
805 804
 	 */
806
-	public function ajax_foldersubscription($_acc_id,$_folderName, $_status)
805
+	public function ajax_foldersubscription($_acc_id, $_folderName, $_status)
807 806
 	{
808 807
 		//Change the Mail object to related profileId
809 808
 		$this->changeProfile($_acc_id);
810
-		try{
809
+		try {
811 810
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
812 811
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
813
-			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
812
+			$this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
814 813
 		} catch (Horde_Imap_Client_Exception $ex) {
815
-			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
816
-			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
814
+			error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex));
815
+			Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status));
817 816
 		}
818 817
 	}
819 818
 
@@ -825,25 +824,25 @@  discard block
 block discarded – undo
825 824
 	 * @param string $_nodeID if of node whos children are requested
826 825
 	 * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default)
827 826
 	 */
828
-	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
827
+	public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null)
829 828
 	{
830 829
 		$nodeID = $_GET['id'];
831 830
 		if (!is_null($_nodeID)) $nodeID = $_nodeID;
832
-		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
831
+		$subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
833 832
 		$fetchCounters = !is_null($_nodeID);
834
-		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
833
+		list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2);
835 834
 
836 835
 		if (!empty($_folderName)) $fetchCounters = true;
837 836
 
838 837
 		// Check if it is called for refresh root
839 838
 		// then we need to reinitialized the index tree
840
-		if(!$nodeID && !$_profileID)
839
+		if (!$nodeID && !$_profileID)
841 840
 		{
842
-			$data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
841
+			$data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
843 842
 		}
844 843
 		else
845 844
 		{
846
-			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
845
+			$data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
847 846
 		}
848 847
 		if (!is_null($_nodeID)) return $data;
849 848
 		Etemplate\Widget\Tree::send_quote_json($data);
@@ -859,17 +858,17 @@  discard block
 block discarded – undo
859 858
 	 */
860 859
 	static function findNode($_out, $_nodeID, $childElements = false)
861 860
 	{
862
-		foreach($_out['item'] as $node)
861
+		foreach ($_out['item'] as $node)
863 862
 		{
864
-			if (strcmp($node['id'],$_nodeID)===0)
863
+			if (strcmp($node['id'], $_nodeID) === 0)
865 864
 			{
866 865
 				//error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']);
867
-				return ($childElements?$node['item']:$node);
866
+				return ($childElements ? $node['item'] : $node);
868 867
 			}
869
-			elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id']))
868
+			elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id']))
870 869
 			{
871 870
 				//error_log(__METHOD__.__LINE__.' descend into '.$node['id']);
872
-				return self::findNode($node,$_nodeID,$childElements);
871
+				return self::findNode($node, $_nodeID, $childElements);
873 872
 			}
874 873
 		}
875 874
 	}
@@ -883,7 +882,7 @@  discard block
 block discarded – undo
883 882
 	 */
884 883
 	private function get_actions()
885 884
 	{
886
-		static $accArray=array(); // buffer identity names on single request
885
+		static $accArray = array(); // buffer identity names on single request
887 886
 		// duplicated from mail_hooks
888 887
 		static $deleteOptions = array(
889 888
 			'move_to_trash'		=> 'move to trash',
@@ -894,12 +893,12 @@  discard block
 block discarded – undo
894 893
 		$lastFolderUsedForMove = null;
895 894
 		$moveactions = array();
896 895
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
897
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
896
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
898 897
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
899 898
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
900 899
 		if (is_null($accArray))
901 900
 		{
902
-			foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj)
901
+			foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj)
903 902
 			{
904 903
 				//error_log(__METHOD__.__LINE__.array2string($accountObj));
905 904
 				if (!$accountObj->is_imap())
@@ -907,22 +906,22 @@  discard block
 block discarded – undo
907 906
 					// not to be used for IMAP Foldertree, as there is no Imap host
908 907
 					continue;
909 908
 				}
910
-				$identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']);
911
-				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
909
+				$identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']);
910
+				$accArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); // as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
912 911
 			}
913 912
 		}
914
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
913
+		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array();
915 914
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
916 915
 		{
917
-			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
916
+			if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
918 917
 			{
919 918
 				$_folder = $this->mail_bo->icServer->getCurrentMailbox();
920 919
 				//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace());
921
-				$counter =1;
920
+				$counter = 1;
922 921
 				foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont)
923 922
 				{
924 923
 					$moveaction = 'move_';
925
-					if ($_folder!=$i)
924
+					if ($_folder != $i)
926 925
 					{
927 926
 						$moveaction .= $lastFolderUsedForMoveCont;
928 927
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
@@ -933,7 +932,7 @@  discard block
 block discarded – undo
933 932
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
934 933
 							$fS['shortDisplayName'] = $i;
935 934
 							$moveactions[$moveaction] = $fS;
936
-							$counter ++;
935
+							$counter++;
937 936
 						}
938 937
 						else
939 938
 						{
@@ -943,9 +942,9 @@  discard block
 block discarded – undo
943 942
 					}
944 943
 				}
945 944
 			}
946
-			elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
945
+			elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
947 946
 			{
948
-				$counter =1;
947
+				$counter = 1;
949 948
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
950 949
 				{
951 950
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
@@ -958,19 +957,19 @@  discard block
 block discarded – undo
958 957
 						$fS['profileName'] = $accArray[$pid];
959 958
 						$fS['shortDisplayName'] = $i;
960 959
 						$moveactions[$moveaction] = $fS;
961
-						$counter ++;
960
+						$counter++;
962 961
 					}
963 962
 				}
964 963
 			}
965 964
 		}
966
-		Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
965
+		Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
967 966
 		$group = 0;
968
-		$actions =  array(
967
+		$actions = array(
969 968
 			'open' => array(
970 969
 				'caption' => lang('Open'),
971 970
 				'icon' => 'view',
972 971
 				'group' => ++$group,
973
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
972
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open',
974 973
 				'allowOnMultiple' => false,
975 974
 				'default' => true,
976 975
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet'))
@@ -1023,20 +1022,20 @@  discard block
 block discarded – undo
1023 1022
 				'allowOnMultiple' => false,
1024 1023
 			)
1025 1024
 		);
1026
-		$macounter=0;
1025
+		$macounter = 0;
1027 1026
 		if (!empty($moveactions))
1028 1027
 		{
1029 1028
 			//error_log(__METHOD__.__LINE__.array2string($moveactions));
1030
-			$children=array();
1031
-			$pID=0;
1029
+			$children = array();
1030
+			$pID = 0;
1032 1031
 			foreach ($moveactions as $moveaction => $lastFolderUsedForMove)
1033 1032
 			{
1034
-				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group);
1033
+				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group);
1035 1034
 				//error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#');
1036 1035
 				$children = array_merge($children,
1037 1036
 					array(
1038 1037
 						$moveaction => array(
1039
-							'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
1038
+							'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''),
1040 1039
 							'icon' => 'move',
1041 1040
 							'group' => $group,
1042 1041
 							'onExecute' => 'javaScript:app.mail.mail_move2folder',
@@ -1047,7 +1046,7 @@  discard block
 block discarded – undo
1047 1046
 				$pID = $lastFolderUsedForMove['profileID'];
1048 1047
 				$macounter++;
1049 1048
 			}
1050
-			$actions['moveto'] =	array(
1049
+			$actions['moveto'] = array(
1051 1050
 				'caption' => lang('Move selected to'),
1052 1051
 				'icon' => 'move',
1053 1052
 				'group' => $group,
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
 				'icon' => 'tracker/navbar',
1091 1090
 				'onExecute' => 'javaScript:app.mail.mail_integrate',
1092 1091
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1093
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
1092
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
1094 1093
 				'allowOnMultiple' => false,
1095 1094
 			),
1096 1095
 			'calendar' => array(
@@ -1309,25 +1308,25 @@  discard block
 block discarded – undo
1309 1308
 	 * @param array &$rows
1310 1309
 	 * @param array &$readonlys
1311 1310
 	 */
1312
-	public static function get_rows(&$query,&$rows,&$readonlys)
1311
+	public static function get_rows(&$query, &$rows, &$readonlys)
1313 1312
 	{
1314
-		unset($readonlys);	// not used, but required by function signature
1313
+		unset($readonlys); // not used, but required by function signature
1315 1314
 
1316 1315
 		// handle possible profile change in get_rows
1317 1316
 		if (!empty($query['selectedFolder']))
1318 1317
 		{
1319
-			list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1318
+			list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1320 1319
 			if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])
1321 1320
 			{
1322 1321
 				try {
1323
-					$mail_ui = new mail_ui(false);	// do NOT run constructor, as we change profile anyway
1322
+					$mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway
1324 1323
 					$mail_ui->changeProfile($_profileID);
1325 1324
 					$query['actions'] = $mail_ui->get_actions();
1326 1325
 				}
1327
-				catch(Exception $e)
1326
+				catch (Exception $e)
1328 1327
 				{
1329 1328
 					unset($e);
1330
-					$rows=array();
1329
+					$rows = array();
1331 1330
 					return 0;
1332 1331
 				}
1333 1332
 				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
@@ -1337,12 +1336,12 @@  discard block
 block discarded – undo
1337 1336
 		{
1338 1337
 			try
1339 1338
 			{
1340
-				$mail_ui = new mail_ui(true);	// run constructor for current profile
1339
+				$mail_ui = new mail_ui(true); // run constructor for current profile
1341 1340
 			}
1342
-			catch(Exception $e)
1341
+			catch (Exception $e)
1343 1342
 			{
1344 1343
 				unset($e);
1345
-				$rows=array();
1344
+				$rows = array();
1346 1345
 				return 0;
1347 1346
 			}
1348 1347
 			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
@@ -1353,68 +1352,68 @@  discard block
 block discarded – undo
1353 1352
 		//$query['search'] is the phrase in the searchbox
1354 1353
 
1355 1354
 		$mail_ui->mail_bo->restoreSessionData();
1356
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1355
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder'];
1357 1356
 		$mail_ui->mail_bo->saveSessionData();
1358 1357
 
1359 1358
 		$sRToFetch = null;
1360
-		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
1361
-		if (strpos($_folderName,self::$delimiter)!==false)
1359
+		list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1360
+		if (strpos($_folderName, self::$delimiter) !== false)
1362 1361
 		{
1363
-			list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3);
1362
+			list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3);
1364 1363
 			unset($app);
1365 1364
 		}
1366 1365
 		//save selected Folder to sessionData (mailbox)->currentFolder
1367
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1368
-		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1366
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName;
1367
+		$toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default)
1369 1368
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1370 1369
 		{
1371
-			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false);
1370
+			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false);
1372 1371
 		}
1373 1372
 		else
1374 1373
 		{
1375 1374
 			// take the extra time on failure
1376
-			if (!$mail_ui->mail_bo->folderExists($_folderName,true))
1375
+			if (!$mail_ui->mail_bo->folderExists($_folderName, true))
1377 1376
 			{
1378 1377
 				//error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead');
1379
-				$query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX';
1378
+				$query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX';
1380 1379
 			}
1381 1380
 		}
1382 1381
 		$mail_ui->mail_bo->saveSessionData();
1383 1382
 		$rowsFetched['messages'] = null;
1384
-		$offset = $query['start']+1; // we always start with 1
1383
+		$offset = $query['start'] + 1; // we always start with 1
1385 1384
 		$maxMessages = $query['num_rows'];
1386 1385
 		//error_log(__METHOD__.__LINE__.array2string($query));
1387
-		$sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']);
1388
-		if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
1386
+		$sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']);
1387
+		if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
1389 1388
 		{
1390 1389
 			if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1391 1390
 			{
1392
-				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
1391
+				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1393 1392
 				if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1394 1393
 				{
1395
-					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
1394
+					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true;
1396 1395
 				}
1397 1396
 			}
1398 1397
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1399 1398
 			$cutoffdate = $cutoffdate2 = null;
1400
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1401
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1399
+			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
1400
+			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
1402 1401
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1403 1402
 			$filter = array(
1404
-				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
1405
-				'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
1403
+				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
1404
+				'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
1406 1405
 				'string' => $query['search'],
1407 1406
 				'status' => 'any',
1408 1407
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1409 1408
 			);
1410
-			if ($query['enddate']||$query['startdate']) {
1409
+			if ($query['enddate'] || $query['startdate']) {
1411 1410
 				$filter['range'] = "BETWEEN";
1412 1411
 				if ($cutoffdate) {
1413
-					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1412
+					$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
1414 1413
 					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1415 1414
 				}
1416 1415
 				if ($cutoffdate2) {
1417
-					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1416
+					$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
1418 1417
 					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1419 1418
 				}
1420 1419
 			}
@@ -1427,17 +1426,17 @@  discard block
 block discarded – undo
1427 1426
 		{
1428 1427
 			$filter['status'] = $query['filter'];
1429 1428
 		}
1430
-		$reverse = ($query['sort']=='ASC'?false:true);
1429
+		$reverse = ($query['sort'] == 'ASC' ? false : true);
1431 1430
 		$prefchanged = false;
1432
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1431
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1433 1432
 		{
1434 1433
 			//error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']);
1435
-			$GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user');
1434
+			$GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user');
1436 1435
 			$prefchanged = true;
1437 1436
 		}
1438
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1437
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1439 1438
 		{
1440
-			$GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user');
1439
+			$GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user');
1441 1440
 			$prefchanged = true;
1442 1441
 		}
1443 1442
 		if ($prefchanged)
@@ -1468,13 +1467,13 @@  discard block
 block discarded – undo
1468 1467
 				$rowsFetched['messages'] = $_sR['count'];
1469 1468
 				$ids = $_sR['match']->ids;
1470 1469
 				// if $sR is false, something failed fundamentally
1471
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1472
-				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1473
-				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1470
+				if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids));
1471
+				$sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids
1472
+				$sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1474 1473
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
1475 1474
 				$maxMessages = 75;
1476 1475
 				$sortResultwH['header'] = array();
1477
-				if (count($sRToFetch)>0)
1476
+				if (count($sRToFetch) > 0)
1478 1477
 				{
1479 1478
 					//error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch));
1480 1479
 					$sortResult = array();
@@ -1488,7 +1487,7 @@  discard block
 block discarded – undo
1488 1487
 						$filter,
1489 1488
 						$sRToFetch,
1490 1489
 						true, //cacheResult
1491
-						($query['filter2']?true:false) // fetchPreview
1490
+						($query['filter2'] ? true : false) // fetchPreview
1492 1491
 					);
1493 1492
 				}
1494 1493
 			}
@@ -1505,30 +1504,30 @@  discard block
 block discarded – undo
1505 1504
 					$filter,
1506 1505
 					null, // this uids only
1507 1506
 					true, // cacheResult
1508
-					($query['filter2']?true:false) // fetchPreview
1507
+					($query['filter2'] ? true : false) // fetchPreview
1509 1508
 				);
1510 1509
 				$rowsFetched['messages'] = $sortResultwH['info']['total'];
1511 1510
 			}
1512 1511
 		}
1513 1512
 		catch (Exception $e)
1514 1513
 		{
1515
-			$sortResultwH=array();
1516
-			$sR=array();
1514
+			$sortResultwH = array();
1515
+			$sR = array();
1517 1516
 			self::callWizard($e->getMessage(), false, 'error');
1518 1517
 		}
1519 1518
 		$response = Api\Json\Response::get();
1520 1519
 		// unlock immediately after fetching the rows
1521
-		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
1520
+		if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false)
1522 1521
 		{
1523 1522
 			//error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']);
1524 1523
 			$response->call('app.mail.unlock_tree');
1525 1524
 		}
1526 1525
 
1527
-		if (is_array($sR) && count($sR)>0)
1526
+		if (is_array($sR) && count($sR) > 0)
1528 1527
 		{
1529 1528
 			foreach ((array)$sR as $key => $v)
1530 1529
 			{
1531
-				if (array_key_exists($key,(array)$sortResultwH['header'])==true)
1530
+				if (array_key_exists($key, (array)$sortResultwH['header']) == true)
1532 1531
 				{
1533 1532
 					$sortResult['header'][] = $sortResultwH['header'][$key];
1534 1533
 				}
@@ -1546,12 +1545,12 @@  discard block
 block discarded – undo
1546 1545
 		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1547 1546
 
1548 1547
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1549
-		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1550
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1551
-		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1548
+		$cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview');
1549
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1550
+		$rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema);
1552 1551
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1553 1552
 
1554
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1553
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__);
1555 1554
 		return $rowsFetched['messages'];
1556 1555
 	}
1557 1556
 
@@ -1563,7 +1562,7 @@  discard block
 block discarded – undo
1563 1562
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1564 1563
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1565 1564
 	 */
1566
-	function createRowID($_folderName, $message_uid, $_prependApp=false)
1565
+	function createRowID($_folderName, $message_uid, $_prependApp = false)
1567 1566
 	{
1568 1567
 		return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp);
1569 1568
 	}
@@ -1577,9 +1576,9 @@  discard block
 block discarded – undo
1577 1576
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1578 1577
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1579 1578
 	 */
1580
-	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false)
1579
+	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false)
1581 1580
 	{
1582
-		return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1581
+		return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1583 1582
 	}
1584 1583
 
1585 1584
 	/**
@@ -1590,13 +1589,13 @@  discard block
 block discarded – undo
1590 1589
 	 */
1591 1590
 	static function splitRowID($_rowID)
1592 1591
 	{
1593
-		$res = explode(self::$delimiter,$_rowID);
1592
+		$res = explode(self::$delimiter, $_rowID);
1594 1593
 		// as a rowID is perceeded by app::, should be mail!
1595 1594
 		//error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res));
1596
-		if (count($res)==4 && is_numeric($res[0]) )
1595
+		if (count($res) == 4 && is_numeric($res[0]))
1597 1596
 		{
1598 1597
 			// we have an own created rowID; prepend app=mail
1599
-			array_unshift($res,'mail');
1598
+			array_unshift($res, 'mail');
1600 1599
 		}
1601 1600
 		return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]);
1602 1601
 	}
@@ -1610,56 +1609,56 @@  discard block
 block discarded – undo
1610 1609
 	{
1611 1610
 		$actions = $this->get_actions();
1612 1611
 		$arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print',
1613
-			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1',	'label2', 'label3',	'label4', 'label5');
1614
-		foreach( $arrActions as &$act)
1612
+			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5');
1613
+		foreach ($arrActions as &$act)
1615 1614
 		{
1616 1615
 			//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
1617 1616
 			switch ($act)
1618 1617
 			{
1619 1618
 				case 'forward':
1620
-					$actionsenabled[$act]=$actions[$act];
1619
+					$actionsenabled[$act] = $actions[$act];
1621 1620
 					break;
1622 1621
 				case 'save':
1623
-					$actionsenabled[$act]=$actions[$act];
1622
+					$actionsenabled[$act] = $actions[$act];
1624 1623
 
1625 1624
 					break;
1626 1625
 				case 'view':
1627
-					$actionsenabled[$act]=$actions[$act];
1626
+					$actionsenabled[$act] = $actions[$act];
1628 1627
 					break;
1629 1628
 				case 'flagged':
1630
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1629
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1631 1630
 					break;
1632 1631
 				case 'read':
1633
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1632
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1634 1633
 					break;
1635 1634
 				case 'label1':
1636 1635
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important');
1637
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1636
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1638 1637
 					break;
1639 1638
 				case 'label2':
1640 1639
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job');
1641
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1640
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1642 1641
 					break;
1643 1642
 				case 'label3':
1644 1643
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal');
1645
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1644
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1646 1645
 					break;
1647 1646
 				case 'label4':
1648 1647
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do');
1649
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1648
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1650 1649
 					break;
1651 1650
 				case 'label5':
1652 1651
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later');
1653
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1652
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1654 1653
 					break;
1655 1654
 				default:
1656
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1655
+					if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act];
1657 1656
 			}
1658 1657
 		}
1659 1658
 		unset($actionsenabled['drag_mail']);
1660 1659
 		//error_log(array2string($actionsenabled['view']));
1661
-		unset($actionsenabled['view']['children']['openastext']);//not supported in preview
1662
-		unset($actionsenabled['view']['children']['openashtml']);//not supported in preview
1660
+		unset($actionsenabled['view']['children']['openastext']); //not supported in preview
1661
+		unset($actionsenabled['view']['children']['openashtml']); //not supported in preview
1663 1662
 
1664 1663
 		return $actionsenabled;
1665 1664
 	}
@@ -1673,45 +1672,45 @@  discard block
 block discarded – undo
1673 1672
 	 * @param array $_folderType used to determine if we need to populate from/to
1674 1673
 	 * @return array populated result array
1675 1674
 	 */
1676
-	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1675
+	public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0)
1677 1676
 	{
1678 1677
 		if (Mail::$debugTimes) $starttime = microtime(true);
1679 1678
 		$rv = array();
1680
-		$i=0;
1681
-		foreach((array)$_headers as $header)
1679
+		$i = 0;
1680
+		foreach ((array)$_headers as $header)
1682 1681
 		{
1683 1682
 			$i++;
1684 1683
 			$data = array();
1685 1684
 			//error_log(__METHOD__.array2string($header));
1686 1685
 			$message_uid = $header['uid'];
1687 1686
 			$data['uid'] = $message_uid;
1688
-			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1687
+			$data['row_id'] = $this->createRowID($_folderName, $message_uid);
1689 1688
 
1690 1689
 			$flags = "";
1691
-			if(!empty($header['recent'])) $flags .= "R";
1692
-			if(!empty($header['flagged'])) $flags .= "F";
1693
-			if(!empty($header['answered'])) $flags .= "A";
1694
-			if(!empty($header['forwarded'])) $flags .= "W";
1695
-			if(!empty($header['deleted'])) $flags .= "D";
1696
-			if(!empty($header['seen'])) $flags .= "S";
1697
-			if(!empty($header['label1'])) $flags .= "1";
1698
-			if(!empty($header['label2'])) $flags .= "2";
1699
-			if(!empty($header['label3'])) $flags .= "3";
1700
-			if(!empty($header['label4'])) $flags .= "4";
1701
-			if(!empty($header['label5'])) $flags .= "5";
1690
+			if (!empty($header['recent'])) $flags .= "R";
1691
+			if (!empty($header['flagged'])) $flags .= "F";
1692
+			if (!empty($header['answered'])) $flags .= "A";
1693
+			if (!empty($header['forwarded'])) $flags .= "W";
1694
+			if (!empty($header['deleted'])) $flags .= "D";
1695
+			if (!empty($header['seen'])) $flags .= "S";
1696
+			if (!empty($header['label1'])) $flags .= "1";
1697
+			if (!empty($header['label2'])) $flags .= "2";
1698
+			if (!empty($header['label3'])) $flags .= "3";
1699
+			if (!empty($header['label4'])) $flags .= "4";
1700
+			if (!empty($header['label5'])) $flags .= "5";
1702 1701
 
1703 1702
 			$data["status"] = "<span class=\"status_img\"></span>";
1704 1703
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
1705 1704
 
1706 1705
 			// the css for this row
1707
-			$is_recent=false;
1706
+			$is_recent = false;
1708 1707
 			$css_styles = array("mail");
1709 1708
 			if ($header['deleted']) {
1710 1709
 				$css_styles[] = 'deleted';
1711 1710
 			}
1712 1711
 			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1713 1712
 				$css_styles[] = 'recent';
1714
-				$is_recent=true;
1713
+				$is_recent = true;
1715 1714
 			}
1716 1715
 			if ($header['priority'] < 3) {
1717 1716
 				$css_styles[] = 'prio_high';
@@ -1749,19 +1748,19 @@  discard block
 block discarded – undo
1749 1748
 			if (in_array("subject", $cols))
1750 1749
 			{
1751 1750
 				// filter out undisplayable characters
1752
-				$search = array('[\016]','[\017]',
1753
-					'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1754
-					'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1751
+				$search = array('[\016]', '[\017]',
1752
+					'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1753
+					'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1755 1754
 				$replace = '';
1756 1755
 
1757
-				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1756
+				$header['subject'] = preg_replace($search, $replace, $header['subject']);
1758 1757
 				// curly brackets get messed up by the template!
1759 1758
 
1760 1759
 				if (!empty($header['subject'])) {
1761 1760
 					// make the subject shorter if it is to long
1762 1761
 					$subject = $header['subject'];
1763 1762
 				} else {
1764
-					$subject = '('. lang('no subject') .')';
1763
+					$subject = '('.lang('no subject').')';
1765 1764
 				}
1766 1765
 
1767 1766
 				$data["subject"] = $subject; // the mailsubject
@@ -1771,53 +1770,53 @@  discard block
 block discarded – undo
1771 1770
 			//error_log(__METHOD__.__LINE__.array2string($header));
1772 1771
 			if (in_array("attachments", $cols))
1773 1772
 			{
1774
-				if($header['mimetype'] == 'multipart/mixed' ||
1773
+				if ($header['mimetype'] == 'multipart/mixed' ||
1775 1774
 					$header['mimetype'] == 'multipart/signed' ||
1776 1775
 					$header['mimetype'] == 'multipart/related' ||
1777 1776
 					$header['mimetype'] == 'multipart/report' ||
1778 1777
 					$header['mimetype'] == 'text/calendar' ||
1779 1778
 					$header['mimetype'] == 'text/html' ||
1780
-					substr($header['mimetype'],0,11) == 'application' ||
1781
-					substr($header['mimetype'],0,5) == 'audio' ||
1782
-					substr($header['mimetype'],0,5) == 'video' ||
1779
+					substr($header['mimetype'], 0, 11) == 'application' ||
1780
+					substr($header['mimetype'], 0, 5) == 'audio' ||
1781
+					substr($header['mimetype'], 0, 5) == 'video' ||
1783 1782
 					$header['mimetype'] == 'multipart/alternative')
1784 1783
 				{
1785
-					$image = Api\Html::image('mail','attach');
1784
+					$image = Api\Html::image('mail', 'attach');
1786 1785
 					$imageHTMLBlock = '';
1787
-					$datarowid = $this->createRowID($_folderName,$message_uid,true);
1786
+					$datarowid = $this->createRowID($_folderName, $message_uid, true);
1788 1787
 					$attachments = $header['attachments'];
1789
-					if (count($attachments)<1)
1788
+					if (count($attachments) < 1)
1790 1789
 					{
1791 1790
 						$image = '&nbsp;';
1792 1791
 					}
1793
-					if (count($attachments)==1)
1792
+					if (count($attachments) == 1)
1794 1793
 					{
1795
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1796
-						$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
1794
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1795
+						$image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : ''));
1797 1796
 					}
1798
-					if (count($attachments)>1)
1797
+					if (count($attachments) > 1)
1799 1798
 					{
1800
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1801
-						$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
1799
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1800
+						$image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments)));
1802 1801
 					}
1803 1802
 
1804 1803
 					$attachmentFlag = $image;
1805 1804
 				} else {
1806
-					$attachmentFlag ='&nbsp;';
1805
+					$attachmentFlag = '&nbsp;';
1807 1806
 				}
1808 1807
 				// show priority flag
1809 1808
 				if ($header['priority'] < 3) {
1810
-					 $image = Api\Html::image('mail','prio_high');
1809
+					 $image = Api\Html::image('mail', 'prio_high');
1811 1810
 				} elseif ($header['priority'] > 3) {
1812
-					$image = Api\Html::image('mail','prio_low');
1811
+					$image = Api\Html::image('mail', 'prio_low');
1813 1812
 				} else {
1814 1813
 					$image = '';
1815 1814
 				}
1816 1815
 				// show a flag for flagged messages
1817
-				$imageflagged ='';
1816
+				$imageflagged = '';
1818 1817
 				if ($header['flagged'])
1819 1818
 				{
1820
-					$imageflagged = Api\Html::image('mail','unread_flagged_small');
1819
+					$imageflagged = Api\Html::image('mail', 'unread_flagged_small');
1821 1820
 				}
1822 1821
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
1823 1822
 			}
@@ -1826,7 +1825,7 @@  discard block
 block discarded – undo
1826 1825
 			if (in_array("toaddress", $cols))
1827 1826
 			{
1828 1827
 				// sent or drafts or template folder means foldertype > 0, use to address instead of from
1829
-				$data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset);
1828
+				$data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset);
1830 1829
 			}
1831 1830
 
1832 1831
 			if (in_array("additionaltoaddress", $cols))
@@ -1859,29 +1858,29 @@  discard block
 block discarded – undo
1859 1858
 			$data['flags'] = Array();
1860 1859
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1861 1860
 			foreach ($css_styles as &$flag) {
1862
-				if ($flag!='mail')
1861
+				if ($flag != 'mail')
1863 1862
 				{
1864
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1865
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1866
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1867
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1868
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1869
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1863
+					if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; }
1864
+					elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; }
1865
+					elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; }
1866
+					elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; }
1867
+					elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; }
1868
+					elseif ($flag == 'unseen') {unset($data["flags"]['read']); }
1870 1869
 					else $data["flags"][$flag] = $flag;
1871 1870
 				}
1872 1871
 			}
1873 1872
 			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1874
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1873
+			if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1875 1874
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1876
-			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1877
-			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
1875
+			$data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]);
1876
+			if (in_array("bodypreview", $cols) && $header['bodypreview'])
1878 1877
 			{
1879 1878
 				$data["bodypreview"] = $header['bodypreview'];
1880 1879
 			}
1881 1880
 			$rv[] = $data;
1882 1881
 			//error_log(__METHOD__.__LINE__.array2string($data));
1883 1882
 		}
1884
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
1883
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__);
1885 1884
 
1886 1885
 		// ToDo: call this ONLY if labels change
1887 1886
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1896,8 +1895,8 @@  discard block
 block discarded – undo
1896 1895
 	 */
1897 1896
 	function displayHeader()
1898 1897
 	{
1899
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1900
-		if(isset($_GET['part'])) $partID = $_GET['part'];
1898
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
1899
+		if (isset($_GET['part'])) $partID = $_GET['part'];
1901 1900
 
1902 1901
 		$hA = self::splitRowID($rowID);
1903 1902
 		$uid = $hA['msgUID'];
@@ -1911,17 +1910,17 @@  discard block
 block discarded – undo
1911 1910
 		}
1912 1911
 
1913 1912
 		$this->mail_bo->reopen($mailbox);
1914
-		$headers_in	= $this->mail_bo->getMessageRawHeader($uid, $partID);
1913
+		$headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID);
1915 1914
 
1916 1915
 		// add line breaks to $rawheaders
1917
-		$newRawHeaders = explode("\n",$headers_in);
1916
+		$newRawHeaders = explode("\n", $headers_in);
1918 1917
 		reset($newRawHeaders);
1919 1918
 
1920 1919
 		// reset $rawheaders
1921
-		$rawheaders 	= "";
1920
+		$rawheaders = "";
1922 1921
 		// create it new, with good line breaks
1923 1922
 		reset($newRawHeaders);
1924
-		while(list($key,$value) = @each($newRawHeaders)) {
1923
+		while (list($key, $value) = @each($newRawHeaders)) {
1925 1924
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1926 1925
 		}
1927 1926
 
@@ -1933,7 +1932,7 @@  discard block
 block discarded – undo
1933 1932
 		}
1934 1933
 
1935 1934
 		header('Content-type: text/html; charset=iso-8859-1');
1936
-		print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
1935
+		print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>';
1937 1936
 
1938 1937
 	}
1939 1938
 
@@ -1946,10 +1945,10 @@  discard block
 block discarded – undo
1946 1945
 	{
1947 1946
 		if (is_null($_requesteddata)) $_requesteddata = $_GET;
1948 1947
 
1949
-		$preventRedirect=false;
1950
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1951
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1952
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
1948
+		$preventRedirect = false;
1949
+		if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id'];
1950
+		if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null;
1951
+		if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false);
1953 1952
 
1954 1953
 		$hA = self::splitRowID($rowID);
1955 1954
 		$uid = $hA['msgUID'];
@@ -1973,79 +1972,79 @@  discard block
 block discarded – undo
1973 1972
 		}
1974 1973
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
1975 1974
 		{
1976
-			Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
1975
+			Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft'));
1977 1976
 		}
1978 1977
 		$this->mail_bo->reopen($mailbox);
1979 1978
 		// retrieve the flags of the message, before touching it.
1980 1979
 		try
1981 1980
 		{
1982
-			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
1981
+			$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox);
1983 1982
 		}
1984 1983
 		catch (Api\Exception $e)
1985 1984
 		{
1986 1985
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
1987
-			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1986
+			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID);
1988 1987
 			Framework::message($e->getMessage(), 'error');
1989 1988
 		}
1990 1989
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
1991
-		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1990
+		$envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox);
1992 1991
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1993
-		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1992
+		$this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox);
1994 1993
 		$fetchEmbeddedImages = false;
1995 1994
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1996 1995
 		// we do NOT want to see those, that are embedded in the list of attachments
1997
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
1998
-		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1996
+		if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true;
1997
+		$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox);
1999 1998
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2000 1999
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
2001 2000
 
2002
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2003
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2004
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2001
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2002
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2003
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2005 2004
 
2006 2005
 		//error_log(__METHOD__.__LINE__.$mailBody);
2007 2006
 		$this->mail_bo->closeConnection();
2008 2007
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
2009 2008
 		$etpl = new Etemplate('mail.display');
2010
-		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2009
+		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false);
2011 2010
 
2012 2011
 		// Set up data for taglist widget(s)
2013
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2012
+		if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']);
2014 2013
 		$sel_options = array();
2015
-		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2014
+		foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field)
2016 2015
 		{
2017 2016
 			if (!isset($envelope[$field])) continue;
2018
-			foreach($envelope[$field] as $field_data)
2017
+			foreach ($envelope[$field] as $field_data)
2019 2018
 			{
2020 2019
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
2021 2020
 				$content[$field][] = $field_data;
2022 2021
 				$sel_options[$field][] = array(
2023 2022
 					// taglist requires these - not optional
2024 2023
 					'id' => $field_data,
2025
-					'label' => str_replace('"',"'",$field_data),
2024
+					'label' => str_replace('"', "'", $field_data),
2026 2025
 				);
2027 2026
 			}
2028 2027
 		}
2029 2028
 		$actionsenabled = $this->getDisplayToolbarActions();
2030 2029
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2031 2030
 		if (empty($subject)) $subject = lang('no subject');
2032
-		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2031
+		$content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg);
2033 2032
 		// Send mail ID so we can use it for actions
2034 2033
 		$content['mail_id'] = $rowID;
2035 2034
 		if (!is_array($headers) || !isset($headers['DATE']))
2036 2035
 		{
2037
-			$headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:'');
2036
+			$headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : '');
2038 2037
 		}
2039
-		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2038
+		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true);
2040 2039
 		$content['mail_displaysubject'] = $subject;
2041
-		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2042
-		if (!empty($partID)) $linkData['_partID']=$partID;
2043
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2044
-		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2040
+		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID);
2041
+		if (!empty($partID)) $linkData['_partID'] = $partID;
2042
+		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions;
2043
+		$content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData);
2045 2044
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2046
-		$content['mail_id']=$rowID;
2047
-		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
2048
-		$content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone");
2045
+		$content['mail_id'] = $rowID;
2046
+		$content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight");
2047
+		$content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone");
2049 2048
 
2050 2049
 		// DRAG attachments actions
2051 2050
 		$etpl->setElementAttribute('mail_displayattachments', 'actions', array(
@@ -2062,22 +2061,22 @@  discard block
 block discarded – undo
2062 2061
 			$this->changeProfile($rememberServerID);
2063 2062
 		}
2064 2063
 
2065
-		$etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
2064
+		$etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2);
2066 2065
 	}
2067 2066
 
2068 2067
 	/**
2069 2068
 	 * Build actions for display toolbar
2070 2069
 	 */
2071
-	function getDisplayToolbarActions ()
2070
+	function getDisplayToolbarActions()
2072 2071
 	{
2073 2072
 		$actions = $this->get_toolbar_actions();
2074
-		$actions['mark']['children']['flagged']=array(
2073
+		$actions['mark']['children']['flagged'] = array(
2075 2074
 			'group' => $actions['mark']['children']['flagged']['group'],
2076 2075
 			'caption' => 'Flagged',
2077 2076
 			'icon' => 'unread_flagged_small',
2078 2077
 			'onExecute' => 'javaScript:app.mail.mail_flag',
2079 2078
 		);
2080
-		$actions['mark']['children']['unflagged']=array(
2079
+		$actions['mark']['children']['unflagged'] = array(
2081 2080
 			'group' => $actions['mark']['children']['flagged']['group'],
2082 2081
 			'caption' => 'Unflagged',
2083 2082
 			'icon' => 'read_flagged_small',
@@ -2089,9 +2088,9 @@  discard block
 block discarded – undo
2089 2088
 		$compose = $actions['composeasnew'];
2090 2089
 		unset($actions['composeasnew']);
2091 2090
 
2092
-		$actions2 = array_reverse($actions,true);
2093
-		$actions2['composeasnew']= $compose;
2094
-		return array_reverse($actions2,true);
2091
+		$actions2 = array_reverse($actions, true);
2092
+		$actions2['composeasnew'] = $compose;
2093
+		return array_reverse($actions2, true);
2095 2094
 	}
2096 2095
 
2097 2096
 	/**
@@ -2104,22 +2103,22 @@  discard block
 block discarded – undo
2104 2103
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
2105 2104
 	 * @return array|string data array or html or empty string
2106 2105
 	 */
2107
-	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
2106
+	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false)
2108 2107
 	{
2109
-		$attachmentHTMLBlock='';
2108
+		$attachmentHTMLBlock = '';
2110 2109
 		$attachmentHTML = array();
2111 2110
 		if (is_array($attachments) && count($attachments) > 0) {
2112
-			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2113
-			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2111
+			$url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"');
2112
+			$url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all'));
2114 2113
 
2115 2114
 			foreach ($attachments as $key => $value)
2116 2115
 			{
2117
-				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
2118
-				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2116
+				$attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)'));
2117
+				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8');
2119 2118
 				//error_log(array2string($value));
2120 2119
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2121
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2122
-				$attachmentHTML[$key]['type']=$value['mimeType'];
2120
+				if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2121
+				$attachmentHTML[$key]['type'] = $value['mimeType'];
2123 2122
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2124 2123
 				$hA = self::splitRowID($rowID);
2125 2124
 				$uid = $hA['msgUID'];
@@ -2129,26 +2128,25 @@  discard block
 block discarded – undo
2129 2128
 				$attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
2130 2129
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
2131 2130
 				));
2132
-				$attachmentHTML[$key]['size']=Vfs::hsize($value['size']);
2133
-				$attachmentHTML[$key]['attachment_number']=$key;
2134
-				$attachmentHTML[$key]['partID']=$value['partID'];
2131
+				$attachmentHTML[$key]['size'] = Vfs::hsize($value['size']);
2132
+				$attachmentHTML[$key]['attachment_number'] = $key;
2133
+				$attachmentHTML[$key]['partID'] = $value['partID'];
2135 2134
 				$attachmentHTML[$key]['mail_id'] = $rowID;
2136
-				$attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
2135
+				$attachmentHTML[$key]['winmailFlag'] = $value['is_winmail'];
2137 2136
 				$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
2138 2137
 
2139
-				switch(strtoupper($value['mimeType']))
2138
+				switch (strtoupper($value['mimeType']))
2140 2139
 				{
2141 2140
 					case 'MESSAGE/RFC822':
2142
-						$linkData = array
2143
-						(
2141
+						$linkData = array(
2144 2142
 							'menuaction'	=> 'mail.mail_ui.displayMessage',
2145 2143
 							'mode'		=> 'display', //message/rfc822 attachments should be opened in display mode
2146 2144
 							'id'		=> $rowID,
2147 2145
 							'part'		=> $value['partID'],
2148 2146
 							'is_winmail'    => $value['is_winmail']
2149 2147
 						);
2150
-						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
2151
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2148
+						$windowName = 'displayMessage_'.$rowID.'_'.$value['partID'];
2149
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2152 2150
 						break;
2153 2151
 					case 'IMAGE/JPEG':
2154 2152
 					case 'IMAGE/PNG':
@@ -2159,7 +2157,7 @@  discard block
 block discarded – undo
2159 2157
 					case 'TEXT/HTML':
2160 2158
 					case 'TEXT/DIRECTORY':
2161 2159
 						$sfxMimeType = $value['mimeType'];
2162
-						$buff = explode('.',$value['name']);
2160
+						$buff = explode('.', $value['name']);
2163 2161
 						$suffix = '';
2164 2162
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2165 2163
 						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2172,49 +2170,47 @@  discard block
 block discarded – undo
2172 2170
 					case 'TEXT/VCARD':
2173 2171
 					case 'TEXT/CALENDAR':
2174 2172
 					case 'TEXT/X-VCALENDAR':
2175
-						$linkData = array
2176
-						(
2173
+						$linkData = array(
2177 2174
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2178 2175
 							'id'		=> $rowID,
2179 2176
 							'part'		=> $value['partID'],
2180 2177
 							'is_winmail'    => $value['is_winmail'],
2181 2178
 							'mailbox'   => base64_encode($mailbox),
2182 2179
 						);
2183
-						$windowName = 'displayAttachment_'. $uid;
2180
+						$windowName = 'displayAttachment_'.$uid;
2184 2181
 						$reg = '800x600';
2185 2182
 						// handle calendar/vcard
2186
-						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
2183
+						if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR')
2187 2184
 						{
2188
-							$windowName = 'displayEvent_'. $rowID;
2189
-							$reg2 = Link::get_registry('calendar','view_popup');
2190
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2185
+							$windowName = 'displayEvent_'.$rowID;
2186
+							$reg2 = Link::get_registry('calendar', 'view_popup');
2187
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2191 2188
 						}
2192
-						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
2189
+						if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD')
2193 2190
 						{
2194
-							$windowName = 'displayContact_'. $rowID;
2195
-							$reg2 = Link::get_registry('addressbook','add_popup');
2196
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2191
+							$windowName = 'displayContact_'.$rowID;
2192
+							$reg2 = Link::get_registry('addressbook', 'add_popup');
2193
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2197 2194
 						}
2198 2195
 						// apply to action
2199
-						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
2200
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
2196
+						list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg));
2197
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);";
2201 2198
 						break;
2202 2199
 					default:
2203
-						$linkData = array
2204
-						(
2200
+						$linkData = array(
2205 2201
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2206 2202
 							'id'		=> $rowID,
2207 2203
 							'part'		=> $value['partID'],
2208 2204
 							'is_winmail'    => $value['is_winmail'],
2209 2205
 							'mailbox'   => base64_encode($mailbox),
2210 2206
 						);
2211
-						$linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';";
2207
+						$linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';";
2212 2208
 						break;
2213 2209
 				}
2214 2210
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
2215 2211
 				if (empty($attachmentHTML[$key]['mime_data']))
2216 2212
 				{
2217
-					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData);
2213
+					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData);
2218 2214
 					unset($attachmentHTML[$key]['mime_data']);
2219 2215
 				}
2220 2216
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2224,8 +2220,7 @@  discard block
 block discarded – undo
2224 2220
 					($value['name'] ? $value['name'] : lang('(no subject)')).
2225 2221
 					'</b></a>';
2226 2222
 
2227
-				$linkData = array
2228
-				(
2223
+				$linkData = array(
2229 2224
 					'menuaction'	=> 'mail.mail_ui.getAttachment',
2230 2225
 					'mode'		=> 'save',
2231 2226
 					'id'		=> $rowID,
@@ -2233,11 +2228,11 @@  discard block
 block discarded – undo
2233 2228
 					'is_winmail'    => $value['is_winmail'],
2234 2229
 					'mailbox'   => base64_encode($mailbox),
2235 2230
 				);
2236
-				$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
2231
+				$attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>";
2237 2232
 
2238 2233
 				if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
2239 2234
 				{
2240
-					$link_vfs_save = Egw::link('/index.php',array(
2235
+					$link_vfs_save = Egw::link('/index.php', array(
2241 2236
 						'menuaction' => 'filemanager.filemanager_select.select',
2242 2237
 						'mode' => 'saveas',
2243 2238
 						'name' => $value['name'],
@@ -2256,19 +2251,19 @@  discard block
 block discarded – undo
2256 2251
 							//$rowID
2257 2252
 							$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
2258 2253
 						}
2259
-						$link_vfs_save = Egw::link('/index.php',array(
2254
+						$link_vfs_save = Egw::link('/index.php', array(
2260 2255
 							'menuaction' => 'filemanager.filemanager_select.select',
2261 2256
 							'mode' => 'select-dir',
2262 2257
 							'method' => 'mail.mail_ui.vfsSaveAttachment',
2263 2258
 							'label' => lang('Save all'),
2264
-						)+$ids);
2259
+						) + $ids);
2265 2260
 						$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>";
2266 2261
 					}
2267 2262
 					$attachmentHTML[$key]['link_save'] .= $vfs_save;
2268 2263
 					//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
2269 2264
 				}
2270 2265
 			}
2271
-			$attachmentHTMLBlock="<table width='100%'>";
2266
+			$attachmentHTMLBlock = "<table width='100%'>";
2272 2267
 			foreach ((array)$attachmentHTML as $row)
2273 2268
 			{
2274 2269
 				$attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>';
@@ -2286,7 +2281,7 @@  discard block
 block discarded – undo
2286 2281
 				unset($attachmentHTML[$ikey]['link_save']);
2287 2282
 			}
2288 2283
 		}
2289
-		return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML);
2284
+		return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML);
2290 2285
 	}
2291 2286
 
2292 2287
 	/**
@@ -2297,7 +2292,7 @@  discard block
 block discarded – undo
2297 2292
 	 */
2298 2293
 	function gatherVacation($cachedVacations = array())
2299 2294
 	{
2300
-		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host);
2295
+		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host);
2301 2296
 		//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
2302 2297
 
2303 2298
 		if ($isVacationEnabled)
@@ -2310,7 +2305,7 @@  discard block
 block discarded – undo
2310 2305
 
2311 2306
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
2312 2307
 				// Set vacation to the instance cache for particular account with expiration of one day
2313
-				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
2308
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24);
2314 2309
 			}
2315 2310
 			catch (PEAR_Exception $ex)
2316 2311
 			{
@@ -2331,36 +2326,36 @@  discard block
 block discarded – undo
2331 2326
 	function quotaDisplay($_usage, $_limit)
2332 2327
 	{
2333 2328
 
2334
-		if($_limit == 0) {
2335
-			$quotaPercent=100;
2329
+		if ($_limit == 0) {
2330
+			$quotaPercent = 100;
2336 2331
 		} else {
2337
-			$quotaPercent=round(($_usage*100)/$_limit);
2332
+			$quotaPercent = round(($_usage * 100) / $_limit);
2338 2333
 		}
2339 2334
 
2340
-		$quotaLimit=Mail::show_readable_size($_limit*1024);
2341
-		$quotaUsage=Mail::show_readable_size($_usage*1024);
2335
+		$quotaLimit = Mail::show_readable_size($_limit * 1024);
2336
+		$quotaUsage = Mail::show_readable_size($_usage * 1024);
2342 2337
 
2343 2338
 
2344
-		if($quotaPercent > 90 && $_limit>0) {
2345
-			$quotaBG='mail-index_QuotaRed';
2346
-		} elseif($quotaPercent > 80 && $_limit>0) {
2347
-			$quotaBG='mail-index_QuotaYellow';
2339
+		if ($quotaPercent > 90 && $_limit > 0) {
2340
+			$quotaBG = 'mail-index_QuotaRed';
2341
+		} elseif ($quotaPercent > 80 && $_limit > 0) {
2342
+			$quotaBG = 'mail-index_QuotaYellow';
2348 2343
 		} else {
2349
-			$quotaBG='mail-index_QuotaGreen';
2344
+			$quotaBG = 'mail-index_QuotaGreen';
2350 2345
 		}
2351 2346
 
2352
-		if($_limit > 0) {
2353
-			$quotaText = $quotaUsage .'/'.$quotaLimit;
2347
+		if ($_limit > 0) {
2348
+			$quotaText = $quotaUsage.'/'.$quotaLimit;
2354 2349
 		} else {
2355 2350
 			$quotaText = $quotaUsage;
2356 2351
 		}
2357 2352
 
2358
-		if($quotaPercent > 50) {
2353
+		if ($quotaPercent > 50) {
2359 2354
 		} else {
2360 2355
 		}
2361 2356
 		$quota['class'] = $quotaBG;
2362
-		$quota['text'] = lang('Quota: %1',$quotaText);
2363
-		$quota['percent'] = (string)round(($_usage*100)/$_limit);
2357
+		$quota['text'] = lang('Quota: %1', $quotaText);
2358
+		$quota['percent'] = (string)round(($_usage * 100) / $_limit);
2364 2359
 		return $quota;
2365 2360
 	}
2366 2361
 
@@ -2374,12 +2369,12 @@  discard block
 block discarded – undo
2374 2369
 		$uid	= $_GET['uid'];
2375 2370
 		$cid	= base64_decode($_GET['cid']);
2376 2371
 		$partID = urldecode($_GET['partID']);
2377
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2372
+		if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']);
2378 2373
 
2379 2374
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2380 2375
 		$this->mail_bo->reopen($mailbox);
2381 2376
 
2382
-		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true);	// true get contents as stream
2377
+		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream
2383 2378
 
2384 2379
 		$this->mail_bo->closeConnection();
2385 2380
 
@@ -2387,8 +2382,8 @@  discard block
 block discarded – undo
2387 2382
 
2388 2383
 		if ($attachment)
2389 2384
 		{
2390
-			header("Content-Type: ". $attachment->getType());
2391
-			header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"');
2385
+			header("Content-Type: ".$attachment->getType());
2386
+			header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"');
2392 2387
 			//header("Expires: 0");
2393 2388
 			// the next headers are for IE and SSL
2394 2389
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -2406,7 +2401,7 @@  discard block
 block discarded – undo
2406 2401
 
2407 2402
 	function getAttachment()
2408 2403
 	{
2409
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2404
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2410 2405
 
2411 2406
 		$hA = self::splitRowID($rowID);
2412 2407
 		$uid = $hA['msgUID'];
@@ -2418,11 +2413,11 @@  discard block
 block discarded – undo
2418 2413
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2419 2414
 			$this->changeProfile($icServerID);
2420 2415
 		}
2421
-		$part		= $_GET['part'];
2416
+		$part = $_GET['part'];
2422 2417
 		$is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0;
2423 2418
 
2424 2419
 		$this->mail_bo->reopen($mailbox);
2425
-		$attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false);
2420
+		$attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false);
2426 2421
 		$this->mail_bo->closeConnection();
2427 2422
 		if ($rememberServerID != $this->mail_bo->profileID)
2428 2423
 		{
@@ -2437,7 +2432,7 @@  discard block
 block discarded – undo
2437 2432
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type']))
2438 2433
 			{
2439 2434
 				$sfxMimeType = $attachment['type'];
2440
-				$buff = explode('.',$attachment['filename']);
2435
+				$buff = explode('.', $attachment['filename']);
2441 2436
 				$suffix = '';
2442 2437
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2443 2438
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2449,10 +2444,10 @@  discard block
 block discarded – undo
2449 2444
 			{
2450 2445
 				//error_log(__METHOD__."about to call calendar_ical");
2451 2446
 				$calendar_ical = new calendar_ical();
2452
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2447
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2453 2448
 				//error_log(__METHOD__.array2string($eventid));
2454 2449
 				if (!$eventid) $eventid = -1;
2455
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2450
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']);
2456 2451
 				//error_log(__METHOD__.$event);
2457 2452
 				if ((int)$event > 0)
2458 2453
 				{
@@ -2460,7 +2455,7 @@  discard block
 block discarded – undo
2460 2455
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2461 2456
 						'cal_id'      => $event,
2462 2457
 					);
2463
-					Egw::redirect_link('../index.php',$vars);
2458
+					Egw::redirect_link('../index.php', $vars);
2464 2459
 				}
2465 2460
 				//Import failed, download content anyway
2466 2461
 			}
@@ -2475,13 +2470,13 @@  discard block
 block discarded – undo
2475 2470
 				{
2476 2471
 					$vcard['uid'] = trim($vcard['uid']);
2477 2472
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2478
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2473
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2479 2474
 				}
2480 2475
 				if (!$contact) $contact = null;
2481 2476
 				// if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO))
2482
-				if ($contact || count($vcard)>2)
2477
+				if ($contact || count($vcard) > 2)
2483 2478
 				{
2484
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2479
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']);
2485 2480
 				}
2486 2481
 				if ((int)$contact > 0)
2487 2482
 				{
@@ -2489,14 +2484,14 @@  discard block
 block discarded – undo
2489 2484
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2490 2485
 						'contact_id'	=> $contact,
2491 2486
 					);
2492
-					Egw::redirect_link('../index.php',$vars);
2487
+					Egw::redirect_link('../index.php', $vars);
2493 2488
 				}
2494 2489
 				//Import failed, download content anyway
2495 2490
 			}
2496 2491
 		}
2497 2492
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2498
-		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
2499
-		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
2493
+		$filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part));
2494
+		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save");
2500 2495
 		echo $attachment['attachment'];
2501 2496
 
2502 2497
 		exit();
@@ -2511,9 +2506,9 @@  discard block
 block discarded – undo
2511 2506
 	function saveMessage()
2512 2507
 	{
2513 2508
 		$display = false;
2514
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2515
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2516
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2509
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2510
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2511
+		if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location'];
2517 2512
 
2518 2513
 		$hA = self::splitRowID($rowID);
2519 2514
 		$uid = $hA['msgUID'];
@@ -2541,14 +2536,14 @@  discard block
 block discarded – undo
2541 2536
 		if (!$display)
2542 2537
 		{
2543 2538
 			$headers = Horde_Mime_Headers::parseHeaders($message);
2544
-			$subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT']));
2545
-			Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
2539
+			$subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT']));
2540
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true);
2546 2541
 			echo $message;
2547 2542
 		}
2548 2543
 		else
2549 2544
 		{
2550
-			Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false);
2551
-			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
2545
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false);
2546
+			print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>';
2552 2547
 		}
2553 2548
 	}
2554 2549
 
@@ -2560,18 +2555,18 @@  discard block
 block discarded – undo
2560 2555
 	 * @param boolean $close Return javascript to close the window
2561 2556
 	 * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
2562 2557
 	 */
2563
-	function vfsSaveMessage($ids,$path, $close = true)
2558
+	function vfsSaveMessage($ids, $path, $close = true)
2564 2559
 	{
2565 2560
 		//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
2566 2561
 
2567 2562
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2568 2563
 		{
2569
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2564
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2570 2565
 		}
2571 2566
 		Api\Translation::add_app('mail');
2572 2567
 
2573 2568
 		$rememberServerID = $this->mail_bo->profileID;
2574
-		foreach((array)$ids as $id)
2569
+		foreach ((array)$ids as $id)
2575 2570
 		{
2576 2571
 			$hA = self::splitRowID($id);
2577 2572
 			$uid = $hA['msgUID'];
@@ -2582,20 +2577,20 @@  discard block
 block discarded – undo
2582 2577
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2583 2578
 				$this->changeProfile($icServerID);
2584 2579
 			}
2585
-			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
2586
-			$err=null;
2587
-			if(Vfs::is_dir($path))
2580
+			$message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox);
2581
+			$err = null;
2582
+			if (Vfs::is_dir($path))
2588 2583
 			{
2589
-				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
2590
-				$file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml';
2584
+				$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2585
+				$file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml';
2591 2586
 			}
2592 2587
 			else
2593 2588
 			{
2594 2589
 				$file = $path;
2595 2590
 			}
2596
-			if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message))
2591
+			if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message))
2597 2592
 			{
2598
-				$err .= lang('Error saving %1!',$file);
2593
+				$err .= lang('Error saving %1!', $file);
2599 2594
 				$succeeded = false;
2600 2595
 			}
2601 2596
 			else
@@ -2605,10 +2600,10 @@  discard block
 block discarded – undo
2605 2600
 			if ($fp) fclose($fp);
2606 2601
 			if ($succeeded)
2607 2602
 			{
2608
-				unset($headers['SUBJECT']);//already in filename
2603
+				unset($headers['SUBJECT']); //already in filename
2609 2604
 				$infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false);
2610
-				$props = array(array('name' => 'comment','val' => $infoSection));
2611
-				Vfs::proppatch($file,$props);
2605
+				$props = array(array('name' => 'comment', 'val' => $infoSection));
2606
+				Vfs::proppatch($file, $props);
2612 2607
 			}
2613 2608
 		}
2614 2609
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2617,9 +2612,9 @@  discard block
 block discarded – undo
2617 2612
 			$this->changeProfile($rememberServerID);
2618 2613
 		}
2619 2614
 
2620
-		if($close)
2615
+		if ($close)
2621 2616
 		{
2622
-			Framework::window_close(($err?$err:null));
2617
+			Framework::window_close(($err ? $err : null));
2623 2618
 		}
2624 2619
 		else
2625 2620
 		{
@@ -2634,15 +2629,15 @@  discard block
 block discarded – undo
2634 2629
 	 * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
2635 2630
 	 * @return string javascript eg. to close the selector window
2636 2631
 	 */
2637
-	function vfsSaveAttachment($ids,$path)
2632
+	function vfsSaveAttachment($ids, $path)
2638 2633
 	{
2639 2634
 		//error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');");
2640 2635
 
2641 2636
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2642 2637
 		{
2643
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2638
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2644 2639
 		}
2645
-		$err=null;
2640
+		$err = null;
2646 2641
 		$dupe_count = array();
2647 2642
 		$rememberServerID = $this->mail_bo->profileID;
2648 2643
 
@@ -2652,12 +2647,12 @@  discard block
 block discarded – undo
2652 2647
 		 *
2653 2648
 		 * @return array an array of parameters
2654 2649
 		 */
2655
-		$getParams = function ($id) {
2656
-			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2657
-			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2650
+		$getParams = function($id) {
2651
+			list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8);
2652
+			$lId = implode('::', array($app, $user, $serverID, $mailbox, $uid));
2658 2653
 			$hA = mail_ui::splitRowID($lId);
2659 2654
 			return array(
2660
-				'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail,
2655
+				'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail,
2661 2656
 				'user' => $user,
2662 2657
 				'name' => $name,
2663 2658
 				'part' => $part,
@@ -2669,8 +2664,8 @@  discard block
 block discarded – undo
2669 2664
 
2670 2665
 		//Examine the first attachment to see if attachment
2671 2666
 		//is winmail.dat embedded attachments.
2672
-		$isMultipleDownload=is_array($ids);
2673
-		$p = $getParams((is_array($ids)?$ids[0]:$ids));
2667
+		$isMultipleDownload = is_array($ids);
2668
+		$p = $getParams((is_array($ids) ? $ids[0] : $ids));
2674 2669
 		if ($p['is_winmail'])
2675 2670
 		{
2676 2671
 			if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID)
@@ -2681,14 +2676,14 @@  discard block
 block discarded – undo
2681 2676
 			// Retrive all embedded attachments at once
2682 2677
 			// avoids to fetch heavy winmail.dat content
2683 2678
 			// for each file.
2684
-			$attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']);
2679
+			$attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']);
2685 2680
 		}
2686 2681
 
2687
-		foreach((array)$ids as $id)
2682
+		foreach ((array)$ids as $id)
2688 2683
 		{
2689 2684
 			$params = $getParams($id);
2690 2685
 			// when downloading a single file, name is not set
2691
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
2686
+			if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name'];
2692 2687
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2693 2688
 			{
2694 2689
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2706,25 +2701,25 @@  discard block
 block discarded – undo
2706 2701
 			}
2707 2702
 			else
2708 2703
 			{
2709
-				$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
2704
+				$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
2710 2705
 			}
2711 2706
 
2712 2707
 			$file = $params['name'];
2713 2708
 			// when $isMultipleDownload the path holds no filename
2714
-			while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2709
+			while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2715 2710
 			{
2716 2711
 				$dupe_count[$params['name']]++;
2717
-				$file = pathinfo($params['name'], PATHINFO_FILENAME) .
2718
-					' ('.($dupe_count[$params['name']] + 1).')' . '.' .
2712
+				$file = pathinfo($params['name'], PATHINFO_FILENAME).
2713
+					' ('.($dupe_count[$params['name']] + 1).')'.'.'.
2719 2714
 					pathinfo($params['name'], PATHINFO_EXTENSION);
2720 2715
 			}
2721 2716
 			$params['name'] = $file;
2722 2717
 			//error_log(__METHOD__.__LINE__.array2string($attachment));
2723 2718
 			// when $isMultipleDownload the path holds no filename
2724
-			if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
2725
-				!fwrite($fp,$attachment['attachment']))
2719
+			if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) ||
2720
+				!fwrite($fp, $attachment['attachment']))
2726 2721
 			{
2727
-				$err .= lang('Error saving %1!',$file);
2722
+				$err .= lang('Error saving %1!', $file);
2728 2723
 			}
2729 2724
 			if ($fp)
2730 2725
 			{
@@ -2737,21 +2732,21 @@  discard block
 block discarded – undo
2737 2732
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
2738 2733
 			$this->changeProfile($rememberServerID);
2739 2734
 		}
2740
-		Framework::window_close(($err?$err:null));
2735
+		Framework::window_close(($err ? $err : null));
2741 2736
 	}
2742 2737
 
2743 2738
 	/**
2744 2739
 	 * Zip all attachments and send to user
2745 2740
 	 * @param string $message_id = null
2746 2741
 	 */
2747
-	function download_zip($message_id=null)
2742
+	function download_zip($message_id = null)
2748 2743
 	{
2749 2744
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2750 2745
 		// First, get all attachment IDs
2751
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
2746
+		if (isset($_GET['id'])) $message_id = $_GET['id'];
2752 2747
 		//error_log(__METHOD__.__LINE__.$message_id);
2753 2748
 		$rememberServerID = $this->mail_bo->profileID;
2754
-		if(!is_numeric($message_id))
2749
+		if (!is_numeric($message_id))
2755 2750
 		{
2756 2751
 			$hA = self::splitRowID($message_id);
2757 2752
 			$message_id = $hA['msgUID'];
@@ -2769,30 +2764,30 @@  discard block
 block discarded – undo
2769 2764
 		}
2770 2765
 		// always fetch all, even inline (images)
2771 2766
 		$fetchEmbeddedImages = true;
2772
-		$attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox);
2767
+		$attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox);
2773 2768
 		// put them in VFS so they can be zipped
2774
-		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
2769
+		$header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox);
2775 2770
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2776 2771
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2777
-		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2778
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
2772
+		$temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id";
2773
+		if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path);
2779 2774
 
2780 2775
 		// Add subject to path, so it gets used as the file name
2781
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
2782
-		if(!Vfs::mkdir($path, 0700, true))
2776
+		$path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/';
2777
+		if (!Vfs::mkdir($path, 0700, true))
2783 2778
 		{
2784
-			Framework::message("Unable to open temp directory $path",'error');
2779
+			Framework::message("Unable to open temp directory $path", 'error');
2785 2780
 			return;
2786 2781
 		}
2787 2782
 
2788 2783
 		$file_list = array();
2789 2784
 		$dupe_count = array();
2790 2785
 		$this->mail_bo->reopen($mailbox);
2791
-		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null')
2786
+		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null')
2792 2787
 		{
2793
-			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true);
2788
+			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true);
2794 2789
 		}
2795
-		foreach($attachments as $file)
2790
+		foreach ($attachments as $file)
2796 2791
 		{
2797 2792
 			if ($file['is_winmail'])
2798 2793
 			{
@@ -2805,22 +2800,22 @@  discard block
 block discarded – undo
2805 2800
 			}
2806 2801
 			else
2807 2802
 			{
2808
-				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2803
+				$attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true);
2809 2804
 			}
2810
-			$success=true;
2805
+			$success = true;
2811 2806
 			if (empty($file['filename'])) $file['filename'] = $file['name'];
2812
-			if(in_array($path.$file['filename'], $file_list))
2807
+			if (in_array($path.$file['filename'], $file_list))
2813 2808
 			{
2814 2809
 				$dupe_count[$path.$file['filename']]++;
2815
-				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) .
2816
-					' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
2810
+				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME).
2811
+					' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'.
2817 2812
 					pathinfo($file['filename'], PATHINFO_EXTENSION);
2818 2813
 			}
2819
-			if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) ||
2814
+			if (!($fp = Vfs::fopen($path.$file['filename'], 'wb')) ||
2820 2815
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
2821 2816
 			{
2822
-				$success=false;
2823
-				Framework::message("Unable to zip {$file['filename']}",'error');
2817
+				$success = false;
2818
+				Framework::message("Unable to zip {$file['filename']}", 'error');
2824 2819
 			}
2825 2820
 			if ($success) $file_list[] = $path.$file['filename'];
2826 2821
 			if ($fp) fclose($fp);
@@ -2841,7 +2836,7 @@  discard block
 block discarded – undo
2841 2836
 		exit();
2842 2837
 	}
2843 2838
 
2844
-	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
2839
+	function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null)
2845 2840
 	{
2846 2841
 		// seems to be needed, as if we open a mail from notification popup that is
2847 2842
 		// located in a different folder, we experience: could not parse message
@@ -2853,19 +2848,19 @@  discard block
 block discarded – undo
2853 2848
 		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
2854 2849
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2855 2850
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2856
-		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
2851
+		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox);
2857 2852
 
2858 2853
 		//error_log(__METHOD__.__LINE__.array2string($bodyParts));
2859 2854
 		// attachments here are only fetched to determine if there is a meeting request
2860 2855
 		// and if. use the appropriate action. so we do not need embedded images
2861 2856
 		$fetchEmbeddedImages = false;
2862
-		$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox);
2857
+		$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true, true, $mailbox);
2863 2858
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2864 2859
 		foreach ($attachments as &$attach)
2865 2860
 		{
2866 2861
 			if (strtolower($attach['mimeType']) == 'text/calendar' &&
2867 2862
 				isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
2868
-				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true))))
2863
+				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'], $attach['is_winmail'], (strtolower($attach['mimeType']) == 'text/calendar' ? false : true))))
2869 2864
 			{
2870 2865
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2871 2866
 				Api\Cache::setSession('calendar', 'ical', array(
@@ -2876,28 +2871,28 @@  discard block
 block discarded – undo
2876 2871
 				));
2877 2872
 				$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2878 2873
 				Api\Translation::add_app('calendar');
2879
-				return ExecMethod( 'calendar.calendar_uiforms.meeting',
2880
-					array('event'=>null,'msg'=>'','useSession'=>true)
2874
+				return ExecMethod('calendar.calendar_uiforms.meeting',
2875
+					array('event'=>null, 'msg'=>'', 'useSession'=>true)
2881 2876
 				);
2882 2877
 			}
2883 2878
 		}
2884 2879
 		// Compose the content of the frame
2885 2880
 		$frameHtml =
2886 2881
 			$this->get_email_header($this->mail_bo->getStyles($bodyParts)).
2887
-			$this->showBody($this->getdisplayableBody($bodyParts,true,false), false);
2882
+			$this->showBody($this->getdisplayableBody($bodyParts, true, false), false);
2888 2883
 		//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
2889
-		$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
2884
+		$frameHtml = str_replace(" \r\n", "\r\n", $frameHtml);
2890 2885
 		$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2891 2886
 
2892 2887
 		return $frameHtml;
2893 2888
 	}
2894 2889
 
2895
-	static function get_email_header($additionalStyle='')
2890
+	static function get_email_header($additionalStyle = '')
2896 2891
 	{
2897 2892
 		// egw_info[flags][css] already include <style> tags
2898 2893
 		$GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle);
2899
-		$GLOBALS['egw_info']['flags']['nofooter']=true;
2900
-		$GLOBALS['egw_info']['flags']['nonavbar']=true;
2894
+		$GLOBALS['egw_info']['flags']['nofooter'] = true;
2895
+		$GLOBALS['egw_info']['flags']['nonavbar'] = true;
2901 2896
 		// do NOT include any default CSS
2902 2897
 		Framework::includeCSS('mail', 'preview', true, true);
2903 2898
 
@@ -2908,35 +2903,35 @@  discard block
 block discarded – undo
2908 2903
 		return $GLOBALS['egw']->framework->header();
2909 2904
 	}
2910 2905
 
2911
-	function showBody(&$body, $print=true,$fullPageTags=true)
2906
+	function showBody(&$body, $print = true, $fullPageTags = true)
2912 2907
 	{
2913 2908
 		$BeginBody = '<div class="mailDisplayBody">
2914 2909
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2915 2910
 
2916 2911
 		$EndBody = '</td></tr></table></div>';
2917 2912
 		if ($fullPageTags) $EndBody .= "</body></html>";
2918
-		if ($print)	{
2919
-			print $BeginBody. $body .$EndBody;
2913
+		if ($print) {
2914
+			print $BeginBody.$body.$EndBody;
2920 2915
 		} else {
2921
-			return $BeginBody. $body .$EndBody;
2916
+			return $BeginBody.$body.$EndBody;
2922 2917
 		}
2923 2918
 	}
2924 2919
 
2925
-	function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true)
2920
+	function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true)
2926 2921
 	{
2927
-		$bodyParts	= $_bodyParts;
2922
+		$bodyParts = $_bodyParts;
2928 2923
 
2929
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2930
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2931
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2924
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2925
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2926
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2932 2927
 
2933 2928
 		$body = '';
2934 2929
 
2935 2930
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2936 2931
 		if (empty($bodyParts)) return "";
2937
-		foreach((array)$bodyParts as $singleBodyPart) {
2932
+		foreach ((array)$bodyParts as $singleBodyPart) {
2938 2933
 			if (!isset($singleBodyPart['body'])) {
2939
-				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2934
+				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy);
2940 2935
 				$body .= $singleBodyPart['body'];
2941 2936
 				continue;
2942 2937
 			}
@@ -2946,7 +2941,7 @@  discard block
 block discarded – undo
2946 2941
 				$body .= '';
2947 2942
 				continue;
2948 2943
 			}
2949
-			if(!empty($body)) {
2944
+			if (!empty($body)) {
2950 2945
 				$body .= '<hr style="border:dotted 1px silver;">';
2951 2946
 			}
2952 2947
 			//error_log($singleBodyPart['body']);
@@ -2971,22 +2966,22 @@  discard block
 block discarded – undo
2971 2966
 				'(R)',
2972 2967
 			);
2973 2968
 
2974
-			if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2969
+			if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2975 2970
 				strtoupper($singleBodyPart['charSet']) != 'UTF-8')
2976 2971
 			{
2977
-				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
2972
+				$singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']);
2978 2973
 			}
2979 2974
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
2980
-			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
2975
+			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']);
2981 2976
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
2982
-			if($singleBodyPart['mimeType'] == 'text/plain')
2977
+			if ($singleBodyPart['mimeType'] == 'text/plain')
2983 2978
 			{
2984
-				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2979
+				$newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset));
2985 2980
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2986 2981
 				// if empty and charset is utf8 try sanitizing the string in question
2987
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
2982
+				if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset));
2988 2983
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2989
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
2984
+				if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
2990 2985
 
2991 2986
 				// search http[s] links and make them as links available again
2992 2987
 				// to understand what's going on here, have a look at
@@ -3014,20 +3009,20 @@  discard block
 block discarded – undo
3014 3009
 				// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
3015 3010
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3016 3011
 				// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
3017
-				$newBody	= "<pre>".Mail::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
3012
+				$newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '&gt;')."</pre>";
3018 3013
 			}
3019 3014
 			else
3020 3015
 			{
3021
-				$alreadyHtmlLawed=false;
3022
-				$newBody	= $singleBodyPart['body'];
3016
+				$alreadyHtmlLawed = false;
3017
+				$newBody = $singleBodyPart['body'];
3023 3018
 				//TODO:$newBody	= $this->highlightQuotes($newBody);
3024 3019
 				#error_log(print_r($newBody,true));
3025 3020
 				if ($useTidy && extension_loaded('tidy'))
3026 3021
 				{
3027 3022
 					$tidy = new tidy();
3028
-					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8');
3023
+					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8');
3029 3024
 					// Found errors. Strip it all so there's some output
3030
-					if($tidy->getStatus() == 2)
3025
+					if ($tidy->getStatus() == 2)
3031 3026
 					{
3032 3027
 						error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
3033 3028
 					}
@@ -3038,7 +3033,7 @@  discard block
 block discarded – undo
3038 3033
 					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3039 3034
 					{
3040 3035
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3041
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3036
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3042 3037
 						if ($matches[2])
3043 3038
 						{
3044 3039
 							$hasOther = true;
@@ -3049,7 +3044,7 @@  discard block
 block discarded – undo
3049 3044
 				else
3050 3045
 				{
3051 3046
 					// htmLawed filter only the 'body'
3052
-					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3047
+					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3053 3048
 					if ($matches[2])
3054 3049
 					{
3055 3050
 						$hasOther = true;
@@ -3058,10 +3053,10 @@  discard block
 block discarded – undo
3058 3053
 					$htmLawed = new Api\Html\HtmLawed();
3059 3054
 					// the next line should not be needed, but produces better results on HTML 2 Text conversion,
3060 3055
 					// as we switched off HTMLaweds tidy functionality
3061
-					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3062
-					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3063
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3064
-					$alreadyHtmlLawed=true;
3056
+					$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
3057
+					$newBody = $htmLawed->run($newBody, Mail::$htmLawed_config);
3058
+					if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
3059
+					$alreadyHtmlLawed = true;
3065 3060
 				}
3066 3061
 				// do the cleanup, set for the use of purifier
3067 3062
 				//$newBodyBuff = $newBody;
@@ -3083,8 +3078,8 @@  discard block
 block discarded – undo
3083 3078
 				}
3084 3079
 */
3085 3080
 				// removes stuff between http and ?http
3086
-				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';    // only http:// gets removed, other protocolls are shown
3087
-				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http://
3081
+				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
3082
+				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http://
3088 3083
 				// TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK
3089 3084
 				$newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
3090 3085
 					"\\1@\\2.\\3",
@@ -3097,7 +3092,7 @@  discard block
 block discarded – undo
3097 3092
 				// create links for inline images
3098 3093
 				if ($modifyURI)
3099 3094
 				{
3100
-					$newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID);
3095
+					$newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID);
3101 3096
 				}
3102 3097
 				// email addresses / mailto links get now activated on client-side
3103 3098
 			}
@@ -3109,7 +3104,7 @@  discard block
 block discarded – undo
3109 3104
 		$body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
3110 3105
 			"<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body);
3111 3106
 
3112
-		$body = preg_replace($nonDisplayAbleCharacters,'',$body);
3107
+		$body = preg_replace($nonDisplayAbleCharacters, '', $body);
3113 3108
 
3114 3109
 		return $body;
3115 3110
 	}
@@ -3124,7 +3119,7 @@  discard block
 block discarded – undo
3124 3119
 	 * @param string $_messageType = 'html', message type is either html or plain
3125 3120
 	 * @return string message body including all CID images replaced
3126 3121
 	 */
3127
-	public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html')
3122
+	public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html')
3128 3123
 	{
3129 3124
 		if ($_messageType === 'plain')
3130 3125
 		{
@@ -3132,7 +3127,7 @@  discard block
 block discarded – undo
3132 3127
 		}
3133 3128
 		else
3134 3129
 		{
3135
-			foreach(array('src','url','background') as $type)
3130
+			foreach (array('src', 'url', 'background') as $type)
3136 3131
 			{
3137 3132
 				$_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type);
3138 3133
 			}
@@ -3151,7 +3146,7 @@  discard block
 block discarded – undo
3151 3146
 	 *	- types: {plain|src|url|background}
3152 3147
 	 * @return string returns body content including all CID replacements
3153 3148
 	 */
3154
-	public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src')
3149
+	public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src')
3155 3150
 	{
3156 3151
 		/**
3157 3152
 		 * Callback for preg_replace_callback function
@@ -3163,7 +3158,7 @@  discard block
 block discarded – undo
3163 3158
 		 * @param string $_type
3164 3159
 		 * @return string|boolean returns the replace
3165 3160
 		*/
3166
-		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3161
+		$replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type)
3167 3162
 		{
3168 3163
 			if (!$_type)	return false;
3169 3164
 			$CID = '';
@@ -3185,11 +3180,11 @@  discard block
 block discarded – undo
3185 3180
 					break;
3186 3181
 			}
3187 3182
 
3188
-			static $cache = array();	// some caching, if mails containing the same image multiple times
3183
+			static $cache = array(); // some caching, if mails containing the same image multiple times
3189 3184
 
3190 3185
 			if (is_array($matches) && $CID)
3191 3186
 			{
3192
-				$linkData = array (
3187
+				$linkData = array(
3193 3188
 					'menuaction'    => 'mail.mail_ui.displayImage',
3194 3189
 					'uid'		=> $_uid,
3195 3190
 					'mailbox'	=> base64_encode($_mailbox),
@@ -3202,7 +3197,7 @@  discard block
 block discarded – undo
3202 3197
 				{
3203 3198
 					if (!isset($cache[$imageURL]))
3204 3199
 					{
3205
-						if ($_type !="background")
3200
+						if ($_type != "background")
3206 3201
 						{
3207 3202
 							$bo = Mail::getInstance(false, mail_ui::$icServerID);
3208 3203
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
@@ -3243,16 +3238,16 @@  discard block
 block discarded – undo
3243 3238
 		};
3244 3239
 
3245 3240
 		// return new body content base on chosen type
3246
-		switch($_type)
3241
+		switch ($_type)
3247 3242
 		{
3248 3243
 			case"plain":
3249
-				return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body);
3244
+				return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body);
3250 3245
 			case "src":
3251
-				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3246
+				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3252 3247
 			case "url":
3253
-				return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body);
3248
+				return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body);
3254 3249
 			case "background":
3255
-				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3250
+				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3256 3251
 		}
3257 3252
 	}
3258 3253
 
@@ -3260,7 +3255,7 @@  discard block
 block discarded – undo
3260 3255
 	 * importMessage
3261 3256
 	 * @param array $content = null an array of content
3262 3257
 	 */
3263
-	function importMessage($content=null)
3258
+	function importMessage($content = null)
3264 3259
 	{
3265 3260
 		//error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder());
3266 3261
 
@@ -3282,7 +3277,7 @@  discard block
 block discarded – undo
3282 3277
 			}
3283 3278
 			$destination = $content['FOLDER'][0];
3284 3279
 
3285
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3280
+			if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2);
3286 3281
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3287 3282
 			{
3288 3283
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3293,32 +3288,31 @@  discard block
 block discarded – undo
3293 3288
 			$importFailed = false;
3294 3289
 			try
3295 3290
 			{
3296
-				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3297
-			    $linkData = array
3298
-			    (
3291
+				$messageUid = $this->importMessageToFolder($file, $destination, $importID);
3292
+			    $linkData = array(
3299 3293
 					'id' => $this->createRowID($destination, $messageUid, true),
3300 3294
 			    );
3301 3295
 			}
3302 3296
 			catch (Api\Exception\WrongUserinput $e)
3303 3297
 			{
3304
-					$importFailed=true;
3305
-					$content['msg']		= $e->getMessage();
3298
+					$importFailed = true;
3299
+					$content['msg'] = $e->getMessage();
3306 3300
 			}
3307 3301
 			if (!$importFailed)
3308 3302
 			{
3309 3303
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3310 3304
 				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3311
-				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3305
+				ExecMethod2('mail.mail_ui.displayMessage', $linkData);
3312 3306
 				return;
3313 3307
 			}
3314 3308
 		}
3315 3309
 		if (!is_array($content)) $content = array();
3316
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3317
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3310
+		if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder();
3311
+		if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true);
3318 3312
 
3319 3313
 		$etpl = new Etemplate('mail.importMessage');
3320
-		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
3321
-		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
3314
+		$etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport');
3315
+		$etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2);
3322 3316
 	}
3323 3317
 
3324 3318
 	/**
@@ -3330,7 +3324,7 @@  discard block
 block discarded – undo
3330 3324
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3331 3325
 	 * @return mixed $messageUID or exception
3332 3326
 	 */
3333
-	function importMessageToFolder($_formData,&$_folder,$importID='')
3327
+	function importMessageToFolder($_formData, &$_folder, $importID = '')
3334 3328
 	{
3335 3329
 		$importfailed = false;
3336 3330
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -3338,7 +3332,7 @@  discard block
 block discarded – undo
3338 3332
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3339 3333
 		try
3340 3334
 		{
3341
-			$tmpFileName = Mail::checkFileBasics($_formData,$importID);
3335
+			$tmpFileName = Mail::checkFileBasics($_formData, $importID);
3342 3336
 		}
3343 3337
 		catch (Api\Exception\WrongUserinput $e)
3344 3338
 		{
@@ -3362,29 +3356,29 @@  discard block
 block discarded – undo
3362 3356
 			if (empty($_folder))
3363 3357
 			{
3364 3358
 				$importfailed = true;
3365
-				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3359
+				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']);
3366 3360
 			}
3367 3361
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3368
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3362
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
3369 3363
 			if ($importfailed === false)
3370 3364
 			{
3371
-				if ($this->mail_bo->folderExists($_folder,true)) {
3365
+				if ($this->mail_bo->folderExists($_folder, true)) {
3372 3366
 					try
3373 3367
 					{
3374 3368
 						$messageUid = $this->mail_bo->appendMessage($_folder,
3375 3369
 							$mailObject->getRaw(),
3376
-							null,'\\Seen');
3370
+							null, '\\Seen');
3377 3371
 					}
3378 3372
 					catch (Api\Exception\WrongUserinput $e)
3379 3373
 					{
3380 3374
 						$importfailed = true;
3381
-						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
3375
+						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage());
3382 3376
 					}
3383 3377
 				}
3384 3378
 				else
3385 3379
 				{
3386 3380
 					$importfailed = true;
3387
-					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder);
3381
+					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder);
3388 3382
 				}
3389 3383
 			}
3390 3384
 		}
@@ -3410,9 +3404,9 @@  discard block
 block discarded – undo
3410 3404
 	 *								 $formData['size']	= 2136;
3411 3405
 	 * @return void
3412 3406
 	 */
3413
-	function importMessageFromVFS2DraftAndEdit($formData='')
3407
+	function importMessageFromVFS2DraftAndEdit($formData = '')
3414 3408
 	{
3415
-		$this->importMessageFromVFS2DraftAndDisplay($formData,'edit');
3409
+		$this->importMessageFromVFS2DraftAndDisplay($formData, 'edit');
3416 3410
 	}
3417 3411
 
3418 3412
 	/**
@@ -3427,7 +3421,7 @@  discard block
 block discarded – undo
3427 3421
 	 * @param string $mode mode to open ImportedMessage display and edit are supported
3428 3422
 	 * @return void
3429 3423
 	 */
3430
-	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3424
+	function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display')
3431 3425
 	{
3432 3426
 		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3433 3427
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
@@ -3440,43 +3434,42 @@  discard block
 block discarded – undo
3440 3434
 			$formData['file'] = 'egw-data://'.$formData['data'];
3441 3435
 		}
3442 3436
 		// name should be set to meet the requirements of checkFileBasics
3443
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3437
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3444 3438
 		{
3445
-			$buff = explode('/',$formData['file']);
3439
+			$buff = explode('/', $formData['file']);
3446 3440
 			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3447 3441
 		}
3448 3442
 		// type should be set to meet the requirements of checkFileBasics
3449
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3443
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3450 3444
 		{
3451
-			$buff = explode('.',$formData['file']);
3445
+			$buff = explode('.', $formData['file']);
3452 3446
 			$suffix = '';
3453 3447
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3454 3448
 			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3455 3449
 		}
3456 3450
 		// size should be set to meet the requirements of checkFileBasics
3457
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3451
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3458 3452
 		{
3459 3453
 			$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
3460 3454
 		}
3461 3455
 		try
3462 3456
 		{
3463
-			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3464
-			$linkData = array
3465
-			(
3466
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3467
-				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3457
+			$messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID);
3458
+			$linkData = array(
3459
+		        'menuaction'    => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'),
3460
+				'id'		=> $this->createRowID($draftFolder, $messageUid, true),
3468 3461
 				'deleteDraftOnClose' => 1,
3469 3462
 			);
3470
-			if ($mode!='display')
3463
+			if ($mode != 'display')
3471 3464
 			{
3472 3465
 				unset($linkData['deleteDraftOnClose']);
3473
-				$linkData['method']	='importMessageToMergeAndSend';
3466
+				$linkData['method'] = 'importMessageToMergeAndSend';
3474 3467
 			}
3475 3468
 			else
3476 3469
 			{
3477
-				$linkData['mode']=$mode;
3470
+				$linkData['mode'] = $mode;
3478 3471
 			}
3479
-			Egw::redirect_link('/index.php',$linkData);
3472
+			Egw::redirect_link('/index.php', $linkData);
3480 3473
 		}
3481 3474
 		catch (Api\Exception\WrongUserinput $e)
3482 3475
 		{
@@ -3491,13 +3484,13 @@  discard block
 block discarded – undo
3491 3484
 	 *
3492 3485
 	 * @return xajax response
3493 3486
 	 */
3494
-	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3487
+	function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null)
3495 3488
 	{
3496 3489
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3497 3490
 		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3498 3491
 		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3499 3492
 		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3500
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3493
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions");
3501 3494
 		if (empty($_messageID)) return "";
3502 3495
 		$uidA = self::splitRowID($_messageID);
3503 3496
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -3511,7 +3504,7 @@  discard block
 block discarded – undo
3511 3504
 			$this->changeProfile($icServerID);
3512 3505
 		}
3513 3506
 
3514
-		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions);
3507
+		$bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions);
3515 3508
 		Api\Session::cache_control(true);
3516 3509
 		//error_log(array2string($bodyResponse));
3517 3510
 		echo $bodyResponse;
@@ -3534,7 +3527,7 @@  discard block
 block discarded – undo
3534 3527
 			$oA = array();
3535 3528
 			foreach ($_folder as $_folderName)
3536 3529
 			{
3537
-				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3530
+				list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2);
3538 3531
 				if (is_numeric($profileID))
3539 3532
 				{
3540 3533
 					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
@@ -3542,19 +3535,19 @@  discard block
 block discarded – undo
3542 3535
 					{
3543 3536
 						try
3544 3537
 						{
3545
-							$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3538
+							$fS = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3546 3539
 						}
3547 3540
 						catch (Exception $e)
3548 3541
 						{
3549 3542
 							continue;
3550 3543
 						}
3551
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3544
+						if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']);
3552 3545
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3553 3546
 						if ($fS['unseen'])
3554 3547
 						{
3555 3548
 							$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
3556 3549
 						}
3557
-						if ($fS['unseen']==0 && $fS['shortDisplayName'])
3550
+						if ($fS['unseen'] == 0 && $fS['shortDisplayName'])
3558 3551
 						{
3559 3552
 							$oA[$_folderName] = $fS['shortDisplayName'];
3560 3553
 						}
@@ -3565,7 +3558,7 @@  discard block
 block discarded – undo
3565 3558
 			if ($oA)
3566 3559
 			{
3567 3560
 				$response = Api\Json\Response::get();
3568
-				$response->call('app.mail.mail_setFolderStatus',$oA);
3561
+				$response->call('app.mail.mail_setFolderStatus', $oA);
3569 3562
 			}
3570 3563
 		}
3571 3564
 	}
@@ -3579,14 +3572,14 @@  discard block
 block discarded – undo
3579 3572
 	function ajax_addFolder($_parentFolderName, $_newName)
3580 3573
 	{
3581 3574
 		//error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName));
3582
-		$errorMessage='';
3575
+		$errorMessage = '';
3583 3576
 		if ($_parentFolderName)
3584 3577
 		{
3585 3578
 			$created = false;
3586 3579
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName);
3587 3580
 			//the conversion is handeled by horde, frontend interaction is all utf-8
3588 3581
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3589
-			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3582
+			list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2);
3590 3583
 			if (is_numeric($profileID))
3591 3584
 			{
3592 3585
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
@@ -3626,10 +3619,10 @@  discard block
 block discarded – undo
3626 3619
 
3627 3620
 				if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false);
3628 3621
 				*/
3629
-				$nA = explode($del,$_newName);
3622
+				$nA = explode($del, $_newName);
3630 3623
 
3631 3624
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3632
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3625
+				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false);
3633 3626
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3634 3627
 
3635 3628
 				$this->mail_bo->reopen('INBOX');
@@ -3637,11 +3630,11 @@  discard block
 block discarded – undo
3637 3630
 				// if newName has delimiter ($del) in it, we need to create the subtree
3638 3631
 				if (!empty($nA))
3639 3632
 				{
3640
-					$c=0;
3641
-					foreach($nA as $sTName)
3633
+					$c = 0;
3634
+					foreach ($nA as $sTName)
3642 3635
 					{
3643
-						$error=null;
3644
-						if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3636
+						$error = null;
3637
+						if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3645 3638
 						{
3646 3639
 							$c++;
3647 3640
 						}
@@ -3650,16 +3643,16 @@  discard block
 block discarded – undo
3650 3643
 							$errorMessage .= $error;
3651 3644
 						}
3652 3645
 					}
3653
-					if ($c==count($nA)) $created=true;
3646
+					if ($c == count($nA)) $created = true;
3654 3647
 				}
3655 3648
 				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3656 3649
 			}
3657 3650
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3658
-			if ($created===true)
3651
+			if ($created === true)
3659 3652
 			{
3660 3653
 				$this->mail_bo->resetFolderObjectCache($profileID);
3661 3654
 				$response = Api\Json\Response::get();
3662
-				if ( $oldFolderInfo['shortDisplayName'])
3655
+				if ($oldFolderInfo['shortDisplayName'])
3663 3656
 				{
3664 3657
 					$nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']);
3665 3658
 				}
@@ -3667,14 +3660,14 @@  discard block
 block discarded – undo
3667 3660
 				{
3668 3661
 					$nodeInfo = array($profileID=>lang('INBOX'));
3669 3662
 				}
3670
-				$response->call('app.mail.mail_reloadNode',$nodeInfo);
3663
+				$response->call('app.mail.mail_reloadNode', $nodeInfo);
3671 3664
 			}
3672 3665
 			else
3673 3666
 			{
3674 3667
 				if ($errorMessage)
3675 3668
 				{
3676 3669
 					$response = Api\Json\Response::get();
3677
-					$response->call('egw.message',$errorMessage);
3670
+					$response->call('egw.message', $errorMessage);
3678 3671
 				}
3679 3672
 			}
3680 3673
 		}
@@ -3696,22 +3689,22 @@  discard block
 block discarded – undo
3696 3689
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3697 3690
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3698 3691
 			$oA = array();
3699
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3692
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3700 3693
 			$hasChildren = false;
3701 3694
 			if (is_numeric($profileID))
3702 3695
 			{
3703 3696
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
3704
-				$pA = explode($del,$folderName);
3697
+				$pA = explode($del, $folderName);
3705 3698
 				array_pop($pA);
3706
-				$parentFolder = implode($del,$pA);
3707
-				if (strtoupper($folderName)!= 'INBOX')
3699
+				$parentFolder = implode($del, $pA);
3700
+				if (strtoupper($folderName) != 'INBOX')
3708 3701
 				{
3709 3702
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3710
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false);
3703
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false);
3711 3704
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3712
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3705
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3713 3706
 					{
3714
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3707
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3715 3708
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3716 3709
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3717 3710
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3728,7 +3721,7 @@  discard block
 block discarded – undo
3728 3721
 							else
3729 3722
 							{
3730 3723
 								$rv = $this->mail_bo->icServer->subscribeMailbox($folder, false);
3731
-								$fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName));
3724
+								$fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName));
3732 3725
 							}
3733 3726
 						}
3734 3727
 						//error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments));
@@ -3738,7 +3731,7 @@  discard block
 block discarded – undo
3738 3731
 					$success = false;
3739 3732
 					try
3740 3733
 					{
3741
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3734
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3742 3735
 						{
3743 3736
 							$this->mail_bo->resetFolderObjectCache($profileID);
3744 3737
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3749,11 +3742,11 @@  discard block
 block discarded – undo
3749 3742
 					}
3750 3743
 					catch (Exception $e)
3751 3744
 					{
3752
-						$newFolderName=$folderName;
3745
+						$newFolderName = $folderName;
3753 3746
 						$msg = $e->getMessage();
3754 3747
 					}
3755 3748
 					$this->mail_bo->reopen($newFolderName);
3756
-					$fS = $this->mail_bo->getFolderStatus($newFolderName,false);
3749
+					$fS = $this->mail_bo->getFolderStatus($newFolderName, false);
3757 3750
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3758 3751
 					if ($hasChildren)
3759 3752
 					{
@@ -3784,12 +3777,12 @@  discard block
 block discarded – undo
3784 3777
 					{
3785 3778
 						$oA[$_folderName]['desc'] = $fS['shortDisplayName'];
3786 3779
 					}
3787
-					foreach($fragments as $oldFolderName => $fragment)
3780
+					foreach ($fragments as $oldFolderName => $fragment)
3788 3781
 					{
3789 3782
 						//error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment);
3790 3783
 						$oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment;
3791 3784
 						$oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#';
3792
-						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
3785
+						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false);
3793 3786
 						if ($fS['unseen'])
3794 3787
 						{
3795 3788
 							$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
@@ -3802,20 +3795,20 @@  discard block
 block discarded – undo
3802 3795
 					}
3803 3796
 				}
3804 3797
 			}
3805
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
3798
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
3806 3799
 			{
3807
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
3800
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
3808 3801
 				$this->mail_bo->saveSessionData();
3809 3802
 			}
3810 3803
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3811 3804
 			$response = Api\Json\Response::get();
3812 3805
 			if ($oA && $success)
3813 3806
 			{
3814
-				$response->call('app.mail.mail_setLeaf',$oA);
3807
+				$response->call('app.mail.mail_setLeaf', $oA);
3815 3808
 			}
3816 3809
 			else
3817 3810
 			{
3818
-				$response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail');
3811
+				$response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail');
3819 3812
 			}
3820 3813
 		}
3821 3814
 	}
@@ -3827,7 +3820,7 @@  discard block
 block discarded – undo
3827 3820
 	 * @param boolean $_subscribedOnly = true
3828 3821
 	 * @return void
3829 3822
 	 */
3830
-	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
3823
+	function ajax_reloadNode($_folderName, $_subscribedOnly = true)
3831 3824
 	{
3832 3825
 		Api\Translation::add_app('mail');
3833 3826
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
@@ -3838,20 +3831,20 @@  discard block
 block discarded – undo
3838 3831
 
3839 3832
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3840 3833
 		$this->mail_bo->getHierarchyDelimiter(false);
3841
-		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3834
+		list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3842 3835
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3843 3836
 		// that we get what we request
3844 3837
 		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3845 3838
 		if ($profileID != $this->mail_bo->profileID) return; // only current connection
3846 3839
 		if (!empty($folderName))
3847 3840
 		{
3848
-			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
3849
-			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3841
+			$parentFolder = (!empty($folderName) ? $folderName : 'INBOX');
3842
+			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3850 3843
 			if ($folderInfo['unseen'])
3851 3844
 			{
3852 3845
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')';
3853 3846
 			}
3854
-			if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName'])
3847
+			if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName'])
3855 3848
 			{
3856 3849
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'];
3857 3850
 			}
@@ -3867,11 +3860,11 @@  discard block
 block discarded – undo
3867 3860
 		}
3868 3861
 		// Send full info back in the response
3869 3862
 		$response = Api\Json\Response::get();
3870
-		foreach($refreshData as $folder => &$name)
3863
+		foreach ($refreshData as $folder => &$name)
3871 3864
 		{
3872
-			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
3865
+			$name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true);
3873 3866
 		}
3874
-		$response->call('app.mail.mail_reloadNode',$refreshData);
3867
+		$response->call('app.mail.mail_reloadNode', $refreshData);
3875 3868
 
3876 3869
 	}
3877 3870
 
@@ -3887,7 +3880,7 @@  discard block
 block discarded – undo
3887 3880
 	 * @param type $_rowid row id from nm
3888 3881
 	 *
3889 3882
 	 */
3890
-	function ajax_resolveWinmail ($_rowid)
3883
+	function ajax_resolveWinmail($_rowid)
3891 3884
 	{
3892 3885
 		$response = Api\Json\Response::get();
3893 3886
 
@@ -3895,7 +3888,7 @@  discard block
 block discarded – undo
3895 3888
 		$uid = $idParts['msgUID'];
3896 3889
 		$mbox = $idParts['folder'];
3897 3890
 
3898
-		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
3891
+		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox);
3899 3892
 		if (is_array($attachments))
3900 3893
 		{
3901 3894
 			$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
@@ -3923,30 +3916,30 @@  discard block
 block discarded – undo
3923 3916
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3924 3917
 			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
3925 3918
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3926
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3927
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
3919
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3920
+			list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2);
3928 3921
 			$hasChildren = false;
3929 3922
 			if (is_numeric($profileID))
3930 3923
 			{
3931 3924
 				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
3932
-				$pA = explode($del,$folderName);
3925
+				$pA = explode($del, $folderName);
3933 3926
 				$namePart = array_pop($pA);
3934 3927
 				$_newName = $namePart;
3935
-				$oldParentFolder = implode($del,$pA);
3928
+				$oldParentFolder = implode($del, $pA);
3936 3929
 				$parentFolder = $_newLocation;
3937 3930
 
3938
-				if (strtoupper($folderName)!= 'INBOX' &&
3931
+				if (strtoupper($folderName) != 'INBOX' &&
3939 3932
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3940 3933
 					(($oldParentFolder != $parentFolder &&
3941
-					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3942
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
3934
+					strlen($parentFolder) > 0 && strlen($folderName) > 0 &&
3935
+					strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch
3943 3936
 				{
3944 3937
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3945
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3938
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3946 3939
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3947
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3940
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3948 3941
 					{
3949
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3942
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3950 3943
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3951 3944
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3952 3945
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3971,7 +3964,7 @@  discard block
 block discarded – undo
3971 3964
 					$success = false;
3972 3965
 					try
3973 3966
 					{
3974
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3967
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3975 3968
 						{
3976 3969
 							$this->mail_bo->resetFolderObjectCache($profileID);
3977 3970
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3983,11 +3976,11 @@  discard block
 block discarded – undo
3983 3976
 					}
3984 3977
 					catch (Exception $e)
3985 3978
 					{
3986
-						$newFolderName=$folderName;
3979
+						$newFolderName = $folderName;
3987 3980
 						$msg = $e->getMessage();
3988 3981
 					}
3989 3982
 					$this->mail_bo->reopen($parentFolder);
3990
-					$this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3983
+					$this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3991 3984
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3992 3985
 					if ($hasChildren)
3993 3986
 					{
@@ -4008,9 +4001,9 @@  discard block
 block discarded – undo
4008 4001
 					}
4009 4002
 				}
4010 4003
 			}
4011
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
4004
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
4012 4005
 			{
4013
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
4006
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
4014 4007
 				$this->mail_bo->saveSessionData();
4015 4008
 			}
4016 4009
 			//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -4019,26 +4012,26 @@  discard block
 block discarded – undo
4019 4012
 			{
4020 4013
 				Api\Translation::add_app('mail');
4021 4014
 
4022
-				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
4023
-				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4015
+				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false);
4016
+				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4024 4017
 				$refreshData = array(
4025 4018
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4026 4019
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4027 4020
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4028
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4029
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4021
+				if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4022
+				if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4030 4023
 
4031 4024
 				// Send full info back in the response
4032
-				foreach($refreshData as $folder => &$name)
4025
+				foreach ($refreshData as $folder => &$name)
4033 4026
 				{
4034
-					$name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true);
4027
+					$name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true);
4035 4028
 				}
4036
-				$response->call('app.mail.mail_reloadNode',$refreshData);
4029
+				$response->call('app.mail.mail_reloadNode', $refreshData);
4037 4030
 
4038 4031
 			}
4039 4032
 			else
4040 4033
 			{
4041
-				$response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail');
4034
+				$response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail');
4042 4035
 			}
4043 4036
 		}
4044 4037
 	}
@@ -4058,23 +4051,23 @@  discard block
 block discarded – undo
4058 4051
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4059 4052
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4060 4053
 			$oA = array();
4061
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4054
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4062 4055
 			$hasChildren = false;
4063 4056
 			if (is_numeric($profileID))
4064 4057
 			{
4065 4058
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4066
-				$pA = explode($del,$folderName);
4059
+				$pA = explode($del, $folderName);
4067 4060
 				array_pop($pA);
4068
-				if (strtoupper($folderName)!= 'INBOX')
4061
+				if (strtoupper($folderName) != 'INBOX')
4069 4062
 				{
4070 4063
 					//error_log(__METHOD__.__LINE__."$folderName,  implode($del,$pA), $_newName");
4071 4064
 					$oA = array();
4072 4065
 					$subFolders = array();
4073
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4066
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4074 4067
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4075
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4068
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4076 4069
 					{
4077
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4070
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4078 4071
 						$ftD = array();
4079 4072
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4080 4073
 						$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -4084,24 +4077,24 @@  discard block
 block discarded – undo
4084 4077
 						//error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix");
4085 4078
 						foreach ($subFolders as $k => $f)
4086 4079
 						{
4087
-							$ftD[substr_count($f,$delimiter)][]=$f;
4080
+							$ftD[substr_count($f, $delimiter)][] = $f;
4088 4081
 						}
4089
-						krsort($ftD,SORT_NUMERIC);//sort per level
4082
+						krsort($ftD, SORT_NUMERIC); //sort per level
4090 4083
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4091
-						foreach($ftD as $k => $lc)//collection per level
4084
+						foreach ($ftD as $k => $lc)//collection per level
4092 4085
 						{
4093
-							foreach($lc as $f)//folders contained in that level
4086
+							foreach ($lc as $f)//folders contained in that level
4094 4087
 							{
4095 4088
 								try
4096 4089
 								{
4097 4090
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4098 4091
 									$this->mail_bo->deleteFolder($f);
4099 4092
 									$success = true;
4100
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4093
+									if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4101 4094
 								}
4102 4095
 								catch (Exception $e)
4103 4096
 								{
4104
-									$msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage();
4097
+									$msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage();
4105 4098
 									$success = false;
4106 4099
 								}
4107 4100
 							}
@@ -4132,11 +4125,11 @@  discard block
 block discarded – undo
4132 4125
 			if ($success)
4133 4126
 			{
4134 4127
 				//error_log(__METHOD__.__LINE__.array2string($oA));
4135
-				$response->call('app.mail.mail_removeLeaf',$oA);
4128
+				$response->call('app.mail.mail_removeLeaf', $oA);
4136 4129
 			}
4137 4130
 			else
4138 4131
 			{
4139
-				$response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail');
4132
+				$response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail');
4140 4133
 			}
4141 4134
 		}
4142 4135
 	}
@@ -4150,7 +4143,7 @@  discard block
 block discarded – undo
4150 4143
 	 * @param bool $getFolders The client needs the folders for the profile
4151 4144
 	 * @return nothing
4152 4145
 	 */
4153
-	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
4146
+	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null)
4154 4147
 	{
4155 4148
 		$response = Api\Json\Response::get();
4156 4149
 
@@ -4158,7 +4151,7 @@  discard block
 block discarded – undo
4158 4151
 
4159 4152
 		if ($icServerID && $icServerID != $previous_id)
4160 4153
 		{
4161
-			$mail_ui = new mail_ui(false);	// do NOT run constructor, as we call changeProfile anyway
4154
+			$mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway
4162 4155
 			try
4163 4156
 			{
4164 4157
 				$mail_ui->changeProfile($icServerID);
@@ -4174,23 +4167,23 @@  discard block
 block discarded – undo
4174 4167
 				}
4175 4168
 			}
4176 4169
 			catch (Exception $e) {
4177
-				self::callWizard($e->getMessage(),true, 'error');
4170
+				self::callWizard($e->getMessage(), true, 'error');
4178 4171
 			}
4179 4172
 		}
4180 4173
 		else
4181 4174
 		{
4182
-			$mail_ui = new mail_ui(true);	// run constructor
4175
+			$mail_ui = new mail_ui(true); // run constructor
4183 4176
 		}
4184 4177
 
4185 4178
 		// Send full info back in the response
4186
-		if($getFolders)
4179
+		if ($getFolders)
4187 4180
 		{
4188 4181
 			Api\Translation::add_app('mail');
4189 4182
 
4190 4183
 			$refreshData = array(
4191
-				$icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4184
+				$icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4192 4185
 			);
4193
-			$response->call('app.mail.mail_reloadNode',$refreshData);
4186
+			$response->call('app.mail.mail_reloadNode', $refreshData);
4194 4187
 		}
4195 4188
 	}
4196 4189
 
@@ -4201,7 +4194,7 @@  discard block
 block discarded – undo
4201 4194
 	 *						if other than active profile; nothing is done!
4202 4195
 	 * @return nothing
4203 4196
 	 */
4204
-	public static function ajax_refreshVacationNotice($icServerID=null)
4197
+	public static function ajax_refreshVacationNotice($icServerID = null)
4205 4198
 	{
4206 4199
 		//Get vacation from cache if it's available
4207 4200
 		$cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
@@ -4219,28 +4212,28 @@  discard block
 block discarded – undo
4219 4212
 
4220 4213
 				$vacation = $mail->gatherVacation($cachedVacations);
4221 4214
 			} catch (Exception $e) {
4222
-				$vacation=false;
4215
+				$vacation = false;
4223 4216
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4224 4217
 				unset($e);
4225 4218
 			}
4226 4219
 		}
4227 4220
 
4228
-		if($vacation) {
4229
-			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4221
+		if ($vacation) {
4222
+			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date'))
4230 4223
 			{
4231 4224
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4232 4225
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4233
-				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4234
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4226
+				$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) : '') : '');
4227
+				if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = '';
4235 4228
 			}
4236 4229
 		}
4237
-		if ($vacation==false)
4230
+		if ($vacation == false)
4238 4231
 		{
4239
-			$refreshData['vacationnotice'] =  '';
4240
-			$refreshData['vacationrange'] =  '';
4232
+			$refreshData['vacationnotice'] = '';
4233
+			$refreshData['vacationrange'] = '';
4241 4234
 		}
4242 4235
 		$response = Api\Json\Response::get();
4243
-		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
4236
+		$response->call('app.mail.mail_refreshVacationNotice', $refreshData);
4244 4237
 	}
4245 4238
 
4246 4239
 	/**
@@ -4250,43 +4243,43 @@  discard block
 block discarded – undo
4250 4243
 	 *						if other than active profile; nothing is done!
4251 4244
 	 * @return nothing
4252 4245
 	 */
4253
-	function ajax_refreshFilters($icServerID=null)
4246
+	function ajax_refreshFilters($icServerID = null)
4254 4247
 	{
4255 4248
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4256 4249
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4257 4250
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4258 4251
 		{
4259
-			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4260
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4252
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4253
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4261 4254
 		}
4262 4255
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4263 4256
 		{
4264 4257
 			unset($this->searchTypes['quick']);
4265 4258
 			unset($this->searchTypes['quickwithcc']);
4266 4259
 		}
4267
-		if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4260
+		if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4268 4261
 		{
4269
-			$this->statusTypes = array_merge($this->statusTypes,array(
4270
-				'keyword1'	=> 'important',//lang('important'),
4271
-				'keyword2'	=> 'job',	//lang('job'),
4272
-				'keyword3'	=> 'personal',//lang('personal'),
4273
-				'keyword4'	=> 'to do',	//lang('to do'),
4274
-				'keyword5'	=> 'later',	//lang('later'),
4262
+			$this->statusTypes = array_merge($this->statusTypes, array(
4263
+				'keyword1'	=> 'important', //lang('important'),
4264
+				'keyword2'	=> 'job', //lang('job'),
4265
+				'keyword3'	=> 'personal', //lang('personal'),
4266
+				'keyword4'	=> 'to do', //lang('to do'),
4267
+				'keyword5'	=> 'later', //lang('later'),
4275 4268
 			));
4276 4269
 		}
4277 4270
 		else
4278 4271
 		{
4279
-			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4280
-			foreach($keywords as &$k)
4272
+			$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
4273
+			foreach ($keywords as &$k)
4281 4274
 			{
4282
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4275
+				if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
4283 4276
 			}
4284 4277
 		}
4285 4278
 
4286 4279
 		$response = Api\Json\Response::get();
4287
-		$response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes);
4288
-		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
4289
-		$response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')));
4280
+		$response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes);
4281
+		$response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes);
4282
+		$response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')));
4290 4283
 
4291 4284
 	}
4292 4285
 
@@ -4295,7 +4288,7 @@  discard block
 block discarded – undo
4295 4288
 	 *
4296 4289
 	 * @return nothing
4297 4290
 	 */
4298
-	function ajax_refreshQuotaDisplay($icServerID=null)
4291
+	function ajax_refreshQuotaDisplay($icServerID = null)
4299 4292
 	{
4300 4293
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4301 4294
 		Api\Translation::add_app('mail');
@@ -4315,10 +4308,10 @@  discard block
 block discarded – undo
4315 4308
 			unset($e);
4316 4309
 		}
4317 4310
 
4318
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4311
+		if ($quota !== false && $quota['limit'] != 'NOT SET') {
4319 4312
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4320 4313
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4321
-			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4314
+			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
4322 4315
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4323 4316
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4324 4317
 		} else {
@@ -4338,7 +4331,7 @@  discard block
 block discarded – undo
4338 4331
 			}
4339 4332
 		}
4340 4333
 		$response = Api\Json\Response::get();
4341
-		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
4334
+		$response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content));
4342 4335
 	}
4343 4336
 
4344 4337
 	/**
@@ -4360,34 +4353,34 @@  discard block
 block discarded – undo
4360 4353
 			$this->changeProfile($icServerID);
4361 4354
 		}
4362 4355
 		$junkFolder = $this->mail_bo->getJunkFolder();
4363
-		if(!empty($junkFolder)) {
4356
+		if (!empty($junkFolder)) {
4364 4357
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4365 4358
 			{
4366 4359
 				// Lock the tree if the active folder is junk folder
4367 4360
 				$response->call('app.mail.lock_tree');
4368 4361
 			}
4369
-			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4362
+			$this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately');
4370 4363
 
4371 4364
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4372
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4365
+			$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
4373 4366
 			$fStatus = array(
4374 4367
 				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4375 4368
 			);
4376 4369
 			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4377 4370
 			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4378
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4371
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4379 4372
 		}
4380 4373
 		if ($rememberServerID != $this->mail_bo->profileID)
4381 4374
 		{
4382
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4383
-			$response->call('egw.message',lang('empty junk'));
4384
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4375
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false);
4376
+			$response->call('egw.message', lang('empty junk'));
4377
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4385 4378
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4386 4379
 			$this->changeProfile($rememberServerID);
4387 4380
 		}
4388 4381
 		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4389 4382
 		{
4390
-			$response->call('egw.refresh',lang('empty junk'),'mail');
4383
+			$response->call('egw.refresh', lang('empty junk'), 'mail');
4391 4384
 		}
4392 4385
 	}
4393 4386
 
@@ -4410,7 +4403,7 @@  discard block
 block discarded – undo
4410 4403
 			$this->changeProfile($icServerID);
4411 4404
 		}
4412 4405
 		$trashFolder = $this->mail_bo->getTrashFolder();
4413
-		if(!empty($trashFolder)) {
4406
+		if (!empty($trashFolder)) {
4414 4407
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4415 4408
 			{
4416 4409
 				// Lock the tree if the active folder is Trash folder
@@ -4419,25 +4412,25 @@  discard block
 block discarded – undo
4419 4412
 			$this->mail_bo->compressFolder($trashFolder);
4420 4413
 
4421 4414
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4422
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4415
+			$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
4423 4416
 			$fStatus = array(
4424 4417
 				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4425 4418
 			);
4426 4419
 			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4427 4420
 			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4428
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4421
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4429 4422
 		}
4430 4423
 		if ($rememberServerID != $this->mail_bo->profileID)
4431 4424
 		{
4432
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4433
-			$response->call('egw.message',lang('empty trash'));
4434
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4425
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false);
4426
+			$response->call('egw.message', lang('empty trash'));
4427
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4435 4428
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4436 4429
 			$this->changeProfile($rememberServerID);
4437 4430
 		}
4438 4431
 		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4439 4432
 		{
4440
-			$response->call('egw.refresh',lang('empty trash'),'mail');
4433
+			$response->call('egw.refresh', lang('empty trash'), 'mail');
4441 4434
 		}
4442 4435
 	}
4443 4436
 
@@ -4454,7 +4447,7 @@  discard block
 block discarded – undo
4454 4447
 
4455 4448
 		$this->mail_bo->restoreSessionData();
4456 4449
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4457
-		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4450
+		list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4458 4451
 
4459 4452
 		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4460 4453
 		if ($this->mail_bo->folderExists($folderName))
@@ -4465,7 +4458,7 @@  discard block
 block discarded – undo
4465 4458
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4466 4459
 				$this->changeProfile($icServerID);
4467 4460
 			}
4468
-			if(!empty($_folderName)) {
4461
+			if (!empty($_folderName)) {
4469 4462
 				$this->mail_bo->compressFolder($folderName);
4470 4463
 			}
4471 4464
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4474,7 +4467,7 @@  discard block
 block discarded – undo
4474 4467
 				$this->changeProfile($rememberServerID);
4475 4468
 			}
4476 4469
 			$response = Api\Json\Response::get();
4477
-			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
4470
+			$response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail');
4478 4471
 		}
4479 4472
 	}
4480 4473
 
@@ -4487,10 +4480,10 @@  discard block
 block discarded – undo
4487 4480
 	 */
4488 4481
 	function ajax_sendMDN($_messageList)
4489 4482
 	{
4490
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4483
+		if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4491 4484
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4492 4485
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4493
-		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
4486
+		$this->mail_bo->sendMDN($uidA['msgUID'], $folder);
4494 4487
 	}
4495 4488
 
4496 4489
 	/**
@@ -4502,14 +4495,14 @@  discard block
 block discarded – undo
4502 4495
 	 *
4503 4496
 	 * @return xajax response
4504 4497
 	 */
4505
-	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4498
+	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true)
4506 4499
 	{
4507
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4500
+		if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4508 4501
 		Api\Translation::add_app('mail');
4509
-		$alreadyFlagged=false;
4510
-		$flag2check='';
4502
+		$alreadyFlagged = false;
4503
+		$flag2check = '';
4511 4504
 		$filter2toggle = $query = array();
4512
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4505
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4513 4506
 		{
4514 4507
 			if (isset($_messageList['all']) && $_messageList['all'])
4515 4508
 			{
@@ -4519,34 +4512,34 @@  discard block
 block discarded – undo
4519 4512
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4520 4513
 				{
4521 4514
 					$query = $_messageList['activeFilters'];
4522
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4515
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4523 4516
 					{
4524 4517
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4525 4518
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4526 4519
 						{
4527
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4528
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4520
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4521
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4529 4522
 						}
4530 4523
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4531 4524
 						$cutoffdate = $cutoffdate2 = null;
4532
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4533
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4525
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4526
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4534 4527
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4535 4528
 						$filter = array(
4536
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4537
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4529
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4530
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4538 4531
 							'string' => $query['search'],
4539
-							'status' => 'any',//this is a status change. status will be manipulated later on
4532
+							'status' => 'any', //this is a status change. status will be manipulated later on
4540 4533
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4541 4534
 						);
4542
-						if ($query['enddate']||$query['startdate']) {
4535
+						if ($query['enddate'] || $query['startdate']) {
4543 4536
 							$filter['range'] = "BETWEEN";
4544 4537
 							if ($cutoffdate) {
4545
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4538
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4546 4539
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4547 4540
 							}
4548 4541
 							if ($cutoffdate2) {
4549
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4542
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4550 4543
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4551 4544
 							}
4552 4545
 						}
@@ -4559,12 +4552,12 @@  discard block
 block discarded – undo
4559 4552
 					// flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder
4560 4553
 					// should be affected serverside. here.
4561 4554
 					$messageList = $messageListForToggle = array();
4562
-					$flag2check = ($_flag=='read'?'seen':$_flag);
4563
-					if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4564
-						!($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))
4555
+					$flag2check = ($_flag == 'read' ? 'seen' : $_flag);
4556
+					if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4557
+						!($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))
4565 4558
 					{
4566 4559
 						$filter2toggle['status'] = array('un'.$_flag);
4567
-						if ($query['filter'] && $query['filter']!='any')
4560
+						if ($query['filter'] && $query['filter'] != 'any')
4568 4561
 						{
4569 4562
 							$filter2toggle['status'][] = $query['filter'];
4570 4563
 						}
@@ -4572,7 +4565,7 @@  discard block
 block discarded – undo
4572 4565
 						$reverse = 1;
4573 4566
 						$_sRt = $this->mail_bo->getSortedList(
4574 4567
 							$folder,
4575
-							$sort=0,
4568
+							$sort = 0,
4576 4569
 							$reverse,
4577 4570
 							$filter2toggle,
4578 4571
 							$rByUid,
@@ -4580,52 +4573,52 @@  discard block
 block discarded – undo
4580 4573
 						);
4581 4574
 						$messageListForToggle = $_sRt['match']->ids;
4582 4575
 						$filter['status'] = array($_flag);
4583
-						if ($query['filter'] && $query['filter'] !='any')
4576
+						if ($query['filter'] && $query['filter'] != 'any')
4584 4577
 						{
4585 4578
 							$filter['status'][] = $query['filter'];
4586 4579
 						}
4587
-						$rByUid=true;
4580
+						$rByUid = true;
4588 4581
 						$reverse = 1;
4589 4582
 						$_sR = $this->mail_bo->getSortedList(
4590 4583
 							$folder,
4591
-							$sort=0,
4584
+							$sort = 0,
4592 4585
 							$reverse,
4593 4586
 							$filter,
4594 4587
 							$rByUid,
4595 4588
 							false
4596 4589
 						);
4597 4590
 						$messageList = $_sR['match']->ids;
4598
-						if (count($messageListForToggle)>0)
4591
+						if (count($messageListForToggle) > 0)
4599 4592
 						{
4600 4593
 							$flag2set = (strtolower($_flag));
4601
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4602
-							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4594
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4595
+							$this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder);
4603 4596
 						}
4604
-						if (count($messageList)>0)
4597
+						if (count($messageList) > 0)
4605 4598
 						{
4606 4599
 							$flag2set = 'un'.$_flag;
4607
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4608
-							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4600
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4601
+							$this->mail_bo->flagMessages($flag2set, $messageList, $folder);
4609 4602
 						}
4610
-						$alreadyFlagged=true;
4603
+						$alreadyFlagged = true;
4611 4604
 					}
4612 4605
 					elseif (!empty($filter) &&
4613
-						(!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) ||
4614
-						(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4615
-						($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
4606
+						(!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) ||
4607
+						(in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4608
+						($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))))
4616 4609
 					{
4617
-						if ($query['filter'] && $query['filter'] !='any')
4610
+						if ($query['filter'] && $query['filter'] != 'any')
4618 4611
 						{
4619 4612
 							$filter['status'] = $query['filter'];
4620 4613
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4621
-							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4614
+							$_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag)));
4622 4615
 						}
4623
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4616
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4624 4617
 						$rByUid = true;
4625 4618
 						$reverse = 1;
4626 4619
 						$_sR = $this->mail_bo->getSortedList(
4627 4620
 							$folder,
4628
-							$sort=0,
4621
+							$sort = 0,
4629 4622
 							$reverse,
4630 4623
 							$filter,
4631 4624
 							$rByUid,
@@ -4637,8 +4630,8 @@  discard block
 block discarded – undo
4637 4630
 					}
4638 4631
 					else
4639 4632
 					{
4640
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4641
-						$alreadyFlagged=true;
4633
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4634
+						$alreadyFlagged = true;
4642 4635
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4643 4636
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4644 4637
 						$this->mail_bo->flagMessages($_flag, 'all', $folder);
@@ -4652,41 +4645,41 @@  discard block
 block discarded – undo
4652 4645
 			}
4653 4646
 			if (!$alreadyFlagged)
4654 4647
 			{
4655
-				foreach($_messageList['msg'] as $rowID)
4648
+				foreach ($_messageList['msg'] as $rowID)
4656 4649
 				{
4657 4650
 					$hA = self::splitRowID($rowID);
4658 4651
 					$messageList[] = $hA['msgUID'];
4659 4652
 				}
4660
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
4661
-				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4653
+				if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList)));
4654
+				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder);
4662 4655
 			}
4663 4656
 		}
4664 4657
 		else
4665 4658
 		{
4666
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4659
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4667 4660
 		}
4668 4661
 
4669 4662
 		if ($_sendJsonResponse)
4670 4663
 		{
4671
-			$flag=array(
4672
-				'label1'	=> 'important',//lang('important'),
4673
-				'label2'	=> 'job',	//lang('job'),
4674
-				'label3'	=> 'personal',//lang('personal'),
4675
-				'label4'	=> 'to do',	//lang('to do'),
4676
-				'label5'	=> 'later',	//lang('later'),
4664
+			$flag = array(
4665
+				'label1'	=> 'important', //lang('important'),
4666
+				'label2'	=> 'job', //lang('job'),
4667
+				'label3'	=> 'personal', //lang('personal'),
4668
+				'label4'	=> 'to do', //lang('to do'),
4669
+				'label5'	=> 'later', //lang('later'),
4677 4670
 			);
4678 4671
 			$response = Api\Json\Response::get();
4679 4672
 			if (isset($_messageList['msg']) && $_messageList['popup'])
4680 4673
 			{
4681
-				$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');
4674
+				$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');
4682 4675
 			}
4683
-			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
4676
+			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))
4684 4677
 			{
4685
-				$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');
4678
+				$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');
4686 4679
 			}
4687 4680
 			else
4688 4681
 			{
4689
-				$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));
4682
+				$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));
4690 4683
 			}
4691 4684
 		}
4692 4685
 	}
@@ -4698,12 +4691,12 @@  discard block
 block discarded – undo
4698 4691
 	 * @param string _forceDeleteMethod - method of deletion to be enforced
4699 4692
 	 * @return xajax response
4700 4693
 	 */
4701
-	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4694
+	function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null)
4702 4695
 	{
4703
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
4696
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod);
4704 4697
 		$error = null;
4705
-		$filtered =  false;
4706
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4698
+		$filtered = false;
4699
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4707 4700
 		{
4708 4701
 			if (isset($_messageList['all']) && $_messageList['all'])
4709 4702
 			{
@@ -4713,34 +4706,34 @@  discard block
 block discarded – undo
4713 4706
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4714 4707
 				{
4715 4708
 					$query = $_messageList['activeFilters'];
4716
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4709
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4717 4710
 					{
4718 4711
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4719 4712
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4720 4713
 						{
4721
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4722
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4714
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4715
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4723 4716
 						}
4724
-						$filtered =  true;
4717
+						$filtered = true;
4725 4718
 						$cutoffdate = $cutoffdate2 = null;
4726
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4727
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4719
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4720
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4728 4721
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4729 4722
 						$filter = array(
4730
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4731
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4723
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4724
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4732 4725
 							'string' => $query['search'],
4733
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4726
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4734 4727
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4735 4728
 						);
4736
-						if ($query['enddate']||$query['startdate']) {
4729
+						if ($query['enddate'] || $query['startdate']) {
4737 4730
 							$filter['range'] = "BETWEEN";
4738 4731
 							if ($cutoffdate) {
4739
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4732
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4740 4733
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4741 4734
 							}
4742 4735
 							if ($cutoffdate2) {
4743
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4736
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4744 4737
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4745 4738
 							}
4746 4739
 						}
@@ -4754,7 +4747,7 @@  discard block
 block discarded – undo
4754 4747
 					$rByUid = true;
4755 4748
 					$_sR = $this->mail_bo->getSortedList(
4756 4749
 						$folder,
4757
-						$sort=0,
4750
+						$sort = 0,
4758 4751
 						$reverse,
4759 4752
 						$filter,
4760 4753
 						$rByUid,
@@ -4764,23 +4757,23 @@  discard block
 block discarded – undo
4764 4757
 				}
4765 4758
 				else
4766 4759
 				{
4767
-					$messageList='all';
4760
+					$messageList = 'all';
4768 4761
 				}
4769 4762
 				try
4770 4763
 				{
4771 4764
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4772
-					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4765
+					$this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4773 4766
 				}
4774 4767
 				catch (Api\Exception $e)
4775 4768
 				{
4776
-					$error = str_replace('"',"'",$e->getMessage());
4769
+					$error = str_replace('"', "'", $e->getMessage());
4777 4770
 				}
4778 4771
 			}
4779 4772
 			else
4780 4773
 			{
4781 4774
 				$uidA = self::splitRowID($_messageList['msg'][0]);
4782 4775
 				$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4783
-				foreach($_messageList['msg'] as $rowID)
4776
+				foreach ($_messageList['msg'] as $rowID)
4784 4777
 				{
4785 4778
 					$hA = self::splitRowID($rowID);
4786 4779
 					$messageList[] = $hA['msgUID'];
@@ -4788,27 +4781,27 @@  discard block
 block discarded – undo
4788 4781
 				try
4789 4782
 				{
4790 4783
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4791
-					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4784
+					$this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4792 4785
 				}
4793 4786
 				catch (Api\Exception $e)
4794 4787
 				{
4795
-					$error = str_replace('"',"'",$e->getMessage());
4788
+					$error = str_replace('"', "'", $e->getMessage());
4796 4789
 				}
4797 4790
 			}
4798 4791
 			$response = Api\Json\Response::get();
4799 4792
 			if (empty($error))
4800 4793
 			{
4801
-				$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']));
4794
+				$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']));
4802 4795
 			}
4803 4796
 			else
4804 4797
 			{
4805
-				$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));
4806
-				$response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList));
4798
+				$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));
4799
+				$response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList));
4807 4800
 			}
4808 4801
 		}
4809 4802
 		else
4810 4803
 		{
4811
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4804
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4812 4805
 		}
4813 4806
 	}
4814 4807
 
@@ -4822,48 +4815,48 @@  discard block
 block discarded – undo
4822 4815
 	 *
4823 4816
 	 * @return xajax response
4824 4817
 	 */
4825
-	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4818
+	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_')
4826 4819
 	{
4827
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4820
+		if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4828 4821
 		Api\Translation::add_app('mail');
4829 4822
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4830 4823
 		// only copy or move are supported as method
4831
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
4832
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4824
+		if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy';
4825
+		list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2);
4833 4826
 		// check if move2archive was called with the correct archiveFolder
4834 4827
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
4835
-		if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder)
4828
+		if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder)
4836 4829
 		{
4837 4830
 			error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder");
4838 4831
 			$targetProfileID = $this->mail_bo->profileID;
4839 4832
 			$targetFolder = $archiveFolder;
4840 4833
 			error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder");
4841 4834
 		}
4842
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
4835
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
4843 4836
 		$changeFolderActions = false;
4844 4837
 		//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
4845 4838
 		//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
4846 4839
 		if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
4847 4840
 		{
4848 4841
 			//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]));
4849
-			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
4842
+			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3)
4850 4843
 			{
4851 4844
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4852
-				foreach( $keys as &$f)
4845
+				foreach ($keys as &$f)
4853 4846
 				{
4854
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4847
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4855 4848
 					else break;
4856 4849
 				}
4857 4850
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4858 4851
 			}
4859 4852
 			//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
4860
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName;
4853
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName;
4861 4854
 			$changeFolderActions = true;
4862 4855
 		}
4863 4856
 		$filtered = false;
4864
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4857
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4865 4858
 		{
4866
-			$error=false;
4859
+			$error = false;
4867 4860
 			if (isset($_messageList['all']) && $_messageList['all'])
4868 4861
 			{
4869 4862
 				// we have both messageIds AND allFlag folder information
@@ -4873,34 +4866,34 @@  discard block
 block discarded – undo
4873 4866
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4874 4867
 				{
4875 4868
 					$query = $_messageList['activeFilters'];
4876
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4869
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4877 4870
 					{
4878 4871
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4879 4872
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4880 4873
 						{
4881
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4882
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4874
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4875
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4883 4876
 						}
4884 4877
 						$filtered = true;
4885 4878
 						$cutoffdate = $cutoffdate2 = null;
4886
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4887
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4879
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4880
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4888 4881
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4889 4882
 						$filter = array(
4890
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4891
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4883
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4884
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4892 4885
 							'string' => $query['search'],
4893
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4886
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4894 4887
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4895 4888
 						);
4896
-						if ($query['enddate']||$query['startdate']) {
4889
+						if ($query['enddate'] || $query['startdate']) {
4897 4890
 							$filter['range'] = "BETWEEN";
4898 4891
 							if ($cutoffdate) {
4899
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4892
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4900 4893
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4901 4894
 							}
4902 4895
 							if ($cutoffdate2) {
4903
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4896
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4904 4897
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4905 4898
 							}
4906 4899
 						}
@@ -4913,70 +4906,70 @@  discard block
 block discarded – undo
4913 4906
 					$rByUid = true;
4914 4907
 					$_sR = $this->mail_bo->getSortedList(
4915 4908
 						$folder,
4916
-						$sort=0,
4909
+						$sort = 0,
4917 4910
 						$reverse,
4918 4911
 						$filter,
4919
-						$rByUid=true,
4912
+						$rByUid = true,
4920 4913
 						false
4921 4914
 					);
4922 4915
 					$messageList = $_sR['match']->ids;
4923
-					foreach($messageList as $uID)
4916
+					foreach ($messageList as $uID)
4924 4917
 					{
4925 4918
 						//error_log(__METHOD__.__LINE__.$uID);
4926
-						if ($_copyOrMove=='move')
4919
+						if ($_copyOrMove == 'move')
4927 4920
 						{
4928
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false);
4921
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false);
4929 4922
 						}
4930 4923
 					}
4931 4924
 				}
4932 4925
 				else
4933 4926
 				{
4934
-					$messageList='all';
4927
+					$messageList = 'all';
4935 4928
 				}
4936 4929
 				try
4937 4930
 				{
4938 4931
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4939
-					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4932
+					$this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4940 4933
 				}
4941 4934
 				catch (Api\Exception $e)
4942 4935
 				{
4943
-					$error = str_replace('"',"'",$e->getMessage());
4936
+					$error = str_replace('"', "'", $e->getMessage());
4944 4937
 				}
4945 4938
 			}
4946 4939
 			else
4947 4940
 			{
4948 4941
 				$messageList = array();
4949
-				while(count($_messageList['msg']) > 0)
4942
+				while (count($_messageList['msg']) > 0)
4950 4943
 				{
4951 4944
 					$uidA = self::splitRowID($_messageList['msg'][0]);
4952 4945
 					$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4953 4946
 					$sourceProfileID = $uidA['profileID'];
4954 4947
 					$moveList = array();
4955
-					foreach($_messageList['msg'] as $rowID)
4948
+					foreach ($_messageList['msg'] as $rowID)
4956 4949
 					{
4957 4950
 						$hA = self::splitRowID($rowID);
4958 4951
 
4959 4952
 						// If folder changes, stop and move what we've got
4960
-						if($hA['folder'] != $folder) break;
4953
+						if ($hA['folder'] != $folder) break;
4961 4954
 
4962 4955
 						array_shift($_messageList['msg']);
4963 4956
 						$messageList[] = $hA['msgUID'];
4964 4957
 						$moveList[] = $hA['msgUID'];
4965
-						if ($_copyOrMove=='move')
4958
+						if ($_copyOrMove == 'move')
4966 4959
 						{
4967
-							$helpvar = explode(self::$delimiter,$rowID);
4960
+							$helpvar = explode(self::$delimiter, $rowID);
4968 4961
 							array_shift($helpvar);
4969
-							$messageListForRefresh[]= implode(self::$delimiter,$helpvar);
4962
+							$messageListForRefresh[] = implode(self::$delimiter, $helpvar);
4970 4963
 						}
4971 4964
 					}
4972 4965
 					try
4973 4966
 					{
4974 4967
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4975
-						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4968
+						$this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4976 4969
 					}
4977 4970
 					catch (Api\Exception $e)
4978 4971
 					{
4979
-						$error = str_replace('"',"'",$e->getMessage());
4972
+						$error = str_replace('"', "'", $e->getMessage());
4980 4973
 					}
4981 4974
 				}
4982 4975
 			}
@@ -4989,30 +4982,30 @@  discard block
 block discarded – undo
4989 4982
 					unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]);
4990 4983
 					$changeFolderActions = true;
4991 4984
 				}
4992
-				$response->call('egw.message',$error,"error");
4985
+				$response->call('egw.message', $error, "error");
4993 4986
 			}
4994 4987
 			else
4995 4988
 			{
4996
-				if ($_copyOrMove=='copy')
4989
+				if ($_copyOrMove == 'copy')
4997 4990
 				{
4998
-					$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));
4991
+					$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));
4999 4992
 				}
5000 4993
 				else
5001 4994
 				{
5002
-					$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');
4995
+					$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');
5003 4996
 				}
5004 4997
 			}
5005 4998
 			if ($changeFolderActions == true)
5006 4999
 			{
5007 5000
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
5008
-				Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
5001
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
5009 5002
 				$actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions());
5010
-				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
5003
+				$response->call('app.mail.mail_rebuildActionsOnList', $actionsnew);
5011 5004
 			}
5012 5005
 		}
5013 5006
 		else
5014 5007
 		{
5015
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5008
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5016 5009
 		}
5017 5010
 	}
5018 5011
 
@@ -5022,11 +5015,11 @@  discard block
 block discarded – undo
5022 5015
 	 *
5023 5016
 	 * @param type $_id
5024 5017
 	 */
5025
-	function ajax_folderMgmtTree_autoloading ($_id = null)
5018
+	function ajax_folderMgmtTree_autoloading($_id = null)
5026 5019
 	{
5027 5020
 		$mail_ui = new mail_ui();
5028
-		$id = $_id? $_id : $_GET['id'];
5029
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false));
5021
+		$id = $_id ? $_id : $_GET['id'];
5022
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false));
5030 5023
 	}
5031 5024
 
5032 5025
 	/**
@@ -5034,15 +5027,15 @@  discard block
 block discarded – undo
5034 5027
 	 *
5035 5028
 	 * @param array $content content of dialog
5036 5029
 	 */
5037
-	function folderManagement (array $content = null)
5030
+	function folderManagement(array $content = null)
5038 5031
 	{
5039 5032
 		$dtmpl = new Etemplate('mail.folder_management');
5040
-		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
5041
-		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
5033
+		$profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id'];
5034
+		$sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false);
5042 5035
 
5043 5036
 		if (!is_array($content))
5044 5037
 		{
5045
-			$content = array ('acc_id' => $profileID);
5038
+			$content = array('acc_id' => $profileID);
5046 5039
 		}
5047 5040
 
5048 5041
 		$readonlys = array();
@@ -5050,7 +5043,7 @@  discard block
 block discarded – undo
5050 5043
 		$preserv = array(
5051 5044
 			'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side
5052 5045
 		);
5053
-		$dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2);
5046
+		$dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2);
5054 5047
 	}
5055 5048
 
5056 5049
 	/**
@@ -5060,11 +5053,11 @@  discard block
 block discarded – undo
5060 5053
 	 *
5061 5054
 	 * @param type $_folderName
5062 5055
 	 */
5063
-	function ajax_folderMgmt_delete ($_folderName)
5056
+	function ajax_folderMgmt_delete($_folderName)
5064 5057
 	{
5065 5058
 		if ($_folderName)
5066 5059
 		{
5067
-			$success = $this->ajax_deleteFolder($_folderName,true);
5060
+			$success = $this->ajax_deleteFolder($_folderName, true);
5068 5061
 			$response = Api\Json\Response::get();
5069 5062
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
5070 5063
 			if ($success)
@@ -5073,7 +5066,7 @@  discard block
 block discarded – undo
5073 5066
 			}
5074 5067
 			else
5075 5068
 			{
5076
-				$res = lang("Failed to delete %1",$folderName);
5069
+				$res = lang("Failed to delete %1", $folderName);
5077 5070
 			}
5078 5071
 			$response->data($res);
5079 5072
 		}
Please login to merge, or discard this patch.