Completed
Push — 14.2 ( 83e303...4fee7b )
by Nathan
26:18
created
emailadmin/inc/class.emailadmin_imapbase.inc.php 1 patch
Spacing   +1066 added lines, -1067 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @array
96 96
 	 */
97
-	static $tidy_config = array('clean'=>false,'output-html'=>true,'join-classes'=>true,'join-styles'=>true,'show-body-only'=>"auto",'word-2000'=>true,'wrap'=>0);
97
+	static $tidy_config = array('clean'=>false, 'output-html'=>true, 'join-classes'=>true, 'join-styles'=>true, 'show-body-only'=>"auto", 'word-2000'=>true, 'wrap'=>0);
98 98
 
99 99
 	/**
100 100
 	 * static used to configure htmLawed, for use with emails
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 	static $htmLawed_config = array('comment'=>1, //remove comments
105 105
 		'make_tag_strict' => 3, // 3 is a new own config value, to indicate that transformation is to be performed, but don't transform font as size transformation of numeric sizes to keywords alters the intended result too much
106 106
 		'keep_bad'=>2, //remove tags but keep element content (4 and 6 keep element content only if text (pcdata) is valid in parent element as per specs, this may lead to textloss if balance is switched on)
107
-		'balance'=>1,//turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering)
107
+		'balance'=>1, //turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering)
108 108
 		'direct_list_nest' => 1,
109
-		'allow_for_inline' => array('table','div','li','p'),//block elements allowed for nesting when only inline is allowed; Example span does not allow block elements as table; table is the only element tested so far
109
+		'allow_for_inline' => array('table', 'div', 'li', 'p'), //block elements allowed for nesting when only inline is allowed; Example span does not allow block elements as table; table is the only element tested so far
110 110
 		// tidy eats away even some wanted whitespace, so we switch it off;
111 111
 		// we used it for its compacting and beautifying capabilities, which resulted in better html for further processing
112 112
 		'tidy'=>0,
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @array
123 123
 	 */
124
-	static $aclShortCuts = array('' => array('label'=>'none','title'=>'The user has no rights whatsoever.'),
125
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
126
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
127
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
128
-		'cdilprsw'	=> array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
129
-		'acdilprsw'	=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
130
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
124
+	static $aclShortCuts = array('' => array('label'=>'none', 'title'=>'The user has no rights whatsoever.'),
125
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
126
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
127
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
128
+		'cdilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
129
+		'acdilprsw'	=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
130
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
131 131
 	);
132 132
 
133 133
 	/**
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession
176 176
 	 * @return emailadmin_imapbase
177 177
 	 */
178
-	public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null)
178
+	public static function getInstance($_restoreSession = true, &$_profileID = 0, $_validate = true, $_oldImapServerObject = false, $_reuseCache = null)
179 179
 	{
180 180
 		//$_restoreSession=false;
181 181
 		if (is_null($_reuseCache)) $_reuseCache = $_restoreSession;
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 		{
186 186
 			if (!is_object(self::$instances[$_profileID]))
187 187
 			{
188
-				self::$instances[$_profileID] = new emailadmin_imapbase('utf-8',false,$_profileID,false,$_reuseCache);
188
+				self::$instances[$_profileID] = new emailadmin_imapbase('utf-8', false, $_profileID, false, $_reuseCache);
189 189
 			}
190 190
 			self::$instances[$_profileID]->icServer = $_oldImapServerObject;
191
-			self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId;
192
-			self::$instances[$_profileID]->profileID= $_oldImapServerObject->ImapServerId;
191
+			self::$instances[$_profileID]->accountid = $_oldImapServerObject->ImapServerId;
192
+			self::$instances[$_profileID]->profileID = $_oldImapServerObject->ImapServerId;
193 193
 			self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
194
-			self::$instances[$_profileID]->htmlOptions  = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
194
+			self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
195 195
 			return self::$instances[$_profileID];
196 196
 		}
197 197
 		if ($_profileID == 0)
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 			{
205 205
 				$profileID = emailadmin_account::get_default_acc_id();
206 206
 			}
207
-			if ($profileID!=$_profileID) $_restoreSession==false;
208
-			$_profileID=$profileID;
207
+			if ($profileID != $_profileID) $_restoreSession == false;
208
+			$_profileID = $profileID;
209 209
 			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace());
210 210
 		}
211 211
 		// no validation or restoreSession for old ImapServer Object, just fetch it and return it
212
-		if ($_oldImapServerObject===true)
212
+		if ($_oldImapServerObject === true)
213 213
 		{
214
-			return new emailadmin_imapbase('utf-8',false,$_profileID,true,$_reuseCache);
214
+			return new emailadmin_imapbase('utf-8', false, $_profileID, true, $_reuseCache);
215 215
 		}
216 216
 		if ($_profileID != 0 && $_validate)
217 217
 		{
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 			//egw_cache::setSession('mail','activeProfileID',$_profileID);
232 232
 		}
233 233
 		//error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace());
234
-		if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession===false))
234
+		if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession === false))
235 235
 		{
236
-			self::$instances[$_profileID] = new emailadmin_imapbase('utf-8',$_restoreSession,$_profileID,false,$_reuseCache);
236
+			self::$instances[$_profileID] = new emailadmin_imapbase('utf-8', $_restoreSession, $_profileID, false, $_reuseCache);
237 237
 		}
238 238
 		else
239 239
 		{
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 				self::$instances[$_profileID]->ogServer = emailadmin_account::read($_profileID)->smtpServer();
245 245
 				// TODO: merge mailprefs into userprefs, for easy treatment
246 246
 				self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
247
-				self::$instances[$_profileID]->htmlOptions  = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
247
+				self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions'];
248 248
 			} catch (egw_exception $e)
249 249
 			{
250 250
 				$newprofileID = emailadmin_account::get_default_acc_id();
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 				error_log(__METHOD__.' ('.__LINE__.') '." Loading the Profile for ProfileID ".$_profileID.' failed for icServer; '.$e->getMessage().' Trigger new instance for Default-Profile '.$newprofileID.'. called from:'.function_backtrace());
253 253
 				if ($newprofileID)
254 254
 				{
255
-					self::$instances[$newprofileID] = new emailadmin_imapbase('utf-8',false,$newprofileID,false,$_reuseCache);
255
+					self::$instances[$newprofileID] = new emailadmin_imapbase('utf-8', false, $newprofileID, false, $_reuseCache);
256 256
 					$_profileID = $newprofileID;
257 257
 				}
258 258
 				else
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 					throw $e;
261 261
 				}
262 262
 			}
263
-			self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate );
263
+			self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate);
264 264
 		}
265 265
 		self::$instances[$_profileID]->profileID = $_profileID;
266 266
 		if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new egw_idna;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @param boolean $_testConnection = 0
277 277
 	 * @return mixed $_profileID or false on failed ConnectionTest
278 278
 	 */
279
-	public static function storeActiveProfileIDToPref($_icServerObject, $_profileID=0, $_testConnection=true)
279
+	public static function storeActiveProfileIDToPref($_icServerObject, $_profileID = 0, $_testConnection = true)
280 280
 	{
281 281
 		if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) && !empty($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']))
282 282
 		{
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 		}
298 298
 		if ($oldProfileID != $_profileID)
299 299
 		{
300
-			if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID;
301
-			$GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user');
300
+			if ($oldProfileID && $_profileID == 0) $_profileID = $oldProfileID;
301
+			$GLOBALS['egw']->preferences->add('mail', 'ActiveProfileID', $_profileID, 'user');
302 302
 			// save prefs
303 303
 			$GLOBALS['egw']->preferences->save_repository(true);
304 304
 			$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $_profileID;
305
-			egw_cache::setSession('mail','activeProfileID',$_profileID);
305
+			egw_cache::setSession('mail', 'activeProfileID', $_profileID);
306 306
 		}
307 307
 		return $_profileID;
308 308
 	}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @param int $_acc_id = 0
318 318
 	 * @return int validated acc_id -> either acc_id given, or first valid one
319 319
 	 */
320
-	public static function validateProfileID($_acc_id=0)
320
+	public static function validateProfileID($_acc_id = 0)
321 321
 	{
322 322
 		if ($_acc_id)
323 323
 		{
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 		// no account specified or specified account not found or not valid
338 338
 		// --> search existing account for first valid one and return that
339
-		foreach(emailadmin_account::search($only_current_user=true, 'acc_imap_host') as $acc_id => $imap_host)
339
+		foreach (emailadmin_account::search($only_current_user = true, 'acc_imap_host') as $acc_id => $imap_host)
340 340
 		{
341 341
 			if (!empty($imap_host) && ($account = emailadmin_account::read($acc_id)) && $account->is_imap())
342 342
 			{
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @param boolean $_oldImapServerObject = false
359 359
 	 * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession
360 360
 	 */
361
-	private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null)
361
+	private function __construct($_displayCharset = 'utf-8', $_restoreSession = true, $_profileID = 0, $_oldImapServerObject = false, $_reuseCache = null)
362 362
 	{
363 363
 		if (is_null($_reuseCache)) $_reuseCache = $_restoreSession;
364 364
 		if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			$firstMessage = $this->sessionData['previewMessage'];
379 379
 			$this->sessionData = array();
380 380
 		}
381
-		if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache);
381
+		if (!$_reuseCache) $this->forcePrefReload($_profileID, !$_reuseCache);
382 382
 		try
383 383
 		{
384 384
 			$this->profileID = self::validateProfileID($_profileID);
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
 		}
390 390
 		catch (Exception $e)
391 391
 		{
392
-			throw new egw_exception(__METHOD__." failed to instanciate emailadmin_imapbase for $_profileID / ".$this->profileID." with error:".$e->getMessage());;
392
+			throw new egw_exception(__METHOD__." failed to instanciate emailadmin_imapbase for $_profileID / ".$this->profileID." with error:".$e->getMessage()); ;
393 393
 		}
394 394
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($acc->imapServer()));
395
-		$this->icServer = ($_oldImapServerObject?$acc->oldImapServer():$acc->imapServer());
395
+		$this->icServer = ($_oldImapServerObject ? $acc->oldImapServer() : $acc->imapServer());
396 396
 		$this->ogServer = $acc->smtpServer();
397 397
 		// TODO: merge mailprefs into userprefs, for easy treatment
398 398
 		$this->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
399
-		$this->htmlOptions  = $this->mailPreferences['htmlOptions'];
399
+		$this->htmlOptions = $this->mailPreferences['htmlOptions'];
400 400
 		if (isset($this->icServer->ImapServerId) && !empty($this->icServer->ImapServerId))
401 401
 		{
402 402
 			$_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId;
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	public static function &forceEAProfileLoad($_profile_id)
416 416
 	{
417 417
 		self::unsetCachedObjects($_profile_id);
418
-		$mail = emailadmin_imapbase::getInstance(false, $_profile_id,false);
418
+		$mail = emailadmin_imapbase::getInstance(false, $_profile_id, false);
419 419
 		//_debug_array( $_profile_id);
420 420
 		$mail->icServer = emailadmin_account::read($_profile_id)->imapServer();
421 421
 		$mail->ogServer = emailadmin_account::read($_profile_id)->smtpServer();
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 	 * @param int $_profile_id
428 428
 	 * @param boolean $_resetFolderObjects
429 429
 	 */
430
-	public static function forcePrefReload($_profile_id=null,$_resetFolderObjects=true)
430
+	public static function forcePrefReload($_profile_id = null, $_resetFolderObjects = true)
431 431
 	{
432 432
 		// unset the mail_preferences session object, to force the reload/rebuild
433
-		$GLOBALS['egw']->session->appsession('mail_preferences','mail',serialize(array()));
434
-		$GLOBALS['egw']->session->appsession('session_data','emailadmin',serialize(array()));
433
+		$GLOBALS['egw']->session->appsession('mail_preferences', 'mail', serialize(array()));
434
+		$GLOBALS['egw']->session->appsession('session_data', 'emailadmin', serialize(array()));
435 435
 		if ($_resetFolderObjects) emailadmin_imapbase::resetFolderObjectCache($_profile_id);
436 436
 	}
437 437
 
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	function restoreSessionData()
442 442
 	{
443
-		$this->sessionData = array();//egw_cache::getCache(egw_cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1);
444
-		self::$activeFolderCache = egw_cache::getCache(egw_cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
443
+		$this->sessionData = array(); //egw_cache::getCache(egw_cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1);
444
+		self::$activeFolderCache = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
445 445
 		if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID];
446 446
 	}
447 447
 
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
 	function saveSessionData()
452 452
 	{
453 453
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData)));
454
-		if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox'];
454
+		if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID] = $this->sessionData['mailbox'];
455 455
 		if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache))
456 456
 		{
457
-			egw_cache::setCache(egw_cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10);
457
+			egw_cache::setCache(egw_cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), self::$activeFolderCache, 60 * 60 * 10);
458 458
 		}
459 459
 	}
460 460
 
@@ -470,40 +470,40 @@  discard block
 block discarded – undo
470 470
 	 * @param int $_profileID = null default profile of user as returned by getUserDefaultProfileID
471 471
 	 * @return void
472 472
 	 */
473
-	static function unsetCachedObjects($_profileID=null)
473
+	static function unsetCachedObjects($_profileID = null)
474 474
 	{
475 475
 		if (is_null($_profileID)) $_profileID = emailadmin_account::get_default_acc_id();
476 476
 		if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id'];
477 477
 		//error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace());
478
-		if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false)))
478
+		if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID, 'tracker_') === false)))
479 479
 		{
480 480
 			self::resetConnectionErrorCache($_profileID);
481
-			$rawHeadersCache = egw_cache::getCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1);
481
+			$rawHeadersCache = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1);
482 482
 			if (isset($rawHeadersCache[$_profileID]))
483 483
 			{
484 484
 				unset($rawHeadersCache[$_profileID]);
485
-				egw_cache::setCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$rawHeadersCache, $expiration=60*60*1);
485
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $rawHeadersCache, $expiration = 60 * 60 * 1);
486 486
 			}
487
-			$HierarchyDelimiterCache = egw_cache::getCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*5);
487
+			$HierarchyDelimiterCache = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 5);
488 488
 			if (isset($HierarchyDelimiterCache[$_profileID]))
489 489
 			{
490 490
 				unset($HierarchyDelimiterCache[$_profileID]);
491
-				egw_cache::setCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$HierarchyDelimiterCache, $expiration=60*60*24*5);
491
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $HierarchyDelimiterCache, $expiration = 60 * 60 * 24 * 5);
492 492
 			}
493 493
 			//reset folderObject cache, to trigger reload
494 494
 			self::resetFolderObjectCache($_profileID);
495 495
 			//reset counter of deleted messages per folder
496
-			$eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1);
496
+			$eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1);
497 497
 			if (isset($eMailListContainsDeletedMessages[$_profileID]))
498 498
 			{
499 499
 				unset($eMailListContainsDeletedMessages[$_profileID]);
500
-				egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$eMailListContainsDeletedMessages, $expiration=60*60*1);
500
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $eMailListContainsDeletedMessages, $expiration = 60 * 60 * 1);
501 501
 			}
502
-			$vacationCached = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*1);
502
+			$vacationCached = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 1);
503 503
 			if (isset($vacationCached[$_profileID]))
504 504
 			{
505 505
 				unset($vacationCached[$_profileID]);
506
-				egw_cache::setCache(egw_cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1);
506
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $vacationCached, $expiration = 60 * 60 * 24 * 1);
507 507
 			}
508 508
 
509 509
 			if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]);
@@ -511,17 +511,17 @@  discard block
 block discarded – undo
511 511
 		if (is_array($_profileID) && $_profileID['location'] == 'clear_cache')
512 512
 		{
513 513
 			// called via hook
514
-			foreach($GLOBALS['egw']->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account)
514
+			foreach ($GLOBALS['egw']->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account)
515 515
 			{
516 516
 				//error_log(__METHOD__.__LINE__.array2string($account));
517 517
 				$account_id = $account['account_id'];
518 518
 				$_profileID = null;
519
-				self::resetConnectionErrorCache($_profileID,$account_id);
520
-				self::resetFolderObjectCache($_profileID,$account_id);
521
-				egw_cache::setCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),array(), 60*60*1);
522
-				egw_cache::setCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),array(), 60*60*24*5);
523
-				egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),array(), 60*60*1);
524
-				egw_cache::setCache(egw_cache::INSTANCE,'email','vacationNotice'.trim($account_id),array(), 60*60*24*1);
519
+				self::resetConnectionErrorCache($_profileID, $account_id);
520
+				self::resetFolderObjectCache($_profileID, $account_id);
521
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), array(), 60 * 60 * 1);
522
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), array(), 60 * 60 * 24 * 5);
523
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), array(), 60 * 60 * 1);
524
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), array(), 60 * 60 * 24 * 1);
525 525
 			}
526 526
 		}
527 527
 	}
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 * @param int $_ImapServerId the profileID to look for
533 533
 	 * @param int $account_id the egw account to look for
534 534
 	 */
535
-	static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null)
535
+	static function resetConnectionErrorCache($_ImapServerId = null, $account_id = null)
536 536
 	{
537 537
 		//error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id));
538 538
 		if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
@@ -550,19 +550,19 @@  discard block
 block discarded – undo
550 550
 		}
551 551
 		else
552 552
 		{
553
-			$isConError = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id));
553
+			$isConError = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id));
554 554
 			if (isset($isConError[$_ImapServerId]))
555 555
 			{
556 556
 				unset($isConError[$_ImapServerId]);
557 557
 			}
558
-			$waitOnFailure = egw_cache::getCache(egw_cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),null,array(),60*60*2);
558
+			$waitOnFailure = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), null, array(), 60 * 60 * 2);
559 559
 			if (isset($waitOnFailure[$_ImapServerId]))
560 560
 			{
561 561
 				unset($waitOnFailure[$_ImapServerId]);
562 562
 			}
563 563
 		}
564
-		egw_cache::setCache(egw_cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id),$isConError,60*15);
565
-		egw_cache::setCache(egw_cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),$waitOnFailure,60*60*2);
564
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id), $isConError, 60 * 15);
565
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), $waitOnFailure, 60 * 60 * 2);
566 566
 	}
567 567
 
568 568
 	/**
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 	 * @param int $_ImapServerId the profileID to look for
572 572
 	 * @param int $account_id the egw account to look for
573 573
 	 */
574
-	static function resetFolderObjectCache($_ImapServerId=null,$account_id=null)
574
+	static function resetFolderObjectCache($_ImapServerId = null, $account_id = null)
575 575
 	{
576 576
 		//error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace());
577 577
 		if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
578 578
 		// on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId
579 579
 		// or treat it as not given. we try that path
580
-		if (is_null($_ImapServerId)||is_array($_ImapServerId))
580
+		if (is_null($_ImapServerId) || is_array($_ImapServerId))
581 581
 		{
582 582
 			$folders2return = array();
583 583
 			$folderInfo = array();
@@ -586,12 +586,12 @@  discard block
 block discarded – undo
586 586
 		}
587 587
 		else
588 588
 		{
589
-			$folders2return = egw_cache::getCache(egw_cache::INSTANCE,'email','folderObjects'.trim($account_id),null,array(),60*60*1);
589
+			$folders2return = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), null, array(), 60 * 60 * 1);
590 590
 			if (!empty($folders2return) && isset($folders2return[$_ImapServerId]))
591 591
 			{
592 592
 				unset($folders2return[$_ImapServerId]);
593 593
 			}
594
-			$folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),null,array(),60*60*5);
594
+			$folderInfo = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), null, array(), 60 * 60 * 5);
595 595
 			if (!empty($folderInfo) && isset($folderInfo[$_ImapServerId]))
596 596
 			{
597 597
 				unset($folderInfo[$_ImapServerId]);
@@ -603,23 +603,23 @@  discard block
 block discarded – undo
603 603
 				unset($lastFolderUsedForMove[$_ImapServerId]);
604 604
 			}
605 605
 			*/
606
-			$folderBasicInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),null,array(),60*60*1);
606
+			$folderBasicInfo = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), null, array(), 60 * 60 * 1);
607 607
 			if (!empty($folderBasicInfo) && isset($folderBasicInfo[$_ImapServerId]))
608 608
 			{
609 609
 				unset($folderBasicInfo[$_ImapServerId]);
610 610
 			}
611
-			$_specialUseFolders = egw_cache::getCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($account_id),null,array(),60*60*12);
611
+			$_specialUseFolders = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), null, array(), 60 * 60 * 12);
612 612
 			if (!empty($_specialUseFolders) && isset($_specialUseFolders[$_ImapServerId]))
613 613
 			{
614 614
 				unset($_specialUseFolders[$_ImapServerId]);
615
-				self::$specialUseFolders=null;
615
+				self::$specialUseFolders = null;
616 616
 			}
617 617
 		}
618
-		egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($account_id),$folders2return, 60*60*1);
619
-		egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),$folderInfo,60*60*5);
618
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), $folders2return, 60 * 60 * 1);
619
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), $folderInfo, 60 * 60 * 5);
620 620
 		//egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($account_id),$lastFolderUsedForMove,$expiration=60*60*1);
621
-		egw_cache::setCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),$folderBasicInfo,60*60*1);
622
-		egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($account_id),$_specialUseFolders,60*60*12);
621
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), $folderBasicInfo, 60 * 60 * 1);
622
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), $_specialUseFolders, 60 * 60 * 12);
623 623
 	}
624 624
 
625 625
 	/**
@@ -640,14 +640,14 @@  discard block
 block discarded – undo
640 640
 	 * @param string $_profileID the ID of the mailaccount to check for identities, if null current mail-account is used
641 641
 	 * @return array - array(email=>realname)
642 642
 	 */
643
-	function getUserEMailAddresses($_profileID=null) {
644
-		$acc = emailadmin_account::read((!empty($_profileID)?$_profileID:$this->profileID));
643
+	function getUserEMailAddresses($_profileID = null) {
644
+		$acc = emailadmin_account::read((!empty($_profileID) ? $_profileID : $this->profileID));
645 645
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($acc));
646 646
 		$identities = $acc->identities();
647 647
 
648 648
 		$userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']);
649 649
 
650
-		foreach($identities as $ik => $ident) {
650
+		foreach ($identities as $ik => $ident) {
651 651
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
652 652
 			$identity = emailadmin_account::read_identity($ik);
653 653
 			if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
@@ -662,19 +662,19 @@  discard block
 block discarded – undo
662 662
 	 * @param boolean $resolve_placeholders wether or not resolve possible placeholders in identities
663 663
 	 * @return array - array(email=>realname)
664 664
 	 */
665
-	static function getAllIdentities($_accountToSearch=null,$resolve_placeholders=false) {
665
+	static function getAllIdentities($_accountToSearch = null, $resolve_placeholders = false) {
666 666
 		$userEMailAdresses = array();
667
-		foreach(emailadmin_account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name)
667
+		foreach (emailadmin_account::search($only_current_user = ($_accountToSearch ? $_accountToSearch : true), $just_name = true) as $acc_id => $identity_name)
668 668
 		{
669
-			$acc = emailadmin_account::read($acc_id,($_accountToSearch?$_accountToSearch:null));
670
-			if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
669
+			$acc = emailadmin_account::read($acc_id, ($_accountToSearch ? $_accountToSearch : null));
670
+			if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id, 'ident_id'=>$acc['ident_id'], 'ident_email'=>$acc['ident_email'], 'ident_org'=>$acc['ident_org'], 'ident_realname'=>$acc['ident_realname'], 'ident_signature'=>$acc['ident_signature'], 'ident_name'=>$acc['ident_name']);
671 671
 			$identities = $acc->identities($acc_id);
672 672
 
673
-			foreach($identities as $ik => $ident) {
673
+			foreach ($identities as $ik => $ident) {
674 674
 				//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
675
-				$identity = emailadmin_account::read_identity($ik,$resolve_placeholders);
675
+				$identity = emailadmin_account::read_identity($ik, $resolve_placeholders);
676 676
 				//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
677
-				if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']);
677
+				if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id, 'ident_id'=>$identity['ident_id'], 'ident_email'=>$identity['ident_email'], 'ident_org'=>$identity['ident_org'], 'ident_realname'=>$identity['ident_realname'], 'ident_signature'=>$identity['ident_signature'], 'ident_name'=>$identity['ident_name']);
678 678
 			}
679 679
 		}
680 680
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses));
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 		}
695 695
 		$userEMailAdresses = array();
696 696
 		$identities = $account->identities(null, true, 'params');
697
-		foreach($identities as $ik => $ident) {
697
+		foreach ($identities as $ik => $ident) {
698 698
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
699
-			$identity = emailadmin_account::read_identity($ik,true,null,$account);
699
+			$identity = emailadmin_account::read_identity($ik, true, null, $account);
700 700
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
701 701
 			// standardIdentity has ident_id==acc_id (as it is done within account->identities)
702 702
 			if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id'];
@@ -721,10 +721,10 @@  discard block
 block discarded – undo
721 721
 	 */
722 722
 	function getDefaultIdentity() {
723 723
 		// retrieve the signature accociated with the identity
724
-		$id = $this->getIdentitiesWithAccounts($_accountData=array());
724
+		$id = $this->getIdentitiesWithAccounts($_accountData = array());
725 725
 		$acc = emailadmin_account::read($this->profileID);
726
-		$accountDataIT = ($_accountData[$this->profileID]?$acc->identities($this->profileID,false,'ident_id'):$acc->identities($_accountData[$id],false,'ident_id'));
727
-		foreach($accountDataIT as $it => $accountData)
726
+		$accountDataIT = ($_accountData[$this->profileID] ? $acc->identities($this->profileID, false, 'ident_id') : $acc->identities($_accountData[$id], false, 'ident_id'));
727
+		foreach ($accountDataIT as $it => $accountData)
728 728
 		{
729 729
 			return $accountData;
730 730
 		}
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 	{
741 741
 		// account select box
742 742
 		$selectedID = $this->profileID;
743
-		$allAccountData = emailadmin_account::search($only_current_user=true, false, null);
743
+		$allAccountData = emailadmin_account::search($only_current_user = true, false, null);
744 744
 		if ($allAccountData) {
745
-			$rememberFirst=$selectedFound=null;
745
+			$rememberFirst = $selectedFound = null;
746 746
 			foreach ($allAccountData as $tmpkey => $icServers)
747 747
 			{
748 748
 				if (is_null($rememberFirst)) $rememberFirst = $tmpkey;
749
-				if ($tmpkey == $selectedID) $selectedFound=true;
749
+				if ($tmpkey == $selectedID) $selectedFound = true;
750 750
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host));
751 751
 				$host = $icServers->acc_imap_host;
752 752
 				if (empty($host)) continue;
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id]));
755 755
 			}
756 756
 		}
757
-		return ($selectedFound?$selectedID:$rememberFirst);
757
+		return ($selectedFound ? $selectedID : $rememberFirst);
758 758
 	}
759 759
 
760 760
 	/**
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 	 * @var boolean $fullString full or false=NamePart only is returned
765 765
 	 * @return string - constructed of identity object data as defined in mailConfig
766 766
 	 */
767
-	static function generateIdentityString($identity, $fullString=true)
767
+	static function generateIdentityString($identity, $fullString = true)
768 768
 	{
769 769
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity));
770 770
 		//if (is_null(self::$mailConfig)) self::$mailConfig = config::read('mail');
@@ -775,16 +775,16 @@  discard block
 block discarded – undo
775 775
 		{
776 776
 			case 'email';
777 777
 				//$retData = str_replace('@',' ',$identity->emailAddress).($fullString===true?' <'.$identity->emailAddress.'>':'');
778
-				$retData = $identity['ident_email'].($fullString===true?' <'.$identity['ident_email'].'>':'');
778
+				$retData = $identity['ident_email'].($fullString === true ? ' <'.$identity['ident_email'].'>' : '');
779 779
 				break;
780 780
 			case 'nameNemail';
781
-				$retData = (!empty($identity['ident_realname'])?$identity['ident_realname']:substr_replace($identity['ident_email'],'',strpos($identity['ident_email'],'@'))).($fullString===true?' <'.$identity['ident_email'].'>':'');
781
+				$retData = (!empty($identity['ident_realname']) ? $identity['ident_realname'] : substr_replace($identity['ident_email'], '', strpos($identity['ident_email'], '@'))).($fullString === true ? ' <'.$identity['ident_email'].'>' : '');
782 782
 				break;
783 783
 			case 'orgNemail';
784
-				$retData = (!empty($identity['ident_org'])?$identity['ident_org']:substr_replace($identity['ident_email'],'',0,strpos($identity['ident_email'],'@')+1)).($fullString===true?' <'.$identity['ident_email'].'>':'');
784
+				$retData = (!empty($identity['ident_org']) ? $identity['ident_org'] : substr_replace($identity['ident_email'], '', 0, strpos($identity['ident_email'], '@') + 1)).($fullString === true ? ' <'.$identity['ident_email'].'>' : '');
785 785
 				break;
786 786
 			default:
787
-				$retData = $identity['ident_realname'].(!empty($identity['ident_org'])?' '.$identity['ident_org']:'').($fullString===true?' <'.$identity['ident_email'].'>':'');
787
+				$retData = $identity['ident_realname'].(!empty($identity['ident_org']) ? ' '.$identity['ident_org'] : '').($fullString === true ? ' <'.$identity['ident_email'].'>' : '');
788 788
 		}
789 789
 		return $retData;
790 790
 	}
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 	 */
809 809
 	function reopen($_foldername)
810 810
 	{
811
-		if (self::$debugTimes) $starttime = microtime (true);
811
+		if (self::$debugTimes) $starttime = microtime(true);
812 812
 
813 813
 		//error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace());
814 814
 		// TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 			}
824 824
 			$folderOpened = $_foldername;
825 825
 		//}
826
-		if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') ');
826
+		if (self::$debugTimes) self::logRunTimes($starttime, null, 'Folder:'.$_foldername, __METHOD__.' ('.__LINE__.') ');
827 827
 	}
828 828
 
829 829
 
@@ -834,15 +834,15 @@  discard block
 block discarded – undo
834 834
 	 * @throws Horde_Imap_Client_Exception on connection error or authentication failure
835 835
 	 * @throws InvalidArgumentException on missing credentials
836 836
 	 */
837
-	function openConnection($_icServerID=0)
837
+	function openConnection($_icServerID = 0)
838 838
 	{
839 839
 		//error_log( "-------------------------->open connection ".function_backtrace());
840 840
 		//error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer));
841
-		if (self::$debugTimes) $starttime = microtime (true);
842
-		$mailbox=null;
841
+		if (self::$debugTimes) $starttime = microtime(true);
842
+		$mailbox = null;
843 843
 		try
844 844
 		{
845
-			if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox'];
845
+			if (isset($this->sessionData['mailbox']) && $this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox'];
846 846
 			if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox();
847 847
 /*
848 848
 			if (isset(emailadmin_imap::$supports_keywords[$_icServerID]))
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 			error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." failed!".$e->getMessage());
870 870
 			throw new egw_exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID :".$e->getMessage());
871 871
 		}
872
-		if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') ');
872
+		if (self::$debugTimes) self::logRunTimes($starttime, null, 'ProfileID:'.$_icServerID, __METHOD__.' ('.__LINE__.') ');
873 873
 	}
874 874
 
875 875
 	/**
@@ -883,13 +883,13 @@  discard block
 block discarded – undo
883 883
 		static $quota;
884 884
 		if (isset($quota)) return $quota;
885 885
 		$this->icServer->getCurrentMailbox();
886
-		if(!$this->icServer->hasCapability('QUOTA')) {
886
+		if (!$this->icServer->hasCapability('QUOTA')) {
887 887
 			$quota = false;
888 888
 			return false;
889 889
 		}
890 890
 		$quota = $this->icServer->getStorageQuotaRoot('INBOX');
891 891
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota));
892
-		if(is_array($quota)) {
892
+		if (is_array($quota)) {
893 893
 			$quota = array(
894 894
 				'usage'	=> $quota['USED'],
895 895
 				'limit'	=> $quota['QMAX'],
@@ -907,10 +907,10 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return int - timeout (either set or default 20/10)
909 909
 	 */
910
-	static function getTimeOut($_use='IMAP')
910
+	static function getTimeOut($_use = 'IMAP')
911 911
 	{
912 912
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
913
-		if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value
913
+		if (empty($timeout)) $timeout = ($_use == 'SIEVE' ? 10 : 20); // this is the default value
914 914
 		return $timeout;
915 915
 	}
916 916
 
@@ -929,18 +929,18 @@  discard block
 block discarded – undo
929 929
 		if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray();
930 930
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace));
931 931
 		if (is_array($nameSpace)) {
932
-			foreach($nameSpace as $type => $singleNameSpaceArray)
932
+			foreach ($nameSpace as $type => $singleNameSpaceArray)
933 933
 			{
934 934
 				foreach ($singleNameSpaceArray as $k => $singleNameSpace)
935 935
 				{
936 936
 					$_foldersNameSpace = array();
937
-					if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX')))
937
+					if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX')))
938 938
 					{
939 939
 						$_foldersNameSpace['prefix_present'] = 'forced';
940 940
 						// uw-imap server with mailbox prefix or dovecot maybe
941
-						$_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:''));
941
+						$_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : ''));
942 942
 					}
943
-					elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail'))
943
+					elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail'))
944 944
 					{
945 945
 						$_foldersNameSpace['prefix_present'] = 'forced';
946 946
 						// uw-imap server with mailbox prefix or dovecot maybe
@@ -949,9 +949,9 @@  discard block
 block discarded – undo
949 949
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
950 950
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
951 951
 					}
952
-					$_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter);
952
+					$_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter);
953 953
 					$_foldersNameSpace['type'] = $type;
954
-					$foldersNameSpace[] =$_foldersNameSpace;
954
+					$foldersNameSpace[] = $_foldersNameSpace;
955 955
 				}
956 956
 				//echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>";
957 957
 			}
@@ -968,10 +968,10 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	function getFolderPrefixFromNamespace($nameSpace, $folderName)
970 970
 	{
971
-		foreach($nameSpace as &$singleNameSpace)
971
+		foreach ($nameSpace as &$singleNameSpace)
972 972
 		{
973 973
 			//if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix'];
974
-			if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix'];
974
+			if (substr($folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
975 975
 		}
976 976
 		return "";
977 977
 	}
@@ -981,12 +981,12 @@  discard block
 block discarded – undo
981 981
 	 * @var boolean $_useCache
982 982
 	 * @return string the hierarchyDelimiter
983 983
 	 */
984
-	function getHierarchyDelimiter($_useCache=true)
984
+	function getHierarchyDelimiter($_useCache = true)
985 985
 	{
986 986
 		static $HierarchyDelimiter;
987
-		if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = egw_cache::getCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
988
-		if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
989
-		if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId]))
987
+		if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5);
988
+		if ($_useCache === false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
989
+		if (isset($HierarchyDelimiter[$this->icServer->ImapServerId]) && !empty($HierarchyDelimiter[$this->icServer->ImapServerId]))
990 990
 		{
991 991
 			return $HierarchyDelimiter[$this->icServer->ImapServerId];
992 992
 		}
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
 			$this->icServer->getCurrentMailbox();
997 997
 			$HierarchyDelimiter[$this->icServer->ImapServerId] = $this->icServer->getDelimiter();
998 998
 		}
999
-		catch(Exception $e)
999
+		catch (Exception $e)
1000 1000
 		{
1001 1001
 			$HierarchyDelimiter[$this->icServer->ImapServerId] = '/';
1002 1002
 		}
1003
-		egw_cache::setCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$HierarchyDelimiter, 60*60*24*5);
1003
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), $HierarchyDelimiter, 60 * 60 * 24 * 5);
1004 1004
 		return $HierarchyDelimiter[$this->icServer->ImapServerId];
1005 1005
 	}
1006 1006
 
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 	{
1014 1014
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected);
1015 1015
 		static $_specialUseFolders;
1016
-		if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = egw_cache::getCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
1016
+		if (is_null($_specialUseFolders) || empty($_specialUseFolders)) $_specialUseFolders = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5);
1017 1017
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash));
1018 1018
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent));
1019 1019
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft));
@@ -1021,19 +1021,19 @@  discard block
 block discarded – undo
1021 1021
 		self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
1022 1022
 		if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId]))
1023 1023
 			return $_specialUseFolders[$this->icServer->ImapServerId];
1024
-		$_specialUseFolders[$this->icServer->ImapServerId]=array();
1024
+		$_specialUseFolders[$this->icServer->ImapServerId] = array();
1025 1025
 		//if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]))
1026
-			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash';
1026
+			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash] = 'Trash';
1027 1027
 		//if (!empty($this->icServer->acc_folder_draft) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]))
1028
-			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts';
1028
+			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft] = 'Drafts';
1029 1029
 		//if (!empty($this->icServer->acc_folder_sent) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]))
1030
-			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent';
1030
+			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent] = 'Sent';
1031 1031
 		//if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]))
1032
-			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates';
1033
-		$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk';
1032
+			$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template] = 'Templates';
1033
+		$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk] = 'Junk';
1034 1034
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer));
1035 1035
 		self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
1036
-		egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5);
1036
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $_specialUseFolders, 60 * 60 * 24 * 5);
1037 1037
 		return $_specialUseFolders[$this->icServer->ImapServerId];
1038 1038
 	}
1039 1039
 
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
 	function folderIsSelectable($folderToSelect)
1050 1050
 	{
1051 1051
 		$retval = true;
1052
-		if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) {
1053
-			if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false)
1052
+		if ($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect, false, true))) {
1053
+			if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']), 'noselect') !== false)
1054 1054
 			{
1055 1055
 				$retval = false;
1056 1056
 			}
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @throws egw_exception
1072 1072
 	 */
1073
-	function _getStatus($folderName,$ignoreStatusCache=false)
1073
+	function _getStatus($folderName, $ignoreStatusCache = false)
1074 1074
 	{
1075 1075
 		static $folderStatus;
1076 1076
 		if (!$ignoreStatusCache && isset($folderStatus[$this->icServer->ImapServerId][$folderName]))
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		}
1081 1081
 		try
1082 1082
 		{
1083
-			$folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName,$ignoreStatusCache);
1083
+			$folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName, $ignoreStatusCache);
1084 1084
 		}
1085 1085
 		catch (Exception $e)
1086 1086
 		{
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	 * @param fetchSubscribedInfo bool fetch Subscribed Info on folder
1101 1101
 	 * @return array
1102 1102
 	 */
1103
-	function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true)
1103
+	function getFolderStatus($_folderName, $ignoreStatusCache = false, $basicInfoOnly = false, $fetchSubscribedInfo = true)
1104 1104
 	{
1105 1105
 		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly");
1106 1106
 		if (!is_string($_folderName) || empty($_folderName)) // something is wrong. Do not proceed
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 		{
1114 1114
 			$folderInfoCache = $folderBasicInfo[$this->profileID];
1115 1115
 		}
1116
-		if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName];
1116
+		if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache == false && $basicInfoOnly) return $folderInfoCache[$_folderName];
1117 1117
 		$retValue = array();
1118 1118
 		$retValue['subscribed'] = false;
1119 1119
 /*
@@ -1131,28 +1131,28 @@  discard block
 block discarded – undo
1131 1131
 			if (is_array($ret))
1132 1132
 			{
1133 1133
 				$retkeys = array_keys($ret);
1134
-				if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]];
1134
+				if ($retkeys[0] == $_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]];
1135 1135
 			}
1136 1136
 			else
1137 1137
 			{
1138
-				$folderInfoCache[$_folderName]=false;
1138
+				$folderInfoCache[$_folderName] = false;
1139 1139
 			}
1140 1140
 		}
1141 1141
 		$folderInfo = $folderInfoCache[$_folderName];
1142 1142
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace());
1143
-		if(!$folderInfo|| !is_array($folderInfo)) {
1143
+		if (!$folderInfo || !is_array($folderInfo)) {
1144 1144
 			try
1145 1145
 			{
1146
-				$folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache);
1146
+				$folderInfo = $this->_getStatus($_folderName, $ignoreStatusCache);
1147 1147
 			}
1148 1148
 			catch (Exception $e)
1149 1149
 			{
1150
-				$folderInfo=null;
1150
+				$folderInfo = null;
1151 1151
 			}
1152 1152
 			if (!is_array($folderInfo))
1153 1153
 			{
1154 1154
 				// no folder info, but there is a status returned for the folder: something is wrong, try to cope with it
1155
-				$folderInfo = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(),
1155
+				$folderInfo = is_array($folderInfo) ? $folderInfo : array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(),
1156 1156
 					'ATTRIBUTES' => '');
1157 1157
 				if (!isset($folderInfo['HIERACHY_DELIMITER']) || empty($folderInfo['HIERACHY_DELIMITER']) || (isset($folderInfo['delimiter']) && empty($folderInfo['delimiter'])))
1158 1158
 				{
@@ -1164,24 +1164,24 @@  discard block
 block discarded – undo
1164 1164
 		#if(!is_array($folderInfo)) {
1165 1165
 		#	return false;
1166 1166
 		#}
1167
-		$retValue['delimiter']		= (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER']?$folderInfo['HIERACHY_DELIMITER']:$folderInfo['delimiter']);
1168
-		$retValue['attributes']		= (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES']?$folderInfo['ATTRIBUTES']:$folderInfo['attributes']);
1169
-		$shortNameParts			= explode($retValue['delimiter'], $_folderName);
1167
+		$retValue['delimiter']		= (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER'] ? $folderInfo['HIERACHY_DELIMITER'] : $folderInfo['delimiter']);
1168
+		$retValue['attributes']		= (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES'] ? $folderInfo['ATTRIBUTES'] : $folderInfo['attributes']);
1169
+		$shortNameParts = explode($retValue['delimiter'], $_folderName);
1170 1170
 		$retValue['shortName']		= array_pop($shortNameParts);
1171 1171
 		$retValue['displayName']	= $_folderName;
1172
-		$retValue['shortDisplayName']	= $retValue['shortName'];
1173
-		if(strtoupper($retValue['shortName']) == 'INBOX') {
1174
-			$retValue['displayName']	= lang('INBOX');
1175
-			$retValue['shortDisplayName']	= lang('INBOX');
1172
+		$retValue['shortDisplayName'] = $retValue['shortName'];
1173
+		if (strtoupper($retValue['shortName']) == 'INBOX') {
1174
+			$retValue['displayName'] = lang('INBOX');
1175
+			$retValue['shortDisplayName'] = lang('INBOX');
1176 1176
 		}
1177 1177
 		// translate the automatic Folders (Sent, Drafts, ...) like the INBOX
1178
-		elseif (in_array($retValue['shortName'],self::$autoFolders))
1178
+		elseif (in_array($retValue['shortName'], self::$autoFolders))
1179 1179
 		{
1180 1180
 			$retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']);
1181 1181
 		}
1182
-		if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue;
1182
+		if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName] = $retValue;
1183 1183
 		//error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes']));
1184
-		if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false))
1184
+		if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']), 'noselect') !== false))
1185 1185
 		{
1186 1186
 			return $retValue;
1187 1187
 		}
@@ -1194,12 +1194,12 @@  discard block
 block discarded – undo
1194 1194
 		if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces();
1195 1195
 		if (!empty($nameSpace[$this->profileID]))
1196 1196
 		{
1197
-			$nsNoPersonal=array();
1198
-			foreach($nameSpace[$this->profileID] as &$ns)
1197
+			$nsNoPersonal = array();
1198
+			foreach ($nameSpace[$this->profileID] as &$ns)
1199 1199
 			{
1200
-				if ($ns['type']!='personal') $nsNoPersonal[]=$ns;
1200
+				if ($ns['type'] != 'personal') $nsNoPersonal[] = $ns;
1201 1201
 			}
1202
-			$nameSpace[$this->profileID]=$nsNoPersonal;
1202
+			$nameSpace[$this->profileID] = $nsNoPersonal;
1203 1203
 		}
1204 1204
 		if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName);
1205 1205
 
@@ -1208,32 +1208,32 @@  discard block
 block discarded – undo
1208 1208
 			$subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes();
1209 1209
 		}
1210 1210
 
1211
-		if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) {
1211
+		if ($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName, $subscribedFolders[$this->profileID])) {
1212 1212
 			$retValue['subscribed'] = true;
1213 1213
 		}
1214 1214
 
1215 1215
 		try
1216 1216
 		{
1217 1217
 			//$folderStatus = $this->_getStatus($_folderName,$ignoreStatusCache);
1218
-			$folderStatus = $this->getMailBoxCounters($_folderName,false);
1219
-			$retValue['messages']		= $folderStatus['MESSAGES'];
1218
+			$folderStatus = $this->getMailBoxCounters($_folderName, false);
1219
+			$retValue['messages'] = $folderStatus['MESSAGES'];
1220 1220
 			$retValue['recent']		= $folderStatus['RECENT'];
1221
-			$retValue['uidnext']		= $folderStatus['UIDNEXT'];
1222
-			$retValue['uidvalidity']	= $folderStatus['UIDVALIDITY'];
1221
+			$retValue['uidnext'] = $folderStatus['UIDNEXT'];
1222
+			$retValue['uidvalidity'] = $folderStatus['UIDVALIDITY'];
1223 1223
 			$retValue['unseen']		= $folderStatus['UNSEEN'];
1224 1224
 			if (//$retValue['unseen']==0 &&
1225 1225
 				(isset($this->mailPreferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information
1226
-				$this->mailPreferences['trustServersUnseenInfo']==false) ||
1226
+				$this->mailPreferences['trustServersUnseenInfo'] == false) ||
1227 1227
 				(isset($this->mailPreferences['trustServersUnseenInfo']) &&
1228
-				$this->mailPreferences['trustServersUnseenInfo']==2 &&
1229
-				$prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false)
1228
+				$this->mailPreferences['trustServersUnseenInfo'] == 2 &&
1229
+				$prefix[$this->profileID][$_folderName] != '' && stripos($_folderName, $prefix[$this->profileID][$_folderName]) !== false)
1230 1230
 			)
1231 1231
 			{
1232 1232
 				//error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']);
1233 1233
 				// we filter for the combined status of unseen and undeleted, as this is what we show in list
1234 1234
 				try
1235 1235
 				{
1236
-					$sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse=1, array('status'=>array('UNSEEN','UNDELETED')),$byUid=true,false);
1236
+					$sortResult = $this->getSortedList($_folderName, $_sort = 0, $_reverse = 1, array('status'=>array('UNSEEN', 'UNDELETED')), $byUid = true, false);
1237 1237
 					$retValue['unseen'] = $sortResult['count'];
1238 1238
 				}
1239 1239
 				catch (Exception $ee)
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 		}
1245 1245
 		catch (Exception $e)
1246 1246
 		{
1247
-			if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true));
1247
+			if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(), true));
1248 1248
 		}
1249 1249
 
1250 1250
 		return $retValue;
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 	 * @param boolean $_cacheResult = true try touse the cache of getSortedList
1266 1266
 	 * @return array result as array(header=>array,total=>int,first=>int,last=>int)
1267 1267
 	 */
1268
-	function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true)
1268
+	function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly = null, $_cacheResult = true)
1269 1269
 	{
1270 1270
 		//self::$debug=true;
1271 1271
 		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace());
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 		$rByUid = true; // try searching by uid. this var will be passed by reference to getSortedList, and may be set to false, if UID retrieval fails
1279 1279
 		#print "<pre>";
1280 1280
 		#$this->icServer->setDebug(true);
1281
-		$total=0;
1281
+		$total = 0;
1282 1282
 		if ($_thisUIDOnly === null)
1283 1283
 		{
1284 1284
 			if (($_startMessage || $_numberOfMessages) && !isset($_filter['range']))
@@ -1291,24 +1291,24 @@  discard block
 block discarded – undo
1291 1291
 				//$_filter['range'] ="$_startMessage:*";
1292 1292
 			}
1293 1293
 			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid");
1294
-			if (self::$debug||self::$debugTimes) $starttime = microtime (true);
1294
+			if (self::$debug || self::$debugTimes) $starttime = microtime(true);
1295 1295
 			//see this example below for a 12 week datefilter (since)
1296 1296
 			//$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12)));
1297 1297
 			$_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult);
1298 1298
 			$sortResult = $_sortResult['match']->ids;
1299 1299
 			//$modseq = $_sortResult['modseq'];
1300 1300
 			//error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq);
1301
-			if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') ');
1301
+			if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly), __METHOD__.' ('.__LINE__.') ');
1302 1302
 
1303 1303
 			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1304 1304
 			#$this->icServer->setDebug(false);
1305 1305
 			#print "</pre>";
1306 1306
 			// nothing found
1307
-			if(!is_array($sortResult) || empty($sortResult)) {
1307
+			if (!is_array($sortResult) || empty($sortResult)) {
1308 1308
 				$retValue = array();
1309 1309
 				$retValue['info']['total']	= 0;
1310 1310
 				$retValue['info']['first']	= 0;
1311
-				$retValue['info']['last']	= 0;
1311
+				$retValue['info']['last'] = 0;
1312 1312
 				return $retValue;
1313 1313
 			}
1314 1314
 
@@ -1316,54 +1316,54 @@  discard block
 block discarded – undo
1316 1316
 			#_debug_array($sortResult);
1317 1317
 			#_debug_array(array_slice($sortResult, -5, -2));
1318 1318
 			//error_log("REVERSE: $reverse");
1319
-			if($reverse === true) {
1320
-				if  ($_startMessage<=$total)
1319
+			if ($reverse === true) {
1320
+				if ($_startMessage <= $total)
1321 1321
 				{
1322
-					$startMessage = $_startMessage-1;
1322
+					$startMessage = $_startMessage - 1;
1323 1323
 				}
1324 1324
 				else
1325 1325
 				{
1326 1326
 					//error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total);
1327
-					if ($_startMessage+$_numberOfMessages>$total)
1327
+					if ($_startMessage + $_numberOfMessages > $total)
1328 1328
 					{
1329
-						$numberOfMessages = $total%$_numberOfMessages;
1329
+						$numberOfMessages = $total % $_numberOfMessages;
1330 1330
 						//$numberOfMessages = abs($_startMessage-$total-1);
1331
-						if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages;
1331
+						if ($numberOfMessages > 0 && $numberOfMessages <= $_numberOfMessages) $_numberOfMessages = $numberOfMessages;
1332 1332
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total);
1333 1333
 					}
1334
-					$startMessage=($total-$_numberOfMessages)-1;
1334
+					$startMessage = ($total - $_numberOfMessages) - 1;
1335 1335
 					//$retValue['info']['first'] = $startMessage;
1336 1336
 					//$retValue['info']['last'] = $total;
1337 1337
 
1338 1338
 				}
1339
-				if ($startMessage+$_numberOfMessages>$total)
1339
+				if ($startMessage + $_numberOfMessages > $total)
1340 1340
 				{
1341
-					$_numberOfMessages = $_numberOfMessages-($total-($startMessage+$_numberOfMessages));
1341
+					$_numberOfMessages = $_numberOfMessages - ($total - ($startMessage + $_numberOfMessages));
1342 1342
 					//$retValue['info']['first'] = $startMessage;
1343 1343
 					//$retValue['info']['last'] = $total;
1344 1344
 				}
1345
-				if($startMessage > 0) {
1346
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult));
1347
-					$sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage);
1345
+				if ($startMessage > 0) {
1346
+					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + $startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult));
1347
+					$sortResult = array_slice($sortResult, -($_numberOfMessages + $startMessage), -$startMessage);
1348 1348
 				} else {
1349
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult));
1350
-					$sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1)));
1349
+					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + ($_startMessage - 1))).', AllTheRest, Number of Messages:'.count($sortResult));
1350
+					$sortResult = array_slice($sortResult, -($_numberOfMessages + ($_startMessage - 1)));
1351 1351
 				}
1352 1352
 				$sortResult = array_reverse($sortResult);
1353 1353
 			} else {
1354
-				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult));
1355
-				$sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages);
1354
+				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage - 1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult));
1355
+				$sortResult = array_slice($sortResult, $_startMessage - 1, $_numberOfMessages);
1356 1356
 			}
1357 1357
 			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult));
1358 1358
 		}
1359 1359
 		else
1360 1360
 		{
1361
-			$sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly:(array)$_thisUIDOnly);
1361
+			$sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly : (array)$_thisUIDOnly);
1362 1362
 		}
1363 1363
 
1364 1364
 
1365 1365
 		// fetch the data for the selected messages
1366
-		if (self::$debug||self::$debugTimes) $starttime = microtime(true);
1366
+		if (self::$debug || self::$debugTimes) $starttime = microtime(true);
1367 1367
 		try
1368 1368
 		{
1369 1369
 			$uidsToFetch = new Horde_Imap_Client_Ids();
@@ -1372,20 +1372,20 @@  discard block
 block discarded – undo
1372 1372
 			$fquery = new Horde_Imap_Client_Fetch_Query();
1373 1373
 
1374 1374
 			// Pre-cache the headers we want, 'fetchHeaders' is a label into the cache
1375
-			$fquery->headers('fetchHeaders',array(
1376
-				'DISPOSITION-NOTIFICATION-TO','RETURN-RECEIPT-TO','X-CONFIRM-READING-TO',
1377
-				'DATE','SUBJECT','FROM','TO','CC',
1375
+			$fquery->headers('fetchHeaders', array(
1376
+				'DISPOSITION-NOTIFICATION-TO', 'RETURN-RECEIPT-TO', 'X-CONFIRM-READING-TO',
1377
+				'DATE', 'SUBJECT', 'FROM', 'TO', 'CC',
1378 1378
 				'X-PRIORITY'
1379
-			),array(
1379
+			), array(
1380 1380
 				// Cache headers, we'll look at them below
1381
-				'cache' => true,//$_cacheResult,
1381
+				'cache' => true, //$_cacheResult,
1382 1382
 				// Set peek so messages are not flagged as read
1383 1383
 				'peek' => true
1384 1384
 			));
1385 1385
 			$fquery->size();
1386 1386
 			$fquery->structure();
1387 1387
 			$fquery->flags();
1388
-			$fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time
1388
+			$fquery->imapDate(); // needed to ensure getImapDate fetches the internaldate, not the current time
1389 1389
 			$headersNew = $this->icServer->fetch($_folderName, $fquery, array(
1390 1390
 				'ids' => $uidsToFetch,
1391 1391
 			));
@@ -1396,9 +1396,9 @@  discard block
 block discarded – undo
1396 1396
 			$headersNew = array();
1397 1397
 			$sortResult = array();
1398 1398
 		}
1399
-		if (self::$debug||self::$debugTimes)
1399
+		if (self::$debug || self::$debugTimes)
1400 1400
 		{
1401
-			self::logRunTimes($starttime,null,'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter),__METHOD__.' ('.__LINE__.') ');
1401
+			self::logRunTimes($starttime, null, 'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter), __METHOD__.' ('.__LINE__.') ');
1402 1402
 			if (self::$debug)
1403 1403
 			{
1404 1404
 				$queryString = implode(',', $sortResult);
@@ -1408,28 +1408,28 @@  discard block
 block discarded – undo
1408 1408
 
1409 1409
 		$count = 0;
1410 1410
 
1411
-		foreach((array)$sortResult as $uid) {
1411
+		foreach ((array)$sortResult as $uid) {
1412 1412
 			$sortOrder[$uid] = $count++;
1413 1413
 		}
1414 1414
 
1415 1415
 		$count = 0;
1416 1416
 		if (is_object($headersNew)) {
1417
-			if (self::$debug||self::$debugTimes) $starttime = microtime(true);
1418
-			foreach($headersNew->ids() as $id) {
1417
+			if (self::$debug || self::$debugTimes) $starttime = microtime(true);
1418
+			foreach ($headersNew->ids() as $id) {
1419 1419
 				$_headerObject = $headersNew->get($id);
1420 1420
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject));
1421 1421
 				$headerObject = array();
1422
-				$uid = $headerObject['UID']= ($_headerObject->getUid()?$_headerObject->getUid():$id);
1422
+				$uid = $headerObject['UID'] = ($_headerObject->getUid() ? $_headerObject->getUid() : $id);
1423 1423
 				$headerObject['MSG_NUM'] = $_headerObject->getSeq();
1424 1424
 				$headerObject['SIZE'] = $_headerObject->getSize();
1425 1425
 				$headerObject['INTERNALDATE'] = $_headerObject->getImapDate();
1426 1426
 
1427 1427
 				// Get already cached headers, 'fetchHeaders' is a label matchimg above
1428
-				$headerForPrio = array_change_key_case($_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER);
1428
+				$headerForPrio = array_change_key_case($_headerObject->getHeaders('fetchHeaders', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER);
1429 1429
 				// Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com
1430
-				if (empty($headerForPrio)) $headerForPrio = array_change_key_case($_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER);
1430
+				if (empty($headerForPrio)) $headerForPrio = array_change_key_case($_headerObject->getHeaders('', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER);
1431 1431
 				if (self::$debug) {
1432
-					error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.egw_time::to($_headerObject->getImapDate(),'Y-m-d H:i:s'));
1432
+					error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.egw_time::to($_headerObject->getImapDate(), 'Y-m-d H:i:s'));
1433 1433
 					error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio));
1434 1434
 				}
1435 1435
 
@@ -1439,24 +1439,24 @@  discard block
 block discarded – undo
1439 1439
 					$total--;
1440 1440
 					continue;
1441 1441
 				}
1442
-				if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) {
1442
+				if (isset($headerForPrio['DISPOSITION-NOTIFICATION-TO'])) {
1443 1443
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO']));
1444
-				} else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) {
1444
+				} else if (isset($headerForPrio['RETURN-RECEIPT-TO'])) {
1445 1445
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO']));
1446
-				} else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) {
1446
+				} else if (isset($headerForPrio['X-CONFIRM-READING-TO'])) {
1447 1447
 					$headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO']));
1448 1448
 				} /*else $sent_not = "";*/
1449 1449
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject));
1450 1450
 				$headerObject['DATE'] = $headerForPrio['DATE'];
1451
-				$headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT'])?$headerForPrio['SUBJECT'][0]:$headerForPrio['SUBJECT']);
1452
-				$headerObject['FROM'] = (array)($headerForPrio['FROM']?$headerForPrio['FROM']:($headerForPrio['REPLY-TO']?$headerForPrio['REPLY-TO']:$headerForPrio['RETURN-PATH']));
1451
+				$headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT']) ? $headerForPrio['SUBJECT'][0] : $headerForPrio['SUBJECT']);
1452
+				$headerObject['FROM'] = (array)($headerForPrio['FROM'] ? $headerForPrio['FROM'] : ($headerForPrio['REPLY-TO'] ? $headerForPrio['REPLY-TO'] : $headerForPrio['RETURN-PATH']));
1453 1453
 				$headerObject['TO'] = (array)$headerForPrio['TO'];
1454
-				$headerObject['CC'] = isset($headerForPrio['CC'])?(array)$headerForPrio['CC']:array();
1455
-				$headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY'])?$headerForPrio['X-PRIORITY']:null;
1456
-				foreach (array('FROM','TO','CC') as $_k => $key)
1454
+				$headerObject['CC'] = isset($headerForPrio['CC']) ? (array)$headerForPrio['CC'] : array();
1455
+				$headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY']) ? $headerForPrio['X-PRIORITY'] : null;
1456
+				foreach (array('FROM', 'TO', 'CC') as $_k => $key)
1457 1457
 				{
1458 1458
 					$address = array();
1459
-					$remember=null;
1459
+					$remember = null;
1460 1460
 					foreach ($headerObject[$key] as $k => $ad)
1461 1461
 					{
1462 1462
 						//the commented section below IS a simplified version of the section "make sure ..."
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
 						foreach ($rfcAddr as $_rfcAddr)
1477 1477
 						{
1478 1478
 							if (!$_rfcAddr->valid)	continue; // skip. not a valid address
1479
-							$address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal);
1479
+							$address[] = imap_rfc822_write_address($_rfcAddr->mailbox, $_rfcAddr->host, $_rfcAddr->personal);
1480 1480
 						}
1481 1481
 					}
1482 1482
 					$headerObject[$key] = $address;
@@ -1486,12 +1486,12 @@  discard block
 block discarded – undo
1486 1486
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject));
1487 1487
 				//error_log(__METHOD__.' ('.__LINE__.') '.' MimeMap:'.array2string($mailStructureObject->contentTypeMap()));
1488 1488
 				//foreach ($_headerObject->getStructure()->getParts() as $p => $part)
1489
-				$headerObject['ATTACHMENTS']=null;
1490
-				$skipParts=array();
1491
-				$messageMimeType='';
1489
+				$headerObject['ATTACHMENTS'] = null;
1490
+				$skipParts = array();
1491
+				$messageMimeType = '';
1492 1492
 				foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type)
1493 1493
 				{
1494
-					if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type;
1494
+					if ($mime_id == 0 || $messageMimeType === '') $messageMimeType = $mime_type;
1495 1495
 					$part = $mailStructureObject->getPart($mime_id);
1496 1496
 					$partdisposition = $part->getDisposition();
1497 1497
 					$partPrimaryType = $part->getPrimaryType();
@@ -1502,28 +1502,28 @@  discard block
 block discarded – undo
1502 1502
 						// the presence of an cid does not necessarily indicate its inline. it may lack the needed
1503 1503
 						// link to show the image. Considering this: we "list" everything that matches the above criteria
1504 1504
 						// as attachment in order to not loose/miss information on our data
1505
-						$partdisposition='attachment';//($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment');
1505
+						$partdisposition = 'attachment'; //($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment');
1506 1506
 					}
1507
-					if ($mime_type=='message/rfc822')
1507
+					if ($mime_type == 'message/rfc822')
1508 1508
 					{
1509 1509
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap()));
1510
-						foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;}
1510
+						foreach ($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; }
1511 1511
 					}
1512 1512
 					//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts));
1513
-					if (array_key_exists($mime_id,$skipParts)) continue;
1514
-					if ($partdisposition=='attachment' ||
1515
-						($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs
1516
-						($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) ||
1517
-						($partdisposition=='inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text'))
1513
+					if (array_key_exists($mime_id, $skipParts)) continue;
1514
+					if ($partdisposition == 'attachment' ||
1515
+						($partdisposition == 'inline' && $partPrimaryType == 'image' && $mime_type == 'image/tiff') || // as we are not able to display tiffs
1516
+						($partdisposition == 'inline' && $partPrimaryType == 'image' && empty($cid)) ||
1517
+						($partdisposition == 'inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text'))
1518 1518
 					{
1519
-						$headerObject['ATTACHMENTS'][$mime_id]=$part->getAllDispositionParameters();
1520
-						$headerObject['ATTACHMENTS'][$mime_id]['mimeType']=$mime_type;
1521
-						$headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid;
1519
+						$headerObject['ATTACHMENTS'][$mime_id] = $part->getAllDispositionParameters();
1520
+						$headerObject['ATTACHMENTS'][$mime_id]['mimeType'] = $mime_type;
1521
+						$headerObject['ATTACHMENTS'][$mime_id]['uid'] = $uid;
1522 1522
 						$headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid;
1523
-						$headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id;
1524
-						if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName();
1525
-						if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') ||
1526
-							$headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef')
1523
+						$headerObject['ATTACHMENTS'][$mime_id]['partID'] = $mime_id;
1524
+						if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name'] = $part->getName();
1525
+						if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'], 'winmail.dat') ||
1526
+							$headerObject['ATTACHMENTS'][$mime_id]['mimeType'] == 'application/ms-tnef')
1527 1527
 						{
1528 1528
 							$headerObject['ATTACHMENTS'][$mime_id]['is_winmail'] = true;
1529 1529
 						}
@@ -1538,53 +1538,53 @@  discard block
 block discarded – undo
1538 1538
 				if (empty($headerObject['UID'])) continue;
1539 1539
 				//$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']);
1540 1540
 				// make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime
1541
-				if(substr($headerObject['DATE'],-2) === 'UT') {
1541
+				if (substr($headerObject['DATE'], -2) === 'UT') {
1542 1542
 					$headerObject['DATE'] .= 'C';
1543 1543
 				}
1544
-				if(substr($headerObject['INTERNALDATE'],-2) === 'UT') {
1544
+				if (substr($headerObject['INTERNALDATE'], -2) === 'UT') {
1545 1545
 					$headerObject['INTERNALDATE'] .= 'C';
1546 1546
 				}
1547 1547
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#');
1548 1548
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']);
1549
-				if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;}
1550
-				$retValue['header'][$sortOrder[$uid]]['subject']	= $this->decode_subject($headerObject['SUBJECT']);
1551
-				$retValue['header'][$sortOrder[$uid]]['size'] 		= $headerObject['SIZE'];
1552
-				$retValue['header'][$sortOrder[$uid]]['date']		= self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true);
1553
-				$retValue['header'][$sortOrder[$uid]]['internaldate']= self::_strtotime($headerObject['INTERNALDATE'],'ts',true);
1554
-				$retValue['header'][$sortOrder[$uid]]['mimetype']	= $messageMimeType;
1555
-				$retValue['header'][$sortOrder[$uid]]['id']		= $headerObject['MSG_NUM'];
1556
-				$retValue['header'][$sortOrder[$uid]]['uid']		= $headerObject['UID'];
1557
-				$retValue['header'][$sortOrder[$uid]]['priority']		= ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3);
1549
+				if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][] = $a; }
1550
+				$retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']);
1551
+				$retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE'];
1552
+				$retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE'] && !($headerObject['DATE'] == 'NIL') ? $headerObject['DATE'] : $headerObject['INTERNALDATE']), 'ts', true);
1553
+				$retValue['header'][$sortOrder[$uid]]['internaldate'] = self::_strtotime($headerObject['INTERNALDATE'], 'ts', true);
1554
+				$retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType;
1555
+				$retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM'];
1556
+				$retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID'];
1557
+				$retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY'] ? $headerObject['PRIORITY'] : 3);
1558 1558
 				//error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]]));
1559 1559
 				if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO'];
1560 1560
 				if (is_array($headerObject['FLAGS'])) {
1561
-					$retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject));
1561
+					$retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]], self::prepareFlagsArray($headerObject));
1562 1562
 				}
1563 1563
 				//error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from')));
1564
-				if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) {
1565
-					$retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true);
1564
+				if (is_array($headerObject['FROM']) && $headerObject['FROM'][0]) {
1565
+					$retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0], true);
1566 1566
 				}
1567
-				if(is_array($headerObject['TO']) && $headerObject['TO'][0]) {
1568
-					$retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true);
1569
-					if (count($headerObject['TO'])>1)
1567
+				if (is_array($headerObject['TO']) && $headerObject['TO'][0]) {
1568
+					$retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0], true);
1569
+					if (count($headerObject['TO']) > 1)
1570 1570
 					{
1571
-						$ki=0;
1572
-						foreach($headerObject['TO'] as $k => $add)
1571
+						$ki = 0;
1572
+						foreach ($headerObject['TO'] as $k => $add)
1573 1573
 						{
1574
-							if ($k==0) continue;
1574
+							if ($k == 0) continue;
1575 1575
 							//error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add));
1576
-							$retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true);
1576
+							$retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add, true);
1577 1577
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki]));
1578 1578
 							$ki++;
1579 1579
 						}
1580 1580
 					}
1581 1581
 				}
1582
-				if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) {
1583
-					$ki=0;
1584
-					foreach($headerObject['CC'] as $k => $add)
1582
+				if (is_array($headerObject['CC']) && count($headerObject['CC']) > 0) {
1583
+					$ki = 0;
1584
+					foreach ($headerObject['CC'] as $k => $add)
1585 1585
 					{
1586 1586
 						//error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add));
1587
-						$retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add,true);
1587
+						$retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add, true);
1588 1588
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki]));
1589 1589
 						$ki++;
1590 1590
 					}
@@ -1593,27 +1593,27 @@  discard block
 block discarded – undo
1593 1593
 
1594 1594
 				$count++;
1595 1595
 			}
1596
-			if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') ');
1596
+			if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' fetching Headers and stuff for Folder:'.$_folderName, __METHOD__.' ('.__LINE__.') ');
1597 1597
 			//self::$debug=false;
1598 1598
 			// sort the messages to the requested displayorder
1599
-			if(is_array($retValue['header'])) {
1599
+			if (is_array($retValue['header'])) {
1600 1600
 				$countMessages = $total;
1601 1601
 				if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages'];
1602 1602
 				ksort($retValue['header']);
1603 1603
 				$retValue['info']['total']	= $total;
1604 1604
 				//if ($_startMessage>$total) $_startMessage = $total-($count-1);
1605 1605
 				$retValue['info']['first']	= $_startMessage;
1606
-				$retValue['info']['last']	= $_startMessage + $count - 1 ;
1606
+				$retValue['info']['last'] = $_startMessage + $count - 1;
1607 1607
 				return $retValue;
1608 1608
 			} else {
1609 1609
 				$retValue = array();
1610 1610
 				$retValue['info']['total']	= 0;
1611 1611
 				$retValue['info']['first']	= 0;
1612
-				$retValue['info']['last']	= 0;
1612
+				$retValue['info']['last'] = 0;
1613 1613
 				return $retValue;
1614 1614
 			}
1615 1615
 		} else {
1616
-			if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE));
1616
+			if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew, TRUE));
1617 1617
 			$retValue = array();
1618 1618
 			$retValue['info']['total']  = 0;
1619 1619
 			$retValue['info']['first']  = 0;
@@ -1630,17 +1630,17 @@  discard block
 block discarded – undo
1630 1630
 	 */
1631 1631
 	static function prepareFlagsArray($headerObject)
1632 1632
 	{
1633
-		if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']);
1633
+		if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower', $headerObject['FLAGS']);
1634 1634
 		$retValue = array();
1635 1635
 		$retValue['recent']		= in_array('\\recent', $headerFlags);
1636 1636
 		$retValue['flagged']	= in_array('\\flagged', $headerFlags);
1637
-		$retValue['answered']	= in_array('\\answered', $headerFlags);
1638
-		$retValue['forwarded']   = in_array('$forwarded', $headerFlags);
1637
+		$retValue['answered'] = in_array('\\answered', $headerFlags);
1638
+		$retValue['forwarded'] = in_array('$forwarded', $headerFlags);
1639 1639
 		$retValue['deleted']	= in_array('\\deleted', $headerFlags);
1640
-		$retValue['seen']		= in_array('\\seen', $headerFlags);
1641
-		$retValue['draft']		= in_array('\\draft', $headerFlags);
1642
-		$retValue['mdnsent']	= in_array('$mdnsent', $headerFlags)||in_array('mdnsent', $headerFlags);
1643
-		$retValue['mdnnotsent']	= in_array('$mdnnotsent', $headerFlags)||in_array('mdnnotsent', $headerFlags);
1640
+		$retValue['seen'] = in_array('\\seen', $headerFlags);
1641
+		$retValue['draft'] = in_array('\\draft', $headerFlags);
1642
+		$retValue['mdnsent']	= in_array('$mdnsent', $headerFlags) || in_array('mdnsent', $headerFlags);
1643
+		$retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags) || in_array('mdnnotsent', $headerFlags);
1644 1644
 		$retValue['label1']   = in_array('$label1', $headerFlags);
1645 1645
 		$retValue['label2']   = in_array('$label2', $headerFlags);
1646 1646
 		$retValue['label3']   = in_array('$label3', $headerFlags);
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
 	 * @param bool $setSession if set to true the session will be populated with the result of the query
1665 1665
 	 * @return mixed bool/array false or array of ids
1666 1666
 	 */
1667
-	function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid=true, $setSession=true)
1667
+	function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid = true, $setSession = true)
1668 1668
 	{
1669 1669
 		static $cachedFolderStatus;
1670 1670
 		// in the past we needed examineMailbox to figure out if the server with the serverID support keywords
1671 1671
 		// this information is filled/provided by examineMailbox; but caching within one request seems o.k.
1672
-		if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) )
1672
+		if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]))
1673 1673
 		{
1674 1674
 			$folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName);
1675 1675
 		}
@@ -1681,27 +1681,27 @@  discard block
 block discarded – undo
1681 1681
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter));
1682 1682
 		$try2useCache = true;
1683 1683
 		static $eMailListContainsDeletedMessages;
1684
-		if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
1684
+		if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1);
1685 1685
 		// this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED
1686
-		if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false)))
1686
+		if ($setSession == true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false)))
1687 1687
 		{
1688 1688
 			if (self::$debugTimes) $starttime = microtime(true);
1689
-			if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
1690
-			$deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false);
1689
+			if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1);
1690
+			$deletedMessages = $this->getSortedList($_folderName, 0, $three = 1, array('status'=>array('DELETED')), $five = true, false);
1691 1691
 			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages));
1692
-			$eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count'];
1693
-			egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1);
1694
-			if (self::$debugTimes) self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') ');			//error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']);
1692
+			$eMailListContainsDeletedMessages[$this->profileID][$_folderName] = $deletedMessages['count'];
1693
+			egw_cache::setCache(egw_cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), $eMailListContainsDeletedMessages, 60 * 60 * 1);
1694
+			if (self::$debugTimes) self::logRunTimes($starttime, null, 'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName], __METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']);
1695 1695
 		}
1696 1696
 		$try2useCache = false;
1697 1697
 		//self::$supportsORinQuery[$this->profileID]=true;
1698 1698
 		if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID]))
1699 1699
 		{
1700
-			self::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
1701
-			if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true;
1700
+			self::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1701
+			if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID] = true;
1702 1702
 		}
1703 1703
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]);
1704
-		$filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]);
1704
+		$filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]);
1705 1705
 		if (self::$debug)
1706 1706
 		{
1707 1707
 			$query_str = $filter->build();
@@ -1709,14 +1709,14 @@  discard block
 block discarded – undo
1709 1709
 		}
1710 1710
 		//_debug_array($filter);
1711 1711
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability()));
1712
-		if($this->icServer->hasCapability('SORT')) {
1712
+		if ($this->icServer->hasCapability('SORT')) {
1713 1713
 			// when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client
1714 1714
 			// thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if
1715 1715
 			// there is no messing with the dates)
1716 1716
 			//if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE';
1717 1717
 			if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse");
1718 1718
 			$sortOrder = $this->_getSortString($_sort, $_reverse);
1719
-			if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already
1719
+			if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE, $sortOrder)) $_reverse = false; // as we reversed the result already
1720 1720
 			if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter));
1721 1721
 			try
1722 1722
 			{
@@ -1724,24 +1724,24 @@  discard block
 block discarded – undo
1724 1724
 					'sort' => $sortOrder,));
1725 1725
 			// if there is an Error, we assume that the server is not capable of sorting
1726 1726
 			}
1727
-			catch(Exception $e)
1727
+			catch (Exception $e)
1728 1728
 			{
1729 1729
 				//error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage());
1730 1730
 				$resultByUid = false;
1731 1731
 				$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE);
1732
-				if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE);
1732
+				if ($_reverse) array_unshift($sortOrder, Horde_Imap_Client::SORT_REVERSE);
1733 1733
 				try
1734 1734
 				{
1735 1735
 					$sortResult = $this->icServer->search($_folderName, $filter, array(
1736 1736
 						'sort' => $sortOrder));
1737 1737
 				}
1738
-				catch(Exception $e)
1738
+				catch (Exception $e)
1739 1739
 				{
1740 1740
 					error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage());
1741 1741
 					$sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'];
1742 1742
 				}
1743 1743
 			}
1744
-			if (self::$debug) error_log(__METHOD__.print_r($sortResult,true));
1744
+			if (self::$debug) error_log(__METHOD__.print_r($sortResult, true));
1745 1745
 		} else {
1746 1746
 			if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability");
1747 1747
 			//$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE);
@@ -1751,12 +1751,12 @@  discard block
 block discarded – undo
1751 1751
 				$sortResult = $this->icServer->search($_folderName, $filter, array()/*array(
1752 1752
 					'sort' => $sortOrder)*/);
1753 1753
 			}
1754
-			catch(Exception $e)
1754
+			catch (Exception $e)
1755 1755
 			{
1756 1756
 				//error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage());
1757 1757
 				// possible error OR Query. But Horde gives no detailed Info :-(
1758
-				self::$supportsORinQuery[$this->profileID]=false;
1759
-				egw_cache::setCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10);
1758
+				self::$supportsORinQuery[$this->profileID] = false;
1759
+				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), self::$supportsORinQuery, 60 * 60 * 10);
1760 1760
 				if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message);
1761 1761
 				$filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]);
1762 1762
 				try
@@ -1764,25 +1764,25 @@  discard block
 block discarded – undo
1764 1764
 					$sortResult = $this->icServer->search($_folderName, $filter, array()/*array(
1765 1765
 						'sort' => $sortOrder)*/);
1766 1766
 				}
1767
-				catch(Exception $e)
1767
+				catch (Exception $e)
1768 1768
 				{
1769 1769
 				}
1770 1770
 			}
1771
-			if(is_array($sortResult['match'])) {
1771
+			if (is_array($sortResult['match'])) {
1772 1772
 					// not sure that this is going so succeed as $sortResult['match'] is a hordeObject
1773 1773
 					sort($sortResult['match'], SORT_NUMERIC);
1774 1774
 			}
1775
-			if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true));
1775
+			if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter, true)." ->".print_r($sortResult, true));
1776 1776
 		}
1777 1777
 		if ($setSession)
1778 1778
 		{
1779 1779
 			self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY'];
1780
-			self::$folderStatusCache[$this->profileID][$_folderName]['messages']	= $folderStatus['MESSAGES'];
1780
+			self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES'];
1781 1781
 			self::$folderStatusCache[$this->profileID][$_folderName]['deleted']	= $eMailListContainsDeletedMessages[$this->profileID][$_folderName];
1782 1782
 			self::$folderStatusCache[$this->profileID][$_folderName]['uidnext']	= $folderStatus['UIDNEXT'];
1783
-			self::$folderStatusCache[$this->profileID][$_folderName]['filter']	= $_filter;
1783
+			self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter;
1784 1784
 			self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult;
1785
-			self::$folderStatusCache[$this->profileID][$_folderName]['sort']	= $_sort;
1785
+			self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort;
1786 1786
 		}
1787 1787
 		//error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true));
1788 1788
 		//_debug_array($sortResult['match']->ids);
@@ -1796,12 +1796,12 @@  discard block
 block discarded – undo
1796 1796
 	 * @param bool _reverse wether to add REVERSE to the Sort String or not
1797 1797
 	 * @return the sort sequence for horde search
1798 1798
 	 */
1799
-	function _getSortString($_sort, $_reverse=false)
1799
+	function _getSortString($_sort, $_reverse = false)
1800 1800
 	{
1801
-		$_reverse=false;
1801
+		$_reverse = false;
1802 1802
 		if (is_numeric($_sort))
1803 1803
 		{
1804
-			switch($_sort) {
1804
+			switch ($_sort) {
1805 1805
 				case 2:
1806 1806
 					$retValue = array(Horde_Imap_Client::SORT_FROM);
1807 1807
 					break;
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
 		}
1824 1824
 		else
1825 1825
 		{
1826
-			switch(strtoupper($_sort)) {
1826
+			switch (strtoupper($_sort)) {
1827 1827
 				case 'FROMADDRESS':
1828 1828
 					$retValue = array(Horde_Imap_Client::SORT_FROM);
1829 1829
 					break;
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
 					break;
1850 1850
 			}
1851 1851
 		}
1852
-		if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE);
1852
+		if ($_reverse) array_unshift($retValue, Horde_Imap_Client::SORT_REVERSE);
1853 1853
 		//error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue);
1854 1854
 		return $retValue;
1855 1855
 	}
@@ -1862,22 +1862,22 @@  discard block
 block discarded – undo
1862 1862
 	 * @param boolean $_supportsOrInQuery wether to use the OR Query on QuickSearch
1863 1863
 	 * @return Horde_Imap_Client_Search_Query the IMAP filter
1864 1864
 	 */
1865
-	function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery=true)
1865
+	function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery = true)
1866 1866
 	{
1867 1867
 		$imapFilter = new Horde_Imap_Client_Search_Query();
1868 1868
 		$imapFilter->charset('UTF-8');
1869 1869
 
1870 1870
 		//_debug_array($_criterias);
1871
-		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias)));
1872
-		if((!is_array($_criterias) || $_criterias['status']=='any') && (!isset($_criterias['string']) || empty($_criterias['string']))) {
1873
-			$imapFilter->flag('DELETED', $set=false);
1871
+		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias) ? " none -> returning" : array2string($_criterias)));
1872
+		if ((!is_array($_criterias) || $_criterias['status'] == 'any') && (!isset($_criterias['string']) || empty($_criterias['string']))) {
1873
+			$imapFilter->flag('DELETED', $set = false);
1874 1874
 			return $imapFilter;
1875 1875
 		}
1876 1876
 		$queryValid = false;
1877 1877
 		// statusQuery MUST be placed first, as search for subject/mailbody and such is
1878 1878
 		// depending on charset. flagSearch is not BUT messes the charset if called afterwards
1879 1879
 		$statusQueryValid = false;
1880
-		foreach((array)$_criterias['status'] as $k => $criteria) {
1880
+		foreach ((array)$_criterias['status'] as $k => $criteria) {
1881 1881
 			$imapStatusFilter = new Horde_Imap_Client_Search_Query();
1882 1882
 			$imapStatusFilter->charset('UTF-8');
1883 1883
 			$criteria = strtoupper($criteria);
@@ -1887,12 +1887,12 @@  discard block
 block discarded – undo
1887 1887
 				case 'FLAGGED':
1888 1888
 				case 'RECENT':
1889 1889
 				case 'SEEN':
1890
-					$imapStatusFilter->flag($criteria, $set=true);
1891
-					$queryValid = $statusQueryValid =true;
1890
+					$imapStatusFilter->flag($criteria, $set = true);
1891
+					$queryValid = $statusQueryValid = true;
1892 1892
 					break;
1893 1893
 				case 'READ':
1894
-					$imapStatusFilter->flag('SEEN', $set=true);
1895
-					$queryValid = $statusQueryValid =true;
1894
+					$imapStatusFilter->flag('SEEN', $set = true);
1895
+					$queryValid = $statusQueryValid = true;
1896 1896
 					break;
1897 1897
 				case 'LABEL1':
1898 1898
 				case 'KEYWORD1':
@@ -1904,38 +1904,38 @@  discard block
 block discarded – undo
1904 1904
 				case 'KEYWORD4':
1905 1905
 				case 'LABEL5':
1906 1906
 				case 'KEYWORD5':
1907
-					$imapStatusFilter->flag(str_ireplace('KEYWORD','$LABEL',$criteria), $set=true);
1908
-					$queryValid = $statusQueryValid =true;
1907
+					$imapStatusFilter->flag(str_ireplace('KEYWORD', '$LABEL', $criteria), $set = true);
1908
+					$queryValid = $statusQueryValid = true;
1909 1909
 					break;
1910 1910
 				case 'NEW':
1911
-					$imapStatusFilter->flag('RECENT', $set=true);
1912
-					$imapStatusFilter->flag('SEEN', $set=false);
1913
-					$queryValid = $statusQueryValid =true;
1911
+					$imapStatusFilter->flag('RECENT', $set = true);
1912
+					$imapStatusFilter->flag('SEEN', $set = false);
1913
+					$queryValid = $statusQueryValid = true;
1914 1914
 					break;
1915 1915
 				case 'OLD':
1916
-					$imapStatusFilter->flag('RECENT', $set=false);
1917
-					$queryValid = $statusQueryValid =true;
1916
+					$imapStatusFilter->flag('RECENT', $set = false);
1917
+					$queryValid = $statusQueryValid = true;
1918 1918
 					break;
1919 1919
 // operate only on system flags
1920 1920
 //        $systemflags = array(
1921 1921
 //            'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'RECENT', 'SEEN'
1922 1922
 //        );
1923 1923
 				case 'UNANSWERED':
1924
-					$imapStatusFilter->flag('ANSWERED', $set=false);
1925
-					$queryValid = $statusQueryValid =true;
1924
+					$imapStatusFilter->flag('ANSWERED', $set = false);
1925
+					$queryValid = $statusQueryValid = true;
1926 1926
 					break;
1927 1927
 				case 'UNDELETED':
1928
-					$imapFilter->flag('DELETED', $set=false);
1928
+					$imapFilter->flag('DELETED', $set = false);
1929 1929
 					$queryValid = true;
1930 1930
 					break;
1931 1931
 				case 'UNFLAGGED':
1932
-					$imapStatusFilter->flag('FLAGGED', $set=false);
1933
-					$queryValid = $statusQueryValid =true;
1932
+					$imapStatusFilter->flag('FLAGGED', $set = false);
1933
+					$queryValid = $statusQueryValid = true;
1934 1934
 					break;
1935 1935
 				case 'UNREAD':
1936 1936
 				case 'UNSEEN':
1937
-					$imapStatusFilter->flag('SEEN', $set=false);
1938
-					$queryValid = $statusQueryValid =true;
1937
+					$imapStatusFilter->flag('SEEN', $set = false);
1938
+					$queryValid = $statusQueryValid = true;
1939 1939
 					break;
1940 1940
 				case 'UNLABEL1':
1941 1941
 				case 'UNKEYWORD1':
@@ -1947,8 +1947,8 @@  discard block
 block discarded – undo
1947 1947
 				case 'UNKEYWORD4':
1948 1948
 				case 'UNLABEL5':
1949 1949
 				case 'UNKEYWORD5':
1950
-					$imapStatusFilter->flag(str_ireplace(array('UNKEYWORD','UNLABEL'),'$LABEL',$criteria), $set=false);
1951
-					$queryValid = $statusQueryValid =true;
1950
+					$imapStatusFilter->flag(str_ireplace(array('UNKEYWORD', 'UNLABEL'), '$LABEL', $criteria), $set = false);
1951
+					$queryValid = $statusQueryValid = true;
1952 1952
 					break;
1953 1953
 				default:
1954 1954
 					$statusQueryValid = false;
@@ -1964,18 +1964,18 @@  discard block
 block discarded – undo
1964 1964
 		$imapSearchFilter = new Horde_Imap_Client_Search_Query();
1965 1965
 		$imapSearchFilter->charset('UTF-8');
1966 1966
 
1967
-		if(!empty($_criterias['string'])) {
1967
+		if (!empty($_criterias['string'])) {
1968 1968
 			$criteria = strtoupper($_criterias['type']);
1969 1969
 			switch ($criteria) {
1970 1970
 				case 'QUICK':
1971
-					$imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not=false);
1971
+					$imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not = false);
1972 1972
 					//$imapSearchFilter->charset('UTF-8');
1973 1973
 					$imapFilter2 = new Horde_Imap_Client_Search_Query();
1974 1974
 					$imapFilter2->charset('UTF-8');
1975
-					if($this->isSentFolder($_folder)) {
1976
-						$imapFilter2->headerText('TO', $_criterias['string'], $not=false);
1975
+					if ($this->isSentFolder($_folder)) {
1976
+						$imapFilter2->headerText('TO', $_criterias['string'], $not = false);
1977 1977
 					} else {
1978
-						$imapFilter2->headerText('FROM', $_criterias['string'], $not=false);
1978
+						$imapFilter2->headerText('FROM', $_criterias['string'], $not = false);
1979 1979
 					}
1980 1980
 					if ($_supportsOrInQuery)
1981 1981
 					{
@@ -1992,31 +1992,31 @@  discard block
 block discarded – undo
1992 1992
 				case 'CC':
1993 1993
 				case 'BCC':
1994 1994
 				case 'SUBJECT':
1995
-					$imapSearchFilter->headerText($criteria, $_criterias['string'], $not=false);
1995
+					$imapSearchFilter->headerText($criteria, $_criterias['string'], $not = false);
1996 1996
 					//$imapSearchFilter->charset('UTF-8');
1997 1997
 					$queryValid = true;
1998 1998
 					break;
1999 1999
 				case 'BODY':
2000 2000
 				case 'TEXT':
2001
-					$imapSearchFilter->text($_criterias['string'],($criteria=='BODY'?true:false), $not=false);
2001
+					$imapSearchFilter->text($_criterias['string'], ($criteria == 'BODY' ? true : false), $not = false);
2002 2002
 					//$imapSearchFilter->charset('UTF-8');
2003 2003
 					$queryValid = true;
2004 2004
 					break;
2005 2005
 				case 'SINCE':
2006
-					$imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false);
2006
+					$imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false);
2007 2007
 					$queryValid = true;
2008 2008
 					break;
2009 2009
 				case 'BEFORE':
2010
-					$imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false);
2010
+					$imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false);
2011 2011
 					$queryValid = true;
2012 2012
 					break;
2013 2013
 				case 'ON':
2014
-					$imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false);
2014
+					$imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false);
2015 2015
 					$queryValid = true;
2016 2016
 					break;
2017 2017
 			}
2018 2018
 		}
2019
-		if ($statusQueryValid && !$queryValid) $queryValid=true;
2019
+		if ($statusQueryValid && !$queryValid) $queryValid = true;
2020 2020
 		if ($queryValid) $imapFilter->andSearch($imapSearchFilter);
2021 2021
 
2022 2022
 		if (isset($_criterias['range']) && !empty($_criterias['range']))
@@ -2029,8 +2029,8 @@  discard block
 block discarded – undo
2029 2029
 			$query_str = $imapFilter->build();
2030 2030
 			error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query']);
2031 2031
 		}
2032
-		if($queryValid==false) {
2033
-			$imapFilter->flag('DELETED', $set=false);
2032
+		if ($queryValid == false) {
2033
+			$imapFilter->flag('DELETED', $set = false);
2034 2034
 			return $imapFilter;
2035 2035
 		} else {
2036 2036
 			return $imapFilter;
@@ -2044,11 +2044,11 @@  discard block
 block discarded – undo
2044 2044
 	 * @param  mixed/boolean $_tryIDNConversion (true/false AND FORCE): try IDN Conversion on domainparts of emailADRESSES
2045 2045
 	 * @return mixed - based on the input type
2046 2046
 	 */
2047
-	static function decode_header($_string, $_tryIDNConversion=false)
2047
+	static function decode_header($_string, $_tryIDNConversion = false)
2048 2048
 	{
2049 2049
 		if (is_array($_string))
2050 2050
 		{
2051
-			foreach($_string as $k=>$v)
2051
+			foreach ($_string as $k=>$v)
2052 2052
 			{
2053 2053
 				$_string[$k] = self::decode_header($v, $_tryIDNConversion);
2054 2054
 			}
@@ -2056,18 +2056,18 @@  discard block
 block discarded – undo
2056 2056
 		}
2057 2057
 		else
2058 2058
 		{
2059
-			$_string = translation::decodeMailHeader($_string,self::$displayCharset);
2059
+			$_string = translation::decodeMailHeader($_string, self::$displayCharset);
2060 2060
 			$test = @json_encode($_string);
2061 2061
 			//error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#');
2062
-			if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0)
2062
+			if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0)
2063 2063
 			{
2064 2064
 				// try to fix broken utf8
2065 2065
 				$x = utf8_encode($_string);
2066 2066
 				$test = @json_encode($x);
2067
-				if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0)
2067
+				if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0)
2068 2068
 				{
2069 2069
 					// this should not be needed, unless something fails with charset detection/ wrong charset passed
2070
-					$_string = (function_exists('mb_convert_encoding')?mb_convert_encoding($_string,'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$_string):$_string));
2070
+					$_string = (function_exists('mb_convert_encoding') ? mb_convert_encoding($_string, 'UTF-8', 'UTF-8') : (function_exists('iconv') ? @iconv("UTF-8", "UTF-8//IGNORE", $_string) : $_string));
2071 2071
 				}
2072 2072
 				else
2073 2073
 				{
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 				}
2076 2076
 			}
2077 2077
 
2078
-			if ($_tryIDNConversion===true && stripos($_string,'@')!==false)
2078
+			if ($_tryIDNConversion === true && stripos($_string, '@') !== false)
2079 2079
 			{
2080 2080
 				$rfcAddr = self::parseAddressList($_string);
2081 2081
 				if (!isset(self::$idna2)) self::$idna2 = new egw_idna;
@@ -2090,12 +2090,12 @@  discard block
 block discarded – undo
2090 2090
 							$stringA = array();
2091 2091
 							break; // skip idna conversion if we encounter an error here
2092 2092
 						}
2093
-						$stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,self::$idna2->decode($_rfcAddr->host),$_rfcAddr->personal);
2093
+						$stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox, self::$idna2->decode($_rfcAddr->host), $_rfcAddr->personal);
2094 2094
 					}
2095
-					if (!empty($stringA)) $_string = implode(',',$stringA);
2095
+					if (!empty($stringA)) $_string = implode(',', $stringA);
2096 2096
 				}
2097 2097
 			}
2098
-			if ($_tryIDNConversion==='FORCE')
2098
+			if ($_tryIDNConversion === 'FORCE')
2099 2099
 			{
2100 2100
 				if (!isset(self::$idna2)) self::$idna2 = new egw_idna;
2101 2101
 				if (isset(self::$idna2))
@@ -2115,17 +2115,17 @@  discard block
 block discarded – undo
2115 2115
 	 * @param  boolean $decode try decoding
2116 2116
 	 * @return mixed - based on the input type
2117 2117
 	 */
2118
-	function decode_subject($_string,$decode=true)
2118
+	function decode_subject($_string, $decode = true)
2119 2119
 	{
2120 2120
 		#$string = $_string;
2121
-		if($_string=='NIL')
2121
+		if ($_string == 'NIL')
2122 2122
 		{
2123 2123
 			return 'No Subject';
2124 2124
 		}
2125 2125
 		if ($decode) $_string = self::decode_header($_string);
2126 2126
 		// make sure its utf-8
2127 2127
 		$test = @json_encode($_string);
2128
-		if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0)
2128
+		if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0)
2129 2129
 		{
2130 2130
 			$_string = utf8_encode($_string);
2131 2131
 		}
@@ -2177,18 +2177,18 @@  discard block
 block discarded – undo
2177 2177
 	function createFolder($_parent, $_folderName, &$_error)
2178 2178
 	{
2179 2179
 		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace());
2180
-		$parent		= $_parent;//$this->_encodeFolderName($_parent);
2181
-		$folderName	= $_folderName;//$this->_encodeFolderName($_folderName);
2180
+		$parent = $_parent; //$this->_encodeFolderName($_parent);
2181
+		$folderName = $_folderName; //$this->_encodeFolderName($_folderName);
2182 2182
 
2183
-		if(empty($parent)) {
2183
+		if (empty($parent)) {
2184 2184
 			$newFolderName = $folderName;
2185 2185
 		} else {
2186 2186
 			$HierarchyDelimiter = $this->getHierarchyDelimiter();
2187
-			$newFolderName = $parent . $HierarchyDelimiter . $folderName;
2187
+			$newFolderName = $parent.$HierarchyDelimiter.$folderName;
2188 2188
 		}
2189 2189
 		if (empty($newFolderName)) return false;
2190 2190
 		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName);
2191
-		if ($this->folderExists($newFolderName,true))
2191
+		if ($this->folderExists($newFolderName, true))
2192 2192
 		{
2193 2193
 			if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists.");
2194 2194
 			return $newFolderName;
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
 		}
2206 2206
 		catch (Exception $e)
2207 2207
 		{
2208
-			$_error = lang('Could not create Folder %1 Reason: %2',$newFolderName,$e->getMessage());
2208
+			$_error = lang('Could not create Folder %1 Reason: %2', $newFolderName, $e->getMessage());
2209 2209
 			error_log(__METHOD__.' ('.__LINE__.') '.' create Folder '.$newFolderName.'->'.$e->getMessage().' ('.$e->details.') Namespace:'.array2string($this->icServer->getNameSpaces()).function_backtrace());
2210 2210
 			return false;
2211 2211
 		}
@@ -2234,15 +2234,15 @@  discard block
 block discarded – undo
2234 2234
 	 */
2235 2235
 	function renameFolder($_oldFolderName, $_parent, $_folderName)
2236 2236
 	{
2237
-		$oldFolderName	= $_oldFolderName;//$this->_encodeFolderName($_oldFolderName);
2238
-		$parent		= $_parent;//$this->_encodeFolderName($_parent);
2239
-		$folderName	= $_folderName;//$this->_encodeFolderName($_folderName);
2237
+		$oldFolderName = $_oldFolderName; //$this->_encodeFolderName($_oldFolderName);
2238
+		$parent = $_parent; //$this->_encodeFolderName($_parent);
2239
+		$folderName = $_folderName; //$this->_encodeFolderName($_folderName);
2240 2240
 
2241
-		if(empty($parent)) {
2241
+		if (empty($parent)) {
2242 2242
 			$newFolderName = $folderName;
2243 2243
 		} else {
2244 2244
 			$HierarchyDelimiter = $this->getHierarchyDelimiter();
2245
-			$newFolderName = $parent . $HierarchyDelimiter . $folderName;
2245
+			$newFolderName = $parent.$HierarchyDelimiter.$folderName;
2246 2246
 		}
2247 2247
 		if (self::$debug) error_log("create folder: $newFolderName");
2248 2248
 		try
@@ -2251,10 +2251,10 @@  discard block
 block discarded – undo
2251 2251
 		}
2252 2252
 		catch (Exception $e)
2253 2253
 		{
2254
-			throw new egw_exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage());;
2254
+			throw new egw_exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage()); ;
2255 2255
 		}
2256 2256
 		// clear FolderExistsInfoCache
2257
-		egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5);
2257
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5);
2258 2258
 
2259 2259
 		return $newFolderName;
2260 2260
 
@@ -2273,15 +2273,15 @@  discard block
 block discarded – undo
2273 2273
 		//$folderName = $this->_encodeFolderName($_folderName);
2274 2274
 		try
2275 2275
 		{
2276
-			$this->icServer->subscribeMailbox($_folderName,false);
2276
+			$this->icServer->subscribeMailbox($_folderName, false);
2277 2277
 			$this->icServer->deleteMailbox($_folderName);
2278 2278
 		}
2279 2279
 		catch (Exception $e)
2280 2280
 		{
2281
-			throw new egw_exception("Deleting Folder $_folderName failed! Error:".$e->getMessage());;
2281
+			throw new egw_exception("Deleting Folder $_folderName failed! Error:".$e->getMessage()); ;
2282 2282
 		}
2283 2283
 		// clear FolderExistsInfoCache
2284
-		egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5);
2284
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5);
2285 2285
 
2286 2286
 		return true;
2287 2287
 	}
@@ -2316,10 +2316,10 @@  discard block
 block discarded – undo
2316 2316
 	 *
2317 2317
 	 * @return array with folder objects. eg.: INBOX => {inbox object}
2318 2318
 	 */
2319
-	function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true)
2319
+	function getFolderObjects($_subscribedOnly = false, $_getCounters = false, $_alwaysGetDefaultFolders = false, $_useCacheIfPossible = true)
2320 2320
 	{
2321 2321
 		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible");
2322
-		if (self::$debugTimes) $starttime = microtime (true);
2322
+		if (self::$debugTimes) $starttime = microtime(true);
2323 2323
 		static $folders2return;
2324 2324
 		//$_subscribedOnly=false;
2325 2325
 		// always use static on single request if info is available;
@@ -2327,42 +2327,42 @@  discard block
 block discarded – undo
2327 2327
 		// set $_useCacheIfPossible to false !
2328 2328
 		if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
2329 2329
 		{
2330
-			if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') ');
2330
+			if (self::$debugTimes) self::logRunTimes($starttime, null, 'using static', __METHOD__.' ('.__LINE__.') ');
2331 2331
 			return $folders2return[$this->icServer->ImapServerId];
2332 2332
 		}
2333 2333
 
2334
-		if ($_subscribedOnly && $_getCounters===false)
2334
+		if ($_subscribedOnly && $_getCounters === false)
2335 2335
 		{
2336
-			if (is_null($folders2return)) $folders2return = egw_cache::getCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2336
+			if (is_null($folders2return)) $folders2return = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1);
2337 2337
 			if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
2338 2338
 			{
2339 2339
 				//error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId]));
2340
-				if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') ');
2340
+				if (self::$debugTimes) self::logRunTimes($starttime, null, 'from Cache', __METHOD__.' ('.__LINE__.') ');
2341 2341
 				return $folders2return[$this->icServer->ImapServerId];
2342 2342
 			}
2343 2343
 		}
2344 2344
 		// use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId]
2345 2345
 		static $folderBasicInfo;
2346
-		if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
2346
+		if (is_null($folderBasicInfo) || !isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1);
2347 2347
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId])));
2348 2348
 
2349 2349
 		$delimiter = $this->getHierarchyDelimiter();
2350 2350
 
2351 2351
 		$inboxData = new stdClass;
2352
-		$inboxData->name 		= 'INBOX';
2352
+		$inboxData->name = 'INBOX';
2353 2353
 		$inboxData->folderName		= 'INBOX';
2354
-		$inboxData->displayName		= lang('INBOX');
2354
+		$inboxData->displayName = lang('INBOX');
2355 2355
 		$inboxData->delimiter 		= $delimiter;
2356
-		$inboxData->shortFolderName	= 'INBOX';
2357
-		$inboxData->shortDisplayName	= lang('INBOX');
2356
+		$inboxData->shortFolderName = 'INBOX';
2357
+		$inboxData->shortDisplayName = lang('INBOX');
2358 2358
 		$inboxData->subscribed = true;
2359
-		if($_getCounters == true) {
2359
+		if ($_getCounters == true) {
2360 2360
 			$inboxData->counter = $this->getMailBoxCounters('INBOX');
2361 2361
 		}
2362 2362
 		// force unsubscribed by preference showAllFoldersInFolderPane
2363 2363
 		if ($_subscribedOnly == true &&
2364 2364
 			isset($this->mailPreferences['showAllFoldersInFolderPane']) &&
2365
-			$this->mailPreferences['showAllFoldersInFolderPane']==1)
2365
+			$this->mailPreferences['showAllFoldersInFolderPane'] == 1)
2366 2366
 		{
2367 2367
 			$_subscribedOnly = false;
2368 2368
 		}
@@ -2375,12 +2375,12 @@  discard block
 block discarded – undo
2375 2375
 		//error_log(__METHOD__.__LINE__.array2string($nameSpace));
2376 2376
 		if (is_array($nameSpace))
2377 2377
 		{
2378
-			foreach($nameSpace as $k => $singleNameSpace) {
2378
+			foreach ($nameSpace as $k => $singleNameSpace) {
2379 2379
 				$type = $singleNameSpace['type'];
2380 2380
 				// the following line (assumption that for the same namespace the delimiter should be equal) may be wrong
2381
-				$foldersNameSpace[$type]['delimiter']  = $singleNameSpace['delimiter'];
2381
+				$foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter'];
2382 2382
 
2383
-				if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) {
2383
+				if (is_array($singleNameSpace) && $fetchedAllInOneGo == false) {
2384 2384
 					// fetch and sort the subscribed folders
2385 2385
 					// we alway fetch the subscribed, as this provides the only way to tell
2386 2386
 					// if a folder is subscribed or not
@@ -2388,22 +2388,22 @@  discard block
 block discarded – undo
2388 2388
 					{
2389 2389
 						try
2390 2390
 						{
2391
-							$subscribedMailboxes = $this->icServer->listSubscribedMailboxes('',0,true);
2391
+							$subscribedMailboxes = $this->icServer->listSubscribedMailboxes('', 0, true);
2392 2392
 							if (!empty($subscribedMailboxes))
2393 2393
 							{
2394 2394
 								$fetchedAllInOneGo = true;
2395 2395
 							}
2396 2396
 							else
2397 2397
 							{
2398
-								$subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'],0,true);
2398
+								$subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'], 0, true);
2399 2399
 							}
2400 2400
 						}
2401
-						catch(Exception $e)
2401
+						catch (Exception $e)
2402 2402
 						{
2403 2403
 							continue;
2404 2404
 						}
2405 2405
 						//echo "subscribedMailboxes";_debug_array($subscribedMailboxes);
2406
-						$subscribedFoldersPerNS = (!empty($subscribedMailboxes)?array_keys($subscribedMailboxes):array());
2406
+						$subscribedFoldersPerNS = (!empty($subscribedMailboxes) ? array_keys($subscribedMailboxes) : array());
2407 2407
 						//if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']);
2408 2408
 						//_debug_array($foldersNameSpace);
2409 2409
 						//error_log(__METHOD__.__LINE__.array2string($singleNameSpace).':#:'.array2string($subscribedFoldersPerNS));
@@ -2413,18 +2413,18 @@  discard block
 block discarded – undo
2413 2413
 							foreach ($subscribedMailboxes as $k => $finfo)
2414 2414
 							{
2415 2415
 								//error_log(__METHOD__.__LINE__.$k.':#:'.array2string($finfo));
2416
-								$subscribedFoldersForCache[$this->icServer->ImapServerId][$k]=
2417
-								$folderBasicInfo[$this->icServer->ImapServerId][$k]=array(
2416
+								$subscribedFoldersForCache[$this->icServer->ImapServerId][$k] =
2417
+								$folderBasicInfo[$this->icServer->ImapServerId][$k] = array(
2418 2418
 									'MAILBOX'=>$finfo['MAILBOX'],
2419 2419
 									'ATTRIBUTES'=>$finfo['ATTRIBUTES'],
2420
-									'delimiter'=>$finfo['delimiter'],//lowercase for some reason???
2421
-									'SUBSCRIBED'=>$finfo['SUBSCRIBED'],//seeded by getMailboxes
2420
+									'delimiter'=>$finfo['delimiter'], //lowercase for some reason???
2421
+									'SUBSCRIBED'=>$finfo['SUBSCRIBED'], //seeded by getMailboxes
2422 2422
 								);
2423
-								if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k,$foldersNameSpace[$type]['subscribed']))
2423
+								if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k, $foldersNameSpace[$type]['subscribed']))
2424 2424
 								{
2425 2425
 									$foldersNameSpace[$type]['subscribed'][] = $k;
2426 2426
 								}
2427
-								if (empty($foldersNameSpace[$type]['all']) || !in_array($k,$foldersNameSpace[$type]['all']))
2427
+								if (empty($foldersNameSpace[$type]['all']) || !in_array($k, $foldersNameSpace[$type]['all']))
2428 2428
 								{
2429 2429
 									$foldersNameSpace[$type]['all'][] = $k;
2430 2430
 								}
@@ -2447,7 +2447,7 @@  discard block
 block discarded – undo
2447 2447
 						// that may produce problems, when encountering recursions probably
2448 2448
 						// horde is handling that, so we do not; keep that in mind!
2449 2449
 						//$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],2,true);
2450
-						$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],0,true);
2450
+						$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'], 0, true);
2451 2451
 					}
2452 2452
 					catch (Exception $e)
2453 2453
 					{
@@ -2465,26 +2465,26 @@  discard block
 block discarded – undo
2465 2465
 					foreach ($allMailboxesExt as $mbx) {
2466 2466
 						if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]))
2467 2467
 						{
2468
-							$folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array(
2468
+							$folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']] = array(
2469 2469
 								'MAILBOX'=>$mbx['MAILBOX'],
2470 2470
 								'ATTRIBUTES'=>$mbx['ATTRIBUTES'],
2471
-								'delimiter'=>$mbx['delimiter'],//lowercase for some reason???
2472
-								'SUBSCRIBED'=>$mbx['SUBSCRIBED'],//seeded by getMailboxes
2471
+								'delimiter'=>$mbx['delimiter'], //lowercase for some reason???
2472
+								'SUBSCRIBED'=>$mbx['SUBSCRIBED'], //seeded by getMailboxes
2473 2473
 							);
2474 2474
 							if ($mbx['SUBSCRIBED'] && !isset($subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']]))
2475 2475
 							{
2476 2476
 								$subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']] = $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']];
2477 2477
 							}
2478 2478
 						}
2479
-						if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'],$foldersNameSpace[$type]['subscribed'])))
2479
+						if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'], $foldersNameSpace[$type]['subscribed'])))
2480 2480
 						{
2481 2481
 							$foldersNameSpace[$type]['subscribed'][] = $mbx['MAILBOX'];
2482 2482
 						}
2483 2483
 						//echo __METHOD__;_debug_array($mbx);
2484 2484
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx));
2485
-						if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])||
2486
-							isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])||
2487
-							(substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)]))
2485
+						if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']]) ||
2486
+							isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']]) ||
2487
+							(substr($mbx['MAILBOX'], -1) == $foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'], 0, -1)]))
2488 2488
 						) continue;
2489 2489
 
2490 2490
 						//echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>";
@@ -2494,7 +2494,7 @@  discard block
 block discarded – undo
2494 2494
 					//_debug_array(array_keys($allMailBoxesExtSorted));
2495 2495
 					$allMailboxes = array();
2496 2496
 					foreach ((array)$allMailBoxesExtSorted as $mbx) {
2497
-						if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX'];
2497
+						if (!in_array($mbx['MAILBOX'], $allMailboxes)) $allMailboxes[] = $mbx['MAILBOX'];
2498 2498
 						//echo "Result:";_debug_array($allMailboxes);
2499 2499
 					}
2500 2500
 					$foldersNameSpace[$type]['all'] = $allMailboxes;
@@ -2503,57 +2503,57 @@  discard block
 block discarded – undo
2503 2503
 			}
2504 2504
 		}
2505 2505
 		//subscribed folders may be used in getFolderStatus
2506
-		egw_cache::setCache(egw_cache::INSTANCE,'email','subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$subscribedFoldersForCache,$expiration=60*60*1);
2506
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $subscribedFoldersForCache, $expiration = 60 * 60 * 1);
2507 2507
 		//echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
2508 2508
 		$autoFolderObjects = $folders = array();
2509 2509
 		$autofolder_exists = array();
2510
-		foreach( array('personal', 'others', 'shared') as $type) {
2511
-			if(isset($foldersNameSpace[$type])) {
2512
-				if($_subscribedOnly) {
2513
-					if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed'];
2510
+		foreach (array('personal', 'others', 'shared') as $type) {
2511
+			if (isset($foldersNameSpace[$type])) {
2512
+				if ($_subscribedOnly) {
2513
+					if (!empty($foldersNameSpace[$type]['subscribed'])) $listOfFolders = $foldersNameSpace[$type]['subscribed'];
2514 2514
 				} else {
2515
-					if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all'];
2515
+					if (!empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all'];
2516 2516
 				}
2517
-				foreach((array)$listOfFolders as $folderName) {
2517
+				foreach ((array)$listOfFolders as $folderName) {
2518 2518
 					//echo "<br>FolderToCheck:$folderName<br>";
2519 2519
 					//error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName);
2520
-					if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go.
2521
-					if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) {
2520
+					if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue; //when subscribedonly, we fetch all folders in one go.
2521
+					if ($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all']) || in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) {
2522 2522
 						#echo "$folderName failed to be here <br>";
2523 2523
 						continue;
2524 2524
 					}
2525 2525
 					if (isset($folders[$folderName])) continue;
2526 2526
 					if (isset($autoFolderObjects[$folderName])) continue;
2527
-					if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter'];
2527
+					if (empty($delimiter) || $delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter'];
2528 2528
 					$folderParts = explode($delimiter, $folderName);
2529 2529
 					$shortName = array_pop($folderParts);
2530 2530
 
2531 2531
 					$folderObject = new stdClass;
2532
-					$folderObject->delimiter	= $delimiter;
2533
-					$folderObject->folderName	= $folderName;
2534
-					$folderObject->shortFolderName	= $shortName;
2535
-					if(!$_subscribedOnly) {
2532
+					$folderObject->delimiter = $delimiter;
2533
+					$folderObject->folderName = $folderName;
2534
+					$folderObject->shortFolderName = $shortName;
2535
+					if (!$_subscribedOnly) {
2536 2536
 						#echo $folderName."->".$type."<br>";
2537 2537
 						#_debug_array($foldersNameSpace[$type]['subscribed']);
2538 2538
 						$folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']);
2539 2539
 					}
2540 2540
 
2541
-					if($_getCounters == true) {
2541
+					if ($_getCounters == true) {
2542 2542
 						//error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName);
2543 2543
 						$folderObject->counter = $this->getMailBoxCounters($folderName);
2544 2544
 					}
2545
-					if(strtoupper($folderName) == 'INBOX') {
2545
+					if (strtoupper($folderName) == 'INBOX') {
2546 2546
 						$folderName = 'INBOX';
2547
-						$folderObject->folderName	= 'INBOX';
2548
-						$folderObject->shortFolderName	= 'INBOX';
2549
-						$folderObject->displayName	= lang('INBOX');
2547
+						$folderObject->folderName = 'INBOX';
2548
+						$folderObject->shortFolderName = 'INBOX';
2549
+						$folderObject->displayName = lang('INBOX');
2550 2550
 						$folderObject->shortDisplayName = lang('INBOX');
2551
-						$folderObject->subscribed	= true;
2551
+						$folderObject->subscribed = true;
2552 2552
 					// translate the automatic Folders (Sent, Drafts, ...) like the INBOX
2553
-					} elseif (in_array($shortName,self::$autoFolders)) {
2554
-						$tmpfolderparts = explode($delimiter,$folderObject->folderName);
2553
+					} elseif (in_array($shortName, self::$autoFolders)) {
2554
+						$tmpfolderparts = explode($delimiter, $folderObject->folderName);
2555 2555
 						array_pop($tmpfolderparts);
2556
-						$folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName);
2556
+						$folderObject->displayName = implode($delimiter, $tmpfolderparts).$delimiter.lang($shortName);
2557 2557
 						$folderObject->shortDisplayName = lang($shortName);
2558 2558
 						unset($tmpfolderparts);
2559 2559
 					} else {
@@ -2561,13 +2561,13 @@  discard block
 block discarded – undo
2561 2561
 						$folderObject->shortDisplayName = $shortName;
2562 2562
 					}
2563 2563
 					//$folderName = $folderName;
2564
-					if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) {
2564
+					if (in_array($shortName, self::$autoFolders) && self::searchValueInFolderObjects($shortName, $autoFolderObjects) === false) {
2565 2565
 						$autoFolderObjects[$folderName] = $folderObject;
2566 2566
 					} else {
2567 2567
 						$folders[$folderName] = $folderObject;
2568 2568
 					}
2569 2569
 					//error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName);
2570
-					if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders ();
2570
+					if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders();
2571 2571
 					if (isset(self::$specialUseFolders[$folderName]))
2572 2572
 					{
2573 2573
 						$autofolder_exists[$folderName] = self::$specialUseFolders[$folderName];
@@ -2576,27 +2576,27 @@  discard block
 block discarded – undo
2576 2576
 			}
2577 2577
 		}
2578 2578
 		if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) {
2579
-			uasort($autoFolderObjects,array($this,"sortByAutoFolderPos"));
2579
+			uasort($autoFolderObjects, array($this, "sortByAutoFolderPos"));
2580 2580
 		}
2581 2581
 		// check if some standard folders are missing and need to be created
2582 2582
 		if (count($autofolder_exists) < count(self::$autoFolders) && $this->check_create_autofolders($autofolder_exists))
2583 2583
 		{
2584 2584
 			// if new folders have been created, re-read folders ignoring the cache
2585
-			return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false);	// false = do NOT use cache
2585
+			return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache
2586 2586
 		}
2587
-		if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName"));
2587
+		if (is_array($folders)) uasort($folders, array($this, "sortByDisplayName"));
2588 2588
 		//$folders2return = array_merge($autoFolderObjects,$folders);
2589 2589
 		//_debug_array($folders2return); #exit;
2590
-		$folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders);
2591
-		if (($_subscribedOnly && $_getCounters===false) ||
2592
-			($_subscribedOnly == false && $_getCounters===false &&
2590
+		$folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject, (array)$autoFolderObjects, (array)$folders);
2591
+		if (($_subscribedOnly && $_getCounters === false) ||
2592
+			($_subscribedOnly == false && $_getCounters === false &&
2593 2593
 			isset($this->mailPreferences['showAllFoldersInFolderPane']) &&
2594
-			$this->mailPreferences['showAllFoldersInFolderPane']==1))
2594
+			$this->mailPreferences['showAllFoldersInFolderPane'] == 1))
2595 2595
 		{
2596
-			egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1);
2596
+			egw_cache::setCache(egw_cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), $folders2return, $expiration = 60 * 60 * 1);
2597 2597
 		}
2598
-		egw_cache::setCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1);
2599
-		if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') ');
2598
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderBasicInfo, $expiration = 60 * 60 * 1);
2599
+		if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') ');
2600 2600
 		return $folders2return[$this->icServer->ImapServerId];
2601 2601
 	}
2602 2602
 
@@ -2617,21 +2617,21 @@  discard block
 block discarded – undo
2617 2617
 	 *
2618 2618
 	 * @return array arrays of folders
2619 2619
 	 */
2620
-	function getFolderArrays ($_nodePath = null, $_onlyTopLevel = false, $_search= 2, $_subscribedOnly = false, $_getCounter = false)
2620
+	function getFolderArrays($_nodePath = null, $_onlyTopLevel = false, $_search = 2, $_subscribedOnly = false, $_getCounter = false)
2621 2621
 	{
2622 2622
 		// delimiter
2623 2623
 		$delimiter = $this->getHierarchyDelimiter();
2624 2624
 
2625
-		$folders = $nameSpace =  array();
2625
+		$folders = $nameSpace = array();
2626 2626
 		$nameSpaceTmp = $this->_getNameSpaces();
2627
-		foreach($nameSpaceTmp as $k => $singleNameSpace) {
2628
-			$nameSpace[$singleNameSpace['type']]=$singleNameSpace;
2627
+		foreach ($nameSpaceTmp as $k => $singleNameSpace) {
2628
+			$nameSpace[$singleNameSpace['type']] = $singleNameSpace;
2629 2629
 		}
2630 2630
 		unset($nameSpaceTmp);
2631 2631
 
2632 2632
 		//error_log(__METHOD__.__LINE__.array2string($nameSpace));
2633 2633
 		// Get special use folders
2634
-		if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders
2634
+		if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); // Set self::$specialUseFolders
2635 2635
 		// topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace
2636 2636
 		if ($_onlyTopLevel) // top level leaves
2637 2637
 		{
@@ -2642,20 +2642,20 @@  discard block
 block discarded – undo
2642 2642
 			if (is_null(self::$mailConfig)) self::$mailConfig = config::read('mail');
2643 2643
 			if (self::$mailConfig['examineNamespace'])
2644 2644
 			{
2645
-				$prefixes=array();
2645
+				$prefixes = array();
2646 2646
 				if (is_array($nameSpace))
2647 2647
 				{
2648
-					foreach($nameSpace as $k => $singleNameSpace) {
2648
+					foreach ($nameSpace as $k => $singleNameSpace) {
2649 2649
 						$type = $singleNameSpace['type'];
2650 2650
 
2651
-						if(is_array($singleNameSpace) && $singleNameSpace['prefix']){
2651
+						if (is_array($singleNameSpace) && $singleNameSpace['prefix']) {
2652 2652
 							$prefixes[$type] = $singleNameSpace['prefix'];
2653 2653
 							//regard extra care for nameSpacequeries when configured AND respect $_search
2654
-							$result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true);
2654
+							$result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search == 0 ? 0 : 2, true);
2655 2655
 							if (is_array($result))
2656 2656
 							{
2657 2657
 								ksort($result);
2658
-								$topFolders = array_merge($topFolders,$result);
2658
+								$topFolders = array_merge($topFolders, $result);
2659 2659
 							}
2660 2660
 						}
2661 2661
 					}
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
 
2665 2665
 			$autofolders = array();
2666 2666
 
2667
-			foreach(self::$specialUseFolders as $path => $folder)
2667
+			foreach (self::$specialUseFolders as $path => $folder)
2668 2668
 			{
2669 2669
 				if ($this->folderExists($path))
2670 2670
 				{
@@ -2672,9 +2672,9 @@  discard block
 block discarded – undo
2672 2672
 				}
2673 2673
 			}
2674 2674
 			// Check if the special use folders are there, otherwise try to create them
2675
-			if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders ($autofolders))
2675
+			if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders($autofolders))
2676 2676
 			{
2677
-				return $this->getFolderArrays ($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter);
2677
+				return $this->getFolderArrays($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter);
2678 2678
 			}
2679 2679
 
2680 2680
 			// now process topFolders for next level
@@ -2682,13 +2682,13 @@  discard block
 block discarded – undo
2682 2682
 			{
2683 2683
 				$pattern = "/\\".$delimiter."/";
2684 2684
 				$reference = preg_replace($pattern, '', $node['MAILBOX']);
2685
-				if(!empty($prefixes))
2685
+				if (!empty($prefixes))
2686 2686
 				{
2687 2687
 					$reference = '';
2688
-					$tmpArray = explode($delimiter,$node['MAILBOX']);
2689
-					foreach($tmpArray as $p)
2688
+					$tmpArray = explode($delimiter, $node['MAILBOX']);
2689
+					foreach ($tmpArray as $p)
2690 2690
 					{
2691
-						$reference = empty($reference)?$p:$reference.$delimiter.$p;
2691
+						$reference = empty($reference) ? $p : $reference.$delimiter.$p;
2692 2692
 					}
2693 2693
 				}
2694 2694
 				$mainFolder = $subFolders = array();
@@ -2724,19 +2724,19 @@  discard block
 block discarded – undo
2724 2724
 							$nFolders [$path] = $folder;
2725 2725
 						}
2726 2726
 					}
2727
-					if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder'));
2727
+					if (is_array($aFolders)) uasort($aFolders, array($this, 'sortByAutofolder'));
2728 2728
 					//ksort($aFolders);
2729 2729
 
2730 2730
 					// Sort none auto folders base on mailbox name
2731
-					uasort($nFolders,array($this,'sortByMailbox'));
2731
+					uasort($nFolders, array($this, 'sortByMailbox'));
2732 2732
 
2733
-					$subFolders = array_merge($aFolders,$nFolders);
2733
+					$subFolders = array_merge($aFolders, $nFolders);
2734 2734
 				}
2735 2735
 				else
2736 2736
 				{
2737 2737
 					if (is_array($subFolders)) ksort($subFolders);
2738 2738
 				}
2739
-				$folders = array_merge($folders,(array)$mainFolder, (array)$subFolders);
2739
+				$folders = array_merge($folders, (array)$mainFolder, (array)$subFolders);
2740 2740
 			}
2741 2741
 		}
2742 2742
 		elseif ($_nodePath) // single node
@@ -2763,9 +2763,9 @@  discard block
 block discarded – undo
2763 2763
 				$folders = $this->icServer->getMailboxes($path, $_search, true);
2764 2764
 			}
2765 2765
 
2766
-			uasort($folders,array($this,'sortByMailbox'));//ksort($folders);
2766
+			uasort($folders, array($this, 'sortByMailbox')); //ksort($folders);
2767 2767
 		}
2768
-		elseif(!$_nodePath) // all
2768
+		elseif (!$_nodePath) // all
2769 2769
 		{
2770 2770
 			if ($_subscribedOnly)
2771 2771
 			{
@@ -2781,98 +2781,98 @@  discard block
 block discarded – undo
2781 2781
 		{
2782 2782
 			// SORTING FOLDERS
2783 2783
 			//self::$debugTimes=true;
2784
-			if (self::$debugTimes) $starttime = microtime (true);
2784
+			if (self::$debugTimes) $starttime = microtime(true);
2785 2785
 			// Merge of all auto folders and specialusefolders
2786 2786
 			$autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders))));
2787
-			uasort($folders,array($this,'sortByMailbox'));//ksort($folders);
2787
+			uasort($folders, array($this, 'sortByMailbox')); //ksort($folders);
2788 2788
 			$tmpFolders = $folders;
2789
-			$inboxFolderObject=$inboxSubFolderObjects=$autoFolderObjects=$typeFolderObject=$mySpecialUseFolders=array();
2790
-			$googleMailFolderObject=$googleAutoFolderObjects=$googleSubFolderObjects=array();
2791
-			$isGoogleMail=false;
2792
-			foreach($autoFoldersTmp as $afk=>$aF)
2789
+			$inboxFolderObject = $inboxSubFolderObjects = $autoFolderObjects = $typeFolderObject = $mySpecialUseFolders = array();
2790
+			$googleMailFolderObject = $googleAutoFolderObjects = $googleSubFolderObjects = array();
2791
+			$isGoogleMail = false;
2792
+			foreach ($autoFoldersTmp as $afk=>$aF)
2793 2793
 			{
2794
-				if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false);
2794
+				if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF] = $this->getFolderByType($aF, false);
2795 2795
 				//error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
2796 2796
 			}
2797 2797
 			//error_log(array2string($mySpecialUseFolders));
2798 2798
 			foreach ($tmpFolders as $k => $f) {
2799
-				$sorted=false;
2800
-				if (strtoupper(substr($k,0,5))=='INBOX') {
2801
-					if (strtoupper($k)=='INBOX') {
2799
+				$sorted = false;
2800
+				if (strtoupper(substr($k, 0, 5)) == 'INBOX') {
2801
+					if (strtoupper($k) == 'INBOX') {
2802 2802
 						//error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k);
2803
-						$inboxFolderObject[$k]=$f;
2803
+						$inboxFolderObject[$k] = $f;
2804 2804
 						unset($folders[$k]);
2805
-						$sorted=true;
2805
+						$sorted = true;
2806 2806
 					} else {
2807
-						$isAutoFolder=false;
2808
-						foreach($autoFoldersTmp as $afk=>$aF)
2807
+						$isAutoFolder = false;
2808
+						foreach ($autoFoldersTmp as $afk=>$aF)
2809 2809
 						{
2810 2810
 							//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
2811
-							if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
2812
-								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter))
2811
+							if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
2812
+								($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter))
2813 2813
 							{
2814 2814
 								//error_log($k.'->'.$mySpecialUseFolders[$aF]);
2815
-								$isAutoFolder=true;
2816
-								$autoFolderObjects[$k]=$f;
2815
+								$isAutoFolder = true;
2816
+								$autoFolderObjects[$k] = $f;
2817 2817
 								break;
2818 2818
 							}
2819 2819
 						}
2820
-						if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f;
2820
+						if ($isAutoFolder == false) $inboxSubFolderObjects[$k] = $f;
2821 2821
 						unset($folders[$k]);
2822
-						$sorted=true;
2822
+						$sorted = true;
2823 2823
 					}
2824
-				} elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') {
2825
-					$isGoogleMail=true;
2826
-					if (strtoupper($k)=='[GOOGLE MAIL]') {
2827
-						$googleMailFolderObject[$k]=$f;
2824
+				} elseif (strtoupper(substr($k, 0, 13)) == '[GOOGLE MAIL]') {
2825
+					$isGoogleMail = true;
2826
+					if (strtoupper($k) == '[GOOGLE MAIL]') {
2827
+						$googleMailFolderObject[$k] = $f;
2828 2828
 						unset($folders[$k]);
2829
-						$sorted=true;
2829
+						$sorted = true;
2830 2830
 					} else {
2831
-						$isAutoFolder=false;
2832
-						foreach($autoFoldersTmp as $afk=>$aF)
2831
+						$isAutoFolder = false;
2832
+						foreach ($autoFoldersTmp as $afk=>$aF)
2833 2833
 						{
2834 2834
 							//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
2835
-							if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
2836
-								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter))
2835
+							if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
2836
+								($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter))
2837 2837
 							{
2838 2838
 								//error_log($k.'->'.$mySpecialUseFolders[$aF]);
2839
-								$isAutoFolder=true;
2840
-								$googleAutoFolderObjects[$k]=$f;
2839
+								$isAutoFolder = true;
2840
+								$googleAutoFolderObjects[$k] = $f;
2841 2841
 								break;
2842 2842
 							}
2843 2843
 						}
2844
-						if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f;
2844
+						if ($isAutoFolder == false) $googleSubFolderObjects[$k] = $f;
2845 2845
 						unset($folders[$k]);
2846
-						$sorted=true;
2846
+						$sorted = true;
2847 2847
 					}
2848 2848
 				} else {
2849
-					$isAutoFolder=false;
2850
-					foreach($autoFoldersTmp as $afk=>$aF)
2849
+					$isAutoFolder = false;
2850
+					foreach ($autoFoldersTmp as $afk=>$aF)
2851 2851
 					{
2852 2852
 						//error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]);
2853
-						if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
2854
-								($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter))
2853
+						if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/
2854
+								($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter))
2855 2855
 						{
2856 2856
 							//error_log($k.'->'.$mySpecialUseFolders[$aF]);
2857
-							$isAutoFolder=true;
2858
-							$autoFolderObjects[$k]=$f;
2857
+							$isAutoFolder = true;
2858
+							$autoFolderObjects[$k] = $f;
2859 2859
 							unset($folders[$k]);
2860
-							$sorted=true;
2860
+							$sorted = true;
2861 2861
 							break;
2862 2862
 						}
2863 2863
 					}
2864 2864
 				}
2865 2865
 
2866
-				if ($sorted==false)
2866
+				if ($sorted == false)
2867 2867
 				{
2868
-					foreach(array('others','shared') as $type)
2868
+					foreach (array('others', 'shared') as $type)
2869 2869
 					{
2870
-						if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix'])
2870
+						if ($nameSpace[$type]['prefix_present'] && $nameSpace[$type]['prefix'])
2871 2871
 						{
2872
-							if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']||
2873
-								substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) {
2872
+							if (substr($k, 0, strlen($nameSpace[$type]['prefix'])) == $nameSpace[$type]['prefix'] ||
2873
+								substr($k, 0, strlen($nameSpace[$type]['prefix']) - strlen($nameSpace[$type]['delimiter'])) == substr($nameSpace[$type]['prefix'], 0, strlen($nameSpace[$type]['delimiter']) * -1)) {
2874 2874
 								//error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k);
2875
-								$typeFolderObject[$type][$k]=$f;
2875
+								$typeFolderObject[$type][$k] = $f;
2876 2876
 								unset($folders[$k]);
2877 2877
 							}
2878 2878
 						}
@@ -2883,38 +2883,38 @@  discard block
 block discarded – undo
2883 2883
 			// avoid calling sortByAutoFolder as it is not regarding subfolders
2884 2884
 			$autoFolderObjectsTmp = $autoFolderObjects;
2885 2885
 			unset($autoFolderObjects);
2886
-			uasort($autoFolderObjectsTmp, array($this,'sortByMailbox'));
2887
-			foreach($autoFoldersTmp as $afk=>$aF)
2886
+			uasort($autoFolderObjectsTmp, array($this, 'sortByMailbox'));
2887
+			foreach ($autoFoldersTmp as $afk=>$aF)
2888 2888
 			{
2889
-				foreach($autoFolderObjectsTmp as $k => $f)
2889
+				foreach ($autoFolderObjectsTmp as $k => $f)
2890 2890
 				{
2891
-					if($aF && ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter))
2891
+					if ($aF && ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter))
2892 2892
 					{
2893
-						$autoFolderObjects[$k]=$f;
2893
+						$autoFolderObjects[$k] = $f;
2894 2894
 					}
2895 2895
 				}
2896 2896
 			}
2897 2897
 			//error_log(__METHOD__.__LINE__.array2string($autoFolderObjects));
2898 2898
 			if (!$isGoogleMail) {
2899
-				$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']);
2899
+				$folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$inboxSubFolderObjects, (array)$folders, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']);
2900 2900
 			} else {
2901 2901
 				// avoid calling sortByAutoFolder as it is not regarding subfolders
2902 2902
 				$gAutoFolderObjectsTmp = $googleAutoFolderObjects;
2903 2903
 				unset($googleAutoFolderObjects);
2904
-				uasort($gAutoFolderObjectsTmp, array($this,'sortByMailbox'));
2905
-				foreach($autoFoldersTmp as $afk=>$aF)
2904
+				uasort($gAutoFolderObjectsTmp, array($this, 'sortByMailbox'));
2905
+				foreach ($autoFoldersTmp as $afk=>$aF)
2906 2906
 				{
2907
-					foreach($gAutoFolderObjectsTmp as $k => $f)
2907
+					foreach ($gAutoFolderObjectsTmp as $k => $f)
2908 2908
 					{
2909
-						if($aF && ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter))
2909
+						if ($aF && ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter))
2910 2910
 						{
2911
-							$googleAutoFolderObjects[$k]=$f;
2911
+							$googleAutoFolderObjects[$k] = $f;
2912 2912
 						}
2913 2913
 					}
2914 2914
 				}
2915
-				$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']);
2915
+				$folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$folders, (array)$googleMailFolderObject, $googleAutoFolderObjects, $googleSubFolderObjects, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']);
2916 2916
 			}
2917
-			if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:');
2917
+			if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') Sorting:');
2918 2918
 			//self::$debugTimes=false;
2919 2919
 		}
2920 2920
 		// Get counter information and add them to each fetched folders array
@@ -2936,10 +2936,10 @@  discard block
 block discarded – undo
2936 2936
 	 * @param array $autofolders_exists existing folders, no need to check their existance again
2937 2937
 	 * @return int number of new folders created
2938 2938
 	 */
2939
-	function check_create_autofolders(array $autofolders_exists=array())
2939
+	function check_create_autofolders(array $autofolders_exists = array())
2940 2940
 	{
2941 2941
 		$num_created = 0;
2942
-		foreach(self::$autoFolders as $folder)
2942
+		foreach (self::$autoFolders as $folder)
2943 2943
 		{
2944 2944
 			$created = false;
2945 2945
 			if (!in_array($folder, $autofolders_exists) && $this->_getSpecialUseFolder($folder, true, $created) &&
@@ -2964,7 +2964,7 @@  discard block
 block discarded – undo
2964 2964
 		$rv = false;
2965 2965
 		foreach ($haystack as $k => $v)
2966 2966
 		{
2967
-			foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;}
2967
+			foreach ($v as &$sv) {if (trim($sv) == trim($needle)) return $k; }
2968 2968
 		}
2969 2969
 		return $rv;
2970 2970
 	}
@@ -2977,9 +2977,9 @@  discard block
 block discarded – undo
2977 2977
 	 * @param array $b array of folders
2978 2978
 	 * @return int expect values (0, 1 or -1)
2979 2979
 	 */
2980
-	function sortByMailbox($a,$b)
2980
+	function sortByMailbox($a, $b)
2981 2981
 	{
2982
-		return strcasecmp($a['MAILBOX'],$b['MAILBOX']);
2982
+		return strcasecmp($a['MAILBOX'], $b['MAILBOX']);
2983 2983
 	}
2984 2984
 
2985 2985
 	/**
@@ -2990,13 +2990,13 @@  discard block
 block discarded – undo
2990 2990
 	 * @param array $b
2991 2991
 	 * @return int expect values (0, 1 or -1)
2992 2992
 	 */
2993
-	function sortByAutoFolder($a,$b)
2993
+	function sortByAutoFolder($a, $b)
2994 2994
 	{
2995 2995
 		// 0, 1 und -1
2996 2996
 		$a = mail_tree::pathToFolderData($a['MAILBOX'], $a['delimiter']);
2997 2997
 		$b = mail_tree::pathToFolderData($b['MAILBOX'], $b['delimiter']);
2998
-		$pos1 = array_search(trim($a['name']),self::$autoFolders);
2999
-		$pos2 = array_search(trim($b['name']),self::$autoFolders);
2998
+		$pos1 = array_search(trim($a['name']), self::$autoFolders);
2999
+		$pos2 = array_search(trim($b['name']), self::$autoFolders);
3000 3000
 		if ($pos1 == $pos2) return 0;
3001 3001
 		return ($pos1 < $pos2) ? -1 : 1;
3002 3002
 	}
@@ -3009,10 +3009,10 @@  discard block
 block discarded – undo
3009 3009
 	 * @param object $b array of folderobjects
3010 3010
 	 * @return int expect values (0, 1 or -1)
3011 3011
 	 */
3012
-	function sortByDisplayName($a,$b)
3012
+	function sortByDisplayName($a, $b)
3013 3013
 	{
3014 3014
 		// 0, 1 und -1
3015
-		return strcasecmp($a->displayName,$b->displayName);
3015
+		return strcasecmp($a->displayName, $b->displayName);
3016 3016
 	}
3017 3017
 
3018 3018
 	/**
@@ -3023,11 +3023,11 @@  discard block
 block discarded – undo
3023 3023
 	 * @param object $b array of folderobjects
3024 3024
 	 * @return int expect values (0, 1 or -1)
3025 3025
 	 */
3026
-	function sortByAutoFolderPos($a,$b)
3026
+	function sortByAutoFolderPos($a, $b)
3027 3027
 	{
3028 3028
 		// 0, 1 und -1
3029
-		$pos1 = array_search(trim($a->shortFolderName),self::$autoFolders);
3030
-		$pos2 = array_search(trim($b->shortFolderName),self::$autoFolders);
3029
+		$pos1 = array_search(trim($a->shortFolderName), self::$autoFolders);
3030
+		$pos2 = array_search(trim($b->shortFolderName), self::$autoFolders);
3031 3031
 		if ($pos1 == $pos2) return 0;
3032 3032
 		return ($pos1 < $pos2) ? -1 : 1;
3033 3033
 	}
@@ -3040,7 +3040,7 @@  discard block
 block discarded – undo
3040 3040
 	 * @param boolean $_returnObject return the counters as object rather than an array
3041 3041
 	 * @return mixed false or array of counters array(MESSAGES,UNSEEN,RECENT,UIDNEXT,UIDVALIDITY) or object
3042 3042
 	 */
3043
-	function getMailBoxCounters($folderName,$_returnObject=true)
3043
+	function getMailBoxCounters($folderName, $_returnObject = true)
3044 3044
 	{
3045 3045
 		try
3046 3046
 		{
@@ -3052,9 +3052,9 @@  discard block
 block discarded – undo
3052 3052
 			if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage());
3053 3053
 			return false;
3054 3054
 		}
3055
-		if(is_array($folderStatus)) {
3056
-			if ($_returnObject===false) return $folderStatus;
3057
-			$status =  new stdClass;
3055
+		if (is_array($folderStatus)) {
3056
+			if ($_returnObject === false) return $folderStatus;
3057
+			$status = new stdClass;
3058 3058
 			$status->messages   = $folderStatus['MESSAGES'];
3059 3059
 			$status->unseen     = $folderStatus['UNSEEN'];
3060 3060
 			$status->recent     = $folderStatus['RECENT'];
@@ -3076,42 +3076,42 @@  discard block
 block discarded – undo
3076 3076
 	 * @param string $reclevel 0, counter to keep track of the current recursionlevel
3077 3077
 	 * @return array of mailboxes
3078 3078
 	 */
3079
-	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
3079
+	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0)
3080 3080
 	{
3081 3081
 		#echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>";
3082
-		$maxreclevel=25;
3082
+		$maxreclevel = 25;
3083 3083
 		if ($reclevel > $maxreclevel) {
3084
-			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
3084
+			error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
3085 3085
 			return array();
3086 3086
 		}
3087 3087
 		$reclevel++;
3088 3088
 		// clean up double delimiters
3089
-		$_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox);
3089
+		$_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox);
3090 3090
 		//get that mailbox in question
3091
-		$mbx = $this->icServer->getMailboxes($_mailbox,1,true);
3091
+		$mbx = $this->icServer->getMailboxes($_mailbox, 1, true);
3092 3092
 		$mbxkeys = array_keys($mbx);
3093 3093
 		#_debug_array($mbx);
3094 3094
 //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter));
3095 3095
 //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx));
3096 3096
 		// Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /))
3097
-		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) {
3097
+		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) {
3098 3098
 			// if there are children fetch them
3099 3099
 			//echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>";
3100 3100
 
3101
-			$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false);
3101
+			$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false);
3102 3102
 			//$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false);
3103 3103
 			//_debug_array($buff);
3104 3104
 			$allMailboxes = array();
3105 3105
 			foreach ($buff as $mbxname) {
3106 3106
 //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname));
3107
-				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
3107
+				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']);
3108 3108
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
3109
-				if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix  && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
3109
+				if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
3110 3110
 				{
3111 3111
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
3112 3112
 				}
3113 3113
 			}
3114
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
3114
+			if (!(in_array('\NoSelect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
3115 3115
 			return $allMailboxes;
3116 3116
 		} else {
3117 3117
 			return array($_mailbox);
@@ -3126,17 +3126,17 @@  discard block
 block discarded – undo
3126 3126
 	 * @param boolean& $created =null on return true: if folder was just created, false if not
3127 3127
 	 * @return mixed string or false
3128 3128
 	 */
3129
-	function _getSpecialUseFolder($_type, $_checkexistance=TRUE, &$created=null)
3129
+	function _getSpecialUseFolder($_type, $_checkexistance = TRUE, &$created = null)
3130 3130
 	{
3131 3131
 		static $types = array(
3132
-			'Drafts'   => array('profileKey'=>'acc_folder_draft','autoFolderName'=>'Drafts'),
3133
-			'Template' => array('profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'),
3134
-			'Trash'    => array('profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'),
3135
-			'Sent'     => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'),
3136
-			'Junk'     => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'),
3137
-			'Outbox'   => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'),
3132
+			'Drafts'   => array('profileKey'=>'acc_folder_draft', 'autoFolderName'=>'Drafts'),
3133
+			'Template' => array('profileKey'=>'acc_folder_template', 'autoFolderName'=>'Templates'),
3134
+			'Trash'    => array('profileKey'=>'acc_folder_trash', 'autoFolderName'=>'Trash'),
3135
+			'Sent'     => array('profileKey'=>'acc_folder_sent', 'autoFolderName'=>'Sent'),
3136
+			'Junk'     => array('profileKey'=>'acc_folder_junk', 'autoFolderName'=>'Junk'),
3137
+			'Outbox'   => array('profileKey'=>'acc_folder_outbox', 'autoFolderName'=>'Outbox'),
3138 3138
 		);
3139
-		if ($_type == 'Templates') $_type = 'Template';	// for some reason self::$autofolders uses 'Templates'!
3139
+		if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'!
3140 3140
 		$created = false;
3141 3141
 		if (!isset($types[$_type]))
3142 3142
 		{
@@ -3157,38 +3157,38 @@  discard block
 block discarded – undo
3157 3157
 			$_folderName = false;
3158 3158
 		}
3159 3159
 		// does the folder exist??? (is configured/preset, but non-existent)
3160
-		if ($_folderName && $_checkexistance && $_folderName !='none' && !$this->folderExists($_folderName,true)) {
3160
+		if ($_folderName && $_checkexistance && $_folderName != 'none' && !$this->folderExists($_folderName, true)) {
3161 3161
 			try
3162 3162
 			{
3163 3163
 				$error = null;
3164 3164
 				if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true;
3165 3165
 				if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
3166 3166
 			}
3167
-			catch(Exception $e)
3167
+			catch (Exception $e)
3168 3168
 			{
3169 3169
 				error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage().':'.function_backtrace());
3170 3170
 				$_folderName = false;
3171 3171
 			}
3172 3172
 		}
3173 3173
 		// not sure yet if false is the correct behavior on none
3174
-		if ($_folderName =='none') return 'none' ; //false;
3174
+		if ($_folderName == 'none') return 'none'; //false;
3175 3175
 		//no (valid) folder found yet; try specialUseFolders
3176
-		if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f;
3176
+		if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type, self::$specialUseFolders))) $_folderName = $f;
3177 3177
 		//no specialUseFolder; try some Defaults
3178 3178
 		if (empty($_folderName) && isset($types[$_type]))
3179 3179
 		{
3180 3180
 			$nameSpace = $this->_getNameSpaces();
3181
-			$prefix='';
3181
+			$prefix = '';
3182 3182
 			foreach ($nameSpace as $nSp)
3183 3183
 			{
3184
-				if ($nSp['type']=='personal')
3184
+				if ($nSp['type'] == 'personal')
3185 3185
 				{
3186 3186
 					//error_log(__METHOD__.__LINE__.array2string($nSp));
3187 3187
 					$prefix = $nSp['prefix'];
3188 3188
 					break;
3189 3189
 				}
3190 3190
 			}
3191
-			if ($this->folderExists($prefix.$types[$_type]['autoFolderName'],true))
3191
+			if ($this->folderExists($prefix.$types[$_type]['autoFolderName'], true))
3192 3192
 			{
3193 3193
 				$_folderName = $prefix.$types[$_type]['autoFolderName'];
3194 3194
 			}
@@ -3197,11 +3197,11 @@  discard block
 block discarded – undo
3197 3197
 				try
3198 3198
 				{
3199 3199
 					$error = null;
3200
-					$this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error);
3200
+					$this->createFolder('', $prefix.$types[$_type]['autoFolderName'], $error);
3201 3201
 					$_folderName = $prefix.$types[$_type]['autoFolderName'];
3202 3202
 					if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error);
3203 3203
 				}
3204
-				catch(Exception $e)
3204
+				catch (Exception $e)
3205 3205
 				{
3206 3206
 					error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage());
3207 3207
 					$_folderName = false;
@@ -3217,7 +3217,7 @@  discard block
 block discarded – undo
3217 3217
 	 * @param boolean $_checkexistance trigger check for existance
3218 3218
 	 * @return mixed string or false
3219 3219
 	 */
3220
-	function getFolderByType($type, $_checkexistance=false)
3220
+	function getFolderByType($type, $_checkexistance = false)
3221 3221
 	{
3222 3222
 		return $this->_getSpecialUseFolder($type, $_checkexistance);
3223 3223
 	}
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
 	 * @param boolean $_checkexistance trigger check for existance
3228 3228
 	 * @return mixed string or false
3229 3229
 	 */
3230
-	function getJunkFolder($_checkexistance=TRUE)
3230
+	function getJunkFolder($_checkexistance = TRUE)
3231 3231
 	{
3232 3232
 		return $this->_getSpecialUseFolder('Junk', $_checkexistance);
3233 3233
 	}
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
 	 * @param boolean $_checkexistance trigger check for existance
3238 3238
 	 * @return mixed string or false
3239 3239
 	 */
3240
-	function getDraftFolder($_checkexistance=TRUE)
3240
+	function getDraftFolder($_checkexistance = TRUE)
3241 3241
 	{
3242 3242
 		return $this->_getSpecialUseFolder('Drafts', $_checkexistance);
3243 3243
 	}
@@ -3247,7 +3247,7 @@  discard block
 block discarded – undo
3247 3247
 	 * @param boolean $_checkexistance trigger check for existance
3248 3248
 	 * @return mixed string or false
3249 3249
 	 */
3250
-	function getTemplateFolder($_checkexistance=TRUE)
3250
+	function getTemplateFolder($_checkexistance = TRUE)
3251 3251
 	{
3252 3252
 		return $this->_getSpecialUseFolder('Template', $_checkexistance);
3253 3253
 	}
@@ -3257,7 +3257,7 @@  discard block
 block discarded – undo
3257 3257
 	 * @param boolean $_checkexistance trigger check for existance
3258 3258
 	 * @return mixed string or false
3259 3259
 	 */
3260
-	function getTrashFolder($_checkexistance=TRUE)
3260
+	function getTrashFolder($_checkexistance = TRUE)
3261 3261
 	{
3262 3262
 		return $this->_getSpecialUseFolder('Trash', $_checkexistance);
3263 3263
 	}
@@ -3267,7 +3267,7 @@  discard block
 block discarded – undo
3267 3267
 	 * @param boolean $_checkexistance trigger check for existance
3268 3268
 	 * @return mixed string or false
3269 3269
 	 */
3270
-	function getSentFolder($_checkexistance=TRUE)
3270
+	function getSentFolder($_checkexistance = TRUE)
3271 3271
 	{
3272 3272
 		return $this->_getSpecialUseFolder('Sent', $_checkexistance);
3273 3273
 	}
@@ -3277,7 +3277,7 @@  discard block
 block discarded – undo
3277 3277
 	 * @param boolean $_checkexistance trigger check for existance
3278 3278
 	 * @return mixed string or false
3279 3279
 	 */
3280
-	function getOutboxFolder($_checkexistance=TRUE)
3280
+	function getOutboxFolder($_checkexistance = TRUE)
3281 3281
 	{
3282 3282
 		return $this->_getSpecialUseFolder('Outbox', $_checkexistance);
3283 3283
 	}
@@ -3288,10 +3288,10 @@  discard block
 block discarded – undo
3288 3288
 	 * @param boolean $_checkexistance trigger check for existance
3289 3289
 	 * @return boolean
3290 3290
 	 */
3291
-	function isSentFolder($_folderName, $_checkexistance=TRUE)
3291
+	function isSentFolder($_folderName, $_checkexistance = TRUE)
3292 3292
 	{
3293 3293
 		$sentFolder = $this->getSentFolder($_checkexistance);
3294
-		if(empty($sentFolder)) {
3294
+		if (empty($sentFolder)) {
3295 3295
 			return false;
3296 3296
 		}
3297 3297
 		// does the folder exist???
@@ -3299,7 +3299,7 @@  discard block
 block discarded – undo
3299 3299
 			return false;
3300 3300
 		}
3301 3301
 
3302
-		if(false !== stripos($_folderName, $sentFolder)) {
3302
+		if (false !== stripos($_folderName, $sentFolder)) {
3303 3303
 			return true;
3304 3304
 		} else {
3305 3305
 			return false;
@@ -3312,15 +3312,15 @@  discard block
 block discarded – undo
3312 3312
 	 * @param boolean $_checkexistance trigger check for existance
3313 3313
 	 * @return boolean
3314 3314
 	 */
3315
-	function isOutbox($_folderName, $_checkexistance=TRUE)
3315
+	function isOutbox($_folderName, $_checkexistance = TRUE)
3316 3316
 	{
3317
-		if (stripos($_folderName, 'Outbox')===false) {
3317
+		if (stripos($_folderName, 'Outbox') === false) {
3318 3318
 			return false;
3319 3319
 		}
3320 3320
 		// does the folder exist???
3321 3321
 		if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) {
3322 3322
 			$outboxFolder = $this->getOutboxFolder($_checkexistance);
3323
-			if(false !== stripos($_folderName, $outboxFolder)) {
3323
+			if (false !== stripos($_folderName, $outboxFolder)) {
3324 3324
 				return true;
3325 3325
 			} else {
3326 3326
 				return false;
@@ -3335,18 +3335,18 @@  discard block
 block discarded – undo
3335 3335
 	 * @param boolean $_checkexistance trigger check for existance
3336 3336
 	 * @return boolean
3337 3337
 	 */
3338
-	function isDraftFolder($_folderName, $_checkexistance=TRUE)
3338
+	function isDraftFolder($_folderName, $_checkexistance = TRUE)
3339 3339
 	{
3340 3340
 		$draftFolder = $this->getDraftFolder($_checkexistance);
3341
-		if(empty($draftFolder)) {
3341
+		if (empty($draftFolder)) {
3342 3342
 			return false;
3343 3343
 		}
3344 3344
 		// does the folder exist???
3345 3345
 		if ($_checkexistance && !$this->folderExists($_folderName)) {
3346 3346
 			return false;
3347 3347
 		}
3348
-		if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8;
3349
-		if(false !== stripos($_folderName, $draftFolder)) {
3348
+		if (is_a($_folderName, "Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8;
3349
+		if (false !== stripos($_folderName, $draftFolder)) {
3350 3350
 			return true;
3351 3351
 		} else {
3352 3352
 			return false;
@@ -3359,10 +3359,10 @@  discard block
 block discarded – undo
3359 3359
 	 * @param boolean $_checkexistance trigger check for existance
3360 3360
 	 * @return boolean
3361 3361
 	 */
3362
-	function isTrashFolder($_folderName, $_checkexistance=TRUE)
3362
+	function isTrashFolder($_folderName, $_checkexistance = TRUE)
3363 3363
 	{
3364 3364
 		$trashFolder = $this->getTrashFolder($_checkexistance);
3365
-		if(empty($trashFolder)) {
3365
+		if (empty($trashFolder)) {
3366 3366
 			return false;
3367 3367
 		}
3368 3368
 		// does the folder exist???
@@ -3370,7 +3370,7 @@  discard block
 block discarded – undo
3370 3370
 			return false;
3371 3371
 		}
3372 3372
 
3373
-		if(false !== stripos($_folderName, $trashFolder)) {
3373
+		if (false !== stripos($_folderName, $trashFolder)) {
3374 3374
 			return true;
3375 3375
 		} else {
3376 3376
 			return false;
@@ -3383,10 +3383,10 @@  discard block
 block discarded – undo
3383 3383
 	 * @param boolean $_checkexistance trigger check for existance
3384 3384
 	 * @return boolean
3385 3385
 	 */
3386
-	function isTemplateFolder($_folderName, $_checkexistance=TRUE)
3386
+	function isTemplateFolder($_folderName, $_checkexistance = TRUE)
3387 3387
 	{
3388 3388
 		$templateFolder = $this->getTemplateFolder($_checkexistance);
3389
-		if(empty($templateFolder)) {
3389
+		if (empty($templateFolder)) {
3390 3390
 			return false;
3391 3391
 		}
3392 3392
 		// does the folder exist???
@@ -3394,7 +3394,7 @@  discard block
 block discarded – undo
3394 3394
 			return false;
3395 3395
 		}
3396 3396
 
3397
-		if(false !== stripos($_folderName, $templateFolder)) {
3397
+		if (false !== stripos($_folderName, $templateFolder)) {
3398 3398
 			return true;
3399 3399
 		} else {
3400 3400
 			return false;
@@ -3407,24 +3407,24 @@  discard block
 block discarded – undo
3407 3407
 	 * @param boolean $_forceCheck trigger check for existance on icServer
3408 3408
 	 * @return mixed string or false
3409 3409
 	 */
3410
-	function folderExists($_folder, $_forceCheck=false)
3410
+	function folderExists($_folder, $_forceCheck = false)
3411 3411
 	{
3412 3412
 		static $folderInfo;
3413 3413
 		$forceCheck = $_forceCheck;
3414 3414
 		if (empty($_folder))
3415 3415
 		{
3416 3416
 			// this error is more or less without significance, unless we force the check
3417
-			if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace());
3417
+			if ($_forceCheck === true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace());
3418 3418
 			return false;
3419 3419
 		}
3420 3420
 		// when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder
3421
-		if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true;
3422
-		if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder =  $_folder->utf8;
3421
+		if (is_a($_folder, "Horde_Imap_Client_Mailbox") && $_forceCheck === false) return true;
3422
+		if (is_a($_folder, "Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8;
3423 3423
 		// reduce traffic within the Instance per User; Expire every 5 hours
3424 3424
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace());
3425
-		if (is_null($folderInfo)) $folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5);
3425
+		if (is_null($folderInfo)) $folderInfo = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 5);
3426 3426
 		//error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo));
3427
-		if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false)
3427
+		if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck === false)
3428 3428
 		{
3429 3429
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Using cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID);
3430 3430
 			return $folderInfo[$this->profileID][$_folder];
@@ -3440,7 +3440,7 @@  discard block
 block discarded – undo
3440 3440
 
3441 3441
 		// does the folder exist???
3442 3442
 		//error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server'));
3443
-		if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) {
3443
+		if ($forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) {
3444 3444
 			//error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID);
3445 3445
 			//return false;
3446 3446
 			//try to connect
@@ -3456,12 +3456,12 @@  discard block
 block discarded – undo
3456 3456
 		}
3457 3457
 		//error_log(__METHOD__.' ('.__LINE__.') '.' Folder Exists:'.$folderInfo[$this->profileID][$_folder].function_backtrace());
3458 3458
 
3459
-		if(!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) &&
3459
+		if (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) &&
3460 3460
 			$folderInfo[$this->profileID][$_folder] !== true)
3461 3461
 		{
3462 3462
 			$folderInfo[$this->profileID][$_folder] = false; // set to false, whatever it was (to have a valid returnvalue for the static return)
3463 3463
 		}
3464
-		egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5);
3464
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, $expiration = 60 * 60 * 5);
3465 3465
 		return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false);
3466 3466
 	}
3467 3467
 
@@ -3474,14 +3474,14 @@  discard block
 block discarded – undo
3474 3474
 	 */
3475 3475
 	function compressFolder($_folderName = false)
3476 3476
 	{
3477
-		$folderName	= ($_folderName ? $_folderName : $this->sessionData['mailbox']);
3478
-		$deleteOptions	= $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'];
3479
-		$trashFolder	= $this->getTrashFolder();
3477
+		$folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']);
3478
+		$deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'];
3479
+		$trashFolder = $this->getTrashFolder();
3480 3480
 
3481 3481
 		$this->icServer->openMailbox($folderName);
3482 3482
 
3483
-		if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") {
3484
-			$this->deleteMessages('all',$folderName,'remove_immediately');
3483
+		if (strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") {
3484
+			$this->deleteMessages('all', $folderName, 'remove_immediately');
3485 3485
 		} else {
3486 3486
 			$this->icServer->expunge($folderName);
3487 3487
 		}
@@ -3497,19 +3497,19 @@  discard block
 block discarded – undo
3497 3497
 	 * @return bool true, as we do not handle return values yet
3498 3498
 	 * @throws egw_exception
3499 3499
 	 */
3500
-	function deleteMessages($_messageUID, $_folder=NULL, $_forceDeleteMethod='no')
3500
+	function deleteMessages($_messageUID, $_folder = NULL, $_forceDeleteMethod = 'no')
3501 3501
 	{
3502 3502
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod);
3503 3503
 		$oldMailbox = '';
3504 3504
 		if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox'];
3505 3505
 		if (empty($_messageUID))
3506 3506
 		{
3507
-			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
3507
+			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID));
3508 3508
 			return false;
3509 3509
 		}
3510
-		elseif ($_messageUID==='all')
3510
+		elseif ($_messageUID === 'all')
3511 3511
 		{
3512
-			$_messageUID= null;
3512
+			$_messageUID = null;
3513 3513
 		}
3514 3514
 		else
3515 3515
 		{
@@ -3518,32 +3518,32 @@  discard block
 block discarded – undo
3518 3518
 			$uidsToDelete->add($_messageUID);
3519 3519
 		}
3520 3520
 		$deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method
3521
-		if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions  = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted");
3521
+		if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod, array('move_to_trash', "mark_as_deleted", "remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions'] ? $this->mailPreferences['deleteOptions'] : "mark_as_deleted");
3522 3522
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
3523 3523
 		$trashFolder    = $this->getTrashFolder();
3524
-		$draftFolder	= $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder'];
3524
+		$draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder'];
3525 3525
 		$templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder'];
3526
-		if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") ||
3526
+		if ((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") ||
3527 3527
 		   (strtolower($_folder) == strtolower($draftFolder))) {
3528 3528
 			$deleteOptions = "remove_immediately";
3529 3529
 		}
3530
-		if($this->icServer->getCurrentMailbox() != $_folder) {
3530
+		if ($this->icServer->getCurrentMailbox() != $_folder) {
3531 3531
 			$oldMailbox = $this->icServer->getCurrentMailbox();
3532 3532
 			$this->icServer->openMailbox($_folder);
3533 3533
 		}
3534 3534
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
3535 3535
 		$updateCache = false;
3536
-		switch($deleteOptions) {
3536
+		switch ($deleteOptions) {
3537 3537
 			case "move_to_trash":
3538 3538
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3539 3539
 				$updateCache = true;
3540
-				if(!empty($trashFolder)) {
3540
+				if (!empty($trashFolder)) {
3541 3541
 					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID));
3542
-					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
3542
+					if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ".$this->sessionData['mailbox']);
3543 3543
 					// copy messages
3544 3544
 					try
3545 3545
 					{
3546
-						$this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete,'move'=>true));
3546
+						$this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete, 'move'=>true));
3547 3547
 					}
3548 3548
 					catch (Exception $e)
3549 3549
 					{
@@ -3555,18 +3555,18 @@  discard block
 block discarded – undo
3555 3555
 			case "mark_as_deleted":
3556 3556
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3557 3557
 				// mark messages as deleted
3558
-				if (is_null($_messageUID)) $_messageUID='all';
3559
-				foreach((array)$_messageUID as $key =>$uid)
3558
+				if (is_null($_messageUID)) $_messageUID = 'all';
3559
+				foreach ((array)$_messageUID as $key =>$uid)
3560 3560
 				{
3561 3561
 					//flag messages, that are flagged for deletion as seen too
3562 3562
 					$this->flagMessages('read', $uid, $_folder);
3563 3563
 					$flags = $this->getFlags($uid);
3564 3564
 					$this->flagMessages('delete', $uid, $_folder);
3565 3565
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags));
3566
-					if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid;
3566
+					if (strpos(array2string($flags), 'Deleted') !== false) $undelete[] = $uid;
3567 3567
 					unset($flags);
3568 3568
 				}
3569
-				foreach((array)$undelete as $key =>$uid)
3569
+				foreach ((array)$undelete as $key =>$uid)
3570 3570
 				{
3571 3571
 					$this->flagMessages('undelete', $uid, $_folder);
3572 3572
 				}
@@ -3575,14 +3575,14 @@  discard block
 block discarded – undo
3575 3575
 			case "remove_immediately":
3576 3576
 				//error_log(__METHOD__.' ('.__LINE__.') ');
3577 3577
 				$updateCache = true;
3578
-				if (is_null($_messageUID)) $_messageUID='all';
3578
+				if (is_null($_messageUID)) $_messageUID = 'all';
3579 3579
 				if (is_object($_messageUID))
3580 3580
 				{
3581 3581
 					$this->flagMessages('delete', $_messageUID, $_folder);
3582 3582
 				}
3583 3583
 				else
3584 3584
 				{
3585
-					foreach((array)$_messageUID as $key =>$uid)
3585
+					foreach ((array)$_messageUID as $key =>$uid)
3586 3586
 					{
3587 3587
 						//flag messages, that are flagged for deletion as seen too
3588 3588
 						$this->flagMessages('delete', $uid, $_folder);
@@ -3592,7 +3592,7 @@  discard block
 block discarded – undo
3592 3592
 				$this->icServer->expunge($_folder);
3593 3593
 				break;
3594 3594
 		}
3595
-		if($oldMailbox != '') {
3595
+		if ($oldMailbox != '') {
3596 3596
 			$this->icServer->openMailbox($oldMailbox);
3597 3597
 		}
3598 3598
 
@@ -3606,7 +3606,7 @@  discard block
 block discarded – undo
3606 3606
 	 *
3607 3607
 	 * @return null/array flags
3608 3608
 	 */
3609
-	function getFlags ($_messageUID) {
3609
+	function getFlags($_messageUID) {
3610 3610
 		try
3611 3611
 		{
3612 3612
 			$uidsToFetch = new Horde_Imap_Client_Ids();
@@ -3619,7 +3619,7 @@  discard block
 block discarded – undo
3619 3619
 				'ids' => $uidsToFetch,
3620 3620
 			));
3621 3621
 			if (is_object($headersNew)) {
3622
-				foreach($headersNew->ids() as $id) {
3622
+				foreach ($headersNew->ids() as $id) {
3623 3623
 					$_headerObject = $headersNew->get($id);
3624 3624
 					$flags = $_headerObject->getFlags();
3625 3625
 				}
@@ -3642,22 +3642,22 @@  discard block
 block discarded – undo
3642 3642
 	 *
3643 3643
 	 * @return null/boolean
3644 3644
 	 */
3645
-	function getNotifyFlags ($_messageUID, $flags=null)
3645
+	function getNotifyFlags($_messageUID, $flags = null)
3646 3646
 	{
3647 3647
 		if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags));
3648 3648
 		try
3649 3649
 		{
3650
-			if($flags===null) $flags =  $this->getFlags($_messageUID);
3650
+			if ($flags === null) $flags = $this->getFlags($_messageUID);
3651 3651
 		}
3652 3652
 		catch (Exception $e)
3653 3653
 		{
3654 3654
 			return null;
3655 3655
 		}
3656 3656
 
3657
-		if ( stripos( array2string($flags),'MDNSent')!==false)
3657
+		if (stripos(array2string($flags), 'MDNSent') !== false)
3658 3658
 			return true;
3659 3659
 
3660
-		if ( stripos( array2string($flags),'MDNnotSent')!==false)
3660
+		if (stripos(array2string($flags), 'MDNnotSent') !== false)
3661 3661
 			return false;
3662 3662
 
3663 3663
 		return null;
@@ -3674,45 +3674,45 @@  discard block
 block discarded – undo
3674 3674
 	 *
3675 3675
 	 * @return bool true, as we do not handle icserver->setFlags returnValue
3676 3676
 	 */
3677
-	function flagMessages($_flag, $_messageUID,$_folder=NULL)
3677
+	function flagMessages($_flag, $_messageUID, $_folder = NULL)
3678 3678
 	{
3679 3679
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']);
3680 3680
 		if (empty($_messageUID))
3681 3681
 		{
3682
-			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
3682
+			if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID));
3683 3683
 			return false;
3684 3684
 		}
3685
-		$this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox']));
3685
+		$this->icServer->openMailbox(($_folder ? $_folder : $this->sessionData['mailbox']));
3686 3686
 		$folder = $this->icServer->getCurrentMailbox();
3687
-		if (is_array($_messageUID)&& count($_messageUID)>50)
3687
+		if (is_array($_messageUID) && count($_messageUID) > 50)
3688 3688
 		{
3689
-			$count = $this->getMailBoxCounters($folder,true);
3690
-			if ($count->messages == count($_messageUID)) $_messageUID='all';
3689
+			$count = $this->getMailBoxCounters($folder, true);
3690
+			if ($count->messages == count($_messageUID)) $_messageUID = 'all';
3691 3691
 		}
3692 3692
 
3693
-		if ($_messageUID==='all')
3693
+		if ($_messageUID === 'all')
3694 3694
 		{
3695 3695
 			$messageUIDs = array('all');
3696 3696
 		}
3697 3697
 		else
3698 3698
 		{
3699 3699
 			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
3700
-			$messageUIDs = array_chunk($_messageUID,50,true);
3700
+			$messageUIDs = array_chunk($_messageUID, 50, true);
3701 3701
 		}
3702 3702
 		try
3703 3703
 		{
3704
-			foreach($messageUIDs as &$uids)
3704
+			foreach ($messageUIDs as &$uids)
3705 3705
 			{
3706
-				if ($uids==='all')
3706
+				if ($uids === 'all')
3707 3707
 				{
3708
-					$uidsToModify=null;
3708
+					$uidsToModify = null;
3709 3709
 				}
3710 3710
 				else
3711 3711
 				{
3712 3712
 					$uidsToModify = new Horde_Imap_Client_Ids();
3713 3713
 					$uidsToModify->add($uids);
3714 3714
 				}
3715
-				switch($_flag) {
3715
+				switch ($_flag) {
3716 3716
 					case "delete":
3717 3717
 						$ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify));
3718 3718
 						break;
@@ -3736,7 +3736,7 @@  discard block
 block discarded – undo
3736 3736
 						break;
3737 3737
 					case "unread":
3738 3738
 					case "unseen":
3739
-						$ret = $this->icServer->store($folder, array('remove'=>array('\\Seen','\\Answered','$Forwarded'), 'ids'=> $uidsToModify));
3739
+						$ret = $this->icServer->store($folder, array('remove'=>array('\\Seen', '\\Answered', '$Forwarded'), 'ids'=> $uidsToModify));
3740 3740
 						break;
3741 3741
 					case "mdnsent":
3742 3742
 						$ret = $this->icServer->store($folder, array('add'=>array('MDNSent'), 'ids'=> $uidsToModify));
@@ -3794,13 +3794,13 @@  discard block
 block discarded – undo
3794 3794
 				}
3795 3795
 			}
3796 3796
 		}
3797
-		catch(Exception $e)
3797
+		catch (Exception $e)
3798 3798
 		{
3799 3799
 			error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage());
3800 3800
 		}
3801 3801
 		if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8;
3802 3802
 		//error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#');
3803
-		self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0;
3803
+		self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder) ? $_folder : $this->sessionData['mailbox'])]['uidValidity'] = 0;
3804 3804
 
3805 3805
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox']));
3806 3806
 		return true; // as we do not catch/examine setFlags returnValue
@@ -3821,19 +3821,19 @@  discard block
 block discarded – undo
3821 3821
 	 * @return mixed/bool true,false or new uid
3822 3822
 	 * @throws egw_exception
3823 3823
 	 */
3824
-	function moveMessages($_foldername, $_messageUID, $deleteAfterMove=true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null)
3824
+	function moveMessages($_foldername, $_messageUID, $deleteAfterMove = true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null)
3825 3825
 	{
3826
-		$source = emailadmin_account::read(($_sourceProfileID?$_sourceProfileID:$this->icServer->ImapServerId))->imapServer();
3826
+		$source = emailadmin_account::read(($_sourceProfileID ? $_sourceProfileID : $this->icServer->ImapServerId))->imapServer();
3827 3827
 		//$deleteOptions  = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"];
3828 3828
 		if (empty($_messageUID))
3829 3829
 		{
3830
-			if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID));
3830
+			if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',', $_messageUID));
3831 3831
 			return false;
3832 3832
 		}
3833
-		elseif ($_messageUID==='all')
3833
+		elseif ($_messageUID === 'all')
3834 3834
 		{
3835 3835
 			//error_log(__METHOD__." all Message(s): ".implode(',',$_messageUID));
3836
-			$uidsToMove= null;
3836
+			$uidsToMove = null;
3837 3837
 		}
3838 3838
 		else
3839 3839
 		{
@@ -3842,7 +3842,7 @@  discard block
 block discarded – undo
3842 3842
 			if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
3843 3843
 			$uidsToMove->add($_messageUID);
3844 3844
 		}
3845
-		$sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']);
3845
+		$sourceFolder = (!empty($currentFolder) ? $currentFolder : $this->sessionData['mailbox']);
3846 3846
 		//error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId));
3847 3847
 		if (!is_null($_targetProfileID) && $_targetProfileID !== $source->ImapServerId)
3848 3848
 		{
@@ -3862,19 +3862,19 @@  discard block
 block discarded – undo
3862 3862
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew));
3863 3863
 
3864 3864
 			if (is_object($headersNew)) {
3865
-				$c=0;
3865
+				$c = 0;
3866 3866
 				$retUid = new Horde_Imap_Client_Ids();
3867 3867
 				// we copy chunks of 5 to avoid too much memory and/or server stress
3868 3868
 				// some servers seem not to allow/support the appendig of multiple messages. so we are down to one
3869
-				foreach($headersNew as &$_headerObject) {
3869
+				foreach ($headersNew as &$_headerObject) {
3870 3870
 					$c++;
3871 3871
 					$flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message
3872 3872
 					$date = $_headerObject->getImapDate();
3873
-					$currentDate =  new Horde_Imap_Client_DateTime();
3873
+					$currentDate = new Horde_Imap_Client_DateTime();
3874 3874
 					// if the internal Date of the message equals the current date; try using the header date
3875
-					if ($date==$currentDate)
3875
+					if ($date == $currentDate)
3876 3876
 					{
3877
-						$headerForPrio = array_change_key_case($_headerObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER);
3877
+						$headerForPrio = array_change_key_case($_headerObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER);
3878 3878
 						//error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'.$headerForPrio['DATE']);
3879 3879
 						$date = new Horde_Imap_Client_DateTime($headerForPrio['DATE']);
3880 3880
 						//error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#');
@@ -3883,20 +3883,20 @@  discard block
 block discarded – undo
3883 3883
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags));
3884 3884
 					$body = $_headerObject->getFullMsg();
3885 3885
 					$dataNflags[] = array('data'=>$body, 'flags'=>$flags, 'internaldate'=>$date);
3886
-					if ($c==1)
3886
+					if ($c == 1)
3887 3887
 					{
3888 3888
 						$target = emailadmin_account::read($_targetProfileID)->imapServer();
3889 3889
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' TargetServer:'.$_targetProfileID.' TargetFolderObject:'.array2string($_foldername));
3890 3890
 						$foldername = $target->getMailbox($_foldername);
3891 3891
 						// make sure the target folder is open and ready
3892 3892
 						$target->openMailbox($foldername);
3893
-						$ret = $target->append($foldername,$dataNflags);
3893
+						$ret = $target->append($foldername, $dataNflags);
3894 3894
 						$retUid->add($ret);
3895 3895
 						unset($dataNflags);
3896 3896
 						// sleep 500 miliseconds; AS some sERVERs seem not to be capable of the load this is
3897 3897
 						// inflicting in them. they "reply" with an unspecific IMAP Error
3898
-						time_nanosleep(0,500000);
3899
-						$c=0;
3898
+						time_nanosleep(0, 500000);
3899
+						$c = 0;
3900 3900
 					}
3901 3901
 				}
3902 3902
 				if (isset($dataNflags))
@@ -3906,7 +3906,7 @@  discard block
 block discarded – undo
3906 3906
 					$foldername = $target->getMailbox($_foldername);
3907 3907
 					// make sure the target folder is open and ready
3908 3908
 					$target->openMailbox($foldername);
3909
-					$ret = $target->append($foldername,$dataNflags);
3909
+					$ret = $target->append($foldername, $dataNflags);
3910 3910
 					$retUid->add($ret);
3911 3911
 					unset($dataNflags);
3912 3912
 				}
@@ -3917,7 +3917,7 @@  discard block
 block discarded – undo
3917 3917
 				{
3918 3918
 					$remember = $this->icServer;
3919 3919
 					$this->icServer = $source;
3920
-					$this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod='remove_immediately');
3920
+					$this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod = 'remove_immediately');
3921 3921
 					$this->icServer = $remember;
3922 3922
 				}
3923 3923
 			}
@@ -3926,7 +3926,7 @@  discard block
 block discarded – undo
3926 3926
 		{
3927 3927
 			try
3928 3928
 			{
3929
-				$retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove,'move'=>$deleteAfterMove));
3929
+				$retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove, 'move'=>$deleteAfterMove));
3930 3930
 			}
3931 3931
 			catch (exception $e)
3932 3932
 			{
@@ -3946,19 +3946,19 @@  discard block
 block discarded – undo
3946 3946
 	 * @param string $format ='' if none is passed, use user prefs
3947 3947
 	 * @return string returns the date as it is parseable by strtotime, or current timestamp if everything fails
3948 3948
 	 */
3949
-	static function _strtotime($_date='', $format='', $convert2usertime=false)
3949
+	static function _strtotime($_date = '', $format = '', $convert2usertime = false)
3950 3950
 	{
3951 3951
 		try {
3952
-			$date = new egw_time($_date);	// parse date & time including timezone (throws exception, if not parsable)
3953
-			if ($convert2usertime) $date->setUser();	// convert to user-time
3952
+			$date = new egw_time($_date); // parse date & time including timezone (throws exception, if not parsable)
3953
+			if ($convert2usertime) $date->setUser(); // convert to user-time
3954 3954
 			$date2return = $date->format($format);
3955 3955
 		}
3956
-		catch(Exception $e)
3956
+		catch (Exception $e)
3957 3957
 		{
3958
-			unset($e);	// not used
3958
+			unset($e); // not used
3959 3959
 
3960 3960
 			// remove last space-separated part and retry
3961
-			$parts = explode(' ',$_date);
3961
+			$parts = explode(' ', $_date);
3962 3962
 			if (count($parts) > 1)
3963 3963
 			{
3964 3964
 				array_pop($parts);
@@ -3979,12 +3979,12 @@  discard block
 block discarded – undo
3979 3979
 	 * @param mixed $_charset false or string -> Target charset, if false emailadmin_imapbase displayCharset will be used
3980 3980
 	 * @return string
3981 3981
 	 */
3982
-	static function htmlentities($_string, $_charset=false)
3982
+	static function htmlentities($_string, $_charset = false)
3983 3983
 	{
3984 3984
 		//setting the charset (if not given)
3985
-		if ($_charset===false) $_charset = self::$displayCharset;
3985
+		if ($_charset === false) $_charset = self::$displayCharset;
3986 3986
 		$string = @htmlentities($_string, ENT_QUOTES, $_charset, false);
3987
-		if (empty($string) && !empty($_string)) $string = @htmlentities(translation::convert($_string,translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false);
3987
+		if (empty($string) && !empty($_string)) $string = @htmlentities(translation::convert($_string, translation::detect_encoding($_string), $_charset), ENT_QUOTES|ENT_IGNORE, $_charset, false);
3988 3988
 		return $string;
3989 3989
 	}
3990 3990
 
@@ -4001,21 +4001,21 @@  discard block
 block discarded – undo
4001 4001
 		//$_html = str_replace("\t",' ',$_html);
4002 4002
 		//error_log($_html);
4003 4003
 		//repair doubleencoded ampersands, and some stuff htmLawed stumbles upon with balancing switched on
4004
-		$_html = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>','</td></font>','<br><td>','<tr></tr>','<o:p></o:p>','<o:p>','</o:p>'),
4005
-							 array('&amp;',    '<BR>',           '<BR>',             '<BR>',             '</font></td>','<td>',    '',         '',           '',  ''),$_html);
4004
+		$_html = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>', '</td></font>', '<br><td>', '<tr></tr>', '<o:p></o:p>', '<o:p>', '</o:p>'),
4005
+							 array('&amp;', '<BR>', '<BR>', '<BR>', '</font></td>', '<td>', '', '', '', ''), $_html);
4006 4006
 		//$_html = str_replace(array('&amp;amp;'),array('&amp;'),$_html);
4007
-		if (stripos($_html,'style')!==false) translation::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags
4008
-		if (stripos($_html,'head')!==false) translation::replaceTagsCompletley($_html,'head'); // Strip out stuff in head
4007
+		if (stripos($_html, 'style') !== false) translation::replaceTagsCompletley($_html, 'style'); // clean out empty or pagewide style definitions / left over tags
4008
+		if (stripos($_html, 'head') !== false) translation::replaceTagsCompletley($_html, 'head'); // Strip out stuff in head
4009 4009
 		//if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) translation::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs
4010 4010
 		//if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) translation::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
4011 4011
 		//error_log(__METHOD__.' ('.__LINE__.') '.$_html);
4012 4012
 
4013 4013
 		if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
4014 4014
 		// Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards
4015
-		if (stripos($_html,'!doctype')!==false) translation::replaceTagsCompletley($_html,'!doctype');
4016
-		if (stripos($_html,'?xml:namespace')!==false) translation::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
4017
-		if (stripos($_html,'?xml version')!==false) translation::replaceTagsCompletley($_html,'\?xml version','\?>',false);
4018
-		if (strpos($_html,'!CURSOR')!==false) translation::replaceTagsCompletley($_html,'!CURSOR');
4015
+		if (stripos($_html, '!doctype') !== false) translation::replaceTagsCompletley($_html, '!doctype');
4016
+		if (stripos($_html, '?xml:namespace') !== false) translation::replaceTagsCompletley($_html, '\?xml:namespace', '/>', false);
4017
+		if (stripos($_html, '?xml version') !== false) translation::replaceTagsCompletley($_html, '\?xml version', '\?>', false);
4018
+		if (strpos($_html, '!CURSOR') !== false) translation::replaceTagsCompletley($_html, '!CURSOR');
4019 4019
 		// htmLawed filter only the 'body'
4020 4020
 		//preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches);
4021 4021
 		//if ($matches[2])
@@ -4026,16 +4026,16 @@  discard block
 block discarded – undo
4026 4026
 		// purify got switched to htmLawed
4027 4027
 		// some testcode to test purifying / htmlawed
4028 4028
 		//$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html;
4029
-		$_html = html::purify($_html,self::$htmLawed_config,array(),true);
4029
+		$_html = html::purify($_html, self::$htmLawed_config, array(), true);
4030 4030
 		//if ($hasOther) $_html = $matches[1]. $_html. $matches[3];
4031 4031
 		// clean out comments , should not be needed as purify should do the job.
4032 4032
 		$search = array(
4033
-			'@url\(http:\/\/[^\)].*?\)@si',  // url calls e.g. in style definitions
4034
-			'@<!--[\s\S]*?[ \t\n\r]*-->@',         // Strip multi-line comments including CDATA
4033
+			'@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions
4034
+			'@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA
4035 4035
 		);
4036
-		$_html = preg_replace($search,"",$_html);
4036
+		$_html = preg_replace($search, "", $_html);
4037 4037
 		// remove non printable chars
4038
-		$_html = preg_replace('/([\000-\011])/','',$_html);
4038
+		$_html = preg_replace('/([\000-\011])/', '', $_html);
4039 4039
 		//error_log(__METHOD__.':'.__LINE__.':'.$_html);
4040 4040
 	}
4041 4041
 
@@ -4052,12 +4052,12 @@  discard block
 block discarded – undo
4052 4052
 	function getMimePartCharset($_mimePartObject)
4053 4053
 	{
4054 4054
 		//$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1
4055
-		$CharsetFound=false;
4055
+		$CharsetFound = false;
4056 4056
 		//echo "#".$_mimePartObject->encoding.'#<br>';
4057
-		if(is_array($_mimePartObject->parameters)) {
4058
-			if(isset($_mimePartObject->parameters['CHARSET'])) {
4057
+		if (is_array($_mimePartObject->parameters)) {
4058
+			if (isset($_mimePartObject->parameters['CHARSET'])) {
4059 4059
 				$charSet = $_mimePartObject->parameters['CHARSET'];
4060
-				$CharsetFound=true;
4060
+				$CharsetFound = true;
4061 4061
 			}
4062 4062
 		}
4063 4063
 		// this one is dirty, but until I find something that does the trick of detecting the encoding, ....
@@ -4076,7 +4076,7 @@  discard block
 block discarded – undo
4076 4076
 	function decodeMimePart($_mimeMessage, $_encoding, $_charset = '')
4077 4077
 	{
4078 4078
 		// decode the part
4079
-		if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true));
4079
+		if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage, true));
4080 4080
 		switch (strtoupper($_encoding))
4081 4081
 		{
4082 4082
 			case 'BASE64':
@@ -4116,10 +4116,10 @@  discard block
 block discarded – undo
4116 4116
 		// sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that
4117 4117
 		// as attachment AND as abstracted ical information (we use our notification style here).
4118 4118
 		$partText = $partCalendar = $partHTML = null;
4119
-		if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure));
4119
+		if (self::$debug) _debug_array(array("METHOD"=>__METHOD__, "LINE"=>__LINE__, "STRUCTURE"=>$_structure));
4120 4120
 		//error_log(__METHOD__.' ('.__LINE__.') ');
4121 4121
 		$ignore_first_part = true;
4122
-		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
4122
+		foreach ($_structure->contentTypeMap() as $mime_id => $mime_type)
4123 4123
 		{
4124 4124
 			//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part);
4125 4125
 			if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
@@ -4127,15 +4127,15 @@  discard block
 block discarded – undo
4127 4127
 			if ($ignore_first_part)
4128 4128
 			{
4129 4129
 				$ignore_first_part = false;
4130
-				continue;	// ignore multipart/alternative itself
4130
+				continue; // ignore multipart/alternative itself
4131 4131
 			}
4132 4132
 
4133 4133
 			$mimePart = $_structure->getPart($mime_id);
4134 4134
 
4135
-			switch($mimePart->getPrimaryType())
4135
+			switch ($mimePart->getPrimaryType())
4136 4136
 			{
4137 4137
 				case 'text':
4138
-					switch($mimePart->getSubType())
4138
+					switch ($mimePart->getSubType())
4139 4139
 					{
4140 4140
 						case 'plain':
4141 4141
 							if ($mimePart->getBytes() > 0) $partText = $mimePart;
@@ -4148,7 +4148,7 @@  discard block
 block discarded – undo
4148 4148
 					break;
4149 4149
 
4150 4150
 				case 'multipart':
4151
-					switch($mimePart->getSubType())
4151
+					switch ($mimePart->getSubType())
4152 4152
 					{
4153 4153
 						case 'related':
4154 4154
 						case 'mixed':
@@ -4170,13 +4170,13 @@  discard block
 block discarded – undo
4170 4170
 			}
4171 4171
 		}
4172 4172
 
4173
-		switch($_htmlMode)
4173
+		switch ($_htmlMode)
4174 4174
 		{
4175 4175
 			case 'html_only':
4176 4176
 			case 'always_display':
4177 4177
 				if ($partHTML)
4178 4178
 				{
4179
-					switch($partHTML->getSubType())
4179
+					switch ($partHTML->getSubType())
4180 4180
 					{
4181 4181
 						case 'related':
4182 4182
 							return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode, $_preserveSeen);
@@ -4188,7 +4188,7 @@  discard block
 block discarded – undo
4188 4188
 							return $this->getTextPart($_uid, $partHTML, $_htmlMode, $_preserveSeen);
4189 4189
 					}
4190 4190
 				}
4191
-				elseif ($partText && $_htmlMode=='always_display')
4191
+				elseif ($partText && $_htmlMode == 'always_display')
4192 4192
 				{
4193 4193
 					return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen);
4194 4194
 				}
@@ -4234,7 +4234,7 @@  discard block
 block discarded – undo
4234 4234
 	 * @param array	&$skipParts - passed by reference to have control/knowledge which parts are already fetched
4235 4235
 	 * @return array containing the desired part
4236 4236
 	 */
4237
-	function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array())
4237
+	function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts = array())
4238 4238
 	{
4239 4239
 		if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>";
4240 4240
 		$bodyPart = array();
@@ -4243,7 +4243,7 @@  discard block
 block discarded – undo
4243 4243
 		$ignore_first_part = true;
4244 4244
 		//$skipParts = array();
4245 4245
 		//error_log(__METHOD__.__LINE__.array2string($_structure->contentTypeMap()));
4246
-		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
4246
+		foreach ($_structure->contentTypeMap() as $mime_id => $mime_type)
4247 4247
 		{
4248 4248
 			//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type");
4249 4249
 			if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>";
@@ -4251,9 +4251,9 @@  discard block
 block discarded – undo
4251 4251
 			{
4252 4252
 				$ignore_first_part = false;
4253 4253
 				//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED FirstPart $mime_id: $mime_type");
4254
-				continue;	// ignore multipart/mixed itself
4254
+				continue; // ignore multipart/mixed itself
4255 4255
 			}
4256
-			if (array_key_exists($mime_id,$skipParts))
4256
+			if (array_key_exists($mime_id, $skipParts))
4257 4257
 			{
4258 4258
 				//error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED $mime_id: $mime_type");
4259 4259
 				continue;
@@ -4261,11 +4261,11 @@  discard block
 block discarded – undo
4261 4261
 
4262 4262
 			$part = $_structure->getPart($mime_id);
4263 4263
 
4264
-			switch($part->getPrimaryType())
4264
+			switch ($part->getPrimaryType())
4265 4265
 			{
4266 4266
 				case 'multipart':
4267 4267
 					if ($part->getDisposition() == 'attachment') continue;
4268
-					switch($part->getSubType())
4268
+					switch ($part->getSubType())
4269 4269
 					{
4270 4270
 						case 'alternative':
4271 4271
 							return array($this->getMultipartAlternative($_uid, $part, $_htmlMode, $_preserveSeen));
@@ -4281,15 +4281,15 @@  discard block
 block discarded – undo
4281 4281
 					}
4282 4282
 					break;
4283 4283
 				case 'application':
4284
-					switch($part->getSubType())
4284
+					switch ($part->getSubType())
4285 4285
 					{
4286 4286
 						case 'pgp-encrypted':
4287
-							if (($part = $_structure->getPart($mime_id+1)) &&
4287
+							if (($part = $_structure->getPart($mime_id + 1)) &&
4288 4288
 								$part->getType() == 'application/octet-stream')
4289 4289
 							{
4290 4290
 								$this->fetchPartContents($_uid, $part);
4291
-								$skipParts[$mime_id]=$mime_type;
4292
-								$skipParts[$mime_id+1]=$part->getType();
4291
+								$skipParts[$mime_id] = $mime_type;
4292
+								$skipParts[$mime_id + 1] = $part->getType();
4293 4293
 								$bodyPart[] = array(
4294 4294
 									'body'		=> $part->getContents(array(
4295 4295
 										'stream' => false,
@@ -4303,15 +4303,15 @@  discard block
 block discarded – undo
4303 4303
 					break;
4304 4304
 
4305 4305
 				case 'text':
4306
-					switch($part->getSubType())
4306
+					switch ($part->getSubType())
4307 4307
 					{
4308 4308
 						case 'plain':
4309 4309
 						case 'html':
4310 4310
 						case 'calendar': // inline ics/ical files
4311
-							if($part->getDisposition() != 'attachment')
4311
+							if ($part->getDisposition() != 'attachment')
4312 4312
 							{
4313 4313
 								$bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen);
4314
-								$skipParts[$mime_id]=$mime_type;
4314
+								$skipParts[$mime_id] = $mime_type;
4315 4315
 							}
4316 4316
 							//error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$part->type."/".$part->subType.' -> BodyPart:'.array2string($bodyPart[count($bodyPart)-1]));
4317 4317
 							break;
@@ -4320,16 +4320,16 @@  discard block
 block discarded – undo
4320 4320
 
4321 4321
 				case 'message':
4322 4322
 					//skip attachments
4323
-					if($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment')
4323
+					if ($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment')
4324 4324
 					{
4325 4325
 						$bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen);
4326
-						$skipParts[$mime_id]=$mime_type;
4326
+						$skipParts[$mime_id] = $mime_type;
4327 4327
 					}
4328 4328
 					// do not descend into attached Messages
4329
-					if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment')
4329
+					if ($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment')
4330 4330
 					{
4331 4331
 						$skipParts[$mime_id.'.0'] = $mime_type;
4332
-						foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;}
4332
+						foreach ($part->contentTypeMap() as $sub_id => $sub_type) { $skipParts[$sub_id] = $sub_type; }
4333 4333
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts));
4334 4334
 						//break 2;
4335 4335
 					}
@@ -4370,13 +4370,13 @@  discard block
 block discarded – undo
4370 4370
 	 * @param boolean $_tryDecodingServerside = true; wether to try to fetch Data with BINARY instead of BODY
4371 4371
 	 * @return string|resource
4372 4372
 	 */
4373
-	function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true)
4373
+	function getBodyPart($_uid, $_partID = null, $_folder = null, $_preserveSeen = false, $_stream = false, &$_encoding = null, $_tryDecodingServerside = true)
4374 4374
 	{
4375
-		if (self::$debug) error_log( __METHOD__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen)");
4375
+		if (self::$debug) error_log(__METHOD__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen)");
4376 4376
 
4377 4377
 		if (empty($_folder))
4378 4378
 		{
4379
-			$_folder = (isset($this->sessionData['mailbox'])&&$this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
4379
+			$_folder = (isset($this->sessionData['mailbox']) && $this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
4380 4380
 		}
4381 4381
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']);
4382 4382
 		// querying contents of body part
@@ -4387,11 +4387,11 @@  discard block
 block discarded – undo
4387 4387
 		$fquery = new Horde_Imap_Client_Fetch_Query();
4388 4388
 		$fetchParams = array(
4389 4389
 			'peek' => $_preserveSeen,
4390
-			'decode' => true,	// try decode on server, does NOT neccessary work
4390
+			'decode' => true, // try decode on server, does NOT neccessary work
4391 4391
 		);
4392
-		if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder)))
4392
+		if ($_tryDecodingServerside === false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder)))
4393 4393
 		{
4394
-			$_tryDecodingServerside=false;
4394
+			$_tryDecodingServerside = false;
4395 4395
 			$fetchParams = array(
4396 4396
 				'peek' => $_preserveSeen,
4397 4397
 			);
@@ -4411,12 +4411,12 @@  discard block
 block discarded – undo
4411 4411
 		}
4412 4412
 		// if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID])
4413 4413
 		// thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID])
4414
-		if (empty($partToReturn)&&$_tryDecodingServerside===true)
4414
+		if (empty($partToReturn) && $_tryDecodingServerside === true)
4415 4415
 		{
4416 4416
 			error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in  BINARY. Try BODY');
4417 4417
 			$partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false);
4418 4418
 		}
4419
-		return ($partToReturn?$partToReturn:null);
4419
+		return ($partToReturn ? $partToReturn : null);
4420 4420
 	}
4421 4421
 
4422 4422
 	/**
@@ -4429,13 +4429,13 @@  discard block
 block discarded – undo
4429 4429
 	 * @param boolean $_stream = false true return a stream, false return string
4430 4430
 	 * @return array containing the desired text part, mimeType and charset
4431 4431
 	 */
4432
-	function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode='', $_preserveSeen=false, $_stream=false)
4432
+	function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode = '', $_preserveSeen = false, $_stream = false)
4433 4433
 	{
4434 4434
 		//error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace());
4435 4435
 		$bodyPart = array();
4436
-		if (self::$debug) _debug_array(array($_structure,function_backtrace()));
4436
+		if (self::$debug) _debug_array(array($_structure, function_backtrace()));
4437 4437
 
4438
-		if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text')))
4438
+		if ($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text')))
4439 4439
 		{
4440 4440
 			$bodyPart = array(
4441 4441
 				'error'		=> 1,
@@ -4481,10 +4481,10 @@  discard block
 block discarded – undo
4481 4481
 	 * @param string $_folder folder to work on
4482 4482
 	 * @return array containing the message body, mimeType and charset
4483 4483
 	 */
4484
-	function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '')
4484
+	function getMessageBody($_uid, $_htmlOptions = '', $_partID = null, Horde_Mime_Part $_structure = null, $_preserveSeen = false, $_folder = '')
4485 4485
 	{
4486 4486
 		if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
4487
-		if($_htmlOptions != '') {
4487
+		if ($_htmlOptions != '') {
4488 4488
 			$this->htmlOptions = $_htmlOptions;
4489 4489
 		}
4490 4490
 		if (empty($_folder))
@@ -4505,7 +4505,7 @@  discard block
 block discarded – undo
4505 4505
 			return array(
4506 4506
 				array(
4507 4507
 					'error'		=> 1,
4508
-					'body'		=> 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions". 'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'],
4508
+					'body'		=> 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions".'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'],
4509 4509
 					'mimeType'	=> 'text/plain',
4510 4510
 					'charSet'	=> self::$displayCharset,
4511 4511
 				)
@@ -4518,7 +4518,7 @@  discard block
 block discarded – undo
4518 4518
 			//_debug_array($_structure->getMimeId()); exit;
4519 4519
 		}
4520 4520
 
4521
-		switch($_structure->getPrimaryType())
4521
+		switch ($_structure->getPrimaryType())
4522 4522
 		{
4523 4523
 			case 'application':
4524 4524
 				return array(
@@ -4530,7 +4530,7 @@  discard block
 block discarded – undo
4530 4530
 				);
4531 4531
 
4532 4532
 			case 'multipart':
4533
-				switch($_structure->getSubType())
4533
+				switch ($_structure->getSubType())
4534 4534
 				{
4535 4535
 					case 'alternative':
4536 4536
 						$bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen));
@@ -4564,7 +4564,7 @@  discard block
 block discarded – undo
4564 4564
 				$bodyPart = array();
4565 4565
 				if ($_structure->getDisposition() != 'attachment')
4566 4566
 				{
4567
-					switch($_structure->getSubType())
4567
+					switch ($_structure->getSubType())
4568 4568
 					{
4569 4569
 						case 'calendar':
4570 4570
 							// this is handeled in getTextPart
@@ -4580,11 +4580,11 @@  discard block
 block discarded – undo
4580 4580
 
4581 4581
 			case 'attachment':
4582 4582
 			case 'message':
4583
-				switch($_structure->getSubType())
4583
+				switch ($_structure->getSubType())
4584 4584
 				{
4585 4585
 					case 'rfc822':
4586 4586
 						$newStructure = $_structure->getParts();
4587
-						if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);}
4587
+						if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]); }
4588 4588
 						return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder));
4589 4589
 				}
4590 4590
 				break;
@@ -4612,11 +4612,11 @@  discard block
 block discarded – undo
4612 4612
 	{
4613 4613
 		if (is_array($_bodyParts))
4614 4614
 		{
4615
-			foreach($_bodyParts as $singleBodyPart)
4615
+			foreach ($_bodyParts as $singleBodyPart)
4616 4616
 			{
4617 4617
 				if (!isset($singleBodyPart['body'])) {
4618 4618
 					$buff = self::normalizeBodyParts($singleBodyPart);
4619
-					foreach ((array)$buff as $val) { $body2return[] = $val;}
4619
+					foreach ((array)$buff as $val) { $body2return[] = $val; }
4620 4620
 					continue;
4621 4621
 				}
4622 4622
 				$body2return[] = $singleBodyPart;
@@ -4637,14 +4637,14 @@  discard block
 block discarded – undo
4637 4637
 	 * @param boolean $useTidy  switch to use tidy
4638 4638
 	 * @return string a preformatted string with the mails converted to text
4639 4639
 	 */
4640
-	static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false,  $useTidy = true)
4640
+	static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true)
4641 4641
 	{
4642
-		$message='';
4643
-		for($i=0; $i<count($bodyParts); $i++)
4642
+		$message = '';
4643
+		for ($i = 0; $i < count($bodyParts); $i++)
4644 4644
 		{
4645 4645
 			if (!isset($bodyParts[$i]['body'])) {
4646 4646
 				$bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy);
4647
-				$message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body'];
4647
+				$message .= empty($bodyParts[$i]['body']) ? '' : $bodyParts[$i]['body'];
4648 4648
 				continue;
4649 4649
 			}
4650 4650
 			if (isset($bodyParts[$i]['error'])) continue;
@@ -4669,32 +4669,32 @@  discard block
 block discarded – undo
4669 4669
 				'(R)',
4670 4670
 			);
4671 4671
 
4672
-			if(($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') &&
4672
+			if (($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') &&
4673 4673
 				strtoupper($bodyParts[$i]['charSet']) != 'UTF-8')
4674 4674
 			{
4675
-				$bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']);
4675
+				$bodyParts[$i]['body'] = preg_replace($sar, $rar, $bodyParts[$i]['body']);
4676 4676
 			}
4677 4677
 
4678
-			if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = translation::detect_encoding($bodyParts[$i]['body']);
4678
+			if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = translation::detect_encoding($bodyParts[$i]['body']);
4679 4679
 			// add line breaks to $bodyParts
4680 4680
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']);
4681
-			$newBody  = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
4681
+			$newBody = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
4682 4682
 			//error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody);
4683 4683
 			$mailClass->activeMimeType = 'text/plain';
4684 4684
 			if ($bodyParts[$i]['mimeType'] == 'text/html') {
4685 4685
 				$mailClass->activeMimeType = $bodyParts[$i]['mimeType'];
4686 4686
 				if (!$preserveHTML)
4687 4687
 				{
4688
-					$alreadyHtmlLawed=false;
4688
+					$alreadyHtmlLawed = false;
4689 4689
 					// as translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space
4690
-					$newBody = str_replace("\n"," ",$newBody);
4690
+					$newBody = str_replace("\n", " ", $newBody);
4691 4691
 					// convert HTML to text, as we dont want HTML in infologs
4692 4692
 					if ($useTidy && extension_loaded('tidy'))
4693 4693
 					{
4694 4694
 						$tidy = new tidy();
4695
-						$cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8');
4695
+						$cleaned = $tidy->repairString($newBody, self::$tidy_config, 'utf8');
4696 4696
 						// Found errors. Strip it all so there's some output
4697
-						if($tidy->getStatus() == 2)
4697
+						if ($tidy->getStatus() == 2)
4698 4698
 						{
4699 4699
 							error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
4700 4700
 						}
@@ -4705,7 +4705,7 @@  discard block
 block discarded – undo
4705 4705
 						if (!$preserveHTML)
4706 4706
 						{
4707 4707
 							// filter only the 'body', as we only want that part, if we throw away the html
4708
-							preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
4708
+							preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
4709 4709
 							if ($matches[2])
4710 4710
 							{
4711 4711
 								$hasOther = true;
@@ -4716,7 +4716,7 @@  discard block
 block discarded – undo
4716 4716
 					else
4717 4717
 					{
4718 4718
 						// htmLawed filter only the 'body'
4719
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
4719
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
4720 4720
 						if ($matches[2])
4721 4721
 						{
4722 4722
 							$hasOther = true;
@@ -4725,17 +4725,17 @@  discard block
 block discarded – undo
4725 4725
 						$htmLawed = new egw_htmLawed();
4726 4726
 						// the next line should not be needed, but produces better results on HTML 2 Text conversion,
4727 4727
 						// as we switched off HTMLaweds tidy functionality
4728
-						$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
4729
-						$newBody = $htmLawed->egw_htmLawed($newBody,self::$htmLawed_config);
4730
-						if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
4731
-						$alreadyHtmlLawed=true;
4728
+						$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
4729
+						$newBody = $htmLawed->egw_htmLawed($newBody, self::$htmLawed_config);
4730
+						if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
4731
+						$alreadyHtmlLawed = true;
4732 4732
 					}
4733 4733
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody);
4734
-					if ($preserveHTML==false) $newBody = translation::convertHTMLToText($newBody,self::$displayCharset,true,true);
4734
+					if ($preserveHTML == false) $newBody = translation::convertHTMLToText($newBody, self::$displayCharset, true, true);
4735 4735
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody);
4736
-					if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n
4736
+					if ($preserveHTML == false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n
4737 4737
 					/*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted
4738
-					if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody);
4738
+					if ($preserveHTML == false) $newBody = str_replace("<br />", "\r\n", $newBody);
4739 4739
 					//error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody);
4740 4740
 				}
4741 4741
 				$message .= $newBody;
@@ -4744,9 +4744,9 @@  discard block
 block discarded – undo
4744 4744
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Body(after specialchars):'.$newBody);
4745 4745
 			//use translation::convertHTMLToText instead of strip_tags, (even message is plain text) as strip_tags eats away too much
4746 4746
 			//$newBody = strip_tags($newBody); //we need to fix broken tags (or just stuff like "<800 USD/p" )
4747
-			$newBody = translation::convertHTMLToText($newBody,self::$displayCharset,false,false);
4747
+			$newBody = translation::convertHTMLToText($newBody, self::$displayCharset, false, false);
4748 4748
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Body(after strip tags):'.$newBody);
4749
-			$newBody = htmlspecialchars_decode($newBody,ENT_QUOTES);
4749
+			$newBody = htmlspecialchars_decode($newBody, ENT_QUOTES);
4750 4750
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Body (after hmlspc_decode):'.$newBody);
4751 4751
 			$message .= $newBody;
4752 4752
 			//continue;
@@ -4754,27 +4754,27 @@  discard block
 block discarded – undo
4754 4754
 		return $message;
4755 4755
 	}
4756 4756
 
4757
-	static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false)
4757
+	static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith = false)
4758 4758
 	{
4759 4759
 		$lines = explode("\n", $str);
4760 4760
 		$newStr = '';
4761
-		foreach($lines as $line)
4761
+		foreach ($lines as $line)
4762 4762
 		{
4763 4763
 			// replace tabs by 8 space chars, or any tab only counts one char
4764 4764
 			//$line = str_replace("\t","        ",$line);
4765 4765
 			//$newStr .= wordwrap($line, $cols, $cut);
4766
-			$allowedLength = $cols-strlen($cut);
4766
+			$allowedLength = $cols - strlen($cut);
4767 4767
 			//dont try to break lines with links, chance is we mess up the text is way too big
4768
-			if (strlen($line) > $allowedLength && stripos($line,'href=')===false &&
4769
-				($dontbreaklinesstartingwith==false ||
4768
+			if (strlen($line) > $allowedLength && stripos($line, 'href=') === false &&
4769
+				($dontbreaklinesstartingwith == false ||
4770 4770
 				 ($dontbreaklinesstartingwith &&
4771
-				  strlen($dontbreaklinesstartingwith)>=1 &&
4772
-				  substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith
4771
+				  strlen($dontbreaklinesstartingwith) >= 1 &&
4772
+				  substr($line, 0, strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith
4773 4773
 				 )
4774 4774
 				)
4775 4775
 			   )
4776 4776
 			{
4777
-				$s=explode(" ", $line);
4777
+				$s = explode(" ", $line);
4778 4778
 				$line = "";
4779 4779
 				$linecnt = 0;
4780 4780
 				foreach ($s as &$v) {
@@ -4782,22 +4782,22 @@  discard block
 block discarded – undo
4782 4782
 					// only break long words within the wordboundaries,
4783 4783
 					// but it may destroy links, so we check for href and dont do it if we find one
4784 4784
 					// we check for any html within the word, because we do not want to break html by accident
4785
-					if($cnt > $allowedLength && stripos($v,'href=')===false && stripos($v,'onclick=')===false && $cnt == strlen(html_entity_decode($v)))
4785
+					if ($cnt > $allowedLength && stripos($v, 'href=') === false && stripos($v, 'onclick=') === false && $cnt == strlen(html_entity_decode($v)))
4786 4786
 					{
4787
-						$v=wordwrap($v, $allowedLength, $cut, true);
4787
+						$v = wordwrap($v, $allowedLength, $cut, true);
4788 4788
 					}
4789 4789
 					// the rest should be broken at the start of the new word that exceeds the limit
4790
-					if ($linecnt+$cnt > $allowedLength) {
4791
-						$v=$cut.$v;
4790
+					if ($linecnt + $cnt > $allowedLength) {
4791
+						$v = $cut.$v;
4792 4792
 						#$linecnt = 0;
4793
-						$linecnt =strlen($v)-strlen($cut);
4793
+						$linecnt = strlen($v) - strlen($cut);
4794 4794
 					} else {
4795 4795
 						$linecnt += $cnt;
4796 4796
 					}
4797 4797
 					if (strlen($v)) $line .= (strlen($line) ? " " : "").$v;
4798 4798
 				}
4799 4799
 			}
4800
-			$newStr .= $line . "\n";
4800
+			$newStr .= $line."\n";
4801 4801
 		}
4802 4802
 		return $newStr;
4803 4803
 	}
@@ -4812,12 +4812,12 @@  discard block
 block discarded – undo
4812 4812
 	 * @param boolean $_useHeaderInsteadOfEnvelope - force getMessageHeader method to be used for fetching Envelope Information
4813 4813
 	 * @return array the message header
4814 4814
 	 */
4815
-	function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false)
4815
+	function getMessageEnvelope($_uid, $_partID = '', $decode = false, $_folder = '', $_useHeaderInsteadOfEnvelope = false)
4816 4816
 	{
4817 4817
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace());
4818
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
4818
+		if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
4819 4819
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder");
4820
-		if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) {
4820
+		if ((empty($_partID) || $_partID == 'null') && $_useHeaderInsteadOfEnvelope === false) {
4821 4821
 			$uidsToFetch = new Horde_Imap_Client_Ids();
4822 4822
 			if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
4823 4823
 			$uidsToFetch->add($_uid);
@@ -4829,7 +4829,7 @@  discard block
 block discarded – undo
4829 4829
 				'ids' => $uidsToFetch,
4830 4830
 			));
4831 4831
 			if (is_object($headersNew)) {
4832
-				foreach($headersNew as &$_headerObject) {
4832
+				foreach ($headersNew as &$_headerObject) {
4833 4833
 					$env = $_headerObject->getEnvelope();
4834 4834
 					//_debug_array($envFields->singleFields());
4835 4835
 					$singleFields = $envFields->singleFields();
@@ -4844,33 +4844,33 @@  discard block
 block discarded – undo
4844 4844
 							case 'bcc':
4845 4845
 							case 'sender':
4846 4846
 								//error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses));
4847
-								$envelope[$v]=$env->$v->addresses;
4847
+								$envelope[$v] = $env->$v->addresses;
4848 4848
 								$address = array();
4849 4849
 								if (!is_array($envelope[$v])) break;
4850 4850
 								foreach ($envelope[$v] as $k => $ad)
4851 4851
 								{
4852
-									if (stripos($ad,'@')===false)
4852
+									if (stripos($ad, '@') === false)
4853 4853
 									{
4854
-										$remember=$k;
4854
+										$remember = $k;
4855 4855
 									}
4856 4856
 									else
4857 4857
 									{
4858
-										$address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad;
4859
-										$remember=null;
4858
+										$address[] = (!is_null($remember) ? $envelope[$v][$remember].' ' : '').$ad;
4859
+										$remember = null;
4860 4860
 									}
4861 4861
 								}
4862 4862
 								$envelope[$v] = $address;
4863 4863
 								break;
4864 4864
 							case 'date':
4865
-								$envelope[$v]=egw_time::to($env->$v);
4865
+								$envelope[$v] = egw_time::to($env->$v);
4866 4866
 								break;
4867 4867
 							default:
4868
-								$envelope[$v]=$env->$v;
4868
+								$envelope[$v] = $env->$v;
4869 4869
 						}
4870 4870
 					}
4871 4871
 				}
4872 4872
 			}
4873
-			$envelope = array_change_key_case($envelope,CASE_UPPER);
4873
+			$envelope = array_change_key_case($envelope, CASE_UPPER);
4874 4874
 			//if ($decode) _debug_array($envelope);
4875 4875
 			//error_log(__METHOD__.' ('.__LINE__.') '.array2string($envelope));
4876 4876
 			if ($decode)
@@ -4878,19 +4878,19 @@  discard block
 block discarded – undo
4878 4878
 				foreach ($envelope as $key => $rvV)
4879 4879
 				{
4880 4880
 					//try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'
4881
-					$envelope[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO')));
4881
+					$envelope[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO')));
4882 4882
 				}
4883 4883
 			}
4884 4884
 			return $envelope;
4885 4885
 		} else {
4886 4886
 
4887
-			$headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder);
4887
+			$headers = $this->getMessageHeader($_uid, $_partID, true, true, $_folder);
4888 4888
 
4889 4889
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($headers));
4890 4890
 			//_debug_array($headers);
4891 4891
 			$newData = array(
4892 4892
 				'DATE'		=> $headers['DATE'],
4893
-				'SUBJECT'	=> ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']),
4893
+				'SUBJECT'	=> ($decode ? self::decode_header($headers['SUBJECT']) : $headers['SUBJECT']),
4894 4894
 				'MESSAGE_ID'	=> $headers['MESSAGE-ID']
4895 4895
 			);
4896 4896
 			if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO'];
@@ -4900,11 +4900,11 @@  discard block
 block discarded – undo
4900 4900
 			if (isset($headers['LIST-ID'])) $newData['LIST-ID'] = $headers['LIST-ID'];
4901 4901
 			//_debug_array($newData);
4902 4902
 			$recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO');
4903
-			foreach($recepientList as $recepientType) {
4904
-				if(isset($headers[$recepientType])) {
4905
-					if ($decode) $headers[$recepientType] =  self::decode_header($headers[$recepientType],true);
4903
+			foreach ($recepientList as $recepientType) {
4904
+				if (isset($headers[$recepientType])) {
4905
+					if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType], true);
4906 4906
 					//error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType]));
4907
-					foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) {
4907
+					foreach (self::parseAddressList($headers[$recepientType]) as $singleAddress) {
4908 4908
 						$addressData = array(
4909 4909
 							'PERSONAL_NAME'		=> $singleAddress->personal ? $singleAddress->personal : 'NIL',
4910 4910
 							'AT_DOMAIN_LIST'	=> $singleAddress->adl ? $singleAddress->adl : 'NIL',
@@ -4912,15 +4912,15 @@  discard block
 block discarded – undo
4912 4912
 							'HOST_NAME'		=> $singleAddress->host ? $singleAddress->host : 'NIL',
4913 4913
 							'EMAIL'			=> $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox,
4914 4914
 						);
4915
-						if($addressData['PERSONAL_NAME'] != 'NIL') {
4915
+						if ($addressData['PERSONAL_NAME'] != 'NIL') {
4916 4916
 							$addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal);
4917 4917
 						} else {
4918 4918
 							$addressData['RFC822_EMAIL'] = 'NIL';
4919 4919
 						}
4920
-						$newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData;
4920
+						$newData[$recepientType][] = ($addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']); //$addressData;
4921 4921
 					}
4922 4922
 				} else {
4923
-					if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') {
4923
+					if ($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') {
4924 4924
 						$newData[$recepientType] = $newData['FROM'];
4925 4925
 					} else {
4926 4926
 						$newData[$recepientType] = array();
@@ -4942,10 +4942,10 @@  discard block
 block discarded – undo
4942 4942
 	 * @param string $_folder folder to work on
4943 4943
 	 * @return array|Horde_Mime_Headers message header as array or object
4944 4944
 	 */
4945
-	function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='')
4945
+	function getMessageHeader($_uid, $_partID = '', $decode = false, $preserveUnSeen = false, $_folder = '')
4946 4946
 	{
4947 4947
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder);
4948
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
4948
+		if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
4949 4949
 		$uidsToFetch = new Horde_Imap_Client_Ids();
4950 4950
 		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
4951 4951
 		$uidsToFetch->add($_uid);
@@ -4953,7 +4953,7 @@  discard block
 block discarded – undo
4953 4953
 		$fquery = new Horde_Imap_Client_Fetch_Query();
4954 4954
 		if ($_partID != '')
4955 4955
 		{
4956
-			$fquery->headerText(array('id'=>$_partID,'peek'=>$preserveUnSeen));
4956
+			$fquery->headerText(array('id'=>$_partID, 'peek'=>$preserveUnSeen));
4957 4957
 			$fquery->structure();
4958 4958
 		}
4959 4959
 		else
@@ -4964,18 +4964,18 @@  discard block
 block discarded – undo
4964 4964
 			'ids' => $uidsToFetch,
4965 4965
 		));
4966 4966
 		if (is_object($headersNew)) {
4967
-			foreach($headersNew as $_fetchObject)
4967
+			foreach ($headersNew as $_fetchObject)
4968 4968
 			{
4969
-				$headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
4969
+				$headers = $_fetchObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
4970 4970
 				if ($_partID != '')
4971 4971
 				{
4972 4972
 					$mailStructureObject = $_fetchObject->getStructure();
4973 4973
 					foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type)
4974 4974
 					{
4975
-						if ($mime_id==$_partID)
4975
+						if ($mime_id == $_partID)
4976 4976
 						{
4977 4977
 							//error_log(__METHOD__.' ('.__LINE__.') '."$mime_id == $_partID".array2string($_headerObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray()));
4978
-							$headers = $_fetchObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
4978
+							$headers = $_fetchObject->getHeaderText($mime_id, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
4979 4979
 							break;
4980 4980
 						}
4981 4981
 					}
@@ -4986,14 +4986,14 @@  discard block
 block discarded – undo
4986 4986
 				if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
4987 4987
 				return $headers;
4988 4988
 			}
4989
-			$retValue = is_object($headers) ? $headers->toArray():array();
4989
+			$retValue = is_object($headers) ? $headers->toArray() : array();
4990 4990
 		}
4991
-		$retValue = array_change_key_case($retValue,CASE_UPPER);
4991
+		$retValue = array_change_key_case($retValue, CASE_UPPER);
4992 4992
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue));
4993 4993
 		// if SUBJECT is an array, use thelast one, as we assume something with the unfolding for the subject did not work
4994 4994
 		if (is_array($retValue['SUBJECT']))
4995 4995
 		{
4996
-			$retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT'])-1];
4996
+			$retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT']) - 1];
4997 4997
 		}
4998 4998
 		//error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($decode ? self::decode_header($retValue,true):$retValue));
4999 4999
 		if ($decode)
@@ -5001,7 +5001,7 @@  discard block
 block discarded – undo
5001 5001
 			foreach ($retValue as $key => $rvV)
5002 5002
 			{
5003 5003
 				//try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'
5004
-				$retValue[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO')));
5004
+				$retValue[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO')));
5005 5005
 			}
5006 5006
 		}
5007 5007
 		return $retValue;
@@ -5018,14 +5018,14 @@  discard block
 block discarded – undo
5018 5018
 	function getMessageRawHeader($_uid, $_partID = '', $_folder = '')
5019 5019
 	{
5020 5020
 		static $rawHeaders;
5021
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5021
+		if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5022 5022
 		//error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder");
5023 5023
 
5024
-		if (is_null($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = egw_cache::getCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
5025
-		if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
5024
+		if (is_null($rawHeaders) || !is_array($rawHeaders)) $rawHeaders = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1);
5025
+		if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]))
5026 5026
 		{
5027 5027
 			//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder");
5028
-			return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)];
5028
+			return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)];
5029 5029
 		}
5030 5030
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5031 5031
 		$uid = $_uid;
@@ -5035,7 +5035,7 @@  discard block
 block discarded – undo
5035 5035
 		$fquery = new Horde_Imap_Client_Fetch_Query();
5036 5036
 		if ($_partID != '')
5037 5037
 		{
5038
-			$fquery->headerText(array('id'=>$_partID,'peek'=>true));
5038
+			$fquery->headerText(array('id'=>$_partID, 'peek'=>true));
5039 5039
 			$fquery->structure();
5040 5040
 		}
5041 5041
 		else
@@ -5046,14 +5046,14 @@  discard block
 block discarded – undo
5046 5046
 			'ids' => $uidsToFetch,
5047 5047
 		));
5048 5048
 		if (is_object($headersNew)) {
5049
-			foreach($headersNew as &$_headerObject) {
5049
+			foreach ($headersNew as &$_headerObject) {
5050 5050
 				$retValue = $_headerObject->getHeaderText();
5051 5051
 				if ($_partID != '')
5052 5052
 				{
5053 5053
 					$mailStructureObject = $_headerObject->getStructure();
5054 5054
 					foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type)
5055 5055
 					{
5056
-						if ($mime_id==$_partID)
5056
+						if ($mime_id == $_partID)
5057 5057
 						{
5058 5058
 							$retValue = $_headerObject->getHeaderText($mime_id);
5059 5059
 						}
@@ -5061,8 +5061,8 @@  discard block
 block discarded – undo
5061 5061
 				}
5062 5062
 			}
5063 5063
 		}
5064
-		$rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]=$retValue;
5065
-		egw_cache::setCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeaders,60*60*1);
5064
+		$rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $retValue;
5065
+		egw_cache::setCache(egw_cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), $rawHeaders, 60 * 60 * 1);
5066 5066
 		return $retValue;
5067 5067
 	}
5068 5068
 
@@ -5075,25 +5075,25 @@  discard block
 block discarded – undo
5075 5075
 	{
5076 5076
 		$style = '';
5077 5077
 		if (empty($_bodyParts)) return "";
5078
-		foreach((array)$_bodyParts as $singleBodyPart) {
5078
+		foreach ((array)$_bodyParts as $singleBodyPart) {
5079 5079
 			if (!isset($singleBodyPart['body'])) {
5080 5080
 				$singleBodyPart['body'] = self::getStyles($singleBodyPart);
5081 5081
 				$style .= $singleBodyPart['body'];
5082 5082
 				continue;
5083 5083
 			}
5084 5084
 
5085
-			if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = translation::detect_encoding($singleBodyPart['body']);
5085
+			if ($singleBodyPart['charSet'] === false) $singleBodyPart['charSet'] = translation::detect_encoding($singleBodyPart['body']);
5086 5086
 			$singleBodyPart['body'] = translation::convert(
5087 5087
 				$singleBodyPart['body'],
5088 5088
 				strtolower($singleBodyPart['charSet'])
5089 5089
 			);
5090 5090
 			$ct = 0;
5091
-			$newStyle=array();
5092
-			if (stripos($singleBodyPart['body'],'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle);
5093
-			if ($ct>0)
5091
+			$newStyle = array();
5092
+			if (stripos($singleBodyPart['body'], '<style') !== false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle);
5093
+			if ($ct > 0)
5094 5094
 			{
5095 5095
 				//error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle));
5096
-				$style2buffer = implode('',$newStyle[0]);
5096
+				$style2buffer = implode('', $newStyle[0]);
5097 5097
 			}
5098 5098
 			if ($style2buffer && strtoupper(self::$displayCharset) == 'UTF-8')
5099 5099
 			{
@@ -5101,7 +5101,7 @@  discard block
 block discarded – undo
5101 5101
 				$test = json_encode($style2buffer);
5102 5102
 				//error_log(__METHOD__.' ('.__LINE__.') '.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error());
5103 5103
 				//if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0)
5104
-				if ($test=="null" && strlen($style2buffer)>0)
5104
+				if ($test == "null" && strlen($style2buffer) > 0)
5105 5105
 				{
5106 5106
 					// this should not be needed, unless something fails with charset detection/ wrong charset passed
5107 5107
 					error_log(__METHOD__.' ('.__LINE__.') '.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Charset Reported:'.$singleBodyPart['charSet'].' Carset Detected:'.translation::detect_encoding($style2buffer));
@@ -5112,19 +5112,19 @@  discard block
 block discarded – undo
5112 5112
 		}
5113 5113
 		// clean out comments and stuff
5114 5114
 		$search = array(
5115
-			'@url\(http:\/\/[^\)].*?\)@si',  // url calls e.g. in style definitions
5115
+			'@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions
5116 5116
 //			'@<!--[\s\S]*?[ \t\n\r]*-->@',   // Strip multi-line comments including CDATA
5117 5117
 //			'@<!--[\s\S]*?[ \t\n\r]*--@',    // Strip broken multi-line comments including CDATA
5118 5118
 		);
5119
-		$style = preg_replace($search,"",$style);
5119
+		$style = preg_replace($search, "", $style);
5120 5120
 
5121 5121
 		// CSS Security
5122 5122
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
5123
-		$css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style);
5124
-		if (stripos($css,'script')!==false) translation::replaceTagsCompletley($css,'script'); // Strip out script that may be included
5123
+		$css = preg_replace('/(javascript|expression|-moz-binding)/i', '', $style);
5124
+		if (stripos($css, 'script') !== false) translation::replaceTagsCompletley($css, 'script'); // Strip out script that may be included
5125 5125
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
5126 5126
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
5127
-		$css = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
5127
+		$css = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css);
5128 5128
 		//error_log(__METHOD__.' ('.__LINE__.') '.$css);
5129 5129
 		// TODO: we may have to strip urls and maybe comments and ifs
5130 5130
 		return $css;
@@ -5138,16 +5138,16 @@  discard block
 block discarded – undo
5138 5138
 	 * @param string $_folder folder to work on
5139 5139
 	 * @return string the message body
5140 5140
 	 */
5141
-	function getMessageRawBody($_uid, $_partID = '', $_folder='')
5141
+	function getMessageRawBody($_uid, $_partID = '', $_folder = '')
5142 5142
 	{
5143 5143
 		//TODO: caching einbauen static!
5144 5144
 		static $rawBody;
5145 5145
 		if (is_null($rawBody)) $rawBody = array();
5146
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5147
-		if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
5146
+		if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5147
+		if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]))
5148 5148
 		{
5149 5149
 			//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder");
5150
-			return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)];
5150
+			return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)];
5151 5151
 		}
5152 5152
 
5153 5153
 		$uidsToFetch = new Horde_Imap_Client_Ids();
@@ -5160,13 +5160,13 @@  discard block
 block discarded – undo
5160 5160
 		if ($_partID != '')
5161 5161
 		{
5162 5162
 			$fquery->structure();
5163
-			$fquery->bodyPart($_partID,array('peek'=>true));
5163
+			$fquery->bodyPart($_partID, array('peek'=>true));
5164 5164
 		}
5165 5165
 		$headersNew = $this->icServer->fetch($_folder, $fquery, array(
5166 5166
 			'ids' => $uidsToFetch,
5167 5167
 		));
5168 5168
 		if (is_object($headersNew)) {
5169
-			foreach($headersNew as &$_headerObject) {
5169
+			foreach ($headersNew as &$_headerObject) {
5170 5170
 				$body = $_headerObject->getFullMsg();
5171 5171
 				if ($_partID != '')
5172 5172
 				{
@@ -5174,7 +5174,7 @@  discard block
 block discarded – undo
5174 5174
 					//_debug_array($mailStructureObject->contentTypeMap());
5175 5175
 					foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type)
5176 5176
 					{
5177
-						if ($mime_id==$_partID)
5177
+						if ($mime_id == $_partID)
5178 5178
 						{
5179 5179
 							$body = $_headerObject->getBodyPart($mime_id);
5180 5180
 						}
@@ -5183,7 +5183,7 @@  discard block
 block discarded – undo
5183 5183
 			}
5184 5184
 		}
5185 5185
 		//error_log(__METHOD__.' ('.__LINE__.') '."[$this->icServer->ImapServerId][$_folder][$_uid][".(empty($_partID)?'NIL':$_partID)."]");
5186
-		$rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)] = $body;
5186
+		$rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $body;
5187 5187
 		return $body;
5188 5188
 	}
5189 5189
 
@@ -5197,13 +5197,13 @@  discard block
 block discarded – undo
5197 5197
 	 * @param Horde_Imap_Client_Fetch_Query $fquery=null default query just structure
5198 5198
 	 * @return Horde_Mime_Part
5199 5199
 	 */
5200
-	function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false)
5200
+	function getStructure($_uid, $_partID = null, $_folder = null, $_preserveSeen = false)
5201 5201
 	{
5202
-		if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID");
5202
+		if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_partID");
5203 5203
 
5204 5204
 		if (empty($_folder))
5205 5205
 		{
5206
-			$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5206
+			$_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5207 5207
 		}
5208 5208
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5209 5209
 		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
@@ -5221,7 +5221,7 @@  discard block
 block discarded – undo
5221 5221
 				'ids' => $uidsToFetch,
5222 5222
 			))->first();
5223 5223
 
5224
-			return is_object($mail)?$mail->getStructure():null;
5224
+			return is_object($mail) ? $mail->getStructure() : null;
5225 5225
 		}
5226 5226
 		catch (Exception $e)
5227 5227
 		{
@@ -5244,14 +5244,14 @@  discard block
 block discarded – undo
5244 5244
 	 * @param string $_folder folder to work on
5245 5245
 	 * @return array  an array of information about the attachment: array of array(name, size, mimeType, partID, encoding)
5246 5246
 	 */
5247
-	function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='')
5247
+	function getMessageAttachments($_uid, $_partID = null, Horde_Mime_Part $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = false, $resolveTNEF = true, $_folder = '')
5248 5248
 	{
5249
-		if (self::$debug) error_log( __METHOD__.":$_uid, $_partID");
5250
-		if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5249
+		if (self::$debug) error_log(__METHOD__.":$_uid, $_partID");
5250
+		if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5251 5251
 		$attachments = array();
5252 5252
 		if (!isset($_structure))
5253 5253
 		{
5254
-			$_structure = $this->getStructure($_uid, $_partID,$_folder,true);
5254
+			$_structure = $this->getStructure($_uid, $_partID, $_folder, true);
5255 5255
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true));
5256 5256
 		}
5257 5257
 		if (!$_structure || !$_structure->contentTypeMap()) return array();
@@ -5259,7 +5259,7 @@  discard block
 block discarded – undo
5259 5259
 		$skipParts = array();
5260 5260
 		$tnefParts = array();
5261 5261
 		$skip = 0;
5262
-		foreach($_structure->contentTypeMap() as $mime_id => $mime_type)
5262
+		foreach ($_structure->contentTypeMap() as $mime_id => $mime_type)
5263 5263
 		{
5264 5264
 			$part = $_structure->getPart($mime_id);
5265 5265
 			//error_log(__METHOD__.' ('.__LINE__.') '.':'.' Uid:'.$uid.' Part:'.$_partID.'->'.array2string($part->getMimeId()));
@@ -5270,10 +5270,10 @@  discard block
 block discarded – undo
5270 5270
 			$partPrimaryType = $part->getPrimaryType();
5271 5271
 			// we only want to retrieve the attachments of the current mail, not those of possible
5272 5272
 			// attached mails
5273
-			if ($mime_type=='message/rfc822' && $_partID!=$mime_id)
5273
+			if ($mime_type == 'message/rfc822' && $_partID != $mime_id)
5274 5274
 			{
5275 5275
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap()));
5276
-				foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;}
5276
+				foreach ($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; }
5277 5277
 			}
5278 5278
 			if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')
5279 5279
 			{
@@ -5281,27 +5281,27 @@  discard block
 block discarded – undo
5281 5281
 				// attachment with no link to show the attachment inline.
5282 5282
 				// Considering this: we "list" everything that matches the above criteria
5283 5283
 				// as attachment in order to not loose/miss information on our data
5284
-				$partDisposition='attachment';
5284
+				$partDisposition = 'attachment';
5285 5285
 			}
5286 5286
 			//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts));
5287
-			if (array_key_exists($mime_id,$skipParts)) continue;
5287
+			if (array_key_exists($mime_id, $skipParts)) continue;
5288 5288
 
5289 5289
 			if ($partDisposition == 'attachment' ||
5290
-				(($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') ||
5290
+				(($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId() == '') ||
5291 5291
 				(($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType != 'image' && $partPrimaryType != 'text' && $partPrimaryType != 'multipart') ||
5292
-				($mime_type=='image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs
5292
+				($mime_type == 'image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs
5293 5293
 				($fetchEmbeddedImages && ($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image') ||
5294 5294
 				($fetchTextCalendar && $partPrimaryType == 'text' && $part->getSubType() == 'calendar'))
5295 5295
 			{
5296 5296
 				// if type is message/rfc822 and _partID is given, and MimeID equals partID
5297 5297
 				// we attempt to fetch "ourselves"
5298
-				if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue;
5298
+				if ($_partID == $part->getMimeId() && $part->getPrimaryType() == 'message') continue;
5299 5299
 				$attachment = $part->getAllDispositionParameters();
5300 5300
 
5301 5301
 				$attachment['mimeType'] = $mime_type;
5302 5302
 				$attachment['uid'] = $_uid;
5303 5303
 				$attachment['partID'] = $mime_id;
5304
-				if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName();
5304
+				if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName();
5305 5305
 				if ($fetchTextCalendar)
5306 5306
 				{
5307 5307
 					//error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters()));
@@ -5311,11 +5311,11 @@  discard block
 block discarded – undo
5311 5311
 				}
5312 5312
 				$attachment['size'] = $part->getBytes();
5313 5313
 				if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5314
-				if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($mime_type);
5314
+				if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($mime_type);
5315 5315
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment));
5316 5316
 				//typical winmail.dat attachment is
5317 5317
 				//Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat)
5318
-				if ($resolveTNEF && ($attachment['mimeType']=='application/ms-tnef' || !strcasecmp($attachment['name'],'winmail.dat')))
5318
+				if ($resolveTNEF && ($attachment['mimeType'] == 'application/ms-tnef' || !strcasecmp($attachment['name'], 'winmail.dat')))
5319 5319
 				{
5320 5320
 					$tnefParts[] = $attachment;
5321 5321
 				}
@@ -5330,31 +5330,31 @@  discard block
 block discarded – undo
5330 5330
 			//error_log(__METHOD__.__LINE__.array2string($tnefParts));
5331 5331
 			foreach ($tnefParts as $k => $tnp)
5332 5332
 			{
5333
-				$tnefResolved=false;
5334
-				$tnef_data = $this->getAttachment($tnp['uid'],$tnp['partID'],$k,false);
5333
+				$tnefResolved = false;
5334
+				$tnef_data = $this->getAttachment($tnp['uid'], $tnp['partID'], $k, false);
5335 5335
 				$myTnef = $this->tnef_decoder($tnef_data['attachment']);
5336 5336
 				//error_log(__METHOD__.__LINE__.array2string($myTnef->getParts()));
5337 5337
 				// Note: MimeId starts with 0, almost always, we cannot use that as winmail_id
5338 5338
 				// we need to build Something that meets the needs
5339 5339
 				if ($myTnef)
5340 5340
 				{
5341
-					foreach($myTnef->getParts() as $mime_id => $part)
5341
+					foreach ($myTnef->getParts() as $mime_id => $part)
5342 5342
 					{
5343
-						$tnefResolved=true;
5343
+						$tnefResolved = true;
5344 5344
 						$attachment = $part->getAllDispositionParameters();
5345 5345
 
5346 5346
 						$attachment['mimeType'] = $part->getType();
5347 5347
 						$attachment['uid'] = $tnp['uid'];
5348 5348
 						$attachment['partID'] = $tnp['partID'];
5349 5349
 						$attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id;
5350
-						if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName();
5350
+						if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName();
5351 5351
 						$attachment['size'] = $part->getBytes();
5352 5352
 						if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5353
-						if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($attachment['mimeType']);
5353
+						if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($attachment['mimeType']);
5354 5354
 						$attachments[] = $attachment;
5355 5355
 					}
5356 5356
 				}
5357
-				if ($tnefResolved===false) $attachments[]=$tnp;
5357
+				if ($tnefResolved === false) $attachments[] = $tnp;
5358 5358
 			}
5359 5359
 		}
5360 5360
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
@@ -5369,9 +5369,9 @@  discard block
 block discarded – undo
5369 5369
 	 * @return boolean|Horde_Mime_part Multipart/Mixed part decoded attachments |
5370 5370
 	 *	return false if there's no attachments or failure
5371 5371
 	 */
5372
-	public function tnef_decoder( $data )
5372
+	public function tnef_decoder($data)
5373 5373
 	{
5374
-		foreach(array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class)
5374
+		foreach (array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class)
5375 5375
 		{
5376 5376
 			if (!class_exists($class))
5377 5377
 			{
@@ -5402,7 +5402,7 @@  discard block
 block discarded – undo
5402 5402
 				$tmp_part->setContents($data['stream']);
5403 5403
 				$tmp_part->setDescription($data['name']);
5404 5404
 
5405
-				$type = $data['type'] . '/' . $data['subtype'];
5405
+				$type = $data['type'].'/'.$data['subtype'];
5406 5406
 				if (in_array($type, array('application/octet-stream', 'application/base64')))
5407 5407
 				{
5408 5408
 					$type = Horde_Mime_Magic::filenameToMIME($data['name']);
@@ -5445,24 +5445,24 @@  discard block
 block discarded – undo
5445 5445
 	 *
5446 5446
 	 * @return array returns an array of all resolved embeded attachments from winmail.dat
5447 5447
 	 */
5448
-	function getTnefAttachments ($_uid, $_partID, $_stream=false)
5448
+	function getTnefAttachments($_uid, $_partID, $_stream = false)
5449 5449
 	{
5450
-		$tnef_data = $this->getAttachment($_uid, $_partID,0,false);
5450
+		$tnef_data = $this->getAttachment($_uid, $_partID, 0, false);
5451 5451
 		$tnef_parts = $this->tnef_decoder($tnef_data['attachment']);
5452 5452
 		$attachments = array();
5453 5453
 		if ($tnef_parts)
5454 5454
 		{
5455
-			foreach($tnef_parts->getParts() as $mime_id => $part)
5455
+			foreach ($tnef_parts->getParts() as $mime_id => $part)
5456 5456
 			{
5457 5457
 
5458 5458
 				$attachment = $part->getAllDispositionParameters();
5459 5459
 				$attachment['mimeType'] = $part->getType();
5460
-				if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5460
+				if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5461 5461
 				if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5462 5462
 				if (empty($attachment['filename']))
5463 5463
 				{
5464
-					$attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?
5465
-						$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($attachment['mimeType']);
5464
+					$attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ?
5465
+						$attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($attachment['mimeType']);
5466 5466
 				}
5467 5467
 
5468 5468
 				$attachment['attachment'] = $part->getContents(array('stream'=>$_stream));
@@ -5486,10 +5486,10 @@  discard block
 block discarded – undo
5486 5486
 	 *
5487 5487
 	 * @return array
5488 5488
 	 */
5489
-	function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null)
5489
+	function getAttachment($_uid, $_partID, $_winmail_nr = 0, $_returnPart = true, $_stream = false, $_folder = null)
5490 5490
 	{
5491 5491
 		//error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace());
5492
-		if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5492
+		if (!isset($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
5493 5493
 
5494 5494
 		$uidsToFetch = new Horde_Imap_Client_Ids();
5495 5495
 		if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
@@ -5502,36 +5502,36 @@  discard block
 block discarded – undo
5502 5502
 			'ids' => $uidsToFetch,
5503 5503
 		));
5504 5504
 		if (is_object($headersNew)) {
5505
-			foreach($headersNew as $id=>$_headerObject) {
5505
+			foreach ($headersNew as $id=>$_headerObject) {
5506 5506
 				$body = $_headerObject->getFullMsg();
5507 5507
 				if ($_partID != '')
5508 5508
 				{
5509 5509
 					$mailStructureObject = $_headerObject->getStructure();
5510 5510
 					$mailStructureObject->contentTypeMap();
5511 5511
 					$part = $mailStructureObject->getPart($_partID);
5512
-					$partDisposition = ($part?$part->getDisposition():'failed');
5513
-					if ($partDisposition=='failed')
5512
+					$partDisposition = ($part ? $part->getDisposition() : 'failed');
5513
+					if ($partDisposition == 'failed')
5514 5514
 					{
5515 5515
 						error_log(__METHOD__.'('.__LINE__.'):'.array2string($_uid).','.$_partID.' ID:'.$id.' HObject:'.array2string($_headerObject).' StructureObject:'.array2string($mailStructureObject->contentTypeMap()).'->'.function_backtrace());
5516 5516
 					}
5517 5517
 					// if $partDisposition is empty, we assume attachment, and hope that the function
5518 5518
 					// itself is only triggered to fetch attachments
5519
-					if (empty($partDisposition)) $partDisposition='attachment';
5520
-					if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar')))
5519
+					if (empty($partDisposition)) $partDisposition = 'attachment';
5520
+					if ($part && ($partDisposition == 'attachment' || $partDisposition == 'inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar')))
5521 5521
 					{
5522 5522
 						//$headerObject=$part->getAllDispositionParameters();//not used anywhere around here
5523 5523
 						$structure_mime = $part->getType();
5524 5524
 						$filename = $part->getName();
5525 5525
 						$charset = $part->getContentTypeParameter('charset');
5526 5526
 						//$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" );
5527
-						$this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime);
5527
+						$this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen = true, $structure_mime);
5528 5528
 						if ($_returnPart) return $part;
5529 5529
 					}
5530 5530
 				}
5531 5531
 			}
5532 5532
 		}
5533 5533
 		$ext = mime_magic::mime2ext($structure_mime);
5534
-		if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext;
5534
+		if ($ext && stripos($filename, '.') === false && stripos($filename, $ext) === false) $filename = trim($filename).'.'.$ext;
5535 5535
 		if (!$part)
5536 5536
 		{
5537 5537
 			throw new egw_exception_wrong_parameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder");
@@ -5549,20 +5549,20 @@  discard block
 block discarded – undo
5549 5549
 		// try guessing the mimetype, if we get the application/octet-stream
5550 5550
 		if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = mime_magic::filename2mime($attachmentData['filename']);
5551 5551
 		# if the attachment holds a winmail number and is a winmail.dat then we have to handle that.
5552
-		if ( $filename == 'winmail.dat' && $_winmail_nr)
5552
+		if ($filename == 'winmail.dat' && $_winmail_nr)
5553 5553
 		{
5554 5554
 			//by now _uid is of type array
5555
-			$tnefResolved=false;
5556
-			$wantedPart=$_uid[0].'@'.$_partID;
5555
+			$tnefResolved = false;
5556
+			$wantedPart = $_uid[0].'@'.$_partID;
5557 5557
 			$myTnef = $this->tnef_decoder($attachmentData['attachment']);
5558 5558
 			//error_log(__METHOD__.__LINE__.array2string($myTnef->getParts()));
5559 5559
 			// Note: MimeId starts with 0, almost always, we cannot use that as winmail_id
5560 5560
 			// we need to build Something that meets the needs
5561 5561
 			if ($myTnef)
5562 5562
 			{
5563
-				foreach($myTnef->getParts() as $mime_id => $part)
5563
+				foreach ($myTnef->getParts() as $mime_id => $part)
5564 5564
 				{
5565
-					$tnefResolved=true;
5565
+					$tnefResolved = true;
5566 5566
 					$attachment = $part->getAllDispositionParameters();
5567 5567
 					$attachment['mimeType'] = $part->getType();
5568 5568
 					//error_log(__METHOD__.__LINE__.'#'.$mime_id.'#'.$filename.'#'.array2string($attachment));
@@ -5570,9 +5570,9 @@  discard block
 block discarded – undo
5570 5570
 					if ($_winmail_nr == $wantedPart.'@'.$mime_id)
5571 5571
 					{
5572 5572
 						//error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment));
5573
-						if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5573
+						if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName();
5574 5574
 						if (($cid = $part->getContentId())) $attachment['cid'] = $cid;
5575
-						if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($attachment['mimeType']);
5575
+						if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.mime_magic::mime2ext($attachment['mimeType']);
5576 5576
 						$wmattach = $attachment;
5577 5577
 						$wmattach['attachment'] = $part->getContents(array('stream'=>$_stream));
5578 5578
 
@@ -5582,7 +5582,7 @@  discard block
 block discarded – undo
5582 5582
 			if ($tnefResolved)
5583 5583
 			{
5584 5584
 				$ext = mime_magic::mime2ext($wmattach['mimeType']);
5585
-				if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext;
5585
+				if ($ext && stripos($wmattach['filename'], '.') === false && stripos($wmattach['filename'], $ext) === false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext;
5586 5586
 				$attachmentData = array(
5587 5587
 					'type'       => $wmattach['mimeType'],
5588 5588
 					'filename'   => $wmattach['filename'],
@@ -5606,21 +5606,21 @@  discard block
 block discarded – undo
5606 5606
 	 *	true:
5607 5607
 	 * @return Horde_Mime_Part
5608 5608
 	 */
5609
-	function getAttachmentByCID($_uid, $_cid, $_part, $_stream=null)
5609
+	function getAttachmentByCID($_uid, $_cid, $_part, $_stream = null)
5610 5610
 	{
5611 5611
 		// some static variables to avoid fetching the same mail multiple times
5612
-		static $uid=null, $part=null, $structure=null;
5612
+		static $uid = null, $part = null, $structure = null;
5613 5613
 		//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part");
5614 5614
 
5615
-		if(empty($_cid)) return false;
5615
+		if (empty($_cid)) return false;
5616 5616
 
5617 5617
 		if ($_uid != $uid || $_part != $part)
5618 5618
 		{
5619
-			$structure = $this->getStructure($uid=$_uid, $part=$_part);
5619
+			$structure = $this->getStructure($uid = $_uid, $part = $_part);
5620 5620
 		}
5621 5621
 		/** @var Horde_Mime_Part */
5622 5622
 		$attachment = null;
5623
-		foreach($structure->contentTypeMap() as $mime_id => $mime_type)
5623
+		foreach ($structure->contentTypeMap() as $mime_id => $mime_type)
5624 5624
 		{
5625 5625
 			$part = $structure->getPart($mime_id);
5626 5626
 
@@ -5672,16 +5672,16 @@  discard block
 block discarded – undo
5672 5672
 	 * @param string  $_mimetype to decide wether to try to fetch part as binary or not
5673 5673
 	 * @return Horde_Mime_Part
5674 5674
 	 */
5675
-	public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null)
5675
+	public function fetchPartContents($_uid, Horde_Mime_Part $part = null, $_stream = false, $_preserveSeen = false, $_mimetype = null)
5676 5676
 	{
5677
-		if (is_null($part)) return null;//new Horde_Mime_Part;
5677
+		if (is_null($part)) return null; //new Horde_Mime_Part;
5678 5678
 		$encoding = null;
5679 5679
 		$fetchAsBinary = true;
5680
-		if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false;
5680
+		if ($_mimetype && strtolower($_mimetype) == 'message/rfc822') $fetchAsBinary = false;
5681 5681
 		// we need to set content on structure to decode transfer encoding
5682 5682
 		$part->setContents(
5683 5683
 			$this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary),
5684
-			array('encoding' => (!$fetchAsBinary&&!$encoding?'8bit':$encoding)));
5684
+			array('encoding' => (!$fetchAsBinary && !$encoding ? '8bit' : $encoding)));
5685 5685
 
5686 5686
 		return $part;
5687 5687
 	}
@@ -5699,17 +5699,17 @@  discard block
 block discarded – undo
5699 5699
 	 * @return the id of the message appended or exception
5700 5700
 	 * @throws egw_exception_wrong_userinput
5701 5701
 	 */
5702
-	function appendMessage($_folderName, $_header, $_body, $_flags='\\Recent')
5702
+	function appendMessage($_folderName, $_header, $_body, $_flags = '\\Recent')
5703 5703
 	{
5704 5704
 		if (!is_resource($_header))
5705 5705
 		{
5706
-			if (stripos($_header,'message-id:')===false)
5706
+			if (stripos($_header, 'message-id:') === false)
5707 5707
 			{
5708 5708
 				$_header = 'Message-ID: <'.self::getRandomString().'@localhost>'."\n".$_header;
5709 5709
 			}
5710 5710
 			//error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_header, $_body, $_flags");
5711
-			$_header = ltrim(str_replace("\n","\r\n",$_header));
5712
-			$_header .= str_replace("\n","\r\n",$_body);
5711
+			$_header = ltrim(str_replace("\n", "\r\n", $_header));
5712
+			$_header .= str_replace("\n", "\r\n", $_body);
5713 5713
 		}
5714 5714
 		// the recent flag is the default enforced here ; as we assume the _flags is always set,
5715 5715
 		// we default it to hordes default (Recent) (, other wise we should not pass the parameter
@@ -5727,7 +5727,7 @@  discard block
 block discarded – undo
5727 5727
 			// searched for the message-id then returning the uid found
5728 5728
 			//$dataNflags[] = array('data'=>array(array('t'=>'text','v'=>"$header"."$body")), 'flags'=>array($_flags));
5729 5729
 			$dataNflags[] = array('data' => $_header, 'flags'=>array($_flags));
5730
-			$messageid = $this->icServer->append($_folderName,$dataNflags);
5730
+			$messageid = $this->icServer->append($_folderName, $dataNflags);
5731 5731
 		}
5732 5732
 		catch (Exception $e)
5733 5733
 		{
@@ -5739,7 +5739,7 @@  discard block
 block discarded – undo
5739 5739
 		//$messageid = true; // for debug reasons only
5740 5740
 		if ($messageid === true || empty($messageid)) // try to figure out the message uid
5741 5741
 		{
5742
-			$list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false);
5742
+			$list = $this->getHeaders($_folderName, $_startMessage = 1, 1, 'INTERNALDATE', true, array(), null, false);
5743 5743
 			if ($list)
5744 5744
 			{
5745 5745
 				if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list));
@@ -5779,27 +5779,27 @@  discard block
 block discarded – undo
5779 5779
 	 *				'attachments'=>$attachments,
5780 5780
 	 *				'headers'=>$headers,; boolean false on failure
5781 5781
 	 */
5782
-	static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true)
5782
+	static function get_mailcontent(&$mailClass, $uid, $partid = '', $mailbox = '', $preserveHTML = false, $addHeaderSection = true, $includeAttachments = true)
5783 5783
 	{
5784 5784
 			//echo __METHOD__." called for $uid,$partid <br>";
5785
-			$headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox);
5785
+			$headers = $mailClass->getMessageHeader($uid, $partid, true, false, $mailbox);
5786 5786
 			if (empty($headers)) return false;
5787 5787
 			// dont force retrieval of the textpart, let mailClass preferences decide
5788
-			$bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox);
5788
+			$bodyParts = $mailClass->getMessageBody($uid, ($preserveHTML ? 'always_display' : 'only_if_no_text'), $partid, null, false, $mailbox);
5789 5789
 			// if we do not want HTML but there is no TextRepresentation with the message itself, try converting
5790
-			if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html')
5790
+			if (!$preserveHTML && $bodyParts[0]['mimeType'] == 'text/html')
5791 5791
 			{
5792
-				foreach($bodyParts as $i => $part)
5792
+				foreach ($bodyParts as $i => $part)
5793 5793
 				{
5794
-					if ($bodyParts[$i]['mimeType']=='text/html')
5794
+					if ($bodyParts[$i]['mimeType'] == 'text/html')
5795 5795
 					{
5796
-						$bodyParts[$i]['body'] = translation::convertHTMLToText($bodyParts[$i]['body'],$bodyParts[$i]['charSet'],true,$stripalltags=true);
5797
-						$bodyParts[$i]['mimeType']='text/plain';
5796
+						$bodyParts[$i]['body'] = translation::convertHTMLToText($bodyParts[$i]['body'], $bodyParts[$i]['charSet'], true, $stripalltags = true);
5797
+						$bodyParts[$i]['mimeType'] = 'text/plain';
5798 5798
 					}
5799 5799
 				}
5800 5800
 			}
5801 5801
 			//error_log(array2string($bodyParts));
5802
-			$attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array();
5802
+			$attachments = $includeAttachments ? $mailClass->getMessageAttachments($uid, $partid, null, true, false, true, $mailbox) : array();
5803 5803
 
5804 5804
 			if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO'];
5805 5805
 			elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM'];
@@ -5810,7 +5810,7 @@  discard block
 block discarded – undo
5810 5810
 
5811 5811
 			$message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML);
5812 5812
 			if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>';
5813
-			$headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : '');
5813
+			$headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '', $preserveHTML) : '');
5814 5814
 			$message = $headdata.$message;
5815 5815
 			//echo __METHOD__.'<br>';
5816 5816
 			//_debug_array($attachments);
@@ -5826,25 +5826,25 @@  discard block
 block discarded – undo
5826 5826
 						//_debug_array($mailClass->getMessageHeader($uid, $attachment['partID']));
5827 5827
 						//_debug_array($mailClass->getMessageBody($uid,'', $attachment['partID']));
5828 5828
 						//_debug_array($mailClass->getMessageAttachments($uid, $attachment['partID']));
5829
-						$mailcontent = self::get_mailcontent($mailClass,$uid,$attachment['partID'],$mailbox);
5830
-						$headdata ='';
5829
+						$mailcontent = self::get_mailcontent($mailClass, $uid, $attachment['partID'], $mailbox);
5830
+						$headdata = '';
5831 5831
 						if ($mailcontent['headers'])
5832 5832
 						{
5833
-							$headdata = self::createHeaderInfoSection($mailcontent['headers'],'',$preserveHTML);
5833
+							$headdata = self::createHeaderInfoSection($mailcontent['headers'], '', $preserveHTML);
5834 5834
 						}
5835 5835
 						if ($mailcontent['message'])
5836 5836
 						{
5837
-							$tempname =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
5837
+							$tempname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_");
5838 5838
 							$attachedMessages[] = array(
5839 5839
 								'type' => 'TEXT/PLAIN',
5840 5840
 								'name' => $mailcontent['subject'].'.txt',
5841 5841
 								'tmp_name' => $tempname,
5842 5842
 							);
5843
-							$tmpfile = fopen($tempname,'w');
5844
-							fwrite($tmpfile,$headdata.$mailcontent['message']);
5843
+							$tmpfile = fopen($tempname, 'w');
5844
+							fwrite($tmpfile, $headdata.$mailcontent['message']);
5845 5845
 							fclose($tmpfile);
5846 5846
 						}
5847
-						foreach($mailcontent['attachments'] as &$tmpval)
5847
+						foreach ($mailcontent['attachments'] as &$tmpval)
5848 5848
 						{
5849 5849
 							$attachedMessages[] = $tmpval;
5850 5850
 						}
@@ -5852,36 +5852,36 @@  discard block
 block discarded – undo
5852 5852
 					}
5853 5853
 					else
5854 5854
 					{
5855
-						$attachments[$num] = array_merge($attachments[$num],$mailClass->getAttachment($uid, $attachment['partID'],0,false,false));
5855
+						$attachments[$num] = array_merge($attachments[$num], $mailClass->getAttachment($uid, $attachment['partID'], 0, false, false));
5856 5856
 
5857
-						if (empty($attachments[$num]['attachment'])&&$attachments[$num]['cid'])
5857
+						if (empty($attachments[$num]['attachment']) && $attachments[$num]['cid'])
5858 5858
 						{
5859
-							$c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'],true);
5859
+							$c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'], true);
5860 5860
 							$attachments[$num]['attachment'] = $c->getContents();
5861 5861
 						}
5862 5862
 						// no attempt to convert, if we dont know about the charset
5863
-						if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) {
5863
+						if (isset($attachments[$num]['charset']) && !empty($attachments[$num]['charset'])) {
5864 5864
 							// we do not try guessing the charset, if it is not set
5865 5865
 							//if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = translation::detect_encoding($attachments[$num]['attachment']);
5866
-							translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']);
5866
+							translation::convert($attachments[$num]['attachment'], $attachments[$num]['charset']);
5867 5867
 						}
5868
-						if(in_array($attachments[$num]['name'], $file_list))
5868
+						if (in_array($attachments[$num]['name'], $file_list))
5869 5869
 						{
5870 5870
 							$dupe_count[$attachments[$num]['name']]++;
5871
-							$attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME) .
5872
-								' ('.($dupe_count[$attachments[$num]['name']] + 1).')' . '.' .
5871
+							$attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME).
5872
+								' ('.($dupe_count[$attachments[$num]['name']] + 1).')'.'.'.
5873 5873
 								pathinfo($attachments[$num]['name'], PATHINFO_EXTENSION);
5874 5874
 						}
5875 5875
 						$attachments[$num]['type'] = $attachments[$num]['mimeType'];
5876
-						$attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
5877
-						$tmpfile = fopen($attachments[$num]['tmp_name'],'w');
5878
-						fwrite($tmpfile,$attachments[$num]['attachment']);
5876
+						$attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_");
5877
+						$tmpfile = fopen($attachments[$num]['tmp_name'], 'w');
5878
+						fwrite($tmpfile, $attachments[$num]['attachment']);
5879 5879
 						fclose($tmpfile);
5880 5880
 						$file_list[] = $attachments[$num]['name'];
5881 5881
 						unset($attachments[$num]['attachment']);
5882 5882
 					}
5883 5883
 				}
5884
-				if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages);
5884
+				if (is_array($attachedMessages)) $attachments = array_merge($attachments, $attachedMessages);
5885 5885
 			}
5886 5886
 			return array(
5887 5887
 					'mailaddress'=>$mailaddress,
@@ -5903,10 +5903,10 @@  discard block
 block discarded – undo
5903 5903
 	{
5904 5904
 		$c = 0;
5905 5905
 		// use the standardIdentity
5906
-		foreach($_identities as $key => $acc) {
5907
-			if ($c==0) $identity = $acc;
5906
+		foreach ($_identities as $key => $acc) {
5907
+			if ($c == 0) $identity = $acc;
5908 5908
 			//error_log(__METHOD__.__LINE__." $key == $_profile_id ");
5909
-			if ($key==$_profile_id) $identity = $acc;
5909
+			if ($key == $_profile_id) $identity = $acc;
5910 5910
 			$c++;
5911 5911
 		}
5912 5912
 		return $identity;
@@ -5918,29 +5918,29 @@  discard block
 block discarded – undo
5918 5918
 	 * @param bool createHTML do it with HTML breaks
5919 5919
 	 * @return string a preformatted string with the information of the header worked into it
5920 5920
 	 */
5921
-	static function createHeaderInfoSection($header,$headline='', $createHTML = false)
5921
+	static function createHeaderInfoSection($header, $headline = '', $createHTML = false)
5922 5922
 	{
5923 5923
 		$headdata = null;
5924 5924
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace());
5925
-		if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n");
5926
-		if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n");
5927
-		if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n");
5928
-		if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n");
5929
-		if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n");
5930
-		if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n");
5931
-		if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n");
5932
-		if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n");
5933
-		if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n");
5925
+		if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML ? "<br />" : "\n");
5926
+		if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML ? "<br />" : "\n");
5927
+		if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML ? "<br />" : "\n");
5928
+		if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML ? "<br />" : "\n");
5929
+		if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML ? "<br />" : "\n");
5930
+		if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML ? "<br />" : "\n");
5931
+		if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML ? "<br />" : "\n");
5932
+		if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML ? "<br />" : "\n");
5933
+		if ($header['IMPORTANCE'] && $header['IMPORTANCE'] != 'normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML ? "<br />" : "\n");
5934 5934
 		//if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\
5935 5935
 		if (!empty($headdata))
5936 5936
 		{
5937
-			if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
5938
-			if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata;
5939
-			$headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'');
5937
+			if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML ? "<br />" : "\n").$headdata;
5938
+			if (empty($headline)) $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '').$headdata;
5939
+			$headdata .= ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '');
5940 5940
 		}
5941 5941
 		else
5942 5942
 		{
5943
-			$headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'');
5943
+			$headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '');
5944 5944
 		}
5945 5945
 		return $headdata;
5946 5946
 	}
@@ -5953,8 +5953,8 @@  discard block
 block discarded – undo
5953 5953
 	 */
5954 5954
 	static function adaptSubjectForImport($subject)
5955 5955
 	{
5956
-		$subject = str_replace('$$','__',($subject?$subject:lang('(no subject)')));
5957
-		$subject = str_ireplace(array('[FWD]','[',']','{','}','<','>'),array('Fwd:',' ',' ',' ',' ',' ',' '),trim($subject));
5956
+		$subject = str_replace('$$', '__', ($subject ? $subject : lang('(no subject)')));
5957
+		$subject = str_ireplace(array('[FWD]', '[', ']', '{', '}', '<', '>'), array('Fwd:', ' ', ' ', ' ', ' ', ' ', ' '), trim($subject));
5958 5958
 		return $subject;
5959 5959
 	}
5960 5960
 
@@ -5966,15 +5966,15 @@  discard block
 block discarded – undo
5966 5966
 	static function convertAddressArrayToString($rfcAddressArray)
5967 5967
 	{
5968 5968
 		//error_log(__METHOD__.' ('.__LINE__.') '.array2string($rfcAddressArray));
5969
-		$returnAddr ='';
5969
+		$returnAddr = '';
5970 5970
 		if (is_array($rfcAddressArray))
5971 5971
 		{
5972
-			foreach((array)$rfcAddressArray as $addressData) {
5972
+			foreach ((array)$rfcAddressArray as $addressData) {
5973 5973
 				//error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData));
5974
-				if($addressData['MAILBOX_NAME'] == 'NIL') {
5974
+				if ($addressData['MAILBOX_NAME'] == 'NIL') {
5975 5975
 					continue;
5976 5976
 				}
5977
-				if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') {
5977
+				if (strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') {
5978 5978
 					continue;
5979 5979
 				}
5980 5980
 				if ($addressData['RFC822_EMAIL'])
@@ -5983,7 +5983,7 @@  discard block
 block discarded – undo
5983 5983
 				}
5984 5984
 				else
5985 5985
 				{
5986
-					$emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']);
5986
+					$emailaddress = ($addressData['PERSONAL_NAME'] ? $addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>' : $addressData['EMAIL']);
5987 5987
 					$addressObjectA = self::parseAddressList($emailaddress);
5988 5988
 				}
5989 5989
 				$addressObject = $addressObjectA[0];
@@ -5992,10 +5992,10 @@  discard block
 block discarded – undo
5992 5992
 				//$mb =(string)$addressObject->mailbox;
5993 5993
 				//$h = (string)$addressObject->host;
5994 5994
 				//$p = (string)$addressObject->personal;
5995
-				$returnAddr .= (strlen($returnAddr)>0?',':'');
5995
+				$returnAddr .= (strlen($returnAddr) > 0 ? ',' : '');
5996 5996
 				//error_log(__METHOD__.' ('.__LINE__.') '.$p.' <'.$mb.'@'.$h.'>');
5997 5997
 				$buff = imap_rfc822_write_address($addressObject->mailbox, self::$idna2->decode($addressObject->host), $addressObject->personal);
5998
-				$buff = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$buff);
5998
+				$buff = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $buff);
5999 5999
 				//error_log(__METHOD__.' ('.__LINE__.') '.' Address: '.$returnAddr);
6000 6000
 				$returnAddr .= $buff;
6001 6001
 			}
@@ -6003,8 +6003,8 @@  discard block
 block discarded – undo
6003 6003
 		else
6004 6004
 		{
6005 6005
 			// do not mess with strings, return them untouched /* ToDo: validate string as Address */
6006
-			$rfcAddressArray = self::decode_header($rfcAddressArray,true);
6007
-			$rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray);
6006
+			$rfcAddressArray = self::decode_header($rfcAddressArray, true);
6007
+			$rfcAddressArray = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $rfcAddressArray);
6008 6008
 			if (is_string($rfcAddressArray)) return $rfcAddressArray;
6009 6009
 		}
6010 6010
 		return $returnAddr;
@@ -6018,12 +6018,12 @@  discard block
 block discarded – undo
6018 6018
 	 * @param string &$err error-message on error
6019 6019
 	 * @return string/boolean merged content or false on error
6020 6020
 	 */
6021
-	static function merge($content,$ids,$mimetype='')
6021
+	static function merge($content, $ids, $mimetype = '')
6022 6022
 	{
6023 6023
 		$mergeobj = new addressbook_merge();
6024 6024
 
6025
-		if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html');
6026
-		$rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset);
6025
+		if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ? 'text/plain' : 'text/html');
6026
+		$rv = $mergeobj->merge_string($content, $ids, $err = '', $mimetype, array(), self::$displayCharset);
6027 6027
 		if (empty($rv) && !empty($content) && !empty($err)) $rv = $content;
6028 6028
 		if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err));
6029 6029
 		return $rv;
@@ -6065,12 +6065,12 @@  discard block
 block discarded – undo
6065 6065
 		else
6066 6066
 			settype($bytes, 'integer');
6067 6067
 
6068
-		return $bytes . ' ' . $type ;
6068
+		return $bytes.' '.$type;
6069 6069
 	}
6070 6070
 
6071 6071
 	static function detect_qp(&$sting) {
6072 6072
 		$needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/';
6073
-		return preg_match("$needle",$string);
6073
+		return preg_match("$needle", $string);
6074 6074
 	}
6075 6075
 
6076 6076
 	/**
@@ -6083,11 +6083,11 @@  discard block
 block discarded – undo
6083 6083
 	 * @param string $_methodNline - Information where the log was taken
6084 6084
 	 * @return void
6085 6085
 	 */
6086
-	static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='')
6086
+	static function logRunTimes($_starttime, $_endtime = null, $_message = '', $_methodNline = '')
6087 6087
 	{
6088 6088
 		if (is_null($_endtime)) $_endtime = microtime(true);
6089 6089
 		$usagetime = microtime(true) - $_starttime;
6090
-		if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:''));
6090
+		if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime, 5).'(s) '.($_message ? 'Details:'.$_message : ''));
6091 6091
 	}
6092 6092
 
6093 6093
 	/**
@@ -6100,9 +6100,9 @@  discard block
 block discarded – undo
6100 6100
 	 *
6101 6101
 	 * @throws egw_exception_wrong_userinput
6102 6102
 	 */
6103
-	static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822')
6103
+	static function checkFileBasics(&$_formData, $IDtoAddToFileName = '', $reqMimeType = 'message/rfc822')
6104 6104
 	{
6105
-		if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file'];
6105
+		if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'egw-data') return $_formData['file'];
6106 6106
 
6107 6107
 		//error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType);
6108 6108
 		$importfailed = $tmpFileName = false;
@@ -6112,7 +6112,7 @@  discard block
 block discarded – undo
6112 6112
 			$importfailed = true;
6113 6113
 			$alert_msg .= lang("Empty file %1 ignored.", $_formData['name']);
6114 6114
 		}
6115
-		elseif (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) ||
6115
+		elseif (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) ||
6116 6116
 			realpath(dirname($_formData['file'])) == realpath($GLOBALS['egw_info']['server']['temp_dir']))
6117 6117
 		{
6118 6118
 			// ensure existance of eGW temp dir
@@ -6120,7 +6120,7 @@  discard block
 block discarded – undo
6120 6120
 			// and different from any other temp file location set in php.ini
6121 6121
 			if (!file_exists($GLOBALS['egw_info']['server']['temp_dir']))
6122 6122
 			{
6123
-				@mkdir($GLOBALS['egw_info']['server']['temp_dir'],0700);
6123
+				@mkdir($GLOBALS['egw_info']['server']['temp_dir'], 0700);
6124 6124
 			}
6125 6125
 
6126 6126
 			// if we were NOT able to create this temp directory, then make an ERROR report
@@ -6147,14 +6147,14 @@  discard block
 block discarded – undo
6147 6147
 			// maybe its application/octet-stream -> this may mean that we could not determine the type
6148 6148
 			// so we check for the suffix too
6149 6149
 			// trust vfs mime-types, trust the mimetype if it contains a method
6150
-			if ((substr($_formData['file'],0,6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'],'method=')===false)
6150
+			if ((substr($_formData['file'], 0, 6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'], 'method=') === false)
6151 6151
 			{
6152
-				$buff = explode('.',$_formData['name']);
6152
+				$buff = explode('.', $_formData['name']);
6153 6153
 				$suffix = '';
6154 6154
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
6155 6155
 				if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
6156 6156
 				if (!empty($suffix) && !empty($sfxMimeType) &&
6157
-					(strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType)))
6157
+					(strlen(trim($_formData['type'])) == 0 || (strtolower(trim($_formData['type'])) != $sfxMimeType)))
6158 6158
 				{
6159 6159
 					error_log(__METHOD__.' ('.__LINE__.') '.' Data:'.array2string($_formData));
6160 6160
 					error_log(__METHOD__.' ('.__LINE__.') '.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType);
@@ -6169,13 +6169,13 @@  discard block
 block discarded – undo
6169 6169
 			if ($reqMimeType)
6170 6170
 			{
6171 6171
 				// so if PHP did not pass any file_type info, then substitute the rfc default value
6172
-				if (substr(strtolower(trim($_formData['type'])),0,strlen($mime_type_default)) != $mime_type_default)
6172
+				if (substr(strtolower(trim($_formData['type'])), 0, strlen($mime_type_default)) != $mime_type_default)
6173 6173
 				{
6174 6174
 					if (!(strtolower(trim($_formData['type'])) == "application/octet-stream" && $sfxMimeType == $reqMimeType))
6175 6175
 					{
6176 6176
 						//error_log("Message rejected, no message/rfc. Is:".$_formData['type']);
6177 6177
 						$importfailed = true;
6178
-						$alert_msg .= lang("File rejected, no %2. Is:%1",$_formData['type'],$reqMimeType);
6178
+						$alert_msg .= lang("File rejected, no %2. Is:%1", $_formData['type'], $reqMimeType);
6179 6179
 					}
6180 6180
 					if ((strtolower(trim($_formData['type'])) != $reqMimeType && $sfxMimeType == $reqMimeType))
6181 6181
 					{
@@ -6184,17 +6184,17 @@  discard block
 block discarded – undo
6184 6184
 				}
6185 6185
 			}
6186 6186
 			// as FreeBSD seems to have problems with the generated temp names we append some more random stuff
6187
-			$randomString = chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90));
6187
+			$randomString = chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90));
6188 6188
 			$tmpFileName = $GLOBALS['egw_info']['user']['account_id'].
6189 6189
 				trim($IDtoAddToFileName).basename($_formData['file']).'_'.$randomString;
6190 6190
 
6191
-			if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs')
6191
+			if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs')
6192 6192
 			{
6193
-				$tmpFileName = $_formData['file'];	// no need to store it somewhere
6193
+				$tmpFileName = $_formData['file']; // no need to store it somewhere
6194 6194
 			}
6195 6195
 			elseif (is_uploaded_file($_formData['file']))
6196 6196
 			{
6197
-				move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].SEP.$tmpFileName);	// requirement for safe_mode!
6197
+				move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].SEP.$tmpFileName); // requirement for safe_mode!
6198 6198
 			}
6199 6199
 			else
6200 6200
 			{
@@ -6203,7 +6203,7 @@  discard block
 block discarded – undo
6203 6203
 		} else {
6204 6204
 			//error_log("Import of message ".$_formData['file']." failes to meet basic restrictions");
6205 6205
 			$importfailed = true;
6206
-			$alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']);
6206
+			$alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.", $_formData['name']);
6207 6207
 		}
6208 6208
 		if ($importfailed == true)
6209 6209
 		{
@@ -6211,7 +6211,7 @@  discard block
 block discarded – undo
6211 6211
 		}
6212 6212
 		else
6213 6213
 		{
6214
-			if (parse_url($tmpFileName,PHP_URL_SCHEME) == 'vfs')
6214
+			if (parse_url($tmpFileName, PHP_URL_SCHEME) == 'vfs')
6215 6215
 			{
6216 6216
 				egw_vfs::load_wrapper('vfs');
6217 6217
 			}
@@ -6236,7 +6236,7 @@  discard block
 block discarded – undo
6236 6236
 		$images = null;
6237 6237
 		if (preg_match_all("/(src|background)=\"(.*)\"/Ui", $_html2parse, $images) && isset($images[2]))
6238 6238
 		{
6239
-			foreach($images[2] as $i => $url)
6239
+			foreach ($images[2] as $i => $url)
6240 6240
 			{
6241 6241
 				//$isData = false;
6242 6242
 				$basedir = $data = '';
@@ -6248,20 +6248,20 @@  discard block
 block discarded – undo
6248 6248
 					$filename = basename($url);
6249 6249
 					if (($directory = dirname($url)) == '.') $directory = '';
6250 6250
 					$ext = pathinfo($filename, PATHINFO_EXTENSION);
6251
-					$mimeType  = mime_magic::ext2mime($ext);
6252
-					if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
6251
+					$mimeType = mime_magic::ext2mime($ext);
6252
+					if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
6253 6253
 					$myUrl = $directory.$filename;
6254
-					if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs)
6254
+					if ($myUrl[0] == '/') // local path -> we only allow path's that are available via http/https (or vfs)
6255 6255
 					{
6256
-						$basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']);
6256
+						$basedir = ($_SERVER['HTTPS'] ? 'https://' : 'http://'.$_SERVER['HTTP_HOST']);
6257 6257
 					}
6258 6258
 					// use vfs instead of url containing webdav.php
6259 6259
 					// ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign
6260 6260
 					// webdav.php urls as vfs
6261
-					if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it.
6261
+					if (strpos($myUrl, '/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it.
6262 6262
 					{
6263 6263
 						egw_vfs::load_wrapper('vfs');
6264
-						list(,$myUrl) = explode('/webdav.php',$myUrl,2);
6264
+						list(,$myUrl) = explode('/webdav.php', $myUrl, 2);
6265 6265
 						$basedir = 'vfs://default';
6266 6266
 						$needTempFile = false;
6267 6267
 					}
@@ -6274,11 +6274,11 @@  discard block
 block discarded – undo
6274 6274
 						// Strips the url and store it into a temp for further procss
6275 6275
 						$tmp_url = html_entity_decode($myUrl);
6276 6276
 
6277
-						parse_str(parse_url($tmp_url, PHP_URL_QUERY),$URI_params);
6277
+						parse_str(parse_url($tmp_url, PHP_URL_QUERY), $URI_params);
6278 6278
 						if ($URI_params['mailbox'] && $URI_params['uid'] && $URI_params['cid'])
6279 6279
 						{
6280 6280
 							$mail_bo->reopen(base64_decode($URI_params['mailbox']));
6281
-							$attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']),base64_decode($URI_params['partID']),true);
6281
+							$attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']), base64_decode($URI_params['partID']), true);
6282 6282
 							$mail_bo->closeConnection();
6283 6283
 							if ($attachment)
6284 6284
 							{
@@ -6289,32 +6289,32 @@  discard block
 block discarded – undo
6289 6289
 						}
6290 6290
 					}
6291 6291
 
6292
-					if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; }
6293
-					if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl));
6292
+					if (strlen($basedir) > 1 && substr($basedir, -1) != '/' && $myUrl[0] != '/') { $basedir .= '/'; }
6293
+					if ($needTempFile && !$attachment && substr($myUrl, 0, 4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl));
6294 6294
 				}
6295
-				if (substr($url,0,strlen('data:'))=='data:')
6295
+				if (substr($url, 0, strlen('data:')) == 'data:')
6296 6296
 				{
6297 6297
 					//error_log(__METHOD__.' ('.__LINE__.') '.' -> '.$i.': '.array2string($images[$i]));
6298 6298
 					// we only support base64 encoded data
6299
-					$tmp = substr($url,strlen('data:'));
6300
-					list($mimeType,$data_base64) = explode(';base64,',$tmp);
6299
+					$tmp = substr($url, strlen('data:'));
6300
+					list($mimeType, $data_base64) = explode(';base64,', $tmp);
6301 6301
 					$data = base64_decode($data_base64);
6302 6302
 					// FF currently does NOT add any mime-type
6303 6303
 					if (strtolower(substr($mimeType, 0, 6)) != 'image/')
6304 6304
 					{
6305 6305
 						$mimeType = mime_magic::analyze_data($data);
6306 6306
 					}
6307
-					list($what,$exactly) = explode('/',$mimeType);
6307
+					list($what, $exactly) = explode('/', $mimeType);
6308 6308
 					$needTempFile = true;
6309
-					$filename = ($what?$what:'data').$imageC++.'.'.$exactly;
6309
+					$filename = ($what ? $what : 'data').$imageC++.'.'.$exactly;
6310 6310
 				}
6311 6311
 				if ($data || $needTempFile === false)
6312 6312
 				{
6313 6313
 					if ($needTempFile)
6314 6314
 					{
6315
-						$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
6316
-						$tmpfile = fopen($attachment_file,'w');
6317
-						fwrite($tmpfile,$data);
6315
+						$attachment_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_");
6316
+						$tmpfile = fopen($attachment_file, 'w');
6317
+						fwrite($tmpfile, $data);
6318 6318
 						fclose($tmpfile);
6319 6319
 					}
6320 6320
 					else
@@ -6325,7 +6325,7 @@  discard block
 block discarded – undo
6325 6325
 					// (or similar) in all cases (when cut&paste). This may lead to more attached files, in case
6326 6326
 					// we use the same image multiple times, but, if we do this, we should try to detect that
6327 6327
 					// on upload. filename itself is not sufficient to determine the sameness of images
6328
-					$cid = 'cid:' . md5($attachment_file);
6328
+					$cid = 'cid:'.md5($attachment_file);
6329 6329
 					if ($_mailObject->AddEmbeddedImage($attachment_file, substr($cid, 4), $filename, $mimeType) !== null)
6330 6330
 					{
6331 6331
 						//$_html2parse = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $_html2parse);
@@ -6347,14 +6347,14 @@  discard block
 block discarded – undo
6347 6347
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
6348 6348
 	 * @return mixed array of messages with success and failed messages or exception
6349 6349
 	 */
6350
-	function importMessageToMergeAndSend(bo_merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID='')
6350
+	function importMessageToMergeAndSend(bo_merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID = '')
6351 6351
 	{
6352 6352
 		$importfailed = false;
6353
-		$processStats = array('success'=>array(),'failed'=>array());
6353
+		$processStats = array('success'=>array(), 'failed'=>array());
6354 6354
 		if (empty($SendAndMergeTocontacts))
6355 6355
 		{
6356 6356
 			$importfailed = true;
6357
-			$alert_msg .= lang("Import of message %1 failed. No Contacts to merge and send to specified.",$_formData['name']);
6357
+			$alert_msg .= lang("Import of message %1 failed. No Contacts to merge and send to specified.", $_formData['name']);
6358 6358
 		}
6359 6359
 
6360 6360
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
@@ -6391,7 +6391,7 @@  discard block
 block discarded – undo
6391 6391
 				$_folder = $this->getSentFolder();
6392 6392
 			}
6393 6393
 			$delimiter = $this->getHierarchyDelimiter();
6394
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
6394
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
6395 6395
 			if ($importfailed === false)
6396 6396
 			{
6397 6397
 				$Subject = $mailObject->getHeader('Subject');
@@ -6409,9 +6409,9 @@  discard block
 block discarded – undo
6409 6409
 				{
6410 6410
 					$mailObject->clearReplyTos();
6411 6411
 					$activeMailProfiles = $this->mail->getAccountIdentities($this->profileID);
6412
-					$activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID);
6412
+					$activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID);
6413 6413
 
6414
-					$mailObject->addReplyTo(self::$idna2->encode($activeMailProfile['ident_email']),emailadmin_imapbase::generateIdentityString($activeMailProfile,false));
6414
+					$mailObject->addReplyTo(self::$idna2->encode($activeMailProfile['ident_email']), emailadmin_imapbase::generateIdentityString($activeMailProfile, false));
6415 6415
 				}
6416 6416
 				foreach ($SendAndMergeTocontacts as $k => $val)
6417 6417
 				{
@@ -6425,12 +6425,12 @@  discard block
 block discarded – undo
6425 6425
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject));
6426 6426
 
6427 6427
 						// Parse destinations for placeholders
6428
-						foreach(egw_mailer::$type2header as $type => $h)
6428
+						foreach (egw_mailer::$type2header as $type => $h)
6429 6429
 						{
6430 6430
 							//error_log('ID ' . $val . ' ' .$type . ': ' . $mailObject->getHeader(egw_mailer::$type2header[$type]) . ' -> ' .$bo_merge->merge_string($mailObject->getHeader(egw_mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset));
6431
-							$merged = $bo_merge->merge_string($mailObject->getHeader(egw_mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset);
6432
-							$mailObject->addAddress($merged,'',$type);
6433
-							if($type == 'to')
6431
+							$merged = $bo_merge->merge_string($mailObject->getHeader(egw_mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset);
6432
+							$mailObject->addAddress($merged, '', $type);
6433
+							if ($type == 'to')
6434 6434
 							{
6435 6435
 								$email = $merged;
6436 6436
 							}
@@ -6443,26 +6443,26 @@  discard block
 block discarded – undo
6443 6443
 							//error_log(__METHOD__.' ('.__LINE__.') '.' ID:'.$val.' Data:'.array2string($contact));
6444 6444
 							$email = ($contact['email'] ? $contact['email'] : $contact['email_home']);
6445 6445
 							$nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']);
6446
-							if($email)
6446
+							if ($email)
6447 6447
 							{
6448
-								$mailObject->addAddress(self::$idna2->encode($email),$mailObject->EncodeHeader($nfn));
6448
+								$mailObject->addAddress(self::$idna2->encode($email), $mailObject->EncodeHeader($nfn));
6449 6449
 							}
6450 6450
 						}
6451 6451
 
6452 6452
 						$activeMailProfiles = $this->getAccountIdentities($this->profileID);
6453
-						$activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID);
6453
+						$activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID);
6454 6454
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($activeMailProfile));
6455 6455
 						$mailObject->setFrom($activeMailProfile['ident_email'],
6456
-							self::generateIdentityString($activeMailProfile,false));
6456
+							self::generateIdentityString($activeMailProfile, false));
6457 6457
 
6458 6458
 						$mailObject->removeHeader('Message-ID');
6459 6459
 						$mailObject->removeHeader('Date');
6460 6460
 						$mailObject->clearCustomHeaders();
6461 6461
 						$mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset));
6462 6462
 						//error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType);
6463
-						if($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6463
+						if ($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6464 6464
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e));
6465
-						if($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6465
+						if ($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6466 6466
 
6467 6467
 						//error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject));
6468 6468
 						// set a higher timeout for big messages
@@ -6471,7 +6471,7 @@  discard block
 block discarded – undo
6471 6471
 						try {
6472 6472
 							$mailObject->send();
6473 6473
 						}
6474
-						catch(Exception $e) {
6474
+						catch (Exception $e) {
6475 6475
 							$sendOK = false;
6476 6476
 							$errorInfo = $e->getMessage();
6477 6477
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo));
@@ -6485,42 +6485,42 @@  discard block
 block discarded – undo
6485 6485
 						$mailObject->clearCustomHeaders();
6486 6486
 
6487 6487
 						// Parse destinations for placeholders
6488
-						foreach(egw_mailer::$type2header as $type => $h)
6488
+						foreach (egw_mailer::$type2header as $type => $h)
6489 6489
 						{
6490 6490
 							// Parse destinations for placeholders
6491
-							$merged = $bo_merge->merge_string($mailObject->getHeader(egw_mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset);
6491
+							$merged = $bo_merge->merge_string($mailObject->getHeader(egw_mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset);
6492 6492
 							//error_log($type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$merged);
6493
-							$mailObject->addAddress(trim($merged,'"'),'',$type);
6493
+							$mailObject->addAddress(trim($merged, '"'), '', $type);
6494 6494
 						}
6495 6495
 
6496 6496
 						// No addresses from placeholders?  Treat it as just a contact ID
6497
-						if (count($mailObject->getAddresses('to',true)) == 0 &&
6497
+						if (count($mailObject->getAddresses('to', true)) == 0 &&
6498 6498
 							is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge
6499 6499
 						{
6500 6500
 							$contact = $bo_merge->contacts->read($val);
6501 6501
 							//error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact));
6502 6502
 							$email = ($contact['email'] ? $contact['email'] : $contact['email_home']);
6503 6503
 							$nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']);
6504
-							if($email)
6504
+							if ($email)
6505 6505
 							{
6506
-								$mailObject->addAddress(self::$idna2->encode($email),$mailObject->EncodeHeader($nfn));
6506
+								$mailObject->addAddress(self::$idna2->encode($email), $mailObject->EncodeHeader($nfn));
6507 6507
 							}
6508 6508
 						}
6509 6509
 						$mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset));
6510 6510
 						//error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType);
6511
-						if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6511
+						if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6512 6512
 						//error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e));
6513
-						if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6513
+						if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
6514 6514
 						$_folder = $this->getDraftFolder();
6515 6515
 					}
6516 6516
 					if ($sendOK || $openAsDraft)
6517 6517
 					{
6518
-						if ($this->folderExists($_folder,true))
6518
+						if ($this->folderExists($_folder, true))
6519 6519
 						{
6520
-						    if($this->isSentFolder($_folder))
6520
+						    if ($this->isSentFolder($_folder))
6521 6521
 							{
6522 6522
 						        $flags = '\\Seen';
6523
-						    } elseif($this->isDraftFolder($_folder)) {
6523
+						    } elseif ($this->isDraftFolder($_folder)) {
6524 6524
 						        $flags = '\\Draft';
6525 6525
 						    } else {
6526 6526
 						        $flags = '';
@@ -6528,7 +6528,7 @@  discard block
 block discarded – undo
6528 6528
 							$savefailed = false;
6529 6529
 							try
6530 6530
 							{
6531
-								$messageUid =$this->appendMessage($_folder,
6531
+								$messageUid = $this->appendMessage($_folder,
6532 6532
 									$mailObject->getRaw(),
6533 6533
 									null,
6534 6534
 									$flags);
@@ -6536,10 +6536,10 @@  discard block
 block discarded – undo
6536 6536
 							catch (egw_exception_wrong_userinput $e)
6537 6537
 							{
6538 6538
 								$savefailed = true;
6539
-								$alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage());
6539
+								$alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", $Subject, $_folder, $e->getMessage());
6540 6540
 							}
6541 6541
 							// no send, save successful, and message_uid present
6542
-							if ($savefailed===false && $messageUid && is_null($sendOK))
6542
+							if ($savefailed === false && $messageUid && is_null($sendOK))
6543 6543
 							{
6544 6544
 								$importID = $messageUid;
6545 6545
 								$openComposeWindow = true;
@@ -6548,20 +6548,20 @@  discard block
 block discarded – undo
6548 6548
 						else
6549 6549
 						{
6550 6550
 							$savefailed = true;
6551
-							$alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.",$Subject,$_folder);
6551
+							$alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.", $Subject, $_folder);
6552 6552
 						}
6553 6553
 						if ($sendOK)
6554 6554
 						{
6555
-							$processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed?' but failed to store to Folder:'.$_folder:'');
6555
+							$processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed ? ' but failed to store to Folder:'.$_folder : '');
6556 6556
 						}
6557 6557
 						else
6558 6558
 						{
6559
-							if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
6559
+							if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
6560 6560
 						}
6561 6561
 					}
6562
-					if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow))
6562
+					if (!is_null($sendOK) && $sendOK === false && is_null($openComposeWindow))
6563 6563
 					{
6564
-						$processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
6564
+						$processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
6565 6565
 					}
6566 6566
 				}
6567 6567
 			}
@@ -6631,19 +6631,18 @@  discard block
 block discarded – undo
6631 6631
 			//error_log(__METHOD__.__LINE__.':'.array2string($structure));
6632 6632
 
6633 6633
 			// unfortunately parseMessage does NOT return parsed headers (we assume header is shorter then 8k)
6634
-			$start = is_string($message) ? substr($message, 0, 8192) :
6635
-				(fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192));
6634
+			$start = is_string($message) ? substr($message, 0, 8192) : (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192));
6636 6635
 
6637 6636
 			$length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL);
6638
-			if ($length===false) $length = strlen($start);
6639
-			$headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length));
6637
+			if ($length === false) $length = strlen($start);
6638
+			$headers = Horde_Mime_Headers::parseHeaders(substr($start, 0, $length));
6640 6639
 
6641
-			foreach($headers->toArray(array('nowrap' => true)) as $header => $value)
6640
+			foreach ($headers->toArray(array('nowrap' => true)) as $header => $value)
6642 6641
 			{
6643
-				foreach((array)$value as $n => $val)
6642
+				foreach ((array)$value as $n => $val)
6644 6643
 				{
6645 6644
 					$overwrite = !$n;
6646
-					switch($header)
6645
+					switch ($header)
6647 6646
 					{
6648 6647
 						case 'Content-Transfer-Encoding':
6649 6648
 							//as we parse the message and this sets the part with a Content-Transfer-Encoding, we
@@ -6664,7 +6663,7 @@  discard block
 block discarded – undo
6664 6663
 		}
6665 6664
 		else
6666 6665
 		{
6667
-			if (($type = gettype($message)) == 'object') $type = get_class ($message);
6666
+			if (($type = gettype($message)) == 'object') $type = get_class($message);
6668 6667
 			throw new egw_exception_wrong_parameter('Wrong parameter type for message: '.$type);
6669 6668
 		}
6670 6669
 	}
@@ -6678,50 +6677,50 @@  discard block
 block discarded – undo
6678 6677
 	 * @param string $default_domain
6679 6678
 	 * @return Horde_Mail_Rfc822_List iteratable Horde_Mail_Rfc822_Address objects with attributes mailbox, host, personal and valid
6680 6679
 	 */
6681
-	public static function parseAddressList($addresses, $default_domain=null)
6680
+	public static function parseAddressList($addresses, $default_domain = null)
6682 6681
 	{
6683 6682
 		$rfc822 = new Horde_Mail_Rfc822();
6684 6683
 		$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
6685 6684
 		//error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count.function_backtrace());
6686
-		if ((empty($ret) || $ret->count()==0)&& is_string($addresses) && strlen($addresses)>0)
6685
+		if ((empty($ret) || $ret->count() == 0) && is_string($addresses) && strlen($addresses) > 0)
6687 6686
 		{
6688 6687
 			$matches = array();
6689
-			preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches);
6688
+			preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/", $addresses, $matches);
6690 6689
 			//error_log(__METHOD__.__LINE__.array2string($matches));
6691
-			foreach ($matches[0] as &$match) {$match = trim($match,', ');}
6692
-			$addresses = implode(',',$matches[0]);
6690
+			foreach ($matches[0] as &$match) {$match = trim($match, ', '); }
6691
+			$addresses = implode(',', $matches[0]);
6693 6692
 			//error_log(__METHOD__.__LINE__.array2string($addresses));
6694 6693
 			$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
6695 6694
 			//error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count);
6696 6695
 		}
6697
-		$previousFailed=false;
6696
+		$previousFailed = false;
6698 6697
 		$ret2 = new Horde_Mail_Rfc822_List();
6699 6698
 		// handle known problems on emailaddresses
6700
-		foreach($ret as $i => $adr)
6699
+		foreach ($ret as $i => $adr)
6701 6700
 		{
6702 6701
 			//mailaddresses enclosed in single quotes like '[email protected]' show up as 'me as mailbox and you.com' as host
6703
-			if ($adr->mailbox && stripos($adr->mailbox,"'")== 0 &&
6704
-					$adr->host && stripos($adr->host,"'")== (strlen($adr->host) -1))
6702
+			if ($adr->mailbox && stripos($adr->mailbox, "'") == 0 &&
6703
+					$adr->host && stripos($adr->host, "'") == (strlen($adr->host) - 1))
6705 6704
 			{
6706
-				$adr->mailbox = str_replace("'","",$adr->mailbox);
6707
-				$adr->host = str_replace("'","",$adr->host);
6705
+				$adr->mailbox = str_replace("'", "", $adr->mailbox);
6706
+				$adr->host = str_replace("'", "", $adr->host);
6708 6707
 			}
6709 6708
 			// no mailbox or host part as 'Xr\xc3\xa4hlyz, User <[email protected]>' is parsed as 2 addresses separated by ','
6710 6709
 			//#'Xr\xc3\xa4hlyz, User <[email protected]>'
6711 6710
 			//#Horde_Mail_Rfc822_List Object([_data:protected] => Array(
6712 6711
 			//[0] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => Xr\xc3\xa4hlyz[_host:protected] => [_personal:protected] => )
6713 6712
 			//[1] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => mailboxpart1.mailboxpart2[_host:protected] => youthost.com[_personal:protected] => User))[_filter:protected] => Array()[_ptr:protected] => )#2#,
6714
-			if (strlen($adr->mailbox)==0||strlen($adr->host)==0)
6713
+			if (strlen($adr->mailbox) == 0 || strlen($adr->host) == 0)
6715 6714
 			{
6716
-				$remember = ($adr->mailbox?$adr->mailbox:($adr->host?$adr->host:''));
6717
-				$previousFailed=true;
6715
+				$remember = ($adr->mailbox ? $adr->mailbox : ($adr->host ? $adr->host : ''));
6716
+				$previousFailed = true;
6718 6717
 				//error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal");
6719 6718
 			}
6720 6719
 			else
6721 6720
 			{
6722
-				if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal;
6721
+				if ($previousFailed && $remember) $adr->personal = $remember.' '.$adr->personal;
6723 6722
 				$remember = '';
6724
-				$previousFailed=false;
6723
+				$previousFailed = false;
6725 6724
 				//error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal");
6726 6725
 				$ret2->add($adr);
6727 6726
 			}
@@ -6737,7 +6736,7 @@  discard block
 block discarded – undo
6737 6736
 	 * @param string $_folder
6738 6737
 	 * @return boolean
6739 6738
 	 */
6740
-	function sendMDN($uid,$_folder)
6739
+	function sendMDN($uid, $_folder)
6741 6740
 	{
6742 6741
 		$acc = emailadmin_account::read($this->profileID);
6743 6742
 		$identity = emailadmin_account::read_identity($acc['ident_id'], true, null, $acc);
@@ -6767,7 +6766,7 @@  discard block
 block discarded – undo
6767 6766
 	 */
6768 6767
 	function addAccount($_hookValues)
6769 6768
 	{
6770
-		error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues);
6769
+		error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues);
6771 6770
 
6772 6771
 	}
6773 6772
 
@@ -6781,7 +6780,7 @@  discard block
 block discarded – undo
6781 6780
 	 */
6782 6781
 	function deleteAccount($_hookValues)
6783 6782
 	{
6784
-		error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues);
6783
+		error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues);
6785 6784
 
6786 6785
 	}
6787 6786
 
@@ -6795,7 +6794,7 @@  discard block
 block discarded – undo
6795 6794
 	 */
6796 6795
 	function updateAccount($_hookValues)
6797 6796
 	{
6798
-		error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues);
6797
+		error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues);
6799 6798
 
6800 6799
 	}
6801 6800
 }
Please login to merge, or discard this patch.