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