Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
mail/inc/class.mail_sieve.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1278,7 +1278,7 @@
 block discarded – undo
1278 1278
 	 * int $_searchStringLength
1279 1279
 	 * @param boolean $_returnList
1280 1280
 	 * @param int $_mailaccountToSearch
1281
-	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1281
+	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283 1283
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1284
 	{
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277 277
 			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
278
-            $error = 0;
278
+			$error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 	/**
1203 1203
 	 *
1204 1204
 	 * Get the data for iterating the rows on rules list grid
1205
- 	 *
1205
+	 *
1206 1206
 	 * @return {boolean|array} Array of rows | false if failed
1207 1207
 	 */
1208 1208
 	function get_rows()
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
1224 1224
 				}
1225
-            }
1225
+			}
1226 1226
 		}
1227 1227
 		else
1228 1228
 		{
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 				'caption' => 'Edit',
1248 1248
 				'default' => true,
1249 1249
 				'onExecute' => 'javaScript:app.mail.action',
1250
-                'disableClass' => 'th'
1250
+				'disableClass' => 'th'
1251 1251
 			),
1252 1252
 			'add' => array(
1253 1253
 				'caption' => 'Add',
@@ -1257,13 +1257,13 @@  discard block
 block discarded – undo
1257 1257
 				'caption' => 'Enable',
1258 1258
 				'onExecute' => 'javaScript:app.mail.action',
1259 1259
 				'enableClass' => 'mail_sieve_DISABLED',
1260
-                'hideOnDisabled' => true
1260
+				'hideOnDisabled' => true
1261 1261
 			),
1262 1262
 			'disable' => array(
1263 1263
 				'caption' => 'Disable',
1264 1264
 				'onExecute' => 'javaScript:app.mail.action',
1265 1265
 				'disableClass' => 'mail_sieve_DISABLED',
1266
-                'hideOnDisabled' => true
1266
+				'hideOnDisabled' => true
1267 1267
 			),
1268 1268
 			'delete' => array(
1269 1269
 				'caption' => 'Delete',
Please login to merge, or discard this patch.
Braces   +39 added lines, -11 removed lines patch added patch discarded remove patch
@@ -305,11 +305,21 @@  discard block
 block discarded – undo
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307 307
 						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
308
+						if( $newRule['continue'] )
309
+						{
310
+$newRule['flg'] += 1; }
311
+						if( $newRule['gthan'] )
312
+						{
313
+$newRule['flg'] += 2; }
314
+						if( $newRule['anyof'] )
315
+						{
316
+$newRule['flg'] += 4; }
317
+						if( $newRule['keep'] )
318
+						{
319
+$newRule['flg'] += 8; }
320
+						if( $newRule['regexp'] )
321
+						{
322
+$newRule['flg'] += 128; }
313 323
 
314 324
 						if($newRule['action'] && $this->rulesByID['priority'])
315 325
 						{
@@ -443,7 +453,10 @@  discard block
 block discarded – undo
443 453
 		{
444 454
 			Framework::window_close(lang($e->getMessage()));
445 455
 		}
446
-		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
456
+		if (is_null($accountID))
457
+		{
458
+			$accountID = $GLOBALS['egw_info']['user']['account_id'];
459
+		}
447 460
 
448 461
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
449 462
 		$allAliases = array($this->account->ident_email);
@@ -473,7 +486,10 @@  discard block
 block discarded – undo
473 486
 		$vtmpl = new Etemplate('mail.sieve.vacation');
474 487
 		$vacation = array();
475 488
 
476
-		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
489
+		if (isset($_GET['account_id']))
490
+		{
491
+			$account_id = $preserv['account_id'] = $_GET['account_id'];
492
+		}
477 493
 
478 494
 		if (isset($content['account_id']))
479 495
 		{
@@ -543,7 +559,10 @@  discard block
 block discarded – undo
543 559
 				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
544 560
 				{
545 561
 					$content = $vacation = $vacRules['vacation'];
546
-					if (!empty($profileID)) $content['acc_id'] = $profileID;
562
+					if (!empty($profileID))
563
+					{
564
+						$content['acc_id'] = $profileID;
565
+					}
547 566
 					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
548 567
 					{
549 568
 						$content['addresses'] = $vacRules['aliases'];
@@ -556,7 +575,10 @@  discard block
 block discarded – undo
556 575
 					{
557 576
 						$content['forwards'] = '';
558 577
 					}
559
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
578
+					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text'])
579
+					{
580
+						$content['text'] = $this->mailConfig['default_vacation_text'];
581
+					}
560 582
 					if (strlen(trim($content['text']))==0)
561 583
 					{
562 584
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
@@ -746,7 +768,10 @@  discard block
 block discarded – undo
746 768
 		}
747 769
 		// setting up an async job to enable/disable the vacation message
748 770
 		$async = new Api\Asyncservice();
749
-		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
771
+		if (empty($_vacation['account_id']))
772
+		{
773
+			$_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
774
+		}
750 775
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
751 776
 		$async->delete($async_id);
752 777
 
@@ -1283,7 +1308,10 @@  discard block
 block discarded – undo
1283 1308
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1309
 	{
1285 1310
 		$mailCompose = new mail_compose();
1286
-		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
1311
+		if ($_REQUEST['noPrefixId'])
1312
+		{
1313
+			$_noPrefixId = $_REQUEST['noPrefixId'];
1314
+		}
1287 1315
 		$mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId);
1288 1316
 	}
1289 1317
 }
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		if ($acc_id > 0)
75 75
 		{
76 76
 			$this->account = Mail\Account::read($acc_id);
77
-			$identity = Mail\Account::read_identity($this->account->ident_id,true);
78
-			$this->currentIdentity = Mail::generateIdentityString($identity,false);
77
+			$identity = Mail\Account::read_identity($this->account->ident_id, true);
78
+			$this->currentIdentity = Mail::generateIdentityString($identity, false);
79 79
 		}
80 80
 
81 81
 		$this->restoreSessionData();
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param {array} $content
88 88
 	 * @param {string} $msg
89 89
 	 */
90
-	function index(array $content=null,$msg=null)
90
+	function index(array $content = null, $msg = null)
91 91
 	{
92 92
 		if (!is_array($content))
93 93
 		{
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 		if ($this->account->acc_sieve_enabled)
105 105
 		{
106 106
 			//Initializes the Grid contents
107
-			$content['rg']= $this->get_rows();
107
+			$content['rg'] = $this->get_rows();
108 108
 
109 109
 			// Set content-menu actions
110
-			$tmpl->setElementAttribute('rg', 'actions',$this->get_actions());
110
+			$tmpl->setElementAttribute('rg', 'actions', $this->get_actions());
111 111
 
112 112
 			$sel_options = array(
113 113
 				'status' => array(
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 		}
119 119
 		else
120 120
 		{
121
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
122
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
121
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
122
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
123 123
 		}
124
-		$tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array());
124
+		$tmpl->exec('mail.mail_sieve.index', $content, $sel_options, array());
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param {array} $content
132 132
 	 * @param {string} $msg
133 133
 	 */
134
-	function editEmailNotification($content=null, $msg='')
134
+	function editEmailNotification($content = null, $msg = '')
135 135
 	{
136 136
 		//Instantiate an eTemplate object, representing sieve.emailNotification
137 137
 		$eNotitmpl = new Etemplate('mail.sieve.emailNotification');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 				if (!empty($eNotification['externalEmail']))
148 148
 				{
149
-					$content['externalEmail'] = explode(",",$eNotification['externalEmail']);
149
+					$content['externalEmail'] = explode(",", $eNotification['externalEmail']);
150 150
 				}
151 151
 			}
152 152
 			else
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 				list($button) = @each($content['button']);
156 156
 				unset ($content['button']);
157 157
 
158
-				switch($button)
158
+				switch ($button)
159 159
 				{
160 160
 					case 'save':
161 161
 					case 'apply':
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 						{
164 164
 							$newEmailNotification = $content;
165 165
 							if (empty($this->mailConfig['prefpreventforwarding']) ||
166
-								$this->mailConfig['prefpreventforwarding'] == 0 )
166
+								$this->mailConfig['prefpreventforwarding'] == 0)
167 167
 							{
168 168
 								if (is_array($content['externalEmail']) && !empty($content['externalEmail']))
169 169
 								{
170
-									$newEmailNotification['externalEmail'] = implode(",",$content['externalEmail']);
170
+									$newEmailNotification['externalEmail'] = implode(",", $content['externalEmail']);
171 171
 								}
172 172
 							}
173 173
 						}
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 		else
217 217
 		{
218
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
219
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
218
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
219
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
220 220
 		}
221
-		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options);
221
+		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content, $sel_options);
222 222
 	}
223 223
 
224 224
 	/**
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param {array} $content
228 228
 	 */
229
-	function edit ($content=null)
229
+	function edit($content = null)
230 230
 	{
231 231
 		//Instantiate an eTemplate object, representing sieve.edit template
232 232
 		$etmpl = new Etemplate('mail.sieve.edit');
233
-		$etmpl->setElementAttribute('action_folder_text','autocomplete_params', array('noPrefixId'=> true));
233
+		$etmpl->setElementAttribute('action_folder_text', 'autocomplete_params', array('noPrefixId'=> true));
234 234
 		if (!is_array($content))
235 235
 		{
236
-			if ( $this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
236
+			if ($this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
237 237
 			{
238 238
 
239 239
 				$rules = $this->rulesByID;
240
-				$content= $rules;
240
+				$content = $rules;
241 241
 				$content ['ruleID'] = $_GET['ruleID'];
242 242
 				switch ($rules['action'])
243 243
 				{
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			{
258 258
 
259 259
 				$this->getRules(null);
260
-				$newRulePriority = count($this->rules)*2+1;
260
+				$newRulePriority = count($this->rules) * 2 + 1;
261 261
 				$newRules ['priority'] = $newRulePriority;
262 262
 				$newRules ['status'] = 'ENABLED';
263 263
 				$readonlys = array(
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
 			list($button) = @each($content['button']);
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277
-			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
277
+			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] - 1) / 2;
278 278
             $error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
282 282
 				case 'apply':
283
-					if($content)
283
+					if ($content)
284 284
 					{
285 285
 						unset($content['button']);
286 286
 
287 287
 						$newRule = $content;
288
-						$newRule['priority']	= $this->rulesByID['priority'];
289
-						$newRule['status']	= $this->rulesByID['status'];
288
+						$newRule['priority'] = $this->rulesByID['priority'];
289
+						$newRule['status'] = $this->rulesByID['status'];
290 290
 
291 291
 						switch ($content['action'])
292 292
 						{
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 						unset($newRule['action_address_text']);
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307
-						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
307
+						$newRule['flg'] = 0;
308
+						if ($newRule['continue']) { $newRule['flg'] += 1; }
309
+						if ($newRule['gthan']) { $newRule['flg'] += 2; }
310
+						if ($newRule['anyof']) { $newRule['flg'] += 4; }
311
+						if ($newRule['keep']) { $newRule['flg'] += 8; }
312
+						if ($newRule['regexp']) { $newRule['flg'] += 128; }
313 313
 
314
-						if($newRule['action'] && $this->rulesByID['priority'])
314
+						if ($newRule['action'] && $this->rulesByID['priority'])
315 315
 						{
316 316
 							$this->rules[$ruleID] = $newRule;
317 317
 							$ret = $this->account->imapServer()->setRules($this->rules);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 							}
322 322
 							else
323 323
 							{
324
-								$msg .= lang("The rule with priority %1 successfully saved!",$ruleID);
324
+								$msg .= lang("The rule with priority %1 successfully saved!", $ruleID);
325 325
 							}
326 326
 							$this->saveSessionData();
327 327
 						}
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 				case 'delete':
347 347
 					if ($button == "delete")
348 348
 					{
349
-						if ($ruleID === count($this->rules)-1)
349
+						if ($ruleID === count($this->rules) - 1)
350 350
 						{
351
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!');
351
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!');
352 352
 						}
353 353
 						else
354 354
 						{
355 355
 
356
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$ruleID+1,$ruleID);
356
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $ruleID + 1, $ruleID);
357 357
 						}
358 358
 						unset($this->rules[$ruleID]);
359 359
 						$this->rules = array_values($this->rules);
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 		);
385 385
 
386 386
 		//Set the preselect_options for mail/folders as we are not allow free entry for folder taglist
387
-		$sel_options['action_folder_text'] = $this->ajax_getFolders(0,true,null,true);
387
+		$sel_options['action_folder_text'] = $this->ajax_getFolders(0, true, null, true);
388 388
 
389
-		return $etmpl->exec('mail.mail_sieve.edit',$content,$sel_options,$readonlys,array(),2);
389
+		return $etmpl->exec('mail.mail_sieve.edit', $content, $sel_options, $readonlys, array(), 2);
390 390
 	}
391 391
 
392 392
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	function getEmailNotification()
400 400
 	{
401
-		if(!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
401
+		if (!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
402 402
 		{
403 403
 			throw new Api\Exception\NoPermission();
404 404
 		}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$emailNotification = $this->account->imapServer()->getEmailNotification();
408 408
 		}
409
-		catch(Exception $e) {
409
+		catch (Exception $e) {
410 410
 			unset($e);
411 411
 			$emailNotification = array();
412 412
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	function getVacation($accountID = null)
424 424
 	{
425
-		if(!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
425
+		if (!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
426 426
 		{
427 427
 			throw new Api\Exception\NoPermission();
428 428
 		}
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 				$vacation = $icServer->getVacation();
440 440
 			}
441 441
 		}
442
-		catch(Exception $e)
442
+		catch (Exception $e)
443 443
 		{
444 444
 			Framework::window_close(lang($e->getMessage()));
445 445
 		}
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 		$allAliases = array($this->account->ident_email);
450 450
 		foreach ($accAllIdentities as &$arrVal)
451 451
 		{
452
-			if ($arrVal['type'] !='default')
452
+			if ($arrVal['type'] != 'default')
453 453
 			{
454
-				$allAliases[] =  $arrVal['address'];
454
+				$allAliases[] = $arrVal['address'];
455 455
 			}
456 456
 		}
457 457
 		asort($allAliases);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @param {array} $content
468 468
 	 * @param {string} $msg
469 469
 	 */
470
-	function editVacation($content=null, $msg='')
470
+	function editVacation($content = null, $msg = '')
471 471
 	{
472 472
 		//Instantiate an eTemplate object, representing the sieve.vacation template
473 473
 		$vtmpl = new Etemplate('mail.sieve.vacation');
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 			$account_id = $content['account_id'];
481 481
 			$preserv['acc_id'] = $content['acc_id'];
482 482
 		}
483
-		if(isset($account_id) && $this->mail_admin)
483
+		if (isset($account_id) && $this->mail_admin)
484 484
 		{
485
-			foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account)
485
+			foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account)
486 486
 			{
487 487
 				try {
488 488
 					// check if account is valid for multiple users, has admin credentials and sieve enabled
489 489
 					if (Mail\Account::is_multiple($account) &&
490
-						($icServer = $account->imapServer(true)) &&	// check on icServer object, so plugins can overwrite
490
+						($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite
491 491
 						$icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled)
492 492
 					{
493 493
 						$allAccounts[$account->acc_id] = $account->acc_name;
494 494
 						$accounts[$account->acc_id] = $account;
495 495
 					}
496 496
 				}
497
-				catch(Exception $e) {
497
+				catch (Exception $e) {
498 498
 					unset($e);
499 499
 					// ignore broken accounts
500 500
 				}
501 501
 			}
502 502
 
503
-			$profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id'];
503
+			$profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id'];
504 504
 			if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']]))
505 505
 			{
506 506
 				$profileID = $content['acc_id'] = (int)$_GET['acc_id'];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$this->is_admin_vac = true;
513 513
 			$preserv['account_id'] = $account_id;
514 514
 		}
515
-		elseif(!is_array($content) && isset($_GET['acc_id']))
515
+		elseif (!is_array($content) && isset($_GET['acc_id']))
516 516
 		{
517 517
 			$this->account = Mail\Account::read($_GET['acc_id']);
518 518
 			$preserv['acc_id'] = $this->account->acc_id;
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
 		if ($icServer->acc_sieve_enabled)
529 529
 		{
530 530
 			$vacRules = $this->getVacation($account_id);
531
-			if ($vacRules['vacation']===false)
531
+			if ($vacRules['vacation'] === false)
532 532
 			{
533 533
 				$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
534
-					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
535
-				$content['hideIfSieveDisabled']='mail_DisplayNone';
534
+					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
535
+				$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
536 536
 			}
537 537
 			else
538 538
 			{
@@ -540,24 +540,24 @@  discard block
 block discarded – undo
540 540
 				{
541 541
 					$ByDate = array('by_date' => lang('By date'));
542 542
 				}
543
-				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
543
+				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date'))))
544 544
 				{
545 545
 					$content = $vacation = $vacRules['vacation'];
546 546
 					if (!empty($profileID)) $content['acc_id'] = $profileID;
547
-					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
547
+					if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '')
548 548
 					{
549 549
 						$content['addresses'] = $vacRules['aliases'];
550 550
 					}
551 551
 					if (!empty($vacation['forwards']))
552 552
 					{
553
-						$content['forwards'] = explode(",",$vacation['forwards']);
553
+						$content['forwards'] = explode(",", $vacation['forwards']);
554 554
 					}
555 555
 					else
556 556
 					{
557 557
 						$content['forwards'] = '';
558 558
 					}
559
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
560
-					if (strlen(trim($content['text']))==0)
559
+					if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
560
+					if (strlen(trim($content['text'])) == 0)
561 561
 					{
562 562
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
563 563
 						Framework::refresh_opener($msg, 'mail');
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 					list($button) = @each($content['button']);
576 576
 					unset ($content['button']);
577 577
 
578
-					switch($button)
578
+					switch ($button)
579 579
 					{
580 580
 						case 'save':
581 581
 						case 'apply':
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 								$newVacation = $content;
594 594
 
595 595
 								if (empty($this->mailConfig['prefpreventforwarding']) ||
596
-									$this->mailConfig['prefpreventforwarding'] == 0 )
596
+									$this->mailConfig['prefpreventforwarding'] == 0)
597 597
 								{
598 598
 									$content['forwards'] = self::strip_rfc882_addresses($content['forwards']);
599 599
 									$newVacation['forwards'] = implode(',', $content['forwards']);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 									unset($newVacation ['forwards']);
604 604
 								}
605 605
 
606
-								if (!in_array($newVacation['status'],array('on','off','by_date')))
606
+								if (!in_array($newVacation['status'], array('on', 'off', 'by_date')))
607 607
 								{
608 608
 									$newVacation['status'] = 'off';
609 609
 								}
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 										self::strip_rfc882_addresses($content['addresses']);
616 616
 								}
617 617
 
618
-								if($this->checkRule($newVacation,$checkAddresses))
618
+								if ($this->checkRule($newVacation, $checkAddresses))
619 619
 								{
620 620
 									if (isset($account_id) && $this->mail_admin)
621 621
 									{
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 
629 629
 									if (!$resSetvac)
630 630
 									{
631
-										$msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error;
631
+										$msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error;
632 632
 										break;
633 633
 									}
634 634
 									// schedule job to switch message on/off, if request and not already in past
635 635
 									else
636 636
 									{
637
-										if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
637
+										if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() ||
638 638
 											$vacRules && $vacRules['vacation']['status'] == 'by_date')
639 639
 										{
640 640
 											self::setAsyncJob($newVacation);
@@ -642,29 +642,29 @@  discard block
 block discarded – undo
642 642
 										//Reset vacationNotice cache which is used in mail_ui get_rows
643 643
 										if (isset($account_id) && $this->mail_admin)
644 644
 										{
645
-											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
645
+											$account_lid = Api\Accounts::id2name($account_id, 'account_lid');
646 646
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
647 647
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
648
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
648
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations);
649 649
 										}
650 650
 										else
651 651
 										{
652 652
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
653 653
 											//error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations));
654
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
654
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
655 655
 										}
656 656
 										$msg = lang('Vacation notice sucessfully updated.');
657 657
 									}
658 658
 								}
659 659
 								else
660 660
 								{
661
-									$msg .= implode("\n",$this->errorStack);
661
+									$msg .= implode("\n", $this->errorStack);
662 662
 								}
663 663
 								// refresh vacationNotice on index
664 664
 								$response = Api\Json\Response::get();
665
-								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
665
+								$response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId);
666 666
 								Framework::refresh_opener($msg, 'mail');
667
-								if ($button === 'apply' || $icServer->error !=="")
667
+								if ($button === 'apply' || $icServer->error !== "")
668 668
 								{
669 669
 									break;
670 670
 								}
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 						'on' => lang('Active'),
681 681
 						'off' => lang('Deactive'),
682 682
 					),
683
-					'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']),
683
+					'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']),
684 684
 				);
685 685
 				if (!isset($account_id))
686 686
 				{
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 		}
705 705
 		else
706 706
 		{
707
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
708
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
707
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
708
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
709 709
 		}
710
-		$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);
710
+		$vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2);
711 711
 	}
712 712
 
713 713
 	/**
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	static function strip_rfc882_addresses($_addresses)
722 722
 	{
723 723
 		$addresses = array();
724
-		foreach(Mail::parseAddressList($_addresses) as $addr)
724
+		foreach (Mail::parseAddressList($_addresses) as $addr)
725 725
 		{
726 726
 			if ($addr->valid)
727 727
 			{
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes
739 739
 	 * @return  void
740 740
 	 */
741
-	static function setAsyncJob (array $_vacation, $_reschedule=false)
741
+	static function setAsyncJob(array $_vacation, $_reschedule = false)
742 742
 	{
743 743
 		if (!($_vacation['acc_id'] > 0))
744 744
 		{
@@ -750,19 +750,19 @@  discard block
 block discarded – undo
750 750
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
751 751
 		$async->delete($async_id);
752 752
 
753
-		$end_date = $_vacation['end_date'] + 24*3600;   // end-date is inclusive, so we have to add 24h
753
+		$end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h
754 754
 		if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
755 755
 		{
756 756
 			$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
757
-			$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
757
+			$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
758 758
 		}
759 759
 		if ($_reschedule)
760 760
 		{
761
-			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
761
+			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5;
762 762
 			// only try to reschedule for 2 days max
763 763
 			if ($_vacation['rescheduled'] <= 2 * 24 * 60)
764 764
 			{
765
-				$time = time() + 60*($_vacation['rescheduled']);
765
+				$time = time() + 60 * ($_vacation['rescheduled']);
766 766
 				unset($_vacation['next']);
767 767
 				unset($_vacation['times']);
768 768
 				$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 		catch (Exception $e) {
800 800
 			error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
801
-			self::setAsyncJob($_vacation, true);	// reschedule
801
+			self::setAsyncJob($_vacation, true); // reschedule
802 802
 			$ret = false;
803 803
 		}
804 804
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 *
814 814
 	 * @return boolean
815 815
 	 */
816
-	function checkRule($_vacation,$_checkAddresses=true)
816
+	function checkRule($_vacation, $_checkAddresses = true)
817 817
 	{
818 818
 		$this->errorStack = array();
819 819
 
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 			$this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!';
828 828
 		}
829 829
 
830
-		if(is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
830
+		if (is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
831 831
 		{
832
-			$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
832
+			$regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
833 833
 			foreach ($_vacation['addresses'] as $addr)
834 834
 			{
835
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
835
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
836 836
 				{
837 837
 					$this->errorStack['addresses'] = lang('One address is not valid').'!';
838 838
 				}
@@ -848,23 +848,23 @@  discard block
 block discarded – undo
848 848
 			{
849 849
 				$this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!');
850 850
 			}
851
-			elseif($_vacation['start_date'] > $_vacation['end_date'])
851
+			elseif ($_vacation['start_date'] > $_vacation['end_date'])
852 852
 			{
853 853
 				$this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!');
854 854
 			}
855 855
 		}
856 856
 		if ($_vacation['forwards'])
857 857
 		{
858
-			foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr)
858
+			foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr)
859 859
 			{
860
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
860
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
861 861
 				{
862 862
 					$this->errorStack['forwards'] = lang('One address is not valid'.'!');
863 863
 				}
864 864
 			}
865 865
 		}
866 866
 		//error_log(__METHOD__. array2string($this->errorStack));
867
-		if(count($this->errorStack) == 0)
867
+		if (count($this->errorStack) == 0)
868 868
 		{
869 869
 			return true;
870 870
 		}
@@ -885,14 +885,14 @@  discard block
 block discarded – undo
885 885
 
886 886
 		foreach ($orders as $keys => $val)
887 887
 		{
888
-			$orders[$keys] = $val -1;
888
+			$orders[$keys] = $val - 1;
889 889
 		}
890 890
 
891 891
 		$this->getRules(null);
892 892
 
893 893
 		$newrules = $this->rules;
894 894
 
895
-		foreach($orders as $keys => $ruleID)
895
+		foreach ($orders as $keys => $ruleID)
896 896
 		{
897 897
 			$newrules[$keys] = $this->rules[$ruleID];
898 898
 		}
@@ -921,24 +921,24 @@  discard block
 block discarded – undo
921 921
 		switch ($action)
922 922
 		{
923 923
 			case 'delete':
924
-				if ($checked === count($this->rules)-1)
924
+				if ($checked === count($this->rules) - 1)
925 925
 				{
926
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!');
926
+					$msg = lang('rule with priority ').$checked.lang(' deleted!');
927 927
 				}
928 928
 				else
929 929
 				{
930 930
 
931
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked);
931
+					$msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked);
932 932
 				}
933 933
 				unset($this->rules[$checked]);
934 934
 				$this->rules = array_values($this->rules);
935 935
 				break;
936 936
 			case 'enable':
937
-				$msg = lang('rule with priority ') . $checked . lang(' enabled!');
937
+				$msg = lang('rule with priority ').$checked.lang(' enabled!');
938 938
 				$this->rules[$checked][status] = 'ENABLED';
939 939
 				break;
940 940
 			case 'disable':
941
-				$msg = lang('rule with priority ') . $checked . lang(' disabled!');
941
+				$msg = lang('rule with priority ').$checked.lang(' disabled!');
942 942
 				$this->rules[$checked][status] = 'DISABLED';
943 943
 				break;
944 944
 			case 'move':
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 
951 951
 		$response = Api\Json\Response::get();
952 952
 
953
-		if($result)
953
+		if ($result)
954 954
 		{
955 955
 			$response->error($result);
956 956
 			return;
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	function buildRule($rule)
970 970
 	{
971
-		$andor = ' '. lang('and') .' ';
971
+		$andor = ' '.lang('and').' ';
972 972
 		$started = 0;
973 973
 		if ($rule['anyof'])
974 974
 		{
975
-			$andor = ' '. lang('or') .' ';
975
+			$andor = ' '.lang('or').' ';
976 976
 		}
977 977
 		$complete = lang('IF').' ';
978 978
 		if ($rule['unconditional'])
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 		}
982 982
 		if ($rule['from'])
983 983
 		{
984
-			$match = $this->setMatchType($rule['from'],$rule['regexp']);
985
-			$complete .= "'From:' " . $match . " '" . $rule['from'] . "'";
984
+			$match = $this->setMatchType($rule['from'], $rule['regexp']);
985
+			$complete .= "'From:' ".$match." '".$rule['from']."'";
986 986
 			$started = 1;
987 987
 		}
988 988
 		if ($rule['to'])
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				$complete .= $andor;
993 993
 			}
994
-			$match = $this->setMatchType($rule['to'],$rule['regexp']);
995
-			$complete .= "'To:' " . $match . " '" . $rule['to'] . "'";
994
+			$match = $this->setMatchType($rule['to'], $rule['regexp']);
995
+			$complete .= "'To:' ".$match." '".$rule['to']."'";
996 996
 			$started = 1;
997 997
 		}
998 998
 		if ($rule['subject'])
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 			{
1002 1002
 				$complete .= $andor;
1003 1003
 			}
1004
-			$match = $this->setMatchType($rule['subject'],$rule['regexp']);
1005
-			$complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'";
1004
+			$match = $this->setMatchType($rule['subject'], $rule['regexp']);
1005
+			$complete .= "'Subject:' ".$match." '".$rule['subject']."'";
1006 1006
 			$started = 1;
1007 1007
 		}
1008 1008
 		if ($rule['field'] && $rule['field_val'])
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 			{
1012 1012
 				$complete .= $andor;
1013 1013
 			}
1014
-			$match = $this->setMatchType($rule['field_val'],$rule['regexp']);
1015
-			$complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'";
1014
+			$match = $this->setMatchType($rule['field_val'], $rule['regexp']);
1015
+			$complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'";
1016 1016
 			$started = 1;
1017 1017
 		}
1018 1018
 		if ($rule['size'])
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 			{
1027 1027
 				$complete .= $andor;
1028 1028
 			}
1029
-			$complete .= "message " . $xthan . $rule['size'] . "KB'";
1029
+			$complete .= "message ".$xthan.$rule['size']."KB'";
1030 1030
 			$started = 1;
1031 1031
 		}
1032 1032
 		if (!empty($rule['field_bodytransform']))
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 			{
1036 1036
 				$newruletext .= ", ";
1037 1037
 			}
1038
-			$btransform	= " :raw ";
1038
+			$btransform = " :raw ";
1039 1039
 			$match = ' :contains';
1040 1040
 			if ($rule['bodytransform'])
1041 1041
 			{
@@ -1049,11 +1049,11 @@  discard block
 block discarded – undo
1049 1049
 			{
1050 1050
 				$match = ':regex';
1051 1051
 			}
1052
-			$complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\"";
1052
+			$complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\"";
1053 1053
 			$started = 1;
1054 1054
 
1055 1055
 		}
1056
-		if ($rule['ctype']!= '0' && !empty($rule['ctype']))
1056
+		if ($rule['ctype'] != '0' && !empty($rule['ctype']))
1057 1057
 		{
1058 1058
 			if ($started)
1059 1059
 			{
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 			{
1066 1066
 				$ctype_subtype = "/";
1067 1067
 			}
1068
-			$complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\"";
1068
+			$complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\"";
1069 1069
 			$started = 1;
1070 1070
 			//error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array));
1071 1071
 		}
@@ -1073,19 +1073,19 @@  discard block
 block discarded – undo
1073 1073
 		{
1074 1074
 			$complete .= ' '.lang('THEN').' ';
1075 1075
 		}
1076
-		if (preg_match("/folder/i",$rule['action']))
1076
+		if (preg_match("/folder/i", $rule['action']))
1077 1077
 		{
1078
-			$complete .= lang('file into')." '" . $rule['action_arg'] . "';";
1078
+			$complete .= lang('file into')." '".$rule['action_arg']."';";
1079 1079
 		}
1080
-		if (preg_match("/reject/i",$rule['action']))
1080
+		if (preg_match("/reject/i", $rule['action']))
1081 1081
 		{
1082
-			$complete .= lang('reject with')." '" . $rule['action_arg'] . "'.";
1082
+			$complete .= lang('reject with')." '".$rule['action_arg']."'.";
1083 1083
 		}
1084
-		if (preg_match("/address/i",$rule['action']))
1084
+		if (preg_match("/address/i", $rule['action']))
1085 1085
 		{
1086
-			$complete .= lang('forward to').' ' . $rule['action_arg'] .'.';
1086
+			$complete .= lang('forward to').' '.$rule['action_arg'].'.';
1087 1087
 		}
1088
-		if (preg_match("/discard/i",$rule['action']))
1088
+		if (preg_match("/discard/i", $rule['action']))
1089 1089
 		{
1090 1090
 			$complete .= lang('discard').'.';
1091 1091
 		}
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 * @param {string} $regex regular expresion as pattern to be matched
1108 1108
 	 * @return {string} return the type
1109 1109
 	 */
1110
-	function setMatchType (&$matchstr, $regex = false)
1110
+	function setMatchType(&$matchstr, $regex = false)
1111 1111
 	{
1112 1112
 		$match = lang('contains');
1113 1113
 		if (preg_match("/^\s*!/", $matchstr))
@@ -1132,11 +1132,11 @@  discard block
 block discarded – undo
1132 1132
 		}
1133 1133
 		if ($regex && preg_match("/^\s*\\\\!/", $matchstr))
1134 1134
 		{
1135
-			$matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr);
1135
+			$matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr);
1136 1136
 		}
1137 1137
 		else
1138 1138
 		{
1139
-			$matchstr = preg_replace("/^\s*!/","",$matchstr);
1139
+			$matchstr = preg_replace("/^\s*!/", "", $matchstr);
1140 1140
 		}
1141 1141
 		return $match;
1142 1142
 	}
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
 	 */
1147 1147
 	function saveSessionData()
1148 1148
 	{
1149
-		$sessionData['sieve_rules']		= $this->rules;
1149
+		$sessionData['sieve_rules'] = $this->rules;
1150 1150
 		$sessionData['sieve_rulesByID'] = $this->rulesByID;
1151
-		$sessionData['sieve_scriptToEdit']	= $this->scriptToEdit;
1151
+		$sessionData['sieve_scriptToEdit'] = $this->scriptToEdit;
1152 1152
 		Api\Cache::setSession(__CLASS__, 'sieve_session_data', $sessionData);
1153 1153
 	}
1154 1154
 
@@ -1174,15 +1174,15 @@  discard block
 block discarded – undo
1174 1174
 	{
1175 1175
 		try {
1176 1176
 			$this->account->imapServer()->retrieveRules();
1177
-			$this->rules	= $this->account->imapServer()->getRules();
1177
+			$this->rules = $this->account->imapServer()->getRules();
1178 1178
 			$this->rulesByID = $this->rules[$ruleID];
1179
-			$this->vacation	= $this->account->imapServer()->getVacation();
1179
+			$this->vacation = $this->account->imapServer()->getVacation();
1180 1180
 		}
1181
-		catch(Exception $e) {
1181
+		catch (Exception $e) {
1182 1182
 			error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details);
1183
-			$this->rules	= array();
1183
+			$this->rules = array();
1184 1184
 			$this->rulesByID = array();
1185
-			$this->vacation	= array();
1185
+			$this->vacation = array();
1186 1186
 			return false;
1187 1187
 		}
1188 1188
 		return true;
@@ -1194,9 +1194,9 @@  discard block
 block discarded – undo
1194 1194
 	function restoreSessionData()
1195 1195
 	{
1196 1196
 		$sessionData = Api\Cache::getSession(__CLASS__, 'sieve_session_data');
1197
-		$this->rules		= $sessionData['sieve_rules'];
1197
+		$this->rules = $sessionData['sieve_rules'];
1198 1198
 		$this->rulesByID = $sessionData['sieve_rulesByID'];
1199
-		$this->scriptToEdit	= $sessionData['sieve_scriptToEdit'];
1199
+		$this->scriptToEdit = $sessionData['sieve_scriptToEdit'];
1200 1200
 	}
1201 1201
 
1202 1202
 	/**
@@ -1210,14 +1210,14 @@  discard block
 block discarded – undo
1210 1210
 		$rows = array();
1211 1211
 		$this->getRules(null);
1212 1212
 
1213
-		if (is_array($this->rules) && !empty($this->rules) )
1213
+		if (is_array($this->rules) && !empty($this->rules))
1214 1214
 		{
1215 1215
 			$rows = $this->rules;
1216 1216
 
1217
-			foreach ($rows as &$row )
1217
+			foreach ($rows as &$row)
1218 1218
 			{
1219 1219
 				$row['rules'] = $this->buildRule($row);
1220
-				$row['ruleID'] =(string)(($row['priority'] -1) / 2 );
1220
+				$row['ruleID'] = (string)(($row['priority'] - 1) / 2);
1221 1221
 				if ($row ['status'] === 'DISABLED')
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 			return false;
1231 1231
 		}
1232 1232
 		// Shift one down, because in grid the first row is reserved for header
1233
-		array_unshift($rows,array(''=> ''));
1233
+		array_unshift($rows, array(''=> ''));
1234 1234
 		return $rows;
1235 1235
 	}
1236 1236
 
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 	 */
1242 1242
 	private function get_actions()
1243 1243
 	{
1244
-		$actions =array(
1244
+		$actions = array(
1245 1245
 
1246 1246
 			'edit' => array(
1247 1247
 				'caption' => 'Edit',
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	 * @param int $_mailaccountToSearch
1281 1281
 	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283
-	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1283
+	function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false)
1284 1284
 	{
1285 1285
 		$mailCompose = new mail_compose();
1286 1286
 		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
Please login to merge, or discard this patch.
mail/inc/class.mail_tree.inc.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $_profileID icServer profile id
77 77
 	 * @param string $_err error message to be shown on tree node
78 78
 	 * @param mixed $_path
79
-	 * @param mixed $_parent
79
+	 * @param string $_parent
80 80
 	 * @return array returns an array of tree node
81 81
 	 */
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * Check if the given tree id is account node (means root)
125 125
 	 *
126
-	 * @param type $_node a tree id node
126
+	 * @param string|null $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129 129
 	private static function isAccountNode ($_node)
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @param string $_parent = null no parent node means root with the first level of folders
157 157
 	 * @param string $_profileID = '' icServer id
158
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
158
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
159 159
 	 *  false|0 leaves them in closed state
160 160
 	 * @param $_noCheckboxNS = false no checkbox for namesapaces makes sure to not put checkbox for namespaces node
161 161
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @param type $_profileID = null Null means all accounts and giving profileid means fetches node for the account
445 445
 	 * @param type $_noCheckbox = false option to switch checkbox of
446
-	 * @param type $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
446
+	 * @param integer $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
447 447
 	 *
448 448
 	 * @return array an array of baseNodes of accounts
449 449
 	 */
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 *
492 492
 	 * @param string $_parent = null no parent node means root with the first level of folders
493 493
 	 * @param string $_profileID = '' active profile / acc_id
494
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
494
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
495 495
 	 *  false|0 leaves them in closed state
496 496
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
497 497
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		$this->ui = $mail_ui;
62 62
 
63 63
 		// check images available in png or svg
64
-		foreach(self::$leafImages as &$image)
64
+		foreach (self::$leafImages as &$image)
65 65
 		{
66 66
 			if (strpos($image, '.') === false)
67 67
 			{
68
-				$image = basename($img=Api\Image::find('mail', 'dhtmlxtree/'.$image));
68
+				$image = basename($img = Api\Image::find('mail', 'dhtmlxtree/'.$image));
69 69
 			}
70 70
 		}
71 71
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
83 83
 	{
84 84
 		$baseNode = array('id' => $_profileID);
85
-		$leaf =  array(
85
+		$leaf = array(
86 86
 			'id' => $_profileID.self::DELIMITER.'INBOX',
87 87
 			'text' => $_err,
88 88
 			'tooltip' => $_err,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		);
95 95
 		self::setOutStructure($leaf, $baseNode, self::DELIMITER);
96 96
 
97
-		return ($baseNode?$baseNode:array( // fallback not connected array
97
+		return ($baseNode ? $baseNode : array( // fallback not connected array
98 98
 						'id'=>0,
99 99
 						'item'=> array(
100 100
 							'text'=>'INBOX',
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param array $_node array of a node
112 112
 	 * @return int returns 1 if it has children flag set otherwise 0
113 113
 	 */
114
-	private static function nodeHasChildren ($_node)
114
+	private static function nodeHasChildren($_node)
115 115
 	{
116 116
 		$hasChildren = 0;
117 117
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param type $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129
-	private static function isAccountNode ($_node)
129
+	private static function isAccountNode($_node)
130 130
 	{
131 131
 		list(,$leaf) = explode(self::DELIMITER, $_node);
132 132
 		if ($leaf || $_node == null) return false;
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @return array returns an array of mail tree structure according to provided node
166 166
 	 */
167
-	function getTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly= false, $_allInOneGo = false, $_checkSubscribed = true)
167
+	function getTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly = false, $_allInOneGo = false, $_checkSubscribed = true)
168 168
 	{
169 169
 		//Init mail folders
170
-		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
170
+		$tree = array(Tree::ID=> $_parent ? $_parent : 0, Tree::CHILDREN => array());
171 171
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
172 172
 
173 173
 		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			{
179 179
 				$this->ui->changeProfile($_profileID);
180 180
 			} catch (Exception $ex) {
181
-				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
181
+				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
182 182
 			}
183 183
 		}
184 184
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
191 191
 			{
192 192
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
193
-				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
193
+				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly);
194 194
 
195 195
 				$childrenNode = array();
196 196
 				foreach ($folders as &$node)
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 					$nodeData = Mail::pathToFolderData($nodeId, $node['delimiter']);
200 200
 					$childrenNode[] = array(
201 201
 						Tree::ID=> $nodeId,
202
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node),
202
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($node),
203 203
 						Tree::CHILDREN =>array(),
204 204
 						Tree::LABEL => $nodeData['text'],
205 205
 						Tree::TOOLTIP => $nodeData['tooltip'],
206 206
 						Tree::IMAGE_LEAF => self::$leafImages['folderLeaf'],
207 207
 						Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'],
208 208
 						Tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClosed'],
209
-						Tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false,
209
+						Tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false,
210 210
 						'parent' => $_parent
211 211
 					);
212 212
 				}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 				}
227 227
 
228 228
 				//List of folders
229
-				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, false);
229
+				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, false);
230 230
 
231 231
 				// User defined folders based on account
232 232
 				$definedFolders = array(
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 
247 247
 					$data = array(
248 248
 						Tree::ID=>$_profileID.self::DELIMITER.$folder['MAILBOX'],
249
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder),
249
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($folder),
250 250
 						Tree::CHILDREN =>array(),
251 251
 						Tree::LABEL =>lang($folder['MAILBOX']),
252
-						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0,
252
+						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0,
253 253
 						Tree::TOOLTIP => lang($folder['MAILBOX']),
254
-						Tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false,
254
+						Tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false,
255 255
 						Tree::NOCHECKBOX => 0,
256
-						'parent' => $parent?$_profileID.self::DELIMITER.implode($folder['delimiter'], $parent):$_profileID,
256
+						'parent' => $parent ? $_profileID.self::DELIMITER.implode($folder['delimiter'], $parent) : $_profileID,
257 257
 						'path' => $path,
258 258
 						'folderarray' => $folder
259 259
 					);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		catch (Exception $ex) // Catch exceptions
292 292
 		{
293 293
 			//mail_ui::callWizard($ex->getMessage(), false, 'error');
294
-			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
294
+			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
295 295
 		}
296 296
 
297 297
 		return $tree;
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
 	 *					as clearance for access may be limited to a single branch-node of a tree
309 309
 	 * @return void
310 310
 	 */
311
-	static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array())
311
+	static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array())
312 312
 	{
313 313
 		//error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
314 314
 		$components = $data['path'];
315
-		array_pop($components);	// remove own name
315
+		array_pop($components); // remove own name
316 316
 
317 317
 		$insert = &$out;
318 318
 		$parents = array();
319
-		foreach($components as $component)
319
+		foreach ($components as $component)
320 320
 		{
321
-			if (count($parents)>1)
321
+			if (count($parents) > 1)
322 322
 			{
323
-				$helper = array_slice($parents,1,null,true);
323
+				$helper = array_slice($parents, 1, null, true);
324 324
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
325 325
 				if ($parent) $parent .= $del;
326 326
 			}
@@ -343,21 +343,21 @@  discard block
 block discarded – undo
343 343
 				{
344 344
 					// if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent
345 345
 					// we want to create the node in question as we meet the above considerations
346
-					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
346
+					if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::DELIMITER.$nsp['prefix']) === 0)
347 347
 					{
348 348
 						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
349
-						$break=false;
349
+						$break = false;
350 350
 					}
351 351
 				}
352 352
 				if ($break) break;
353 353
 			}
354 354
 			if ($insert['item'])
355 355
 			{
356
-				foreach($insert['item'] as &$item)
356
+				foreach ($insert['item'] as &$item)
357 357
 				{
358 358
 					if ($item['id'] == $parent.$component)
359 359
 					{
360
-						$insert =& $item;
360
+						$insert = & $item;
361 361
 						break;
362 362
 					}
363 363
 				}
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 						'im2' => self::$leafImages["folderNoSelectClosed"],
376 376
 						'tooltip' => lang('no access')
377 377
 					);
378
-					$insert['item'][] =& $item;
379
-					$insert =& $item;
378
+					$insert['item'][] = & $item;
379
+					$insert = & $item;
380 380
 				}
381 381
 				else
382 382
 				{
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 					$data[Tree::IMAGE_FOLDER_OPEN] =
410 410
 					$data [Tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png";
411 411
 			}
412
-			elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false)
412
+			elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false)
413 413
 			{
414 414
 				$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
415 415
 				$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @return array an array of baseNodes of accounts
453 453
 	 */
454
-	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 )
454
+	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0)
455 455
 	{
456 456
 		$roots = array(Tree::ID => 0, Tree::CHILDREN => array());
457 457
 
458
-		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
458
+		foreach (Mail\Account::search(true, false) as $acc_id => $accObj)
459 459
 		{
460
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
461
-			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
460
+			if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue;
461
+			$identity = Mail\Account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']);
462 462
 			// Open top level folders for active account
463
-			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
463
+			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0;
464 464
 
465 465
 			$baseNode = array(
466 466
 							Tree::ID=> (string)$acc_id,
467
-							Tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity),
467
+							Tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity),
468 468
 							Tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity),
469 469
 							Tree::IMAGE_LEAF => self::$leafImages['folderAccount'],
470 470
 							Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'],
@@ -473,16 +473,16 @@  discard block
 block discarded – undo
473 473
 							Tree::CHILDREN => array(), // dynamic loading on unfold
474 474
 							Tree::AUTOLOAD_CHILDREN => true,
475 475
 							'parent' => '',
476
-							Tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount,
476
+							Tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount,
477 477
 							// mark on account if Sieve is enabled
478 478
 							'data' => array(
479 479
 										'sieve' => $accObj->imapServer()->acc_sieve_enabled,
480
-										'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
481
-										'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
480
+										'spamfolder'=> $accObj->imapServer()->acc_folder_junk && (strtolower($accObj->imapServer()->acc_folder_junk) != 'none') ? true : false,
481
+										'archivefolder'=> $accObj->imapServer()->acc_folder_archive && (strtolower($accObj->imapServer()->acc_folder_archive) != 'none') ? true : false
482 482
 									),
483 483
 							Tree::NOCHECKBOX  => $_noCheckbox
484 484
 			);
485
-			self::setOutStructure($baseNode, $roots,self::DELIMITER);
485
+			self::setOutStructure($baseNode, $roots, self::DELIMITER);
486 486
 		}
487 487
 		return $roots;
488 488
 	}
@@ -501,15 +501,15 @@  discard block
 block discarded – undo
501 501
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
502 502
 	 * @return type an array of tree
503 503
 	 */
504
-	function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false)
504
+	function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false)
505 505
 	{
506 506
 		$tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo);
507
-		$branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo);
507
+		$branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo);
508 508
 		foreach ($tree[Tree::CHILDREN] as &$account)
509 509
 		{
510 510
 			if ($account[Tree::ID] == $_profileID)
511 511
 			{
512
-				$account = array_merge($account , $branches);
512
+				$account = array_merge($account, $branches);
513 513
 			}
514 514
 		}
515 515
 		return $tree;
Please login to merge, or discard this patch.
Braces   +54 added lines, -14 removed lines patch added patch discarded remove patch
@@ -116,7 +116,10 @@  discard block
 block discarded – undo
116 116
 		$hasChildren = 0;
117 117
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
118 118
 				in_array('\Haschildren', $_node['ATTRIBUTES']) ||
119
-				in_array('\HasChildren', $_node['ATTRIBUTES'])) $hasChildren = 1;
119
+				in_array('\HasChildren', $_node['ATTRIBUTES']))
120
+		{
121
+			$hasChildren = 1;
122
+		}
120 123
 		return $hasChildren;
121 124
 	}
122 125
 
@@ -129,7 +132,10 @@  discard block
 block discarded – undo
129 132
 	private static function isAccountNode ($_node)
130 133
 	{
131 134
 		list(,$leaf) = explode(self::DELIMITER, $_node);
132
-		if ($leaf || $_node == null) return false;
135
+		if ($leaf || $_node == null)
136
+		{
137
+			return false;
138
+		}
133 139
 		return true;
134 140
 	}
135 141
 
@@ -168,17 +174,24 @@  discard block
 block discarded – undo
168 174
 	{
169 175
 		//Init mail folders
170 176
 		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
171
-		if (!isset($this->ui->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
177
+		if (!isset($this->ui->mail_bo))
178
+		{
179
+			throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
180
+		}
172 181
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
173 182
 
174
-		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
183
+		if ($_parent)
184
+		{
185
+			list($_profileID) = explode(self::DELIMITER, $_parent);
186
+		}
175 187
 
176 188
 		if (is_numeric($_profileID) && $_profileID != $this->ui->mail_bo->profileID)
177 189
 		{
178 190
 			try
179 191
 			{
180 192
 				$this->ui->changeProfile($_profileID);
181
-			} catch (Exception $ex) {
193
+			}
194
+			catch (Exception $ex) {
182 195
 				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
183 196
 			}
184 197
 		}
@@ -188,9 +201,12 @@  discard block
 block discarded – undo
188 201
 			// *** Note: Should not apply any imap transaction, because in case of exception it will stop the
189 202
 			// process of rendering root node
190 203
 
191
-			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
204
+			if ($_parent && !self::isAccountNode($_parent))
205
+			{
206
+				// Single node loader
192 207
 			{
193 208
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
209
+			}
194 210
 				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
195 211
 
196 212
 				$childrenNode = array();
@@ -215,15 +231,21 @@  discard block
 block discarded – undo
215 231
 			}
216 232
 			else //Top Level Nodes loader
217 233
 			{
218
-				if (self::isAccountNode($_parent)) // An account called for open
234
+				if (self::isAccountNode($_parent))
235
+				{
236
+					// An account called for open
219 237
 				{
220 238
 					$_openTopLevel = 1;
239
+				}
221 240
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
222 241
 				}
223 242
 				else // Initial accounts|root nodes
224 243
 				{
225 244
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
226
-					if (!$_profileID && !$_openTopLevel) return $tree;
245
+					if (!$_profileID && !$_openTopLevel)
246
+					{
247
+						return $tree;
248
+					}
227 249
 				}
228 250
 
229 251
 				//List of folders
@@ -323,19 +345,28 @@  discard block
 block discarded – undo
323 345
 			{
324 346
 				$helper = array_slice($parents,1,null,true);
325 347
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
326
-				if ($parent) $parent .= $del;
348
+				if ($parent)
349
+				{
350
+					$parent .= $del;
351
+				}
327 352
 			}
328 353
 			else
329 354
 			{
330 355
 				$parent = implode(self::DELIMITER, $parents);
331
-				if ($parent) $parent .= self::DELIMITER;
356
+				if ($parent)
357
+				{
358
+					$parent .= self::DELIMITER;
359
+				}
332 360
 			}
333 361
 
334 362
 			if (!is_array($insert) || !isset($insert['item']))
335 363
 			{
336 364
 				// throwing an exeption here seems to be unrecoverable,
337 365
 				// even if the cause is a something that can be handeled by the mailserver
338
-				if (mail_bo::$debug) error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
366
+				if (mail_bo::$debug)
367
+				{
368
+					error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
369
+				}
339 370
 				// should we hit the break? if in personal: sure, something is wrong with the folderstructure
340 371
 				// if in shared or others we may proceed as access to folders may very well be limited to
341 372
 				// a single folder within the tree
@@ -346,11 +377,17 @@  discard block
 block discarded – undo
346 377
 					// we want to create the node in question as we meet the above considerations
347 378
 					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
348 379
 					{
349
-						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
380
+						if (mail_bo::$debug)
381
+						{
382
+							error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
383
+						}
350 384
 						$break=false;
351 385
 					}
352 386
 				}
353
-				if ($break) break;
387
+				if ($break)
388
+				{
389
+					break;
390
+				}
354 391
 			}
355 392
 			if ($insert['item'])
356 393
 			{
@@ -458,7 +495,10 @@  discard block
 block discarded – undo
458 495
 
459 496
 		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
460 497
 		{
461
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
498
+			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID)
499
+			{
500
+				continue;
501
+			}
462 502
 			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
463 503
 			// Open top level folders for active account
464 504
 			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
Please login to merge, or discard this patch.
mail/inc/class.mail_ui.inc.php 5 patches
Doc Comments   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
 	 * function splitRowID - split the rowID into its parts
1542 1542
 	 *
1543 1543
 	 * @param string $_rowID string - a colon separated string in the form accountID:profileID:folder:message_uid
1544
-	 * @return array populated named result array (accountID,profileID,folder,msgUID)
1544
+	 * @return string populated named result array (accountID,profileID,folder,msgUID)
1545 1545
 	 */
1546 1546
 	static function splitRowID($_rowID)
1547 1547
 	{
@@ -1623,9 +1623,9 @@  discard block
 block discarded – undo
1623 1623
 	 * function header2gridelements - to populate the grid elements with the collected Data
1624 1624
 	 *
1625 1625
 	 * @param array $_headers headerdata to process
1626
-	 * @param array $cols cols to populate
1626
+	 * @param string[] $cols cols to populate
1627 1627
 	 * @param array $_folderName to ensure the uniqueness of the uid over all folders
1628
-	 * @param array $_folderType used to determine if we need to populate from/to
1628
+	 * @param integer $_folderType used to determine if we need to populate from/to
1629 1629
 	 * @return array populated result array
1630 1630
 	 */
1631 1631
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
@@ -2863,6 +2863,9 @@  discard block
 block discarded – undo
2863 2863
 		return $GLOBALS['egw']->framework->header();
2864 2864
 	}
2865 2865
 
2866
+	/**
2867
+	 * @param string $body
2868
+	 */
2866 2869
 	function showBody(&$body, $print=true,$fullPageTags=true)
2867 2870
 	{
2868 2871
 		$BeginBody = '<div class="mailDisplayBody">
@@ -3099,9 +3102,9 @@  discard block
 block discarded – undo
3099 3102
 	 * Replace CID with proper type of content understandable by browser
3100 3103
 	 *
3101 3104
 	 * @param type $_body content of message
3102
-	 * @param type $_mailbox mail box
3103
-	 * @param type $_uid uid
3104
-	 * @param type $_partID part id
3105
+	 * @param string $_mailbox mail box
3106
+	 * @param string $_uid uid
3107
+	 * @param string $_partID part id
3105 3108
 	 * @param type $_type = 'src' type of inline image that needs to be resolved and replaced
3106 3109
 	 *	- types: {plain|src|url|background}
3107 3110
 	 * @return string returns body content including all CID replacements
@@ -3283,7 +3286,7 @@  discard block
 block discarded – undo
3283 3286
 	 * @param string $_folder (passed by reference) will set the folder used. must be set with a folder, but will hold modifications if
3284 3287
 	 *					folder is modified
3285 3288
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3286
-	 * @return mixed $messageUID or exception
3289
+	 * @return string $messageUID or exception
3287 3290
 	 */
3288 3291
 	function importMessageToFolder($_formData,&$_folder,$importID='')
3289 3292
 	{
@@ -3444,7 +3447,7 @@  discard block
 block discarded – undo
3444 3447
 	 *
3445 3448
 	 * @param string _messageID UID
3446 3449
 	 *
3447
-	 * @return xajax response
3450
+	 * @return string|null response
3448 3451
 	 */
3449 3452
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3450 3453
 	{
@@ -3995,7 +3998,7 @@  discard block
 block discarded – undo
3995 3998
 	 * ajax_deleteFolder - its called via json, so the function must start with ajax (or the class-name must contain ajax)
3996 3999
 	 * @param string $_folderName folder to delete
3997 4000
 	 * @param boolean $_return = false wheter return the success value (true) or send response to client (false)
3998
-	 * @return nothing
4001
+	 * @return null|boolean
3999 4002
 	 */
4000 4003
 	function ajax_deleteFolder($_folderName, $_return = false)
4001 4004
 	{
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3117,7 +3117,7 @@  discard block
 block discarded – undo
3117 3117
 		 * @param string $_partID
3118 3118
 		 * @param string $_type
3119 3119
 		 * @return string|boolean returns the replace
3120
-		*/
3120
+		 */
3121 3121
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3122 3122
 		{
3123 3123
 			if (!$_type)	return false;
@@ -3249,10 +3249,10 @@  discard block
 block discarded – undo
3249 3249
 			try
3250 3250
 			{
3251 3251
 				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3252
-			    $linkData = array
3253
-			    (
3252
+				$linkData = array
3253
+				(
3254 3254
 					'id' => $this->createRowID($destination, $messageUid, true),
3255
-			    );
3255
+				);
3256 3256
 			}
3257 3257
 			catch (Api\Exception\WrongUserinput $e)
3258 3258
 			{
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
 			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3419 3419
 			$linkData = array
3420 3420
 			(
3421
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3421
+				'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3422 3422
 				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3423 3423
 				'deleteDraftOnClose' => 1,
3424 3424
 			);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1811,7 +1811,7 @@
 block discarded – undo
1811 1811
 
1812 1812
 			$data["class"] = implode(' ', $css_styles);
1813 1813
 			//translate style-classes back to flags
1814
-			$data['flags'] = Array();
1814
+			$data['flags'] = array();
1815 1815
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1816 1816
 			foreach ($css_styles as &$flag) {
1817 1817
 				if ($flag!='mail')
Please login to merge, or discard this patch.
Braces   +931 added lines, -259 removed lines patch added patch discarded remove patch
@@ -127,9 +127,15 @@  discard block
 block discarded – undo
127 127
 	function __construct($run_constructor=true)
128 128
 	{
129 129
 		$this->mail_tree = new mail_tree($this);
130
-		if (!$run_constructor) return;
130
+		if (!$run_constructor)
131
+		{
132
+			return;
133
+		}
131 134
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
135
+		if (Mail::$debugTimes)
136
+		{
137
+			$starttime = microtime (true);
138
+		}
133 139
 		// no autohide of the sidebox, as we use it for folderlist now.
134 140
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 141
 
@@ -140,13 +146,19 @@  discard block
 block discarded – undo
140 146
 		if ($_GET["resetConnection"])
141 147
 		{
142 148
 			unset($_GET["resetConnection"]);
143
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
149
+			if (Mail::$debug)
150
+			{
151
+				error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
152
+			}
144 153
 			Mail::unsetCachedObjects(self::$icServerID);
145 154
 		}
146 155
 
147 156
 		try {
148 157
 			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
149
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
158
+			if (Mail::$debug)
159
+			{
160
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
161
+			}
150 162
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 163
 
152 164
 			// RegEx to minimize extra openConnection
@@ -167,9 +179,15 @@  discard block
 block discarded – undo
167 179
 				$response->call('egw.message',$e->getMessage(),'error');
168 180
 			}
169 181
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
182
+			if ($_GET['menuaction'] != 'mail.mail_ui.index')
183
+			{
184
+				self::callWizard($e->getMessage(),true,'error',false);
185
+			}
186
+		}
187
+		if (Mail::$debugTimes)
188
+		{
189
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171 190
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
173 191
 	}
174 192
 
175 193
 	/**
@@ -229,16 +247,28 @@  discard block
 block discarded – undo
229 247
 	 */
230 248
 	function changeProfile($_icServerID,$unsetCache=false)
231 249
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
250
+		if (Mail::$debugTimes)
251
+		{
252
+			$starttime = microtime (true);
253
+		}
233 254
 		if (self::$icServerID != $_icServerID)
234 255
 		{
235 256
 			self::$icServerID = $_icServerID;
236 257
 		}
237
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
258
+		if (Mail::$debug)
259
+		{
260
+			error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
261
+		}
238 262
 
239
-		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
263
+		if ($unsetCache)
264
+		{
265
+			Mail::unsetCachedObjects(self::$icServerID);
266
+		}
240 267
 		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
241
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
268
+		if (Mail::$debug)
269
+		{
270
+			error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
271
+		}
242 272
 		// no icServer Object: something failed big time
243 273
 		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
244 274
 		{
@@ -248,14 +278,23 @@  discard block
 block discarded – undo
248 278
 
249 279
 		// save session varchar
250 280
 		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
251
-		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252
-		if (true) $oldicServerID = self::$icServerID;
281
+		if ($oldicServerID <> self::$icServerID)
282
+		{
283
+			$this->mail_bo->openConnection(self::$icServerID);
284
+		}
285
+		if (true)
286
+		{
287
+			$oldicServerID = self::$icServerID;
288
+		}
253 289
 		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
254 290
 		{
255 291
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 292
 		}
257 293
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
294
+		if (Mail::$debugTimes)
295
+		{
296
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
297
+		}
259 298
 	}
260 299
 
261 300
 	/**
@@ -296,7 +335,8 @@  discard block
 block discarded – undo
296 335
 		// got subscribed or unsubscribed by the user
297 336
 		try {
298 337
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
299
-		} catch (Exception $ex) {
338
+		}
339
+		catch (Exception $ex) {
300 340
 			Framework::message($ex->getMessage());
301 341
 		}
302 342
 
@@ -330,9 +370,18 @@  discard block
 block discarded – undo
330 370
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 371
 						if ($node)
332 372
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
334
-							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335
-							if ($value['value']) $cont[] = $path;
373
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value'])
374
+							{
375
+								$to_unsubscribe []= $node;
376
+							}
377
+							if (is_array($subscribed) && !$subscribed[$node] && $value['value'])
378
+							{
379
+								$to_subscribe [] = $node;
380
+							}
381
+							if ($value['value'])
382
+							{
383
+								$cont[] = $path;
384
+							}
336 385
 						}
337 386
 
338 387
 					}
@@ -420,9 +469,15 @@  discard block
 block discarded – undo
420 469
 	{
421 470
 		//error_log(__METHOD__.__LINE__.array2string($content));
422 471
 		try	{
423
-				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
472
+				if (!isset($this->mail_bo))
473
+				{
474
+					throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
475
+				}
424 476
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
477
+				if (Mail::$debugTimes)
478
+				{
479
+					$starttime = microtime (true);
480
+				}
426 481
 				$this->mail_bo->restoreSessionData();
427 482
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 483
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -451,7 +506,10 @@  discard block
 block discarded – undo
451 506
 							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
452 507
 						);
453 508
 					}
454
-					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
509
+					if (Api\Header\UserAgent::mobile())
510
+					{
511
+						$content[self::$nm_index]['header_row'] = 'mail.index.header_right';
512
+					}
455 513
 				}
456 514
 
457 515
 				// These must always be set, even if $content is an array
@@ -475,13 +533,16 @@  discard block
 block discarded – undo
475 533
 				}
476 534
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477 535
 				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
536
+				if($quota !== false && $quota['limit'] != 'NOT SET')
537
+				{
479 538
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 539
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481 540
 					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
482 541
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 542
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484
-				} else {
543
+				}
544
+				else
545
+				{
485 546
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
486 547
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
487 548
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -489,7 +550,8 @@  discard block
 block discarded – undo
489 550
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
490 551
 				$vacation = false;//$this->gatherVacation();
491 552
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
492
-				if($vacation) {
553
+				if($vacation)
554
+				{
493 555
 					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
494 556
 					{
495 557
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
@@ -523,19 +585,31 @@  discard block
 block discarded – undo
523 585
 					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
524 586
 					foreach($keywords as &$k)
525 587
 					{
526
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
588
+						if (array_key_exists($k,$this->statusTypes))
589
+						{
590
+							unset($this->statusTypes[$k]);
591
+						}
527 592
 					}
528 593
 				}
529 594
 
530
-				if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
531
-				if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
595
+				if (!isset($content[self::$nm_index]['foldertree']))
596
+				{
597
+					$content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
598
+				}
599
+				if (!isset($content[self::$nm_index]['selectedFolder']))
600
+				{
601
+					$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
602
+				}
532 603
 
533 604
 				$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
534 605
 
535 606
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
536 607
 				{
537 608
 					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
538
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
609
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
610
+					{
611
+						Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
612
+					}
539 613
 				}
540 614
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
541 615
 				{
@@ -557,10 +631,16 @@  discard block
 block discarded – undo
557 631
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
558 632
 
559 633
 				// sending preview toolbar actions
560
-				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
634
+				if ($content['mailSplitter'])
635
+				{
636
+					$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
637
+				}
561 638
 
562 639
 				// We need to send toolbar actions to client-side because view template needs them
563
-				if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions();
640
+				if (Api\Header\UserAgent::mobile())
641
+				{
642
+					$sel_options['toolbar'] = $this->get_toolbar_actions();
643
+				}
564 644
 
565 645
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
566 646
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
@@ -568,7 +648,10 @@  discard block
 block discarded – undo
568 648
 					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
569 649
 				}
570 650
 				$readonlys = $preserv = array();
571
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
651
+				if (Mail::$debugTimes)
652
+				{
653
+					Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
654
+				}
572 655
 		}
573 656
 		catch (Exception $e)
574 657
 		{
@@ -584,13 +667,19 @@  discard block
 block discarded – undo
584 667
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
585 668
 			}
586 669
 			$readonlys = $preserv = array();
587
-			if (empty($content)) $content=array();
670
+			if (empty($content))
671
+			{
672
+				$content=array();
673
+			}
588 674
 
589 675
 			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
590 676
 			//return false;
591 677
 		}
592 678
 		// Check preview pane is enabled, then show spliter
593
-		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
679
+		if ($this->mail_bo->mailPreferences['previewPane'])
680
+		{
681
+			$etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
682
+		}
594 683
 
595 684
 		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
596 685
 	}
@@ -811,7 +900,8 @@  discard block
 block discarded – undo
811 900
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
812 901
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
813 902
 			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
814
-		} catch (Horde_Imap_Client_Exception $ex) {
903
+		}
904
+		catch (Horde_Imap_Client_Exception $ex) {
815 905
 			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
816 906
 			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
817 907
 		}
@@ -828,12 +918,18 @@  discard block
 block discarded – undo
828 918
 	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
829 919
 	{
830 920
 		$nodeID = $_GET['id'];
831
-		if (!is_null($_nodeID)) $nodeID = $_nodeID;
921
+		if (!is_null($_nodeID))
922
+		{
923
+			$nodeID = $_nodeID;
924
+		}
832 925
 		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
833 926
 		$fetchCounters = !is_null($_nodeID);
834 927
 		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
835 928
 
836
-		if (!empty($_folderName)) $fetchCounters = true;
929
+		if (!empty($_folderName))
930
+		{
931
+			$fetchCounters = true;
932
+		}
837 933
 
838 934
 		// Check if it is called for refresh root
839 935
 		// then we need to reinitialized the index tree
@@ -845,7 +941,10 @@  discard block
 block discarded – undo
845 941
 		{
846 942
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
847 943
 		}
848
-		if (!is_null($_nodeID)) return $data;
944
+		if (!is_null($_nodeID))
945
+		{
946
+			return $data;
947
+		}
849 948
 		Etemplate\Widget\Tree::send_quote_json($data);
850 949
 	}
851 950
 
@@ -911,7 +1010,10 @@  discard block
 block discarded – undo
911 1010
 				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
912 1011
 			}
913 1012
 		}
914
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
1013
+		if (!is_array($lastFoldersUsedForMoveCont))
1014
+		{
1015
+			$lastFoldersUsedForMoveCont=array();
1016
+		}
915 1017
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
916 1018
 		{
917 1019
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
@@ -927,9 +1029,12 @@  discard block
 block discarded – undo
927 1029
 						$moveaction .= $lastFolderUsedForMoveCont;
928 1030
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
929 1031
 						//error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey);
930
-						if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1032
+						if ($this->mail_bo->folderExists($i))
1033
+						{
1034
+							// only 10 entries per mailaccount.Control this on setting the buffered folders
931 1035
 						{
932 1036
 							$fS['profileID'] = $this->mail_bo->profileID;
1037
+						}
933 1038
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
934 1039
 							$fS['shortDisplayName'] = $i;
935 1040
 							$moveactions[$moveaction] = $fS;
@@ -949,9 +1054,12 @@  discard block
 block discarded – undo
949 1054
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
950 1055
 				{
951 1056
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
952
-					if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1057
+					if (!empty($lastFolderUsedForMoveCont))
1058
+					{
1059
+						// only 10 entries per mailaccount.Control this on setting the buffered folders
953 1060
 					{
954 1061
 						$moveaction = 'move_'.$lastFolderUsedForMoveCont;
1062
+					}
955 1063
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
956 1064
 						$fS = array();
957 1065
 						$fS['profileID'] = $pid;
@@ -1054,7 +1162,9 @@  discard block
 block discarded – undo
1054 1162
 				'children' => $children,
1055 1163
 			);
1056 1164
 
1057
-		} else {
1165
+		}
1166
+		else
1167
+		{
1058 1168
 			$group++;
1059 1169
 		}
1060 1170
 
@@ -1330,7 +1440,10 @@  discard block
 block discarded – undo
1330 1440
 					$rows=array();
1331 1441
 					return 0;
1332 1442
 				}
1333
-				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1443
+				if (empty($folderName))
1444
+				{
1445
+					$query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1446
+				}
1334 1447
 			}
1335 1448
 		}
1336 1449
 		if (!isset($mail_ui))
@@ -1345,15 +1458,24 @@  discard block
 block discarded – undo
1345 1458
 				$rows=array();
1346 1459
 				return 0;
1347 1460
 			}
1348
-			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1461
+			if (empty($query['selectedFolder']))
1462
+			{
1463
+				$query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1464
+			}
1349 1465
 		}
1350 1466
 		//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
1351 1467
 		//Mail::$debugTimes=true;
1352
-		if (Mail::$debugTimes) $starttime = microtime(true);
1468
+		if (Mail::$debugTimes)
1469
+		{
1470
+			$starttime = microtime(true);
1471
+		}
1353 1472
 		//$query['search'] is the phrase in the searchbox
1354 1473
 
1355 1474
 		$mail_ui->mail_bo->restoreSessionData();
1356
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1475
+		if (isset($query['selectedFolder']))
1476
+		{
1477
+			$mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1478
+		}
1357 1479
 		$mail_ui->mail_bo->saveSessionData();
1358 1480
 
1359 1481
 		$sRToFetch = null;
@@ -1364,7 +1486,10 @@  discard block
 block discarded – undo
1364 1486
 			unset($app);
1365 1487
 		}
1366 1488
 		//save selected Folder to sessionData (mailbox)->currentFolder
1367
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1489
+		if (isset($query['selectedFolder']))
1490
+		{
1491
+			$mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1492
+		}
1368 1493
 		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1369 1494
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1370 1495
 		{
@@ -1397,8 +1522,16 @@  discard block
 block discarded – undo
1397 1522
 			}
1398 1523
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1399 1524
 			$cutoffdate = $cutoffdate2 = null;
1400
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1401
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1525
+			if ($query['startdate'])
1526
+			{
1527
+				$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
1528
+			}
1529
+			//SINCE, enddate
1530
+			if ($query['enddate'])
1531
+			{
1532
+				$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
1533
+			}
1534
+			//BEFORE, startdate
1402 1535
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1403 1536
 			$filter = array(
1404 1537
 				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -1407,15 +1540,24 @@  discard block
 block discarded – undo
1407 1540
 				'status' => 'any',
1408 1541
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1409 1542
 			);
1410
-			if ($query['enddate']||$query['startdate']) {
1543
+			if ($query['enddate']||$query['startdate'])
1544
+			{
1411 1545
 				$filter['range'] = "BETWEEN";
1412
-				if ($cutoffdate) {
1546
+				if ($cutoffdate)
1547
+				{
1413 1548
 					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1414
-					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1549
+					if (empty($cutoffdate2))
1550
+					{
1551
+						$filter['range'] = "SINCE";
1552
+					}
1415 1553
 				}
1416
-				if ($cutoffdate2) {
1554
+				if ($cutoffdate2)
1555
+				{
1417 1556
 					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1418
-					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1557
+					if (empty($cutoffdate))
1558
+					{
1559
+						$filter['range'] = "BEFORE";
1560
+					}
1419 1561
 				}
1420 1562
 			}
1421 1563
 		}
@@ -1468,7 +1610,10 @@  discard block
 block discarded – undo
1468 1610
 				$rowsFetched['messages'] = $_sR['count'];
1469 1611
 				$ids = $_sR['match']->ids;
1470 1612
 				// if $sR is false, something failed fundamentally
1471
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1613
+				if($reverse === true)
1614
+				{
1615
+					$ids = ($ids===false?array():array_reverse((array)$ids));
1616
+				}
1472 1617
 				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1473 1618
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1474 1619
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
@@ -1534,7 +1679,10 @@  discard block
 block discarded – undo
1534 1679
 				}
1535 1680
 				else
1536 1681
 				{
1537
-					if (!empty($v)) $sortResult['header'][] = array('uid'=>$v);
1682
+					if (!empty($v))
1683
+					{
1684
+						$sortResult['header'][] = array('uid'=>$v);
1685
+					}
1538 1686
 				}
1539 1687
 			}
1540 1688
 		}
@@ -1543,15 +1691,24 @@  discard block
 block discarded – undo
1543 1691
 			$sortResult = $sortResultwH;
1544 1692
 		}
1545 1693
 		$rowsFetched['rowsFetched'] = count($sortResult['header']);
1546
-		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1694
+		if (empty($rowsFetched['messages']))
1695
+		{
1696
+			$rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1697
+		}
1547 1698
 
1548 1699
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1549 1700
 		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1550
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1701
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE')
1702
+		{
1703
+			unset($cols[0]);
1704
+		}
1551 1705
 		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1552 1706
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1553 1707
 
1554
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1708
+		if (Mail::$debugTimes)
1709
+		{
1710
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1711
+		}
1555 1712
 		return $rowsFetched['messages'];
1556 1713
 	}
1557 1714
 
@@ -1653,7 +1810,10 @@  discard block
 block discarded – undo
1653 1810
 					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1654 1811
 					break;
1655 1812
 				default:
1656
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1813
+					if (isset($actions[$act]))
1814
+					{
1815
+						$actionsenabled[$act]=$actions[$act];
1816
+					}
1657 1817
 			}
1658 1818
 		}
1659 1819
 		unset($actionsenabled['drag_mail']);
@@ -1675,7 +1835,10 @@  discard block
 block discarded – undo
1675 1835
 	 */
1676 1836
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1677 1837
 	{
1678
-		if (Mail::$debugTimes) $starttime = microtime(true);
1838
+		if (Mail::$debugTimes)
1839
+		{
1840
+			$starttime = microtime(true);
1841
+		}
1679 1842
 		$rv = array();
1680 1843
 		$i=0;
1681 1844
 		foreach((array)$_headers as $header)
@@ -1688,17 +1851,50 @@  discard block
 block discarded – undo
1688 1851
 			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1689 1852
 
1690 1853
 			$flags = "";
1691
-			if(!empty($header['recent'])) $flags .= "R";
1692
-			if(!empty($header['flagged'])) $flags .= "F";
1693
-			if(!empty($header['answered'])) $flags .= "A";
1694
-			if(!empty($header['forwarded'])) $flags .= "W";
1695
-			if(!empty($header['deleted'])) $flags .= "D";
1696
-			if(!empty($header['seen'])) $flags .= "S";
1697
-			if(!empty($header['label1'])) $flags .= "1";
1698
-			if(!empty($header['label2'])) $flags .= "2";
1699
-			if(!empty($header['label3'])) $flags .= "3";
1700
-			if(!empty($header['label4'])) $flags .= "4";
1701
-			if(!empty($header['label5'])) $flags .= "5";
1854
+			if(!empty($header['recent']))
1855
+			{
1856
+				$flags .= "R";
1857
+			}
1858
+			if(!empty($header['flagged']))
1859
+			{
1860
+				$flags .= "F";
1861
+			}
1862
+			if(!empty($header['answered']))
1863
+			{
1864
+				$flags .= "A";
1865
+			}
1866
+			if(!empty($header['forwarded']))
1867
+			{
1868
+				$flags .= "W";
1869
+			}
1870
+			if(!empty($header['deleted']))
1871
+			{
1872
+				$flags .= "D";
1873
+			}
1874
+			if(!empty($header['seen']))
1875
+			{
1876
+				$flags .= "S";
1877
+			}
1878
+			if(!empty($header['label1']))
1879
+			{
1880
+				$flags .= "1";
1881
+			}
1882
+			if(!empty($header['label2']))
1883
+			{
1884
+				$flags .= "2";
1885
+			}
1886
+			if(!empty($header['label3']))
1887
+			{
1888
+				$flags .= "3";
1889
+			}
1890
+			if(!empty($header['label4']))
1891
+			{
1892
+				$flags .= "4";
1893
+			}
1894
+			if(!empty($header['label5']))
1895
+			{
1896
+				$flags .= "5";
1897
+			}
1702 1898
 
1703 1899
 			$data["status"] = "<span class=\"status_img\"></span>";
1704 1900
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
@@ -1706,41 +1902,53 @@  discard block
 block discarded – undo
1706 1902
 			// the css for this row
1707 1903
 			$is_recent=false;
1708 1904
 			$css_styles = array("mail");
1709
-			if ($header['deleted']) {
1905
+			if ($header['deleted'])
1906
+			{
1710 1907
 				$css_styles[] = 'deleted';
1711 1908
 			}
1712
-			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1909
+			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded']))
1910
+			{
1713 1911
 				$css_styles[] = 'recent';
1714 1912
 				$is_recent=true;
1715 1913
 			}
1716
-			if ($header['priority'] < 3) {
1914
+			if ($header['priority'] < 3)
1915
+			{
1717 1916
 				$css_styles[] = 'prio_high';
1718 1917
 			}
1719
-			if ($header['flagged']) {
1918
+			if ($header['flagged'])
1919
+			{
1720 1920
 				$css_styles[] = 'flagged';
1721 1921
 			}
1722
-			if (!$header['seen']) {
1922
+			if (!$header['seen'])
1923
+			{
1723 1924
 				$css_styles[] = 'unseen'; // different status image for recent // solved via css !important
1724 1925
 			}
1725
-			if ($header['answered']) {
1926
+			if ($header['answered'])
1927
+			{
1726 1928
 				$css_styles[] = 'replied';
1727 1929
 			}
1728
-			if ($header['forwarded']) {
1930
+			if ($header['forwarded'])
1931
+			{
1729 1932
 				$css_styles[] = 'forwarded';
1730 1933
 			}
1731
-			if ($header['label1']) {
1934
+			if ($header['label1'])
1935
+			{
1732 1936
 				$css_styles[] = 'labelone';
1733 1937
 			}
1734
-			if ($header['label2']) {
1938
+			if ($header['label2'])
1939
+			{
1735 1940
 				$css_styles[] = 'labeltwo';
1736 1941
 			}
1737
-			if ($header['label3']) {
1942
+			if ($header['label3'])
1943
+			{
1738 1944
 				$css_styles[] = 'labelthree';
1739 1945
 			}
1740
-			if ($header['label4']) {
1946
+			if ($header['label4'])
1947
+			{
1741 1948
 				$css_styles[] = 'labelfour';
1742 1949
 			}
1743
-			if ($header['label5']) {
1950
+			if ($header['label5'])
1951
+			{
1744 1952
 				$css_styles[] = 'labelfive';
1745 1953
 			}
1746 1954
 
@@ -1757,10 +1965,13 @@  discard block
 block discarded – undo
1757 1965
 				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1758 1966
 				// curly brackets get messed up by the template!
1759 1967
 
1760
-				if (!empty($header['subject'])) {
1968
+				if (!empty($header['subject']))
1969
+				{
1761 1970
 					// make the subject shorter if it is to long
1762 1971
 					$subject = $header['subject'];
1763
-				} else {
1972
+				}
1973
+				else
1974
+				{
1764 1975
 					$subject = '('. lang('no subject') .')';
1765 1976
 				}
1766 1977
 
@@ -1802,15 +2013,22 @@  discard block
 block discarded – undo
1802 2013
 					}
1803 2014
 
1804 2015
 					$attachmentFlag = $image;
1805
-				} else {
2016
+				}
2017
+				else
2018
+				{
1806 2019
 					$attachmentFlag ='&nbsp;';
1807 2020
 				}
1808 2021
 				// show priority flag
1809
-				if ($header['priority'] < 3) {
2022
+				if ($header['priority'] < 3)
2023
+				{
1810 2024
 					 $image = Api\Html::image('mail','prio_high');
1811
-				} elseif ($header['priority'] > 3) {
2025
+				}
2026
+				elseif ($header['priority'] > 3)
2027
+				{
1812 2028
 					$image = Api\Html::image('mail','prio_low');
1813
-				} else {
2029
+				}
2030
+				else
2031
+				{
1814 2032
 					$image = '';
1815 2033
 				}
1816 2034
 				// show a flag for flagged messages
@@ -1852,26 +2070,53 @@  discard block
 block discarded – undo
1852 2070
 			}
1853 2071
 
1854 2072
 			if (in_array("size", $cols))
1855
-				$data["size"] = $header['size']; /// size
2073
+			{
2074
+							$data["size"] = $header['size'];
2075
+			}
2076
+			/// size
1856 2077
 
1857 2078
 			$data["class"] = implode(' ', $css_styles);
1858 2079
 			//translate style-classes back to flags
1859 2080
 			$data['flags'] = Array();
1860
-			if ($header['seen']) $data["flags"]['read'] = 'read';
1861
-			foreach ($css_styles as &$flag) {
2081
+			if ($header['seen'])
2082
+			{
2083
+				$data["flags"]['read'] = 'read';
2084
+			}
2085
+			foreach ($css_styles as &$flag)
2086
+			{
1862 2087
 				if ($flag!='mail')
1863 2088
 				{
1864
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1865
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1866
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1867
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1868
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1869
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1870
-					else $data["flags"][$flag] = $flag;
2089
+					if ($flag=='labelone')
2090
+					{
2091
+$data["flags"]['label1'] = 'label1';}
2092
+					elseif ($flag=='labeltwo')
2093
+					{
2094
+$data["flags"]['label2'] = 'label2';}
2095
+					elseif ($flag=='labelthree')
2096
+					{
2097
+$data["flags"]['label3'] = 'label3';}
2098
+					elseif ($flag=='labelfour')
2099
+					{
2100
+$data["flags"]['label4'] = 'label4';}
2101
+					elseif ($flag=='labelfive')
2102
+					{
2103
+$data["flags"]['label5'] = 'label5';}
2104
+					elseif ($flag=='unseen')
2105
+					{
2106
+unset($data["flags"]['read']);}
2107
+					else {
2108
+						$data["flags"][$flag] = $flag;
2109
+					}
1871 2110
 				}
1872 2111
 			}
1873
-			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1874
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2112
+			if ($header['disposition-notification-to'])
2113
+			{
2114
+				$data['dispositionnotificationto'] = $header['disposition-notification-to'];
2115
+			}
2116
+			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto']))
2117
+			{
2118
+				unset($data['dispositionnotificationto']);
2119
+			}
1875 2120
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1876 2121
 			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1877 2122
 			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
@@ -1881,7 +2126,10 @@  discard block
 block discarded – undo
1881 2126
 			$rv[] = $data;
1882 2127
 			//error_log(__METHOD__.__LINE__.array2string($data));
1883 2128
 		}
1884
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2129
+		if (Mail::$debugTimes)
2130
+		{
2131
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2132
+		}
1885 2133
 
1886 2134
 		// ToDo: call this ONLY if labels change
1887 2135
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1896,8 +2144,14 @@  discard block
 block discarded – undo
1896 2144
 	 */
1897 2145
 	function displayHeader()
1898 2146
 	{
1899
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1900
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2147
+		if(isset($_GET['id']))
2148
+		{
2149
+			$rowID	= $_GET['id'];
2150
+		}
2151
+		if(isset($_GET['part']))
2152
+		{
2153
+			$partID = $_GET['part'];
2154
+		}
1901 2155
 
1902 2156
 		$hA = self::splitRowID($rowID);
1903 2157
 		$uid = $hA['msgUID'];
@@ -1921,7 +2175,8 @@  discard block
 block discarded – undo
1921 2175
 		$rawheaders 	= "";
1922 2176
 		// create it new, with good line breaks
1923 2177
 		reset($newRawHeaders);
1924
-		while(list($key,$value) = @each($newRawHeaders)) {
2178
+		while(list($key,$value) = @each($newRawHeaders))
2179
+		{
1925 2180
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1926 2181
 		}
1927 2182
 
@@ -1944,12 +2199,24 @@  discard block
 block discarded – undo
1944 2199
 	 */
1945 2200
 	function displayMessage($_requesteddata = null)
1946 2201
 	{
1947
-		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2202
+		if (is_null($_requesteddata))
2203
+		{
2204
+			$_requesteddata = $_GET;
2205
+		}
1948 2206
 
1949 2207
 		$preventRedirect=false;
1950
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1951
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1952
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2208
+		if(isset($_requesteddata['id']))
2209
+		{
2210
+			$rowID	= $_requesteddata['id'];
2211
+		}
2212
+		if(isset($_requesteddata['part']))
2213
+		{
2214
+			$partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2215
+		}
2216
+		if(isset($_requesteddata['mode']))
2217
+		{
2218
+			$preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2219
+		}
1953 2220
 
1954 2221
 		$hA = self::splitRowID($rowID);
1955 2222
 		$uid = $hA['msgUID'];
@@ -1962,8 +2229,14 @@  discard block
 block discarded – undo
1962 2229
 			$this->changeProfile($icServerID);
1963 2230
 		}
1964 2231
 		$htmlOptions = $this->mail_bo->htmlOptions;
1965
-		if (!empty($_requesteddata['tryastext'])) $htmlOptions  = "only_if_no_text";
1966
-		if (!empty($_requesteddata['tryashtml'])) $htmlOptions  = "always_display";
2232
+		if (!empty($_requesteddata['tryastext']))
2233
+		{
2234
+			$htmlOptions  = "only_if_no_text";
2235
+		}
2236
+		if (!empty($_requesteddata['tryashtml']))
2237
+		{
2238
+			$htmlOptions  = "always_display";
2239
+		}
1967 2240
 
1968 2241
 		//error_log(__METHOD__.__LINE__.array2string($hA));
1969 2242
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
@@ -1987,14 +2260,20 @@  discard block
 block discarded – undo
1987 2260
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1988 2261
 			Framework::message($e->getMessage(), 'error');
1989 2262
 		}
1990
-		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2263
+		if (!empty($uid))
2264
+		{
2265
+			$this->mail_bo->getFlags($uid);
2266
+		}
1991 2267
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1992 2268
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1993 2269
 		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1994 2270
 		$fetchEmbeddedImages = false;
1995 2271
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1996 2272
 		// we do NOT want to see those, that are embedded in the list of attachments
1997
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2273
+		if ($htmlOptions !='always_display')
2274
+		{
2275
+			$fetchEmbeddedImages = true;
2276
+		}
1998 2277
 		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1999 2278
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2000 2279
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
@@ -2010,11 +2289,17 @@  discard block
 block discarded – undo
2010 2289
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2011 2290
 
2012 2291
 		// Set up data for taglist widget(s)
2013
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2292
+		if ($envelope['FROM']==$envelope['SENDER'])
2293
+		{
2294
+			unset($envelope['SENDER']);
2295
+		}
2014 2296
 		$sel_options = array();
2015 2297
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2016 2298
 		{
2017
-			if (!isset($envelope[$field])) continue;
2299
+			if (!isset($envelope[$field]))
2300
+			{
2301
+				continue;
2302
+			}
2018 2303
 			foreach($envelope[$field] as $field_data)
2019 2304
 			{
2020 2305
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
@@ -2028,7 +2313,10 @@  discard block
 block discarded – undo
2028 2313
 		}
2029 2314
 		$actionsenabled = $this->getDisplayToolbarActions();
2030 2315
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2031
-		if (empty($subject)) $subject = lang('no subject');
2316
+		if (empty($subject))
2317
+		{
2318
+			$subject = lang('no subject');
2319
+		}
2032 2320
 		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2033 2321
 		// Send mail ID so we can use it for actions
2034 2322
 		$content['mail_id'] = $rowID;
@@ -2039,8 +2327,14 @@  discard block
 block discarded – undo
2039 2327
 		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2040 2328
 		$content['mail_displaysubject'] = $subject;
2041 2329
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2042
-		if (!empty($partID)) $linkData['_partID']=$partID;
2043
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2330
+		if (!empty($partID))
2331
+		{
2332
+			$linkData['_partID']=$partID;
2333
+		}
2334
+		if ($htmlOptions != $this->mail_bo->htmlOptions)
2335
+		{
2336
+			$linkData['_htmloptions']=$htmlOptions;
2337
+		}
2044 2338
 		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2045 2339
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2046 2340
 		$content['mail_id']=$rowID;
@@ -2108,7 +2402,8 @@  discard block
 block discarded – undo
2108 2402
 	{
2109 2403
 		$attachmentHTMLBlock='';
2110 2404
 		$attachmentHTML = array();
2111
-		if (is_array($attachments) && count($attachments) > 0) {
2405
+		if (is_array($attachments) && count($attachments) > 0)
2406
+		{
2112 2407
 			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2113 2408
 			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2114 2409
 
@@ -2118,7 +2413,10 @@  discard block
 block discarded – undo
2118 2413
 				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2119 2414
 				//error_log(array2string($value));
2120 2415
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2121
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2416
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM'))
2417
+				{
2418
+					$value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2419
+				}
2122 2420
 				$attachmentHTML[$key]['type']=$value['mimeType'];
2123 2421
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2124 2422
 				$hA = self::splitRowID($rowID);
@@ -2161,8 +2459,15 @@  discard block
 block discarded – undo
2161 2459
 						$sfxMimeType = $value['mimeType'];
2162 2460
 						$buff = explode('.',$value['name']);
2163 2461
 						$suffix = '';
2164
-						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2165
-						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2462
+						if (is_array($buff))
2463
+						{
2464
+							$suffix = array_pop($buff);
2465
+						}
2466
+						// take the last extension to check with ext2mime
2467
+						if (!empty($suffix))
2468
+						{
2469
+							$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2470
+						}
2166 2471
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2167 2472
 						{
2168 2473
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2331,9 +2636,12 @@  discard block
 block discarded – undo
2331 2636
 	function quotaDisplay($_usage, $_limit)
2332 2637
 	{
2333 2638
 
2334
-		if($_limit == 0) {
2639
+		if($_limit == 0)
2640
+		{
2335 2641
 			$quotaPercent=100;
2336
-		} else {
2642
+		}
2643
+		else
2644
+		{
2337 2645
 			$quotaPercent=round(($_usage*100)/$_limit);
2338 2646
 		}
2339 2647
 
@@ -2341,22 +2649,33 @@  discard block
 block discarded – undo
2341 2649
 		$quotaUsage=Mail::show_readable_size($_usage*1024);
2342 2650
 
2343 2651
 
2344
-		if($quotaPercent > 90 && $_limit>0) {
2652
+		if($quotaPercent > 90 && $_limit>0)
2653
+		{
2345 2654
 			$quotaBG='mail-index_QuotaRed';
2346
-		} elseif($quotaPercent > 80 && $_limit>0) {
2655
+		}
2656
+		elseif($quotaPercent > 80 && $_limit>0)
2657
+		{
2347 2658
 			$quotaBG='mail-index_QuotaYellow';
2348
-		} else {
2659
+		}
2660
+		else
2661
+		{
2349 2662
 			$quotaBG='mail-index_QuotaGreen';
2350 2663
 		}
2351 2664
 
2352
-		if($_limit > 0) {
2665
+		if($_limit > 0)
2666
+		{
2353 2667
 			$quotaText = $quotaUsage .'/'.$quotaLimit;
2354
-		} else {
2668
+		}
2669
+		else
2670
+		{
2355 2671
 			$quotaText = $quotaUsage;
2356 2672
 		}
2357 2673
 
2358
-		if($quotaPercent > 50) {
2359
-		} else {
2674
+		if($quotaPercent > 50)
2675
+		{
2676
+		}
2677
+		else
2678
+		{
2360 2679
 		}
2361 2680
 		$quota['class'] = $quotaBG;
2362 2681
 		$quota['text'] = lang('Quota: %1',$quotaText);
@@ -2374,7 +2693,10 @@  discard block
 block discarded – undo
2374 2693
 		$uid	= $_GET['uid'];
2375 2694
 		$cid	= base64_decode($_GET['cid']);
2376 2695
 		$partID = urldecode($_GET['partID']);
2377
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2696
+		if (!empty($_GET['mailbox']))
2697
+		{
2698
+			$mailbox  = base64_decode($_GET['mailbox']);
2699
+		}
2378 2700
 
2379 2701
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2380 2702
 		$this->mail_bo->reopen($mailbox);
@@ -2406,7 +2728,10 @@  discard block
 block discarded – undo
2406 2728
 
2407 2729
 	function getAttachment()
2408 2730
 	{
2409
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2731
+		if(isset($_GET['id']))
2732
+		{
2733
+			$rowID	= $_GET['id'];
2734
+		}
2410 2735
 
2411 2736
 		$hA = self::splitRowID($rowID);
2412 2737
 		$uid = $hA['msgUID'];
@@ -2439,10 +2764,20 @@  discard block
 block discarded – undo
2439 2764
 				$sfxMimeType = $attachment['type'];
2440 2765
 				$buff = explode('.',$attachment['filename']);
2441 2766
 				$suffix = '';
2442
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2443
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2767
+				if (is_array($buff))
2768
+				{
2769
+					$suffix = array_pop($buff);
2770
+				}
2771
+				// take the last extension to check with ext2mime
2772
+				if (!empty($suffix))
2773
+				{
2774
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2775
+				}
2444 2776
 				$attachment['type'] = $sfxMimeType;
2445
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2777
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2778
+				{
2779
+					$attachment['type'] = strtoupper($sfxMimeType);
2780
+				}
2446 2781
 			}
2447 2782
 			//error_log(__METHOD__.print_r($attachment,true));
2448 2783
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2451,7 +2786,10 @@  discard block
 block discarded – undo
2451 2786
 				$calendar_ical = new calendar_ical();
2452 2787
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2453 2788
 				//error_log(__METHOD__.array2string($eventid));
2454
-				if (!$eventid) $eventid = -1;
2789
+				if (!$eventid)
2790
+				{
2791
+					$eventid = -1;
2792
+				}
2455 2793
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2456 2794
 				//error_log(__METHOD__.$event);
2457 2795
 				if ((int)$event > 0)
@@ -2477,7 +2815,10 @@  discard block
 block discarded – undo
2477 2815
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2478 2816
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2479 2817
 				}
2480
-				if (!$contact) $contact = null;
2818
+				if (!$contact)
2819
+				{
2820
+					$contact = null;
2821
+				}
2481 2822
 				// if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO))
2482 2823
 				if ($contact || count($vcard)>2)
2483 2824
 				{
@@ -2511,9 +2852,18 @@  discard block
 block discarded – undo
2511 2852
 	function saveMessage()
2512 2853
 	{
2513 2854
 		$display = false;
2514
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2515
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2516
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2855
+		if(isset($_GET['id']))
2856
+		{
2857
+			$rowID	= $_GET['id'];
2858
+		}
2859
+		if(isset($_GET['part']))
2860
+		{
2861
+			$partID = $_GET['part'];
2862
+		}
2863
+		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager'))
2864
+		{
2865
+			$display	= $_GET['location'];
2866
+		}
2517 2867
 
2518 2868
 		$hA = self::splitRowID($rowID);
2519 2869
 		$uid = $hA['msgUID'];
@@ -2602,7 +2952,10 @@  discard block
 block discarded – undo
2602 2952
 			{
2603 2953
 				$succeeded = true;
2604 2954
 			}
2605
-			if ($fp) fclose($fp);
2955
+			if ($fp)
2956
+			{
2957
+				fclose($fp);
2958
+			}
2606 2959
 			if ($succeeded)
2607 2960
 			{
2608 2961
 				unset($headers['SUBJECT']);//already in filename
@@ -2652,7 +3005,8 @@  discard block
 block discarded – undo
2652 3005
 		 *
2653 3006
 		 * @return array an array of parameters
2654 3007
 		 */
2655
-		$getParams = function ($id) {
3008
+		$getParams = function ($id)
3009
+		{
2656 3010
 			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2657 3011
 			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2658 3012
 			$hA = mail_ui::splitRowID($lId);
@@ -2688,7 +3042,10 @@  discard block
 block discarded – undo
2688 3042
 		{
2689 3043
 			$params = $getParams($id);
2690 3044
 			// when downloading a single file, name is not set
2691
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
3045
+			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload)
3046
+			{
3047
+				$params['name'] = $_GET['name'];
3048
+			}
2692 3049
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2693 3050
 			{
2694 3051
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2701,7 +3058,10 @@  discard block
 block discarded – undo
2701 3058
 				// Try to find the right content for file id
2702 3059
 				foreach ($attachments as $key => $val)
2703 3060
 				{
2704
-					if ($key == $params['is_winmail']) $attachment = $val;
3061
+					if ($key == $params['is_winmail'])
3062
+					{
3063
+						$attachment = $val;
3064
+					}
2705 3065
 				}
2706 3066
 			}
2707 3067
 			else
@@ -2748,7 +3108,10 @@  discard block
 block discarded – undo
2748 3108
 	{
2749 3109
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2750 3110
 		// First, get all attachment IDs
2751
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
3111
+		if(isset($_GET['id']))
3112
+		{
3113
+			$message_id	= $_GET['id'];
3114
+		}
2752 3115
 		//error_log(__METHOD__.__LINE__.$message_id);
2753 3116
 		$rememberServerID = $this->mail_bo->profileID;
2754 3117
 		if(!is_numeric($message_id))
@@ -2775,7 +3138,10 @@  discard block
 block discarded – undo
2775 3138
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2776 3139
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2777 3140
 		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2778
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
3141
+		if(Vfs::is_dir($temp_path))
3142
+		{
3143
+			Vfs::remove ($temp_path);
3144
+		}
2779 3145
 
2780 3146
 		// Add subject to path, so it gets used as the file name
2781 3147
 		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
@@ -2800,7 +3166,10 @@  discard block
 block discarded – undo
2800 3166
 				foreach ($tnefAttachments as $key => $val)
2801 3167
 				{
2802 3168
 					error_log(__METHOD__.' winmail = '.$key);
2803
-					if ($key == $file['is_winmail']) $attachment = $val;
3169
+					if ($key == $file['is_winmail'])
3170
+					{
3171
+						$attachment = $val;
3172
+					}
2804 3173
 				}
2805 3174
 			}
2806 3175
 			else
@@ -2808,7 +3177,10 @@  discard block
 block discarded – undo
2808 3177
 				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2809 3178
 			}
2810 3179
 			$success=true;
2811
-			if (empty($file['filename'])) $file['filename'] = $file['name'];
3180
+			if (empty($file['filename']))
3181
+			{
3182
+				$file['filename'] = $file['name'];
3183
+			}
2812 3184
 			if(in_array($path.$file['filename'], $file_list))
2813 3185
 			{
2814 3186
 				$dupe_count[$path.$file['filename']]++;
@@ -2822,8 +3194,14 @@  discard block
 block discarded – undo
2822 3194
 				$success=false;
2823 3195
 				Framework::message("Unable to zip {$file['filename']}",'error');
2824 3196
 			}
2825
-			if ($success) $file_list[] = $path.$file['filename'];
2826
-			if ($fp) fclose($fp);
3197
+			if ($success)
3198
+			{
3199
+				$file_list[] = $path.$file['filename'];
3200
+			}
3201
+			if ($fp)
3202
+			{
3203
+				fclose($fp);
3204
+			}
2827 3205
 		}
2828 3206
 		$this->mail_bo->closeConnection();
2829 3207
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2850,7 +3228,10 @@  discard block
 block discarded – undo
2850 3228
 		$this->uid = $uid;
2851 3229
 		$this->partID = $partID;
2852 3230
 		$bufferHtmlOptions = $this->mail_bo->htmlOptions;
2853
-		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
3231
+		if (empty($htmlOptions))
3232
+		{
3233
+			$htmlOptions = $this->mail_bo->htmlOptions;
3234
+		}
2854 3235
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2855 3236
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2856 3237
 		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
@@ -2914,10 +3295,16 @@  discard block
 block discarded – undo
2914 3295
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2915 3296
 
2916 3297
 		$EndBody = '</td></tr></table></div>';
2917
-		if ($fullPageTags) $EndBody .= "</body></html>";
2918
-		if ($print)	{
3298
+		if ($fullPageTags)
3299
+		{
3300
+			$EndBody .= "</body></html>";
3301
+		}
3302
+		if ($print)
3303
+		{
2919 3304
 			print $BeginBody. $body .$EndBody;
2920
-		} else {
3305
+		}
3306
+		else
3307
+		{
2921 3308
 			return $BeginBody. $body .$EndBody;
2922 3309
 		}
2923 3310
 	}
@@ -2933,9 +3320,14 @@  discard block
 block discarded – undo
2933 3320
 		$body = '';
2934 3321
 
2935 3322
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2936
-		if (empty($bodyParts)) return "";
2937
-		foreach((array)$bodyParts as $singleBodyPart) {
2938
-			if (!isset($singleBodyPart['body'])) {
3323
+		if (empty($bodyParts))
3324
+		{
3325
+			return "";
3326
+		}
3327
+		foreach((array)$bodyParts as $singleBodyPart)
3328
+		{
3329
+			if (!isset($singleBodyPart['body']))
3330
+			{
2939 3331
 				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2940 3332
 				$body .= $singleBodyPart['body'];
2941 3333
 				continue;
@@ -2946,7 +3338,8 @@  discard block
 block discarded – undo
2946 3338
 				$body .= '';
2947 3339
 				continue;
2948 3340
 			}
2949
-			if(!empty($body)) {
3341
+			if(!empty($body))
3342
+			{
2950 3343
 				$body .= '<hr style="border:dotted 1px silver;">';
2951 3344
 			}
2952 3345
 			//error_log($singleBodyPart['body']);
@@ -2984,16 +3377,25 @@  discard block
 block discarded – undo
2984 3377
 				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2985 3378
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2986 3379
 				// if empty and charset is utf8 try sanitizing the string in question
2987
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3380
+				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8')
3381
+				{
3382
+					$newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3383
+				}
2988 3384
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2989
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3385
+				if (empty($newBody))
3386
+				{
3387
+					$newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3388
+				}
2990 3389
 
2991 3390
 				// search http[s] links and make them as links available again
2992 3391
 				// to understand what's going on here, have a look at
2993 3392
 				// http://www.php.net/manual/en/function.preg-replace.php
2994 3393
 
2995 3394
 				// create links for websites
2996
-				if ($modifyURI) $newBody = Api\Html::activate_links($newBody);
3395
+				if ($modifyURI)
3396
+				{
3397
+					$newBody = Api\Html::activate_links($newBody);
3398
+				}
2997 3399
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2998 3400
 				// redirect links for websites if you use no cookies
2999 3401
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -3035,10 +3437,13 @@  discard block
 block discarded – undo
3035 3437
 					{
3036 3438
 						$newBody = $cleaned;
3037 3439
 					}
3038
-					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3440
+					if (!$preserveHTML)
3441
+					{
3442
+						// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3039 3443
 					{
3040 3444
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3041 3445
 						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3446
+					}
3042 3447
 						if ($matches[2])
3043 3448
 						{
3044 3449
 							$hasOther = true;
@@ -3060,7 +3465,10 @@  discard block
 block discarded – undo
3060 3465
 					// as we switched off HTMLaweds tidy functionality
3061 3466
 					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3062 3467
 					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3063
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3468
+					if ($hasOther && $preserveHTML)
3469
+					{
3470
+						$newBody = $matches[1]. $newBody. $matches[3];
3471
+					}
3064 3472
 					$alreadyHtmlLawed=true;
3065 3473
 				}
3066 3474
 				// do the cleanup, set for the use of purifier
@@ -3165,7 +3573,10 @@  discard block
 block discarded – undo
3165 3573
 		*/
3166 3574
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3167 3575
 		{
3168
-			if (!$_type)	return false;
3576
+			if (!$_type)
3577
+			{
3578
+				return false;
3579
+			}
3169 3580
 			$CID = '';
3170 3581
 			// Build up matches according to selected type
3171 3582
 			switch ($_type)
@@ -3208,9 +3619,12 @@  discard block
 block discarded – undo
3208 3619
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
3209 3620
 
3210 3621
 							// only use data uri for "smaller" images, as otherwise the first display of the mail takes to long
3211
-							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)	// msie=8 allows max 32k data uris
3622
+							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)
3623
+							{
3624
+								// msie=8 allows max 32k data uris
3212 3625
 							{
3213 3626
 								$bo->fetchPartContents($_uid, $attachment);
3627
+							}
3214 3628
 								$cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents());
3215 3629
 							}
3216 3630
 							else
@@ -3282,7 +3696,10 @@  discard block
 block discarded – undo
3282 3696
 			}
3283 3697
 			$destination = $content['FOLDER'][0];
3284 3698
 
3285
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3699
+			if (stripos($destination,self::$delimiter)!==false)
3700
+			{
3701
+				list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3702
+			}
3286 3703
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3287 3704
 			{
3288 3705
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3307,14 +3724,26 @@  discard block
 block discarded – undo
3307 3724
 			if (!$importFailed)
3308 3725
 			{
3309 3726
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3310
-				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3727
+				if ($width > 0 && $height > 0)
3728
+				{
3729
+					Api\Json\Response::get()->call('resizeTo', $width, $height);
3730
+				}
3311 3731
 				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3312 3732
 				return;
3313 3733
 			}
3314 3734
 		}
3315
-		if (!is_array($content)) $content = array();
3316
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3317
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3735
+		if (!is_array($content))
3736
+		{
3737
+			$content = array();
3738
+		}
3739
+		if (empty($content['FOLDER']))
3740
+		{
3741
+			$content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3742
+		}
3743
+		if (!empty($content['FOLDER']))
3744
+		{
3745
+			$sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3746
+		}
3318 3747
 
3319 3748
 		$etpl = new Etemplate('mail.importMessage');
3320 3749
 		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
@@ -3334,7 +3763,10 @@  discard block
 block discarded – undo
3334 3763
 	{
3335 3764
 		$importfailed = false;
3336 3765
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
3337
-		if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name'];
3766
+		if (empty($_formData['file']))
3767
+		{
3768
+			$_formData['file'] = $_formData['tmp_name'];
3769
+		}
3338 3770
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3339 3771
 		try
3340 3772
 		{
@@ -3365,10 +3797,14 @@  discard block
 block discarded – undo
3365 3797
 				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3366 3798
 			}
3367 3799
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3368
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3800
+			if($_folder=='INBOX'.$delimiter)
3801
+			{
3802
+				$_folder='INBOX';
3803
+			}
3369 3804
 			if ($importfailed === false)
3370 3805
 			{
3371
-				if ($this->mail_bo->folderExists($_folder,true)) {
3806
+				if ($this->mail_bo->folderExists($_folder,true))
3807
+				{
3372 3808
 					try
3373 3809
 					{
3374 3810
 						$messageUid = $this->mail_bo->appendMessage($_folder,
@@ -3429,7 +3865,10 @@  discard block
 block discarded – undo
3429 3865
 	 */
3430 3866
 	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3431 3867
 	{
3432
-		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3868
+		if (empty($formData))
3869
+		{
3870
+			if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3871
+		}
3433 3872
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
3434 3873
 		$draftFolder = $this->mail_bo->getDraftFolder(false);
3435 3874
 		$importID = Mail::getRandomString();
@@ -3443,15 +3882,26 @@  discard block
 block discarded – undo
3443 3882
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3444 3883
 		{
3445 3884
 			$buff = explode('/',$formData['file']);
3446
-			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3885
+			if (is_array($buff))
3886
+			{
3887
+				$formData['name'] = array_pop($buff);
3888
+			}
3889
+			// take the last part as name
3447 3890
 		}
3448 3891
 		// type should be set to meet the requirements of checkFileBasics
3449 3892
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3450 3893
 		{
3451 3894
 			$buff = explode('.',$formData['file']);
3452 3895
 			$suffix = '';
3453
-			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3454
-			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3896
+			if (is_array($buff))
3897
+			{
3898
+				$suffix = array_pop($buff);
3899
+			}
3900
+			// take the last extension to check with ext2mime
3901
+			if (!empty($suffix))
3902
+			{
3903
+				$formData['type'] = Api\MimeMagic::ext2mime($suffix);
3904
+			}
3455 3905
 		}
3456 3906
 		// size should be set to meet the requirements of checkFileBasics
3457 3907
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3494,17 +3944,35 @@  discard block
 block discarded – undo
3494 3944
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3495 3945
 	{
3496 3946
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3497
-		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3498
-		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3499
-		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3500
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3501
-		if (empty($_messageID)) return "";
3947
+		if (!$_messageID && !empty($_GET['_messageID']))
3948
+		{
3949
+			$_messageID = $_GET['_messageID'];
3950
+		}
3951
+		if (!$_partID && !empty($_GET['_partID']))
3952
+		{
3953
+			$_partID = $_GET['_partID'];
3954
+		}
3955
+		if (!$_htmloptions && !empty($_GET['_htmloptions']))
3956
+		{
3957
+			$_htmloptions = $_GET['_htmloptions'];
3958
+		}
3959
+		if(Mail::$debug)
3960
+		{
3961
+			error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3962
+		}
3963
+		if (empty($_messageID))
3964
+		{
3965
+			return "";
3966
+		}
3502 3967
 		$uidA = self::splitRowID($_messageID);
3503 3968
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
3504 3969
 		$messageID = $uidA['msgUID'];
3505 3970
 		$icServerID = $uidA['profileID'];
3506 3971
 		//something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled
3507
-		if (empty($messageID)) return "";
3972
+		if (empty($messageID))
3973
+		{
3974
+			return "";
3975
+		}
3508 3976
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
3509 3977
 		{
3510 3978
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3537,7 +4005,11 @@  discard block
 block discarded – undo
3537 4005
 				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3538 4006
 				if (is_numeric($profileID))
3539 4007
 				{
3540
-					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
4008
+					if ($profileID != $this->mail_bo->profileID)
4009
+					{
4010
+						continue;
4011
+					}
4012
+					// only current connection
3541 4013
 					if ($folderName)
3542 4014
 					{
3543 4015
 						try
@@ -3548,7 +4020,10 @@  discard block
 block discarded – undo
3548 4020
 						{
3549 4021
 							continue;
3550 4022
 						}
3551
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
4023
+						if (in_array($fS['shortDisplayName'],Mail::$autoFolders))
4024
+						{
4025
+							$fS['shortDisplayName']=lang($fS['shortDisplayName']);
4026
+						}
3552 4027
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3553 4028
 						if ($fS['unseen'])
3554 4029
 						{
@@ -3589,7 +4064,11 @@  discard block
 block discarded – undo
3589 4064
 			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3590 4065
 			if (is_numeric($profileID))
3591 4066
 			{
3592
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4067
+				if ($profileID != $this->mail_bo->profileID)
4068
+				{
4069
+					return;
4070
+				}
4071
+				// only current connection
3593 4072
 				$del = $this->mail_bo->getHierarchyDelimiter(false);
3594 4073
 				//$del = $prefix = '';
3595 4074
 				//$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -3629,7 +4108,10 @@  discard block
 block discarded – undo
3629 4108
 				$nA = explode($del,$_newName);
3630 4109
 
3631 4110
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3632
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4111
+				if (!!empty($parentFolderName))
4112
+				{
4113
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
4114
+				}
3633 4115
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3634 4116
 
3635 4117
 				$this->mail_bo->reopen('INBOX');
@@ -3650,9 +4132,15 @@  discard block
 block discarded – undo
3650 4132
 							$errorMessage .= $error;
3651 4133
 						}
3652 4134
 					}
3653
-					if ($c==count($nA)) $created=true;
4135
+					if ($c==count($nA))
4136
+					{
4137
+						$created=true;
4138
+					}
4139
+				}
4140
+				if (!empty($parentName))
4141
+				{
4142
+					$this->mail_bo->reopen($parentName);
3654 4143
 				}
3655
-				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3656 4144
 			}
3657 4145
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3658 4146
 			if ($created===true)
@@ -3688,7 +4176,10 @@  discard block
 block discarded – undo
3688 4176
 	 */
3689 4177
 	function ajax_renameFolder($_folderName, $_newName)
3690 4178
 	{
3691
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4179
+		if (Mail::$debug)
4180
+		{
4181
+			error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4182
+		}
3692 4183
 		if ($_folderName)
3693 4184
 		{
3694 4185
 			Api\Translation::add_app('mail');
@@ -3700,7 +4191,11 @@  discard block
 block discarded – undo
3700 4191
 			$hasChildren = false;
3701 4192
 			if (is_numeric($profileID))
3702 4193
 			{
3703
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4194
+				if ($profileID != $this->mail_bo->profileID)
4195
+				{
4196
+					return;
4197
+				}
4198
+				// only current connection
3704 4199
 				$pA = explode($del,$folderName);
3705 4200
 				array_pop($pA);
3706 4201
 				$parentFolder = implode($del,$pA);
@@ -3841,8 +4336,15 @@  discard block
 block discarded – undo
3841 4336
 		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3842 4337
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3843 4338
 		// that we get what we request
3844
-		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3845
-		if ($profileID != $this->mail_bo->profileID) return; // only current connection
4339
+		if ($_subscribedOnly != $oldPrefForSubscribedOnly)
4340
+		{
4341
+			$this->mail_bo->resetFolderObjectCache($profileID);
4342
+		}
4343
+		if ($profileID != $this->mail_bo->profileID)
4344
+		{
4345
+			return;
4346
+		}
4347
+		// only current connection
3846 4348
 		if (!empty($folderName))
3847 4349
 		{
3848 4350
 			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
@@ -3917,7 +4419,10 @@  discard block
 block discarded – undo
3917 4419
 	 */
3918 4420
 	function ajax_MoveFolder($_folderName, $_target)
3919 4421
 	{
3920
-		if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4422
+		if (Mail::$debug)
4423
+		{
4424
+			error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4425
+		}
3921 4426
 		if ($_folderName)
3922 4427
 		{
3923 4428
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
@@ -3928,7 +4433,11 @@  discard block
 block discarded – undo
3928 4433
 			$hasChildren = false;
3929 4434
 			if (is_numeric($profileID))
3930 4435
 			{
3931
-				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
4436
+				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID)
4437
+				{
4438
+					return;
4439
+				}
4440
+				// only current connection
3932 4441
 				$pA = explode($del,$folderName);
3933 4442
 				$namePart = array_pop($pA);
3934 4443
 				$_newName = $namePart;
@@ -3939,10 +4448,13 @@  discard block
 block discarded – undo
3939 4448
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3940 4449
 					(($oldParentFolder != $parentFolder &&
3941 4450
 					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3942
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4451
+					strpos($parentFolder,$folderName)===false))))
4452
+				{
4453
+					// indicates that we move the older up the tree within its own branch
3943 4454
 				{
3944 4455
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3945 4456
 					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4457
+				}
3946 4458
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3947 4459
 					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3948 4460
 					{
@@ -4025,8 +4537,14 @@  discard block
 block discarded – undo
4025 4537
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4026 4538
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4027 4539
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4028
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4029
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4540
+				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false)
4541
+				{
4542
+					unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4543
+				}
4544
+				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false)
4545
+				{
4546
+					unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4547
+				}
4030 4548
 
4031 4549
 				// Send full info back in the response
4032 4550
 				foreach($refreshData as $folder => &$name)
@@ -4062,7 +4580,11 @@  discard block
 block discarded – undo
4062 4580
 			$hasChildren = false;
4063 4581
 			if (is_numeric($profileID))
4064 4582
 			{
4065
-				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4583
+				if ($profileID != $this->mail_bo->profileID)
4584
+				{
4585
+					return;
4586
+				}
4587
+				// only current connection
4066 4588
 				$pA = explode($del,$folderName);
4067 4589
 				array_pop($pA);
4068 4590
 				if (strtoupper($folderName)!= 'INBOX')
@@ -4088,7 +4610,9 @@  discard block
 block discarded – undo
4088 4610
 						}
4089 4611
 						krsort($ftD,SORT_NUMERIC);//sort per level
4090 4612
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4091
-						foreach($ftD as $k => $lc)//collection per level
4613
+						foreach($ftD as $k => $lc)
4614
+						{
4615
+							//collection per level
4092 4616
 						{
4093 4617
 							foreach($lc as $f)//folders contained in that level
4094 4618
 							{
@@ -4096,8 +4620,12 @@  discard block
 block discarded – undo
4096 4620
 								{
4097 4621
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4098 4622
 									$this->mail_bo->deleteFolder($f);
4623
+						}
4099 4624
 									$success = true;
4100
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4625
+									if ($f==$folderName)
4626
+									{
4627
+										$oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4628
+									}
4101 4629
 								}
4102 4630
 								catch (Exception $e)
4103 4631
 								{
@@ -4127,7 +4655,10 @@  discard block
 block discarded – undo
4127 4655
 					$msg = lang("refused to delete folder INBOX");
4128 4656
 				}
4129 4657
 			}
4130
-			if ($_return) return $success;
4658
+			if ($_return)
4659
+			{
4660
+				return $success;
4661
+			}
4131 4662
 			$response = Api\Json\Response::get();
4132 4663
 			if ($success)
4133 4664
 			{
@@ -4214,24 +4745,35 @@  discard block
 block discarded – undo
4214 4745
 				// Create mail app object
4215 4746
 				$mail = new mail_ui();
4216 4747
 
4217
-				if (empty($icServerID)) $icServerID = $mail->Mail->profileID;
4218
-				if ($icServerID != $mail->Mail->profileID) return;
4748
+				if (empty($icServerID))
4749
+				{
4750
+					$icServerID = $mail->Mail->profileID;
4751
+				}
4752
+				if ($icServerID != $mail->Mail->profileID)
4753
+				{
4754
+					return;
4755
+				}
4219 4756
 
4220 4757
 				$vacation = $mail->gatherVacation($cachedVacations);
4221
-			} catch (Exception $e) {
4758
+			}
4759
+			catch (Exception $e) {
4222 4760
 				$vacation=false;
4223 4761
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4224 4762
 				unset($e);
4225 4763
 			}
4226 4764
 		}
4227 4765
 
4228
-		if($vacation) {
4766
+		if($vacation)
4767
+		{
4229 4768
 			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4230 4769
 			{
4231 4770
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4232 4771
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4233 4772
 				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4234
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4773
+				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())
4774
+				{
4775
+					$refreshData = '';
4776
+				}
4235 4777
 			}
4236 4778
 		}
4237 4779
 		if ($vacation==false)
@@ -4253,11 +4795,17 @@  discard block
 block discarded – undo
4253 4795
 	function ajax_refreshFilters($icServerID=null)
4254 4796
 	{
4255 4797
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4256
-		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4798
+		if (empty($icServerID))
4799
+		{
4800
+			$icServerID = $this->mail_bo->profileID;
4801
+		}
4257 4802
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4258 4803
 		{
4259 4804
 			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4260
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4805
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4806
+			{
4807
+				Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4808
+			}
4261 4809
 		}
4262 4810
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4263 4811
 		{
@@ -4279,7 +4827,10 @@  discard block
 block discarded – undo
4279 4827
 			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4280 4828
 			foreach($keywords as &$k)
4281 4829
 			{
4282
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4830
+				if (array_key_exists($k,$this->statusTypes))
4831
+				{
4832
+					unset($this->statusTypes[$k]);
4833
+				}
4283 4834
 			}
4284 4835
 		}
4285 4836
 
@@ -4299,7 +4850,10 @@  discard block
 block discarded – undo
4299 4850
 	{
4300 4851
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4301 4852
 		Api\Translation::add_app('mail');
4302
-		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
4853
+		if (is_null($icServerID))
4854
+		{
4855
+			$icServerID = $this->mail_bo->profileID;
4856
+		}
4303 4857
 		$rememberServerID = $this->mail_bo->profileID;
4304 4858
 		try
4305 4859
 		{
@@ -4309,19 +4863,23 @@  discard block
 block discarded – undo
4309 4863
 				$this->changeProfile($icServerID);
4310 4864
 			}
4311 4865
 			$quota = $this->mail_bo->getQuotaRoot();
4312
-		} catch (Exception $e) {
4866
+		}
4867
+		catch (Exception $e) {
4313 4868
 			$quota['limit'] = 'NOT SET';
4314 4869
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4315 4870
 			unset($e);
4316 4871
 		}
4317 4872
 
4318
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4873
+		if($quota !== false && $quota['limit'] != 'NOT SET')
4874
+		{
4319 4875
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4320 4876
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4321 4877
 			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4322 4878
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4323 4879
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4324
-		} else {
4880
+		}
4881
+		else
4882
+		{
4325 4883
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
4326 4884
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
4327 4885
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -4332,7 +4890,8 @@  discard block
 block discarded – undo
4332 4890
 			{
4333 4891
 				//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
4334 4892
 				$this->changeProfile($rememberServerID);
4335
-			} catch (Exception $e) {
4893
+			}
4894
+			catch (Exception $e) {
4336 4895
 				//error_log(__METHOD__.__LINE__." ".$e->getMessage());
4337 4896
 				unset($e);
4338 4897
 			}
@@ -4360,7 +4919,8 @@  discard block
 block discarded – undo
4360 4919
 			$this->changeProfile($icServerID);
4361 4920
 		}
4362 4921
 		$junkFolder = $this->mail_bo->getJunkFolder();
4363
-		if(!empty($junkFolder)) {
4922
+		if(!empty($junkFolder))
4923
+		{
4364 4924
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4365 4925
 			{
4366 4926
 				// Lock the tree if the active folder is junk folder
@@ -4410,7 +4970,8 @@  discard block
 block discarded – undo
4410 4970
 			$this->changeProfile($icServerID);
4411 4971
 		}
4412 4972
 		$trashFolder = $this->mail_bo->getTrashFolder();
4413
-		if(!empty($trashFolder)) {
4973
+		if(!empty($trashFolder))
4974
+		{
4414 4975
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4415 4976
 			{
4416 4977
 				// Lock the tree if the active folder is Trash folder
@@ -4456,7 +5017,10 @@  discard block
 block discarded – undo
4456 5017
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4457 5018
 		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4458 5019
 
4459
-		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
5020
+		if (empty($folderName))
5021
+		{
5022
+			$folderName = $this->mail_bo->sessionData['mailbox'];
5023
+		}
4460 5024
 		if ($this->mail_bo->folderExists($folderName))
4461 5025
 		{
4462 5026
 			$rememberServerID = $this->mail_bo->profileID;
@@ -4465,7 +5029,8 @@  discard block
 block discarded – undo
4465 5029
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4466 5030
 				$this->changeProfile($icServerID);
4467 5031
 			}
4468
-			if(!empty($_folderName)) {
5032
+			if(!empty($_folderName))
5033
+			{
4469 5034
 				$this->mail_bo->compressFolder($folderName);
4470 5035
 			}
4471 5036
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4487,7 +5052,10 @@  discard block
 block discarded – undo
4487 5052
 	 */
4488 5053
 	function ajax_sendMDN($_messageList)
4489 5054
 	{
4490
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
5055
+		if(Mail::$debug)
5056
+		{
5057
+			error_log(__METHOD__."->".array2string($_messageList));
5058
+		}
4491 5059
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4492 5060
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4493 5061
 		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
@@ -4504,7 +5072,10 @@  discard block
 block discarded – undo
4504 5072
 	 */
4505 5073
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4506 5074
 	{
4507
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5075
+		if(Mail::$debug)
5076
+		{
5077
+			error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5078
+		}
4508 5079
 		Api\Translation::add_app('mail');
4509 5080
 		$alreadyFlagged=false;
4510 5081
 		$flag2check='';
@@ -4525,12 +5096,23 @@  discard block
 block discarded – undo
4525 5096
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4526 5097
 						{
4527 5098
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4528
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5099
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5100
+							{
5101
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5102
+							}
4529 5103
 						}
4530 5104
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4531 5105
 						$cutoffdate = $cutoffdate2 = null;
4532
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4533
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5106
+						if ($query['startdate'])
5107
+						{
5108
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5109
+						}
5110
+						//SINCE, enddate
5111
+						if ($query['enddate'])
5112
+						{
5113
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5114
+						}
5115
+						//BEFORE, startdate
4534 5116
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4535 5117
 						$filter = array(
4536 5118
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4539,15 +5121,24 @@  discard block
 block discarded – undo
4539 5121
 							'status' => 'any',//this is a status change. status will be manipulated later on
4540 5122
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4541 5123
 						);
4542
-						if ($query['enddate']||$query['startdate']) {
5124
+						if ($query['enddate']||$query['startdate'])
5125
+						{
4543 5126
 							$filter['range'] = "BETWEEN";
4544
-							if ($cutoffdate) {
5127
+							if ($cutoffdate)
5128
+							{
4545 5129
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4546
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5130
+								if (empty($cutoffdate2))
5131
+								{
5132
+									$filter['range'] = "SINCE";
5133
+								}
4547 5134
 							}
4548
-							if ($cutoffdate2) {
5135
+							if ($cutoffdate2)
5136
+							{
4549 5137
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4550
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5138
+								if (empty($cutoffdate))
5139
+								{
5140
+									$filter['range'] = "BEFORE";
5141
+								}
4551 5142
 							}
4552 5143
 						}
4553 5144
 						$filter2toggle = $filter;
@@ -4598,13 +5189,19 @@  discard block
 block discarded – undo
4598 5189
 						if (count($messageListForToggle)>0)
4599 5190
 						{
4600 5191
 							$flag2set = (strtolower($_flag));
4601
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5192
+							if(Mail::$debug)
5193
+							{
5194
+								error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5195
+							}
4602 5196
 							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4603 5197
 						}
4604 5198
 						if (count($messageList)>0)
4605 5199
 						{
4606 5200
 							$flag2set = 'un'.$_flag;
4607
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5201
+							if(Mail::$debug)
5202
+							{
5203
+								error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5204
+							}
4608 5205
 							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4609 5206
 						}
4610 5207
 						$alreadyFlagged=true;
@@ -4620,7 +5217,10 @@  discard block
 block discarded – undo
4620 5217
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4621 5218
 							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4622 5219
 						}
4623
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5220
+						if(Mail::$debug)
5221
+						{
5222
+							error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5223
+						}
4624 5224
 						$rByUid = true;
4625 5225
 						$reverse = 1;
4626 5226
 						$_sR = $this->mail_bo->getSortedList(
@@ -4637,7 +5237,10 @@  discard block
 block discarded – undo
4637 5237
 					}
4638 5238
 					else
4639 5239
 					{
4640
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5240
+						if(Mail::$debug)
5241
+						{
5242
+							error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5243
+						}
4641 5244
 						$alreadyFlagged=true;
4642 5245
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4643 5246
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -4657,13 +5260,19 @@  discard block
 block discarded – undo
4657 5260
 					$hA = self::splitRowID($rowID);
4658 5261
 					$messageList[] = $hA['msgUID'];
4659 5262
 				}
4660
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5263
+				if(Mail::$debug)
5264
+				{
5265
+					error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5266
+				}
4661 5267
 				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4662 5268
 			}
4663 5269
 		}
4664 5270
 		else
4665 5271
 		{
4666
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5272
+			if(Mail::$debug)
5273
+			{
5274
+				error_log(__METHOD__."-> No messages selected.");
5275
+			}
4667 5276
 		}
4668 5277
 
4669 5278
 		if ($_sendJsonResponse)
@@ -4700,7 +5309,10 @@  discard block
 block discarded – undo
4700 5309
 	 */
4701 5310
 	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4702 5311
 	{
4703
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5312
+		if(Mail::$debug)
5313
+		{
5314
+			error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5315
+		}
4704 5316
 		$error = null;
4705 5317
 		$filtered =  false;
4706 5318
 		if ($_messageList=='all' || !empty($_messageList['msg']))
@@ -4719,12 +5331,23 @@  discard block
 block discarded – undo
4719 5331
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4720 5332
 						{
4721 5333
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4722
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5334
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5335
+							{
5336
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5337
+							}
4723 5338
 						}
4724 5339
 						$filtered =  true;
4725 5340
 						$cutoffdate = $cutoffdate2 = null;
4726
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4727
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5341
+						if ($query['startdate'])
5342
+						{
5343
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5344
+						}
5345
+						//SINCE, enddate
5346
+						if ($query['enddate'])
5347
+						{
5348
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5349
+						}
5350
+						//BEFORE, startdate
4728 5351
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4729 5352
 						$filter = array(
4730 5353
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4733,15 +5356,24 @@  discard block
 block discarded – undo
4733 5356
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4734 5357
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4735 5358
 						);
4736
-						if ($query['enddate']||$query['startdate']) {
5359
+						if ($query['enddate']||$query['startdate'])
5360
+						{
4737 5361
 							$filter['range'] = "BETWEEN";
4738
-							if ($cutoffdate) {
5362
+							if ($cutoffdate)
5363
+							{
4739 5364
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4740
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5365
+								if (empty($cutoffdate2))
5366
+								{
5367
+									$filter['range'] = "SINCE";
5368
+								}
4741 5369
 							}
4742
-							if ($cutoffdate2) {
5370
+							if ($cutoffdate2)
5371
+							{
4743 5372
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4744
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5373
+								if (empty($cutoffdate))
5374
+								{
5375
+									$filter['range'] = "BEFORE";
5376
+								}
4745 5377
 							}
4746 5378
 						}
4747 5379
 					}
@@ -4808,7 +5440,10 @@  discard block
 block discarded – undo
4808 5440
 		}
4809 5441
 		else
4810 5442
 		{
4811
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5443
+			if(Mail::$debug)
5444
+			{
5445
+				error_log(__METHOD__."-> No messages selected.");
5446
+			}
4812 5447
 		}
4813 5448
 	}
4814 5449
 
@@ -4824,11 +5459,17 @@  discard block
 block discarded – undo
4824 5459
 	 */
4825 5460
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4826 5461
 	{
4827
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5462
+		if(Mail::$debug)
5463
+		{
5464
+			error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5465
+		}
4828 5466
 		Api\Translation::add_app('mail');
4829 5467
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4830 5468
 		// only copy or move are supported as method
4831
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5469
+		if (!($_copyOrMove=='copy' || $_copyOrMove=='move'))
5470
+		{
5471
+			$_copyOrMove='copy';
5472
+		}
4832 5473
 		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4833 5474
 		// check if move2archive was called with the correct archiveFolder
4834 5475
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
@@ -4851,8 +5492,13 @@  discard block
 block discarded – undo
4851 5492
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4852 5493
 				foreach( $keys as &$f)
4853 5494
 				{
4854
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4855
-					else break;
5495
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9)
5496
+					{
5497
+						unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5498
+					}
5499
+					else {
5500
+						break;
5501
+					}
4856 5502
 				}
4857 5503
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4858 5504
 			}
@@ -4879,12 +5525,23 @@  discard block
 block discarded – undo
4879 5525
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4880 5526
 						{
4881 5527
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4882
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5528
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5529
+							{
5530
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5531
+							}
4883 5532
 						}
4884 5533
 						$filtered = true;
4885 5534
 						$cutoffdate = $cutoffdate2 = null;
4886
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4887
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5535
+						if ($query['startdate'])
5536
+						{
5537
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5538
+						}
5539
+						//SINCE, enddate
5540
+						if ($query['enddate'])
5541
+						{
5542
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5543
+						}
5544
+						//BEFORE, startdate
4888 5545
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4889 5546
 						$filter = array(
4890 5547
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4893,15 +5550,24 @@  discard block
 block discarded – undo
4893 5550
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4894 5551
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4895 5552
 						);
4896
-						if ($query['enddate']||$query['startdate']) {
5553
+						if ($query['enddate']||$query['startdate'])
5554
+						{
4897 5555
 							$filter['range'] = "BETWEEN";
4898
-							if ($cutoffdate) {
5556
+							if ($cutoffdate)
5557
+							{
4899 5558
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4900
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5559
+								if (empty($cutoffdate2))
5560
+								{
5561
+									$filter['range'] = "SINCE";
5562
+								}
4901 5563
 							}
4902
-							if ($cutoffdate2) {
5564
+							if ($cutoffdate2)
5565
+							{
4903 5566
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4904
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5567
+								if (empty($cutoffdate))
5568
+								{
5569
+									$filter['range'] = "BEFORE";
5570
+								}
4905 5571
 							}
4906 5572
 						}
4907 5573
 					}
@@ -4957,7 +5623,10 @@  discard block
 block discarded – undo
4957 5623
 						$hA = self::splitRowID($rowID);
4958 5624
 
4959 5625
 						// If folder changes, stop and move what we've got
4960
-						if($hA['folder'] != $folder) break;
5626
+						if($hA['folder'] != $folder)
5627
+						{
5628
+							break;
5629
+						}
4961 5630
 
4962 5631
 						array_shift($_messageList['msg']);
4963 5632
 						$messageList[] = $hA['msgUID'];
@@ -5012,7 +5681,10 @@  discard block
 block discarded – undo
5012 5681
 		}
5013 5682
 		else
5014 5683
 		{
5015
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5684
+			if(Mail::$debug)
5685
+			{
5686
+				error_log(__METHOD__."-> No messages selected.");
5687
+			}
5016 5688
 		}
5017 5689
 	}
5018 5690
 
Please login to merge, or discard this patch.
Spacing   +822 added lines, -829 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @var array
42 42
 	 */
43
-	var $public_functions = array
44
-	(
43
+	var $public_functions = array(
45 44
 		'index' => True,
46 45
 		'displayHeader'	=> True,
47 46
 		'displayMessage'	=> True,
@@ -92,17 +91,17 @@  discard block
 block discarded – undo
92 91
 	 * @var array
93 92
 	 */
94 93
 	var $searchTypes = array(
95
-		'quick'		=> 'quicksearch',	// lang('quicksearch')
96
-		'quickwithcc'=> 'quicksearch (with cc)',	// lang('quicksearch (with cc)')
97
-		'subject'	=> 'subject',		// lang('subject')
98
-		'body'		=> 'message body',	// lang('message body')
99
-		'from'		=> 'from',			// lang('from')
100
-		'to'		=> 'to',			// lang('to')
101
-		'cc'		=> 'cc',			// lang('cc')
102
-		'text'		=> 'whole message',	// lang('whole message')
103
-		'larger'		=> 'greater than',	// lang('greater than')
104
-		'smaller'		=> 'less than',	// lang('less than')
105
-		'bydate' 	=> 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)')
94
+		'quick'		=> 'quicksearch', // lang('quicksearch')
95
+		'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)')
96
+		'subject'	=> 'subject', // lang('subject')
97
+		'body'		=> 'message body', // lang('message body')
98
+		'from'		=> 'from', // lang('from')
99
+		'to'		=> 'to', // lang('to')
100
+		'cc'		=> 'cc', // lang('cc')
101
+		'text'		=> 'whole message', // lang('whole message')
102
+		'larger'		=> 'greater than', // lang('greater than')
103
+		'smaller'		=> 'less than', // lang('less than')
104
+		'bydate' 	=> 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)')
106 105
 	);
107 106
 
108 107
 	/**
@@ -111,12 +110,12 @@  discard block
 block discarded – undo
111 110
 	 * @var array
112 111
 	 */
113 112
 	var $statusTypes = array(
114
-		'any'		=> 'any status',// lang('any status')
115
-		'flagged'	=> 'flagged',	// lang('flagged')
116
-		'unseen'	=> 'unread',	// lang('unread')
117
-		'answered'	=> 'replied',	// lang('replied')
118
-		'seen'		=> 'read',		// lang('read')
119
-		'deleted'	=> 'deleted',	// lang('deleted')
113
+		'any'		=> 'any status', // lang('any status')
114
+		'flagged'	=> 'flagged', // lang('flagged')
115
+		'unseen'	=> 'unread', // lang('unread')
116
+		'answered'	=> 'replied', // lang('replied')
117
+		'seen'		=> 'read', // lang('read')
118
+		'deleted'	=> 'deleted', // lang('deleted')
120 119
 	);
121 120
 
122 121
 	/**
@@ -124,12 +123,12 @@  discard block
 block discarded – undo
124 123
 	 *
125 124
 	 * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server
126 125
 	 */
127
-	function __construct($run_constructor=true)
126
+	function __construct($run_constructor = true)
128 127
 	{
129 128
 		$this->mail_tree = new mail_tree($this);
130 129
 		if (!$run_constructor) return;
131 130
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
131
+		if (Mail::$debugTimes) $starttime = microtime(true);
133 132
 		// no autohide of the sidebox, as we use it for folderlist now.
134 133
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 134
 
@@ -145,13 +144,13 @@  discard block
 block discarded – undo
145 144
 		}
146 145
 
147 146
 		try {
148
-			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
147
+			$this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true);
149 148
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
150 149
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 150
 
152 151
 			// RegEx to minimize extra openConnection
153 152
 			$needle = '/^(?!mail)/';
154
-			if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
153
+			if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
155 154
 			{
156 155
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
157 156
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -164,12 +163,12 @@  discard block
 block discarded – undo
164 163
 			if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index')
165 164
 			{
166 165
 				$response = Api\Json\Response::get();
167
-				$response->call('egw.message',$e->getMessage(),'error');
166
+				$response->call('egw.message', $e->getMessage(), 'error');
168 167
 			}
169 168
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
169
+			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false);
171 170
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
173 172
 	}
174 173
 
175 174
 	/**
@@ -179,10 +178,10 @@  discard block
 block discarded – undo
179 178
 	 * @param boolean $exit If true, will call exit() after opening the wizardpopup
180 179
 	 * @param string $msg_type = 'success' message type
181 180
 	 */
182
-	static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true)
181
+	static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true)
183 182
 	{
184 183
 		//error_log(__METHOD__."('$message', $exit) ".function_backtrace());
185
-		$linkData=(self::$icServerID ? array(
184
+		$linkData = (self::$icServerID ? array(
186 185
 				'menuaction' => 'mail.mail_wizard.edit',
187 186
 				'acc_id' => self::$icServerID,
188 187
 			) : array(
@@ -196,11 +195,11 @@  discard block
 block discarded – undo
196 195
 		{
197 196
 			$response = Api\Json\Response::get();
198 197
 			$windowName = "editMailAccount".self::$icServerID;
199
-			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
198
+			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true);
200 199
 			Framework::message($message, 'error');
201 200
 			if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index)
202 201
 			{
203
-				$response->call('framework.setSidebox','mail',array(),'md5');
202
+				$response->call('framework.setSidebox', 'mail', array(), 'md5');
204 203
 			}
205 204
 			if ($exit)
206 205
 			{
@@ -210,8 +209,8 @@  discard block
 block discarded – undo
210 209
 		else	// regular GET request eg. in idots template
211 210
 		{
212 211
 			$windowName = "editMailAccount".self::$icServerID;
213
-			Framework::popup(Framework::link('/index.php',$linkData),$windowName);
214
-			$GLOBALS['egw']->framework->render($message,'',true);
212
+			Framework::popup(Framework::link('/index.php', $linkData), $windowName);
213
+			$GLOBALS['egw']->framework->render($message, '', true);
215 214
 			if ($exit)
216 215
 			{
217 216
 				exit();
@@ -227,9 +226,9 @@  discard block
 block discarded – undo
227 226
 	 *
228 227
 	 * @throws Api\Exception
229 228
 	 */
230
-	function changeProfile($_icServerID,$unsetCache=false)
229
+	function changeProfile($_icServerID, $unsetCache = false)
231 230
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
231
+		if (Mail::$debugTimes) $starttime = microtime(true);
233 232
 		if (self::$icServerID != $_icServerID)
234 233
 		{
235 234
 			self::$icServerID = $_icServerID;
@@ -237,35 +236,35 @@  discard block
 block discarded – undo
237 236
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
238 237
 
239 238
 		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
240
-		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
239
+		$this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true);
241 240
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
242 241
 		// no icServer Object: something failed big time
243
-		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
242
+		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID)
244 243
 		{
245 244
 			self::$icServerID = $_icServerID;
246 245
 			throw new Api\Exception('Profile change failed!');
247 246
 		}
248 247
 
249 248
 		// save session varchar
250
-		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
249
+		$oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID');
251 250
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252 251
 		if (true) $oldicServerID = self::$icServerID;
253
-		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
252
+		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true))
254 253
 		{
255 254
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 255
 		}
257 256
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
257
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
259 258
 	}
260 259
 
261 260
 	/**
262 261
 	 * Ajax function to request next branch of a tree branch
263 262
 	 */
264
-	static function ajax_tree_autoloading ($_id = null)
263
+	static function ajax_tree_autoloading($_id = null)
265 264
 	{
266 265
 		$mail_ui = new mail_ui();
267 266
 		$id = $_id ? $_id : $_GET['id'];
268
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
267
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false));
269 268
 	}
270 269
 
271 270
 	/**
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 	 * @param array $content
275 274
 	 * @param type $msg
276 275
 	 */
277
-	function subscription(array $content=null ,$msg=null)
276
+	function subscription(array $content = null, $msg = null)
278 277
 	{
279 278
 		$stmpl = new Etemplate('mail.subscribe');
280 279
 
281
-		if(is_array($content))
280
+		if (is_array($content))
282 281
 		{
283 282
 			$profileId = $content['profileId'];
284 283
 		}
@@ -288,14 +287,14 @@  discard block
 block discarded – undo
288 287
 		}
289 288
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
290 289
 		// triggered from client-side. Also, we keep this here as
291
-		$sel_options['foldertree'] =  $this->mail_tree->getTree(null,$profileId,1,true,false,true);
290
+		$sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true);
292 291
 
293 292
 		//Get all subscribed folders
294 293
 		// as getting all subscribed folders is very fast operation
295 294
 		// we can use it to get a comparison base for folders which
296 295
 		// got subscribed or unsubscribed by the user
297 296
 		try {
298
-			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
297
+			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true);
299 298
 		} catch (Exception $ex) {
300 299
 			Framework::message($ex->getMessage());
301 300
 		}
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
 
307 306
 			foreach ($subscribed as $folder)
308 307
 			{
309
-				$folderName = $profileId . self::$delimiter . $folder['MAILBOX'];
308
+				$folderName = $profileId.self::$delimiter.$folder['MAILBOX'];
310 309
 				array_push($content['foldertree'], $folderName);
311 310
 			}
312 311
 		}
@@ -320,9 +319,9 @@  discard block
 block discarded – undo
320 319
 				{
321 320
 					// do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
322 321
 					$namespace_roots = array($profileId);
323
-					foreach($this->mail_bo->_getNameSpaces() as $namespace)
322
+					foreach ($this->mail_bo->_getNameSpaces() as $namespace)
324 323
 					{
325
-						$namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
324
+						$namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']);
326 325
 					}
327 326
 					$to_unsubscribe = $to_subscribe = array();
328 327
 					foreach ($content['foldertree'] as $path => $value)
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 330
 						if ($node)
332 331
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
332
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node;
334 333
 							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335 334
 							if ($value['value']) $cont[] = $path;
336 335
 						}
@@ -340,7 +339,7 @@  discard block
 block discarded – undo
340 339
 					// set foldertree options to basic node in order to avoid initial autoloading
341 340
 					// from client side, as no options would trigger that.
342 341
 					$sel_options['foldertree'] = array('id' => '0', 'item'=> array());
343
-					foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
342
+					foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
344 343
 					{
345 344
 						if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true))
346 345
 						{
@@ -376,18 +375,18 @@  discard block
 block discarded – undo
376 375
 						}
377 376
 					}
378 377
 					// update foldertree in main window
379
-					$parentFolder='INBOX';
378
+					$parentFolder = 'INBOX';
380 379
 					$refreshData = array(
381 380
 						$profileId => lang($parentFolder),
382 381
 					);
383 382
 					$response = Api\Json\Response::get();
384
-					foreach($refreshData as $folder => &$name)
383
+					foreach ($refreshData as $folder => &$name)
385 384
 					{
386
-						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
385
+						$name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true);
387 386
 					}
388 387
 					// give success/error message to opener and popup itself
389 388
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
390
-					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
389
+					$response->call('opener.app.mail.mail_reloadNode', $refreshData);
391 390
 
392 391
 					Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
393 392
 					if ($button == 'apply')
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 
408 407
 		$readonlys = array();
409 408
 
410
-		$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
409
+		$stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2);
411 410
 	}
412 411
 
413 412
 	/**
@@ -416,13 +415,13 @@  discard block
 block discarded – undo
416 415
 	 * @param array $content
417 416
 	 * @param string $msg
418 417
 	 */
419
-	function index(array $content=null,$msg=null)
418
+	function index(array $content = null, $msg = null)
420 419
 	{
421 420
 		//error_log(__METHOD__.__LINE__.array2string($content));
422
-		try	{
421
+		try {
423 422
 				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
424 423
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
424
+				if (Mail::$debugTimes) $starttime = microtime(true);
426 425
 				$this->mail_bo->restoreSessionData();
427 426
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 427
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -443,26 +442,26 @@  discard block
 block discarded – undo
443 442
 					{
444 443
 						// These only set on first load
445 444
 						$content[self::$nm_index] = array(
446
-							'filter'         => 'any',	// filter is used to choose the mailbox
447
-							'lettersearch'   => false,	// I  show a lettersearch
448
-							'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
449
-							'start'          =>	0,		// IO position in list
450
-							'order'          =>	'date',	// IO name of the column to sort after (optional for the sortheaders)
451
-							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
445
+							'filter'         => 'any', // filter is used to choose the mailbox
446
+							'lettersearch'   => false, // I  show a lettersearch
447
+							'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
448
+							'start'          =>	0, // IO position in list
449
+							'order'          =>	'date', // IO name of the column to sort after (optional for the sortheaders)
450
+							'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
452 451
 						);
453 452
 					}
454 453
 					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
455 454
 				}
456 455
 
457 456
 				// These must always be set, even if $content is an array
458
-				$content[self::$nm_index]['cat_is_select'] = true;    // Category select is just a normal selectbox
459
-				$content[self::$nm_index]['no_filter2'] = false;       // Disable second filter
457
+				$content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox
458
+				$content[self::$nm_index]['no_filter2'] = false; // Disable second filter
460 459
 				$content[self::$nm_index]['actions'] = self::get_actions();
461
-				$content[self::$nm_index]['row_id'] = 'row_id';	     // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
460
+				$content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
462 461
 				$content[self::$nm_index]['placeholder_actions'] = array('composeasnew');
463 462
 				$content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows';
464
-				$content[self::$nm_index]['num_rows'] = 0;      // Do not send any rows with initial request
465
-				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size';	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
463
+				$content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request
464
+				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
466 465
 				$content[self::$nm_index]['csv_fields'] = false;
467 466
 				if ($msg)
468 467
 				{
@@ -474,11 +473,11 @@  discard block
 block discarded – undo
474 473
 					unset($content['msg']);
475 474
 				}
476 475
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477
-				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
476
+				$quota = false; //$this->mail_bo->getQuotaRoot();
477
+				if ($quota !== false && $quota['limit'] != 'NOT SET') {
479 478
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 479
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481
-					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
480
+					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
482 481
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 482
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484 483
 				} else {
@@ -487,43 +486,43 @@  discard block
 block discarded – undo
487 486
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
488 487
 				}
489 488
 				// call gatherVacation asynchronously in getRows by initiating a client Server roundtrip
490
-				$vacation = false;//$this->gatherVacation();
489
+				$vacation = false; //$this->gatherVacation();
491 490
 				//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
492
-				if($vacation) {
493
-					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time()))
491
+				if ($vacation) {
492
+					if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time()))
494 493
 					{
495 494
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
496 495
 						$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
497
-						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
496
+						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
498 497
 					}
499 498
 				}
500
-				if ($vacation==false)
499
+				if ($vacation == false)
501 500
 				{
502 501
 					$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = '';
503 502
 					$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = '';
504 503
 				}
505 504
 				//$zstarttime = microtime (true);
506
-				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
505
+				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
507 506
 				//$zendtime = microtime(true) - $zstarttime;
508 507
 				//error_log(__METHOD__.__LINE__. " time used: ".$zendtime);
509
-				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX');
508
+				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX');
510 509
 				// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
511
-				if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
510
+				if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
512 511
 				{
513
-					$this->statusTypes = array_merge($this->statusTypes,array(
514
-						'keyword1'	=> 'important',//lang('important'),
515
-						'keyword2'	=> 'job',	//lang('job'),
516
-						'keyword3'	=> 'personal',//lang('personal'),
517
-						'keyword4'	=> 'to do',	//lang('to do'),
518
-						'keyword5'	=> 'later',	//lang('later'),
512
+					$this->statusTypes = array_merge($this->statusTypes, array(
513
+						'keyword1'	=> 'important', //lang('important'),
514
+						'keyword2'	=> 'job', //lang('job'),
515
+						'keyword3'	=> 'personal', //lang('personal'),
516
+						'keyword4'	=> 'to do', //lang('to do'),
517
+						'keyword5'	=> 'later', //lang('later'),
519 518
 					));
520 519
 				}
521 520
 				else
522 521
 				{
523
-					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
524
-					foreach($keywords as &$k)
522
+					$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
523
+					foreach ($keywords as &$k)
525 524
 					{
526
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
525
+						if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
527 526
 					}
528 527
 				}
529 528
 
@@ -534,8 +533,8 @@  discard block
 block discarded – undo
534 533
 
535 534
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
536 535
 				{
537
-					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
538
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
536
+					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
537
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
539 538
 				}
540 539
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
541 540
 				{
@@ -547,14 +546,14 @@  discard block
 block discarded – undo
547 546
 				//error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']));
548 547
 				$content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'];
549 548
 				$sel_options['filter'] = $this->statusTypes;
550
-				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'));
549
+				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'));
551 550
 				$content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'];
552 551
 
553 552
 				$etpl = new Etemplate('mail.index');
554 553
 				//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
555 554
 				$content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()";
556 555
 				// set the actions on tree
557
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
556
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions());
558 557
 
559 558
 				// sending preview toolbar actions
560 559
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
@@ -565,34 +564,34 @@  discard block
 block discarded – undo
565 564
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
566 565
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
567 566
 				{
568
-					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
567
+					$content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject'));
569 568
 				}
570 569
 				$readonlys = $preserv = array();
571
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
570
+				if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
572 571
 		}
573 572
 		catch (Exception $e)
574 573
 		{
575 574
 			// do not exit here. mail-tree should be build. if we exit here, we never get there.
576
-			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
575
+			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
577 576
 			if (isset($this->mail_bo))
578 577
 			{
579 578
 				if (empty($etpl))
580 579
 				{
581
-					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
580
+					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
582 581
 					$etpl = new Etemplate('mail.index');
583 582
 				}
584
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
583
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false));
585 584
 			}
586 585
 			$readonlys = $preserv = array();
587
-			if (empty($content)) $content=array();
586
+			if (empty($content)) $content = array();
588 587
 
589
-			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
588
+			self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ? false : true), 'error', false);
590 589
 			//return false;
591 590
 		}
592 591
 		// Check preview pane is enabled, then show spliter
593 592
 		if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter');
594 593
 
595
-		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
594
+		return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv);
596 595
 	}
597 596
 
598 597
 	/**
@@ -602,11 +601,11 @@  discard block
 block discarded – undo
602 601
 	 * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server
603 602
 	 * @return array
604 603
 	 */
605
-	function get_tree_actions($imap_actions=true)
604
+	function get_tree_actions($imap_actions = true)
606 605
 	{
607 606
 		// Start at 2 so auto-added copy+paste actions show up as second group
608 607
 		// Needed because there's no 'select all' action to push things down
609
-		$group=1;
608
+		$group = 1;
610 609
 		// Set tree actions
611 610
 		$tree_actions = array(
612 611
 			'drop_move_mail' => array(
@@ -688,12 +687,12 @@  discard block
 block discarded – undo
688 687
 				'onExecute' => 'javaScript:app.mail.edit_sieve',
689 688
 
690 689
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
691
-				'icon' => 'mail/filter',	// funnel
690
+				'icon' => 'mail/filter', // funnel
692 691
 				'hideOnMobile' => true
693 692
 			),
694 693
 			'vacation' => array(
695 694
 				'caption' => 'Vacation notice',
696
-				'icon' => 'mail/navbar',	// mail as in admin
695
+				'icon' => 'mail/navbar', // mail as in admin
697 696
 				'onExecute' => 'javaScript:app.mail.edit_vacation',
698 697
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
699 698
 			),
@@ -734,8 +733,8 @@  discard block
 block discarded – undo
734 733
 			unset($tree_actions['subscribe']);
735 734
 			unset($tree_actions['unsubscribe']);
736 735
 		}
737
-		++$group;	// put delete in own group
738
-		switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
736
+		++$group; // put delete in own group
737
+		switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
739 738
 		{
740 739
 			case 'move_to_trash':
741 740
 				$tree_actions['empty_trash'] = array(
@@ -754,7 +753,7 @@  discard block
 block discarded – undo
754 753
 				);
755 754
 				break;
756 755
 		}
757
-		$junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null);
756
+		$junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null);
758 757
 
759 758
 		//error_log(__METHOD__.__LINE__.$junkFolder);
760 759
 		if ($junkFolder && !empty($junkFolder))
@@ -767,8 +766,8 @@  discard block
 block discarded – undo
767 766
 				'group'	=> $group,
768 767
 			);
769 768
 		}
770
-		$tree_actions['sieve']['group']	= $tree_actions['vacation']['group'] = ++$group;	// new group for filter
771
-		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group']	= ++$group;
769
+		$tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter
770
+		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group;
772 771
 
773 772
 
774 773
 		// enforce global (group-specific) ACL
@@ -803,17 +802,17 @@  discard block
 block discarded – undo
803 802
 	 * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed
804 803
 	 * @param {boolean} $_status set true for subscribe and false to unsubscribe
805 804
 	 */
806
-	public function ajax_foldersubscription($_acc_id,$_folderName, $_status)
805
+	public function ajax_foldersubscription($_acc_id, $_folderName, $_status)
807 806
 	{
808 807
 		//Change the Mail object to related profileId
809 808
 		$this->changeProfile($_acc_id);
810
-		try{
809
+		try {
811 810
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
812 811
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
813
-			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
812
+			$this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
814 813
 		} catch (Horde_Imap_Client_Exception $ex) {
815
-			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
816
-			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
814
+			error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex));
815
+			Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status));
817 816
 		}
818 817
 	}
819 818
 
@@ -825,25 +824,25 @@  discard block
 block discarded – undo
825 824
 	 * @param string $_nodeID if of node whos children are requested
826 825
 	 * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default)
827 826
 	 */
828
-	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
827
+	public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null)
829 828
 	{
830 829
 		$nodeID = $_GET['id'];
831 830
 		if (!is_null($_nodeID)) $nodeID = $_nodeID;
832
-		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
831
+		$subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
833 832
 		$fetchCounters = !is_null($_nodeID);
834
-		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
833
+		list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2);
835 834
 
836 835
 		if (!empty($_folderName)) $fetchCounters = true;
837 836
 
838 837
 		// Check if it is called for refresh root
839 838
 		// then we need to reinitialized the index tree
840
-		if(!$nodeID && !$_profileID)
839
+		if (!$nodeID && !$_profileID)
841 840
 		{
842
-			$data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
841
+			$data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
843 842
 		}
844 843
 		else
845 844
 		{
846
-			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
845
+			$data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
847 846
 		}
848 847
 		if (!is_null($_nodeID)) return $data;
849 848
 		Etemplate\Widget\Tree::send_quote_json($data);
@@ -859,17 +858,17 @@  discard block
 block discarded – undo
859 858
 	 */
860 859
 	static function findNode($_out, $_nodeID, $childElements = false)
861 860
 	{
862
-		foreach($_out['item'] as $node)
861
+		foreach ($_out['item'] as $node)
863 862
 		{
864
-			if (strcmp($node['id'],$_nodeID)===0)
863
+			if (strcmp($node['id'], $_nodeID) === 0)
865 864
 			{
866 865
 				//error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']);
867
-				return ($childElements?$node['item']:$node);
866
+				return ($childElements ? $node['item'] : $node);
868 867
 			}
869
-			elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id']))
868
+			elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id']))
870 869
 			{
871 870
 				//error_log(__METHOD__.__LINE__.' descend into '.$node['id']);
872
-				return self::findNode($node,$_nodeID,$childElements);
871
+				return self::findNode($node, $_nodeID, $childElements);
873 872
 			}
874 873
 		}
875 874
 	}
@@ -883,7 +882,7 @@  discard block
 block discarded – undo
883 882
 	 */
884 883
 	private function get_actions()
885 884
 	{
886
-		static $accArray=array(); // buffer identity names on single request
885
+		static $accArray = array(); // buffer identity names on single request
887 886
 		// duplicated from mail_hooks
888 887
 		static $deleteOptions = array(
889 888
 			'move_to_trash'		=> 'move to trash',
@@ -894,12 +893,12 @@  discard block
 block discarded – undo
894 893
 		$lastFolderUsedForMove = null;
895 894
 		$moveactions = array();
896 895
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
897
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
896
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
898 897
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
899 898
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
900 899
 		if (is_null($accArray))
901 900
 		{
902
-			foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj)
901
+			foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj)
903 902
 			{
904 903
 				//error_log(__METHOD__.__LINE__.array2string($accountObj));
905 904
 				if (!$accountObj->is_imap())
@@ -907,22 +906,22 @@  discard block
 block discarded – undo
907 906
 					// not to be used for IMAP Foldertree, as there is no Imap host
908 907
 					continue;
909 908
 				}
910
-				$identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']);
911
-				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
909
+				$identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']);
910
+				$accArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); // as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
912 911
 			}
913 912
 		}
914
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
913
+		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array();
915 914
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
916 915
 		{
917
-			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
916
+			if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
918 917
 			{
919 918
 				$_folder = $this->mail_bo->icServer->getCurrentMailbox();
920 919
 				//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace());
921
-				$counter =1;
920
+				$counter = 1;
922 921
 				foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont)
923 922
 				{
924 923
 					$moveaction = 'move_';
925
-					if ($_folder!=$i)
924
+					if ($_folder != $i)
926 925
 					{
927 926
 						$moveaction .= $lastFolderUsedForMoveCont;
928 927
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
@@ -933,7 +932,7 @@  discard block
 block discarded – undo
933 932
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
934 933
 							$fS['shortDisplayName'] = $i;
935 934
 							$moveactions[$moveaction] = $fS;
936
-							$counter ++;
935
+							$counter++;
937 936
 						}
938 937
 						else
939 938
 						{
@@ -943,9 +942,9 @@  discard block
 block discarded – undo
943 942
 					}
944 943
 				}
945 944
 			}
946
-			elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
945
+			elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
947 946
 			{
948
-				$counter =1;
947
+				$counter = 1;
949 948
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
950 949
 				{
951 950
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
@@ -958,19 +957,19 @@  discard block
 block discarded – undo
958 957
 						$fS['profileName'] = $accArray[$pid];
959 958
 						$fS['shortDisplayName'] = $i;
960 959
 						$moveactions[$moveaction] = $fS;
961
-						$counter ++;
960
+						$counter++;
962 961
 					}
963 962
 				}
964 963
 			}
965 964
 		}
966
-		Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
965
+		Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
967 966
 		$group = 0;
968
-		$actions =  array(
967
+		$actions = array(
969 968
 			'open' => array(
970 969
 				'caption' => lang('Open'),
971 970
 				'icon' => 'view',
972 971
 				'group' => ++$group,
973
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
972
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open',
974 973
 				'allowOnMultiple' => false,
975 974
 				'default' => true,
976 975
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet'))
@@ -1023,20 +1022,20 @@  discard block
 block discarded – undo
1023 1022
 				'allowOnMultiple' => false,
1024 1023
 			)
1025 1024
 		);
1026
-		$macounter=0;
1025
+		$macounter = 0;
1027 1026
 		if (!empty($moveactions))
1028 1027
 		{
1029 1028
 			//error_log(__METHOD__.__LINE__.array2string($moveactions));
1030
-			$children=array();
1031
-			$pID=0;
1029
+			$children = array();
1030
+			$pID = 0;
1032 1031
 			foreach ($moveactions as $moveaction => $lastFolderUsedForMove)
1033 1032
 			{
1034
-				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group);
1033
+				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group);
1035 1034
 				//error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#');
1036 1035
 				$children = array_merge($children,
1037 1036
 					array(
1038 1037
 						$moveaction => array(
1039
-							'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
1038
+							'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''),
1040 1039
 							'icon' => 'move',
1041 1040
 							'group' => $group,
1042 1041
 							'onExecute' => 'javaScript:app.mail.mail_move2folder',
@@ -1047,7 +1046,7 @@  discard block
 block discarded – undo
1047 1046
 				$pID = $lastFolderUsedForMove['profileID'];
1048 1047
 				$macounter++;
1049 1048
 			}
1050
-			$actions['moveto'] =	array(
1049
+			$actions['moveto'] = array(
1051 1050
 				'caption' => lang('Move selected to'),
1052 1051
 				'icon' => 'move',
1053 1052
 				'group' => $group,
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
 				'icon' => 'tracker/navbar',
1091 1090
 				'onExecute' => 'javaScript:app.mail.mail_integrate',
1092 1091
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1093
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
1092
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
1094 1093
 				'allowOnMultiple' => false,
1095 1094
 			),
1096 1095
 			'calendar' => array(
@@ -1309,25 +1308,25 @@  discard block
 block discarded – undo
1309 1308
 	 * @param array &$rows
1310 1309
 	 * @param array &$readonlys
1311 1310
 	 */
1312
-	public static function get_rows(&$query,&$rows,&$readonlys)
1311
+	public static function get_rows(&$query, &$rows, &$readonlys)
1313 1312
 	{
1314
-		unset($readonlys);	// not used, but required by function signature
1313
+		unset($readonlys); // not used, but required by function signature
1315 1314
 
1316 1315
 		// handle possible profile change in get_rows
1317 1316
 		if (!empty($query['selectedFolder']))
1318 1317
 		{
1319
-			list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1318
+			list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1320 1319
 			if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])
1321 1320
 			{
1322 1321
 				try {
1323
-					$mail_ui = new mail_ui(false);	// do NOT run constructor, as we change profile anyway
1322
+					$mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway
1324 1323
 					$mail_ui->changeProfile($_profileID);
1325 1324
 					$query['actions'] = $mail_ui->get_actions();
1326 1325
 				}
1327
-				catch(Exception $e)
1326
+				catch (Exception $e)
1328 1327
 				{
1329 1328
 					unset($e);
1330
-					$rows=array();
1329
+					$rows = array();
1331 1330
 					return 0;
1332 1331
 				}
1333 1332
 				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
@@ -1337,12 +1336,12 @@  discard block
 block discarded – undo
1337 1336
 		{
1338 1337
 			try
1339 1338
 			{
1340
-				$mail_ui = new mail_ui(true);	// run constructor for current profile
1339
+				$mail_ui = new mail_ui(true); // run constructor for current profile
1341 1340
 			}
1342
-			catch(Exception $e)
1341
+			catch (Exception $e)
1343 1342
 			{
1344 1343
 				unset($e);
1345
-				$rows=array();
1344
+				$rows = array();
1346 1345
 				return 0;
1347 1346
 			}
1348 1347
 			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
@@ -1353,68 +1352,68 @@  discard block
 block discarded – undo
1353 1352
 		//$query['search'] is the phrase in the searchbox
1354 1353
 
1355 1354
 		$mail_ui->mail_bo->restoreSessionData();
1356
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1355
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder'];
1357 1356
 		$mail_ui->mail_bo->saveSessionData();
1358 1357
 
1359 1358
 		$sRToFetch = null;
1360
-		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
1361
-		if (strpos($_folderName,self::$delimiter)!==false)
1359
+		list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1360
+		if (strpos($_folderName, self::$delimiter) !== false)
1362 1361
 		{
1363
-			list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3);
1362
+			list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3);
1364 1363
 			unset($app);
1365 1364
 		}
1366 1365
 		//save selected Folder to sessionData (mailbox)->currentFolder
1367
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1368
-		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1366
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName;
1367
+		$toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default)
1369 1368
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1370 1369
 		{
1371
-			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false);
1370
+			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false);
1372 1371
 		}
1373 1372
 		else
1374 1373
 		{
1375 1374
 			// take the extra time on failure
1376
-			if (!$mail_ui->mail_bo->folderExists($_folderName,true))
1375
+			if (!$mail_ui->mail_bo->folderExists($_folderName, true))
1377 1376
 			{
1378 1377
 				//error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead');
1379
-				$query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX';
1378
+				$query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX';
1380 1379
 			}
1381 1380
 		}
1382 1381
 		$mail_ui->mail_bo->saveSessionData();
1383 1382
 		$rowsFetched['messages'] = null;
1384
-		$offset = $query['start']+1; // we always start with 1
1383
+		$offset = $query['start'] + 1; // we always start with 1
1385 1384
 		$maxMessages = $query['num_rows'];
1386 1385
 		//error_log(__METHOD__.__LINE__.array2string($query));
1387
-		$sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']);
1388
-		if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
1386
+		$sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']);
1387
+		if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
1389 1388
 		{
1390 1389
 			if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1391 1390
 			{
1392
-				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
1391
+				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1393 1392
 				if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1394 1393
 				{
1395
-					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
1394
+					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true;
1396 1395
 				}
1397 1396
 			}
1398 1397
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1399 1398
 			$cutoffdate = $cutoffdate2 = null;
1400
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1401
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1399
+			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
1400
+			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
1402 1401
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1403 1402
 			$filter = array(
1404
-				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
1405
-				'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
1403
+				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
1404
+				'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
1406 1405
 				'string' => $query['search'],
1407 1406
 				'status' => 'any',
1408 1407
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1409 1408
 			);
1410
-			if ($query['enddate']||$query['startdate']) {
1409
+			if ($query['enddate'] || $query['startdate']) {
1411 1410
 				$filter['range'] = "BETWEEN";
1412 1411
 				if ($cutoffdate) {
1413
-					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1412
+					$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
1414 1413
 					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1415 1414
 				}
1416 1415
 				if ($cutoffdate2) {
1417
-					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1416
+					$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
1418 1417
 					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1419 1418
 				}
1420 1419
 			}
@@ -1427,17 +1426,17 @@  discard block
 block discarded – undo
1427 1426
 		{
1428 1427
 			$filter['status'] = $query['filter'];
1429 1428
 		}
1430
-		$reverse = ($query['sort']=='ASC'?false:true);
1429
+		$reverse = ($query['sort'] == 'ASC' ? false : true);
1431 1430
 		$prefchanged = false;
1432
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1431
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1433 1432
 		{
1434 1433
 			//error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']);
1435
-			$GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user');
1434
+			$GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user');
1436 1435
 			$prefchanged = true;
1437 1436
 		}
1438
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1437
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1439 1438
 		{
1440
-			$GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user');
1439
+			$GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user');
1441 1440
 			$prefchanged = true;
1442 1441
 		}
1443 1442
 		if ($prefchanged)
@@ -1468,13 +1467,13 @@  discard block
 block discarded – undo
1468 1467
 				$rowsFetched['messages'] = $_sR['count'];
1469 1468
 				$ids = $_sR['match']->ids;
1470 1469
 				// if $sR is false, something failed fundamentally
1471
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1472
-				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1473
-				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1470
+				if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids));
1471
+				$sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids
1472
+				$sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1474 1473
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
1475 1474
 				$maxMessages = 75;
1476 1475
 				$sortResultwH['header'] = array();
1477
-				if (count($sRToFetch)>0)
1476
+				if (count($sRToFetch) > 0)
1478 1477
 				{
1479 1478
 					//error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch));
1480 1479
 					$sortResult = array();
@@ -1488,7 +1487,7 @@  discard block
 block discarded – undo
1488 1487
 						$filter,
1489 1488
 						$sRToFetch,
1490 1489
 						true, //cacheResult
1491
-						($query['filter2']?true:false) // fetchPreview
1490
+						($query['filter2'] ? true : false) // fetchPreview
1492 1491
 					);
1493 1492
 				}
1494 1493
 			}
@@ -1505,30 +1504,30 @@  discard block
 block discarded – undo
1505 1504
 					$filter,
1506 1505
 					null, // this uids only
1507 1506
 					true, // cacheResult
1508
-					($query['filter2']?true:false) // fetchPreview
1507
+					($query['filter2'] ? true : false) // fetchPreview
1509 1508
 				);
1510 1509
 				$rowsFetched['messages'] = $sortResultwH['info']['total'];
1511 1510
 			}
1512 1511
 		}
1513 1512
 		catch (Exception $e)
1514 1513
 		{
1515
-			$sortResultwH=array();
1516
-			$sR=array();
1514
+			$sortResultwH = array();
1515
+			$sR = array();
1517 1516
 			self::callWizard($e->getMessage(), false, 'error');
1518 1517
 		}
1519 1518
 		$response = Api\Json\Response::get();
1520 1519
 		// unlock immediately after fetching the rows
1521
-		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
1520
+		if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false)
1522 1521
 		{
1523 1522
 			//error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']);
1524 1523
 			$response->call('app.mail.unlock_tree');
1525 1524
 		}
1526 1525
 
1527
-		if (is_array($sR) && count($sR)>0)
1526
+		if (is_array($sR) && count($sR) > 0)
1528 1527
 		{
1529 1528
 			foreach ((array)$sR as $key => $v)
1530 1529
 			{
1531
-				if (array_key_exists($key,(array)$sortResultwH['header'])==true)
1530
+				if (array_key_exists($key, (array)$sortResultwH['header']) == true)
1532 1531
 				{
1533 1532
 					$sortResult['header'][] = $sortResultwH['header'][$key];
1534 1533
 				}
@@ -1546,12 +1545,12 @@  discard block
 block discarded – undo
1546 1545
 		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1547 1546
 
1548 1547
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1549
-		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview');
1550
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1551
-		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1548
+		$cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview');
1549
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1550
+		$rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema);
1552 1551
 		//error_log(__METHOD__.__LINE__.array2string($rows));
1553 1552
 
1554
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1553
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__);
1555 1554
 		return $rowsFetched['messages'];
1556 1555
 	}
1557 1556
 
@@ -1563,7 +1562,7 @@  discard block
 block discarded – undo
1563 1562
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1564 1563
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1565 1564
 	 */
1566
-	function createRowID($_folderName, $message_uid, $_prependApp=false)
1565
+	function createRowID($_folderName, $message_uid, $_prependApp = false)
1567 1566
 	{
1568 1567
 		return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp);
1569 1568
 	}
@@ -1577,9 +1576,9 @@  discard block
 block discarded – undo
1577 1576
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1578 1577
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1579 1578
 	 */
1580
-	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false)
1579
+	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false)
1581 1580
 	{
1582
-		return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1581
+		return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1583 1582
 	}
1584 1583
 
1585 1584
 	/**
@@ -1590,13 +1589,13 @@  discard block
 block discarded – undo
1590 1589
 	 */
1591 1590
 	static function splitRowID($_rowID)
1592 1591
 	{
1593
-		$res = explode(self::$delimiter,$_rowID);
1592
+		$res = explode(self::$delimiter, $_rowID);
1594 1593
 		// as a rowID is perceeded by app::, should be mail!
1595 1594
 		//error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res));
1596
-		if (count($res)==4 && is_numeric($res[0]) )
1595
+		if (count($res) == 4 && is_numeric($res[0]))
1597 1596
 		{
1598 1597
 			// we have an own created rowID; prepend app=mail
1599
-			array_unshift($res,'mail');
1598
+			array_unshift($res, 'mail');
1600 1599
 		}
1601 1600
 		return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]);
1602 1601
 	}
@@ -1610,56 +1609,56 @@  discard block
 block discarded – undo
1610 1609
 	{
1611 1610
 		$actions = $this->get_actions();
1612 1611
 		$arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print',
1613
-			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1',	'label2', 'label3',	'label4', 'label5');
1614
-		foreach( $arrActions as &$act)
1612
+			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5');
1613
+		foreach ($arrActions as &$act)
1615 1614
 		{
1616 1615
 			//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
1617 1616
 			switch ($act)
1618 1617
 			{
1619 1618
 				case 'forward':
1620
-					$actionsenabled[$act]=$actions[$act];
1619
+					$actionsenabled[$act] = $actions[$act];
1621 1620
 					break;
1622 1621
 				case 'save':
1623
-					$actionsenabled[$act]=$actions[$act];
1622
+					$actionsenabled[$act] = $actions[$act];
1624 1623
 
1625 1624
 					break;
1626 1625
 				case 'view':
1627
-					$actionsenabled[$act]=$actions[$act];
1626
+					$actionsenabled[$act] = $actions[$act];
1628 1627
 					break;
1629 1628
 				case 'flagged':
1630
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1629
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1631 1630
 					break;
1632 1631
 				case 'read':
1633
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1632
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1634 1633
 					break;
1635 1634
 				case 'label1':
1636 1635
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important');
1637
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1636
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1638 1637
 					break;
1639 1638
 				case 'label2':
1640 1639
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job');
1641
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1640
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1642 1641
 					break;
1643 1642
 				case 'label3':
1644 1643
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal');
1645
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1644
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1646 1645
 					break;
1647 1646
 				case 'label4':
1648 1647
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do');
1649
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1648
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1650 1649
 					break;
1651 1650
 				case 'label5':
1652 1651
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later');
1653
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1652
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1654 1653
 					break;
1655 1654
 				default:
1656
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1655
+					if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act];
1657 1656
 			}
1658 1657
 		}
1659 1658
 		unset($actionsenabled['drag_mail']);
1660 1659
 		//error_log(array2string($actionsenabled['view']));
1661
-		unset($actionsenabled['view']['children']['openastext']);//not supported in preview
1662
-		unset($actionsenabled['view']['children']['openashtml']);//not supported in preview
1660
+		unset($actionsenabled['view']['children']['openastext']); //not supported in preview
1661
+		unset($actionsenabled['view']['children']['openashtml']); //not supported in preview
1663 1662
 
1664 1663
 		return $actionsenabled;
1665 1664
 	}
@@ -1673,45 +1672,45 @@  discard block
 block discarded – undo
1673 1672
 	 * @param array $_folderType used to determine if we need to populate from/to
1674 1673
 	 * @return array populated result array
1675 1674
 	 */
1676
-	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1675
+	public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0)
1677 1676
 	{
1678 1677
 		if (Mail::$debugTimes) $starttime = microtime(true);
1679 1678
 		$rv = array();
1680
-		$i=0;
1681
-		foreach((array)$_headers as $header)
1679
+		$i = 0;
1680
+		foreach ((array)$_headers as $header)
1682 1681
 		{
1683 1682
 			$i++;
1684 1683
 			$data = array();
1685 1684
 			//error_log(__METHOD__.array2string($header));
1686 1685
 			$message_uid = $header['uid'];
1687 1686
 			$data['uid'] = $message_uid;
1688
-			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1687
+			$data['row_id'] = $this->createRowID($_folderName, $message_uid);
1689 1688
 
1690 1689
 			$flags = "";
1691
-			if(!empty($header['recent'])) $flags .= "R";
1692
-			if(!empty($header['flagged'])) $flags .= "F";
1693
-			if(!empty($header['answered'])) $flags .= "A";
1694
-			if(!empty($header['forwarded'])) $flags .= "W";
1695
-			if(!empty($header['deleted'])) $flags .= "D";
1696
-			if(!empty($header['seen'])) $flags .= "S";
1697
-			if(!empty($header['label1'])) $flags .= "1";
1698
-			if(!empty($header['label2'])) $flags .= "2";
1699
-			if(!empty($header['label3'])) $flags .= "3";
1700
-			if(!empty($header['label4'])) $flags .= "4";
1701
-			if(!empty($header['label5'])) $flags .= "5";
1690
+			if (!empty($header['recent'])) $flags .= "R";
1691
+			if (!empty($header['flagged'])) $flags .= "F";
1692
+			if (!empty($header['answered'])) $flags .= "A";
1693
+			if (!empty($header['forwarded'])) $flags .= "W";
1694
+			if (!empty($header['deleted'])) $flags .= "D";
1695
+			if (!empty($header['seen'])) $flags .= "S";
1696
+			if (!empty($header['label1'])) $flags .= "1";
1697
+			if (!empty($header['label2'])) $flags .= "2";
1698
+			if (!empty($header['label3'])) $flags .= "3";
1699
+			if (!empty($header['label4'])) $flags .= "4";
1700
+			if (!empty($header['label5'])) $flags .= "5";
1702 1701
 
1703 1702
 			$data["status"] = "<span class=\"status_img\"></span>";
1704 1703
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
1705 1704
 
1706 1705
 			// the css for this row
1707
-			$is_recent=false;
1706
+			$is_recent = false;
1708 1707
 			$css_styles = array("mail");
1709 1708
 			if ($header['deleted']) {
1710 1709
 				$css_styles[] = 'deleted';
1711 1710
 			}
1712 1711
 			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1713 1712
 				$css_styles[] = 'recent';
1714
-				$is_recent=true;
1713
+				$is_recent = true;
1715 1714
 			}
1716 1715
 			if ($header['priority'] < 3) {
1717 1716
 				$css_styles[] = 'prio_high';
@@ -1749,19 +1748,19 @@  discard block
 block discarded – undo
1749 1748
 			if (in_array("subject", $cols))
1750 1749
 			{
1751 1750
 				// filter out undisplayable characters
1752
-				$search = array('[\016]','[\017]',
1753
-					'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1754
-					'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1751
+				$search = array('[\016]', '[\017]',
1752
+					'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1753
+					'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1755 1754
 				$replace = '';
1756 1755
 
1757
-				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1756
+				$header['subject'] = preg_replace($search, $replace, $header['subject']);
1758 1757
 				// curly brackets get messed up by the template!
1759 1758
 
1760 1759
 				if (!empty($header['subject'])) {
1761 1760
 					// make the subject shorter if it is to long
1762 1761
 					$subject = $header['subject'];
1763 1762
 				} else {
1764
-					$subject = '('. lang('no subject') .')';
1763
+					$subject = '('.lang('no subject').')';
1765 1764
 				}
1766 1765
 
1767 1766
 				$data["subject"] = $subject; // the mailsubject
@@ -1771,53 +1770,53 @@  discard block
 block discarded – undo
1771 1770
 			//error_log(__METHOD__.__LINE__.array2string($header));
1772 1771
 			if (in_array("attachments", $cols))
1773 1772
 			{
1774
-				if($header['mimetype'] == 'multipart/mixed' ||
1773
+				if ($header['mimetype'] == 'multipart/mixed' ||
1775 1774
 					$header['mimetype'] == 'multipart/signed' ||
1776 1775
 					$header['mimetype'] == 'multipart/related' ||
1777 1776
 					$header['mimetype'] == 'multipart/report' ||
1778 1777
 					$header['mimetype'] == 'text/calendar' ||
1779 1778
 					$header['mimetype'] == 'text/html' ||
1780
-					substr($header['mimetype'],0,11) == 'application' ||
1781
-					substr($header['mimetype'],0,5) == 'audio' ||
1782
-					substr($header['mimetype'],0,5) == 'video' ||
1779
+					substr($header['mimetype'], 0, 11) == 'application' ||
1780
+					substr($header['mimetype'], 0, 5) == 'audio' ||
1781
+					substr($header['mimetype'], 0, 5) == 'video' ||
1783 1782
 					$header['mimetype'] == 'multipart/alternative')
1784 1783
 				{
1785
-					$image = Api\Html::image('mail','attach');
1784
+					$image = Api\Html::image('mail', 'attach');
1786 1785
 					$imageHTMLBlock = '';
1787
-					$datarowid = $this->createRowID($_folderName,$message_uid,true);
1786
+					$datarowid = $this->createRowID($_folderName, $message_uid, true);
1788 1787
 					$attachments = $header['attachments'];
1789
-					if (count($attachments)<1)
1788
+					if (count($attachments) < 1)
1790 1789
 					{
1791 1790
 						$image = '&nbsp;';
1792 1791
 					}
1793
-					if (count($attachments)==1)
1792
+					if (count($attachments) == 1)
1794 1793
 					{
1795
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1796
-						$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
1794
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1795
+						$image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : ''));
1797 1796
 					}
1798
-					if (count($attachments)>1)
1797
+					if (count($attachments) > 1)
1799 1798
 					{
1800
-						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1801
-						$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
1799
+						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1800
+						$image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments)));
1802 1801
 					}
1803 1802
 
1804 1803
 					$attachmentFlag = $image;
1805 1804
 				} else {
1806
-					$attachmentFlag ='&nbsp;';
1805
+					$attachmentFlag = '&nbsp;';
1807 1806
 				}
1808 1807
 				// show priority flag
1809 1808
 				if ($header['priority'] < 3) {
1810
-					 $image = Api\Html::image('mail','prio_high');
1809
+					 $image = Api\Html::image('mail', 'prio_high');
1811 1810
 				} elseif ($header['priority'] > 3) {
1812
-					$image = Api\Html::image('mail','prio_low');
1811
+					$image = Api\Html::image('mail', 'prio_low');
1813 1812
 				} else {
1814 1813
 					$image = '';
1815 1814
 				}
1816 1815
 				// show a flag for flagged messages
1817
-				$imageflagged ='';
1816
+				$imageflagged = '';
1818 1817
 				if ($header['flagged'])
1819 1818
 				{
1820
-					$imageflagged = Api\Html::image('mail','unread_flagged_small');
1819
+					$imageflagged = Api\Html::image('mail', 'unread_flagged_small');
1821 1820
 				}
1822 1821
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
1823 1822
 			}
@@ -1826,7 +1825,7 @@  discard block
 block discarded – undo
1826 1825
 			if (in_array("toaddress", $cols))
1827 1826
 			{
1828 1827
 				// sent or drafts or template folder means foldertype > 0, use to address instead of from
1829
-				$data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset);
1828
+				$data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset);
1830 1829
 			}
1831 1830
 
1832 1831
 			if (in_array("additionaltoaddress", $cols))
@@ -1859,29 +1858,29 @@  discard block
 block discarded – undo
1859 1858
 			$data['flags'] = Array();
1860 1859
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1861 1860
 			foreach ($css_styles as &$flag) {
1862
-				if ($flag!='mail')
1861
+				if ($flag != 'mail')
1863 1862
 				{
1864
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
1865
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
1866
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
1867
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
1868
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
1869
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
1863
+					if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; }
1864
+					elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; }
1865
+					elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; }
1866
+					elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; }
1867
+					elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; }
1868
+					elseif ($flag == 'unseen') {unset($data["flags"]['read']); }
1870 1869
 					else $data["flags"][$flag] = $flag;
1871 1870
 				}
1872 1871
 			}
1873 1872
 			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
1874
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1873
+			if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
1875 1874
 			$data['attachmentsBlock'] = $imageHTMLBlock;
1876
-			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
1877
-			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
1875
+			$data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]);
1876
+			if (in_array("bodypreview", $cols) && $header['bodypreview'])
1878 1877
 			{
1879 1878
 				$data["bodypreview"] = $header['bodypreview'];
1880 1879
 			}
1881 1880
 			$rv[] = $data;
1882 1881
 			//error_log(__METHOD__.__LINE__.array2string($data));
1883 1882
 		}
1884
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
1883
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__);
1885 1884
 
1886 1885
 		// ToDo: call this ONLY if labels change
1887 1886
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -1896,8 +1895,8 @@  discard block
 block discarded – undo
1896 1895
 	 */
1897 1896
 	function displayHeader()
1898 1897
 	{
1899
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
1900
-		if(isset($_GET['part'])) $partID = $_GET['part'];
1898
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
1899
+		if (isset($_GET['part'])) $partID = $_GET['part'];
1901 1900
 
1902 1901
 		$hA = self::splitRowID($rowID);
1903 1902
 		$uid = $hA['msgUID'];
@@ -1911,17 +1910,17 @@  discard block
 block discarded – undo
1911 1910
 		}
1912 1911
 
1913 1912
 		$this->mail_bo->reopen($mailbox);
1914
-		$headers_in	= $this->mail_bo->getMessageRawHeader($uid, $partID);
1913
+		$headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID);
1915 1914
 
1916 1915
 		// add line breaks to $rawheaders
1917
-		$newRawHeaders = explode("\n",$headers_in);
1916
+		$newRawHeaders = explode("\n", $headers_in);
1918 1917
 		reset($newRawHeaders);
1919 1918
 
1920 1919
 		// reset $rawheaders
1921
-		$rawheaders 	= "";
1920
+		$rawheaders = "";
1922 1921
 		// create it new, with good line breaks
1923 1922
 		reset($newRawHeaders);
1924
-		while(list($key,$value) = @each($newRawHeaders)) {
1923
+		while (list($key, $value) = @each($newRawHeaders)) {
1925 1924
 			$rawheaders .= wordwrap($value, 90, "\n     ");
1926 1925
 		}
1927 1926
 
@@ -1933,7 +1932,7 @@  discard block
 block discarded – undo
1933 1932
 		}
1934 1933
 
1935 1934
 		header('Content-type: text/html; charset=iso-8859-1');
1936
-		print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
1935
+		print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>';
1937 1936
 
1938 1937
 	}
1939 1938
 
@@ -1946,10 +1945,10 @@  discard block
 block discarded – undo
1946 1945
 	{
1947 1946
 		if (is_null($_requesteddata)) $_requesteddata = $_GET;
1948 1947
 
1949
-		$preventRedirect=false;
1950
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
1951
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
1952
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
1948
+		$preventRedirect = false;
1949
+		if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id'];
1950
+		if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null;
1951
+		if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false);
1953 1952
 
1954 1953
 		$hA = self::splitRowID($rowID);
1955 1954
 		$uid = $hA['msgUID'];
@@ -1973,79 +1972,79 @@  discard block
 block discarded – undo
1973 1972
 		}
1974 1973
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
1975 1974
 		{
1976
-			Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
1975
+			Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft'));
1977 1976
 		}
1978 1977
 		$this->mail_bo->reopen($mailbox);
1979 1978
 		// retrieve the flags of the message, before touching it.
1980 1979
 		try
1981 1980
 		{
1982
-			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
1981
+			$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox);
1983 1982
 		}
1984 1983
 		catch (Api\Exception $e)
1985 1984
 		{
1986 1985
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
1987
-			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
1986
+			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID);
1988 1987
 			Framework::message($e->getMessage(), 'error');
1989 1988
 		}
1990 1989
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
1991
-		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
1990
+		$envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox);
1992 1991
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
1993
-		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
1992
+		$this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox);
1994 1993
 		$fetchEmbeddedImages = false;
1995 1994
 		// if we are in HTML so its likely that we should show the embedded images; as a result
1996 1995
 		// we do NOT want to see those, that are embedded in the list of attachments
1997
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
1998
-		$attachments	= $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
1996
+		if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true;
1997
+		$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox);
1999 1998
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2000 1999
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
2001 2000
 
2002
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2003
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2004
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2001
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2002
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2003
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2005 2004
 
2006 2005
 		//error_log(__METHOD__.__LINE__.$mailBody);
2007 2006
 		$this->mail_bo->closeConnection();
2008 2007
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
2009 2008
 		$etpl = new Etemplate('mail.display');
2010
-		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2009
+		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false);
2011 2010
 
2012 2011
 		// Set up data for taglist widget(s)
2013
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2012
+		if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']);
2014 2013
 		$sel_options = array();
2015
-		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2014
+		foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field)
2016 2015
 		{
2017 2016
 			if (!isset($envelope[$field])) continue;
2018
-			foreach($envelope[$field] as $field_data)
2017
+			foreach ($envelope[$field] as $field_data)
2019 2018
 			{
2020 2019
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
2021 2020
 				$content[$field][] = $field_data;
2022 2021
 				$sel_options[$field][] = array(
2023 2022
 					// taglist requires these - not optional
2024 2023
 					'id' => $field_data,
2025
-					'label' => str_replace('"',"'",$field_data),
2024
+					'label' => str_replace('"', "'", $field_data),
2026 2025
 				);
2027 2026
 			}
2028 2027
 		}
2029 2028
 		$actionsenabled = $this->getDisplayToolbarActions();
2030 2029
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2031 2030
 		if (empty($subject)) $subject = lang('no subject');
2032
-		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2031
+		$content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg);
2033 2032
 		// Send mail ID so we can use it for actions
2034 2033
 		$content['mail_id'] = $rowID;
2035 2034
 		if (!is_array($headers) || !isset($headers['DATE']))
2036 2035
 		{
2037
-			$headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:'');
2036
+			$headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : '');
2038 2037
 		}
2039
-		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2038
+		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true);
2040 2039
 		$content['mail_displaysubject'] = $subject;
2041
-		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2042
-		if (!empty($partID)) $linkData['_partID']=$partID;
2043
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2044
-		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2040
+		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID);
2041
+		if (!empty($partID)) $linkData['_partID'] = $partID;
2042
+		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions;
2043
+		$content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData);
2045 2044
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2046
-		$content['mail_id']=$rowID;
2047
-		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
2048
-		$content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone");
2045
+		$content['mail_id'] = $rowID;
2046
+		$content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight");
2047
+		$content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone");
2049 2048
 
2050 2049
 		// DRAG attachments actions
2051 2050
 		$etpl->setElementAttribute('mail_displayattachments', 'actions', array(
@@ -2062,22 +2061,22 @@  discard block
 block discarded – undo
2062 2061
 			$this->changeProfile($rememberServerID);
2063 2062
 		}
2064 2063
 
2065
-		$etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
2064
+		$etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2);
2066 2065
 	}
2067 2066
 
2068 2067
 	/**
2069 2068
 	 * Build actions for display toolbar
2070 2069
 	 */
2071
-	function getDisplayToolbarActions ()
2070
+	function getDisplayToolbarActions()
2072 2071
 	{
2073 2072
 		$actions = $this->get_toolbar_actions();
2074
-		$actions['mark']['children']['flagged']=array(
2073
+		$actions['mark']['children']['flagged'] = array(
2075 2074
 			'group' => $actions['mark']['children']['flagged']['group'],
2076 2075
 			'caption' => 'Flagged',
2077 2076
 			'icon' => 'unread_flagged_small',
2078 2077
 			'onExecute' => 'javaScript:app.mail.mail_flag',
2079 2078
 		);
2080
-		$actions['mark']['children']['unflagged']=array(
2079
+		$actions['mark']['children']['unflagged'] = array(
2081 2080
 			'group' => $actions['mark']['children']['flagged']['group'],
2082 2081
 			'caption' => 'Unflagged',
2083 2082
 			'icon' => 'read_flagged_small',
@@ -2089,9 +2088,9 @@  discard block
 block discarded – undo
2089 2088
 		$compose = $actions['composeasnew'];
2090 2089
 		unset($actions['composeasnew']);
2091 2090
 
2092
-		$actions2 = array_reverse($actions,true);
2093
-		$actions2['composeasnew']= $compose;
2094
-		return array_reverse($actions2,true);
2091
+		$actions2 = array_reverse($actions, true);
2092
+		$actions2['composeasnew'] = $compose;
2093
+		return array_reverse($actions2, true);
2095 2094
 	}
2096 2095
 
2097 2096
 	/**
@@ -2104,22 +2103,22 @@  discard block
 block discarded – undo
2104 2103
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
2105 2104
 	 * @return array|string data array or html or empty string
2106 2105
 	 */
2107
-	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
2106
+	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false)
2108 2107
 	{
2109
-		$attachmentHTMLBlock='';
2108
+		$attachmentHTMLBlock = '';
2110 2109
 		$attachmentHTML = array();
2111 2110
 		if (is_array($attachments) && count($attachments) > 0) {
2112
-			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
2113
-			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
2111
+			$url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"');
2112
+			$url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all'));
2114 2113
 
2115 2114
 			foreach ($attachments as $key => $value)
2116 2115
 			{
2117
-				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
2118
-				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2116
+				$attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)'));
2117
+				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8');
2119 2118
 				//error_log(array2string($value));
2120 2119
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2121
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2122
-				$attachmentHTML[$key]['type']=$value['mimeType'];
2120
+				if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2121
+				$attachmentHTML[$key]['type'] = $value['mimeType'];
2123 2122
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2124 2123
 				$hA = self::splitRowID($rowID);
2125 2124
 				$uid = $hA['msgUID'];
@@ -2129,26 +2128,25 @@  discard block
 block discarded – undo
2129 2128
 				$attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
2130 2129
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
2131 2130
 				));
2132
-				$attachmentHTML[$key]['size']=Vfs::hsize($value['size']);
2133
-				$attachmentHTML[$key]['attachment_number']=$key;
2134
-				$attachmentHTML[$key]['partID']=$value['partID'];
2131
+				$attachmentHTML[$key]['size'] = Vfs::hsize($value['size']);
2132
+				$attachmentHTML[$key]['attachment_number'] = $key;
2133
+				$attachmentHTML[$key]['partID'] = $value['partID'];
2135 2134
 				$attachmentHTML[$key]['mail_id'] = $rowID;
2136
-				$attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
2135
+				$attachmentHTML[$key]['winmailFlag'] = $value['is_winmail'];
2137 2136
 				$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
2138 2137
 
2139
-				switch(strtoupper($value['mimeType']))
2138
+				switch (strtoupper($value['mimeType']))
2140 2139
 				{
2141 2140
 					case 'MESSAGE/RFC822':
2142
-						$linkData = array
2143
-						(
2141
+						$linkData = array(
2144 2142
 							'menuaction'	=> 'mail.mail_ui.displayMessage',
2145 2143
 							'mode'		=> 'display', //message/rfc822 attachments should be opened in display mode
2146 2144
 							'id'		=> $rowID,
2147 2145
 							'part'		=> $value['partID'],
2148 2146
 							'is_winmail'    => $value['is_winmail']
2149 2147
 						);
2150
-						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
2151
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2148
+						$windowName = 'displayMessage_'.$rowID.'_'.$value['partID'];
2149
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2152 2150
 						break;
2153 2151
 					case 'IMAGE/JPEG':
2154 2152
 					case 'IMAGE/PNG':
@@ -2159,7 +2157,7 @@  discard block
 block discarded – undo
2159 2157
 					case 'TEXT/HTML':
2160 2158
 					case 'TEXT/DIRECTORY':
2161 2159
 						$sfxMimeType = $value['mimeType'];
2162
-						$buff = explode('.',$value['name']);
2160
+						$buff = explode('.', $value['name']);
2163 2161
 						$suffix = '';
2164 2162
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2165 2163
 						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2172,49 +2170,47 @@  discard block
 block discarded – undo
2172 2170
 					case 'TEXT/VCARD':
2173 2171
 					case 'TEXT/CALENDAR':
2174 2172
 					case 'TEXT/X-VCALENDAR':
2175
-						$linkData = array
2176
-						(
2173
+						$linkData = array(
2177 2174
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2178 2175
 							'id'		=> $rowID,
2179 2176
 							'part'		=> $value['partID'],
2180 2177
 							'is_winmail'    => $value['is_winmail'],
2181 2178
 							'mailbox'   => base64_encode($mailbox),
2182 2179
 						);
2183
-						$windowName = 'displayAttachment_'. $uid;
2180
+						$windowName = 'displayAttachment_'.$uid;
2184 2181
 						$reg = '800x600';
2185 2182
 						// handle calendar/vcard
2186
-						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
2183
+						if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR')
2187 2184
 						{
2188
-							$windowName = 'displayEvent_'. $rowID;
2189
-							$reg2 = Link::get_registry('calendar','view_popup');
2190
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2185
+							$windowName = 'displayEvent_'.$rowID;
2186
+							$reg2 = Link::get_registry('calendar', 'view_popup');
2187
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2191 2188
 						}
2192
-						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
2189
+						if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD')
2193 2190
 						{
2194
-							$windowName = 'displayContact_'. $rowID;
2195
-							$reg2 = Link::get_registry('addressbook','add_popup');
2196
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2191
+							$windowName = 'displayContact_'.$rowID;
2192
+							$reg2 = Link::get_registry('addressbook', 'add_popup');
2193
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2197 2194
 						}
2198 2195
 						// apply to action
2199
-						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
2200
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
2196
+						list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg));
2197
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);";
2201 2198
 						break;
2202 2199
 					default:
2203
-						$linkData = array
2204
-						(
2200
+						$linkData = array(
2205 2201
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2206 2202
 							'id'		=> $rowID,
2207 2203
 							'part'		=> $value['partID'],
2208 2204
 							'is_winmail'    => $value['is_winmail'],
2209 2205
 							'mailbox'   => base64_encode($mailbox),
2210 2206
 						);
2211
-						$linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';";
2207
+						$linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';";
2212 2208
 						break;
2213 2209
 				}
2214 2210
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
2215 2211
 				if (empty($attachmentHTML[$key]['mime_data']))
2216 2212
 				{
2217
-					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData);
2213
+					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData);
2218 2214
 					unset($attachmentHTML[$key]['mime_data']);
2219 2215
 				}
2220 2216
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2224,8 +2220,7 @@  discard block
 block discarded – undo
2224 2220
 					($value['name'] ? $value['name'] : lang('(no subject)')).
2225 2221
 					'</b></a>';
2226 2222
 
2227
-				$linkData = array
2228
-				(
2223
+				$linkData = array(
2229 2224
 					'menuaction'	=> 'mail.mail_ui.getAttachment',
2230 2225
 					'mode'		=> 'save',
2231 2226
 					'id'		=> $rowID,
@@ -2233,11 +2228,11 @@  discard block
 block discarded – undo
2233 2228
 					'is_winmail'    => $value['is_winmail'],
2234 2229
 					'mailbox'   => base64_encode($mailbox),
2235 2230
 				);
2236
-				$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
2231
+				$attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>";
2237 2232
 
2238 2233
 				if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
2239 2234
 				{
2240
-					$link_vfs_save = Egw::link('/index.php',array(
2235
+					$link_vfs_save = Egw::link('/index.php', array(
2241 2236
 						'menuaction' => 'filemanager.filemanager_select.select',
2242 2237
 						'mode' => 'saveas',
2243 2238
 						'name' => $value['name'],
@@ -2256,19 +2251,19 @@  discard block
 block discarded – undo
2256 2251
 							//$rowID
2257 2252
 							$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
2258 2253
 						}
2259
-						$link_vfs_save = Egw::link('/index.php',array(
2254
+						$link_vfs_save = Egw::link('/index.php', array(
2260 2255
 							'menuaction' => 'filemanager.filemanager_select.select',
2261 2256
 							'mode' => 'select-dir',
2262 2257
 							'method' => 'mail.mail_ui.vfsSaveAttachment',
2263 2258
 							'label' => lang('Save all'),
2264
-						)+$ids);
2259
+						) + $ids);
2265 2260
 						$vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>";
2266 2261
 					}
2267 2262
 					$attachmentHTML[$key]['link_save'] .= $vfs_save;
2268 2263
 					//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
2269 2264
 				}
2270 2265
 			}
2271
-			$attachmentHTMLBlock="<table width='100%'>";
2266
+			$attachmentHTMLBlock = "<table width='100%'>";
2272 2267
 			foreach ((array)$attachmentHTML as $row)
2273 2268
 			{
2274 2269
 				$attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>';
@@ -2286,7 +2281,7 @@  discard block
 block discarded – undo
2286 2281
 				unset($attachmentHTML[$ikey]['link_save']);
2287 2282
 			}
2288 2283
 		}
2289
-		return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML);
2284
+		return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML);
2290 2285
 	}
2291 2286
 
2292 2287
 	/**
@@ -2297,7 +2292,7 @@  discard block
 block discarded – undo
2297 2292
 	 */
2298 2293
 	function gatherVacation($cachedVacations = array())
2299 2294
 	{
2300
-		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host);
2295
+		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host);
2301 2296
 		//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
2302 2297
 
2303 2298
 		if ($isVacationEnabled)
@@ -2310,7 +2305,7 @@  discard block
 block discarded – undo
2310 2305
 
2311 2306
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
2312 2307
 				// Set vacation to the instance cache for particular account with expiration of one day
2313
-				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
2308
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24);
2314 2309
 			}
2315 2310
 			catch (PEAR_Exception $ex)
2316 2311
 			{
@@ -2331,36 +2326,36 @@  discard block
 block discarded – undo
2331 2326
 	function quotaDisplay($_usage, $_limit)
2332 2327
 	{
2333 2328
 
2334
-		if($_limit == 0) {
2335
-			$quotaPercent=100;
2329
+		if ($_limit == 0) {
2330
+			$quotaPercent = 100;
2336 2331
 		} else {
2337
-			$quotaPercent=round(($_usage*100)/$_limit);
2332
+			$quotaPercent = round(($_usage * 100) / $_limit);
2338 2333
 		}
2339 2334
 
2340
-		$quotaLimit=Mail::show_readable_size($_limit*1024);
2341
-		$quotaUsage=Mail::show_readable_size($_usage*1024);
2335
+		$quotaLimit = Mail::show_readable_size($_limit * 1024);
2336
+		$quotaUsage = Mail::show_readable_size($_usage * 1024);
2342 2337
 
2343 2338
 
2344
-		if($quotaPercent > 90 && $_limit>0) {
2345
-			$quotaBG='mail-index_QuotaRed';
2346
-		} elseif($quotaPercent > 80 && $_limit>0) {
2347
-			$quotaBG='mail-index_QuotaYellow';
2339
+		if ($quotaPercent > 90 && $_limit > 0) {
2340
+			$quotaBG = 'mail-index_QuotaRed';
2341
+		} elseif ($quotaPercent > 80 && $_limit > 0) {
2342
+			$quotaBG = 'mail-index_QuotaYellow';
2348 2343
 		} else {
2349
-			$quotaBG='mail-index_QuotaGreen';
2344
+			$quotaBG = 'mail-index_QuotaGreen';
2350 2345
 		}
2351 2346
 
2352
-		if($_limit > 0) {
2353
-			$quotaText = $quotaUsage .'/'.$quotaLimit;
2347
+		if ($_limit > 0) {
2348
+			$quotaText = $quotaUsage.'/'.$quotaLimit;
2354 2349
 		} else {
2355 2350
 			$quotaText = $quotaUsage;
2356 2351
 		}
2357 2352
 
2358
-		if($quotaPercent > 50) {
2353
+		if ($quotaPercent > 50) {
2359 2354
 		} else {
2360 2355
 		}
2361 2356
 		$quota['class'] = $quotaBG;
2362
-		$quota['text'] = lang('Quota: %1',$quotaText);
2363
-		$quota['percent'] = (string)round(($_usage*100)/$_limit);
2357
+		$quota['text'] = lang('Quota: %1', $quotaText);
2358
+		$quota['percent'] = (string)round(($_usage * 100) / $_limit);
2364 2359
 		return $quota;
2365 2360
 	}
2366 2361
 
@@ -2374,12 +2369,12 @@  discard block
 block discarded – undo
2374 2369
 		$uid	= $_GET['uid'];
2375 2370
 		$cid	= base64_decode($_GET['cid']);
2376 2371
 		$partID = urldecode($_GET['partID']);
2377
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2372
+		if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']);
2378 2373
 
2379 2374
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2380 2375
 		$this->mail_bo->reopen($mailbox);
2381 2376
 
2382
-		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true);	// true get contents as stream
2377
+		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream
2383 2378
 
2384 2379
 		$this->mail_bo->closeConnection();
2385 2380
 
@@ -2387,8 +2382,8 @@  discard block
 block discarded – undo
2387 2382
 
2388 2383
 		if ($attachment)
2389 2384
 		{
2390
-			header("Content-Type: ". $attachment->getType());
2391
-			header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"');
2385
+			header("Content-Type: ".$attachment->getType());
2386
+			header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"');
2392 2387
 			//header("Expires: 0");
2393 2388
 			// the next headers are for IE and SSL
2394 2389
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -2406,7 +2401,7 @@  discard block
 block discarded – undo
2406 2401
 
2407 2402
 	function getAttachment()
2408 2403
 	{
2409
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2404
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2410 2405
 
2411 2406
 		$hA = self::splitRowID($rowID);
2412 2407
 		$uid = $hA['msgUID'];
@@ -2418,11 +2413,11 @@  discard block
 block discarded – undo
2418 2413
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2419 2414
 			$this->changeProfile($icServerID);
2420 2415
 		}
2421
-		$part		= $_GET['part'];
2416
+		$part = $_GET['part'];
2422 2417
 		$is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0;
2423 2418
 
2424 2419
 		$this->mail_bo->reopen($mailbox);
2425
-		$attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false);
2420
+		$attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false);
2426 2421
 		$this->mail_bo->closeConnection();
2427 2422
 		if ($rememberServerID != $this->mail_bo->profileID)
2428 2423
 		{
@@ -2437,7 +2432,7 @@  discard block
 block discarded – undo
2437 2432
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type']))
2438 2433
 			{
2439 2434
 				$sfxMimeType = $attachment['type'];
2440
-				$buff = explode('.',$attachment['filename']);
2435
+				$buff = explode('.', $attachment['filename']);
2441 2436
 				$suffix = '';
2442 2437
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2443 2438
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2449,10 +2444,10 @@  discard block
 block discarded – undo
2449 2444
 			{
2450 2445
 				//error_log(__METHOD__."about to call calendar_ical");
2451 2446
 				$calendar_ical = new calendar_ical();
2452
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2447
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2453 2448
 				//error_log(__METHOD__.array2string($eventid));
2454 2449
 				if (!$eventid) $eventid = -1;
2455
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2450
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']);
2456 2451
 				//error_log(__METHOD__.$event);
2457 2452
 				if ((int)$event > 0)
2458 2453
 				{
@@ -2460,7 +2455,7 @@  discard block
 block discarded – undo
2460 2455
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2461 2456
 						'cal_id'      => $event,
2462 2457
 					);
2463
-					Egw::redirect_link('../index.php',$vars);
2458
+					Egw::redirect_link('../index.php', $vars);
2464 2459
 				}
2465 2460
 				//Import failed, download content anyway
2466 2461
 			}
@@ -2475,13 +2470,13 @@  discard block
 block discarded – undo
2475 2470
 				{
2476 2471
 					$vcard['uid'] = trim($vcard['uid']);
2477 2472
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2478
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2473
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2479 2474
 				}
2480 2475
 				if (!$contact) $contact = null;
2481 2476
 				// if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO))
2482
-				if ($contact || count($vcard)>2)
2477
+				if ($contact || count($vcard) > 2)
2483 2478
 				{
2484
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2479
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']);
2485 2480
 				}
2486 2481
 				if ((int)$contact > 0)
2487 2482
 				{
@@ -2489,14 +2484,14 @@  discard block
 block discarded – undo
2489 2484
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2490 2485
 						'contact_id'	=> $contact,
2491 2486
 					);
2492
-					Egw::redirect_link('../index.php',$vars);
2487
+					Egw::redirect_link('../index.php', $vars);
2493 2488
 				}
2494 2489
 				//Import failed, download content anyway
2495 2490
 			}
2496 2491
 		}
2497 2492
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2498
-		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
2499
-		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
2493
+		$filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part));
2494
+		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save");
2500 2495
 		echo $attachment['attachment'];
2501 2496
 
2502 2497
 		exit();
@@ -2511,9 +2506,9 @@  discard block
 block discarded – undo
2511 2506
 	function saveMessage()
2512 2507
 	{
2513 2508
 		$display = false;
2514
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2515
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2516
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2509
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2510
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2511
+		if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location'];
2517 2512
 
2518 2513
 		$hA = self::splitRowID($rowID);
2519 2514
 		$uid = $hA['msgUID'];
@@ -2541,14 +2536,14 @@  discard block
 block discarded – undo
2541 2536
 		if (!$display)
2542 2537
 		{
2543 2538
 			$headers = Horde_Mime_Headers::parseHeaders($message);
2544
-			$subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT']));
2545
-			Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
2539
+			$subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT']));
2540
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true);
2546 2541
 			echo $message;
2547 2542
 		}
2548 2543
 		else
2549 2544
 		{
2550
-			Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false);
2551
-			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
2545
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false);
2546
+			print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>';
2552 2547
 		}
2553 2548
 	}
2554 2549
 
@@ -2560,18 +2555,18 @@  discard block
 block discarded – undo
2560 2555
 	 * @param boolean $close Return javascript to close the window
2561 2556
 	 * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
2562 2557
 	 */
2563
-	function vfsSaveMessage($ids,$path, $close = true)
2558
+	function vfsSaveMessage($ids, $path, $close = true)
2564 2559
 	{
2565 2560
 		//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
2566 2561
 
2567 2562
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2568 2563
 		{
2569
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2564
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2570 2565
 		}
2571 2566
 		Api\Translation::add_app('mail');
2572 2567
 
2573 2568
 		$rememberServerID = $this->mail_bo->profileID;
2574
-		foreach((array)$ids as $id)
2569
+		foreach ((array)$ids as $id)
2575 2570
 		{
2576 2571
 			$hA = self::splitRowID($id);
2577 2572
 			$uid = $hA['msgUID'];
@@ -2582,20 +2577,20 @@  discard block
 block discarded – undo
2582 2577
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2583 2578
 				$this->changeProfile($icServerID);
2584 2579
 			}
2585
-			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
2586
-			$err=null;
2587
-			if(Vfs::is_dir($path))
2580
+			$message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox);
2581
+			$err = null;
2582
+			if (Vfs::is_dir($path))
2588 2583
 			{
2589
-				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
2590
-				$file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml';
2584
+				$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2585
+				$file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml';
2591 2586
 			}
2592 2587
 			else
2593 2588
 			{
2594 2589
 				$file = $path;
2595 2590
 			}
2596
-			if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message))
2591
+			if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message))
2597 2592
 			{
2598
-				$err .= lang('Error saving %1!',$file);
2593
+				$err .= lang('Error saving %1!', $file);
2599 2594
 				$succeeded = false;
2600 2595
 			}
2601 2596
 			else
@@ -2605,10 +2600,10 @@  discard block
 block discarded – undo
2605 2600
 			if ($fp) fclose($fp);
2606 2601
 			if ($succeeded)
2607 2602
 			{
2608
-				unset($headers['SUBJECT']);//already in filename
2603
+				unset($headers['SUBJECT']); //already in filename
2609 2604
 				$infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false);
2610
-				$props = array(array('name' => 'comment','val' => $infoSection));
2611
-				Vfs::proppatch($file,$props);
2605
+				$props = array(array('name' => 'comment', 'val' => $infoSection));
2606
+				Vfs::proppatch($file, $props);
2612 2607
 			}
2613 2608
 		}
2614 2609
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2617,9 +2612,9 @@  discard block
 block discarded – undo
2617 2612
 			$this->changeProfile($rememberServerID);
2618 2613
 		}
2619 2614
 
2620
-		if($close)
2615
+		if ($close)
2621 2616
 		{
2622
-			Framework::window_close(($err?$err:null));
2617
+			Framework::window_close(($err ? $err : null));
2623 2618
 		}
2624 2619
 		else
2625 2620
 		{
@@ -2634,15 +2629,15 @@  discard block
 block discarded – undo
2634 2629
 	 * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
2635 2630
 	 * @return string javascript eg. to close the selector window
2636 2631
 	 */
2637
-	function vfsSaveAttachment($ids,$path)
2632
+	function vfsSaveAttachment($ids, $path)
2638 2633
 	{
2639 2634
 		//error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');");
2640 2635
 
2641 2636
 		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
2642 2637
 		{
2643
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
2638
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();';
2644 2639
 		}
2645
-		$err=null;
2640
+		$err = null;
2646 2641
 		$dupe_count = array();
2647 2642
 		$rememberServerID = $this->mail_bo->profileID;
2648 2643
 
@@ -2652,12 +2647,12 @@  discard block
 block discarded – undo
2652 2647
 		 *
2653 2648
 		 * @return array an array of parameters
2654 2649
 		 */
2655
-		$getParams = function ($id) {
2656
-			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2657
-			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2650
+		$getParams = function($id) {
2651
+			list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8);
2652
+			$lId = implode('::', array($app, $user, $serverID, $mailbox, $uid));
2658 2653
 			$hA = mail_ui::splitRowID($lId);
2659 2654
 			return array(
2660
-				'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail,
2655
+				'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail,
2661 2656
 				'user' => $user,
2662 2657
 				'name' => $name,
2663 2658
 				'part' => $part,
@@ -2669,8 +2664,8 @@  discard block
 block discarded – undo
2669 2664
 
2670 2665
 		//Examine the first attachment to see if attachment
2671 2666
 		//is winmail.dat embedded attachments.
2672
-		$isMultipleDownload=is_array($ids);
2673
-		$p = $getParams((is_array($ids)?$ids[0]:$ids));
2667
+		$isMultipleDownload = is_array($ids);
2668
+		$p = $getParams((is_array($ids) ? $ids[0] : $ids));
2674 2669
 		if ($p['is_winmail'])
2675 2670
 		{
2676 2671
 			if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID)
@@ -2681,14 +2676,14 @@  discard block
 block discarded – undo
2681 2676
 			// Retrive all embedded attachments at once
2682 2677
 			// avoids to fetch heavy winmail.dat content
2683 2678
 			// for each file.
2684
-			$attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']);
2679
+			$attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']);
2685 2680
 		}
2686 2681
 
2687
-		foreach((array)$ids as $id)
2682
+		foreach ((array)$ids as $id)
2688 2683
 		{
2689 2684
 			$params = $getParams($id);
2690 2685
 			// when downloading a single file, name is not set
2691
-			if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name'];
2686
+			if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name'];
2692 2687
 			if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID)
2693 2688
 			{
2694 2689
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -2706,25 +2701,25 @@  discard block
 block discarded – undo
2706 2701
 			}
2707 2702
 			else
2708 2703
 			{
2709
-				$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
2704
+				$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
2710 2705
 			}
2711 2706
 
2712 2707
 			$file = $params['name'];
2713 2708
 			// when $isMultipleDownload the path holds no filename
2714
-			while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2709
+			while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
2715 2710
 			{
2716 2711
 				$dupe_count[$params['name']]++;
2717
-				$file = pathinfo($params['name'], PATHINFO_FILENAME) .
2718
-					' ('.($dupe_count[$params['name']] + 1).')' . '.' .
2712
+				$file = pathinfo($params['name'], PATHINFO_FILENAME).
2713
+					' ('.($dupe_count[$params['name']] + 1).')'.'.'.
2719 2714
 					pathinfo($params['name'], PATHINFO_EXTENSION);
2720 2715
 			}
2721 2716
 			$params['name'] = $file;
2722 2717
 			//error_log(__METHOD__.__LINE__.array2string($attachment));
2723 2718
 			// when $isMultipleDownload the path holds no filename
2724
-			if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
2725
-				!fwrite($fp,$attachment['attachment']))
2719
+			if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) ||
2720
+				!fwrite($fp, $attachment['attachment']))
2726 2721
 			{
2727
-				$err .= lang('Error saving %1!',$file);
2722
+				$err .= lang('Error saving %1!', $file);
2728 2723
 			}
2729 2724
 			if ($fp)
2730 2725
 			{
@@ -2737,21 +2732,21 @@  discard block
 block discarded – undo
2737 2732
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
2738 2733
 			$this->changeProfile($rememberServerID);
2739 2734
 		}
2740
-		Framework::window_close(($err?$err:null));
2735
+		Framework::window_close(($err ? $err : null));
2741 2736
 	}
2742 2737
 
2743 2738
 	/**
2744 2739
 	 * Zip all attachments and send to user
2745 2740
 	 * @param string $message_id = null
2746 2741
 	 */
2747
-	function download_zip($message_id=null)
2742
+	function download_zip($message_id = null)
2748 2743
 	{
2749 2744
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2750 2745
 		// First, get all attachment IDs
2751
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
2746
+		if (isset($_GET['id'])) $message_id = $_GET['id'];
2752 2747
 		//error_log(__METHOD__.__LINE__.$message_id);
2753 2748
 		$rememberServerID = $this->mail_bo->profileID;
2754
-		if(!is_numeric($message_id))
2749
+		if (!is_numeric($message_id))
2755 2750
 		{
2756 2751
 			$hA = self::splitRowID($message_id);
2757 2752
 			$message_id = $hA['msgUID'];
@@ -2769,30 +2764,30 @@  discard block
 block discarded – undo
2769 2764
 		}
2770 2765
 		// always fetch all, even inline (images)
2771 2766
 		$fetchEmbeddedImages = true;
2772
-		$attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox);
2767
+		$attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox);
2773 2768
 		// put them in VFS so they can be zipped
2774
-		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
2769
+		$header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox);
2775 2770
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
2776 2771
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
2777
-		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
2778
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
2772
+		$temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id";
2773
+		if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path);
2779 2774
 
2780 2775
 		// Add subject to path, so it gets used as the file name
2781
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
2782
-		if(!Vfs::mkdir($path, 0700, true))
2776
+		$path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/';
2777
+		if (!Vfs::mkdir($path, 0700, true))
2783 2778
 		{
2784
-			Framework::message("Unable to open temp directory $path",'error');
2779
+			Framework::message("Unable to open temp directory $path", 'error');
2785 2780
 			return;
2786 2781
 		}
2787 2782
 
2788 2783
 		$file_list = array();
2789 2784
 		$dupe_count = array();
2790 2785
 		$this->mail_bo->reopen($mailbox);
2791
-		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null')
2786
+		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null')
2792 2787
 		{
2793
-			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true);
2788
+			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true);
2794 2789
 		}
2795
-		foreach($attachments as $file)
2790
+		foreach ($attachments as $file)
2796 2791
 		{
2797 2792
 			if ($file['is_winmail'])
2798 2793
 			{
@@ -2805,22 +2800,22 @@  discard block
 block discarded – undo
2805 2800
 			}
2806 2801
 			else
2807 2802
 			{
2808
-				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
2803
+				$attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true);
2809 2804
 			}
2810
-			$success=true;
2805
+			$success = true;
2811 2806
 			if (empty($file['filename'])) $file['filename'] = $file['name'];
2812
-			if(in_array($path.$file['filename'], $file_list))
2807
+			if (in_array($path.$file['filename'], $file_list))
2813 2808
 			{
2814 2809
 				$dupe_count[$path.$file['filename']]++;
2815
-				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) .
2816
-					' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
2810
+				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME).
2811
+					' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'.
2817 2812
 					pathinfo($file['filename'], PATHINFO_EXTENSION);
2818 2813
 			}
2819
-			if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) ||
2814
+			if (!($fp = Vfs::fopen($path.$file['filename'], 'wb')) ||
2820 2815
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
2821 2816
 			{
2822
-				$success=false;
2823
-				Framework::message("Unable to zip {$file['filename']}",'error');
2817
+				$success = false;
2818
+				Framework::message("Unable to zip {$file['filename']}", 'error');
2824 2819
 			}
2825 2820
 			if ($success) $file_list[] = $path.$file['filename'];
2826 2821
 			if ($fp) fclose($fp);
@@ -2841,7 +2836,7 @@  discard block
 block discarded – undo
2841 2836
 		exit();
2842 2837
 	}
2843 2838
 
2844
-	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
2839
+	function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null)
2845 2840
 	{
2846 2841
 		// seems to be needed, as if we open a mail from notification popup that is
2847 2842
 		// located in a different folder, we experience: could not parse message
@@ -2853,19 +2848,19 @@  discard block
 block discarded – undo
2853 2848
 		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
2854 2849
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
2855 2850
 		$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
2856
-		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
2851
+		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox);
2857 2852
 
2858 2853
 		//error_log(__METHOD__.__LINE__.array2string($bodyParts));
2859 2854
 		// attachments here are only fetched to determine if there is a meeting request
2860 2855
 		// and if. use the appropriate action. so we do not need embedded images
2861 2856
 		$fetchEmbeddedImages = false;
2862
-		$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox);
2857
+		$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true, true, $mailbox);
2863 2858
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2864 2859
 		foreach ($attachments as &$attach)
2865 2860
 		{
2866 2861
 			if (strtolower($attach['mimeType']) == 'text/calendar' &&
2867 2862
 				isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
2868
-				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true))))
2863
+				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'], $attach['is_winmail'], (strtolower($attach['mimeType']) == 'text/calendar' ? false : true))))
2869 2864
 			{
2870 2865
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2871 2866
 				Api\Cache::setSession('calendar', 'ical', array(
@@ -2876,28 +2871,28 @@  discard block
 block discarded – undo
2876 2871
 				));
2877 2872
 				$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2878 2873
 				Api\Translation::add_app('calendar');
2879
-				return ExecMethod( 'calendar.calendar_uiforms.meeting',
2880
-					array('event'=>null,'msg'=>'','useSession'=>true)
2874
+				return ExecMethod('calendar.calendar_uiforms.meeting',
2875
+					array('event'=>null, 'msg'=>'', 'useSession'=>true)
2881 2876
 				);
2882 2877
 			}
2883 2878
 		}
2884 2879
 		// Compose the content of the frame
2885 2880
 		$frameHtml =
2886 2881
 			$this->get_email_header($this->mail_bo->getStyles($bodyParts)).
2887
-			$this->showBody($this->getdisplayableBody($bodyParts,true,false), false);
2882
+			$this->showBody($this->getdisplayableBody($bodyParts, true, false), false);
2888 2883
 		//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
2889
-		$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
2884
+		$frameHtml = str_replace(" \r\n", "\r\n", $frameHtml);
2890 2885
 		$this->mail_bo->htmlOptions = $bufferHtmlOptions;
2891 2886
 
2892 2887
 		return $frameHtml;
2893 2888
 	}
2894 2889
 
2895
-	static function get_email_header($additionalStyle='')
2890
+	static function get_email_header($additionalStyle = '')
2896 2891
 	{
2897 2892
 		// egw_info[flags][css] already include <style> tags
2898 2893
 		$GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle);
2899
-		$GLOBALS['egw_info']['flags']['nofooter']=true;
2900
-		$GLOBALS['egw_info']['flags']['nonavbar']=true;
2894
+		$GLOBALS['egw_info']['flags']['nofooter'] = true;
2895
+		$GLOBALS['egw_info']['flags']['nonavbar'] = true;
2901 2896
 		// do NOT include any default CSS
2902 2897
 		Framework::includeCSS('mail', 'preview', true, true);
2903 2898
 
@@ -2908,35 +2903,35 @@  discard block
 block discarded – undo
2908 2903
 		return $GLOBALS['egw']->framework->header();
2909 2904
 	}
2910 2905
 
2911
-	function showBody(&$body, $print=true,$fullPageTags=true)
2906
+	function showBody(&$body, $print = true, $fullPageTags = true)
2912 2907
 	{
2913 2908
 		$BeginBody = '<div class="mailDisplayBody">
2914 2909
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
2915 2910
 
2916 2911
 		$EndBody = '</td></tr></table></div>';
2917 2912
 		if ($fullPageTags) $EndBody .= "</body></html>";
2918
-		if ($print)	{
2919
-			print $BeginBody. $body .$EndBody;
2913
+		if ($print) {
2914
+			print $BeginBody.$body.$EndBody;
2920 2915
 		} else {
2921
-			return $BeginBody. $body .$EndBody;
2916
+			return $BeginBody.$body.$EndBody;
2922 2917
 		}
2923 2918
 	}
2924 2919
 
2925
-	function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true)
2920
+	function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true)
2926 2921
 	{
2927
-		$bodyParts	= $_bodyParts;
2922
+		$bodyParts = $_bodyParts;
2928 2923
 
2929
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2930
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2931
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2924
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2925
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2926
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2932 2927
 
2933 2928
 		$body = '';
2934 2929
 
2935 2930
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
2936 2931
 		if (empty($bodyParts)) return "";
2937
-		foreach((array)$bodyParts as $singleBodyPart) {
2932
+		foreach ((array)$bodyParts as $singleBodyPart) {
2938 2933
 			if (!isset($singleBodyPart['body'])) {
2939
-				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
2934
+				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy);
2940 2935
 				$body .= $singleBodyPart['body'];
2941 2936
 				continue;
2942 2937
 			}
@@ -2946,7 +2941,7 @@  discard block
 block discarded – undo
2946 2941
 				$body .= '';
2947 2942
 				continue;
2948 2943
 			}
2949
-			if(!empty($body)) {
2944
+			if (!empty($body)) {
2950 2945
 				$body .= '<hr style="border:dotted 1px silver;">';
2951 2946
 			}
2952 2947
 			//error_log($singleBodyPart['body']);
@@ -2971,22 +2966,22 @@  discard block
 block discarded – undo
2971 2966
 				'(R)',
2972 2967
 			);
2973 2968
 
2974
-			if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2969
+			if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
2975 2970
 				strtoupper($singleBodyPart['charSet']) != 'UTF-8')
2976 2971
 			{
2977
-				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
2972
+				$singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']);
2978 2973
 			}
2979 2974
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
2980
-			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
2975
+			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']);
2981 2976
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
2982
-			if($singleBodyPart['mimeType'] == 'text/plain')
2977
+			if ($singleBodyPart['mimeType'] == 'text/plain')
2983 2978
 			{
2984
-				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
2979
+				$newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset));
2985 2980
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
2986 2981
 				// if empty and charset is utf8 try sanitizing the string in question
2987
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
2982
+				if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset));
2988 2983
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
2989
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
2984
+				if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
2990 2985
 
2991 2986
 				// search http[s] links and make them as links available again
2992 2987
 				// to understand what's going on here, have a look at
@@ -3014,20 +3009,20 @@  discard block
 block discarded – undo
3014 3009
 				// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
3015 3010
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3016 3011
 				// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
3017
-				$newBody	= "<pre>".Mail::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
3012
+				$newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '&gt;')."</pre>";
3018 3013
 			}
3019 3014
 			else
3020 3015
 			{
3021
-				$alreadyHtmlLawed=false;
3022
-				$newBody	= $singleBodyPart['body'];
3016
+				$alreadyHtmlLawed = false;
3017
+				$newBody = $singleBodyPart['body'];
3023 3018
 				//TODO:$newBody	= $this->highlightQuotes($newBody);
3024 3019
 				#error_log(print_r($newBody,true));
3025 3020
 				if ($useTidy && extension_loaded('tidy'))
3026 3021
 				{
3027 3022
 					$tidy = new tidy();
3028
-					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8');
3023
+					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8');
3029 3024
 					// Found errors. Strip it all so there's some output
3030
-					if($tidy->getStatus() == 2)
3025
+					if ($tidy->getStatus() == 2)
3031 3026
 					{
3032 3027
 						error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
3033 3028
 					}
@@ -3038,7 +3033,7 @@  discard block
 block discarded – undo
3038 3033
 					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3039 3034
 					{
3040 3035
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3041
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3036
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3042 3037
 						if ($matches[2])
3043 3038
 						{
3044 3039
 							$hasOther = true;
@@ -3049,7 +3044,7 @@  discard block
 block discarded – undo
3049 3044
 				else
3050 3045
 				{
3051 3046
 					// htmLawed filter only the 'body'
3052
-					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3047
+					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3053 3048
 					if ($matches[2])
3054 3049
 					{
3055 3050
 						$hasOther = true;
@@ -3058,10 +3053,10 @@  discard block
 block discarded – undo
3058 3053
 					$htmLawed = new Api\Html\HtmLawed();
3059 3054
 					// the next line should not be needed, but produces better results on HTML 2 Text conversion,
3060 3055
 					// as we switched off HTMLaweds tidy functionality
3061
-					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3062
-					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3063
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3064
-					$alreadyHtmlLawed=true;
3056
+					$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
3057
+					$newBody = $htmLawed->run($newBody, Mail::$htmLawed_config);
3058
+					if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
3059
+					$alreadyHtmlLawed = true;
3065 3060
 				}
3066 3061
 				// do the cleanup, set for the use of purifier
3067 3062
 				//$newBodyBuff = $newBody;
@@ -3083,8 +3078,8 @@  discard block
 block discarded – undo
3083 3078
 				}
3084 3079
 */
3085 3080
 				// removes stuff between http and ?http
3086
-				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';    // only http:// gets removed, other protocolls are shown
3087
-				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http://
3081
+				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
3082
+				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http://
3088 3083
 				// TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK
3089 3084
 				$newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
3090 3085
 					"\\1@\\2.\\3",
@@ -3097,7 +3092,7 @@  discard block
 block discarded – undo
3097 3092
 				// create links for inline images
3098 3093
 				if ($modifyURI)
3099 3094
 				{
3100
-					$newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID);
3095
+					$newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID);
3101 3096
 				}
3102 3097
 				// email addresses / mailto links get now activated on client-side
3103 3098
 			}
@@ -3109,7 +3104,7 @@  discard block
 block discarded – undo
3109 3104
 		$body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
3110 3105
 			"<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body);
3111 3106
 
3112
-		$body = preg_replace($nonDisplayAbleCharacters,'',$body);
3107
+		$body = preg_replace($nonDisplayAbleCharacters, '', $body);
3113 3108
 
3114 3109
 		return $body;
3115 3110
 	}
@@ -3124,7 +3119,7 @@  discard block
 block discarded – undo
3124 3119
 	 * @param string $_messageType = 'html', message type is either html or plain
3125 3120
 	 * @return string message body including all CID images replaced
3126 3121
 	 */
3127
-	public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html')
3122
+	public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html')
3128 3123
 	{
3129 3124
 		if ($_messageType === 'plain')
3130 3125
 		{
@@ -3132,7 +3127,7 @@  discard block
 block discarded – undo
3132 3127
 		}
3133 3128
 		else
3134 3129
 		{
3135
-			foreach(array('src','url','background') as $type)
3130
+			foreach (array('src', 'url', 'background') as $type)
3136 3131
 			{
3137 3132
 				$_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type);
3138 3133
 			}
@@ -3151,7 +3146,7 @@  discard block
 block discarded – undo
3151 3146
 	 *	- types: {plain|src|url|background}
3152 3147
 	 * @return string returns body content including all CID replacements
3153 3148
 	 */
3154
-	public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src')
3149
+	public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src')
3155 3150
 	{
3156 3151
 		/**
3157 3152
 		 * Callback for preg_replace_callback function
@@ -3163,7 +3158,7 @@  discard block
 block discarded – undo
3163 3158
 		 * @param string $_type
3164 3159
 		 * @return string|boolean returns the replace
3165 3160
 		*/
3166
-		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type)
3161
+		$replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type)
3167 3162
 		{
3168 3163
 			if (!$_type)	return false;
3169 3164
 			$CID = '';
@@ -3185,11 +3180,11 @@  discard block
 block discarded – undo
3185 3180
 					break;
3186 3181
 			}
3187 3182
 
3188
-			static $cache = array();	// some caching, if mails containing the same image multiple times
3183
+			static $cache = array(); // some caching, if mails containing the same image multiple times
3189 3184
 
3190 3185
 			if (is_array($matches) && $CID)
3191 3186
 			{
3192
-				$linkData = array (
3187
+				$linkData = array(
3193 3188
 					'menuaction'    => 'mail.mail_ui.displayImage',
3194 3189
 					'uid'		=> $_uid,
3195 3190
 					'mailbox'	=> base64_encode($_mailbox),
@@ -3202,7 +3197,7 @@  discard block
 block discarded – undo
3202 3197
 				{
3203 3198
 					if (!isset($cache[$imageURL]))
3204 3199
 					{
3205
-						if ($_type !="background")
3200
+						if ($_type != "background")
3206 3201
 						{
3207 3202
 							$bo = Mail::getInstance(false, mail_ui::$icServerID);
3208 3203
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
@@ -3243,16 +3238,16 @@  discard block
 block discarded – undo
3243 3238
 		};
3244 3239
 
3245 3240
 		// return new body content base on chosen type
3246
-		switch($_type)
3241
+		switch ($_type)
3247 3242
 		{
3248 3243
 			case"plain":
3249
-				return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body);
3244
+				return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body);
3250 3245
 			case "src":
3251
-				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3246
+				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3252 3247
 			case "url":
3253
-				return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body);
3248
+				return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body);
3254 3249
 			case "background":
3255
-				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3250
+				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3256 3251
 		}
3257 3252
 	}
3258 3253
 
@@ -3260,7 +3255,7 @@  discard block
 block discarded – undo
3260 3255
 	 * importMessage
3261 3256
 	 * @param array $content = null an array of content
3262 3257
 	 */
3263
-	function importMessage($content=null)
3258
+	function importMessage($content = null)
3264 3259
 	{
3265 3260
 		//error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder());
3266 3261
 
@@ -3282,7 +3277,7 @@  discard block
 block discarded – undo
3282 3277
 			}
3283 3278
 			$destination = $content['FOLDER'][0];
3284 3279
 
3285
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3280
+			if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2);
3286 3281
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3287 3282
 			{
3288 3283
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3293,32 +3288,31 @@  discard block
 block discarded – undo
3293 3288
 			$importFailed = false;
3294 3289
 			try
3295 3290
 			{
3296
-				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3297
-			    $linkData = array
3298
-			    (
3291
+				$messageUid = $this->importMessageToFolder($file, $destination, $importID);
3292
+			    $linkData = array(
3299 3293
 					'id' => $this->createRowID($destination, $messageUid, true),
3300 3294
 			    );
3301 3295
 			}
3302 3296
 			catch (Api\Exception\WrongUserinput $e)
3303 3297
 			{
3304
-					$importFailed=true;
3305
-					$content['msg']		= $e->getMessage();
3298
+					$importFailed = true;
3299
+					$content['msg'] = $e->getMessage();
3306 3300
 			}
3307 3301
 			if (!$importFailed)
3308 3302
 			{
3309 3303
 				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
3310 3304
 				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
3311
-				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
3305
+				ExecMethod2('mail.mail_ui.displayMessage', $linkData);
3312 3306
 				return;
3313 3307
 			}
3314 3308
 		}
3315 3309
 		if (!is_array($content)) $content = array();
3316
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3317
-		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
3310
+		if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder();
3311
+		if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true);
3318 3312
 
3319 3313
 		$etpl = new Etemplate('mail.importMessage');
3320
-		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
3321
-		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
3314
+		$etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport');
3315
+		$etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2);
3322 3316
 	}
3323 3317
 
3324 3318
 	/**
@@ -3330,7 +3324,7 @@  discard block
 block discarded – undo
3330 3324
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3331 3325
 	 * @return mixed $messageUID or exception
3332 3326
 	 */
3333
-	function importMessageToFolder($_formData,&$_folder,$importID='')
3327
+	function importMessageToFolder($_formData, &$_folder, $importID = '')
3334 3328
 	{
3335 3329
 		$importfailed = false;
3336 3330
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -3338,7 +3332,7 @@  discard block
 block discarded – undo
3338 3332
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3339 3333
 		try
3340 3334
 		{
3341
-			$tmpFileName = Mail::checkFileBasics($_formData,$importID);
3335
+			$tmpFileName = Mail::checkFileBasics($_formData, $importID);
3342 3336
 		}
3343 3337
 		catch (Api\Exception\WrongUserinput $e)
3344 3338
 		{
@@ -3362,29 +3356,29 @@  discard block
 block discarded – undo
3362 3356
 			if (empty($_folder))
3363 3357
 			{
3364 3358
 				$importfailed = true;
3365
-				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3359
+				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']);
3366 3360
 			}
3367 3361
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3368
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3362
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
3369 3363
 			if ($importfailed === false)
3370 3364
 			{
3371
-				if ($this->mail_bo->folderExists($_folder,true)) {
3365
+				if ($this->mail_bo->folderExists($_folder, true)) {
3372 3366
 					try
3373 3367
 					{
3374 3368
 						$messageUid = $this->mail_bo->appendMessage($_folder,
3375 3369
 							$mailObject->getRaw(),
3376
-							null,'\\Seen');
3370
+							null, '\\Seen');
3377 3371
 					}
3378 3372
 					catch (Api\Exception\WrongUserinput $e)
3379 3373
 					{
3380 3374
 						$importfailed = true;
3381
-						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
3375
+						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage());
3382 3376
 					}
3383 3377
 				}
3384 3378
 				else
3385 3379
 				{
3386 3380
 					$importfailed = true;
3387
-					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder);
3381
+					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder);
3388 3382
 				}
3389 3383
 			}
3390 3384
 		}
@@ -3410,9 +3404,9 @@  discard block
 block discarded – undo
3410 3404
 	 *								 $formData['size']	= 2136;
3411 3405
 	 * @return void
3412 3406
 	 */
3413
-	function importMessageFromVFS2DraftAndEdit($formData='')
3407
+	function importMessageFromVFS2DraftAndEdit($formData = '')
3414 3408
 	{
3415
-		$this->importMessageFromVFS2DraftAndDisplay($formData,'edit');
3409
+		$this->importMessageFromVFS2DraftAndDisplay($formData, 'edit');
3416 3410
 	}
3417 3411
 
3418 3412
 	/**
@@ -3427,7 +3421,7 @@  discard block
 block discarded – undo
3427 3421
 	 * @param string $mode mode to open ImportedMessage display and edit are supported
3428 3422
 	 * @return void
3429 3423
 	 */
3430
-	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3424
+	function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display')
3431 3425
 	{
3432 3426
 		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3433 3427
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
@@ -3440,43 +3434,42 @@  discard block
 block discarded – undo
3440 3434
 			$formData['file'] = 'egw-data://'.$formData['data'];
3441 3435
 		}
3442 3436
 		// name should be set to meet the requirements of checkFileBasics
3443
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3437
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3444 3438
 		{
3445
-			$buff = explode('/',$formData['file']);
3439
+			$buff = explode('/', $formData['file']);
3446 3440
 			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3447 3441
 		}
3448 3442
 		// type should be set to meet the requirements of checkFileBasics
3449
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3443
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3450 3444
 		{
3451
-			$buff = explode('.',$formData['file']);
3445
+			$buff = explode('.', $formData['file']);
3452 3446
 			$suffix = '';
3453 3447
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3454 3448
 			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3455 3449
 		}
3456 3450
 		// size should be set to meet the requirements of checkFileBasics
3457
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3451
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3458 3452
 		{
3459 3453
 			$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
3460 3454
 		}
3461 3455
 		try
3462 3456
 		{
3463
-			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3464
-			$linkData = array
3465
-			(
3466
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3467
-				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3457
+			$messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID);
3458
+			$linkData = array(
3459
+		        'menuaction'    => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'),
3460
+				'id'		=> $this->createRowID($draftFolder, $messageUid, true),
3468 3461
 				'deleteDraftOnClose' => 1,
3469 3462
 			);
3470
-			if ($mode!='display')
3463
+			if ($mode != 'display')
3471 3464
 			{
3472 3465
 				unset($linkData['deleteDraftOnClose']);
3473
-				$linkData['method']	='importMessageToMergeAndSend';
3466
+				$linkData['method'] = 'importMessageToMergeAndSend';
3474 3467
 			}
3475 3468
 			else
3476 3469
 			{
3477
-				$linkData['mode']=$mode;
3470
+				$linkData['mode'] = $mode;
3478 3471
 			}
3479
-			Egw::redirect_link('/index.php',$linkData);
3472
+			Egw::redirect_link('/index.php', $linkData);
3480 3473
 		}
3481 3474
 		catch (Api\Exception\WrongUserinput $e)
3482 3475
 		{
@@ -3491,13 +3484,13 @@  discard block
 block discarded – undo
3491 3484
 	 *
3492 3485
 	 * @return xajax response
3493 3486
 	 */
3494
-	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3487
+	function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null)
3495 3488
 	{
3496 3489
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3497 3490
 		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3498 3491
 		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3499 3492
 		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3500
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3493
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions");
3501 3494
 		if (empty($_messageID)) return "";
3502 3495
 		$uidA = self::splitRowID($_messageID);
3503 3496
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -3511,7 +3504,7 @@  discard block
 block discarded – undo
3511 3504
 			$this->changeProfile($icServerID);
3512 3505
 		}
3513 3506
 
3514
-		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions);
3507
+		$bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions);
3515 3508
 		Api\Session::cache_control(true);
3516 3509
 		//error_log(array2string($bodyResponse));
3517 3510
 		echo $bodyResponse;
@@ -3534,7 +3527,7 @@  discard block
 block discarded – undo
3534 3527
 			$oA = array();
3535 3528
 			foreach ($_folder as $_folderName)
3536 3529
 			{
3537
-				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3530
+				list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2);
3538 3531
 				if (is_numeric($profileID))
3539 3532
 				{
3540 3533
 					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
@@ -3542,19 +3535,19 @@  discard block
 block discarded – undo
3542 3535
 					{
3543 3536
 						try
3544 3537
 						{
3545
-							$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3538
+							$fS = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3546 3539
 						}
3547 3540
 						catch (Exception $e)
3548 3541
 						{
3549 3542
 							continue;
3550 3543
 						}
3551
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3544
+						if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']);
3552 3545
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3553 3546
 						if ($fS['unseen'])
3554 3547
 						{
3555 3548
 							$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
3556 3549
 						}
3557
-						if ($fS['unseen']==0 && $fS['shortDisplayName'])
3550
+						if ($fS['unseen'] == 0 && $fS['shortDisplayName'])
3558 3551
 						{
3559 3552
 							$oA[$_folderName] = $fS['shortDisplayName'];
3560 3553
 						}
@@ -3565,7 +3558,7 @@  discard block
 block discarded – undo
3565 3558
 			if ($oA)
3566 3559
 			{
3567 3560
 				$response = Api\Json\Response::get();
3568
-				$response->call('app.mail.mail_setFolderStatus',$oA);
3561
+				$response->call('app.mail.mail_setFolderStatus', $oA);
3569 3562
 			}
3570 3563
 		}
3571 3564
 	}
@@ -3579,14 +3572,14 @@  discard block
 block discarded – undo
3579 3572
 	function ajax_addFolder($_parentFolderName, $_newName)
3580 3573
 	{
3581 3574
 		//error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName));
3582
-		$errorMessage='';
3575
+		$errorMessage = '';
3583 3576
 		if ($_parentFolderName)
3584 3577
 		{
3585 3578
 			$created = false;
3586 3579
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName);
3587 3580
 			//the conversion is handeled by horde, frontend interaction is all utf-8
3588 3581
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3589
-			list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2);
3582
+			list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2);
3590 3583
 			if (is_numeric($profileID))
3591 3584
 			{
3592 3585
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
@@ -3626,10 +3619,10 @@  discard block
 block discarded – undo
3626 3619
 
3627 3620
 				if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false);
3628 3621
 				*/
3629
-				$nA = explode($del,$_newName);
3622
+				$nA = explode($del, $_newName);
3630 3623
 
3631 3624
 				//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3632
-				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false);
3625
+				if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false);
3633 3626
 				//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3634 3627
 
3635 3628
 				$this->mail_bo->reopen('INBOX');
@@ -3637,11 +3630,11 @@  discard block
 block discarded – undo
3637 3630
 				// if newName has delimiter ($del) in it, we need to create the subtree
3638 3631
 				if (!empty($nA))
3639 3632
 				{
3640
-					$c=0;
3641
-					foreach($nA as $sTName)
3633
+					$c = 0;
3634
+					foreach ($nA as $sTName)
3642 3635
 					{
3643
-						$error=null;
3644
-						if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3636
+						$error = null;
3637
+						if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error)))
3645 3638
 						{
3646 3639
 							$c++;
3647 3640
 						}
@@ -3650,16 +3643,16 @@  discard block
 block discarded – undo
3650 3643
 							$errorMessage .= $error;
3651 3644
 						}
3652 3645
 					}
3653
-					if ($c==count($nA)) $created=true;
3646
+					if ($c == count($nA)) $created = true;
3654 3647
 				}
3655 3648
 				if (!empty($parentName)) $this->mail_bo->reopen($parentName);
3656 3649
 			}
3657 3650
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3658
-			if ($created===true)
3651
+			if ($created === true)
3659 3652
 			{
3660 3653
 				$this->mail_bo->resetFolderObjectCache($profileID);
3661 3654
 				$response = Api\Json\Response::get();
3662
-				if ( $oldFolderInfo['shortDisplayName'])
3655
+				if ($oldFolderInfo['shortDisplayName'])
3663 3656
 				{
3664 3657
 					$nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']);
3665 3658
 				}
@@ -3667,14 +3660,14 @@  discard block
 block discarded – undo
3667 3660
 				{
3668 3661
 					$nodeInfo = array($profileID=>lang('INBOX'));
3669 3662
 				}
3670
-				$response->call('app.mail.mail_reloadNode',$nodeInfo);
3663
+				$response->call('app.mail.mail_reloadNode', $nodeInfo);
3671 3664
 			}
3672 3665
 			else
3673 3666
 			{
3674 3667
 				if ($errorMessage)
3675 3668
 				{
3676 3669
 					$response = Api\Json\Response::get();
3677
-					$response->call('egw.message',$errorMessage);
3670
+					$response->call('egw.message', $errorMessage);
3678 3671
 				}
3679 3672
 			}
3680 3673
 		}
@@ -3696,22 +3689,22 @@  discard block
 block discarded – undo
3696 3689
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
3697 3690
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3698 3691
 			$oA = array();
3699
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3692
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3700 3693
 			$hasChildren = false;
3701 3694
 			if (is_numeric($profileID))
3702 3695
 			{
3703 3696
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
3704
-				$pA = explode($del,$folderName);
3697
+				$pA = explode($del, $folderName);
3705 3698
 				array_pop($pA);
3706
-				$parentFolder = implode($del,$pA);
3707
-				if (strtoupper($folderName)!= 'INBOX')
3699
+				$parentFolder = implode($del, $pA);
3700
+				if (strtoupper($folderName) != 'INBOX')
3708 3701
 				{
3709 3702
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3710
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false);
3703
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false);
3711 3704
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3712
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3705
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3713 3706
 					{
3714
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3707
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3715 3708
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3716 3709
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3717 3710
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3728,7 +3721,7 @@  discard block
 block discarded – undo
3728 3721
 							else
3729 3722
 							{
3730 3723
 								$rv = $this->mail_bo->icServer->subscribeMailbox($folder, false);
3731
-								$fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName));
3724
+								$fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName));
3732 3725
 							}
3733 3726
 						}
3734 3727
 						//error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments));
@@ -3738,7 +3731,7 @@  discard block
 block discarded – undo
3738 3731
 					$success = false;
3739 3732
 					try
3740 3733
 					{
3741
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3734
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3742 3735
 						{
3743 3736
 							$this->mail_bo->resetFolderObjectCache($profileID);
3744 3737
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3749,11 +3742,11 @@  discard block
 block discarded – undo
3749 3742
 					}
3750 3743
 					catch (Exception $e)
3751 3744
 					{
3752
-						$newFolderName=$folderName;
3745
+						$newFolderName = $folderName;
3753 3746
 						$msg = $e->getMessage();
3754 3747
 					}
3755 3748
 					$this->mail_bo->reopen($newFolderName);
3756
-					$fS = $this->mail_bo->getFolderStatus($newFolderName,false);
3749
+					$fS = $this->mail_bo->getFolderStatus($newFolderName, false);
3757 3750
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3758 3751
 					if ($hasChildren)
3759 3752
 					{
@@ -3784,12 +3777,12 @@  discard block
 block discarded – undo
3784 3777
 					{
3785 3778
 						$oA[$_folderName]['desc'] = $fS['shortDisplayName'];
3786 3779
 					}
3787
-					foreach($fragments as $oldFolderName => $fragment)
3780
+					foreach ($fragments as $oldFolderName => $fragment)
3788 3781
 					{
3789 3782
 						//error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment);
3790 3783
 						$oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment;
3791 3784
 						$oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#';
3792
-						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
3785
+						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false);
3793 3786
 						if ($fS['unseen'])
3794 3787
 						{
3795 3788
 							$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
@@ -3802,20 +3795,20 @@  discard block
 block discarded – undo
3802 3795
 					}
3803 3796
 				}
3804 3797
 			}
3805
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
3798
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
3806 3799
 			{
3807
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
3800
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
3808 3801
 				$this->mail_bo->saveSessionData();
3809 3802
 			}
3810 3803
 			//error_log(__METHOD__.__LINE__.array2string($oA));
3811 3804
 			$response = Api\Json\Response::get();
3812 3805
 			if ($oA && $success)
3813 3806
 			{
3814
-				$response->call('app.mail.mail_setLeaf',$oA);
3807
+				$response->call('app.mail.mail_setLeaf', $oA);
3815 3808
 			}
3816 3809
 			else
3817 3810
 			{
3818
-				$response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail');
3811
+				$response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail');
3819 3812
 			}
3820 3813
 		}
3821 3814
 	}
@@ -3827,7 +3820,7 @@  discard block
 block discarded – undo
3827 3820
 	 * @param boolean $_subscribedOnly = true
3828 3821
 	 * @return void
3829 3822
 	 */
3830
-	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
3823
+	function ajax_reloadNode($_folderName, $_subscribedOnly = true)
3831 3824
 	{
3832 3825
 		Api\Translation::add_app('mail');
3833 3826
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
@@ -3838,20 +3831,20 @@  discard block
 block discarded – undo
3838 3831
 
3839 3832
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3840 3833
 		$this->mail_bo->getHierarchyDelimiter(false);
3841
-		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3834
+		list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3842 3835
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
3843 3836
 		// that we get what we request
3844 3837
 		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
3845 3838
 		if ($profileID != $this->mail_bo->profileID) return; // only current connection
3846 3839
 		if (!empty($folderName))
3847 3840
 		{
3848
-			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
3849
-			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3841
+			$parentFolder = (!empty($folderName) ? $folderName : 'INBOX');
3842
+			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3850 3843
 			if ($folderInfo['unseen'])
3851 3844
 			{
3852 3845
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')';
3853 3846
 			}
3854
-			if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName'])
3847
+			if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName'])
3855 3848
 			{
3856 3849
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'];
3857 3850
 			}
@@ -3867,11 +3860,11 @@  discard block
 block discarded – undo
3867 3860
 		}
3868 3861
 		// Send full info back in the response
3869 3862
 		$response = Api\Json\Response::get();
3870
-		foreach($refreshData as $folder => &$name)
3863
+		foreach ($refreshData as $folder => &$name)
3871 3864
 		{
3872
-			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
3865
+			$name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true);
3873 3866
 		}
3874
-		$response->call('app.mail.mail_reloadNode',$refreshData);
3867
+		$response->call('app.mail.mail_reloadNode', $refreshData);
3875 3868
 
3876 3869
 	}
3877 3870
 
@@ -3887,7 +3880,7 @@  discard block
 block discarded – undo
3887 3880
 	 * @param type $_rowid row id from nm
3888 3881
 	 *
3889 3882
 	 */
3890
-	function ajax_resolveWinmail ($_rowid)
3883
+	function ajax_resolveWinmail($_rowid)
3891 3884
 	{
3892 3885
 		$response = Api\Json\Response::get();
3893 3886
 
@@ -3895,7 +3888,7 @@  discard block
 block discarded – undo
3895 3888
 		$uid = $idParts['msgUID'];
3896 3889
 		$mbox = $idParts['folder'];
3897 3890
 
3898
-		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
3891
+		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox);
3899 3892
 		if (is_array($attachments))
3900 3893
 		{
3901 3894
 			$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
@@ -3923,30 +3916,30 @@  discard block
 block discarded – undo
3923 3916
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
3924 3917
 			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
3925 3918
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
3926
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
3927
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
3919
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
3920
+			list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2);
3928 3921
 			$hasChildren = false;
3929 3922
 			if (is_numeric($profileID))
3930 3923
 			{
3931 3924
 				if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
3932
-				$pA = explode($del,$folderName);
3925
+				$pA = explode($del, $folderName);
3933 3926
 				$namePart = array_pop($pA);
3934 3927
 				$_newName = $namePart;
3935
-				$oldParentFolder = implode($del,$pA);
3928
+				$oldParentFolder = implode($del, $pA);
3936 3929
 				$parentFolder = $_newLocation;
3937 3930
 
3938
-				if (strtoupper($folderName)!= 'INBOX' &&
3931
+				if (strtoupper($folderName) != 'INBOX' &&
3939 3932
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
3940 3933
 					(($oldParentFolder != $parentFolder &&
3941
-					strlen($parentFolder)>0 && strlen($folderName)>0 &&
3942
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
3934
+					strlen($parentFolder) > 0 && strlen($folderName) > 0 &&
3935
+					strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch
3943 3936
 				{
3944 3937
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
3945
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3938
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3946 3939
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
3947
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
3940
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
3948 3941
 					{
3949
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
3942
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
3950 3943
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
3951 3944
 						$nameSpace = $this->mail_bo->_getNameSpaces();
3952 3945
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -3971,7 +3964,7 @@  discard block
 block discarded – undo
3971 3964
 					$success = false;
3972 3965
 					try
3973 3966
 					{
3974
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3967
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
3975 3968
 						{
3976 3969
 							$this->mail_bo->resetFolderObjectCache($profileID);
3977 3970
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -3983,11 +3976,11 @@  discard block
 block discarded – undo
3983 3976
 					}
3984 3977
 					catch (Exception $e)
3985 3978
 					{
3986
-						$newFolderName=$folderName;
3979
+						$newFolderName = $folderName;
3987 3980
 						$msg = $e->getMessage();
3988 3981
 					}
3989 3982
 					$this->mail_bo->reopen($parentFolder);
3990
-					$this->mail_bo->getFolderStatus($parentFolder,false,false,false);
3983
+					$this->mail_bo->getFolderStatus($parentFolder, false, false, false);
3991 3984
 					//error_log(__METHOD__.__LINE__.array2string($fS));
3992 3985
 					if ($hasChildren)
3993 3986
 					{
@@ -4008,9 +4001,9 @@  discard block
 block discarded – undo
4008 4001
 					}
4009 4002
 				}
4010 4003
 			}
4011
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
4004
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
4012 4005
 			{
4013
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
4006
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
4014 4007
 				$this->mail_bo->saveSessionData();
4015 4008
 			}
4016 4009
 			//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -4019,26 +4012,26 @@  discard block
 block discarded – undo
4019 4012
 			{
4020 4013
 				Api\Translation::add_app('mail');
4021 4014
 
4022
-				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
4023
-				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4015
+				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false);
4016
+				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4024 4017
 				$refreshData = array(
4025 4018
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4026 4019
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4027 4020
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4028
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4029
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4021
+				if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4022
+				if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4030 4023
 
4031 4024
 				// Send full info back in the response
4032
-				foreach($refreshData as $folder => &$name)
4025
+				foreach ($refreshData as $folder => &$name)
4033 4026
 				{
4034
-					$name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true);
4027
+					$name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true);
4035 4028
 				}
4036
-				$response->call('app.mail.mail_reloadNode',$refreshData);
4029
+				$response->call('app.mail.mail_reloadNode', $refreshData);
4037 4030
 
4038 4031
 			}
4039 4032
 			else
4040 4033
 			{
4041
-				$response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail');
4034
+				$response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail');
4042 4035
 			}
4043 4036
 		}
4044 4037
 	}
@@ -4058,23 +4051,23 @@  discard block
 block discarded – undo
4058 4051
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4059 4052
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4060 4053
 			$oA = array();
4061
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4054
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4062 4055
 			$hasChildren = false;
4063 4056
 			if (is_numeric($profileID))
4064 4057
 			{
4065 4058
 				if ($profileID != $this->mail_bo->profileID) return; // only current connection
4066
-				$pA = explode($del,$folderName);
4059
+				$pA = explode($del, $folderName);
4067 4060
 				array_pop($pA);
4068
-				if (strtoupper($folderName)!= 'INBOX')
4061
+				if (strtoupper($folderName) != 'INBOX')
4069 4062
 				{
4070 4063
 					//error_log(__METHOD__.__LINE__."$folderName,  implode($del,$pA), $_newName");
4071 4064
 					$oA = array();
4072 4065
 					$subFolders = array();
4073
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4066
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4074 4067
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4075
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4068
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4076 4069
 					{
4077
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4070
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4078 4071
 						$ftD = array();
4079 4072
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4080 4073
 						$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -4084,24 +4077,24 @@  discard block
 block discarded – undo
4084 4077
 						//error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix");
4085 4078
 						foreach ($subFolders as $k => $f)
4086 4079
 						{
4087
-							$ftD[substr_count($f,$delimiter)][]=$f;
4080
+							$ftD[substr_count($f, $delimiter)][] = $f;
4088 4081
 						}
4089
-						krsort($ftD,SORT_NUMERIC);//sort per level
4082
+						krsort($ftD, SORT_NUMERIC); //sort per level
4090 4083
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4091
-						foreach($ftD as $k => $lc)//collection per level
4084
+						foreach ($ftD as $k => $lc)//collection per level
4092 4085
 						{
4093
-							foreach($lc as $f)//folders contained in that level
4086
+							foreach ($lc as $f)//folders contained in that level
4094 4087
 							{
4095 4088
 								try
4096 4089
 								{
4097 4090
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4098 4091
 									$this->mail_bo->deleteFolder($f);
4099 4092
 									$success = true;
4100
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4093
+									if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4101 4094
 								}
4102 4095
 								catch (Exception $e)
4103 4096
 								{
4104
-									$msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage();
4097
+									$msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage();
4105 4098
 									$success = false;
4106 4099
 								}
4107 4100
 							}
@@ -4132,11 +4125,11 @@  discard block
 block discarded – undo
4132 4125
 			if ($success)
4133 4126
 			{
4134 4127
 				//error_log(__METHOD__.__LINE__.array2string($oA));
4135
-				$response->call('app.mail.mail_removeLeaf',$oA);
4128
+				$response->call('app.mail.mail_removeLeaf', $oA);
4136 4129
 			}
4137 4130
 			else
4138 4131
 			{
4139
-				$response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail');
4132
+				$response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail');
4140 4133
 			}
4141 4134
 		}
4142 4135
 	}
@@ -4150,7 +4143,7 @@  discard block
 block discarded – undo
4150 4143
 	 * @param bool $getFolders The client needs the folders for the profile
4151 4144
 	 * @return nothing
4152 4145
 	 */
4153
-	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
4146
+	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null)
4154 4147
 	{
4155 4148
 		$response = Api\Json\Response::get();
4156 4149
 
@@ -4158,7 +4151,7 @@  discard block
 block discarded – undo
4158 4151
 
4159 4152
 		if ($icServerID && $icServerID != $previous_id)
4160 4153
 		{
4161
-			$mail_ui = new mail_ui(false);	// do NOT run constructor, as we call changeProfile anyway
4154
+			$mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway
4162 4155
 			try
4163 4156
 			{
4164 4157
 				$mail_ui->changeProfile($icServerID);
@@ -4174,23 +4167,23 @@  discard block
 block discarded – undo
4174 4167
 				}
4175 4168
 			}
4176 4169
 			catch (Exception $e) {
4177
-				self::callWizard($e->getMessage(),true, 'error');
4170
+				self::callWizard($e->getMessage(), true, 'error');
4178 4171
 			}
4179 4172
 		}
4180 4173
 		else
4181 4174
 		{
4182
-			$mail_ui = new mail_ui(true);	// run constructor
4175
+			$mail_ui = new mail_ui(true); // run constructor
4183 4176
 		}
4184 4177
 
4185 4178
 		// Send full info back in the response
4186
-		if($getFolders)
4179
+		if ($getFolders)
4187 4180
 		{
4188 4181
 			Api\Translation::add_app('mail');
4189 4182
 
4190 4183
 			$refreshData = array(
4191
-				$icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4184
+				$icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
4192 4185
 			);
4193
-			$response->call('app.mail.mail_reloadNode',$refreshData);
4186
+			$response->call('app.mail.mail_reloadNode', $refreshData);
4194 4187
 		}
4195 4188
 	}
4196 4189
 
@@ -4201,7 +4194,7 @@  discard block
 block discarded – undo
4201 4194
 	 *						if other than active profile; nothing is done!
4202 4195
 	 * @return nothing
4203 4196
 	 */
4204
-	public static function ajax_refreshVacationNotice($icServerID=null)
4197
+	public static function ajax_refreshVacationNotice($icServerID = null)
4205 4198
 	{
4206 4199
 		//Get vacation from cache if it's available
4207 4200
 		$cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
@@ -4219,28 +4212,28 @@  discard block
 block discarded – undo
4219 4212
 
4220 4213
 				$vacation = $mail->gatherVacation($cachedVacations);
4221 4214
 			} catch (Exception $e) {
4222
-				$vacation=false;
4215
+				$vacation = false;
4223 4216
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4224 4217
 				unset($e);
4225 4218
 			}
4226 4219
 		}
4227 4220
 
4228
-		if($vacation) {
4229
-			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4221
+		if ($vacation) {
4222
+			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date'))
4230 4223
 			{
4231 4224
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4232 4225
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4233
-				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4234
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4226
+				$refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
4227
+				if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = '';
4235 4228
 			}
4236 4229
 		}
4237
-		if ($vacation==false)
4230
+		if ($vacation == false)
4238 4231
 		{
4239
-			$refreshData['vacationnotice'] =  '';
4240
-			$refreshData['vacationrange'] =  '';
4232
+			$refreshData['vacationnotice'] = '';
4233
+			$refreshData['vacationrange'] = '';
4241 4234
 		}
4242 4235
 		$response = Api\Json\Response::get();
4243
-		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
4236
+		$response->call('app.mail.mail_refreshVacationNotice', $refreshData);
4244 4237
 	}
4245 4238
 
4246 4239
 	/**
@@ -4250,43 +4243,43 @@  discard block
 block discarded – undo
4250 4243
 	 *						if other than active profile; nothing is done!
4251 4244
 	 * @return nothing
4252 4245
 	 */
4253
-	function ajax_refreshFilters($icServerID=null)
4246
+	function ajax_refreshFilters($icServerID = null)
4254 4247
 	{
4255 4248
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4256 4249
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4257 4250
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4258 4251
 		{
4259
-			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4260
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4252
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4253
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4261 4254
 		}
4262 4255
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4263 4256
 		{
4264 4257
 			unset($this->searchTypes['quick']);
4265 4258
 			unset($this->searchTypes['quickwithcc']);
4266 4259
 		}
4267
-		if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4260
+		if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4268 4261
 		{
4269
-			$this->statusTypes = array_merge($this->statusTypes,array(
4270
-				'keyword1'	=> 'important',//lang('important'),
4271
-				'keyword2'	=> 'job',	//lang('job'),
4272
-				'keyword3'	=> 'personal',//lang('personal'),
4273
-				'keyword4'	=> 'to do',	//lang('to do'),
4274
-				'keyword5'	=> 'later',	//lang('later'),
4262
+			$this->statusTypes = array_merge($this->statusTypes, array(
4263
+				'keyword1'	=> 'important', //lang('important'),
4264
+				'keyword2'	=> 'job', //lang('job'),
4265
+				'keyword3'	=> 'personal', //lang('personal'),
4266
+				'keyword4'	=> 'to do', //lang('to do'),
4267
+				'keyword5'	=> 'later', //lang('later'),
4275 4268
 			));
4276 4269
 		}
4277 4270
 		else
4278 4271
 		{
4279
-			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4280
-			foreach($keywords as &$k)
4272
+			$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
4273
+			foreach ($keywords as &$k)
4281 4274
 			{
4282
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4275
+				if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
4283 4276
 			}
4284 4277
 		}
4285 4278
 
4286 4279
 		$response = Api\Json\Response::get();
4287
-		$response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes);
4288
-		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
4289
-		$response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')));
4280
+		$response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes);
4281
+		$response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes);
4282
+		$response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')));
4290 4283
 
4291 4284
 	}
4292 4285
 
@@ -4295,7 +4288,7 @@  discard block
 block discarded – undo
4295 4288
 	 *
4296 4289
 	 * @return nothing
4297 4290
 	 */
4298
-	function ajax_refreshQuotaDisplay($icServerID=null)
4291
+	function ajax_refreshQuotaDisplay($icServerID = null)
4299 4292
 	{
4300 4293
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
4301 4294
 		Api\Translation::add_app('mail');
@@ -4315,10 +4308,10 @@  discard block
 block discarded – undo
4315 4308
 			unset($e);
4316 4309
 		}
4317 4310
 
4318
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4311
+		if ($quota !== false && $quota['limit'] != 'NOT SET') {
4319 4312
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4320 4313
 			$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
4321
-			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
4314
+			$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
4322 4315
 			$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
4323 4316
 			$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
4324 4317
 		} else {
@@ -4338,7 +4331,7 @@  discard block
 block discarded – undo
4338 4331
 			}
4339 4332
 		}
4340 4333
 		$response = Api\Json\Response::get();
4341
-		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
4334
+		$response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content));
4342 4335
 	}
4343 4336
 
4344 4337
 	/**
@@ -4360,34 +4353,34 @@  discard block
 block discarded – undo
4360 4353
 			$this->changeProfile($icServerID);
4361 4354
 		}
4362 4355
 		$junkFolder = $this->mail_bo->getJunkFolder();
4363
-		if(!empty($junkFolder)) {
4356
+		if (!empty($junkFolder)) {
4364 4357
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4365 4358
 			{
4366 4359
 				// Lock the tree if the active folder is junk folder
4367 4360
 				$response->call('app.mail.lock_tree');
4368 4361
 			}
4369
-			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4362
+			$this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately');
4370 4363
 
4371 4364
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4372
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4365
+			$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
4373 4366
 			$fStatus = array(
4374 4367
 				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4375 4368
 			);
4376 4369
 			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4377 4370
 			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4378
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4371
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4379 4372
 		}
4380 4373
 		if ($rememberServerID != $this->mail_bo->profileID)
4381 4374
 		{
4382
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4383
-			$response->call('egw.message',lang('empty junk'));
4384
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4375
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false);
4376
+			$response->call('egw.message', lang('empty junk'));
4377
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4385 4378
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4386 4379
 			$this->changeProfile($rememberServerID);
4387 4380
 		}
4388 4381
 		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4389 4382
 		{
4390
-			$response->call('egw.refresh',lang('empty junk'),'mail');
4383
+			$response->call('egw.refresh', lang('empty junk'), 'mail');
4391 4384
 		}
4392 4385
 	}
4393 4386
 
@@ -4410,7 +4403,7 @@  discard block
 block discarded – undo
4410 4403
 			$this->changeProfile($icServerID);
4411 4404
 		}
4412 4405
 		$trashFolder = $this->mail_bo->getTrashFolder();
4413
-		if(!empty($trashFolder)) {
4406
+		if (!empty($trashFolder)) {
4414 4407
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4415 4408
 			{
4416 4409
 				// Lock the tree if the active folder is Trash folder
@@ -4419,25 +4412,25 @@  discard block
 block discarded – undo
4419 4412
 			$this->mail_bo->compressFolder($trashFolder);
4420 4413
 
4421 4414
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4422
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4415
+			$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
4423 4416
 			$fStatus = array(
4424 4417
 				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4425 4418
 			);
4426 4419
 			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4427 4420
 			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4428
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4421
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4429 4422
 		}
4430 4423
 		if ($rememberServerID != $this->mail_bo->profileID)
4431 4424
 		{
4432
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4433
-			$response->call('egw.message',lang('empty trash'));
4434
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4425
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false);
4426
+			$response->call('egw.message', lang('empty trash'));
4427
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4435 4428
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4436 4429
 			$this->changeProfile($rememberServerID);
4437 4430
 		}
4438 4431
 		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4439 4432
 		{
4440
-			$response->call('egw.refresh',lang('empty trash'),'mail');
4433
+			$response->call('egw.refresh', lang('empty trash'), 'mail');
4441 4434
 		}
4442 4435
 	}
4443 4436
 
@@ -4454,7 +4447,7 @@  discard block
 block discarded – undo
4454 4447
 
4455 4448
 		$this->mail_bo->restoreSessionData();
4456 4449
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4457
-		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4450
+		list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4458 4451
 
4459 4452
 		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4460 4453
 		if ($this->mail_bo->folderExists($folderName))
@@ -4465,7 +4458,7 @@  discard block
 block discarded – undo
4465 4458
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4466 4459
 				$this->changeProfile($icServerID);
4467 4460
 			}
4468
-			if(!empty($_folderName)) {
4461
+			if (!empty($_folderName)) {
4469 4462
 				$this->mail_bo->compressFolder($folderName);
4470 4463
 			}
4471 4464
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4474,7 +4467,7 @@  discard block
 block discarded – undo
4474 4467
 				$this->changeProfile($rememberServerID);
4475 4468
 			}
4476 4469
 			$response = Api\Json\Response::get();
4477
-			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
4470
+			$response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail');
4478 4471
 		}
4479 4472
 	}
4480 4473
 
@@ -4487,10 +4480,10 @@  discard block
 block discarded – undo
4487 4480
 	 */
4488 4481
 	function ajax_sendMDN($_messageList)
4489 4482
 	{
4490
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4483
+		if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4491 4484
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4492 4485
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4493
-		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
4486
+		$this->mail_bo->sendMDN($uidA['msgUID'], $folder);
4494 4487
 	}
4495 4488
 
4496 4489
 	/**
@@ -4502,14 +4495,14 @@  discard block
 block discarded – undo
4502 4495
 	 *
4503 4496
 	 * @return xajax response
4504 4497
 	 */
4505
-	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4498
+	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true)
4506 4499
 	{
4507
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4500
+		if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4508 4501
 		Api\Translation::add_app('mail');
4509
-		$alreadyFlagged=false;
4510
-		$flag2check='';
4502
+		$alreadyFlagged = false;
4503
+		$flag2check = '';
4511 4504
 		$filter2toggle = $query = array();
4512
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4505
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4513 4506
 		{
4514 4507
 			if (isset($_messageList['all']) && $_messageList['all'])
4515 4508
 			{
@@ -4519,34 +4512,34 @@  discard block
 block discarded – undo
4519 4512
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4520 4513
 				{
4521 4514
 					$query = $_messageList['activeFilters'];
4522
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4515
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4523 4516
 					{
4524 4517
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4525 4518
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4526 4519
 						{
4527
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4528
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4520
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4521
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4529 4522
 						}
4530 4523
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4531 4524
 						$cutoffdate = $cutoffdate2 = null;
4532
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4533
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4525
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4526
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4534 4527
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4535 4528
 						$filter = array(
4536
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4537
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4529
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4530
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4538 4531
 							'string' => $query['search'],
4539
-							'status' => 'any',//this is a status change. status will be manipulated later on
4532
+							'status' => 'any', //this is a status change. status will be manipulated later on
4540 4533
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4541 4534
 						);
4542
-						if ($query['enddate']||$query['startdate']) {
4535
+						if ($query['enddate'] || $query['startdate']) {
4543 4536
 							$filter['range'] = "BETWEEN";
4544 4537
 							if ($cutoffdate) {
4545
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4538
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4546 4539
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4547 4540
 							}
4548 4541
 							if ($cutoffdate2) {
4549
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4542
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4550 4543
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4551 4544
 							}
4552 4545
 						}
@@ -4559,12 +4552,12 @@  discard block
 block discarded – undo
4559 4552
 					// flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder
4560 4553
 					// should be affected serverside. here.
4561 4554
 					$messageList = $messageListForToggle = array();
4562
-					$flag2check = ($_flag=='read'?'seen':$_flag);
4563
-					if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4564
-						!($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))
4555
+					$flag2check = ($_flag == 'read' ? 'seen' : $_flag);
4556
+					if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4557
+						!($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))
4565 4558
 					{
4566 4559
 						$filter2toggle['status'] = array('un'.$_flag);
4567
-						if ($query['filter'] && $query['filter']!='any')
4560
+						if ($query['filter'] && $query['filter'] != 'any')
4568 4561
 						{
4569 4562
 							$filter2toggle['status'][] = $query['filter'];
4570 4563
 						}
@@ -4572,7 +4565,7 @@  discard block
 block discarded – undo
4572 4565
 						$reverse = 1;
4573 4566
 						$_sRt = $this->mail_bo->getSortedList(
4574 4567
 							$folder,
4575
-							$sort=0,
4568
+							$sort = 0,
4576 4569
 							$reverse,
4577 4570
 							$filter2toggle,
4578 4571
 							$rByUid,
@@ -4580,52 +4573,52 @@  discard block
 block discarded – undo
4580 4573
 						);
4581 4574
 						$messageListForToggle = $_sRt['match']->ids;
4582 4575
 						$filter['status'] = array($_flag);
4583
-						if ($query['filter'] && $query['filter'] !='any')
4576
+						if ($query['filter'] && $query['filter'] != 'any')
4584 4577
 						{
4585 4578
 							$filter['status'][] = $query['filter'];
4586 4579
 						}
4587
-						$rByUid=true;
4580
+						$rByUid = true;
4588 4581
 						$reverse = 1;
4589 4582
 						$_sR = $this->mail_bo->getSortedList(
4590 4583
 							$folder,
4591
-							$sort=0,
4584
+							$sort = 0,
4592 4585
 							$reverse,
4593 4586
 							$filter,
4594 4587
 							$rByUid,
4595 4588
 							false
4596 4589
 						);
4597 4590
 						$messageList = $_sR['match']->ids;
4598
-						if (count($messageListForToggle)>0)
4591
+						if (count($messageListForToggle) > 0)
4599 4592
 						{
4600 4593
 							$flag2set = (strtolower($_flag));
4601
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4602
-							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4594
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4595
+							$this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder);
4603 4596
 						}
4604
-						if (count($messageList)>0)
4597
+						if (count($messageList) > 0)
4605 4598
 						{
4606 4599
 							$flag2set = 'un'.$_flag;
4607
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4608
-							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4600
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4601
+							$this->mail_bo->flagMessages($flag2set, $messageList, $folder);
4609 4602
 						}
4610
-						$alreadyFlagged=true;
4603
+						$alreadyFlagged = true;
4611 4604
 					}
4612 4605
 					elseif (!empty($filter) &&
4613
-						(!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) ||
4614
-						(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4615
-						($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
4606
+						(!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) ||
4607
+						(in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4608
+						($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))))
4616 4609
 					{
4617
-						if ($query['filter'] && $query['filter'] !='any')
4610
+						if ($query['filter'] && $query['filter'] != 'any')
4618 4611
 						{
4619 4612
 							$filter['status'] = $query['filter'];
4620 4613
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4621
-							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4614
+							$_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag)));
4622 4615
 						}
4623
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4616
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4624 4617
 						$rByUid = true;
4625 4618
 						$reverse = 1;
4626 4619
 						$_sR = $this->mail_bo->getSortedList(
4627 4620
 							$folder,
4628
-							$sort=0,
4621
+							$sort = 0,
4629 4622
 							$reverse,
4630 4623
 							$filter,
4631 4624
 							$rByUid,
@@ -4637,8 +4630,8 @@  discard block
 block discarded – undo
4637 4630
 					}
4638 4631
 					else
4639 4632
 					{
4640
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4641
-						$alreadyFlagged=true;
4633
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
4634
+						$alreadyFlagged = true;
4642 4635
 						$uidA = self::splitRowID($_messageList['msg'][0]);
4643 4636
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4644 4637
 						$this->mail_bo->flagMessages($_flag, 'all', $folder);
@@ -4652,41 +4645,41 @@  discard block
 block discarded – undo
4652 4645
 			}
4653 4646
 			if (!$alreadyFlagged)
4654 4647
 			{
4655
-				foreach($_messageList['msg'] as $rowID)
4648
+				foreach ($_messageList['msg'] as $rowID)
4656 4649
 				{
4657 4650
 					$hA = self::splitRowID($rowID);
4658 4651
 					$messageList[] = $hA['msgUID'];
4659 4652
 				}
4660
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
4661
-				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
4653
+				if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList)));
4654
+				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder);
4662 4655
 			}
4663 4656
 		}
4664 4657
 		else
4665 4658
 		{
4666
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4659
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4667 4660
 		}
4668 4661
 
4669 4662
 		if ($_sendJsonResponse)
4670 4663
 		{
4671
-			$flag=array(
4672
-				'label1'	=> 'important',//lang('important'),
4673
-				'label2'	=> 'job',	//lang('job'),
4674
-				'label3'	=> 'personal',//lang('personal'),
4675
-				'label4'	=> 'to do',	//lang('to do'),
4676
-				'label5'	=> 'later',	//lang('later'),
4664
+			$flag = array(
4665
+				'label1'	=> 'important', //lang('important'),
4666
+				'label2'	=> 'job', //lang('job'),
4667
+				'label3'	=> 'personal', //lang('personal'),
4668
+				'label4'	=> 'to do', //lang('to do'),
4669
+				'label5'	=> 'later', //lang('later'),
4677 4670
 			);
4678 4671
 			$response = Api\Json\Response::get();
4679 4672
 			if (isset($_messageList['msg']) && $_messageList['popup'])
4680 4673
 			{
4681
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update');
4674
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', $_messageList['msg'], lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail', $_messageList['msg'], 'update');
4682 4675
 			}
4683
-			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
4676
+			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))
4684 4677
 			{
4685
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail');
4678
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail');
4686 4679
 			}
4687 4680
 			else
4688 4681
 			{
4689
-				$response->call('egw.message',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder));
4682
+				$response->call('egw.message', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder));
4690 4683
 			}
4691 4684
 		}
4692 4685
 	}
@@ -4698,12 +4691,12 @@  discard block
 block discarded – undo
4698 4691
 	 * @param string _forceDeleteMethod - method of deletion to be enforced
4699 4692
 	 * @return xajax response
4700 4693
 	 */
4701
-	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
4694
+	function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null)
4702 4695
 	{
4703
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
4696
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod);
4704 4697
 		$error = null;
4705
-		$filtered =  false;
4706
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4698
+		$filtered = false;
4699
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4707 4700
 		{
4708 4701
 			if (isset($_messageList['all']) && $_messageList['all'])
4709 4702
 			{
@@ -4713,34 +4706,34 @@  discard block
 block discarded – undo
4713 4706
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4714 4707
 				{
4715 4708
 					$query = $_messageList['activeFilters'];
4716
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4709
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4717 4710
 					{
4718 4711
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4719 4712
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4720 4713
 						{
4721
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4722
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4714
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4715
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4723 4716
 						}
4724
-						$filtered =  true;
4717
+						$filtered = true;
4725 4718
 						$cutoffdate = $cutoffdate2 = null;
4726
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4727
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4719
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4720
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4728 4721
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4729 4722
 						$filter = array(
4730
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4731
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4723
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4724
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4732 4725
 							'string' => $query['search'],
4733
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4726
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4734 4727
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4735 4728
 						);
4736
-						if ($query['enddate']||$query['startdate']) {
4729
+						if ($query['enddate'] || $query['startdate']) {
4737 4730
 							$filter['range'] = "BETWEEN";
4738 4731
 							if ($cutoffdate) {
4739
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4732
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4740 4733
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4741 4734
 							}
4742 4735
 							if ($cutoffdate2) {
4743
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4736
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4744 4737
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4745 4738
 							}
4746 4739
 						}
@@ -4754,7 +4747,7 @@  discard block
 block discarded – undo
4754 4747
 					$rByUid = true;
4755 4748
 					$_sR = $this->mail_bo->getSortedList(
4756 4749
 						$folder,
4757
-						$sort=0,
4750
+						$sort = 0,
4758 4751
 						$reverse,
4759 4752
 						$filter,
4760 4753
 						$rByUid,
@@ -4764,23 +4757,23 @@  discard block
 block discarded – undo
4764 4757
 				}
4765 4758
 				else
4766 4759
 				{
4767
-					$messageList='all';
4760
+					$messageList = 'all';
4768 4761
 				}
4769 4762
 				try
4770 4763
 				{
4771 4764
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4772
-					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4765
+					$this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4773 4766
 				}
4774 4767
 				catch (Api\Exception $e)
4775 4768
 				{
4776
-					$error = str_replace('"',"'",$e->getMessage());
4769
+					$error = str_replace('"', "'", $e->getMessage());
4777 4770
 				}
4778 4771
 			}
4779 4772
 			else
4780 4773
 			{
4781 4774
 				$uidA = self::splitRowID($_messageList['msg'][0]);
4782 4775
 				$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4783
-				foreach($_messageList['msg'] as $rowID)
4776
+				foreach ($_messageList['msg'] as $rowID)
4784 4777
 				{
4785 4778
 					$hA = self::splitRowID($rowID);
4786 4779
 					$messageList[] = $hA['msgUID'];
@@ -4788,27 +4781,27 @@  discard block
 block discarded – undo
4788 4781
 				try
4789 4782
 				{
4790 4783
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
4791
-					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
4784
+					$this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
4792 4785
 				}
4793 4786
 				catch (Api\Exception $e)
4794 4787
 				{
4795
-					$error = str_replace('"',"'",$e->getMessage());
4788
+					$error = str_replace('"', "'", $e->getMessage());
4796 4789
 				}
4797 4790
 			}
4798 4791
 			$response = Api\Json\Response::get();
4799 4792
 			if (empty($error))
4800 4793
 			{
4801
-				$response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg']));
4794
+				$response->call('app.mail.mail_deleteMessagesShowResult', array('egw_message'=>lang('deleted %1 messages in %2', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($_messageList['msg'])), $folder), 'msg'=>$_messageList['msg']));
4802 4795
 			}
4803 4796
 			else
4804 4797
 			{
4805
-				$error = str_replace('\n',"\n",lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)',$error));
4806
-				$response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList));
4798
+				$error = str_replace('\n', "\n", lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)', $error));
4799
+				$response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList));
4807 4800
 			}
4808 4801
 		}
4809 4802
 		else
4810 4803
 		{
4811
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4804
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
4812 4805
 		}
4813 4806
 	}
4814 4807
 
@@ -4822,48 +4815,48 @@  discard block
 block discarded – undo
4822 4815
 	 *
4823 4816
 	 * @return xajax response
4824 4817
 	 */
4825
-	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
4818
+	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_')
4826 4819
 	{
4827
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4820
+		if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
4828 4821
 		Api\Translation::add_app('mail');
4829 4822
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4830 4823
 		// only copy or move are supported as method
4831
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
4832
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
4824
+		if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy';
4825
+		list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2);
4833 4826
 		// check if move2archive was called with the correct archiveFolder
4834 4827
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
4835
-		if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder)
4828
+		if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder)
4836 4829
 		{
4837 4830
 			error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder");
4838 4831
 			$targetProfileID = $this->mail_bo->profileID;
4839 4832
 			$targetFolder = $archiveFolder;
4840 4833
 			error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder");
4841 4834
 		}
4842
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
4835
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
4843 4836
 		$changeFolderActions = false;
4844 4837
 		//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
4845 4838
 		//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
4846 4839
 		if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
4847 4840
 		{
4848 4841
 			//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]));
4849
-			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
4842
+			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3)
4850 4843
 			{
4851 4844
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
4852
-				foreach( $keys as &$f)
4845
+				foreach ($keys as &$f)
4853 4846
 				{
4854
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4847
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
4855 4848
 					else break;
4856 4849
 				}
4857 4850
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
4858 4851
 			}
4859 4852
 			//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
4860
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName;
4853
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName;
4861 4854
 			$changeFolderActions = true;
4862 4855
 		}
4863 4856
 		$filtered = false;
4864
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4857
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4865 4858
 		{
4866
-			$error=false;
4859
+			$error = false;
4867 4860
 			if (isset($_messageList['all']) && $_messageList['all'])
4868 4861
 			{
4869 4862
 				// we have both messageIds AND allFlag folder information
@@ -4873,34 +4866,34 @@  discard block
 block discarded – undo
4873 4866
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4874 4867
 				{
4875 4868
 					$query = $_messageList['activeFilters'];
4876
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4869
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4877 4870
 					{
4878 4871
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4879 4872
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4880 4873
 						{
4881
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4882
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4874
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4875
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4883 4876
 						}
4884 4877
 						$filtered = true;
4885 4878
 						$cutoffdate = $cutoffdate2 = null;
4886
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4887
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4879
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4880
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4888 4881
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4889 4882
 						$filter = array(
4890
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4891
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4883
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')),
4884
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4892 4885
 							'string' => $query['search'],
4893
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
4886
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
4894 4887
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4895 4888
 						);
4896
-						if ($query['enddate']||$query['startdate']) {
4889
+						if ($query['enddate'] || $query['startdate']) {
4897 4890
 							$filter['range'] = "BETWEEN";
4898 4891
 							if ($cutoffdate) {
4899
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4892
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4900 4893
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4901 4894
 							}
4902 4895
 							if ($cutoffdate2) {
4903
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4896
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4904 4897
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4905 4898
 							}
4906 4899
 						}
@@ -4913,70 +4906,70 @@  discard block
 block discarded – undo
4913 4906
 					$rByUid = true;
4914 4907
 					$_sR = $this->mail_bo->getSortedList(
4915 4908
 						$folder,
4916
-						$sort=0,
4909
+						$sort = 0,
4917 4910
 						$reverse,
4918 4911
 						$filter,
4919
-						$rByUid=true,
4912
+						$rByUid = true,
4920 4913
 						false
4921 4914
 					);
4922 4915
 					$messageList = $_sR['match']->ids;
4923
-					foreach($messageList as $uID)
4916
+					foreach ($messageList as $uID)
4924 4917
 					{
4925 4918
 						//error_log(__METHOD__.__LINE__.$uID);
4926
-						if ($_copyOrMove=='move')
4919
+						if ($_copyOrMove == 'move')
4927 4920
 						{
4928
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false);
4921
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false);
4929 4922
 						}
4930 4923
 					}
4931 4924
 				}
4932 4925
 				else
4933 4926
 				{
4934
-					$messageList='all';
4927
+					$messageList = 'all';
4935 4928
 				}
4936 4929
 				try
4937 4930
 				{
4938 4931
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4939
-					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4932
+					$this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4940 4933
 				}
4941 4934
 				catch (Api\Exception $e)
4942 4935
 				{
4943
-					$error = str_replace('"',"'",$e->getMessage());
4936
+					$error = str_replace('"', "'", $e->getMessage());
4944 4937
 				}
4945 4938
 			}
4946 4939
 			else
4947 4940
 			{
4948 4941
 				$messageList = array();
4949
-				while(count($_messageList['msg']) > 0)
4942
+				while (count($_messageList['msg']) > 0)
4950 4943
 				{
4951 4944
 					$uidA = self::splitRowID($_messageList['msg'][0]);
4952 4945
 					$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4953 4946
 					$sourceProfileID = $uidA['profileID'];
4954 4947
 					$moveList = array();
4955
-					foreach($_messageList['msg'] as $rowID)
4948
+					foreach ($_messageList['msg'] as $rowID)
4956 4949
 					{
4957 4950
 						$hA = self::splitRowID($rowID);
4958 4951
 
4959 4952
 						// If folder changes, stop and move what we've got
4960
-						if($hA['folder'] != $folder) break;
4953
+						if ($hA['folder'] != $folder) break;
4961 4954
 
4962 4955
 						array_shift($_messageList['msg']);
4963 4956
 						$messageList[] = $hA['msgUID'];
4964 4957
 						$moveList[] = $hA['msgUID'];
4965
-						if ($_copyOrMove=='move')
4958
+						if ($_copyOrMove == 'move')
4966 4959
 						{
4967
-							$helpvar = explode(self::$delimiter,$rowID);
4960
+							$helpvar = explode(self::$delimiter, $rowID);
4968 4961
 							array_shift($helpvar);
4969
-							$messageListForRefresh[]= implode(self::$delimiter,$helpvar);
4962
+							$messageListForRefresh[] = implode(self::$delimiter, $helpvar);
4970 4963
 						}
4971 4964
 					}
4972 4965
 					try
4973 4966
 					{
4974 4967
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
4975
-						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
4968
+						$this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
4976 4969
 					}
4977 4970
 					catch (Api\Exception $e)
4978 4971
 					{
4979
-						$error = str_replace('"',"'",$e->getMessage());
4972
+						$error = str_replace('"', "'", $e->getMessage());
4980 4973
 					}
4981 4974
 				}
4982 4975
 			}
@@ -4989,30 +4982,30 @@  discard block
 block discarded – undo
4989 4982
 					unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]);
4990 4983
 					$changeFolderActions = true;
4991 4984
 				}
4992
-				$response->call('egw.message',$error,"error");
4985
+				$response->call('egw.message', $error, "error");
4993 4986
 			}
4994 4987
 			else
4995 4988
 			{
4996
-				if ($_copyOrMove=='copy')
4989
+				if ($_copyOrMove == 'copy')
4997 4990
 				{
4998
-					$response->call('egw.message',lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder));
4991
+					$response->call('egw.message', lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder));
4999 4992
 				}
5000 4993
 				else
5001 4994
 				{
5002
-					$response->call('egw.refresh',lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder),'mail',$messageListForRefresh,'delete');
4995
+					$response->call('egw.refresh', lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder), 'mail', $messageListForRefresh, 'delete');
5003 4996
 				}
5004 4997
 			}
5005 4998
 			if ($changeFolderActions == true)
5006 4999
 			{
5007 5000
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
5008
-				Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
5001
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
5009 5002
 				$actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions());
5010
-				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
5003
+				$response->call('app.mail.mail_rebuildActionsOnList', $actionsnew);
5011 5004
 			}
5012 5005
 		}
5013 5006
 		else
5014 5007
 		{
5015
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5008
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5016 5009
 		}
5017 5010
 	}
5018 5011
 
@@ -5022,11 +5015,11 @@  discard block
 block discarded – undo
5022 5015
 	 *
5023 5016
 	 * @param type $_id
5024 5017
 	 */
5025
-	function ajax_folderMgmtTree_autoloading ($_id = null)
5018
+	function ajax_folderMgmtTree_autoloading($_id = null)
5026 5019
 	{
5027 5020
 		$mail_ui = new mail_ui();
5028
-		$id = $_id? $_id : $_GET['id'];
5029
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false));
5021
+		$id = $_id ? $_id : $_GET['id'];
5022
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false));
5030 5023
 	}
5031 5024
 
5032 5025
 	/**
@@ -5034,15 +5027,15 @@  discard block
 block discarded – undo
5034 5027
 	 *
5035 5028
 	 * @param array $content content of dialog
5036 5029
 	 */
5037
-	function folderManagement (array $content = null)
5030
+	function folderManagement(array $content = null)
5038 5031
 	{
5039 5032
 		$dtmpl = new Etemplate('mail.folder_management');
5040
-		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
5041
-		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
5033
+		$profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id'];
5034
+		$sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false);
5042 5035
 
5043 5036
 		if (!is_array($content))
5044 5037
 		{
5045
-			$content = array ('acc_id' => $profileID);
5038
+			$content = array('acc_id' => $profileID);
5046 5039
 		}
5047 5040
 
5048 5041
 		$readonlys = array();
@@ -5050,7 +5043,7 @@  discard block
 block discarded – undo
5050 5043
 		$preserv = array(
5051 5044
 			'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side
5052 5045
 		);
5053
-		$dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2);
5046
+		$dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2);
5054 5047
 	}
5055 5048
 
5056 5049
 	/**
@@ -5060,11 +5053,11 @@  discard block
 block discarded – undo
5060 5053
 	 *
5061 5054
 	 * @param type $_folderName
5062 5055
 	 */
5063
-	function ajax_folderMgmt_delete ($_folderName)
5056
+	function ajax_folderMgmt_delete($_folderName)
5064 5057
 	{
5065 5058
 		if ($_folderName)
5066 5059
 		{
5067
-			$success = $this->ajax_deleteFolder($_folderName,true);
5060
+			$success = $this->ajax_deleteFolder($_folderName, true);
5068 5061
 			$response = Api\Json\Response::get();
5069 5062
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
5070 5063
 			if ($success)
@@ -5073,7 +5066,7 @@  discard block
 block discarded – undo
5073 5066
 			}
5074 5067
 			else
5075 5068
 			{
5076
-				$res = lang("Failed to delete %1",$folderName);
5069
+				$res = lang("Failed to delete %1", $folderName);
5077 5070
 			}
5078 5071
 			$response->data($res);
5079 5072
 		}
Please login to merge, or discard this patch.
mail/inc/class.mail_zpush.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 	 * @param string              $newfolderid         id of the destination folder
1306 1306
 	 * @param ContentParameters   $contentParameters
1307 1307
 	 *
1308
-	 * @return boolean                      status of the operation
1308
+	 * @return string                      status of the operation
1309 1309
 	 * @throws StatusException              could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
1310 1310
 	 */
1311 1311
 	public function MoveMessage($folderid, $id, $newfolderid, $contentParameters)
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
 	 * @param string $displayname => new folder name (to be created, or to be renamed to)
1833 1833
 	 * @param string $type folder type, ignored in IMAP
1834 1834
 	 *
1835
-	 * @return array|boolean stat array or false on error
1835
+	 * @return boolean stat array or false on error
1836 1836
 	 */
1837 1837
 	public function ChangeFolder($id, $oldid, $displayname, $type)
1838 1838
 	{
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
 	 * @param string $id of the folder to delete
1848 1848
 	 *
1849 1849
 	 * @return
1850
-	 * @TODO check what is to be returned
1850
+	 boolean @TODO check what is to be returned
1851 1851
 	 */
1852 1852
 	public function DeleteFolder($parentid, $id)
1853 1853
 	{
Please login to merge, or discard this patch.
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -312,44 +312,44 @@  discard block
 block discarded – undo
312 312
 		return $folderlist;
313 313
 	}
314 314
 
315
-    /**
316
-     * Sends a message which is passed as rfc822. You basically can do two things
317
-     * 1) Send the message to an SMTP server as-is
318
-     * 2) Parse the message yourself, and send it some other way
319
-     * It is up to you whether you want to put the message in the sent items folder. If you
320
-     * want it in 'sent items', then the next sync on the 'sent items' folder should return
321
-     * the new message as any other new message in a folder.
322
-     *
323
-     * @param array $smartdata = IMAP-SendMail: SyncSendMail (
324
-     *        (S) clientid => SendMail-30722448149304
325
-     *        (S) saveinsent => empty
326
-     *        (S) replacemime => null
327
-     *        (S) accountid => null
328
-     *        (S) source => SyncSendMailSource (
329
-     *                                (S) folderid => 101000000000
330
-     *                                (S) itemid => 33776
331
-     *                                (S) longid => null
332
-     *                                (S) instanceid => null
333
-     *                                unsetVars(Array) size: 0
334
-     *                                flags => false
335
-     *                                content => null
336
-     *                        )
337
-     *        (S) mime => Date: Tue, 23 Jun 2015 14:13:23 +0200
338
-     *Subject: AW: Blauer himmel
339
-     *....
340
-     *        (S) replyflag => true
341
-     *        (S) forwardflag => null
342
-     *        unsetVars(Array) size: 0
343
-     *        flags => false
344
-     *        content => null
345
-     *)
315
+	/**
316
+	 * Sends a message which is passed as rfc822. You basically can do two things
317
+	 * 1) Send the message to an SMTP server as-is
318
+	 * 2) Parse the message yourself, and send it some other way
319
+	 * It is up to you whether you want to put the message in the sent items folder. If you
320
+	 * want it in 'sent items', then the next sync on the 'sent items' folder should return
321
+	 * the new message as any other new message in a folder.
322
+	 *
323
+	 * @param array $smartdata = IMAP-SendMail: SyncSendMail (
324
+	 *        (S) clientid => SendMail-30722448149304
325
+	 *        (S) saveinsent => empty
326
+	 *        (S) replacemime => null
327
+	 *        (S) accountid => null
328
+	 *        (S) source => SyncSendMailSource (
329
+	 *                                (S) folderid => 101000000000
330
+	 *                                (S) itemid => 33776
331
+	 *                                (S) longid => null
332
+	 *                                (S) instanceid => null
333
+	 *                                unsetVars(Array) size: 0
334
+	 *                                flags => false
335
+	 *                                content => null
336
+	 *                        )
337
+	 *        (S) mime => Date: Tue, 23 Jun 2015 14:13:23 +0200
338
+	 *Subject: AW: Blauer himmel
339
+	 *....
340
+	 *        (S) replyflag => true
341
+	 *        (S) forwardflag => null
342
+	 *        unsetVars(Array) size: 0
343
+	 *        flags => false
344
+	 *        content => null
345
+	 *)
346 346
 	 *
347
-     * @return boolean true on success, false on error
348
-     *
349
-     * @see eg. BackendIMAP::SendMail()
350
-     * @todo implement either here or in mail backend
351
-     * 	(maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware)
352
-     */
347
+	 * @return boolean true on success, false on error
348
+	 *
349
+	 * @see eg. BackendIMAP::SendMail()
350
+	 * @todo implement either here or in mail backend
351
+	 * 	(maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware)
352
+	 */
353 353
 	public function SendMail($smartdata)
354 354
 	{
355 355
 		//$this->debugLevel=2;
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 		//error_log(__METHOD__.__LINE__.array2string($mailObject));
473 473
 		// if this is a multipart message with a boundary, we must use the original body
474 474
 		//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject));
475
-        if ($use_orgbody) {
476
-    	    ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
475
+		if ($use_orgbody) {
476
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
477 477
  			// if it is a ClientSideMeetingRequest, we report it as send at all times
478 478
 			if (($cal_body = $mailObject->findBody('calendar')) &&
479 479
 				($cSMRMethod = $cal_body->getContentTypeParameter('method')))
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
486 486
 				$ClientSideMeetingRequest = true;
487 487
 			}
488
-        }
488
+		}
489 489
 		// now handle the addressee list
490 490
 		$toCount = 0;
491 491
 		//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 			$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
576 576
 			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
577 577
 			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
578
-		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
578
+			if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
579 579
 				// may be html
580 580
 				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
581 581
 				$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 			$this->splitID($smartdata->source->folderid, $account, $folder);
623 623
 
624 624
 			$this->mail->reopen($folder);
625
-            // receive entire mail (header + body)
625
+			// receive entire mail (header + body)
626 626
 			// get message headers for specified message
627 627
 			$headers	= $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
628 628
 			// build a new mime message, forward entire old mail as file
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		}
707 707
 		//advanced debugging
708 708
 		// Horde SMTP Class uses utf-8 by default.
709
-        //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
709
+		//ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
710 710
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
711 711
 
712 712
 		// set a higher timeout for big messages
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 						//$asf = false;
800 800
 						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName));
801 801
 					}
802
-			        ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed"));
802
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed"));
803 803
 				}
804 804
 				//$this->mail->closeConnection();
805 805
 			}
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 			// end handle Attachments
1150 1150
 			unset($attachments);
1151 1151
 
1152
-            // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1153
-            $output->internetcpid = INTERNET_CPID_UTF8;
1152
+			// Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1153
+			$output->internetcpid = INTERNET_CPID_UTF8;
1154 1154
 
1155 1155
 			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1156 1156
 //$this->debugLevel=0;
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
 	 * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should
1209 1209
 	 * encode any information you need to find the attachment in that 'attname' property.
1210 1210
 	 *
1211
-     * @param string $fid - id
1212
-     * @param string $attname - should contain (folder)id
1211
+	 * @param string $fid - id
1212
+	 * @param string $attname - should contain (folder)id
1213 1213
 	 * @return SyncItemOperationsAttachment-object
1214 1214
 	 */
1215 1215
 	function GetAttachmentData($fid,$attname) {
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
 	 * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should
1224 1224
 	 * encode any information you need to find the attachment in that 'attname' property.
1225 1225
 	 *
1226
-     * @param string $fid - id
1227
-     * @param string $attname - should contain (folder)id
1226
+	 * @param string $fid - id
1227
+	 * @param string $attname - should contain (folder)id
1228 1228
 	 * @return SyncItemOperationsAttachment-object
1229 1229
 	 */
1230 1230
 	function ItemOperationsGetAttachmentData($fid,$attname) {
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 	 * -ItemOperationsGetAttachmentData
1238 1238
 	 * -GetAttachmentData
1239 1239
 	 *
1240
-     * @param string $fid - id
1241
-     * @param string $attname - should contain (folder)id
1240
+	 * @param string $fid - id
1241
+	 * @param string $attname - should contain (folder)id
1242 1242
 	 * @return SyncItemOperationsAttachment-object
1243 1243
 	 */
1244 1244
 	private function _GetAttachmentData($fid,$attname)
@@ -1746,13 +1746,13 @@  discard block
 block discarded – undo
1746 1746
 
1747 1747
 		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1748 1748
 
1749
-        $this->mail->reopen($folder);
1749
+		$this->mail->reopen($folder);
1750 1750
 
1751 1751
 		if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true)))
1752 1752
 		{
1753
-            ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder ");
1754
-            return false;
1755
-        }
1753
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder ");
1754
+			return false;
1755
+		}
1756 1756
 		$syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1757 1757
 
1758 1758
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
@@ -1773,22 +1773,22 @@  discard block
 block discarded – undo
1773 1773
 		return $id;
1774 1774
 	}
1775 1775
 
1776
-    /**
1777
-     * Called when the user has requested to delete (really delete) a message. Usually
1778
-     * this means just unlinking the file its in or somesuch. After this call has succeeded, a call to
1779
-     * GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile
1780
-     * as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to
1781
-     * delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile
1782
-     *
1783
-     * @param string              $folderid             id of the folder
1784
-     * @param string              $id                   id of the message
1785
-     * @param ContentParameters   $contentParameters
1786
-     *
1787
-     * @access public
1788
-     * @return boolean                      status of the operation
1789
-     * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1790
-     */
1791
-    public function DeleteMessage($folderid, $id, $contentParameters)
1776
+	/**
1777
+	 * Called when the user has requested to delete (really delete) a message. Usually
1778
+	 * this means just unlinking the file its in or somesuch. After this call has succeeded, a call to
1779
+	 * GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile
1780
+	 * as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to
1781
+	 * delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile
1782
+	 *
1783
+	 * @param string              $folderid             id of the folder
1784
+	 * @param string              $id                   id of the message
1785
+	 * @param ContentParameters   $contentParameters
1786
+	 *
1787
+	 * @access public
1788
+	 * @return boolean                      status of the operation
1789
+	 * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1790
+	 */
1791
+	public function DeleteMessage($folderid, $id, $contentParameters)
1792 1792
 	{
1793 1793
 		unset($contentParameters);	// not used, but required by function signature
1794 1794
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid'  id: '$id' )");
@@ -1830,24 +1830,24 @@  discard block
 block discarded – undo
1830 1830
 		return $rv;
1831 1831
 	}
1832 1832
 
1833
-    /**
1834
-     * Changes the 'read' flag of a message on disk. The $flags
1835
-     * parameter can only be '1' (read) or '0' (unread). After a call to
1836
-     * SetReadFlag(), GetMessageList() should return the message with the
1837
-     * new 'flags' but should not modify the 'mod' parameter. If you do
1838
-     * change 'mod', simply setting the message to 'read' on the mobile will trigger
1839
-     * a full resync of the item from the server.
1840
-     *
1841
-     * @param string              $folderid            id of the folder
1842
-     * @param string              $id                  id of the message
1843
-     * @param int                 $flags               read flag of the message
1844
-     * @param ContentParameters   $contentParameters
1845
-     *
1846
-     * @access public
1847
-     * @return boolean                      status of the operation
1848
-     * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1849
-     */
1850
-    public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1833
+	/**
1834
+	 * Changes the 'read' flag of a message on disk. The $flags
1835
+	 * parameter can only be '1' (read) or '0' (unread). After a call to
1836
+	 * SetReadFlag(), GetMessageList() should return the message with the
1837
+	 * new 'flags' but should not modify the 'mod' parameter. If you do
1838
+	 * change 'mod', simply setting the message to 'read' on the mobile will trigger
1839
+	 * a full resync of the item from the server.
1840
+	 *
1841
+	 * @param string              $folderid            id of the folder
1842
+	 * @param string              $id                  id of the message
1843
+	 * @param int                 $flags               read flag of the message
1844
+	 * @param ContentParameters   $contentParameters
1845
+	 *
1846
+	 * @access public
1847
+	 * @return boolean                      status of the operation
1848
+	 * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1849
+	 */
1850
+	public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1851 1851
 	{
1852 1852
 		unset($contentParameters);	// not used, but required by function signature
1853 1853
 		// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid'  id: '$id'  flags: '$flags' )");
Please login to merge, or discard this patch.
Spacing   +344 added lines, -345 removed lines patch added patch discarded remove patch
@@ -87,23 +87,23 @@  discard block
 block discarded – undo
87 87
 		$this->backend = $backend;
88 88
 		if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
89 89
 		{
90
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
90
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
91 91
 			// globals preferences add appname varname value
92
-			$GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user');
92
+			$GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user');
93 93
 			// save prefs
94 94
 			$GLOBALS['egw']->preferences->save_repository(true);
95 95
 		}
96
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
96
+		if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
97 97
 
98 98
 		if (is_null(self::$profileID))
99 99
 		{
100
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
101
-			self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID');
102
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
100
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
101
+			self::$profileID = & Api\Cache::getSession('mail', 'activeSyncProfileID');
102
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
103 103
 		}
104 104
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
105 105
 		{
106
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
106
+			if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
107 107
 			if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G')
108 108
 			{
109 109
 				self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is)
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 				self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'];
114 114
 			}
115 115
 		}
116
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
116
+		if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
117 117
 
118 118
 		// verify we are on an existing profile, if not running in setup (settings can not be static according to interface!)
119 119
 		if (!isset($GLOBALS['egw_setup']))
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 			try {
122 122
 				Mail\Account::read(self::$profileID);
123 123
 			}
124
-			catch(Exception $e) {
124
+			catch (Exception $e) {
125 125
 				unset($e);
126 126
 				self::$profileID = Mail\Account::get_default_acc_id();
127 127
 			}
128 128
 		}
129
-		if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
129
+		if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
130 130
 		//$this->debugLevel=0;
131 131
 	}
132 132
 
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 			$this->__construct($this->backend);
231 231
 
232 232
 			try {
233
-				$this->_connect(0,true);
233
+				$this->_connect(0, true);
234 234
 				$this->_disconnect();
235 235
 
236 236
 				if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>');
237 237
 				if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>');
238 238
 			}
239
-			catch(Exception $e) {
239
+			catch (Exception $e) {
240 240
 				$errors[] = lang('Can not open IMAP connection').': '.$e->getMessage();
241 241
 			}
242 242
 			if ($errors)
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 * @param int $account integer id of account to use
255 255
 	 * @todo support different accounts
256 256
 	 */
257
-	private function _connect($account=0)
257
+	private function _connect($account = 0)
258 258
 	{
259 259
 		if (!$account) $account = self::$profileID ? self::$profileID : 0;
260 260
 		if ($this->mail && $this->account != $account) $this->_disconnect();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			$this->account = $account;
268 268
 			// todo: tell mail which account to use
269 269
 			//error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID));
270
-			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
270
+			$this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
271 271
 			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
272 272
 		}
273 273
 		else
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 			//error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID);
276 276
 			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
277 277
 		}
278
-		$this->mail->openConnection(self::$profileID,false);
278
+		$this->mail->openConnection(self::$profileID, false);
279 279
 
280 280
 		$this->_wasteID = $this->mail->getTrashFolder(false);
281 281
 		//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	private function _disconnect()
292 292
 	{
293
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__);
293
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__);
294 294
 		if ($this->mail) $this->mail->closeConnection();
295 295
 
296 296
 		unset($this->mail);
@@ -306,24 +306,24 @@  discard block
 block discarded – undo
306 306
 	public function GetFolderList()
307 307
 	{
308 308
 		$folderlist = array();
309
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
309
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__);
310 310
 		/*foreach($available_accounts as $account)*/ $account = 0;
311 311
 		{
312 312
 			$this->_connect($account);
313
-			if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true);
314
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders));
313
+			if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true);
314
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders));
315 315
 
316 316
 			foreach ($this->folders as $folder => $folderObj) {
317
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder);
317
+				if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder);
318 318
 				$folderlist[] = $f = array(
319
-					'id'     => $this->createID($account,$folder),
319
+					'id'     => $this->createID($account, $folder),
320 320
 					'mod'    => $folderObj->shortDisplayName,
321
-					'parent' => $this->getParentID($account,$folder),
321
+					'parent' => $this->getParentID($account, $folder),
322 322
 				);
323
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f));
323
+				if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f));
324 324
 			}
325 325
 		}
326
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist));
326
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist));
327 327
 
328 328
 		return $folderlist;
329 329
 	}
@@ -372,59 +372,59 @@  discard block
 block discarded – undo
372 372
 		$ClientSideMeetingRequest = false;
373 373
 		$allowSendingInvitations = 'sendifnocalnotif';
374 374
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
375
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend')
375
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend')
376 376
 		{
377 377
 			$allowSendingInvitations = false;
378 378
 		}
379 379
 		elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
380
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend')
380
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend')
381 381
 		{
382 382
 			$allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'];
383 383
 		}
384
-		$smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new'));
384
+		$smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new'));
385 385
 
386
-   		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : ""));
387
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
386
+   		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.(isset($smartdata->mime) ? $smartdata->mime : "")."task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : ""));
387
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
388 388
 		//error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata));
389 389
 
390 390
 		// initialize our Mail
391
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
391
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
392 392
 		$activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID);
393 393
 		// use the standardIdentity
394
-		$activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID);
394
+		$activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID);
395 395
 
396
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile));
396
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile));
397 397
 
398 398
 		// initialize the new Api\Mailer object for sending
399 399
 		$mailObject = new Api\Mailer(self::$profileID);
400
-		$this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime);
400
+		$this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime);
401 401
 		// Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8
402
-		$mailObject->Sender  = $activeMailProfile['ident_email'];
403
-		$mailObject->From 	= $activeMailProfile['ident_email'];
404
-		$mailObject->FromName = Mail::generateIdentityString($activeMailProfile,false);
402
+		$mailObject->Sender = $activeMailProfile['ident_email'];
403
+		$mailObject->From = $activeMailProfile['ident_email'];
404
+		$mailObject->FromName = Mail::generateIdentityString($activeMailProfile, false);
405 405
 		$mailObject->addHeader('X-Mailer', 'mail-Activesync');
406 406
 
407 407
 
408 408
 		// prepare addressee list; moved the adding of addresses to the mailobject down
409 409
 		// to
410 410
 
411
-		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
411
+		foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
412 412
 			if (!$addressObject->valid) continue;
413
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) );
413
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject));
414 414
 			//$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
415 415
 			$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
416 416
 		}
417 417
 		// CC
418
-		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
418
+		foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
419 419
 			if (!$addressObject->valid) continue;
420
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) );
420
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject));
421 421
 			//$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
422 422
 			$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
423 423
 		}
424 424
 		// BCC
425
-		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
425
+		foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
426 426
 			if (!$addressObject->valid) continue;
427
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) );
427
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject));
428 428
 			//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
429 429
 			$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
430 430
 		}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 		$use_orgbody = false;
434 434
 
435 435
 		$k = 'Content-Type';
436
-		$ContentType =$mailObject->getHeader('Content-Type');
436
+		$ContentType = $mailObject->getHeader('Content-Type');
437 437
 		//error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k.  " = ".trim($ContentType));
438 438
 		// if the message is a multipart message, then we should use the sent body
439 439
 		if (preg_match("/multipart/i", $ContentType)) {
@@ -453,43 +453,43 @@  discard block
 block discarded – undo
453 453
 			$k == "Content-Type" && preg_match("/multipart/i", $ContentType))) {
454 454
 			$use_orgbody = true;
455 455
 		}
456
-		$Body =  $AltBody = "";
456
+		$Body = $AltBody = "";
457 457
 		// get body of the transmitted message
458 458
 		// if this is a simple message, no structure at all
459 459
 		if (preg_match("/text/i", $ContentType))
460 460
 		{
461
-			$simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain');
461
+			$simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain');
462 462
 			$bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain');
463
-			$body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null);
464
-			if  ($simpleBodyType == "text/plain")
463
+			$body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null);
464
+			if ($simpleBodyType == "text/plain")
465 465
 			{
466 466
 				$Body = $body;
467 467
 				$AltBody = "<pre>".nl2br($body)."</pre>";
468
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody');
468
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody');
469 469
 			}
470 470
 			else
471 471
 			{
472 472
 				$AltBody = $body;
473
-				$Body =  trim(Api\Mail\Html::convertHTMLToText($body));
474
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body');
473
+				$Body = trim(Api\Mail\Html::convertHTMLToText($body));
474
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body');
475 475
 			}
476 476
 		}
477 477
 		else
478 478
 		{
479 479
 			// if this is a structured message
480 480
 			// prefer plain over html
481
-			$Body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
481
+			$Body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]",
482 482
 				($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null);
483
-			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
483
+			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]",
484 484
 				($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null);
485 485
 		}
486
-		if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
487
-		if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
486
+		if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body);
487
+		if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody);
488 488
 		//error_log(__METHOD__.__LINE__.array2string($mailObject));
489 489
 		// if this is a multipart message with a boundary, we must use the original body
490 490
 		//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject));
491 491
         if ($use_orgbody) {
492
-    	    ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
492
+    	    ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
493 493
  			// if it is a ClientSideMeetingRequest, we report it as send at all times
494 494
 			if (($cal_body = $mailObject->findBody('calendar')) &&
495 495
 				($cSMRMethod = $cal_body->getContentTypeParameter('method')))
@@ -498,21 +498,21 @@  discard block
 block discarded – undo
498 498
 				{
499 499
 					$organizer = calendar_ical::getIcalOrganizer($cal_body->getContents());
500 500
 				}
501
-				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
501
+				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
502 502
 				$ClientSideMeetingRequest = true;
503 503
 			}
504 504
         }
505 505
 		// now handle the addressee list
506 506
 		$toCount = 0;
507 507
 		//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
508
-		foreach((array)$toMailAddr as $address) {
509
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
510
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
508
+		foreach ((array)$toMailAddr as $address) {
509
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
510
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
511 511
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' &&
512 512
 					calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST',
513 513
 						$organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : ''))
514 514
 				{
515
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app");
515
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app");
516 516
 					continue;
517 517
 				}
518 518
 				$mailObject->AddAddress($emailAddress, $addressObject->personal);
@@ -520,29 +520,29 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 		}
522 522
 		$ccCount = 0;
523
-		foreach((array)$ccMailAddr as $address) {
524
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
525
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
523
+		foreach ((array)$ccMailAddr as $address) {
524
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
525
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
526 526
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
527 527
 				$mailObject->AddCC($emailAddress, $addressObject->personal);
528 528
 				$ccCount++;
529 529
 			}
530 530
 		}
531 531
 		$bccCount = 0;
532
-		foreach((array)$bccMailAddr as $address) {
533
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
534
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
532
+		foreach ((array)$bccMailAddr as $address) {
533
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
534
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
535 535
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
536 536
 				$mailObject->AddBCC($emailAddress, $addressObject->personal);
537 537
 				$bccCount++;
538 538
 			}
539 539
 		}
540 540
 		// typical organizer reply will end here with nothing send --> return true, because we suppressed the send above
541
-		if ($toCount+$ccCount+$bccCount == 0)
541
+		if ($toCount + $ccCount + $bccCount == 0)
542 542
 		{
543 543
 			return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to
544 544
 		}
545
-		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true;
545
+		if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true;
546 546
 		// as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail
547 547
 /*
548 548
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body);
@@ -550,29 +550,29 @@  discard block
 block discarded – undo
550 550
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body (modified):'.$body);
551 551
 */
552 552
 		// add signature!! -----------------------------------------------------------------
553
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile));
553
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile));
554 554
 		try
555 555
 		{
556 556
 			$acc = Mail\Account::read($this->mail->icServer->ImapServerId);
557 557
 			//error_log(__METHOD__.__LINE__.array2string($acc));
558
-			$_signature = Mail\Account::read_identity($acc['ident_id'],true);
558
+			$_signature = Mail\Account::read_identity($acc['ident_id'], true);
559 559
 		}
560 560
 		catch (Exception $e)
561 561
 		{
562
-			$_signature=array();
562
+			$_signature = array();
563 563
 		}
564 564
 		$signature = $_signature['ident_signature'];
565 565
 		if ((isset($preferencesArray['disableRulerForSignatureSeparation']) &&
566 566
 			$preferencesArray['disableRulerForSignatureSeparation']) ||
567
-			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='')
567
+			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '')
568 568
 		{
569 569
 			$disableRuler = true;
570 570
 		}
571 571
 		$beforePlain = $beforeHtml = "";
572
-		$beforeHtml = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
573
-		$beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
574
-		$sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
575
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
572
+		$beforeHtml = ($disableRuler ? '&nbsp;<br>' : '&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
573
+		$beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
574
+		$sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
575
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText);
576 576
 		$sigTextHtml = $beforeHtml.$sigText;
577 577
 		$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText);
578 578
 		$isreply = $isforward = false;
@@ -584,26 +584,26 @@  discard block
 block discarded – undo
584 584
 		{
585 585
 			// now get on, and fetch the original mail
586 586
 			$uid = $smartdata->source->itemid;
587
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
587
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
588 588
 			$this->splitID($smartdata->source->folderid, $account, $folder);
589 589
 
590 590
 			$this->mail->reopen($folder);
591 591
 			$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
592
-			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
593
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
594
-		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
592
+			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
593
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
594
+		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
595 595
 				// may be html
596
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
596
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
597 597
 				$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
598 598
 				$isreply = true;
599 599
 			}
600 600
 			// plain text Message part
601
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
601
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
602 602
 			// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
603
-			$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
604
-			$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
605
-			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
606
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
603
+			$bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display');
604
+			$bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
605
+			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) {
606
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
607 607
 				$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
608 608
 				$isreply = true;
609 609
 			}
@@ -611,12 +611,12 @@  discard block
 block discarded – undo
611 611
 			{
612 612
 				$isreply = true;
613 613
 				$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
614
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
614
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
615 615
 			}
616 616
 		}
617 617
 
618 618
 		// how to forward and other prefs
619
-		$preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail'];
619
+		$preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail'];
620 620
 
621 621
 		// forward -------------------------------------------------------------------------
622 622
 		if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) &&
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		{
627 627
 			//force the default for the forwarding -> asmail
628 628
 			if (is_array($preferencesArray)) {
629
-				if (!array_key_exists('message_forwarding',$preferencesArray)
629
+				if (!array_key_exists('message_forwarding', $preferencesArray)
630 630
 					|| !isset($preferencesArray['message_forwarding'])
631 631
 					|| empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail';
632 632
 			} else {
@@ -634,18 +634,18 @@  discard block
 block discarded – undo
634 634
 			}
635 635
 			// construct the uid of the message out of the itemid - seems to be the uid, no construction needed
636 636
 			$uid = $smartdata->source->itemid;
637
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
637
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
638 638
 			$this->splitID($smartdata->source->folderid, $account, $folder);
639 639
 
640 640
 			$this->mail->reopen($folder);
641 641
             // receive entire mail (header + body)
642 642
 			// get message headers for specified message
643
-			$headers	= $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
643
+			$headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
644 644
 			// build a new mime message, forward entire old mail as file
645 645
 			if ($preferencesArray['message_forwarding'] == 'asmail')
646 646
 			{
647
-				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder);
648
-				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder);
647
+				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder);
648
+				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder);
649 649
 				$mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822');
650 650
 				$AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml;
651 651
 				$Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain;
@@ -655,50 +655,50 @@  discard block
 block discarded – undo
655 655
 			{
656 656
 				// now get on, and fetch the original mail
657 657
 				$uid = $smartdata->source->itemid;
658
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
658
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
659 659
 				$this->splitID($smartdata->source->folderid, $account, $folder);
660 660
 
661 661
 				$this->mail->reopen($folder);
662 662
 				$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
663
-				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
664
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
665
-				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
663
+				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
664
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
665
+				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
666 666
 					// may be html
667
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
667
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
668 668
 					$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
669 669
 					$isforward = true;
670 670
 				}
671 671
 				// plain text Message part
672
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
672
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
673 673
 				// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
674
-				$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
675
-				$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
676
-				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
677
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
674
+				$bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display');
675
+				$bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
676
+				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) {
677
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
678 678
 					$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
679 679
 					$isforward = true;
680 680
 				}
681 681
 				if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody))
682 682
 				{
683 683
 					$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
684
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
684
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
685 685
 					$isforward = true;
686 686
 				}
687 687
 				// get all the attachments and add them too.
688 688
 				// start handle Attachments
689 689
 				//												$_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName=''
690
-				$attachments = $this->mail->getMessageAttachments($uid, null,          null,								true,						false,				 true			, $folder);
690
+				$attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder);
691 691
 				$attachmentNames = false;
692
-				if (is_array($attachments) && count($attachments)>0)
692
+				if (is_array($attachments) && count($attachments) > 0)
693 693
 				{
694
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
695
-					foreach((array)$attachments as $key => $attachment)
694
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
695
+					foreach ((array)$attachments as $key => $attachment)
696 696
 					{
697
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
697
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
698 698
 						$attachmentNames .= $attachment['name']."\n";
699
-						$attachmentData	= $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder);
699
+						$attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder);
700 700
 						/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']);
701
-						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x);
701
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x);
702 702
 					}
703 703
 				}
704 704
 			}
@@ -712,36 +712,36 @@  discard block
 block discarded – undo
712 712
 		// now set the body
713 713
 		if ($AltBody && ($html_body = $mailObject->findBody('html')))
714 714
 		{
715
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
716
-			$html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
715
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody);
716
+			$html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
717 717
 		}
718 718
 		if ($Body && ($text_body = $mailObject->findBody('plain')))
719 719
 		{
720
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
721
-			$text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
720
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body);
721
+			$text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
722 722
 		}
723 723
 		//advanced debugging
724 724
 		// Horde SMTP Class uses utf-8 by default.
725 725
         //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
726
-		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
726
+		if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
727 727
 
728 728
 		// set a higher timeout for big messages
729 729
 		@set_time_limit(120);
730
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....');
730
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....');
731 731
 		// send
732 732
 		$send = true;
733 733
 		try {
734 734
 			$mailObject->Send();
735 735
 		}
736
-		catch(Exception $e) {
737
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage());
736
+		catch (Exception $e) {
737
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage());
738 738
 			$send = false;
739 739
 		}
740 740
 
741
-		if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true)
741
+		if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true)
742 742
 		{
743 743
 			$uid = $smartdata->source->itemid;
744
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
744
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
745 745
 			$this->splitID($smartdata->source->folderid, $account, $folder);
746 746
 			//error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid);
747 747
 			$this->mail->reopen($folder);
@@ -749,89 +749,89 @@  discard block
 block discarded – undo
749 749
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
750 750
 			if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder))
751 751
 			{
752
-				$this->mail->deleteMessages(array($uid),$folder);
752
+				$this->mail->deleteMessages(array($uid), $folder);
753 753
 			} else {
754
-				$this->mail->flagMessages("answered", array($uid),$folder);
755
-				if ($smartdata_task== "forward")
754
+				$this->mail->flagMessages("answered", array($uid), $folder);
755
+				if ($smartdata_task == "forward")
756 756
 				{
757
-					$this->mail->flagMessages("forwarded", array($uid),$folder);
757
+					$this->mail->flagMessages("forwarded", array($uid), $folder);
758 758
 				}
759 759
 			}
760 760
 		}
761 761
 
762
-		$asf = ($send ? true:false); // initalize accordingly
763
-		if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */  $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only')
762
+		$asf = ($send ? true : false); // initalize accordingly
763
+		if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */  $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only')
764 764
 		{
765 765
 			$asf = false;
766 766
 			$sentFolder = $this->mail->getSentFolder();
767 767
 			if ($this->_sentID) {
768 768
 				$folderArray[] = $this->_sentID;
769 769
 			}
770
-			else if(isset($sentFolder) && $sentFolder != 'none')
770
+			else if (isset($sentFolder) && $sentFolder != 'none')
771 771
 			{
772 772
 				$folderArray[] = $sentFolder;
773 773
 			}
774 774
 			// No Sent folder set, try defaults
775 775
 			else
776 776
 			{
777
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set");
777
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set");
778 778
 				// we dont try guessing
779 779
 				$asf = true;
780 780
 			}
781 781
 			if (count($folderArray) > 0) {
782
-				foreach((array)$bccMailAddr as $address) {
783
-					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
784
-						$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
782
+				foreach ((array)$bccMailAddr as $address) {
783
+					foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
784
+						$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
785 785
 						$mailAddr[] = array($emailAddress, $addressObject->personal);
786 786
 					}
787 787
 				}
788
-				$BCCmail='';
789
-				if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
790
-				foreach($folderArray as $folderName) {
791
-					if($this->mail->isSentFolder($folderName)) {
788
+				$BCCmail = '';
789
+				if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr);
790
+				foreach ($folderArray as $folderName) {
791
+					if ($this->mail->isSentFolder($folderName)) {
792 792
 						$flags = '\\Seen';
793
-					} elseif($this->mail->isDraftFolder($folderName)) {
793
+					} elseif ($this->mail->isDraftFolder($folderName)) {
794 794
 						$flags = '\\Draft';
795 795
 					} else {
796 796
 						$flags = '';
797 797
 					}
798 798
 					$asf = true;
799 799
 					//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer));
800
-					$this->mail->openConnection(self::$profileID,false);
800
+					$this->mail->openConnection(self::$profileID, false);
801 801
 					if ($this->mail->folderExists($folderName)) {
802 802
 						try
803 803
 						{
804
-							$this->mail->appendMessage($folderName,$mailObject->getRaw(), null,
804
+							$this->mail->appendMessage($folderName, $mailObject->getRaw(), null,
805 805
 									$flags);
806 806
 						}
807 807
 						catch (Api\Exception\WrongUserinput $e)
808 808
 						{
809 809
 							//$asf = false;
810
-							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage()));
810
+							ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage()));
811 811
 						}
812 812
 					}
813 813
 					else
814 814
 					{
815 815
 						//$asf = false;
816
-						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName));
816
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName));
817 817
 					}
818
-			        ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed"));
818
+			        ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed"));
819 819
 				}
820 820
 				//$this->mail->closeConnection();
821 821
 			}
822 822
 		}
823 823
 
824
-		$this->debugLevel=0;
824
+		$this->debugLevel = 0;
825 825
 
826 826
 		if ($send && $asf)
827 827
 		{
828
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully');
828
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully');
829 829
 			return true;
830 830
 		}
831 831
 		else
832 832
 		{
833
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":""));
834
-			return ($ClientSideMeetingRequest ? true : 120);   //MAIL Submission failed, see MS-ASCMD
833
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : ""));
834
+			return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD
835 835
 		}
836 836
 	}
837 837
 
@@ -849,43 +849,43 @@  discard block
 block discarded – undo
849 849
 	public function GetMessage($folderid, $id, $contentparameters)
850 850
 	{
851 851
 		//$this->debugLevel=4;
852
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters));
852
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters));
853 853
 		$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
854 854
 		$mimesupport = $contentparameters->GetMimeSupport();
855
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport));
855
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport));
856 856
 		$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */
857 857
 
858 858
 		// fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0
859 859
 		if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]);
860 860
 
861 861
 		//$this->debugLevel=4;
862
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
863
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
862
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
863
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
864 864
 		$account = $_folderName = $xid = null;
865
-		$this->splitID($folderid,$account,$_folderName,$xid);
865
+		$this->splitID($folderid, $account, $_folderName, $xid);
866 866
 		$this->mail->reopen($_folderName);
867
-		$messages = $this->fetchMessages($folderid, NULL, $id, true);	// true: return all headers
867
+		$messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers
868 868
 		$headers = $messages[$id];
869
-		if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
869
+		if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers));
870 870
 		// StatMessage should reopen the folder in question, so we dont need folderids in the following statements.
871 871
 		if ($headers)
872 872
 		{
873
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers));
873
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers));
874 874
 			// initialize the object
875 875
 			$output = new SyncMail();
876 876
 			//$rawHeaders = $this->mail->getMessageRawHeader($id);
877 877
 			// simple style
878 878
 			// start AS12 Stuff (bodypreference === false) case = old behaviour
879
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
879
+			if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers));
880 880
 
881 881
 			if ($bodypreference === false) {
882
-				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
883
-				$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
882
+				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName);
883
+				$raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
884 884
 				//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
885
-				if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
885
+				if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
886 886
 				// remove all other html
887 887
 				$body = strip_tags($raw_body);
888
-				if(strlen($body) > $truncsize) {
888
+				if (strlen($body) > $truncsize) {
889 889
 					$body = Utils::Utf8_truncate($body, $truncsize);
890 890
 					$output->bodytruncated = 1;
891 891
 				}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 			else // style with bodypreferences
900 900
 			{
901 901
 				//Select body type preference
902
-				$bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN;
902
+				$bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN;
903 903
 				if ($bodypreference !== false) {
904 904
 					// bodypreference can occur multiple times
905 905
 					// usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference);
@@ -913,12 +913,12 @@  discard block
 block discarded – undo
913 913
 					}
914 914
 */
915 915
 				}
916
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType));
916
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType));
917 917
 				// set the protocoll class
918 918
 				$output->asbody = new SyncBaseBody();
919 919
 
920 920
 				// return full mime-message without any (charset) conversation directly as stream
921
-				if ($bpReturnType==SYNC_BODYPREFERENCE_MIME)
921
+				if ($bpReturnType == SYNC_BODYPREFERENCE_MIME)
922 922
 				{
923 923
 					//SYNC_BODYPREFERENCE_MIME
924 924
 					$output->asbody->type = SYNC_BODYPREFERENCE_MIME;
@@ -927,58 +927,58 @@  discard block
 block discarded – undo
927 927
 					fseek($stream, 0, SEEK_SET);
928 928
 					$output->asbody->data = $stream;
929 929
 					$output->asbody->estimatedDataSize = $fstat['size'];
930
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]");
930
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]");
931 931
 				}
932 932
 				else
933 933
 				{
934 934
 					// fetch the body (try to gather data only once)
935
-					$css ='';
936
-					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
937
-					if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
938
-					$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
939
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
940
-					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
935
+					$css = '';
936
+					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName);
937
+					if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
938
+					$body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
939
+					if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body);
940
+					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
941 941
 						// may be html
942
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
942
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
943 943
 						$css = $this->mail->getStyles($bodyStruct);
944
-						$output->nativebodytype=2;
944
+						$output->nativebodytype = 2;
945 945
 					} else {
946 946
 						// plain text Message
947
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
948
-						$output->nativebodytype=1;
949
-						$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
950
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
951
-						$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
952
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
947
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
948
+						$output->nativebodytype = 1;
949
+						$bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text');
950
+						if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
951
+						$body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
952
+						if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body);
953 953
 					}
954 954
 					// whatever format decode (using the correct encoding)
955
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
955
+					if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body);
956 956
 					//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
957 957
 					// prepare plaintextbody
958
-					$plainBody='';
958
+					$plainBody = '';
959 959
 					if ($output->nativebodytype == 2)
960 960
 					{
961
-						$bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
962
-						if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1)
961
+						$bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text');
962
+						if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1)
963 963
 						{
964 964
 							$plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML
965 965
 						}
966 966
 						else
967 967
 						{
968
-							$plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false);
968
+							$plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false);
969 969
 						}
970 970
 					}
971 971
 					//if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body);
972
-					$plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body));
972
+					$plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body));
973 973
 					// remove all other html
974
-					$plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody);
974
+					$plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody);
975 975
 					$plainBody = strip_tags($plainBody);
976
-					if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
976
+					if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody);
977 977
 					//$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that?
978 978
 
979
-					if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML
979
+					if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML
980 980
 					{
981
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
981
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
982 982
 						// Send HTML if requested and native type was html
983 983
 						$output->asbody->type = 2;
984 984
 						$htmlbody = '<html>'.
@@ -988,23 +988,23 @@  discard block
 block discarded – undo
988 988
 							$css.
989 989
 							'</head>'.
990 990
 							'<body>';
991
-						if ($output->nativebodytype==2)
991
+						if ($output->nativebodytype == 2)
992 992
 						{
993
-							if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style');
993
+							if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style');
994 994
 							// as we fetch html, and body is HTML, we may not need to handle this
995 995
 							$htmlbody .= $body;
996 996
 						}
997 997
 						else
998 998
 						{
999 999
 							// html requested but got only plaintext, so fake html
1000
-							$htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody)));
1000
+							$htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody)));
1001 1001
 						}
1002 1002
 						$htmlbody .= '</body>'.
1003 1003
 								'</html>';
1004 1004
 
1005
-						if(isset($truncsize) && strlen($htmlbody) > $truncsize)
1005
+						if (isset($truncsize) && strlen($htmlbody) > $truncsize)
1006 1006
 						{
1007
-							$htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize);
1007
+							$htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize);
1008 1008
 							$output->asbody->truncated = 1;
1009 1009
 						}
1010 1010
 						// output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested.
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 					else
1016 1016
 					{
1017 1017
 						// Send Plaintext as Fallback or if original body is plainttext
1018
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1018
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1019 1019
 						/* we use plainBody (set above) instead
1020 1020
 						$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
1021 1021
 						$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 						*/
1026 1026
 						$output->asbody->type = 1;
1027 1027
 						$output->nativebodytype = 1;
1028
-						if(isset($truncsize) &&
1028
+						if (isset($truncsize) &&
1029 1029
 							strlen($plainBody) > $truncsize)
1030 1030
 						{
1031 1031
 							$plainBody = Utils::Utf8_truncate($plainBody, $truncsize);
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 				}
1045 1045
 			}
1046 1046
 			// end AS12 Stuff
1047
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']);
1047
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']);
1048 1048
 			$output->read = $headers["flags"];
1049 1049
 
1050 1050
 			$output->flag = new SyncMailFlags();
@@ -1064,9 +1064,8 @@  discard block
 block discarded – undo
1064 1064
 				$output->lastverexecuted = AS_FORWARD;
1065 1065
 			}
1066 1066
 			$output->subject = $headers['subject'];
1067
-			$output->importance = $headers['priority'] > 3 ? 0 :
1068
-				($headers['priority'] < 3 ? 2 : 1) ;
1069
-			$output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true);
1067
+			$output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1);
1068
+			$output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true);
1070 1069
 			$output->to = $headers['to_address'];
1071 1070
 			if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name']
1072 1071
 			$output->from = $headers['sender_address'];
@@ -1074,8 +1073,8 @@  discard block
 block discarded – undo
1074 1073
 			if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address'];
1075 1074
 
1076 1075
 			$output->messageclass = "IPM.Note";
1077
-			if (stripos($headers['mimetype'],'multipart')!== false &&
1078
-				stripos($headers['mimetype'],'signed')!== false)
1076
+			if (stripos($headers['mimetype'], 'multipart') !== false &&
1077
+				stripos($headers['mimetype'], 'signed') !== false)
1079 1078
 			{
1080 1079
 				$output->messageclass = "IPM.Note.SMIME.MultipartSigned";
1081 1080
 			}
@@ -1084,20 +1083,20 @@  discard block
 block discarded – undo
1084 1083
 			}
1085 1084
 
1086 1085
 			// start handle Attachments (include text/calendar multipart alternative)
1087
-			$attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName);
1086
+			$attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName);
1088 1087
 			// Attachments should not needed for MIME messages, so skip this part if bpReturnType==4
1089
-			if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0)
1088
+			if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0)
1090 1089
 			{
1091
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments));
1090
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments));
1092 1091
 				//error_log(__METHOD__.__LINE__.array2string($attachments));
1093 1092
 				foreach ($attachments as $key => $attach)
1094 1093
 				{
1095
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1094
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1096 1095
 
1097 1096
 					// pass meeting requests to calendar plugin
1098 1097
 					if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
1099 1098
 						isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
1100
-						($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) &&
1099
+						($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) &&
1101 1100
 						($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment'])))
1102 1101
 					{
1103 1102
 						//overwrite the globalobjId from calendar object, as: if you delete the mail, that is
@@ -1107,7 +1106,7 @@  discard block
 block discarded – undo
1107 1106
 						$output->messageclass = "IPM.Schedule.Meeting.Request";
1108 1107
 						//$output->messageclass = "IPM.Schedule.Meeting";
1109 1108
 						unset($attachment);
1110
-						continue;	// do NOT add attachment as attachment
1109
+						continue; // do NOT add attachment as attachment
1111 1110
 					}
1112 1111
 					if (Request::GetProtocolVersion() >= 12.0) {
1113 1112
 						$attachment = new SyncBaseAttachment();
@@ -1115,33 +1114,33 @@  discard block
 block discarded – undo
1115 1114
 							$output->asattachments = array();
1116 1115
 						$attachment->estimatedDataSize = $attach['size'];
1117 1116
 						$attachment->method = 1;
1118
-						$attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID'];
1117
+						$attachment->filereference = $folderid.":".$id.":".$attach['partID'];
1119 1118
 					} else {
1120 1119
 						$attachment = new SyncAttachment();
1121 1120
 						if (!isset($output->attachments) || !is_array($output->attachments))
1122 1121
 							$output->attachments = array();
1123 1122
 						$attachment->attsize = $attach['size'];
1124 1123
 						$attachment->attmethod = 1;
1125
-						$attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key;
1124
+						$attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key;
1126 1125
 					}
1127 1126
 
1128 1127
 					$attachment->displayname = $attach['name'];
1129 1128
 					//error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']);
1130 1129
 
1131
-					$attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : "";
1130
+					$attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : "";
1132 1131
 					//$attachment->isinline=0; // if not inline, do not use isinline
1133
-					if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' )
1132
+					if (!empty($attach['cid']) && $attach['cid'] <> 'NIL')
1134 1133
 					{
1135 1134
 						if ($bpReturnType != 4 && $attach['disposition'] == 'inline')
1136 1135
 						{
1137 1136
 							$attachment->isinline = true;
1138 1137
 						}
1139 1138
 						if (Request::GetProtocolVersion() >= 12.0) {
1140
-							$attachment->method=1;
1141
-							$attachment->contentid= str_replace(array("<",">"), "",$attach['cid']);
1139
+							$attachment->method = 1;
1140
+							$attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']);
1142 1141
 						} else {
1143
-							$attachment->attmethod=6;
1144
-							$attachment->attoid = str_replace(array("<",">"), "",$attach['cid']);
1142
+							$attachment->attmethod = 6;
1143
+							$attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']);
1145 1144
 						}
1146 1145
 						//	ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."'  ".$attachment->contentid);
1147 1146
 						$attachment->contenttype = trim($attach['mimeType']);
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
             // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1163 1162
             $output->internetcpid = INTERNET_CPID_UTF8;
1164 1163
 
1165
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1164
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output));
1166 1165
 //$this->debugLevel=0;
1167 1166
 			return $output;
1168 1167
 		}
@@ -1185,30 +1184,30 @@  discard block
 block discarded – undo
1185 1184
 	{
1186 1185
 		if (!class_exists('calendar_zpush'))
1187 1186
 		{
1188
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!");
1187
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!");
1189 1188
 			return null;
1190 1189
 		}
1191 1190
 		if (!($stat = $this->StatMessage($folderid, $requestid)))
1192 1191
 		{
1193
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)");
1192
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)");
1194 1193
 			return false;
1195 1194
 		}
1196 1195
 		$ret = false;
1197
-		foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach)
1196
+		foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach)
1198 1197
 		{
1199 1198
 			if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
1200
-				($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false)))
1199
+				($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false)))
1201 1200
 			{
1202
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')");
1201
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')");
1203 1202
 
1204 1203
 				// calling backend again with iCal attachment, to let calendar add the event
1205 1204
 				$ret = $this->backend->MeetingResponse($attachment['attachment'],
1206
-					$this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']),
1205
+					$this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']),
1207 1206
 					$response);
1208 1207
 				break;
1209 1208
 			}
1210 1209
 		}
1211
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret));
1210
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret));
1212 1211
 		return $ret;
1213 1212
 	}
1214 1213
 
@@ -1222,9 +1221,9 @@  discard block
 block discarded – undo
1222 1221
      * @param string $attname - should contain (folder)id
1223 1222
 	 * @return SyncItemOperationsAttachment-object
1224 1223
 	 */
1225
-	function GetAttachmentData($fid,$attname) {
1226
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1227
-		return $this->_GetAttachmentData($fid,$attname);
1224
+	function GetAttachmentData($fid, $attname) {
1225
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')");
1226
+		return $this->_GetAttachmentData($fid, $attname);
1228 1227
 	}
1229 1228
 
1230 1229
 	/**
@@ -1237,9 +1236,9 @@  discard block
 block discarded – undo
1237 1236
      * @param string $attname - should contain (folder)id
1238 1237
 	 * @return SyncItemOperationsAttachment-object
1239 1238
 	 */
1240
-	function ItemOperationsGetAttachmentData($fid,$attname) {
1241
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1242
-		return $this->_GetAttachmentData($fid,$attname);
1239
+	function ItemOperationsGetAttachmentData($fid, $attname) {
1240
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')");
1241
+		return $this->_GetAttachmentData($fid, $attname);
1243 1242
 	}
1244 1243
 
1245 1244
 	/**
@@ -1251,23 +1250,23 @@  discard block
 block discarded – undo
1251 1250
      * @param string $attname - should contain (folder)id
1252 1251
 	 * @return SyncItemOperationsAttachment-object
1253 1252
 	 */
1254
-	private function _GetAttachmentData($fid,$attname)
1253
+	private function _GetAttachmentData($fid, $attname)
1255 1254
 	{
1256
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace());
1255
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace());
1257 1256
 		//error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')");
1258 1257
 		list($folderid, $id, $part) = explode(":", $attname);
1259 1258
 
1260 1259
 		$this->splitID($folderid, $account, $folder);
1261 1260
 
1262
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1261
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1263 1262
 
1264 1263
 		$this->mail->reopen($folder);
1265
-		$attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder);
1264
+		$attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder);
1266 1265
 		$SIOattachment = new SyncItemOperationsAttachment();
1267
-		fseek($attachment['attachment'], 0, SEEK_SET);	// z-push requires stream seeked to start
1266
+		fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start
1268 1267
 		$SIOattachment->data = $attachment['attachment'];
1269 1268
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']);
1270
-		if (isset($attachment['type']) )
1269
+		if (isset($attachment['type']))
1271 1270
 			$SIOattachment->contenttype = $attachment['type'];
1272 1271
 
1273 1272
 		unset($attachment);
@@ -1310,17 +1309,17 @@  discard block
 block discarded – undo
1310 1309
 	 */
1311 1310
 	function ChangeMessage($folderid, $id, $message, $contentParameters)
1312 1311
 	{
1313
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters));
1312
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters));
1314 1313
 		//unset($folderid, $id, $message, $contentParameters);
1315 1314
 		$account = $folder = null;
1316 1315
 		$this->splitID($folderid, $account, $folder);
1317 1316
 		if (isset($message->flag)) {
1318 1317
 			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) {
1319
-				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder);
1320
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1318
+				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder);
1319
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv);
1321 1320
 			} else {
1322
-				$rv = $this->mail->flagMessages("unflagged", $id,$folder);
1323
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv);
1321
+				$rv = $this->mail->flagMessages("unflagged", $id, $folder);
1322
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv);
1324 1323
 			}
1325 1324
 		}
1326 1325
 		return $this->StatMessage($folderid, $id);
@@ -1342,23 +1341,23 @@  discard block
 block discarded – undo
1342 1341
 	 */
1343 1342
 	public function MoveMessage($folderid, $id, $newfolderid, $contentParameters)
1344 1343
 	{
1345
-		unset($contentParameters);	// not used, but required by function signature
1344
+		unset($contentParameters); // not used, but required by function signature
1346 1345
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid'  id: '$id'  dfid: '$newfolderid' )");
1347 1346
 		$account = $srcFolder = $destFolder = null;
1348 1347
 		$this->splitID($folderid, $account, $srcFolder);
1349 1348
 		$this->splitID($newfolderid, $account, $destFolder);
1350 1349
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder'  id: '$id'  DestFolder: '$destFolder' )");
1351
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1350
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1352 1351
 		$this->mail->reopen($destFolder);
1353 1352
 		$status = $this->mail->getFolderStatus($destFolder);
1354 1353
 		$uidNext = $status['uidnext'];
1355 1354
 		$this->mail->reopen($srcFolder);
1356 1355
 
1357 1356
 		// move message
1358
-		$rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true);
1359
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine
1357
+		$rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true);
1358
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine
1360 1359
 		// return the new id "as string"
1361
-		return ($rv===true ? $uidNext : $rv[$id]) . "";
1360
+		return ($rv === true ? $uidNext : $rv[$id])."";
1362 1361
 	}
1363 1362
 
1364 1363
 	/**
@@ -1366,7 +1365,7 @@  discard block
 block discarded – undo
1366 1365
 	 *
1367 1366
 	 *  @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks
1368 1367
 	 */
1369
-	public function GetMessageList($folderid, $cutoffdate=NULL)
1368
+	public function GetMessageList($folderid, $cutoffdate = NULL)
1370 1369
 	{
1371 1370
 		if ($cutoffdate > 0)
1372 1371
 		{
@@ -1374,8 +1373,8 @@  discard block
 block discarded – undo
1374 1373
 		}
1375 1374
 		else
1376 1375
 		{
1377
-			$cutoffdate = Api\DateTime::to('now','ts')-(3600*24*28*3);
1378
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutoffdate));
1376
+			$cutoffdate = Api\DateTime::to('now', 'ts') - (3600 * 24 * 28 * 3);
1377
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutoffdate));
1379 1378
 		}
1380 1379
 		return $this->fetchMessages($folderid, $cutoffdate);
1381 1380
 	}
@@ -1393,11 +1392,11 @@  discard block
 block discarded – undo
1393 1392
 	 * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject"
1394 1393
 	 * @return array uid => array StatMessage($folderid, $_id)
1395 1394
 	 */
1396
-	private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false)
1395
+	private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false)
1397 1396
 	{
1398 1397
 		static $headers = array();
1399 1398
 
1400
-		if ($this->debugLevel>1) $gstarttime = microtime (true);
1399
+		if ($this->debugLevel > 1) $gstarttime = microtime(true);
1401 1400
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
1402 1401
 		$rv_messages = array();
1403 1402
 		// if the message is still available within the class, we use it instead of fetching it again
@@ -1408,64 +1407,64 @@  discard block
 block discarded – undo
1408 1407
 		}
1409 1408
 		else
1410 1409
 		{
1411
-			$headers = array();	// clear cache to not use too much memory
1410
+			$headers = array(); // clear cache to not use too much memory
1412 1411
 
1413
-			if ($this->debugLevel>1) $starttime = microtime (true);
1412
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1414 1413
 			$this->_connect($this->account);
1415
-			if ($this->debugLevel>1)
1414
+			if ($this->debugLevel > 1)
1416 1415
 			{
1417 1416
 				$endtime = microtime(true) - $starttime;
1418
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account);
1417
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account);
1419 1418
 			}
1420 1419
 			$messagelist = $_filter = array();
1421 1420
 			// if not connected, any further action must fail
1422
-			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1423
-			if ($this->debugLevel>1) $starttime = microtime (true);
1421
+			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate));
1422
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1424 1423
 			$account = $_folderName = $id = null;
1425
-			$this->splitID($folderid,$account,$_folderName,$id);
1426
-			if ($this->debugLevel>1)
1424
+			$this->splitID($folderid, $account, $_folderName, $id);
1425
+			if ($this->debugLevel > 1)
1427 1426
 			{
1428 1427
 				$endtime = microtime(true) - $starttime;
1429
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid);
1428
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid);
1430 1429
 			}
1431
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1432
-			if ($this->debugLevel>1) $starttime = microtime (true);
1433
-			$_numberOfMessages = (empty($cutoffdate)?250:99999);
1434
-			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id);
1435
-			if ($this->debugLevel>1)
1430
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1431
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1432
+			$_numberOfMessages = (empty($cutoffdate) ? 250 : 99999);
1433
+			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id);
1434
+			if ($this->debugLevel > 1)
1436 1435
 			{
1437 1436
 				$endtime = microtime(true) - $starttime;
1438
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1437
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1439 1438
 			}
1440 1439
 		}
1441
-		if ($_id == NULL && $this->debugLevel>1)  ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1440
+		if ($_id == NULL && $this->debugLevel > 1)  ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header']));
1442 1441
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages));
1443 1442
 		$messagelist = array();
1444
-		if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist;
1443
+		if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist;
1445 1444
 		//if ($_returnModHash) $messageFolderHash = array();
1446 1445
 		foreach ((array)$rv_messages['header'] as $k => $vars)
1447 1446
 		{
1448
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1447
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1449 1448
 			$headers[$vars['uid']] = $vars;
1450
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1449
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1451 1450
 			if (!empty($vars['deleted'])) continue; // cut of deleted messages
1452 1451
 			if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it
1453
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1452
+			if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1454 1453
 			$mess = $return_all_headers ? $vars : array();
1455 1454
 			$mess["mod"] = self::doFlagsMod($vars).$vars['date'];
1456 1455
 			$mess["id"] = $vars['uid'];
1457 1456
 			// 'seen' aka 'read' is the only flag we want to know about
1458 1457
 			$mess["flags"] = 0;
1459 1458
 			// outlook supports additional flags, set them to 0
1460
-			if($vars["seen"]) $mess["flags"] = 1;
1461
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1459
+			if ($vars["seen"]) $mess["flags"] = 1;
1460
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess));
1462 1461
 			$messagelist[$vars['uid']] = $mess;
1463 1462
 			unset($mess);
1464 1463
 		}
1465
-		if ($this->debugLevel>1)
1464
+		if ($this->debugLevel > 1)
1466 1465
 		{
1467 1466
 			$endtime = microtime(true) - $gstarttime;
1468
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1467
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1469 1468
 		}
1470 1469
 		return $messagelist;
1471 1470
 	}
@@ -1516,32 +1515,32 @@  discard block
 block discarded – undo
1516 1515
 	public function getSearchResultsMailbox($_searchquery)
1517 1516
 	{
1518 1517
 		//$this->debugLevel=1;
1519
-		$searchquery=$_searchquery->GetDataArray();
1518
+		$searchquery = $_searchquery->GetDataArray();
1520 1519
 		if (!is_array($searchquery)) return array();
1521
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1520
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery));
1522 1521
 
1523 1522
 		if (isset($searchquery['searchrebuildresults'])) {
1524 1523
 			$rebuildresults = $searchquery['searchrebuildresults'];
1525 1524
 		} else {
1526 1525
 			$rebuildresults = false;
1527 1526
 		}
1528
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1527
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']');
1529 1528
 
1530 1529
 		if (isset($searchquery['deeptraversal'])) {
1531 1530
 			$deeptraversal = $searchquery['deeptraversal'];
1532 1531
 		} else {
1533 1532
 			$deeptraversal = false;
1534 1533
 		}
1535
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1534
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']');
1536 1535
 
1537 1536
 		if (isset($searchquery['searchrange'])) {
1538
-			$range = explode("-",$_searchquery->GetSearchRange());
1539
-			$start =$range[0] + 1;
1537
+			$range = explode("-", $_searchquery->GetSearchRange());
1538
+			$start = $range[0] + 1;
1540 1539
 			$limit = $range[1] - $range[0] + 1;
1541 1540
 		} else {
1542 1541
 			$range = false;
1543 1542
 		}
1544
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1543
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']');
1545 1544
 
1546 1545
 		//foreach($searchquery['query'] as $k => $value) {
1547 1546
 		//	$query = $value;
@@ -1564,15 +1563,15 @@  discard block
 block discarded – undo
1564 1563
 		}
1565 1564
 		if (!$folderid)
1566 1565
 		{
1567
-			$_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX');
1568
-			$folderid = $this->createID($account=0,$_folderName);
1566
+			$_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX');
1567
+			$folderid = $this->createID($account = 0, $_folderName);
1569 1568
 		}
1570
-		$rv = $this->splitID($folderid,$account,$_folderName,$id);
1571
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName);
1569
+		$rv = $this->splitID($folderid, $account, $_folderName, $id);
1570
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName);
1572 1571
 		$this->_connect($account);
1573 1572
 		// this should not be needed ???
1574
-		Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible)
1575
-		$_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'),
1573
+		Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible)
1574
+		$_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'),
1576 1575
 						 'string'=> $searchText,
1577 1576
 						 'status'=>'any'
1578 1577
 						);
@@ -1587,22 +1586,22 @@  discard block
 block discarded – undo
1587 1586
 		 * 		[searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE
1588 1587
 		 */
1589 1588
 			$_filter['range'] = "BETWEEN";
1590
-			list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']);
1591
-			list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']);
1592
-			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts'));
1593
-			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts'));
1589
+			list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']);
1590
+			list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']);
1591
+			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts'));
1592
+			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts'));
1594 1593
 		}
1595 1594
 		//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
1596
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1597
-		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL);
1595
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1596
+		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL);
1598 1597
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages));
1599
-		$list=array();
1598
+		$list = array();
1600 1599
 
1601 1600
 		$cnt = count($rv_messages['header']);
1602 1601
 		//$list['status'] = 1;
1603 1602
 		$list['searchtotal'] = $cnt;
1604 1603
 		$list["range"] = $_searchquery->GetSearchRange();
1605
-		foreach((array)$rv_messages['header'] as $i => $vars)
1604
+		foreach ((array)$rv_messages['header'] as $i => $vars)
1606 1605
 		{
1607 1606
 			$list[] = array(
1608 1607
 				"class" => "Email",
@@ -1622,20 +1621,20 @@  discard block
 block discarded – undo
1622 1621
 	 * @param string $folder
1623 1622
 	 * @return string
1624 1623
 	 */
1625
-	private function getParentID($account,$folder)
1624
+	private function getParentID($account, $folder)
1626 1625
 	{
1627 1626
 		$this->_connect($account);
1628
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1627
+		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false);
1629 1628
 
1630 1629
 		$mailFolder = $this->folders[$folder];
1631 1630
 		if (!isset($mailFolder)) return false;
1632
-		$delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter());
1633
-		$parent = explode($delimiter,$folder);
1631
+		$delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter());
1632
+		$parent = explode($delimiter, $folder);
1634 1633
 		array_pop($parent);
1635
-		$parent = implode($delimiter,$parent);
1634
+		$parent = implode($delimiter, $parent);
1636 1635
 
1637 1636
 		$id = $parent ? $this->createID($account, $parent) : '0';
1638
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
1637
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id");
1639 1638
 		return $id;
1640 1639
 	}
1641 1640
 
@@ -1655,48 +1654,48 @@  discard block
 block discarded – undo
1655 1654
 			$account = $folder = null;
1656 1655
 			$this->splitID($id, $account, $folder);
1657 1656
 		}
1658
-		catch(Exception $e) {
1659
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage());
1660
-			return $folderObj=false;
1657
+		catch (Exception $e) {
1658
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage());
1659
+			return $folderObj = false;
1661 1660
 		}
1662 1661
 		$this->_connect($account);
1663
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1662
+		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false);
1664 1663
 
1665 1664
 		$mailFolder = $this->folders[$folder];
1666
-		if (!isset($mailFolder)) return $folderObj=false;
1665
+		if (!isset($mailFolder)) return $folderObj = false;
1667 1666
 
1668 1667
 		$folderObj = new SyncFolder();
1669 1668
 		$folderObj->serverid = $id;
1670
-		$folderObj->parentid = $this->getParentID($account,$folder);
1669
+		$folderObj->parentid = $this->getParentID($account, $folder);
1671 1670
 		$folderObj->displayname = $mailFolder->shortDisplayName;
1672
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
1671
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
1673 1672
 		// get folder-type
1674
-		foreach($this->folders as $inbox => $mailFolder) break;
1673
+		foreach ($this->folders as $inbox => $mailFolder) break;
1675 1674
 		if ($folder == $inbox)
1676 1675
 		{
1677 1676
 			$folderObj->type = SYNC_FOLDER_TYPE_INBOX;
1678 1677
 		}
1679
-		elseif($this->mail->isDraftFolder($folder, false, true))
1678
+		elseif ($this->mail->isDraftFolder($folder, false, true))
1680 1679
 		{
1681 1680
 			//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft');
1682 1681
 			$folderObj->type = SYNC_FOLDER_TYPE_DRAFTS;
1683 1682
 			$folderObj->parentid = 0; // required by devices
1684 1683
 		}
1685
-		elseif($this->mail->isTrashFolder($folder, false, true))
1684
+		elseif ($this->mail->isTrashFolder($folder, false, true))
1686 1685
 		{
1687 1686
 			$folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET;
1688 1687
 			$this->_wasteID = $folder;
1689 1688
 			//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID);
1690 1689
 			$folderObj->parentid = 0; // required by devices
1691 1690
 		}
1692
-		elseif($this->mail->isSentFolder($folder, false, true))
1691
+		elseif ($this->mail->isSentFolder($folder, false, true))
1693 1692
 		{
1694 1693
 			$folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL;
1695 1694
 			$folderObj->parentid = 0; // required by devices
1696 1695
 			$this->_sentID = $folder;
1697 1696
 			//error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID);
1698 1697
 		}
1699
-		elseif($this->mail->isOutbox($folder, false, true))
1698
+		elseif ($this->mail->isOutbox($folder, false, true))
1700 1699
 		{
1701 1700
 			//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox');
1702 1701
 			$folderObj->type = SYNC_FOLDER_TYPE_OUTBOX;
@@ -1708,7 +1707,7 @@  discard block
 block discarded – undo
1708 1707
 			$folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL;
1709 1708
 		}
1710 1709
 
1711
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
1710
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
1712 1711
 		return $folderObj;
1713 1712
 	}
1714 1713
 
@@ -1756,18 +1755,18 @@  discard block
 block discarded – undo
1756 1755
 
1757 1756
 		if ($type != 'mail') return false;
1758 1757
 
1759
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1758
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1760 1759
 
1761 1760
         $this->mail->reopen($folder);
1762 1761
 
1763
-		if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true)))
1762
+		if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true)))
1764 1763
 		{
1765
-            ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder ");
1764
+            ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder ");
1766 1765
             return false;
1767 1766
         }
1768
-		$syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1767
+		$syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1769 1768
 
1770
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
1769
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
1771 1770
 		return array();
1772 1771
 	}
1773 1772
 
@@ -1780,8 +1779,8 @@  discard block
 block discarded – undo
1780 1779
 	function GetWasteBasket()
1781 1780
 	{
1782 1781
 		$this->_connect($this->account);
1783
-		$id = $this->createID($account=0, $this->_wasteID);
1784
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID");
1782
+		$id = $this->createID($account = 0, $this->_wasteID);
1783
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID");
1785 1784
 		return $id;
1786 1785
 	}
1787 1786
 
@@ -1802,7 +1801,7 @@  discard block
 block discarded – undo
1802 1801
      */
1803 1802
     public function DeleteMessage($folderid, $id, $contentParameters)
1804 1803
 	{
1805
-		unset($contentParameters);	// not used, but required by function signature
1804
+		unset($contentParameters); // not used, but required by function signature
1806 1805
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid'  id: '$id' )");
1807 1806
 		/*
1808 1807
 		$this->imap_reopenFolder($folderid);
@@ -1813,7 +1812,7 @@  discard block
 block discarded – undo
1813 1812
 		// we may have to split folderid
1814 1813
 		$account = $folder = null;
1815 1814
 		$this->splitID($folderid, $account, $folder);
1816
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder);
1815
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder);
1817 1816
 		$_messageUID = (array)$id;
1818 1817
 
1819 1818
 		$this->_connect($this->account);
@@ -1825,9 +1824,9 @@  discard block
 block discarded – undo
1825 1824
 		catch (Api\Exception $e)
1826 1825
 		{
1827 1826
 			$error = $e->getMessage();
1828
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1827
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1829 1828
 			// if the server thinks the message does not exist report deletion as success
1830
-			if (stripos($error,'[NONEXISTENT]')!==false) return true;
1829
+			if (stripos($error, '[NONEXISTENT]') !== false) return true;
1831 1830
 			return false;
1832 1831
 		}
1833 1832
 
@@ -1861,15 +1860,15 @@  discard block
 block discarded – undo
1861 1860
      */
1862 1861
     public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1863 1862
 	{
1864
-		unset($contentParameters);	// not used, but required by function signature
1863
+		unset($contentParameters); // not used, but required by function signature
1865 1864
 		// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid'  id: '$id'  flags: '$flags' )");
1866 1865
 		$account = $folder = null;
1867 1866
 		$this->splitID($folderid, $account, $folder);
1868 1867
 
1869 1868
 		$_messageUID = (array)$id;
1870 1869
 		$this->_connect($this->account);
1871
-		$rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder);
1872
-		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv);
1870
+		$rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder);
1871
+		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv);
1873 1872
 
1874 1873
 		return $rv;
1875 1874
 	}
@@ -1886,7 +1885,7 @@  discard block
 block discarded – undo
1886 1885
 	 */
1887 1886
 	public function ChangeFolder($id, $oldid, $displayname, $type)
1888 1887
 	{
1889
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!");
1888
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!");
1890 1889
 		return false;
1891 1890
 	}
1892 1891
 
@@ -1901,7 +1900,7 @@  discard block
 block discarded – undo
1901 1900
 	 */
1902 1901
 	public function DeleteFolder($parentid, $id)
1903 1902
 	{
1904
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$parentid', '$id') NOT supported!");
1903
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$parentid', '$id') NOT supported!");
1905 1904
 		return false;
1906 1905
 	}
1907 1906
 
@@ -1921,8 +1920,8 @@  discard block
 block discarded – undo
1921 1920
 		$this->_connect($this->account);
1922 1921
 		$account = $folder = null;
1923 1922
 		$this->splitID($folderid, $account, $folder);
1924
-		$rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder);
1925
-		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1923
+		$rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder);
1924
+		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv);
1926 1925
 
1927 1926
 		return $rv;
1928 1927
 	}
@@ -1936,17 +1935,17 @@  discard block
 block discarded – undo
1936 1935
 	 * @return string
1937 1936
 	 * @throws Api\Exception\WrongParameter
1938 1937
 	 */
1939
-	private function createID($account,$folder,$id=0)
1938
+	private function createID($account, $folder, $id = 0)
1940 1939
 	{
1941 1940
 		if (!is_numeric($folder))
1942 1941
 		{
1943 1942
 			// convert string $folder in numeric id
1944
-			$folder = $this->folder2hash($account,$f=$folder);
1943
+			$folder = $this->folder2hash($account, $f = $folder);
1945 1944
 		}
1946 1945
 
1947 1946
 		$str = $this->backend->createID($account, $folder, $id);
1948 1947
 
1949
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
1948
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
1950 1949
 
1951 1950
 		return $str;
1952 1951
 	}
@@ -1960,14 +1959,14 @@  discard block
 block discarded – undo
1960 1959
 	 * @param int &$id=null
1961 1960
 	 * @throws Api\Exception\WrongParameter
1962 1961
 	 */
1963
-	private function splitID($str,&$account,&$folder,&$id=null)
1962
+	private function splitID($str, &$account, &$folder, &$id = null)
1964 1963
 	{
1965 1964
 		$this->backend->splitID($str, $account, $folder, $id);
1966 1965
 
1967 1966
 		// convert numeric folder-id back to folder name
1968
-		$folder = $this->hash2folder($account,$f=$folder);
1967
+		$folder = $this->hash2folder($account, $f = $folder);
1969 1968
 
1970
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
1969
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$id)");
1971 1970
 	}
1972 1971
 
1973 1972
 	/**
@@ -1984,9 +1983,9 @@  discard block
 block discarded – undo
1984 1983
 	 * @param string $folder
1985 1984
 	 * @return int
1986 1985
 	 */
1987
-	private function folder2hash($account,$folder)
1986
+	private function folder2hash($account, $folder)
1988 1987
 	{
1989
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
1988
+		if (!isset($this->folderHashes)) $this->readFolderHashes();
1990 1989
 
1991 1990
 		if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false)
1992 1991
 		{
@@ -2007,9 +2006,9 @@  discard block
 block discarded – undo
2007 2006
 	 * @param int $index
2008 2007
 	 * @return string NULL if not used so far
2009 2008
 	 */
2010
-	private function hash2folder($account,$index)
2009
+	private function hash2folder($account, $index)
2011 2010
 	{
2012
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2011
+		if (!isset($this->folderHashes)) $this->readFolderHashes();
2013 2012
 
2014 2013
 		return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null;
2015 2014
 	}
@@ -2046,9 +2045,9 @@  discard block
 block discarded – undo
2046 2045
 			if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) &&
2047 2046
 				($hashes = file_get_contents($file)))
2048 2047
 			{
2049
-				$this->folderHashes = json_decode($hashes,true);
2048
+				$this->folderHashes = json_decode($hashes, true);
2050 2049
 				// fallback in case hashes have been serialized instead of being json-encoded
2051
-				if (json_last_error()!=JSON_ERROR_NONE)
2050
+				if (json_last_error() != JSON_ERROR_NONE)
2052 2051
 				{
2053 2052
 					//error_log(__METHOD__.__LINE__." error decoding with json");
2054 2053
 					$this->folderHashes = unserialize($hashes);
@@ -2094,9 +2093,9 @@  discard block
 block discarded – undo
2094 2093
 	 * @param boolean $old =false true: return old / pre-15 hash-file
2095 2094
 	 * @throws Api\Exception\AssertionFailed
2096 2095
 	 */
2097
-	private function hashFile($old=false)
2096
+	private function hashFile($old = false)
2098 2097
 	{
2099
-		if (!($dev_id=Request::GetDeviceID()))
2098
+		if (!($dev_id = Request::GetDeviceID()))
2100 2099
 		{
2101 2100
 			throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!");
2102 2101
 		}
Please login to merge, or discard this patch.
Braces   +589 added lines, -173 removed lines patch added patch discarded remove patch
@@ -81,29 +81,47 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function __construct(activesync_backend $backend)
83 83
 	{
84
-		if ($GLOBALS['egw_setup']) return;
84
+		if ($GLOBALS['egw_setup'])
85
+		{
86
+			return;
87
+		}
85 88
 
86 89
 		//$this->debugLevel=2;
87 90
 		$this->backend = $backend;
88 91
 		if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
89 92
 		{
90
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
93
+			if ($this->debugLevel>1)
94
+			{
95
+				error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default');
96
+			}
91 97
 			// globals preferences add appname varname value
92 98
 			$GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user');
93 99
 			// save prefs
94 100
 			$GLOBALS['egw']->preferences->save_repository(true);
95 101
 		}
96
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
102
+		if ($this->debugLevel>1)
103
+		{
104
+			error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID));
105
+		}
97 106
 
98 107
 		if (is_null(self::$profileID))
99 108
 		{
100
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
109
+			if ($this->debugLevel>1)
110
+			{
111
+				error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
112
+			}
101 113
 			self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID');
102
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
114
+			if ($this->debugLevel>1)
115
+			{
116
+				error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
117
+			}
103 118
 		}
104 119
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
105 120
 		{
106
-			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
121
+			if ($this->debugLevel>1)
122
+			{
123
+				error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']));
124
+			}
107 125
 			if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G')
108 126
 			{
109 127
 				self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is)
@@ -113,7 +131,10 @@  discard block
 block discarded – undo
113 131
 				self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'];
114 132
 			}
115 133
 		}
116
-		if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
134
+		if ($this->debugLevel>1)
135
+		{
136
+			error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID));
137
+		}
117 138
 
118 139
 		// verify we are on an existing profile, if not running in setup (settings can not be static according to interface!)
119 140
 		if (!isset($GLOBALS['egw_setup']))
@@ -126,7 +147,10 @@  discard block
 block discarded – undo
126 147
 				self::$profileID = Mail\Account::get_default_acc_id();
127 148
 			}
128 149
 		}
129
-		if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
150
+		if ($this->debugLevel>0)
151
+		{
152
+			error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID);
153
+		}
130 154
 		//$this->debugLevel=0;
131 155
 	}
132 156
 
@@ -233,8 +257,14 @@  discard block
 block discarded – undo
233 257
 				$this->_connect(0,true);
234 258
 				$this->_disconnect();
235 259
 
236
-				if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>');
237
-				if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>');
260
+				if (!$this->_wasteID)
261
+				{
262
+					$errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>');
263
+				}
264
+				if (!$this->_sentID)
265
+				{
266
+					$errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>');
267
+				}
238 268
 			}
239 269
 			catch(Exception $e) {
240 270
 				$errors[] = lang('Can not open IMAP connection').': '.$e->getMessage();
@@ -256,8 +286,14 @@  discard block
 block discarded – undo
256 286
 	 */
257 287
 	private function _connect($account=0)
258 288
 	{
259
-		if (!$account) $account = self::$profileID ? self::$profileID : 0;
260
-		if ($this->mail && $this->account != $account) $this->_disconnect();
289
+		if (!$account)
290
+		{
291
+			$account = self::$profileID ? self::$profileID : 0;
292
+		}
293
+		if ($this->mail && $this->account != $account)
294
+		{
295
+			$this->_disconnect();
296
+		}
261 297
 
262 298
 		$this->_wasteID = false;
263 299
 		$this->_sentID = false;
@@ -268,12 +304,18 @@  discard block
 block discarded – undo
268 304
 			// todo: tell mail which account to use
269 305
 			//error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID));
270 306
 			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
271
-			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
307
+			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId))
308
+			{
309
+				self::$profileID = $this->mail->icServer->ImapServerId;
310
+			}
272 311
 		}
273 312
 		else
274 313
 		{
275 314
 			//error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID);
276
-			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId;
315
+			if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId))
316
+			{
317
+				self::$profileID = $this->mail->icServer->ImapServerId;
318
+			}
277 319
 		}
278 320
 		$this->mail->openConnection(self::$profileID,false);
279 321
 
@@ -290,8 +332,14 @@  discard block
 block discarded – undo
290 332
 	 */
291 333
 	private function _disconnect()
292 334
 	{
293
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__);
294
-		if ($this->mail) $this->mail->closeConnection();
335
+		if ($this->debugLevel>0)
336
+		{
337
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__);
338
+		}
339
+		if ($this->mail)
340
+		{
341
+			$this->mail->closeConnection();
342
+		}
295 343
 
296 344
 		unset($this->mail);
297 345
 		unset($this->account);
@@ -306,24 +354,43 @@  discard block
 block discarded – undo
306 354
 	public function GetFolderList()
307 355
 	{
308 356
 		$folderlist = array();
309
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
357
+		if ($this->debugLevel>0)
358
+		{
359
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
360
+		}
310 361
 		/*foreach($available_accounts as $account)*/ $account = 0;
311 362
 		{
312 363
 			$this->_connect($account);
313
-			if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true);
314
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders));
364
+			if (!isset($this->folders))
365
+			{
366
+				$this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true);
367
+			}
368
+			if ($this->debugLevel>1)
369
+			{
370
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders));
371
+			}
315 372
 
316
-			foreach ($this->folders as $folder => $folderObj) {
317
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder);
373
+			foreach ($this->folders as $folder => $folderObj)
374
+			{
375
+				if ($this->debugLevel>1)
376
+				{
377
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder);
378
+				}
318 379
 				$folderlist[] = $f = array(
319 380
 					'id'     => $this->createID($account,$folder),
320 381
 					'mod'    => $folderObj->shortDisplayName,
321 382
 					'parent' => $this->getParentID($account,$folder),
322 383
 				);
323
-				if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f));
384
+				if ($this->debugLevel>1)
385
+				{
386
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f));
387
+				}
324 388
 			}
325 389
 		}
326
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist));
390
+		if ($this->debugLevel>0)
391
+		{
392
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist));
393
+		}
327 394
 
328 395
 		return $folderlist;
329 396
 	}
@@ -384,11 +451,17 @@  discard block
 block discarded – undo
384 451
 		$smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new'));
385 452
 
386 453
    		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : ""));
387
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
454
+		if ($this->debugLevel>0)
455
+		{
456
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata));
457
+		}
388 458
 		//error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata));
389 459
 
390 460
 		// initialize our Mail
391
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
461
+		if (!isset($this->mail))
462
+		{
463
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
464
+		}
392 465
 		$activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID);
393 466
 		// use the standardIdentity
394 467
 		$activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID);
@@ -408,22 +481,34 @@  discard block
 block discarded – undo
408 481
 		// prepare addressee list; moved the adding of addresses to the mailobject down
409 482
 		// to
410 483
 
411
-		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
412
-			if (!$addressObject->valid) continue;
484
+		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject)
485
+		{
486
+			if (!$addressObject->valid)
487
+			{
488
+				continue;
489
+			}
413 490
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) );
414 491
 			//$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
415 492
 			$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
416 493
 		}
417 494
 		// CC
418
-		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
419
-			if (!$addressObject->valid) continue;
495
+		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject)
496
+		{
497
+			if (!$addressObject->valid)
498
+			{
499
+				continue;
500
+			}
420 501
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) );
421 502
 			//$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
422 503
 			$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
423 504
 		}
424 505
 		// BCC
425
-		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
426
-			if (!$addressObject->valid) continue;
506
+		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject)
507
+		{
508
+			if (!$addressObject->valid)
509
+			{
510
+				continue;
511
+			}
427 512
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) );
428 513
 			//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
429 514
 			$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
@@ -436,12 +521,14 @@  discard block
 block discarded – undo
436 521
 		$ContentType =$mailObject->getHeader('Content-Type');
437 522
 		//error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k.  " = ".trim($ContentType));
438 523
 		// if the message is a multipart message, then we should use the sent body
439
-		if (preg_match("/multipart/i", $ContentType)) {
524
+		if (preg_match("/multipart/i", $ContentType))
525
+		{
440 526
 			$use_orgbody = true;
441 527
 		}
442 528
 
443 529
 		// save the original content-type header for the body part when forwarding
444
-		if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) {
530
+		if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody)
531
+		{
445 532
 			//continue; // ignore
446 533
 		}
447 534
 		// horde/egw_ mailer does everything as utf-8, the following should not be needed
@@ -450,7 +537,8 @@  discard block
 block discarded – undo
450 537
 		// if the message is a multipart message, then we should use the sent body
451 538
 		if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') &&
452 539
 			((isset($smartdata->replacemime) && $smartdata->replacemime == true) ||
453
-			$k == "Content-Type" && preg_match("/multipart/i", $ContentType))) {
540
+			$k == "Content-Type" && preg_match("/multipart/i", $ContentType)))
541
+		{
454 542
 			$use_orgbody = true;
455 543
 		}
456 544
 		$Body =  $AltBody = "";
@@ -483,12 +571,19 @@  discard block
 block discarded – undo
483 571
 			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
484 572
 				($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null);
485 573
 		}
486
-		if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
487
-		if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
574
+		if ($this->debugLevel>1 && $Body)
575
+		{
576
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
577
+		}
578
+		if ($this->debugLevel>1 && $AltBody)
579
+		{
580
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
581
+		}
488 582
 		//error_log(__METHOD__.__LINE__.array2string($mailObject));
489 583
 		// if this is a multipart message with a boundary, we must use the original body
490 584
 		//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject));
491
-        if ($use_orgbody) {
585
+        if ($use_orgbody)
586
+        {
492 587
     	    ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
493 588
  			// if it is a ClientSideMeetingRequest, we report it as send at all times
494 589
 			if (($cal_body = $mailObject->findBody('calendar')) &&
@@ -498,15 +593,20 @@  discard block
 block discarded – undo
498 593
 				{
499 594
 					$organizer = calendar_ical::getIcalOrganizer($cal_body->getContents());
500 595
 				}
501
-				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
596
+				if ($this->debugLevel)
597
+				{
598
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
599
+				}
502 600
 				$ClientSideMeetingRequest = true;
503 601
 			}
504 602
         }
505 603
 		// now handle the addressee list
506 604
 		$toCount = 0;
507 605
 		//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
508
-		foreach((array)$toMailAddr as $address) {
509
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
606
+		foreach((array)$toMailAddr as $address)
607
+		{
608
+			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
609
+			{
510 610
 				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
511 611
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' &&
512 612
 					calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST',
@@ -520,19 +620,29 @@  discard block
 block discarded – undo
520 620
 			}
521 621
 		}
522 622
 		$ccCount = 0;
523
-		foreach((array)$ccMailAddr as $address) {
524
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
623
+		foreach((array)$ccMailAddr as $address)
624
+		{
625
+			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
626
+			{
525 627
 				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
526
-				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
628
+				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress))
629
+				{
630
+					continue;
631
+				}
527 632
 				$mailObject->AddCC($emailAddress, $addressObject->personal);
528 633
 				$ccCount++;
529 634
 			}
530 635
 		}
531 636
 		$bccCount = 0;
532
-		foreach((array)$bccMailAddr as $address) {
533
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
637
+		foreach((array)$bccMailAddr as $address)
638
+		{
639
+			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
640
+			{
534 641
 				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
535
-				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
642
+				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress))
643
+				{
644
+					continue;
645
+				}
536 646
 				$mailObject->AddBCC($emailAddress, $addressObject->personal);
537 647
 				$bccCount++;
538 648
 			}
@@ -542,7 +652,10 @@  discard block
 block discarded – undo
542 652
 		{
543 653
 			return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to
544 654
 		}
545
-		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true;
655
+		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false)
656
+		{
657
+			return true;
658
+		}
546 659
 		// as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail
547 660
 /*
548 661
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body);
@@ -572,7 +685,10 @@  discard block
 block discarded – undo
572 685
 		$beforeHtml = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
573 686
 		$beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
574 687
 		$sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
575
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
688
+		if ($this->debugLevel>0)
689
+		{
690
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
691
+		}
576 692
 		$sigTextHtml = $beforeHtml.$sigText;
577 693
 		$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText);
578 694
 		$isreply = $isforward = false;
@@ -590,10 +706,17 @@  discard block
 block discarded – undo
590 706
 			$this->mail->reopen($folder);
591 707
 			$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
592 708
 			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
593
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
594
-		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
709
+			if ($this->debugLevel>3)
710
+			{
711
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
712
+			}
713
+		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html'))
714
+		    {
595 715
 				// may be html
596
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
716
+				if ($this->debugLevel>0)
717
+				{
718
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
719
+				}
597 720
 				$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
598 721
 				$isreply = true;
599 722
 			}
@@ -602,8 +725,12 @@  discard block
 block discarded – undo
602 725
 			// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
603 726
 			$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
604 727
 			$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
605
-			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
606
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
728
+			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain'))
729
+			{
730
+				if ($this->debugLevel>0)
731
+				{
732
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
733
+				}
607 734
 				$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
608 735
 				$isreply = true;
609 736
 			}
@@ -611,7 +738,10 @@  discard block
 block discarded – undo
611 738
 			{
612 739
 				$isreply = true;
613 740
 				$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
614
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
741
+				if ($this->debugLevel>0)
742
+				{
743
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
744
+				}
615 745
 			}
616 746
 		}
617 747
 
@@ -625,11 +755,17 @@  discard block
 block discarded – undo
625 755
 			(isset($smartdata->replacemime) && $smartdata->replacemime == false)))
626 756
 		{
627 757
 			//force the default for the forwarding -> asmail
628
-			if (is_array($preferencesArray)) {
758
+			if (is_array($preferencesArray))
759
+			{
629 760
 				if (!array_key_exists('message_forwarding',$preferencesArray)
630 761
 					|| !isset($preferencesArray['message_forwarding'])
631
-					|| empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail';
632
-			} else {
762
+					|| empty($preferencesArray['message_forwarding']))
763
+				{
764
+					$preferencesArray['message_forwarding'] = 'asmail';
765
+				}
766
+			}
767
+			else
768
+			{
633 769
 				$preferencesArray['message_forwarding'] = 'asmail';
634 770
 			}
635 771
 			// construct the uid of the message out of the itemid - seems to be the uid, no construction needed
@@ -661,27 +797,44 @@  discard block
 block discarded – undo
661 797
 				$this->mail->reopen($folder);
662 798
 				$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
663 799
 				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
664
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
665
-				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
800
+				if ($this->debugLevel>0)
801
+				{
802
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
803
+				}
804
+				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html'))
805
+				{
666 806
 					// may be html
667
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
807
+					if ($this->debugLevel>0)
808
+					{
809
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
810
+					}
668 811
 					$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
669 812
 					$isforward = true;
670 813
 				}
671 814
 				// plain text Message part
672
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
815
+				if ($this->debugLevel>0)
816
+				{
817
+					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
818
+				}
673 819
 				// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
674 820
 				$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
675 821
 				$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
676
-				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
677
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
822
+				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain'))
823
+				{
824
+					if ($this->debugLevel>0)
825
+					{
826
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
827
+					}
678 828
 					$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
679 829
 					$isforward = true;
680 830
 				}
681 831
 				if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody))
682 832
 				{
683 833
 					$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
684
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
834
+					if ($this->debugLevel>0)
835
+					{
836
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
837
+					}
685 838
 					$isforward = true;
686 839
 				}
687 840
 				// get all the attachments and add them too.
@@ -694,7 +847,10 @@  discard block
 block discarded – undo
694 847
 					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
695 848
 					foreach((array)$attachments as $key => $attachment)
696 849
 					{
697
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
850
+						if ($this->debugLevel>0)
851
+						{
852
+							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
853
+						}
698 854
 						$attachmentNames .= $attachment['name']."\n";
699 855
 						$attachmentData	= $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder);
700 856
 						/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']);
@@ -712,18 +868,27 @@  discard block
 block discarded – undo
712 868
 		// now set the body
713 869
 		if ($AltBody && ($html_body = $mailObject->findBody('html')))
714 870
 		{
715
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
871
+			if ($this->debugLevel>1)
872
+			{
873
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
874
+			}
716 875
 			$html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
717 876
 		}
718 877
 		if ($Body && ($text_body = $mailObject->findBody('plain')))
719 878
 		{
720
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
879
+			if ($this->debugLevel>1)
880
+			{
881
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
882
+			}
721 883
 			$text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
722 884
 		}
723 885
 		//advanced debugging
724 886
 		// Horde SMTP Class uses utf-8 by default.
725 887
         //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
726
-		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
888
+		if ($this->debugLevel>2)
889
+		{
890
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
891
+		}
727 892
 
728 893
 		// set a higher timeout for big messages
729 894
 		@set_time_limit(120);
@@ -750,7 +915,9 @@  discard block
 block discarded – undo
750 915
 			if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder))
751 916
 			{
752 917
 				$this->mail->deleteMessages(array($uid),$folder);
753
-			} else {
918
+			}
919
+			else
920
+			{
754 921
 				$this->mail->flagMessages("answered", array($uid),$folder);
755 922
 				if ($smartdata_task== "forward")
756 923
 				{
@@ -764,7 +931,8 @@  discard block
 block discarded – undo
764 931
 		{
765 932
 			$asf = false;
766 933
 			$sentFolder = $this->mail->getSentFolder();
767
-			if ($this->_sentID) {
934
+			if ($this->_sentID)
935
+			{
768 936
 				$folderArray[] = $this->_sentID;
769 937
 			}
770 938
 			else if(isset($sentFolder) && $sentFolder != 'none')
@@ -778,27 +946,40 @@  discard block
 block discarded – undo
778 946
 				// we dont try guessing
779 947
 				$asf = true;
780 948
 			}
781
-			if (count($folderArray) > 0) {
782
-				foreach((array)$bccMailAddr as $address) {
783
-					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
949
+			if (count($folderArray) > 0)
950
+			{
951
+				foreach((array)$bccMailAddr as $address)
952
+				{
953
+					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject)
954
+					{
784 955
 						$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
785 956
 						$mailAddr[] = array($emailAddress, $addressObject->personal);
786 957
 					}
787 958
 				}
788 959
 				$BCCmail='';
789
-				if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
790
-				foreach($folderArray as $folderName) {
791
-					if($this->mail->isSentFolder($folderName)) {
960
+				if (count($mailAddr)>0)
961
+				{
962
+					$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
963
+				}
964
+				foreach($folderArray as $folderName)
965
+				{
966
+					if($this->mail->isSentFolder($folderName))
967
+					{
792 968
 						$flags = '\\Seen';
793
-					} elseif($this->mail->isDraftFolder($folderName)) {
969
+					}
970
+					elseif($this->mail->isDraftFolder($folderName))
971
+					{
794 972
 						$flags = '\\Draft';
795
-					} else {
973
+					}
974
+					else
975
+					{
796 976
 						$flags = '';
797 977
 					}
798 978
 					$asf = true;
799 979
 					//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer));
800 980
 					$this->mail->openConnection(self::$profileID,false);
801
-					if ($this->mail->folderExists($folderName)) {
981
+					if ($this->mail->folderExists($folderName))
982
+					{
802 983
 						try
803 984
 						{
804 985
 							$this->mail->appendMessage($folderName,$mailObject->getRaw(), null,
@@ -856,17 +1037,26 @@  discard block
 block discarded – undo
856 1037
 		$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */
857 1038
 
858 1039
 		// fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0
859
-		if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]);
1040
+		if (!$mimesupport && ($key = array_search('4', $bodypreference)))
1041
+		{
1042
+			unset($bodypreference[$key]);
1043
+		}
860 1044
 
861 1045
 		//$this->debugLevel=4;
862
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1046
+		if (!isset($this->mail))
1047
+		{
1048
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1049
+		}
863 1050
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
864 1051
 		$account = $_folderName = $xid = null;
865 1052
 		$this->splitID($folderid,$account,$_folderName,$xid);
866 1053
 		$this->mail->reopen($_folderName);
867 1054
 		$messages = $this->fetchMessages($folderid, NULL, $id, true);	// true: return all headers
868 1055
 		$headers = $messages[$id];
869
-		if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
1056
+		if ($this->debugLevel>3)
1057
+		{
1058
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
1059
+		}
870 1060
 		// StatMessage should reopen the folder in question, so we dont need folderids in the following statements.
871 1061
 		if ($headers)
872 1062
 		{
@@ -876,16 +1066,25 @@  discard block
 block discarded – undo
876 1066
 			//$rawHeaders = $this->mail->getMessageRawHeader($id);
877 1067
 			// simple style
878 1068
 			// start AS12 Stuff (bodypreference === false) case = old behaviour
879
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
1069
+			if ($this->debugLevel>0)
1070
+			{
1071
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
1072
+			}
880 1073
 
881
-			if ($bodypreference === false) {
1074
+			if ($bodypreference === false)
1075
+			{
882 1076
 				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
883 1077
 				$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
884 1078
 				//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
885
-				if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
1079
+				if (stripos($raw_body,'<style')!==false)
1080
+				{
1081
+					$body = preg_replace("/<style.*?<\/style>/is", "", $raw_body);
1082
+				}
1083
+				// in case there is only a html part
886 1084
 				// remove all other html
887 1085
 				$body = strip_tags($raw_body);
888
-				if(strlen($body) > $truncsize) {
1086
+				if(strlen($body) > $truncsize)
1087
+				{
889 1088
 					$body = Utils::Utf8_truncate($body, $truncsize);
890 1089
 					$output->bodytruncated = 1;
891 1090
 				}
@@ -900,7 +1099,8 @@  discard block
 block discarded – undo
900 1099
 			{
901 1100
 				//Select body type preference
902 1101
 				$bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN;
903
-				if ($bodypreference !== false) {
1102
+				if ($bodypreference !== false)
1103
+				{
904 1104
 					// bodypreference can occur multiple times
905 1105
 					// usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference);
906 1106
 					$bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference);
@@ -934,25 +1134,49 @@  discard block
 block discarded – undo
934 1134
 					// fetch the body (try to gather data only once)
935 1135
 					$css ='';
936 1136
 					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
937
-					if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
1137
+					if ($this->debugLevel>2)
1138
+					{
1139
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
1140
+					}
938 1141
 					$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
939
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
940
-					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
1142
+					if ($this->debugLevel>3)
1143
+					{
1144
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
1145
+					}
1146
+					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html'))
1147
+					{
941 1148
 						// may be html
942
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
1149
+						if ($this->debugLevel>0)
1150
+						{
1151
+							ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
1152
+						}
943 1153
 						$css = $this->mail->getStyles($bodyStruct);
944 1154
 						$output->nativebodytype=2;
945
-					} else {
1155
+					}
1156
+					else
1157
+					{
946 1158
 						// plain text Message
947
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
1159
+						if ($this->debugLevel>0)
1160
+						{
1161
+							ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
1162
+						}
948 1163
 						$output->nativebodytype=1;
949 1164
 						$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
950
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
1165
+						if ($this->debugLevel>3)
1166
+						{
1167
+							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
1168
+						}
951 1169
 						$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
952
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
1170
+						if ($this->debugLevel>3)
1171
+						{
1172
+							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
1173
+						}
953 1174
 					}
954 1175
 					// whatever format decode (using the correct encoding)
955
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
1176
+					if ($this->debugLevel>3)
1177
+					{
1178
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
1179
+					}
956 1180
 					//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
957 1181
 					// prepare plaintextbody
958 1182
 					$plainBody='';
@@ -973,12 +1197,18 @@  discard block
 block discarded – undo
973 1197
 					// remove all other html
974 1198
 					$plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody);
975 1199
 					$plainBody = strip_tags($plainBody);
976
-					if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
1200
+					if ($this->debugLevel>3 && $output->nativebodytype==1)
1201
+					{
1202
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
1203
+					}
977 1204
 					//$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that?
978 1205
 
979
-					if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML
1206
+					if ($bpReturnType==2)
1207
+					{
1208
+						//SYNC_BODYPREFERENCE_HTML
980 1209
 					{
981 1210
 						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
1211
+					}
982 1212
 						// Send HTML if requested and native type was html
983 1213
 						$output->asbody->type = 2;
984 1214
 						$htmlbody = '<html>'.
@@ -990,7 +1220,10 @@  discard block
 block discarded – undo
990 1220
 							'<body>';
991 1221
 						if ($output->nativebodytype==2)
992 1222
 						{
993
-							if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style');
1223
+							if ($css)
1224
+							{
1225
+								Api\Mail\Html::replaceTagsCompletley($body,'style');
1226
+							}
994 1227
 							// as we fetch html, and body is HTML, we may not need to handle this
995 1228
 							$htmlbody .= $body;
996 1229
 						}
@@ -1015,7 +1248,10 @@  discard block
 block discarded – undo
1015 1248
 					else
1016 1249
 					{
1017 1250
 						// Send Plaintext as Fallback or if original body is plainttext
1018
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1251
+						if ($this->debugLevel>0)
1252
+						{
1253
+							ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1254
+						}
1019 1255
 						/* we use plainBody (set above) instead
1020 1256
 						$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
1021 1257
 						$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
@@ -1052,7 +1288,9 @@  discard block
 block discarded – undo
1052 1288
 			{
1053 1289
 				$output->flag->flagstatus = 2;
1054 1290
 				//$output->flag->flagtype = "Flag for Follow up";
1055
-			} else {
1291
+			}
1292
+			else
1293
+			{
1056 1294
 				$output->flag->flagstatus = 0;
1057 1295
 			}
1058 1296
 			if ($headers['answered'])
@@ -1068,10 +1306,20 @@  discard block
 block discarded – undo
1068 1306
 				($headers['priority'] < 3 ? 2 : 1) ;
1069 1307
 			$output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true);
1070 1308
 			$output->to = $headers['to_address'];
1071
-			if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name']
1309
+			if ($headers['to'])
1310
+			{
1311
+				$output->displayto = $headers['to_address'];
1312
+			}
1313
+			//$headers['FETCHED_HEADER']['to_name']
1072 1314
 			$output->from = $headers['sender_address'];
1073
-			if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses'];
1074
-			if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address'];
1315
+			if (isset($headers['cc_addresses']) && $headers['cc_addresses'])
1316
+			{
1317
+				$output->cc = $headers['cc_addresses'];
1318
+			}
1319
+			if (isset($headers['reply_to_address']) && $headers['reply_to_address'])
1320
+			{
1321
+				$output->reply_to = $headers['reply_to_address'];
1322
+			}
1075 1323
 
1076 1324
 			$output->messageclass = "IPM.Note";
1077 1325
 			if (stripos($headers['mimetype'],'multipart')!== false &&
@@ -1079,7 +1327,8 @@  discard block
 block discarded – undo
1079 1327
 			{
1080 1328
 				$output->messageclass = "IPM.Note.SMIME.MultipartSigned";
1081 1329
 			}
1082
-			if (Request::GetProtocolVersion() >= 12.0) {
1330
+			if (Request::GetProtocolVersion() >= 12.0)
1331
+			{
1083 1332
 				$output->contentclass = "urn:content-classes:message";
1084 1333
 			}
1085 1334
 
@@ -1092,7 +1341,10 @@  discard block
 block discarded – undo
1092 1341
 				//error_log(__METHOD__.__LINE__.array2string($attachments));
1093 1342
 				foreach ($attachments as $key => $attach)
1094 1343
 				{
1095
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1344
+					if ($this->debugLevel>0)
1345
+					{
1346
+						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1347
+					}
1096 1348
 
1097 1349
 					// pass meeting requests to calendar plugin
1098 1350
 					if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
@@ -1109,17 +1361,24 @@  discard block
 block discarded – undo
1109 1361
 						unset($attachment);
1110 1362
 						continue;	// do NOT add attachment as attachment
1111 1363
 					}
1112
-					if (Request::GetProtocolVersion() >= 12.0) {
1364
+					if (Request::GetProtocolVersion() >= 12.0)
1365
+					{
1113 1366
 						$attachment = new SyncBaseAttachment();
1114 1367
 						if (!isset($output->asattachments) || !is_array($output->asattachments))
1115
-							$output->asattachments = array();
1368
+						{
1369
+													$output->asattachments = array();
1370
+						}
1116 1371
 						$attachment->estimatedDataSize = $attach['size'];
1117 1372
 						$attachment->method = 1;
1118 1373
 						$attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID'];
1119
-					} else {
1374
+					}
1375
+					else
1376
+					{
1120 1377
 						$attachment = new SyncAttachment();
1121 1378
 						if (!isset($output->attachments) || !is_array($output->attachments))
1122
-							$output->attachments = array();
1379
+						{
1380
+													$output->attachments = array();
1381
+						}
1123 1382
 						$attachment->attsize = $attach['size'];
1124 1383
 						$attachment->attmethod = 1;
1125 1384
 						$attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key;
@@ -1136,10 +1395,13 @@  discard block
 block discarded – undo
1136 1395
 						{
1137 1396
 							$attachment->isinline = true;
1138 1397
 						}
1139
-						if (Request::GetProtocolVersion() >= 12.0) {
1398
+						if (Request::GetProtocolVersion() >= 12.0)
1399
+						{
1140 1400
 							$attachment->method=1;
1141 1401
 							$attachment->contentid= str_replace(array("<",">"), "",$attach['cid']);
1142
-						} else {
1402
+						}
1403
+						else
1404
+						{
1143 1405
 							$attachment->attmethod=6;
1144 1406
 							$attachment->attoid = str_replace(array("<",">"), "",$attach['cid']);
1145 1407
 						}
@@ -1147,9 +1409,12 @@  discard block
 block discarded – undo
1147 1409
 						$attachment->contenttype = trim($attach['mimeType']);
1148 1410
 						//	ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-type']."'  ".$attachment->contentid);
1149 1411
 					}
1150
-					if (Request::GetProtocolVersion() >= 12.0) {
1412
+					if (Request::GetProtocolVersion() >= 12.0)
1413
+					{
1151 1414
 						array_push($output->asattachments, $attachment);
1152
-					} else {
1415
+					}
1416
+					else
1417
+					{
1153 1418
 						array_push($output->attachments, $attachment);
1154 1419
 					}
1155 1420
 					unset($attachment);
@@ -1162,8 +1427,11 @@  discard block
 block discarded – undo
1162 1427
             // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1163 1428
             $output->internetcpid = INTERNET_CPID_UTF8;
1164 1429
 
1165
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1166
-//$this->debugLevel=0;
1430
+			if ($this->debugLevel>3)
1431
+			{
1432
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1433
+			}
1434
+			//$this->debugLevel=0;
1167 1435
 			return $output;
1168 1436
 		}
1169 1437
 //$this->debugLevel=0;
@@ -1222,7 +1490,8 @@  discard block
 block discarded – undo
1222 1490
      * @param string $attname - should contain (folder)id
1223 1491
 	 * @return SyncItemOperationsAttachment-object
1224 1492
 	 */
1225
-	function GetAttachmentData($fid,$attname) {
1493
+	function GetAttachmentData($fid,$attname)
1494
+	{
1226 1495
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1227 1496
 		return $this->_GetAttachmentData($fid,$attname);
1228 1497
 	}
@@ -1237,7 +1506,8 @@  discard block
 block discarded – undo
1237 1506
      * @param string $attname - should contain (folder)id
1238 1507
 	 * @return SyncItemOperationsAttachment-object
1239 1508
 	 */
1240
-	function ItemOperationsGetAttachmentData($fid,$attname) {
1509
+	function ItemOperationsGetAttachmentData($fid,$attname)
1510
+	{
1241 1511
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1242 1512
 		return $this->_GetAttachmentData($fid,$attname);
1243 1513
 	}
@@ -1259,7 +1529,10 @@  discard block
 block discarded – undo
1259 1529
 
1260 1530
 		$this->splitID($folderid, $account, $folder);
1261 1531
 
1262
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1532
+		if (!isset($this->mail))
1533
+		{
1534
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1535
+		}
1263 1536
 
1264 1537
 		$this->mail->reopen($folder);
1265 1538
 		$attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder);
@@ -1268,7 +1541,9 @@  discard block
 block discarded – undo
1268 1541
 		$SIOattachment->data = $attachment['attachment'];
1269 1542
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']);
1270 1543
 		if (isset($attachment['type']) )
1271
-			$SIOattachment->contenttype = $attachment['type'];
1544
+		{
1545
+					$SIOattachment->contenttype = $attachment['type'];
1546
+		}
1272 1547
 
1273 1548
 		unset($attachment);
1274 1549
 
@@ -1314,11 +1589,15 @@  discard block
 block discarded – undo
1314 1589
 		//unset($folderid, $id, $message, $contentParameters);
1315 1590
 		$account = $folder = null;
1316 1591
 		$this->splitID($folderid, $account, $folder);
1317
-		if (isset($message->flag)) {
1318
-			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) {
1592
+		if (isset($message->flag))
1593
+		{
1594
+			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2)
1595
+			{
1319 1596
 				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder);
1320 1597
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1321
-			} else {
1598
+			}
1599
+			else
1600
+			{
1322 1601
 				$rv = $this->mail->flagMessages("unflagged", $id,$folder);
1323 1602
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv);
1324 1603
 			}
@@ -1348,7 +1627,10 @@  discard block
 block discarded – undo
1348 1627
 		$this->splitID($folderid, $account, $srcFolder);
1349 1628
 		$this->splitID($newfolderid, $account, $destFolder);
1350 1629
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder'  id: '$id'  DestFolder: '$destFolder' )");
1351
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1630
+		if (!isset($this->mail))
1631
+		{
1632
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1633
+		}
1352 1634
 		$this->mail->reopen($destFolder);
1353 1635
 		$status = $this->mail->getFolderStatus($destFolder);
1354 1636
 		$uidNext = $status['uidnext'];
@@ -1397,7 +1679,10 @@  discard block
 block discarded – undo
1397 1679
 	{
1398 1680
 		static $headers = array();
1399 1681
 
1400
-		if ($this->debugLevel>1) $gstarttime = microtime (true);
1682
+		if ($this->debugLevel>1)
1683
+		{
1684
+			$gstarttime = microtime (true);
1685
+		}
1401 1686
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
1402 1687
 		$rv_messages = array();
1403 1688
 		// if the message is still available within the class, we use it instead of fetching it again
@@ -1410,7 +1695,10 @@  discard block
 block discarded – undo
1410 1695
 		{
1411 1696
 			$headers = array();	// clear cache to not use too much memory
1412 1697
 
1413
-			if ($this->debugLevel>1) $starttime = microtime (true);
1698
+			if ($this->debugLevel>1)
1699
+			{
1700
+				$starttime = microtime (true);
1701
+			}
1414 1702
 			$this->_connect($this->account);
1415 1703
 			if ($this->debugLevel>1)
1416 1704
 			{
@@ -1419,8 +1707,14 @@  discard block
 block discarded – undo
1419 1707
 			}
1420 1708
 			$messagelist = $_filter = array();
1421 1709
 			// if not connected, any further action must fail
1422
-			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1423
-			if ($this->debugLevel>1) $starttime = microtime (true);
1710
+			if (!empty($cutoffdate))
1711
+			{
1712
+				$_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1713
+			}
1714
+			if ($this->debugLevel>1)
1715
+			{
1716
+				$starttime = microtime (true);
1717
+			}
1424 1718
 			$account = $_folderName = $id = null;
1425 1719
 			$this->splitID($folderid,$account,$_folderName,$id);
1426 1720
 			if ($this->debugLevel>1)
@@ -1428,8 +1722,14 @@  discard block
 block discarded – undo
1428 1722
 				$endtime = microtime(true) - $starttime;
1429 1723
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid);
1430 1724
 			}
1431
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1432
-			if ($this->debugLevel>1) $starttime = microtime (true);
1725
+			if ($this->debugLevel>1)
1726
+			{
1727
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1728
+			}
1729
+			if ($this->debugLevel>1)
1730
+			{
1731
+				$starttime = microtime (true);
1732
+			}
1433 1733
 			$_numberOfMessages = (empty($cutoffdate)?250:99999);
1434 1734
 			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id);
1435 1735
 			if ($this->debugLevel>1)
@@ -1438,27 +1738,56 @@  discard block
 block discarded – undo
1438 1738
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1439 1739
 			}
1440 1740
 		}
1441
-		if ($_id == NULL && $this->debugLevel>1)  ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1741
+		if ($_id == NULL && $this->debugLevel>1)
1742
+		{
1743
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1744
+		}
1442 1745
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages));
1443 1746
 		$messagelist = array();
1444
-		if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist;
1747
+		if (!isset($rv_messages['header'])||empty($rv_messages['header']))
1748
+		{
1749
+			return $messagelist;
1750
+		}
1445 1751
 		//if ($_returnModHash) $messageFolderHash = array();
1446 1752
 		foreach ((array)$rv_messages['header'] as $k => $vars)
1447 1753
 		{
1448
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1754
+			if ($this->debugLevel>3)
1755
+			{
1756
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1757
+			}
1449 1758
 			$headers[$vars['uid']] = $vars;
1450
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1451
-			if (!empty($vars['deleted'])) continue; // cut of deleted messages
1452
-			if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it
1453
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1759
+			if ($this->debugLevel>3)
1760
+			{
1761
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1762
+			}
1763
+			if (!empty($vars['deleted']))
1764
+			{
1765
+				continue;
1766
+			}
1767
+			// cut of deleted messages
1768
+			if ($cutoffdate && $vars['date'] < $cutoffdate)
1769
+			{
1770
+				continue;
1771
+			}
1772
+			// message is out of range for cutoffdate, ignore it
1773
+			if ($this->debugLevel>0)
1774
+			{
1775
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1776
+			}
1454 1777
 			$mess = $return_all_headers ? $vars : array();
1455 1778
 			$mess["mod"] = self::doFlagsMod($vars).$vars['date'];
1456 1779
 			$mess["id"] = $vars['uid'];
1457 1780
 			// 'seen' aka 'read' is the only flag we want to know about
1458 1781
 			$mess["flags"] = 0;
1459 1782
 			// outlook supports additional flags, set them to 0
1460
-			if($vars["seen"]) $mess["flags"] = 1;
1461
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1783
+			if($vars["seen"])
1784
+			{
1785
+				$mess["flags"] = 1;
1786
+			}
1787
+			if ($this->debugLevel>3)
1788
+			{
1789
+				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1790
+			}
1462 1791
 			$messagelist[$vars['uid']] = $mess;
1463 1792
 			unset($mess);
1464 1793
 		}
@@ -1483,9 +1812,18 @@  discard block
 block discarded – undo
1483 1812
 	static function doFlagsMod($headerFlags)
1484 1813
 	{
1485 1814
 		$flags = 'nnn';
1486
-		if ($headerFlags['flagged']) $flags[0] = 'f';
1487
-		if ($headerFlags['answered']) $flags[1] = 'a';
1488
-		if ($headerFlags['forwarded']) $flags[2] = 'f';
1815
+		if ($headerFlags['flagged'])
1816
+		{
1817
+			$flags[0] = 'f';
1818
+		}
1819
+		if ($headerFlags['answered'])
1820
+		{
1821
+			$flags[1] = 'a';
1822
+		}
1823
+		if ($headerFlags['forwarded'])
1824
+		{
1825
+			$flags[2] = 'f';
1826
+		}
1489 1827
 		//ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags));
1490 1828
 		return $flags;
1491 1829
 	}
@@ -1517,31 +1855,55 @@  discard block
 block discarded – undo
1517 1855
 	{
1518 1856
 		//$this->debugLevel=1;
1519 1857
 		$searchquery=$_searchquery->GetDataArray();
1520
-		if (!is_array($searchquery)) return array();
1521
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1858
+		if (!is_array($searchquery))
1859
+		{
1860
+			return array();
1861
+		}
1862
+		if ($this->debugLevel>0)
1863
+		{
1864
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1865
+		}
1522 1866
 
1523
-		if (isset($searchquery['searchrebuildresults'])) {
1867
+		if (isset($searchquery['searchrebuildresults']))
1868
+		{
1524 1869
 			$rebuildresults = $searchquery['searchrebuildresults'];
1525
-		} else {
1870
+		}
1871
+		else
1872
+		{
1526 1873
 			$rebuildresults = false;
1527 1874
 		}
1528
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1875
+		if ($this->debugLevel>0)
1876
+		{
1877
+			ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1878
+		}
1529 1879
 
1530
-		if (isset($searchquery['deeptraversal'])) {
1880
+		if (isset($searchquery['deeptraversal']))
1881
+		{
1531 1882
 			$deeptraversal = $searchquery['deeptraversal'];
1532
-		} else {
1883
+		}
1884
+		else
1885
+		{
1533 1886
 			$deeptraversal = false;
1534 1887
 		}
1535
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1888
+		if ($this->debugLevel>0)
1889
+		{
1890
+			ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1891
+		}
1536 1892
 
1537
-		if (isset($searchquery['searchrange'])) {
1893
+		if (isset($searchquery['searchrange']))
1894
+		{
1538 1895
 			$range = explode("-",$_searchquery->GetSearchRange());
1539 1896
 			$start =$range[0] + 1;
1540 1897
 			$limit = $range[1] - $range[0] + 1;
1541
-		} else {
1898
+		}
1899
+		else
1900
+		{
1542 1901
 			$range = false;
1543 1902
 		}
1544
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1903
+		if ($this->debugLevel>0)
1904
+		{
1905
+			ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1906
+		}
1545 1907
 
1546 1908
 		//foreach($searchquery['query'] as $k => $value) {
1547 1909
 		//	$query = $value;
@@ -1593,7 +1955,10 @@  discard block
 block discarded – undo
1593 1955
 			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts'));
1594 1956
 		}
1595 1957
 		//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
1596
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1958
+		if ($this->debugLevel>1)
1959
+		{
1960
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1961
+		}
1597 1962
 		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL);
1598 1963
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages));
1599 1964
 		$list=array();
@@ -1625,17 +1990,26 @@  discard block
 block discarded – undo
1625 1990
 	private function getParentID($account,$folder)
1626 1991
 	{
1627 1992
 		$this->_connect($account);
1628
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1993
+		if (!isset($this->folders))
1994
+		{
1995
+			$this->folders = $this->mail->getFolderObjects(true,false);
1996
+		}
1629 1997
 
1630 1998
 		$mailFolder = $this->folders[$folder];
1631
-		if (!isset($mailFolder)) return false;
1999
+		if (!isset($mailFolder))
2000
+		{
2001
+			return false;
2002
+		}
1632 2003
 		$delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter());
1633 2004
 		$parent = explode($delimiter,$folder);
1634 2005
 		array_pop($parent);
1635 2006
 		$parent = implode($delimiter,$parent);
1636 2007
 
1637 2008
 		$id = $parent ? $this->createID($account, $parent) : '0';
1638
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
2009
+		if ($this->debugLevel>1)
2010
+		{
2011
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
2012
+		}
1639 2013
 		return $id;
1640 2014
 	}
1641 2015
 
@@ -1649,7 +2023,10 @@  discard block
 block discarded – undo
1649 2023
 	{
1650 2024
 		static $last_id = null;
1651 2025
 		static $folderObj = null;
1652
-		if (isset($last_id) && $last_id === $id) return $folderObj;
2026
+		if (isset($last_id) && $last_id === $id)
2027
+		{
2028
+			return $folderObj;
2029
+		}
1653 2030
 
1654 2031
 		try {
1655 2032
 			$account = $folder = null;
@@ -1660,18 +2037,30 @@  discard block
 block discarded – undo
1660 2037
 			return $folderObj=false;
1661 2038
 		}
1662 2039
 		$this->_connect($account);
1663
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
2040
+		if (!isset($this->folders))
2041
+		{
2042
+			$this->folders = $this->mail->getFolderObjects(true,false);
2043
+		}
1664 2044
 
1665 2045
 		$mailFolder = $this->folders[$folder];
1666
-		if (!isset($mailFolder)) return $folderObj=false;
2046
+		if (!isset($mailFolder))
2047
+		{
2048
+			return $folderObj=false;
2049
+		}
1667 2050
 
1668 2051
 		$folderObj = new SyncFolder();
1669 2052
 		$folderObj->serverid = $id;
1670 2053
 		$folderObj->parentid = $this->getParentID($account,$folder);
1671 2054
 		$folderObj->displayname = $mailFolder->shortDisplayName;
1672
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
2055
+		if ($this->debugLevel>1)
2056
+		{
2057
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
2058
+		}
1673 2059
 		// get folder-type
1674
-		foreach($this->folders as $inbox => $mailFolder) break;
2060
+		foreach($this->folders as $inbox => $mailFolder)
2061
+		{
2062
+			break;
2063
+		}
1675 2064
 		if ($folder == $inbox)
1676 2065
 		{
1677 2066
 			$folderObj->type = SYNC_FOLDER_TYPE_INBOX;
@@ -1708,7 +2097,10 @@  discard block
 block discarded – undo
1708 2097
 			$folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL;
1709 2098
 		}
1710 2099
 
1711
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
2100
+		if ($this->debugLevel>1)
2101
+		{
2102
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
2103
+		}
1712 2104
 		return $folderObj;
1713 2105
 	}
1714 2106
 
@@ -1752,11 +2144,20 @@  discard block
 block discarded – undo
1752 2144
 	{
1753 2145
 		$account = $folder = null;
1754 2146
 		$this->splitID($folderid, $account, $folder);
1755
-		if (is_numeric($account)) $type = 'mail';
2147
+		if (is_numeric($account))
2148
+		{
2149
+			$type = 'mail';
2150
+		}
1756 2151
 
1757
-		if ($type != 'mail') return false;
2152
+		if ($type != 'mail')
2153
+		{
2154
+			return false;
2155
+		}
1758 2156
 
1759
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
2157
+		if (!isset($this->mail))
2158
+		{
2159
+			$this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
2160
+		}
1760 2161
 
1761 2162
         $this->mail->reopen($folder);
1762 2163
 
@@ -1801,7 +2202,7 @@  discard block
 block discarded – undo
1801 2202
      * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1802 2203
      */
1803 2204
     public function DeleteMessage($folderid, $id, $contentParameters)
1804
-	{
2205
+    {
1805 2206
 		unset($contentParameters);	// not used, but required by function signature
1806 2207
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid'  id: '$id' )");
1807 2208
 		/*
@@ -1827,7 +2228,10 @@  discard block
 block discarded – undo
1827 2228
 			$error = $e->getMessage();
1828 2229
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1829 2230
 			// if the server thinks the message does not exist report deletion as success
1830
-			if (stripos($error,'[NONEXISTENT]')!==false) return true;
2231
+			if (stripos($error,'[NONEXISTENT]')!==false)
2232
+			{
2233
+				return true;
2234
+			}
1831 2235
 			return false;
1832 2236
 		}
1833 2237
 
@@ -1860,7 +2264,7 @@  discard block
 block discarded – undo
1860 2264
      * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
1861 2265
      */
1862 2266
     public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1863
-	{
2267
+    {
1864 2268
 		unset($contentParameters);	// not used, but required by function signature
1865 2269
 		// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid'  id: '$id'  flags: '$flags' )");
1866 2270
 		$account = $folder = null;
@@ -1946,7 +2350,10 @@  discard block
 block discarded – undo
1946 2350
 
1947 2351
 		$str = $this->backend->createID($account, $folder, $id);
1948 2352
 
1949
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
2353
+		if ($this->debugLevel>1)
2354
+		{
2355
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
2356
+		}
1950 2357
 
1951 2358
 		return $str;
1952 2359
 	}
@@ -1967,7 +2374,10 @@  discard block
 block discarded – undo
1967 2374
 		// convert numeric folder-id back to folder name
1968 2375
 		$folder = $this->hash2folder($account,$f=$folder);
1969 2376
 
1970
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
2377
+		if ($this->debugLevel>1)
2378
+		{
2379
+			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
2380
+		}
1971 2381
 	}
1972 2382
 
1973 2383
 	/**
@@ -1986,7 +2396,10 @@  discard block
 block discarded – undo
1986 2396
 	 */
1987 2397
 	private function folder2hash($account,$folder)
1988 2398
 	{
1989
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2399
+		if(!isset($this->folderHashes))
2400
+		{
2401
+			$this->readFolderHashes();
2402
+		}
1990 2403
 
1991 2404
 		if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false)
1992 2405
 		{
@@ -2009,7 +2422,10 @@  discard block
 block discarded – undo
2009 2422
 	 */
2010 2423
 	private function hash2folder($account,$index)
2011 2424
 	{
2012
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2425
+		if(!isset($this->folderHashes))
2426
+		{
2427
+			$this->readFolderHashes();
2428
+		}
2013 2429
 
2014 2430
 		return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null;
2015 2431
 	}
Please login to merge, or discard this patch.
notifications/inc/class.notifications.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -434,7 +434,7 @@
 block discarded – undo
434 434
 	 * Sets backends that should be skipped even if the user
435 435
 	 * defined them in its chain
436 436
 	 *
437
-	 * @param array $_skip_backends array with names of the backends to be skipped
437
+	 * @param string[] $_skip_backends array with names of the backends to be skipped
438 438
 	 * e.g. array('popup', 'winpopup')
439 439
 	 */
440 440
 	public function set_skip_backends(array $_skip_backends) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -660,14 +660,14 @@
 block discarded – undo
660 660
 	 }
661 661
 
662 662
 	 /**
663
-	 * returns notification chains based on admin prefs
664
-	 * @abstract the available chains can be retrieved in two different output formats:
665
-	 * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
-	 * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
-	 *
668
-	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
-	 * @return array containing notification chains, output like given in $_output
670
-	 */
663
+	  * returns notification chains based on admin prefs
664
+	  * @abstract the available chains can be retrieved in two different output formats:
665
+	  * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
+	  * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
+	  *
668
+	  * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
+	  * @return array containing notification chains, output like given in $_output
670
+	  */
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 */
181 181
 	public function __construct() {
182
-		$this->config = (object) Api\Config::read(self::_appname);
182
+		$this->config = (object)Api\Config::read(self::_appname);
183 183
 	}
184 184
 
185 185
 	/**
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @param boolean $reset =false true: reset all errors
189 189
 	 * @return array
190 190
 	 */
191
-	public static function errors($reset=false)
191
+	public static function errors($reset = false)
192 192
 	{
193 193
 		$ret = self::$errors;
194 194
 		if ($reset) self::$errors = array();
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 	 * it's an int with the account id or the e-mail address of a non-eGW user
204 204
 	 */
205 205
 	public function set_sender($_sender) {
206
-		if(is_object($_sender)) {
206
+		if (is_object($_sender)) {
207 207
 			$this->sender = $_sender;
208 208
 			return true;
209 209
 		} else {
210 210
 			// no object atm, we have to handle this and make a pseudo-object
211
-			if(is_numeric($_sender)) {
212
-				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
211
+			if (is_numeric($_sender)) {
212
+				$this->sender = (object)$GLOBALS['egw']->accounts->read($_sender);
213 213
 				return true;
214 214
 			}
215
-			if(is_string($_sender) && strpos($_sender,'@')) {
216
-				$this->sender = (object) array (
217
-									'account_email' => $this->get_addresspart($_sender,'email'),
218
-									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
215
+			if (is_string($_sender) && strpos($_sender, '@')) {
216
+				$this->sender = (object)array(
217
+									'account_email' => $this->get_addresspart($_sender, 'email'),
218
+									'account_fullname' => $this->get_addresspart($_sender, 'fullname'),
219 219
 									);
220 220
 				return true;
221 221
 			}
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
 	 * it's an int with the account id or the e-mail address of a non-eGW user
246 246
 	 */
247 247
 	public function add_receiver($_receiver) {
248
-		if(is_object($_receiver)) {
248
+		if (is_object($_receiver)) {
249 249
 			$this->receivers[] = $_receiver;
250 250
 			return true;
251 251
 		} else {
252 252
 			// no object atm, we have to handle this and make a pseudo-object
253
-			if(is_numeric($_receiver)) {
254
-				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
253
+			if (is_numeric($_receiver)) {
254
+				$this->receivers[] = (object)$GLOBALS['egw']->accounts->read($_receiver);
255 255
 				return true;
256 256
 			}
257
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
258
-				$this->receivers[] = (object) array (
259
-									'account_email' => $this->get_addresspart($_receiver,'email'),
260
-									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
257
+			if (is_string($_receiver) && strpos($_receiver, '@')) {
258
+				$this->receivers[] = (object)array(
259
+									'account_email' => $this->get_addresspart($_receiver, 'email'),
260
+									'account_fullname' => $this->get_addresspart($_receiver, 'fullname'),
261 261
 									);
262 262
 				return true;
263 263
 			}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 * @param string $_message
297 297
 	 */
298 298
 	public function set_message($_message) {
299
-		if(strlen($_message) == strlen(strip_tags($_message))) {
299
+		if (strlen($_message) == strlen(strip_tags($_message))) {
300 300
 			$this->message_plain = $_message;
301 301
 		} else {
302 302
 			$this->message_html = $_message;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function set_popupmessage($_message) {
316 316
 		//popup requires html
317
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
317
+		if (strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
318 318
 		$this->message_popup = $_message;
319 319
 		return true;
320 320
 	}
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function set_links(array $_links) {
328 328
 		$this->links = array(); // clear array if set
329
-		foreach($_links as $link) {
330
-			if(is_array($link)) {
331
-				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
329
+		foreach ($_links as $link) {
330
+			if (is_array($link)) {
331
+				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'], $link['id']);
332 332
 			}
333 333
 		}
334 334
 		return true;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function set_popuplinks(array $_links) {
343 343
 		$this->popup_links = array(); // clear array if set
344
-		foreach($_links as $link) {
345
-			if(is_array($link)) {
344
+		foreach ($_links as $link) {
345
+			if (is_array($link)) {
346 346
 				$this->add_popuplink($link['text'], $link['view'], $link['popup']);
347 347
 			}
348 348
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
360 360
 	 */
361 361
 	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
362
-		if(!$_view || !$_text) { return false; }
362
+		if (!$_view || !$_text) { return false; }
363 363
 		$this->links[] = (object)array(
364 364
 			'text'	=> $_text,
365 365
 			'view'	=> $_view,
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
379 379
 	 */
380 380
 	public function add_popuplink($_text, $_view, $_popup = false) {
381
-		if(!$_view || !$_text) { return false; }
382
-		$this->popup_links[] = (object)array(	'text'	=> $_text,
381
+		if (!$_view || !$_text) { return false; }
382
+		$this->popup_links[] = (object)array('text'	=> $_text,
383 383
 										'view'	=> $_view,
384 384
 										'popup'	=> $_popup,
385 385
 										);
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	public function set_attachments(array $_attachments) {
395 395
 		$this->attachments = array(); // clear array if set
396
-		foreach($_attachments as $attachment) {
397
-			if(is_array($attachment)) {
396
+		foreach ($_attachments as $attachment) {
397
+			if (is_array($attachment)) {
398 398
 				$this->add_attachment(
399 399
 					$attachment['string'],
400 400
 					$attachment['filename'],
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param string $_type File extension (MIME) type.
419 419
 	 * @param string $_path optional path to attachment, if !$_string
420 420
 	 */
421
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
422
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
421
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path = null) {
422
+		if (!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
423 423
 		$this->attachments[] = (object)array(
424 424
 			'string' => $_string,
425 425
 			'filename' => $_filename,
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		if (!is_array($this->receivers) || count($this->receivers) == 0) {
452 452
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
453 453
 		}
454
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
454
+		if (!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
455 455
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
456 456
 		}
457 457
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			$backend_errors = array();
464 464
 			try {
465 465
 				// system or non-system user
466
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
466
+				if ($receiver->account_id && is_numeric($receiver->account_id)) {
467 467
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
468 468
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
469 469
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -476,17 +476,17 @@  discard block
 block discarded – undo
476 476
 					}
477 477
 					$receiver->handle = $receiver->account_lid;
478 478
 					// check if the receiver has rights to run the notifcation app
479
-					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
479
+					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id, true);
480 480
 					$ids[] = $receiver->account_id;
481
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
481
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids, 'run', 'notifications')) {
482 482
 						// read the users notification chain
483 483
 						$prefs = new Api\Preferences($receiver->account_id);
484 484
 						$preferences_all = $prefs->read();
485 485
 						$preferences = (object)$preferences_all[self::_appname];
486
-						if($preferences->notification_chain) {
486
+						if ($preferences->notification_chain) {
487 487
 							// fallback: admin disabled user-chosen chain
488
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
489
-								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
488
+							if (!$notification_chain = $available_chains[$preferences->notification_chain]) {
489
+								$prepend_message .= lang('This eGroupWare notification has been sent to you by mail because your'
490 490
 															.' chosen notification-chain has been disabled by the administrator.'
491 491
 															.' Please choose another notification-chain in your preferences!');
492 492
 								$notification_chain = $available_chains[self::_fallback];
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
504 504
 				}
505 505
 
506
-				if($notification_chain == 'disable') {
506
+				if ($notification_chain == 'disable') {
507 507
 					continue; //user disabled notifications
508 508
 				}
509 509
 
510
-				foreach($notification_chain as $backend => $action) {
510
+				foreach ($notification_chain as $backend => $action) {
511 511
 					$notification_backend = null;
512 512
 					try {
513 513
 						// check if backend should be skipped
514
-						if( in_array($backend, $this->skip_backends) ) {
514
+						if (in_array($backend, $this->skip_backends)) {
515 515
 							// log as error just for the case too much skipping prevents user from being notified
516 516
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
517 517
 							continue;
518 518
 						}
519 519
 
520 520
 						$notification_backend = self::_appname.'_'.$backend;
521
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
522
-							throw new Exception('file for '.$notification_backend. ' does not exist');
521
+						if (!file_exists(EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.'.$notification_backend.'.inc.php')) {
522
+							throw new Exception('file for '.$notification_backend.' does not exist');
523 523
 						}
524
-						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
525
-						if ( !($obj instanceof notifications_iface) ) {
526
-							unset ( $obj );
527
-					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
524
+						$obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences);
525
+						if (!($obj instanceof notifications_iface)) {
526
+							unset ($obj);
527
+					 		throw new Exception($notification_backend.' is no implementation of notifications_iface');
528 528
 						}
529 529
 						$lsubject = $this->subject;
530 530
 						$llinks = $this->links;
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
 					catch (Exception $exception) {
539 539
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
540 540
 						// try next backend
541
-						if($action == 'fail' || $action == 'continue') {
541
+						if ($action == 'fail' || $action == 'continue') {
542 542
 							continue;
543 543
 						}
544 544
 						break; // stop running through chain
545 545
 					}
546 546
 					// backend sucseeded
547 547
 					$user_notified = true;
548
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
548
+					if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain
549 549
 				}
550 550
 				// check if the user has been notified at all
551
-				if(!$user_notified) {
551
+				if (!$user_notified) {
552 552
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
553 553
 					foreach($backend_errors as $id=>$backend_error) {
554 554
 						error_log($backend_error);
@@ -575,22 +575,22 @@  discard block
 block discarded – undo
575 575
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
576 576
 	 */
577 577
 	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
578
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
578
+		if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
579 579
 		$messages = array();
580 580
 
581 581
 		// create the messages
582
-		if(!empty($_message_plain)) {
582
+		if (!empty($_message_plain)) {
583 583
 			$messages['plain'] = $_message_plain;
584 584
 		} else {
585 585
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
586 586
 		}
587 587
 
588
-		if(!empty($_message_html)) {
588
+		if (!empty($_message_html)) {
589 589
 			$messages['html'] = $_message_html;
590 590
 		} else {
591 591
 			$messages['html'] = self::plain2html($_message_plain);
592 592
 		}
593
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
593
+		if (!empty($_message_popup)) $messages['popup'] = $_message_popup;
594 594
 		return $messages;
595 595
 	}
596 596
 
@@ -613,9 +613,9 @@  discard block
 block discarded – undo
613 613
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
614 614
 	 */
615 615
 	 private function prepend_message(array $_messages, $_prepend = null) {
616
-		if(strlen($_prepend) > 0) {
617
-			foreach($_messages as $key => $value) {
618
-				switch($key) {
616
+		if (strlen($_prepend) > 0) {
617
+			foreach ($_messages as $key => $value) {
618
+				switch ($key) {
619 619
 					case 'plain':
620 620
 						$_messages[$key] = $_prepend."\n\n".$value;
621 621
 						break;
@@ -639,17 +639,17 @@  discard block
 block discarded – undo
639 639
 	 * @param string $_part
640 640
 	 * @return string chosen part of the address
641 641
 	 */
642
-	private function get_addresspart($_address, $_part='email')
642
+	private function get_addresspart($_address, $_part = 'email')
643 643
 	{
644 644
 		$parts = null;
645
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
646
-	 		$fullname = trim(trim($parts[1]),'\"');
645
+	 	if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part
646
+	 		$fullname = trim(trim($parts[1]), '\"');
647 647
 	 		$email = $parts[2];
648 648
 	 	} else {
649 649
 	 		$fullname = false;
650 650
 	 		$email = $_address;
651 651
 	 	}
652
-	 	switch($_part) {
652
+	 	switch ($_part) {
653 653
 	 		case 'fullname':
654 654
 	 			return $fullname;
655 655
 	 		case 'email':
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
674
-		foreach($this->backends as $backend) {
675
-			switch($backend) {
674
+		foreach ($this->backends as $backend) {
675
+			switch ($backend) {
676 676
 				case 'email':
677 677
 				case 'popup':
678 678
 				case 'jpopup':
@@ -687,15 +687,15 @@  discard block
 block discarded – undo
687 687
 
688 688
 		$enabled_chains = array();
689 689
 		$disabled_chains = array();
690
-		foreach($this->notification_chains as $key => $chain) {
690
+		foreach ($this->notification_chains as $key => $chain) {
691 691
 			$allow_chain = true;
692
-			if(is_array($chain)) {
693
-				foreach(array_keys($chain) as $name) {
694
-					if(!$enabled_backends[$name]) {
692
+			if (is_array($chain)) {
693
+				foreach (array_keys($chain) as $name) {
694
+					if (!$enabled_backends[$name]) {
695 695
 						$allow_chain = false; // disable whole chain if one backend is disabled
696 696
 					}
697 697
 				}
698
-				if($allow_chain) {
698
+				if ($allow_chain) {
699 699
 					$enabled_chains[$key] = $chain;
700 700
 				} else {
701 701
 					$disabled_chains[$key] = $chain;
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
 		// create the 'all' chain from the enabled backends
711 711
 		$chain_all = array();
712 712
 		$backend_count = 1;
713
-		foreach($enabled_backends as $backend => $enabled) {
714
-			if($enabled) {
713
+		foreach ($enabled_backends as $backend => $enabled) {
714
+			if ($enabled) {
715 715
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
716 716
 			}
717 717
 			$backend_count++;
718 718
 		}
719 719
 		$common_chains['all'] = $chain_all;
720 720
 
721
-		switch($_output) {
721
+		switch ($_output) {
722 722
 			case 'human':
723 723
 				$chain_groups = array(
724 724
 					lang('Common chains')	=> 'common_chains',
@@ -727,10 +727,10 @@  discard block
 block discarded – undo
727 727
 					);
728 728
 				$suffix = '_human';
729 729
 				// create descriptions for each chain key in each group
730
-				foreach($chain_groups as $name => $arr_name) {
730
+				foreach ($chain_groups as $name => $arr_name) {
731 731
 					${$arr_name.$suffix} = array();
732
-					foreach(array_keys(${$arr_name}) as $key) {
733
-						if($arr_name == 'disabled_chains') {
732
+					foreach (array_keys(${$arr_name}) as $key) {
733
+						if ($arr_name == 'disabled_chains') {
734 734
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
735 735
 						} else {
736 736
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 				}
740 740
 				// summarize all groups with minimum one chain to the final array
741 741
 				$chains_final = array();
742
-				foreach($chain_groups as $name => $arr_name) {
743
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
742
+				foreach ($chain_groups as $name => $arr_name) {
743
+					if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
744 744
 						$chains_final[$name] = ${$arr_name.$suffix};
745 745
 					}
746 746
 				}
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
761 761
 	 */
762 762
 	public function deleteaccount($settings) {
763
-		foreach($this->backends as $backend) {
764
-			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
763
+		foreach ($this->backends as $backend) {
764
+			$backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount');
765 765
 			if (is_callable($backend_hook)) {
766
-				call_user_func($backend_hook,$settings);
766
+				call_user_func($backend_hook, $settings);
767 767
 			}
768 768
 		}
769 769
 	}
Please login to merge, or discard this patch.
Braces   +222 added lines, -96 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
  * called from this class. The backend's job is to deliver ONE message to ONE recipient.
25 25
  *
26 26
  */
27
-final class notifications {
27
+final class notifications
28
+{
28 29
 
29 30
 	/**
30 31
 	 * Appname
@@ -178,7 +179,8 @@  discard block
 block discarded – undo
178 179
 	 * constructor of notifications
179 180
 	 *
180 181
 	 */
181
-	public function __construct() {
182
+	public function __construct()
183
+	{
182 184
 		$this->config = (object) Api\Config::read(self::_appname);
183 185
 	}
184 186
 
@@ -191,7 +193,10 @@  discard block
 block discarded – undo
191 193
 	public static function errors($reset=false)
192 194
 	{
193 195
 		$ret = self::$errors;
194
-		if ($reset) self::$errors = array();
196
+		if ($reset)
197
+		{
198
+			self::$errors = array();
199
+		}
195 200
 		return $ret;
196 201
 	}
197 202
 
@@ -202,17 +207,23 @@  discard block
 block discarded – undo
202 207
 	 * as long as the accounts class isn't a nice object,
203 208
 	 * it's an int with the account id or the e-mail address of a non-eGW user
204 209
 	 */
205
-	public function set_sender($_sender) {
206
-		if(is_object($_sender)) {
210
+	public function set_sender($_sender)
211
+	{
212
+		if(is_object($_sender))
213
+		{
207 214
 			$this->sender = $_sender;
208 215
 			return true;
209
-		} else {
216
+		}
217
+		else
218
+		{
210 219
 			// no object atm, we have to handle this and make a pseudo-object
211
-			if(is_numeric($_sender)) {
220
+			if(is_numeric($_sender))
221
+			{
212 222
 				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
213 223
 				return true;
214 224
 			}
215
-			if(is_string($_sender) && strpos($_sender,'@')) {
225
+			if(is_string($_sender) && strpos($_sender,'@'))
226
+			{
216 227
 				$this->sender = (object) array (
217 228
 									'account_email' => $this->get_addresspart($_sender,'email'),
218 229
 									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
@@ -230,9 +241,11 @@  discard block
 block discarded – undo
230 241
 	 * as long as the accounts class isn't a nice object,
231 242
 	 * it's an array with the int of the account id or the e-mail address of a non-eGW user
232 243
 	 */
233
-	public function set_receivers(array $_receivers) {
244
+	public function set_receivers(array $_receivers)
245
+	{
234 246
 		$this->receivers = array();
235
-		foreach ($_receivers as $receiver) {
247
+		foreach ($_receivers as $receiver)
248
+		{
236 249
 			$this->add_receiver($receiver);
237 250
 		}
238 251
 	}
@@ -244,17 +257,23 @@  discard block
 block discarded – undo
244 257
 	 * as long as the accounts class isn't a nice object,
245 258
 	 * it's an int with the account id or the e-mail address of a non-eGW user
246 259
 	 */
247
-	public function add_receiver($_receiver) {
248
-		if(is_object($_receiver)) {
260
+	public function add_receiver($_receiver)
261
+	{
262
+		if(is_object($_receiver))
263
+		{
249 264
 			$this->receivers[] = $_receiver;
250 265
 			return true;
251
-		} else {
266
+		}
267
+		else
268
+		{
252 269
 			// no object atm, we have to handle this and make a pseudo-object
253
-			if(is_numeric($_receiver)) {
270
+			if(is_numeric($_receiver))
271
+			{
254 272
 				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
255 273
 				return true;
256 274
 			}
257
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
275
+			if(is_string($_receiver) && strpos($_receiver,'@'))
276
+			{
258 277
 				$this->receivers[] = (object) array (
259 278
 									'account_email' => $this->get_addresspart($_receiver,'email'),
260 279
 									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
@@ -270,7 +289,8 @@  discard block
 block discarded – undo
270 289
 	 *
271 290
 	 * @param string $_subject
272 291
 	 */
273
-	public function set_subject($_subject) {
292
+	public function set_subject($_subject)
293
+	{
274 294
 		$this->subject = $_subject;
275 295
 		return true;
276 296
 	}
@@ -280,7 +300,8 @@  discard block
 block discarded – undo
280 300
 	 *
281 301
 	 * @param string $_subject
282 302
 	 */
283
-	public function set_popupsubject($_subject) {
303
+	public function set_popupsubject($_subject)
304
+	{
284 305
 		$this->popupsubject = $_subject;
285 306
 		return true;
286 307
 	}
@@ -295,10 +316,14 @@  discard block
 block discarded – undo
295 316
 	 *
296 317
 	 * @param string $_message
297 318
 	 */
298
-	public function set_message($_message) {
299
-		if(strlen($_message) == strlen(strip_tags($_message))) {
319
+	public function set_message($_message)
320
+	{
321
+		if(strlen($_message) == strlen(strip_tags($_message)))
322
+		{
300 323
 			$this->message_plain = $_message;
301
-		} else {
324
+		}
325
+		else
326
+		{
302 327
 			$this->message_html = $_message;
303 328
 		}
304 329
 		return true;
@@ -312,9 +337,13 @@  discard block
 block discarded – undo
312 337
 	 *
313 338
 	 * @param string $_message
314 339
 	 */
315
-	public function set_popupmessage($_message) {
340
+	public function set_popupmessage($_message)
341
+	{
316 342
 		//popup requires html
317
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
343
+		if(strlen($_message) == strlen(strip_tags($_message)))
344
+		{
345
+			$_message = self::plain2html($_message);
346
+		}
318 347
 		$this->message_popup = $_message;
319 348
 		return true;
320 349
 	}
@@ -324,10 +353,13 @@  discard block
 block discarded – undo
324 353
 	 *
325 354
 	 * @param array $_links link array (like defined in $this->add_link)
326 355
 	 */
327
-	public function set_links(array $_links) {
356
+	public function set_links(array $_links)
357
+	{
328 358
 		$this->links = array(); // clear array if set
329
-		foreach($_links as $link) {
330
-			if(is_array($link)) {
359
+		foreach($_links as $link)
360
+		{
361
+			if(is_array($link))
362
+			{
331 363
 				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
332 364
 			}
333 365
 		}
@@ -339,10 +371,13 @@  discard block
 block discarded – undo
339 371
 	 *
340 372
 	 * @param array $_links link array (like defined in $this->add_link)
341 373
 	 */
342
-	public function set_popuplinks(array $_links) {
374
+	public function set_popuplinks(array $_links)
375
+	{
343 376
 		$this->popup_links = array(); // clear array if set
344
-		foreach($_links as $link) {
345
-			if(is_array($link)) {
377
+		foreach($_links as $link)
378
+		{
379
+			if(is_array($link))
380
+			{
346 381
 				$this->add_popuplink($link['text'], $link['view'], $link['popup']);
347 382
 			}
348 383
 		}
@@ -358,8 +393,11 @@  discard block
 block discarded – undo
358 393
 	 * @param string $_app Application name, to use link registry (popup & view ignored)
359 394
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
360 395
 	 */
361
-	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
362
-		if(!$_view || !$_text) { return false; }
396
+	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false)
397
+	{
398
+		if(!$_view || !$_text)
399
+		{
400
+return false; }
363 401
 		$this->links[] = (object)array(
364 402
 			'text'	=> $_text,
365 403
 			'view'	=> $_view,
@@ -377,8 +415,11 @@  discard block
 block discarded – undo
377 415
 	 * @param array $_view all params needed to view the link (name => value pairs)
378 416
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
379 417
 	 */
380
-	public function add_popuplink($_text, $_view, $_popup = false) {
381
-		if(!$_view || !$_text) { return false; }
418
+	public function add_popuplink($_text, $_view, $_popup = false)
419
+	{
420
+		if(!$_view || !$_text)
421
+		{
422
+return false; }
382 423
 		$this->popup_links[] = (object)array(	'text'	=> $_text,
383 424
 										'view'	=> $_view,
384 425
 										'popup'	=> $_popup,
@@ -391,10 +432,13 @@  discard block
 block discarded – undo
391 432
 	 *
392 433
 	 * @param array $_attachments attachment array (like defined in $this->add_attachment)
393 434
 	 */
394
-	public function set_attachments(array $_attachments) {
435
+	public function set_attachments(array $_attachments)
436
+	{
395 437
 		$this->attachments = array(); // clear array if set
396
-		foreach($_attachments as $attachment) {
397
-			if(is_array($attachment)) {
438
+		foreach($_attachments as $attachment)
439
+		{
440
+			if(is_array($attachment))
441
+			{
398 442
 				$this->add_attachment(
399 443
 					$attachment['string'],
400 444
 					$attachment['filename'],
@@ -418,8 +462,12 @@  discard block
 block discarded – undo
418 462
 	 * @param string $_type File extension (MIME) type.
419 463
 	 * @param string $_path optional path to attachment, if !$_string
420 464
 	 */
421
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
422
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
465
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null)
466
+	{
467
+		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename)
468
+		{
469
+			return false;
470
+		}
423 471
 		$this->attachments[] = (object)array(
424 472
 			'string' => $_string,
425 473
 			'filename' => $_filename,
@@ -437,33 +485,40 @@  discard block
 block discarded – undo
437 485
 	 * @param array $_skip_backends array with names of the backends to be skipped
438 486
 	 * e.g. array('popup', 'winpopup')
439 487
 	 */
440
-	public function set_skip_backends(array $_skip_backends) {
488
+	public function set_skip_backends(array $_skip_backends)
489
+	{
441 490
 		$this->skip_backends = $_skip_backends;
442 491
 	}
443 492
 
444 493
 	/**
445 494
 	 * sends notifications
446 495
 	 */
447
-	public function send() {
448
-		if (!is_object($this->sender)) {
496
+	public function send()
497
+	{
498
+		if (!is_object($this->sender))
499
+		{
449 500
 			throw new Exception('Error: cannot send notifications. No sender supplied');
450 501
 		}
451
-		if (!is_array($this->receivers) || count($this->receivers) == 0) {
502
+		if (!is_array($this->receivers) || count($this->receivers) == 0)
503
+		{
452 504
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
453 505
 		}
454
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
506
+		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup))
507
+		{
455 508
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
456 509
 		}
457 510
 
458 511
 		$available_chains = $this->get_available_chains('routing');
459 512
 
460
-		foreach ($this->receivers as $receiver) {
513
+		foreach ($this->receivers as $receiver)
514
+		{
461 515
 			$user_notified = false;
462 516
 			$prepend_message = '';
463 517
 			$backend_errors = array();
464 518
 			try {
465 519
 				// system or non-system user
466
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
520
+				if($receiver->account_id && is_numeric($receiver->account_id))
521
+				{
467 522
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
468 523
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
469 524
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -478,51 +533,65 @@  discard block
 block discarded – undo
478 533
 					// check if the receiver has rights to run the notifcation app
479 534
 					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
480 535
 					$ids[] = $receiver->account_id;
481
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
536
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications'))
537
+					{
482 538
 						// read the users notification chain
483 539
 						$prefs = new Api\Preferences($receiver->account_id);
484 540
 						$preferences_all = $prefs->read();
485 541
 						$preferences = (object)$preferences_all[self::_appname];
486
-						if($preferences->notification_chain) {
542
+						if($preferences->notification_chain)
543
+						{
487 544
 							// fallback: admin disabled user-chosen chain
488
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
545
+							if(!$notification_chain = $available_chains[$preferences->notification_chain])
546
+							{
489 547
 								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
490 548
 															.' chosen notification-chain has been disabled by the administrator.'
491 549
 															.' Please choose another notification-chain in your preferences!');
492 550
 								$notification_chain = $available_chains[self::_fallback];
493 551
 							}
494
-						} else {
552
+						}
553
+						else
554
+						{
495 555
 							$notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs
496 556
 						}
497
-					} else {
557
+					}
558
+					else
559
+					{
498 560
 						$notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app
499 561
 					}
500
-				} else {
562
+				}
563
+				else
564
+				{
501 565
 					// non-system user
502 566
 					$receiver->handle = $receiver->account_email;
503 567
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
504 568
 				}
505 569
 
506
-				if($notification_chain == 'disable') {
570
+				if($notification_chain == 'disable')
571
+				{
507 572
 					continue; //user disabled notifications
508 573
 				}
509 574
 
510
-				foreach($notification_chain as $backend => $action) {
575
+				foreach($notification_chain as $backend => $action)
576
+				{
511 577
 					$notification_backend = null;
512 578
 					try {
513 579
 						// check if backend should be skipped
514
-						if( in_array($backend, $this->skip_backends) ) {
580
+						if( in_array($backend, $this->skip_backends) )
581
+						{
515 582
 							// log as error just for the case too much skipping prevents user from being notified
516 583
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
517 584
 							continue;
518 585
 						}
519 586
 
520 587
 						$notification_backend = self::_appname.'_'.$backend;
521
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
588
+						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php'))
589
+						{
522 590
 							throw new Exception('file for '.$notification_backend. ' does not exist');
523 591
 						}
524 592
 						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
525
-						if ( !($obj instanceof notifications_iface) ) {
593
+						if ( !($obj instanceof notifications_iface) )
594
+						{
526 595
 							unset ( $obj );
527 596
 					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
528 597
 						}
@@ -530,31 +599,44 @@  discard block
 block discarded – undo
530 599
 						$llinks = $this->links;
531 600
 						if ($backend == 'popup')
532 601
 						{
533
-							if (!empty($this->popupsubject)) $lsubject = $this->popupsubject;
534
-							if ($this->popup_links) $llinks = $this->popup_links;
602
+							if (!empty($this->popupsubject))
603
+							{
604
+								$lsubject = $this->popupsubject;
605
+							}
606
+							if ($this->popup_links)
607
+							{
608
+								$llinks = $this->popup_links;
609
+							}
535 610
 						}
536 611
 						$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments);
537 612
 					}
538 613
 					catch (Exception $exception) {
539 614
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
540 615
 						// try next backend
541
-						if($action == 'fail' || $action == 'continue') {
616
+						if($action == 'fail' || $action == 'continue')
617
+						{
542 618
 							continue;
543 619
 						}
544 620
 						break; // stop running through chain
545 621
 					}
546 622
 					// backend sucseeded
547 623
 					$user_notified = true;
548
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
624
+					if($action == 'stop' || $action == 'fail')
625
+					{
626
+break; } // stop running through chain
549 627
 				}
550 628
 				// check if the user has been notified at all
551
-				if(!$user_notified) {
629
+				if(!$user_notified)
630
+				{
552 631
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
553 632
 					foreach($backend_errors as $id=>$backend_error) {
554 633
 						error_log($backend_error);
555 634
 					}*/
556 635
 					$error = implode(', ', $backend_errors);
557
-					if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error;
636
+					if (stripos($error, (string)$receiver->handle) !== false)
637
+					{
638
+						$error = $receiver->handle.': '.$error;
639
+					}
558 640
 					self::$errors[] = $error;
559 641
 				}
560 642
 			}
@@ -574,23 +656,35 @@  discard block
 block discarded – undo
574 656
 	 * @param string $_message_popup
575 657
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
576 658
 	 */
577
-	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
578
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
659
+	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '')
660
+	{
661
+		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup))
662
+		{
663
+return false; } // no message set
579 664
 		$messages = array();
580 665
 
581 666
 		// create the messages
582
-		if(!empty($_message_plain)) {
667
+		if(!empty($_message_plain))
668
+		{
583 669
 			$messages['plain'] = $_message_plain;
584
-		} else {
670
+		}
671
+		else
672
+		{
585 673
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
586 674
 		}
587 675
 
588
-		if(!empty($_message_html)) {
676
+		if(!empty($_message_html))
677
+		{
589 678
 			$messages['html'] = $_message_html;
590
-		} else {
679
+		}
680
+		else
681
+		{
591 682
 			$messages['html'] = self::plain2html($_message_plain);
592 683
 		}
593
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
684
+		if (!empty($_message_popup))
685
+		{
686
+			$messages['popup']=$_message_popup;
687
+		}
594 688
 		return $messages;
595 689
 	}
596 690
 
@@ -612,10 +706,14 @@  discard block
 block discarded – undo
612 706
 	 * @param string $_prepend just a plain message to prepend, no html!
613 707
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
614 708
 	 */
615
-	 private function prepend_message(array $_messages, $_prepend = null) {
616
-		if(strlen($_prepend) > 0) {
617
-			foreach($_messages as $key => $value) {
618
-				switch($key) {
709
+	 private function prepend_message(array $_messages, $_prepend = null)
710
+	 {
711
+		if(strlen($_prepend) > 0)
712
+		{
713
+			foreach($_messages as $key => $value)
714
+			{
715
+				switch($key)
716
+				{
619 717
 					case 'plain':
620 718
 						$_messages[$key] = $_prepend."\n\n".$value;
621 719
 						break;
@@ -642,14 +740,19 @@  discard block
 block discarded – undo
642 740
 	private function get_addresspart($_address, $_part='email')
643 741
 	{
644 742
 		$parts = null;
645
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
743
+	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts))
744
+	 	{
745
+// _address contains a fullname part
646 746
 	 		$fullname = trim(trim($parts[1]),'\"');
647 747
 	 		$email = $parts[2];
648
-	 	} else {
748
+	 	}
749
+	 	else
750
+	 	{
649 751
 	 		$fullname = false;
650 752
 	 		$email = $_address;
651 753
 	 	}
652
-	 	switch($_part) {
754
+	 	switch($_part)
755
+	 	{
653 756
 	 		case 'fullname':
654 757
 	 			return $fullname;
655 758
 	 		case 'email':
@@ -668,11 +771,14 @@  discard block
 block discarded – undo
668 771
 	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669 772
 	 * @return array containing notification chains, output like given in $_output
670 773
 	 */
671
-	public function get_available_chains($_output = 'routing') {
774
+	public function get_available_chains($_output = 'routing')
775
+	{
672 776
 		// determine enabled backends from Api\Config
673 777
 		$enabled_backends = array();
674
-		foreach($this->backends as $backend) {
675
-			switch($backend) {
778
+		foreach($this->backends as $backend)
779
+		{
780
+			switch($backend)
781
+			{
676 782
 				case 'email':
677 783
 				case 'popup':
678 784
 				case 'jpopup':
@@ -687,17 +793,24 @@  discard block
 block discarded – undo
687 793
 
688 794
 		$enabled_chains = array();
689 795
 		$disabled_chains = array();
690
-		foreach($this->notification_chains as $key => $chain) {
796
+		foreach($this->notification_chains as $key => $chain)
797
+		{
691 798
 			$allow_chain = true;
692
-			if(is_array($chain)) {
693
-				foreach(array_keys($chain) as $name) {
694
-					if(!$enabled_backends[$name]) {
799
+			if(is_array($chain))
800
+			{
801
+				foreach(array_keys($chain) as $name)
802
+				{
803
+					if(!$enabled_backends[$name])
804
+					{
695 805
 						$allow_chain = false; // disable whole chain if one backend is disabled
696 806
 					}
697 807
 				}
698
-				if($allow_chain) {
808
+				if($allow_chain)
809
+				{
699 810
 					$enabled_chains[$key] = $chain;
700
-				} else {
811
+				}
812
+				else
813
+				{
701 814
 					$disabled_chains[$key] = $chain;
702 815
 				}
703 816
 			}
@@ -710,15 +823,18 @@  discard block
 block discarded – undo
710 823
 		// create the 'all' chain from the enabled backends
711 824
 		$chain_all = array();
712 825
 		$backend_count = 1;
713
-		foreach($enabled_backends as $backend => $enabled) {
714
-			if($enabled) {
826
+		foreach($enabled_backends as $backend => $enabled)
827
+		{
828
+			if($enabled)
829
+			{
715 830
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
716 831
 			}
717 832
 			$backend_count++;
718 833
 		}
719 834
 		$common_chains['all'] = $chain_all;
720 835
 
721
-		switch($_output) {
836
+		switch($_output)
837
+		{
722 838
 			case 'human':
723 839
 				$chain_groups = array(
724 840
 					lang('Common chains')	=> 'common_chains',
@@ -727,20 +843,27 @@  discard block
 block discarded – undo
727 843
 					);
728 844
 				$suffix = '_human';
729 845
 				// create descriptions for each chain key in each group
730
-				foreach($chain_groups as $name => $arr_name) {
846
+				foreach($chain_groups as $name => $arr_name)
847
+				{
731 848
 					${$arr_name.$suffix} = array();
732
-					foreach(array_keys(${$arr_name}) as $key) {
733
-						if($arr_name == 'disabled_chains') {
849
+					foreach(array_keys(${$arr_name}) as $key)
850
+					{
851
+						if($arr_name == 'disabled_chains')
852
+						{
734 853
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
735
-						} else {
854
+						}
855
+						else
856
+						{
736 857
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
737 858
 						}
738 859
 					}
739 860
 				}
740 861
 				// summarize all groups with minimum one chain to the final array
741 862
 				$chains_final = array();
742
-				foreach($chain_groups as $name => $arr_name) {
743
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
863
+				foreach($chain_groups as $name => $arr_name)
864
+				{
865
+					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0)
866
+					{
744 867
 						$chains_final[$name] = ${$arr_name.$suffix};
745 868
 					}
746 869
 				}
@@ -759,10 +882,13 @@  discard block
 block discarded – undo
759 882
 	 *
760 883
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
761 884
 	 */
762
-	public function deleteaccount($settings) {
763
-		foreach($this->backends as $backend) {
885
+	public function deleteaccount($settings)
886
+	{
887
+		foreach($this->backends as $backend)
888
+		{
764 889
 			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
765
-			if (is_callable($backend_hook)) {
890
+			if (is_callable($backend_hook))
891
+			{
766 892
 				call_user_func($backend_hook,$settings);
767 893
 			}
768 894
 		}
Please login to merge, or discard this patch.
notifications/inc/class.notifications_email.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 	 * @param array $_links
132 132
 	 * @param boolean $_render_html
133 133
 	 * @param boolean $_render_external
134
-	 * @return plain or html rendered link(s) as complete string
134
+	 * @return false|string or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137 137
 		if(!is_array($_links) || count($_links) == 0) { return false; }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 	 * @param object $_preferences
67 67
 	 */
68 68
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
70
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
71 71
 		$this->sender = $_sender;
72 72
 		$this->recipient = $_recipient;
73 73
 		$this->config = $_config;
74 74
 		$this->preferences = $_preferences;
75
-		if(is_object($this->mail))
75
+		if (is_object($this->mail))
76 76
 		{
77 77
 			unset($this->mail);
78 78
 		}
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 		$this->mail->setFrom($this->sender->account_email, $this->sender->account_fullname);
105 105
 
106 106
 		$this->mail->addHeader('Subject', trim($_subject)); // trim the subject to avoid strange wrong encoding problem
107
-		$this->mail->setHtmlBody($body_html, null, false);	// no automatic alternativ
107
+		$this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ
108 108
 		$this->mail->setBody($body_plain);
109 109
 
110
-		if(is_array($_attachments) && count($_attachments) > 0)
110
+		if (is_array($_attachments) && count($_attachments) > 0)
111 111
 		{
112
-			foreach($_attachments as $attachment)
112
+			foreach ($_attachments as $attachment)
113 113
 			{
114 114
 				if ($attachment->string)
115 115
 				{
116 116
 					$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
117 117
 				}
118
-				elseif($attachment->path)
118
+				elseif ($attachment->path)
119 119
 				{
120 120
 					$this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type);
121 121
 				}
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
 	 * @return plain or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137
-		if(!is_array($_links) || count($_links) == 0) { return false; }
137
+		if (!is_array($_links) || count($_links) == 0) { return false; }
138 138
 
139 139
 		// provide defaults if given arguments are null
140 140
 		// php distinguishes between missing and present(null) arguments
141
-		if(is_null($_render_html)) { $_render_html = false; }
142
-		if(is_null($_render_external)) { $_render_external = true; }
141
+		if (is_null($_render_html)) { $_render_html = false; }
142
+		if (is_null($_render_external)) { $_render_external = true; }
143 143
 		$newline = $_render_html ? "<br />" : "\n";
144 144
 		$hruler = $_render_html ? Api\Html::hr() : '';
145 145
 
146 146
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
147
+		foreach ($_links as $link) {
148
+			if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; }
149 149
 			// do not expose sensitive data
150
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
150
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', Api\Html::link('/index.php', $link->view));
151 151
 			// complete missing protocol and domain part if needed
152 152
 			if ($url{0} == '/' && $_render_external) {
153 153
 				$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			$rendered_links[] = $_render_html ? $a_href : $url;
158 158
 		}
159 159
 
160
-		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links);
160
+		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links);
161 161
 	}
162 162
 
163 163
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via email.
17 17
  */
18
-class notifications_email implements notifications_iface {
18
+class notifications_email implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -65,9 +66,14 @@  discard block
 block discarded – undo
65 66
 	 * @param object $_config
66 67
 	 * @param object $_preferences
67 68
 	 */
68
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
70
+	{
71
+		if(!is_object($_sender))
72
+		{
73
+throw new Exception("no sender given."); }
74
+		if(!is_object($_recipient))
75
+		{
76
+throw new Exception("no recipient given."); }
71 77
 		$this->sender = $_sender;
72 78
 		$this->recipient = $_recipient;
73 79
 		$this->config = $_config;
@@ -133,23 +139,34 @@  discard block
 block discarded – undo
133 139
 	 * @param boolean $_render_external
134 140
 	 * @return plain or html rendered link(s) as complete string
135 141
 	 */
136
-	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137
-		if(!is_array($_links) || count($_links) == 0) { return false; }
142
+	private function render_links($_links = false, $_render_html = false, $_render_external = true)
143
+	{
144
+		if(!is_array($_links) || count($_links) == 0)
145
+		{
146
+return false; }
138 147
 
139 148
 		// provide defaults if given arguments are null
140 149
 		// php distinguishes between missing and present(null) arguments
141
-		if(is_null($_render_html)) { $_render_html = false; }
142
-		if(is_null($_render_external)) { $_render_external = true; }
150
+		if(is_null($_render_html))
151
+		{
152
+$_render_html = false; }
153
+		if(is_null($_render_external))
154
+		{
155
+$_render_external = true; }
143 156
 		$newline = $_render_html ? "<br />" : "\n";
144 157
 		$hruler = $_render_html ? Api\Html::hr() : '';
145 158
 
146 159
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
160
+		foreach($_links as $link)
161
+		{
162
+			if($_render_external || ! $link->popup)
163
+			{
164
+$link->view['no_popup'] = 1; }
149 165
 			// do not expose sensitive data
150 166
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
151 167
 			// complete missing protocol and domain part if needed
152
-			if ($url{0} == '/' && $_render_external) {
168
+			if ($url{0} == '/' && $_render_external)
169
+			{
153 170
 				$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
154 171
 					($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$url;
155 172
 			}
Please login to merge, or discard this patch.
notifications/inc/class.notifications_jpopup.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,6 @@
 block discarded – undo
152 152
 	* saves notification into database so that the client can fetch it from there
153 153
 	*
154 154
 	* @param string $_message
155
-	* @param array $_user_sessions
156 155
 	*/
157 156
 	private function save( $_message ) {
158 157
 		$result = $this->db->insert( self::_notification_table, array(
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,63 +15,63 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
 	/**
18
-	* Appname
19
-	*/
18
+	 * Appname
19
+	 */
20 20
 	const _appname = 'notifications';
21 21
 
22 22
 	/**
23
-	* Notification table in SQL database
24
-	*/
23
+	 * Notification table in SQL database
24
+	 */
25 25
 	const _notification_table = 'egw_notificationpopup';
26 26
 
27 27
 	/**
28
-	* Notification type
29
-	*/
28
+	 * Notification type
29
+	 */
30 30
 	const _type = 'jpopup';
31 31
 
32 32
 	/**
33
-	* holds account object for user who sends the message
34
-	*
35
-	* @var object
36
-	*/
33
+	 * holds account object for user who sends the message
34
+	 *
35
+	 * @var object
36
+	 */
37 37
 	private $sender;
38 38
 
39 39
 	/**
40
-	* holds account object for user to notify
41
-	*
42
-	* @var object
43
-	*/
40
+	 * holds account object for user to notify
41
+	 *
42
+	 * @var object
43
+	 */
44 44
 	private $recipient;
45 45
 
46 46
 	/**
47
-	* holds config object (sitewide application config)
48
-	*
49
-	* @var object
50
-	*/
47
+	 * holds config object (sitewide application config)
48
+	 *
49
+	 * @var object
50
+	 */
51 51
 	private $config;
52 52
 
53 53
 	/**
54
-	* holds preferences object of user to notify
55
-	*
56
-	* @var object
57
-	*/
54
+	 * holds preferences object of user to notify
55
+	 *
56
+	 * @var object
57
+	 */
58 58
 	private $preferences;
59 59
 
60 60
 	/**
61
-	* holds db object of SQL database
62
-	*
63
-	* @var Api\Db
64
-	*/
61
+	 * holds db object of SQL database
62
+	 *
63
+	 * @var Api\Db
64
+	 */
65 65
 	private $db;
66 66
 
67 67
 	/**
68
-	* constructor of notifications_egwpopup
69
-	*
70
-	* @param object $_sender
71
-	* @param object $_recipient
72
-	* @param object $_config
73
-	* @param object $_preferences
74
-	*/
68
+	 * constructor of notifications_egwpopup
69
+	 *
70
+	 * @param object $_sender
71
+	 * @param object $_recipient
72
+	 * @param object $_config
73
+	 * @param object $_preferences
74
+	 */
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77 77
 		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	/**
88
-	* sends notification if user is online
89
-	*
90
-	* @param array $_messages
91
-	* @param string $_subject
92
-	* @param array $_links
93
-	* @param array $_attachments
94
-	*/
88
+	 * sends notification if user is online
89
+	 *
90
+	 * @param array $_messages
91
+	 * @param string $_subject
92
+	 * @param array $_links
93
+	 * @param array $_attachments
94
+	 */
95 95
 	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false)
96 96
 	{
97 97
 		unset($_attachments);	// not used
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	* renders additional infos from sender and subject
137
-	*
138
-	* @param string $_subject
139
-	* @return string html rendered info as complete string
140
-	*/
136
+	 * renders additional infos from sender and subject
137
+	 *
138
+	 * @param string $_subject
139
+	 * @return string html rendered info as complete string
140
+	 */
141 141
 	private function render_infos($_subject = false) {
142 142
 		$infos = array();
143 143
 		$newline = "<br />";
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* saves notification into database so that the client can fetch it from there
153
-	*
154
-	* @param string $_message
155
-	* @param array $_user_sessions
156
-	*/
152
+	 * saves notification into database so that the client can fetch it from there
153
+	 *
154
+	 * @param string $_message
155
+	 * @param array $_user_sessions
156
+	 */
157 157
 	private function save( $_message ) {
158 158
 		$result = $this->db->insert( self::_notification_table, array(
159 159
 			'account_id'     => $this->recipient->account_id,
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	*/
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77
-		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
78
-		if( !is_object($_recipient) ) { throw new Exception("no recipient given."); }
77
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
78
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
79 79
 
80 80
 		$this->sender		= $_sender;
81
-		$this->recipient	= $_recipient;
81
+		$this->recipient = $_recipient;
82 82
 		$this->config		= $_config;
83
-		$this->preferences	= $_preferences;
84
-		$this->db			= $GLOBALS['egw']->db;
83
+		$this->preferences = $_preferences;
84
+		$this->db = $GLOBALS['egw']->db;
85 85
 	}
86 86
 
87 87
 	/**
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
 	* @param array $_links
93 93
 	* @param array $_attachments
94 94
 	*/
95
-	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false)
95
+	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
96 96
 	{
97
-		unset($_attachments);	// not used
97
+		unset($_attachments); // not used
98 98
 
99 99
 		$jmessage = array();
100 100
 
101 101
 		// app-message
102
-		if( ($_links != null) && (count($_links) > 0) )
102
+		if (($_links != null) && (count($_links) > 0))
103 103
 		{
104
-			$tlink		= $_links[0];
105
-			$appname	= "";
104
+			$tlink = $_links[0];
105
+			$appname = "";
106 106
 
107
-			if( key_exists('menuaction', $tlink->view) )
107
+			if (key_exists('menuaction', $tlink->view))
108 108
 			{
109 109
 				$tmp = explode(".", $tlink->view['menuaction']);
110 110
 				$appname = $tmp[0];
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 
113 113
 			$link = array();
114 114
 
115
-			foreach( $tlink->view as $pkey => $pvalue )
115
+			foreach ($tlink->view as $pkey => $pvalue)
116 116
 			{
117
-				$link[] = $pkey . '=' . $pvalue;
117
+				$link[] = $pkey.'='.$pvalue;
118 118
 			}
119 119
 
120 120
 			// TODO more links?
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 			.Api\Html::hr()
126 126
 			.$_messages['html'];
127 127
 
128
-		$jmessage['msghtml']	= $message;
129
-		$jmessage['app']		= $appname;
128
+		$jmessage['msghtml'] = $message;
129
+		$jmessage['app'] = $appname;
130 130
 
131 131
 
132
-		$this->save( serialize($jmessage) );
132
+		$this->save(serialize($jmessage));
133 133
 	}
134 134
 
135 135
 	/**
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 
145 145
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
146 146
 		$infos[] = lang('Message from').': '.$sender;
147
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
148
-		return implode($newline,$infos);
147
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
148
+		return implode($newline, $infos);
149 149
 	}
150 150
 
151 151
 	/**
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 	* @param string $_message
155 155
 	* @param array $_user_sessions
156 156
 	*/
157
-	private function save( $_message ) {
158
-		$result = $this->db->insert( self::_notification_table, array(
157
+	private function save($_message) {
158
+		$result = $this->db->insert(self::_notification_table, array(
159 159
 			'account_id'     => $this->recipient->account_id,
160 160
 			'notify_message' => $_message,
161 161
 			'notify_type'	 => self::_type
162
-			), false,__LINE__,__FILE__,self::_appname);
162
+			), false, __LINE__, __FILE__, self::_appname);
163 163
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
164 164
 	}
165 165
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,8 +74,12 @@  discard block
 block discarded – undo
74 74
 	*/
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77
-		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
78
-		if( !is_object($_recipient) ) { throw new Exception("no recipient given."); }
77
+		if( !is_object($_sender) )
78
+		{
79
+throw new Exception("no sender given."); }
80
+		if( !is_object($_recipient) )
81
+		{
82
+throw new Exception("no recipient given."); }
79 83
 
80 84
 		$this->sender		= $_sender;
81 85
 		$this->recipient	= $_recipient;
@@ -138,13 +142,16 @@  discard block
 block discarded – undo
138 142
 	* @param string $_subject
139 143
 	* @return string html rendered info as complete string
140 144
 	*/
141
-	private function render_infos($_subject = false) {
145
+	private function render_infos($_subject = false)
146
+	{
142 147
 		$infos = array();
143 148
 		$newline = "<br />";
144 149
 
145 150
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
146 151
 		$infos[] = lang('Message from').': '.$sender;
147
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
152
+		if(!empty($_subject))
153
+		{
154
+$infos[] = Api\Html::bold($_subject); }
148 155
 		return implode($newline,$infos);
149 156
 	}
150 157
 
@@ -154,12 +161,16 @@  discard block
 block discarded – undo
154 161
 	* @param string $_message
155 162
 	* @param array $_user_sessions
156 163
 	*/
157
-	private function save( $_message ) {
164
+	private function save( $_message )
165
+	{
158 166
 		$result = $this->db->insert( self::_notification_table, array(
159 167
 			'account_id'     => $this->recipient->account_id,
160 168
 			'notify_message' => $_message,
161 169
 			'notify_type'	 => self::_type
162 170
 			), false,__LINE__,__FILE__,self::_appname);
163
-		if ($result === false) throw new Exception("Can't save notification into SQL table");
171
+		if ($result === false)
172
+		{
173
+			throw new Exception("Can't save notification into SQL table");
174
+		}
164 175
 	}
165 176
 }
Please login to merge, or discard this patch.
notifications/inc/class.notifications_popup.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,6 @@
 block discarded – undo
121 121
 	 * saves notification into database so that the client can fetch it from there
122 122
 	 *
123 123
 	 * @param string $_message
124
-	 * @param array $_user_sessions
125 124
 	 */
126 125
 	private function save( $_message ) {
127 126
 		$result = $this->db->insert( self::_notification_table, array(
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
85 85
 		//error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)');
86
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
87
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
87
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
88 88
 		$this->sender = $_sender;
89 89
 		$this->recipient = $_recipient;
90 90
 		$this->config = $_config;
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
104 104
 	{
105
-		unset($_attachments);	// not used
105
+		unset($_attachments); // not used
106 106
 		// Check access log to see if user is still logged in
107
-		if ( !Api\Session::notifications_active($this->recipient->account_id) )
107
+		if (!Api\Session::notifications_active($this->recipient->account_id))
108 108
 		{
109 109
 			throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
110 110
 		}
111 111
 
112
-		$message = 	$this->render_infos($_subject)
112
+		$message = $this->render_infos($_subject)
113 113
 					.Api\Html::hr()
114
-					.(isset($_messages['popup'])&&!empty($_messages['popup'])?$_messages['popup']:$_messages['html'])
114
+					.(isset($_messages['popup']) && !empty($_messages['popup']) ? $_messages['popup'] : $_messages['html'])
115 115
 					.$this->render_links($_links);
116 116
 
117
-		$this->save( $message );
117
+		$this->save($message);
118 118
 	}
119 119
 
120 120
 	/**
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 * @param string $_message
124 124
 	 * @param array $_user_sessions
125 125
 	 */
126
-	private function save( $_message ) {
127
-		$result = $this->db->insert( self::_notification_table, array(
126
+	private function save($_message) {
127
+		$result = $this->db->insert(self::_notification_table, array(
128 128
 			'account_id'     => $this->recipient->account_id,
129 129
 			'notify_message' => $_message,
130 130
 			'notify_type'	 => self::_type
131
-			), false,__LINE__,__FILE__,self::_appname);
131
+			), false, __LINE__, __FILE__, self::_appname);
132 132
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
133 133
 	}
134 134
 
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 	 * @return string html rendered link(s) as complete string with jspopup or a new window
141 141
 	 */
142 142
 	private function render_links($_links = false) {
143
-		if(!is_array($_links) || count($_links) == 0) { return false; }
143
+		if (!is_array($_links) || count($_links) == 0) { return false; }
144 144
 		$newline = "<br />";
145 145
 
146 146
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if(!$link->popup) { $link->view['no_popup'] = 1; }
147
+		foreach ($_links as $link) {
148
+			if (!$link->popup) { $link->view['no_popup'] = 1; }
149 149
 
150 150
 			// do not expose sensitive data
151
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',
151
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '',
152 152
 				Api\Html::link('/index.php', $link->view));
153 153
 			// extract application-icon from menuaction
154
-			if($link->view['menuaction']) {
155
-				$menuaction_arr = explode('.',$link->view['menuaction']);
154
+			if ($link->view['menuaction']) {
155
+				$menuaction_arr = explode('.', $link->view['menuaction']);
156 156
 				$application = $menuaction_arr[0];
157
-				$image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
157
+				$image = $application ? Api\Html::image($application, 'navbar', $link->text, 'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
158 158
 			} else {
159 159
 				$image = '';
160 160
 			}
161
-			if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
161
+			if ($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
162 162
 			{
163 163
 				$data = array(
164 164
 					"data-app = '{$link->app}'",
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 					"data-popup = '{$link->popup}'"
168 168
 				);
169 169
 
170
-				$rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link');
170
+				$rendered_links[] = Api\Html::div($image.$link->text, implode(' ', $data), 'link');
171 171
 			} else {
172
-				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link');
172
+				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>', '', 'link');
173 173
 			}
174 174
 
175 175
 		}
176
-		if(count($rendered_links) > 0) {
177
-			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
176
+		if (count($rendered_links) > 0) {
177
+			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline, $rendered_links);
178 178
 		}
179 179
 	}
180 180
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	 * @param int $height =400 height of the window
188 188
 	 * @return string javascript (using single quotes)
189 189
 	 */
190
-	private function jspopup($link,$target='_blank',$width=750,$height=410)
190
+	private function jspopup($link, $target = '_blank', $width = 750, $height = 410)
191 191
 	{
192
-		if($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
192
+		if ($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
193 193
 		{
194 194
 			return 'window.open('.($link == 'this.href' ? $link : "'".$link."'").','.
195 195
 				($target == 'this.target' ? $target : "'".$target."'").",$width,$height,'yes')";
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 
214 214
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
215 215
 		$infos[] = lang('Message from').': '.$sender;
216
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
217
-		return implode($newline,$infos);
216
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
217
+		return implode($newline, $infos);
218 218
 	}
219 219
 
220 220
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
224 224
 	 */
225 225
 	public static function deleteaccount($settings) {
226
-		$GLOBALS['egw']->db->delete( self::_notification_table, array(
226
+		$GLOBALS['egw']->db->delete(self::_notification_table, array(
227 227
 			'account_id'	=> $settings['account_id']
228
-		),__LINE__,__FILE__,self::_appname);
228
+		), __LINE__, __FILE__, self::_appname);
229 229
 	}
230 230
 }
Please login to merge, or discard this patch.
Braces   +43 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
  * out the table to look if there is a notificaton for this
22 22
  * client. The second stage is done in class.notifications_ajax.inc.php
23 23
  */
24
-class notifications_popup implements notifications_iface {
24
+class notifications_popup implements notifications_iface
25
+{
25 26
 
26 27
 	/**
27 28
 	 * Appname
@@ -81,10 +82,15 @@  discard block
 block discarded – undo
81 82
 	 * @param object $_config
82 83
 	 * @param object $_preferences
83 84
 	 */
84
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
85
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
86
+	{
85 87
 		//error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)');
86
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
87
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
88
+		if(!is_object($_sender))
89
+		{
90
+throw new Exception("no sender given."); }
91
+		if(!is_object($_recipient))
92
+		{
93
+throw new Exception("no recipient given."); }
88 94
 		$this->sender = $_sender;
89 95
 		$this->recipient = $_recipient;
90 96
 		$this->config = $_config;
@@ -123,13 +129,17 @@  discard block
 block discarded – undo
123 129
 	 * @param string $_message
124 130
 	 * @param array $_user_sessions
125 131
 	 */
126
-	private function save( $_message ) {
132
+	private function save( $_message )
133
+	{
127 134
 		$result = $this->db->insert( self::_notification_table, array(
128 135
 			'account_id'     => $this->recipient->account_id,
129 136
 			'notify_message' => $_message,
130 137
 			'notify_type'	 => self::_type
131 138
 			), false,__LINE__,__FILE__,self::_appname);
132
-		if ($result === false) throw new Exception("Can't save notification into SQL table");
139
+		if ($result === false)
140
+		{
141
+			throw new Exception("Can't save notification into SQL table");
142
+		}
133 143
 	}
134 144
 
135 145
 	/**
@@ -139,23 +149,32 @@  discard block
 block discarded – undo
139 149
 	 * @param array $_links
140 150
 	 * @return string html rendered link(s) as complete string with jspopup or a new window
141 151
 	 */
142
-	private function render_links($_links = false) {
143
-		if(!is_array($_links) || count($_links) == 0) { return false; }
152
+	private function render_links($_links = false)
153
+	{
154
+		if(!is_array($_links) || count($_links) == 0)
155
+		{
156
+return false; }
144 157
 		$newline = "<br />";
145 158
 
146 159
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if(!$link->popup) { $link->view['no_popup'] = 1; }
160
+		foreach($_links as $link)
161
+		{
162
+			if(!$link->popup)
163
+			{
164
+$link->view['no_popup'] = 1; }
149 165
 
150 166
 			// do not expose sensitive data
151 167
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',
152 168
 				Api\Html::link('/index.php', $link->view));
153 169
 			// extract application-icon from menuaction
154
-			if($link->view['menuaction']) {
170
+			if($link->view['menuaction'])
171
+			{
155 172
 				$menuaction_arr = explode('.',$link->view['menuaction']);
156 173
 				$application = $menuaction_arr[0];
157 174
 				$image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
158
-			} else {
175
+			}
176
+			else
177
+			{
159 178
 				$image = '';
160 179
 			}
161 180
 			if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
@@ -168,12 +187,15 @@  discard block
 block discarded – undo
168 187
 				);
169 188
 
170 189
 				$rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link');
171
-			} else {
190
+			}
191
+			else
192
+			{
172 193
 				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link');
173 194
 			}
174 195
 
175 196
 		}
176
-		if(count($rendered_links) > 0) {
197
+		if(count($rendered_links) > 0)
198
+		{
177 199
 			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
178 200
 		}
179 201
 	}
@@ -207,13 +229,16 @@  discard block
 block discarded – undo
207 229
 	 * @param string $_subject
208 230
 	 * @return string html rendered info as complete string
209 231
 	 */
210
-	private function render_infos($_subject = false) {
232
+	private function render_infos($_subject = false)
233
+	{
211 234
 		$infos = array();
212 235
 		$newline = "<br />";
213 236
 
214 237
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
215 238
 		$infos[] = lang('Message from').': '.$sender;
216
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
239
+		if(!empty($_subject))
240
+		{
241
+$infos[] = Api\Html::bold($_subject); }
217 242
 		return implode($newline,$infos);
218 243
 	}
219 244
 
@@ -222,7 +247,8 @@  discard block
 block discarded – undo
222 247
 	 *
223 248
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
224 249
 	 */
225
-	public static function deleteaccount($settings) {
250
+	public static function deleteaccount($settings)
251
+	{
226 252
 		$GLOBALS['egw']->db->delete( self::_notification_table, array(
227 253
 			'account_id'	=> $settings['account_id']
228 254
 		),__LINE__,__FILE__,self::_appname);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
 		// Check access log to see if user is still logged in
107 107
 		if ( !Api\Session::notifications_active($this->recipient->account_id) )
108 108
 		{
109
-			throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
109
+			throw new Exception("user {$this->recipient->account_lid} isn't online. Can't send notification via popup");
110 110
 		}
111 111
 
112 112
 		$message = 	$this->render_infos($_subject)
Please login to merge, or discard this patch.
notifications/inc/class.notifications_winpopup.inc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * checks for a valid IPv4-address without CIDR notation
156 156
 	 *
157 157
 	 * @param string $_ip
158
-	 * @return true or false
158
+	 * @return integer or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161 161
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * renders additional info from subject
166 166
 	 *
167 167
 	 * @param string $_subject
168
-	 * @return plain rendered info as complete string
168
+	 * @return string|false rendered info as complete string
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
Please login to merge, or discard this patch.
Braces   +43 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via winpopup.
17 17
  */
18
-class notifications_winpopup implements notifications_iface {
18
+class notifications_winpopup implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -80,10 +81,16 @@  discard block
 block discarded – undo
80 81
 	 * @param object $_config
81 82
 	 * @param object $_preferences
82 83
 	 */
83
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
84
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
85
+	{
86
+		if(!is_object($_sender))
87
+		{
88
+throw new Exception("no sender given."); }
89
+		if(!is_object($_recipient))
90
+		{
91
+throw new Exception("no recipient given."); }
92
+		if(!$this->netbios_command)
93
+		{
87 94
 			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
88 95
 									'Please check var "netbios_command" in winpopup backend '.
89 96
 									'('.EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.notifications_winpopup.inc.php).');
@@ -107,14 +114,20 @@  discard block
 block discarded – undo
107 114
 		unset($_links, $_attachments);	// not used
108 115
 
109 116
 		$user_sessions = array();
110
-		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
111
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
112
-				if($this->valid_ip($session['session_ip'])) {
117
+		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session)
118
+		{
119
+			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain'])
120
+			{
121
+				if($this->valid_ip($session['session_ip']))
122
+				{
113 123
 					$user_sessions[] = $session['session_ip'];
114 124
 				}
115 125
 			}
116 126
 		}
117
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
127
+		if ( empty($user_sessions) )
128
+		{
129
+			throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
130
+		}
118 131
 
119 132
 		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
120 133
 		return true;
@@ -126,13 +139,20 @@  discard block
 block discarded – undo
126 139
 	 * @param string $_message
127 140
 	 * @param array $_user_sessions
128 141
 	 */
129
-	private function send_winpopup( $_message, array $_user_sessions ) {
130
-		foreach($_user_sessions as $user_session) {
142
+	private function send_winpopup( $_message, array $_user_sessions )
143
+	{
144
+		foreach($_user_sessions as $user_session)
145
+		{
131 146
 			$ip_octets=explode(".",$user_session);
132 147
 			// format the ip_octets to 3 digits each
133
-			foreach($ip_octets as $id=>$ip_octet) {
134
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
135
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
148
+			foreach($ip_octets as $id=>$ip_octet)
149
+			{
150
+				if(strlen($ip_octet)==1)
151
+				{
152
+$ip_octets[$id] = '00'.$ip_octet; }
153
+				if(strlen($ip_octet)==2)
154
+				{
155
+$ip_octets[$id] = '0'.$ip_octet; }
136 156
 			}
137 157
 			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138 158
 									'/\[1\]/' => $ip_octets[0],
@@ -145,7 +165,8 @@  discard block
 block discarded – undo
145 165
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
146 166
 			$output = $returncode = null;
147 167
 			exec($command,$output,$returncode);
148
-			if($returncode != 0) {
168
+			if($returncode != 0)
169
+			{
149 170
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
150 171
 			}
151 172
 		}
@@ -157,7 +178,8 @@  discard block
 block discarded – undo
157 178
 	 * @param string $_ip
158 179
 	 * @return true or false
159 180
 	 */
160
-	private function valid_ip($_ip) {
181
+	private function valid_ip($_ip)
182
+	{
161 183
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
162 184
 	}
163 185
 
@@ -167,9 +189,12 @@  discard block
 block discarded – undo
167 189
 	 * @param string $_subject
168 190
 	 * @return plain rendered info as complete string
169 191
 	 */
170
-	private function render_infos($_subject = false) {
192
+	private function render_infos($_subject = false)
193
+	{
171 194
 		$newline = "\n";
172
-		if(!empty($_subject)) { return $_subject.$newline; }
195
+		if(!empty($_subject))
196
+		{
197
+return $_subject.$newline; }
173 198
 		return false;
174 199
 	}
175 200
 }
176 201
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	 * @param object $_preferences
82 82
 	 */
83 83
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
87
-			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
84
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
85
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!$this->netbios_command) {
87
+			throw new Exception('Winpopup plugin not configured yet. Skipped sending notification message. '.
88 88
 									'Please check var "netbios_command" in winpopup backend '.
89
-									'('.EGW_INCLUDE_ROOT. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
89
+									'('.EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.notifications_winpopup.inc.php).');
90 90
 		}
91 91
 		$this->sender = $_sender;
92 92
 		$this->recipient = $_recipient;
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
106 106
 	{
107
-		unset($_links, $_attachments);	// not used
107
+		unset($_links, $_attachments); // not used
108 108
 
109 109
 		$user_sessions = array();
110 110
 		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
111
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
112
-				if($this->valid_ip($session['session_ip'])) {
111
+			if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) {
112
+				if ($this->valid_ip($session['session_ip'])) {
113 113
 					$user_sessions[] = $session['session_ip'];
114 114
 				}
115 115
 			}
116 116
 		}
117
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
117
+		if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
118 118
 
119
-		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
119
+		$this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions);
120 120
 		return true;
121 121
 	}
122 122
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	 * @param string $_message
127 127
 	 * @param array $_user_sessions
128 128
 	 */
129
-	private function send_winpopup( $_message, array $_user_sessions ) {
130
-		foreach($_user_sessions as $user_session) {
131
-			$ip_octets=explode(".",$user_session);
129
+	private function send_winpopup($_message, array $_user_sessions) {
130
+		foreach ($_user_sessions as $user_session) {
131
+			$ip_octets = explode(".", $user_session);
132 132
 			// format the ip_octets to 3 digits each
133
-			foreach($ip_octets as $id=>$ip_octet) {
134
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
135
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
133
+			foreach ($ip_octets as $id=>$ip_octet) {
134
+				if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; }
135
+				if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; }
136 136
 			}
137
-			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
137
+			$placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138 138
 									'/\[1\]/' => $ip_octets[0],
139 139
 									'/\[2\]/' => $ip_octets[1],
140 140
 									'/\[3\]/' => $ip_octets[2],
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 									);
145 145
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
146 146
 			$output = $returncode = null;
147
-			exec($command,$output,$returncode);
148
-			if($returncode != 0) {
147
+			exec($command, $output, $returncode);
148
+			if ($returncode != 0) {
149 149
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
150 150
 			}
151 151
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return true or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161
-		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
161
+		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip);
162 162
 	}
163 163
 
164 164
 	/**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
172
-		if(!empty($_subject)) { return $_subject.$newline; }
172
+		if (!empty($_subject)) { return $_subject.$newline; }
173 173
 		return false;
174 174
 	}
175 175
 }
176 176
\ No newline at end of file
Please login to merge, or discard this patch.