Passed
Pull Request — master (#46)
by Neo
33:01
created
mail/inc/class.mail_acl.inc.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -277,8 +277,6 @@
 block discarded – undo
277 277
 	 * Update ACL rights of a folder or including subfolders for an account(s)
278 278
 	 *
279 279
 	 * @param array $content content including the acl rights
280
-	 * @param Boolean $recursive boolean flag FALSE|TRUE. If it is FALSE, only the folder take in to account, but in case of TRUE
281
-	 *		the mailbox including all its subfolders will be considered.
282 280
 	 * @param string $msg Message
283 281
 	 *
284 282
 	 */
Please login to merge, or discard this patch.
Braces   +28 added lines, -8 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 			//Todo: Implement autocomplete_url function with admin stuffs consideration
98 98
 		}
99 99
 		// Unset the content if folder is changed, in order to read acl rights for new selected folder
100
-		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete'])) unset($content);
100
+		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete']))
101
+		{
102
+			unset($content);
103
+		}
101 104
 
102 105
 		if (!is_array($content))
103 106
 		{
@@ -172,7 +175,9 @@  discard block
 block discarded – undo
172 175
 
173 176
 						//Add new row at the end
174 177
 						if ($content['grid'][count($content['grid'])]['acc_id'])
175
-							array_push($content['grid'], array('acc_id'=>''));
178
+						{
179
+													array_push($content['grid'], array('acc_id'=>''));
180
+						}
176 181
 					}
177 182
 					else
178 183
 					{
@@ -180,7 +185,10 @@  discard block
 block discarded – undo
180 185
 					}
181 186
 					//Send message
182 187
 					Framework::message($msg);
183
-					if ($button == "apply") break;
188
+					if ($button == "apply")
189
+					{
190
+						break;
191
+					}
184 192
 					Framework::window_close();
185 193
 					exit;
186 194
 
@@ -304,8 +312,16 @@  discard block
 block discarded – undo
304 312
 				if ($value[$key] == true)
305 313
 				{
306 314
 					$right = explode("acl_" ,$key);
307
-					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
308
-					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
315
+					if ($right[1] === 'c')
316
+					{
317
+						$right[1] = 'kx';
318
+					}
319
+					// c = kx , rfc 4314
320
+					if ($right[1] === 'd')
321
+					{
322
+						$right[1] = 'et';
323
+					}
324
+					// d = et , rfc 4314
309 325
 					$options['rights'] .=  $right[1];
310 326
 				}
311 327
 			}
@@ -351,7 +367,7 @@  discard block
 block discarded – undo
351 367
 	function retrieve_acl ($mailbox, &$msg)
352 368
 	{
353 369
 		if (($acl = $this->getACL($mailbox)))
354
-		 {
370
+		{
355 371
 			$msg = lang('ACL rights retrieved successfully');
356 372
 			return $acl;
357 373
 		 }
@@ -374,7 +390,10 @@  discard block
 block discarded – undo
374 390
 	function remove_acl($content, &$msg)
375 391
 	{
376 392
 		$row_num = array_keys($content['grid']['delete'],"pressed");
377
-		if ($row_num) $row_num = $row_num[0];
393
+		if ($row_num)
394
+		{
395
+			$row_num = $row_num[0];
396
+		}
378 397
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
379 398
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
380 399
 		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
@@ -514,7 +533,8 @@  discard block
 block discarded – undo
514 533
 		{
515 534
 			$acl = $this->imap->getACL($mailbox);
516 535
 			return $acl;
517
-		} catch (Exception $e) {
536
+		}
537
+		catch (Exception $e) {
518 538
 			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
519 539
 			return false;
520 540
 		}
Please login to merge, or discard this patch.
Spacing   +43 added lines, -44 removed lines patch added patch discarded remove patch
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 */
85 85
 	var $aclRightsAbbrvs = array(
86
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
87
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
88
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
89
-		'ilprsw'	=> array('label'=>'write','title'=>'Allows a user to read and write the maibox, post to it, append messages to it.'),
90
-		'eilprswtk'	=> array('label'=>'write & delete','title'=>'Allows a user to read, write and create folders and mails, post to it, append messages to it and delete messages.'),
91
-		'aeiklprstwx'=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
92
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
86
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
87
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
88
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
89
+		'ilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read and write the maibox, post to it, append messages to it.'),
90
+		'eilprswtk'	=> array('label'=>'write & delete', 'title'=>'Allows a user to read, write and create folders and mails, post to it, append messages to it and delete messages.'),
91
+		'aeiklprstwx'=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
92
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
93 93
 	);
94 94
 
95 95
 	/**
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 	 * @param string $msg = ''
113 113
 	 *
114 114
 	 */
115
-	function edit(array $content=null ,$msg='')
115
+	function edit(array $content = null, $msg = '')
116 116
 	{
117 117
 		$tmpl = new Etemplate('mail.acl');
118 118
 		if (!is_array($content))
119 119
 		{
120
-			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
120
+			$acc_id = $_GET['acc_id'] ? $_GET['acc_id'] : $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
121 121
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
122 122
 			{
123 123
 				Framework::window_close(lang('Permission denied'));
@@ -132,8 +132,7 @@  discard block
 block discarded – undo
132 132
 		$account = Mail\Account::read($acc_id, $account_id);
133 133
 		$this->imap = $account->imapServer(isset($account_id) ? (int)$account_id : false);
134 134
 
135
-		$mailbox = $_GET['mailbox']? base64_decode($_GET['mailbox']):
136
-			preg_replace("/^".$acc_id."::/",'',$content['mailbox'][0]);
135
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : preg_replace("/^".$acc_id."::/", '', $content['mailbox'][0]);
137 136
 		if (empty($mailbox))
138 137
 		{
139 138
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($account_id) : 'INBOX';
@@ -168,14 +167,14 @@  discard block
 block discarded – undo
168 167
 
169 168
 					foreach ($rights as $right)
170 169
 					{
171
-						$content['grid'][$n]['acl_'. $right] = true;
170
+						$content['grid'][$n]['acl_'.$right] = true;
172 171
 					}
173
-					$virtualD = array('e','t');
174
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
175
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
172
+					$virtualD = array('e', 't');
173
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false: true; //c=kx more information rfc4314, Obsolote Rights
174
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false: true; //d=et more information rfc4314, Obsolote Rights
176 175
 
177 176
 					sort($rights);
178
-					$acl_abbrvs = implode('',$rights);
177
+					$acl_abbrvs = implode('', $rights);
179 178
 
180 179
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
181 180
 					{
@@ -216,7 +215,7 @@  discard block
 block discarded – undo
216 215
 				case 'apply':
217 216
 					if ($content)
218 217
 					{
219
-						$validation_err = $this->update_acl($content,$msg);
218
+						$validation_err = $this->update_acl($content, $msg);
220 219
 						if ($validation_err)
221 220
 						{
222 221
 							foreach ($validation_err as &$row)
@@ -247,7 +246,7 @@  discard block
 block discarded – undo
247 246
 					}
248 247
 					else
249 248
 					{
250
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
249
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
251 250
 					}
252 251
 					Framework::message($msg);
253 252
 			}
@@ -256,7 +255,7 @@  discard block
 block discarded – undo
256 255
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
257 256
 
258 257
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
259
-		foreach($content['grid'] as $key => $fields)
258
+		foreach ($content['grid'] as $key => $fields)
260 259
 		{
261 260
 			if (self::_extract_acc_id($fields['acc_id']) == $this->imap->acc_imap_username ||
262 261
 					$this->imap->getMailBoxUserName(self::_extract_acc_id($fields['acc_id'])) == $this->imap->acc_imap_username)
@@ -295,7 +294,7 @@  discard block
 block discarded – undo
295 294
 			));
296 295
 		}
297 296
 
298
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
297
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
299 298
 	}
300 299
 
301 300
 	/**
@@ -314,7 +313,7 @@  discard block
 block discarded – undo
314 313
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
315 314
 
316 315
 		$folders = array();
317
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
316
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
318 317
 		{
319 318
 			if (stripos($folder, $_GET['query']) !== false)
320 319
 			{
@@ -342,7 +341,7 @@  discard block
 block discarded – undo
342 341
 	 * @param string $msg Message
343 342
 	 *
344 343
 	 */
345
-	function update_acl ($content, &$msg)
344
+	function update_acl($content, &$msg)
346 345
 	{
347 346
 		$validator = array();
348 347
 
@@ -358,10 +357,10 @@  discard block
 block discarded – undo
358 357
 			{
359 358
 				if ($value[$key] == true)
360 359
 				{
361
-					$right = explode("acl_" ,$key);
360
+					$right = explode("acl_", $key);
362 361
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
363 362
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
364
-					$options['rights'] .=  $right[1];
363
+					$options['rights'] .= $right[1];
365 364
 				}
366 365
 			}
367 366
 			$username = self::_extract_acc_id($content['grid'][$keys]['acc_id']);
@@ -374,7 +373,7 @@  discard block
 block discarded – undo
374 373
 			if (!empty($username))
375 374
 			{
376 375
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
377
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
376
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
378 377
 				{
379 378
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
380 379
 
@@ -386,7 +385,7 @@  discard block
 block discarded – undo
386 385
 			}
387 386
 			else
388 387
 			{
389
-				if($keys !== count($content['grid']))
388
+				if ($keys !== count($content['grid']))
390 389
 				{
391 390
 					array_push($validator, $keys);
392 391
 					$msg = lang("Could not save the ACL because some names are empty");
@@ -403,7 +402,7 @@  discard block
 block discarded – undo
403 402
 	 * Retrieve Folder ACL rights
404 403
 	 * @todo rights 'c' and 'd' should be fixed
405 404
 	 */
406
-	function retrieve_acl ($mailbox, &$msg)
405
+	function retrieve_acl($mailbox, &$msg)
407 406
 	{
408 407
 		if (($acl = $this->getACL($mailbox)))
409 408
 		 {
@@ -429,34 +428,34 @@  discard block
 block discarded – undo
429 428
 	 */
430 429
 	function remove_acl($content, &$msg)
431 430
 	{
432
-		$row_num = array_keys($content['grid']['delete'],"pressed");
431
+		$row_num = array_keys($content['grid']['delete'], "pressed");
433 432
 		if ($row_num) $row_num = $row_num[0];
434 433
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
435 434
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
436
-		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
435
+		$content['mailbox'] = is_array($content['mailbox']) ? $content['mailbox'][0] : $content['mailbox'];
437 436
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
438 437
 		{
439 438
 			$identifier = $u;
440 439
 		}
441 440
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
442
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
441
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
443 442
 		{
444 443
 			unset($content['grid'][$row_num]);
445 444
 			unset($content['grid']['delete']);
446 445
 			if ($recursive)
447 446
 			{
448
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
447
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
449 448
 			}
450 449
 			else
451 450
 			{
452
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
451
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
453 452
 			}
454 453
 
455 454
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
456 455
 		}
457 456
 		else
458 457
 		{
459
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
458
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
460 459
 			return false;
461 460
 		}
462 461
 	}
@@ -471,7 +470,7 @@  discard block
 block discarded – undo
471 470
 	 *
472 471
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
473 472
 	 */
474
-	function deleteACL ($mailbox, $identifier, $recursive)
473
+	function deleteACL($mailbox, $identifier, $recursive)
475 474
 	{
476 475
 		if ($recursive)
477 476
 		{
@@ -481,7 +480,7 @@  discard block
 block discarded – undo
481 480
 		{
482 481
 			$folders = (array)$mailbox;
483 482
 		}
484
-		foreach($folders as $sbFolders)
483
+		foreach ($folders as $sbFolders)
485 484
 		{
486 485
 			try
487 486
 			{
@@ -489,7 +488,7 @@  discard block
 block discarded – undo
489 488
 			}
490 489
 			catch (Exception $e)
491 490
 			{
492
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ."." .$e->getMessage());
491
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
493 492
 				return false;
494 493
 			}
495 494
 		}
@@ -532,7 +531,7 @@  discard block
 block discarded – undo
532 531
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
533 532
 	 *
534 533
 	 */
535
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
534
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
536 535
 	{
537 536
 		if ($recursive)
538 537
 		{
@@ -542,16 +541,16 @@  discard block
 block discarded – undo
542 541
 		{
543 542
 			$folders = (array)$mailbox;
544 543
 		}
545
-		foreach($folders as $sbFolders)
544
+		foreach ($folders as $sbFolders)
546 545
 		{
547 546
 			try
548 547
 			{
549
-				$this->imap->setACL($sbFolders,$identifier,$options);
548
+				$this->imap->setACL($sbFolders, $identifier, $options);
550 549
 			}
551 550
 			catch (Exception $e)
552 551
 			{
553 552
 				$msg = $e->getMessage();
554
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . "." .$e->getMessage());
553
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
555 554
 				return false;
556 555
 			}
557 556
 		}
@@ -564,14 +563,14 @@  discard block
 block discarded – undo
564 563
 	 * @param String $mailbox folder name that needs to be read
565 564
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
566 565
 	 */
567
-	function getACL ($mailbox)
566
+	function getACL($mailbox)
568 567
 	{
569 568
 		try
570 569
 		{
571 570
 			$acl = $this->imap->getACL($mailbox);
572 571
 			return $acl;
573 572
 		} catch (Exception $e) {
574
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
573
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox.".".$e->getMessage());
575 574
 			return false;
576 575
 		}
577 576
 	}
@@ -583,8 +582,8 @@  discard block
 block discarded – undo
583 582
 	 *
584 583
 	 * @return string returns acc_id in flat format
585 584
 	 */
586
-	private static function _extract_acc_id ($acc_id)
585
+	private static function _extract_acc_id($acc_id)
587 586
 	{
588
-		return is_array($acc_id)?$acc_id[0]:$acc_id;
587
+		return is_array($acc_id) ? $acc_id[0] : $acc_id;
589 588
 	}
590 589
 }
Please login to merge, or discard this patch.
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
 		$account_email =  Api\Accounts::id2name($accountID, 'account_email');
449 462
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
@@ -484,7 +497,10 @@  discard block
 block discarded – undo
484 497
 		$vtmpl = new Etemplate('mail.sieve.vacation');
485 498
 		$vacation = array();
486 499
 
487
-		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
500
+		if (isset($_GET['account_id']))
501
+		{
502
+			$account_id = $preserv['account_id'] = $_GET['account_id'];
503
+		}
488 504
 
489 505
 		if (isset($content['account_id']))
490 506
 		{
@@ -554,7 +570,10 @@  discard block
 block discarded – undo
554 570
 				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
555 571
 				{
556 572
 					$content = $vacation = $vacRules['vacation'];
557
-					if (!empty($profileID)) $content['acc_id'] = $profileID;
573
+					if (!empty($profileID))
574
+					{
575
+						$content['acc_id'] = $profileID;
576
+					}
558 577
 					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
559 578
 					{
560 579
 						$content['addresses'] = $vacRules['aliases'];
@@ -567,7 +586,10 @@  discard block
 block discarded – undo
567 586
 					{
568 587
 						$content['forwards'] = '';
569 588
 					}
570
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
589
+					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text'])
590
+					{
591
+						$content['text'] = $this->mailConfig['default_vacation_text'];
592
+					}
571 593
 					if (strlen(trim($content['text']))==0)
572 594
 					{
573 595
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
@@ -757,7 +779,10 @@  discard block
 block discarded – undo
757 779
 		}
758 780
 		// setting up an async job to enable/disable the vacation message
759 781
 		$async = new Api\Asyncservice();
760
-		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
782
+		if (empty($_vacation['account_id']))
783
+		{
784
+			$_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
785
+		}
761 786
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
762 787
 		$async->delete($async_id);
763 788
 
@@ -1294,7 +1319,10 @@  discard block
 block discarded – undo
1294 1319
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1295 1320
 	{
1296 1321
 		$mailCompose = new mail_compose();
1297
-		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
1322
+		if ($_REQUEST['noPrefixId'])
1323
+		{
1324
+			$_noPrefixId = $_REQUEST['noPrefixId'];
1325
+		}
1298 1326
 		$mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId);
1299 1327
 	}
1300 1328
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 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,25 +439,25 @@  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
 		}
446 446
 		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
447 447
 
448
-		$account_email =  Api\Accounts::id2name($accountID, 'account_email');
448
+		$account_email = Api\Accounts::id2name($accountID, 'account_email');
449 449
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
450
-		$allAliases = $this->account->ident_email !=''?
450
+		$allAliases = $this->account->ident_email != '' ?
451 451
 				// Fix ident_email with no domain part set
452 452
 				array(Mail::fixInvalidAliasAddress($account_email, $this->account->ident_email))
453 453
 				: array();
454 454
 		foreach ($accAllIdentities as &$val)
455 455
 		{
456
-			if ($val['type'] !='default')
456
+			if ($val['type'] != 'default')
457 457
 			{
458 458
 				// if the alias has no domain part set try to add
459 459
 				// default domain extracted from ident_email address
460
-				$allAliases[] =  Mail::fixInvalidAliasAddress($account_email, $val['address']);
460
+				$allAliases[] = Mail::fixInvalidAliasAddress($account_email, $val['address']);
461 461
 			}
462 462
 		}
463 463
 		// try to fix already stored aliases
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param {array} $content
479 479
 	 * @param {string} $msg
480 480
 	 */
481
-	function editVacation($content=null, $msg='')
481
+	function editVacation($content = null, $msg = '')
482 482
 	{
483 483
 		//Instantiate an eTemplate object, representing the sieve.vacation template
484 484
 		$vtmpl = new Etemplate('mail.sieve.vacation');
@@ -491,27 +491,27 @@  discard block
 block discarded – undo
491 491
 			$account_id = $content['account_id'];
492 492
 			$preserv['acc_id'] = $content['acc_id'];
493 493
 		}
494
-		if(isset($account_id) && $this->mail_admin)
494
+		if (isset($account_id) && $this->mail_admin)
495 495
 		{
496
-			foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account)
496
+			foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account)
497 497
 			{
498 498
 				try {
499 499
 					// check if account is valid for multiple users, has admin credentials and sieve enabled
500 500
 					if (Mail\Account::is_multiple($account) &&
501
-						($icServer = $account->imapServer(true)) &&	// check on icServer object, so plugins can overwrite
501
+						($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite
502 502
 						$icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled)
503 503
 					{
504 504
 						$allAccounts[$account->acc_id] = $account->acc_name;
505 505
 						$accounts[$account->acc_id] = $account;
506 506
 					}
507 507
 				}
508
-				catch(Exception $e) {
508
+				catch (Exception $e) {
509 509
 					unset($e);
510 510
 					// ignore broken accounts
511 511
 				}
512 512
 			}
513 513
 
514
-			$profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id'];
514
+			$profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id'];
515 515
 			if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']]))
516 516
 			{
517 517
 				$profileID = $content['acc_id'] = (int)$_GET['acc_id'];
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			$this->is_admin_vac = true;
524 524
 			$preserv['account_id'] = $account_id;
525 525
 		}
526
-		elseif(!is_array($content) && isset($_GET['acc_id']))
526
+		elseif (!is_array($content) && isset($_GET['acc_id']))
527 527
 		{
528 528
 			$this->account = Mail\Account::read($_GET['acc_id']);
529 529
 			$preserv['acc_id'] = $this->account->acc_id;
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
 		if ($icServer->acc_sieve_enabled)
540 540
 		{
541 541
 			$vacRules = $this->getVacation($account_id);
542
-			if ($vacRules['vacation']===false)
542
+			if ($vacRules['vacation'] === false)
543 543
 			{
544 544
 				$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
545
-					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);
546
-				$content['hideIfSieveDisabled']='mail_DisplayNone';
545
+					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);
546
+				$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
547 547
 			}
548 548
 			else
549 549
 			{
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
 				{
552 552
 					$ByDate = array('by_date' => lang('By date'));
553 553
 				}
554
-				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
554
+				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date'))))
555 555
 				{
556 556
 					$content = $vacation = $vacRules['vacation'];
557 557
 					if (!empty($profileID)) $content['acc_id'] = $profileID;
558
-					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
558
+					if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '')
559 559
 					{
560 560
 						$content['addresses'] = $vacRules['aliases'];
561 561
 					}
562 562
 					if (!empty($vacation['forwards']))
563 563
 					{
564
-						$content['forwards'] = explode(",",$vacation['forwards']);
564
+						$content['forwards'] = explode(",", $vacation['forwards']);
565 565
 					}
566 566
 					else
567 567
 					{
568 568
 						$content['forwards'] = '';
569 569
 					}
570
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
571
-					if (strlen(trim($content['text']))==0)
570
+					if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
571
+					if (strlen(trim($content['text'])) == 0)
572 572
 					{
573 573
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
574 574
 						Framework::refresh_opener($msg, 'mail');
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 					list($button) = @each($content['button']);
587 587
 					unset ($content['button']);
588 588
 
589
-					switch($button)
589
+					switch ($button)
590 590
 					{
591 591
 						case 'save':
592 592
 						case 'apply':
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 								$newVacation = $content;
605 605
 
606 606
 								if (empty($this->mailConfig['prefpreventforwarding']) ||
607
-									$this->mailConfig['prefpreventforwarding'] == 0 )
607
+									$this->mailConfig['prefpreventforwarding'] == 0)
608 608
 								{
609 609
 									$content['forwards'] = self::strip_rfc882_addresses($content['forwards']);
610 610
 									$newVacation['forwards'] = implode(',', $content['forwards']);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 									unset($newVacation ['forwards']);
615 615
 								}
616 616
 
617
-								if (!in_array($newVacation['status'],array('on','off','by_date')))
617
+								if (!in_array($newVacation['status'], array('on', 'off', 'by_date')))
618 618
 								{
619 619
 									$newVacation['status'] = 'off';
620 620
 								}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 										self::strip_rfc882_addresses($content['addresses']);
627 627
 								}
628 628
 
629
-								if($this->checkRule($newVacation,$checkAddresses))
629
+								if ($this->checkRule($newVacation, $checkAddresses))
630 630
 								{
631 631
 									if (isset($account_id) && $this->mail_admin)
632 632
 									{
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
 
640 640
 									if (!$resSetvac)
641 641
 									{
642
-										$msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error;
642
+										$msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error;
643 643
 										break;
644 644
 									}
645 645
 									// schedule job to switch message on/off, if request and not already in past
646 646
 									else
647 647
 									{
648
-										if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
648
+										if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() ||
649 649
 											$vacRules && $vacRules['vacation']['status'] == 'by_date')
650 650
 										{
651 651
 											self::setAsyncJob($newVacation);
@@ -653,29 +653,29 @@  discard block
 block discarded – undo
653 653
 										//Reset vacationNotice cache which is used in mail_ui get_rows
654 654
 										if (isset($account_id) && $this->mail_admin)
655 655
 										{
656
-											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
656
+											$account_lid = Api\Accounts::id2name($account_id, 'account_lid');
657 657
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
658 658
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
659
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
659
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations);
660 660
 										}
661 661
 										else
662 662
 										{
663 663
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
664 664
 											//error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations));
665
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
665
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
666 666
 										}
667 667
 										$msg = lang('Vacation notice sucessfully updated.');
668 668
 									}
669 669
 								}
670 670
 								else
671 671
 								{
672
-									$msg .= implode("\n",$this->errorStack);
672
+									$msg .= implode("\n", $this->errorStack);
673 673
 								}
674 674
 								// refresh vacationNotice on index
675 675
 								$response = Api\Json\Response::get();
676
-								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
676
+								$response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId);
677 677
 								Framework::refresh_opener($msg, 'mail');
678
-								if ($button === 'apply' || $icServer->error !=="")
678
+								if ($button === 'apply' || $icServer->error !== "")
679 679
 								{
680 680
 									break;
681 681
 								}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 						'on' => lang('Active'),
692 692
 						'off' => lang('Deactive'),
693 693
 					),
694
-					'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']),
694
+					'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']),
695 695
 				);
696 696
 				if (!isset($account_id))
697 697
 				{
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
 		}
716 716
 		else
717 717
 		{
718
-			$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);
719
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
718
+			$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);
719
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
720 720
 		}
721
-		$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);
721
+		$vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2);
722 722
 	}
723 723
 
724 724
 	/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	static function strip_rfc882_addresses($_addresses)
733 733
 	{
734 734
 		$addresses = array();
735
-		foreach(Mail::parseAddressList($_addresses) as $addr)
735
+		foreach (Mail::parseAddressList($_addresses) as $addr)
736 736
 		{
737 737
 			if ($addr->valid)
738 738
 			{
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes
750 750
 	 * @return  void
751 751
 	 */
752
-	static function setAsyncJob (array $_vacation, $_reschedule=false)
752
+	static function setAsyncJob(array $_vacation, $_reschedule = false)
753 753
 	{
754 754
 		if (!($_vacation['acc_id'] > 0))
755 755
 		{
@@ -761,19 +761,19 @@  discard block
 block discarded – undo
761 761
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
762 762
 		$async->delete($async_id);
763 763
 
764
-		$end_date = $_vacation['end_date'] + 24*3600;   // end-date is inclusive, so we have to add 24h
764
+		$end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h
765 765
 		if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
766 766
 		{
767 767
 			$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
768
-			$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
768
+			$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
769 769
 		}
770 770
 		if ($_reschedule)
771 771
 		{
772
-			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
772
+			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5;
773 773
 			// only try to reschedule for 2 days max
774 774
 			if ($_vacation['rescheduled'] <= 2 * 24 * 60)
775 775
 			{
776
-				$time = time() + 60*($_vacation['rescheduled']);
776
+				$time = time() + 60 * ($_vacation['rescheduled']);
777 777
 				unset($_vacation['next']);
778 778
 				unset($_vacation['times']);
779 779
 				$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		}
810 810
 		catch (Exception $e) {
811 811
 			error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
812
-			self::setAsyncJob($_vacation, true);	// reschedule
812
+			self::setAsyncJob($_vacation, true); // reschedule
813 813
 			$ret = false;
814 814
 		}
815 815
 
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 *
825 825
 	 * @return boolean
826 826
 	 */
827
-	function checkRule($_vacation,$_checkAddresses=true)
827
+	function checkRule($_vacation, $_checkAddresses = true)
828 828
 	{
829 829
 		$this->errorStack = array();
830 830
 
@@ -838,12 +838,12 @@  discard block
 block discarded – undo
838 838
 			$this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!';
839 839
 		}
840 840
 
841
-		if(is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
841
+		if (is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
842 842
 		{
843
-			$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
843
+			$regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
844 844
 			foreach ($_vacation['addresses'] as $addr)
845 845
 			{
846
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
846
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
847 847
 				{
848 848
 					$this->errorStack['addresses'] = lang('One address is not valid').'!';
849 849
 				}
@@ -859,23 +859,23 @@  discard block
 block discarded – undo
859 859
 			{
860 860
 				$this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!');
861 861
 			}
862
-			elseif($_vacation['start_date'] > $_vacation['end_date'])
862
+			elseif ($_vacation['start_date'] > $_vacation['end_date'])
863 863
 			{
864 864
 				$this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!');
865 865
 			}
866 866
 		}
867 867
 		if ($_vacation['forwards'])
868 868
 		{
869
-			foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr)
869
+			foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr)
870 870
 			{
871
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
871
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
872 872
 				{
873 873
 					$this->errorStack['forwards'] = lang('One address is not valid'.'!');
874 874
 				}
875 875
 			}
876 876
 		}
877 877
 		//error_log(__METHOD__. array2string($this->errorStack));
878
-		if(count($this->errorStack) == 0)
878
+		if (count($this->errorStack) == 0)
879 879
 		{
880 880
 			return true;
881 881
 		}
@@ -896,14 +896,14 @@  discard block
 block discarded – undo
896 896
 
897 897
 		foreach ($orders as $keys => $val)
898 898
 		{
899
-			$orders[$keys] = $val -1;
899
+			$orders[$keys] = $val - 1;
900 900
 		}
901 901
 
902 902
 		$this->getRules(null);
903 903
 
904 904
 		$newrules = $this->rules;
905 905
 
906
-		foreach($orders as $keys => $ruleID)
906
+		foreach ($orders as $keys => $ruleID)
907 907
 		{
908 908
 			$newrules[$keys] = $this->rules[$ruleID];
909 909
 		}
@@ -932,24 +932,24 @@  discard block
 block discarded – undo
932 932
 		switch ($action)
933 933
 		{
934 934
 			case 'delete':
935
-				if ($checked === count($this->rules)-1)
935
+				if ($checked === count($this->rules) - 1)
936 936
 				{
937
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!');
937
+					$msg = lang('rule with priority ').$checked.lang(' deleted!');
938 938
 				}
939 939
 				else
940 940
 				{
941 941
 
942
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked);
942
+					$msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked);
943 943
 				}
944 944
 				unset($this->rules[$checked]);
945 945
 				$this->rules = array_values($this->rules);
946 946
 				break;
947 947
 			case 'enable':
948
-				$msg = lang('rule with priority ') . $checked . lang(' enabled!');
948
+				$msg = lang('rule with priority ').$checked.lang(' enabled!');
949 949
 				$this->rules[$checked][status] = 'ENABLED';
950 950
 				break;
951 951
 			case 'disable':
952
-				$msg = lang('rule with priority ') . $checked . lang(' disabled!');
952
+				$msg = lang('rule with priority ').$checked.lang(' disabled!');
953 953
 				$this->rules[$checked][status] = 'DISABLED';
954 954
 				break;
955 955
 			case 'move':
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 
962 962
 		$response = Api\Json\Response::get();
963 963
 
964
-		if($result)
964
+		if ($result)
965 965
 		{
966 966
 			$response->message($result);
967 967
 			return;
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
 	 */
980 980
 	function buildRule($rule)
981 981
 	{
982
-		$andor = ' '. lang('and') .' ';
982
+		$andor = ' '.lang('and').' ';
983 983
 		$started = 0;
984 984
 		if ($rule['anyof'])
985 985
 		{
986
-			$andor = ' '. lang('or') .' ';
986
+			$andor = ' '.lang('or').' ';
987 987
 		}
988 988
 		$complete = lang('IF').' ';
989 989
 		if ($rule['unconditional'])
@@ -992,8 +992,8 @@  discard block
 block discarded – undo
992 992
 		}
993 993
 		if ($rule['from'])
994 994
 		{
995
-			$match = $this->setMatchType($rule['from'],$rule['regexp']);
996
-			$complete .= "'From:' " . $match . " '" . $rule['from'] . "'";
995
+			$match = $this->setMatchType($rule['from'], $rule['regexp']);
996
+			$complete .= "'From:' ".$match." '".$rule['from']."'";
997 997
 			$started = 1;
998 998
 		}
999 999
 		if ($rule['to'])
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 			{
1003 1003
 				$complete .= $andor;
1004 1004
 			}
1005
-			$match = $this->setMatchType($rule['to'],$rule['regexp']);
1006
-			$complete .= "'To:' " . $match . " '" . $rule['to'] . "'";
1005
+			$match = $this->setMatchType($rule['to'], $rule['regexp']);
1006
+			$complete .= "'To:' ".$match." '".$rule['to']."'";
1007 1007
 			$started = 1;
1008 1008
 		}
1009 1009
 		if ($rule['subject'])
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 			{
1013 1013
 				$complete .= $andor;
1014 1014
 			}
1015
-			$match = $this->setMatchType($rule['subject'],$rule['regexp']);
1016
-			$complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'";
1015
+			$match = $this->setMatchType($rule['subject'], $rule['regexp']);
1016
+			$complete .= "'Subject:' ".$match." '".$rule['subject']."'";
1017 1017
 			$started = 1;
1018 1018
 		}
1019 1019
 		if ($rule['field'] && $rule['field_val'])
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 			{
1023 1023
 				$complete .= $andor;
1024 1024
 			}
1025
-			$match = $this->setMatchType($rule['field_val'],$rule['regexp']);
1026
-			$complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'";
1025
+			$match = $this->setMatchType($rule['field_val'], $rule['regexp']);
1026
+			$complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'";
1027 1027
 			$started = 1;
1028 1028
 		}
1029 1029
 		if ($rule['size'])
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			{
1038 1038
 				$complete .= $andor;
1039 1039
 			}
1040
-			$complete .= "message " . $xthan . $rule['size'] . "KB'";
1040
+			$complete .= "message ".$xthan.$rule['size']."KB'";
1041 1041
 			$started = 1;
1042 1042
 		}
1043 1043
 		if (!empty($rule['field_bodytransform']))
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 			{
1047 1047
 				$newruletext .= ", ";
1048 1048
 			}
1049
-			$btransform	= " :raw ";
1049
+			$btransform = " :raw ";
1050 1050
 			$match = ' :contains';
1051 1051
 			if ($rule['bodytransform'])
1052 1052
 			{
@@ -1060,11 +1060,11 @@  discard block
 block discarded – undo
1060 1060
 			{
1061 1061
 				$match = ':regex';
1062 1062
 			}
1063
-			$complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\"";
1063
+			$complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\"";
1064 1064
 			$started = 1;
1065 1065
 
1066 1066
 		}
1067
-		if ($rule['ctype']!= '0' && !empty($rule['ctype']))
1067
+		if ($rule['ctype'] != '0' && !empty($rule['ctype']))
1068 1068
 		{
1069 1069
 			if ($started)
1070 1070
 			{
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 			{
1077 1077
 				$ctype_subtype = "/";
1078 1078
 			}
1079
-			$complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\"";
1079
+			$complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\"";
1080 1080
 			$started = 1;
1081 1081
 			//error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array));
1082 1082
 		}
@@ -1084,19 +1084,19 @@  discard block
 block discarded – undo
1084 1084
 		{
1085 1085
 			$complete .= ' '.lang('THEN').' ';
1086 1086
 		}
1087
-		if (preg_match("/folder/i",$rule['action']))
1087
+		if (preg_match("/folder/i", $rule['action']))
1088 1088
 		{
1089
-			$complete .= lang('file into')." '" . $rule['action_arg'] . "';";
1089
+			$complete .= lang('file into')." '".$rule['action_arg']."';";
1090 1090
 		}
1091
-		if (preg_match("/reject/i",$rule['action']))
1091
+		if (preg_match("/reject/i", $rule['action']))
1092 1092
 		{
1093
-			$complete .= lang('reject with')." '" . $rule['action_arg'] . "'.";
1093
+			$complete .= lang('reject with')." '".$rule['action_arg']."'.";
1094 1094
 		}
1095
-		if (preg_match("/address/i",$rule['action']))
1095
+		if (preg_match("/address/i", $rule['action']))
1096 1096
 		{
1097
-			$complete .= lang('forward to').' ' . $rule['action_arg'] .'.';
1097
+			$complete .= lang('forward to').' '.$rule['action_arg'].'.';
1098 1098
 		}
1099
-		if (preg_match("/discard/i",$rule['action']))
1099
+		if (preg_match("/discard/i", $rule['action']))
1100 1100
 		{
1101 1101
 			$complete .= lang('discard').'.';
1102 1102
 		}
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 	 * @param {string} $regex regular expresion as pattern to be matched
1119 1119
 	 * @return {string} return the type
1120 1120
 	 */
1121
-	function setMatchType (&$matchstr, $regex = false)
1121
+	function setMatchType(&$matchstr, $regex = false)
1122 1122
 	{
1123 1123
 		$match = lang('contains');
1124 1124
 		if (preg_match("/^\s*!/", $matchstr))
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 		}
1144 1144
 		if ($regex && preg_match("/^\s*\\\\!/", $matchstr))
1145 1145
 		{
1146
-			$matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr);
1146
+			$matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr);
1147 1147
 		}
1148 1148
 		else
1149 1149
 		{
1150
-			$matchstr = preg_replace("/^\s*!/","",$matchstr);
1150
+			$matchstr = preg_replace("/^\s*!/", "", $matchstr);
1151 1151
 		}
1152 1152
 		return $match;
1153 1153
 	}
@@ -1157,9 +1157,9 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	function saveSessionData()
1159 1159
 	{
1160
-		$sessionData['sieve_rules']		= $this->rules;
1160
+		$sessionData['sieve_rules'] = $this->rules;
1161 1161
 		$sessionData['sieve_rulesByID'] = $this->rulesByID;
1162
-		$sessionData['sieve_scriptToEdit']	= $this->scriptToEdit;
1162
+		$sessionData['sieve_scriptToEdit'] = $this->scriptToEdit;
1163 1163
 		Api\Cache::setSession(__CLASS__, 'sieve_session_data', $sessionData);
1164 1164
 	}
1165 1165
 
@@ -1185,15 +1185,15 @@  discard block
 block discarded – undo
1185 1185
 	{
1186 1186
 		try {
1187 1187
 			$this->account->imapServer()->retrieveRules();
1188
-			$this->rules	= $this->account->imapServer()->getRules();
1188
+			$this->rules = $this->account->imapServer()->getRules();
1189 1189
 			$this->rulesByID = $this->rules[$ruleID];
1190
-			$this->vacation	= $this->account->imapServer()->getVacation();
1190
+			$this->vacation = $this->account->imapServer()->getVacation();
1191 1191
 		}
1192
-		catch(Exception $e) {
1192
+		catch (Exception $e) {
1193 1193
 			error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details);
1194
-			$this->rules	= array();
1194
+			$this->rules = array();
1195 1195
 			$this->rulesByID = array();
1196
-			$this->vacation	= array();
1196
+			$this->vacation = array();
1197 1197
 			return false;
1198 1198
 		}
1199 1199
 		return true;
@@ -1205,9 +1205,9 @@  discard block
 block discarded – undo
1205 1205
 	function restoreSessionData()
1206 1206
 	{
1207 1207
 		$sessionData = Api\Cache::getSession(__CLASS__, 'sieve_session_data');
1208
-		$this->rules		= $sessionData['sieve_rules'];
1208
+		$this->rules = $sessionData['sieve_rules'];
1209 1209
 		$this->rulesByID = $sessionData['sieve_rulesByID'];
1210
-		$this->scriptToEdit	= $sessionData['sieve_scriptToEdit'];
1210
+		$this->scriptToEdit = $sessionData['sieve_scriptToEdit'];
1211 1211
 	}
1212 1212
 
1213 1213
 	/**
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
 		$rows = array();
1222 1222
 		$this->getRules(null);
1223 1223
 
1224
-		if (is_array($this->rules) && !empty($this->rules) )
1224
+		if (is_array($this->rules) && !empty($this->rules))
1225 1225
 		{
1226 1226
 			$rows = $this->rules;
1227 1227
 
1228
-			foreach ($rows as &$row )
1228
+			foreach ($rows as &$row)
1229 1229
 			{
1230 1230
 				$row['rules'] = $this->buildRule($row);
1231
-				$row['ruleID'] =(string)(($row['priority'] -1) / 2 );
1231
+				$row['ruleID'] = (string)(($row['priority'] - 1) / 2);
1232 1232
 				if ($row ['status'] === 'DISABLED')
1233 1233
 				{
1234 1234
 					$row['class'] = 'mail_sieve_DISABLED';
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 			return false;
1242 1242
 		}
1243 1243
 		// Shift one down, because in grid the first row is reserved for header
1244
-		array_unshift($rows,array(''=> ''));
1244
+		array_unshift($rows, array(''=> ''));
1245 1245
 		return $rows;
1246 1246
 	}
1247 1247
 
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 	 */
1253 1253
 	private function get_actions()
1254 1254
 	{
1255
-		$actions =array(
1255
+		$actions = array(
1256 1256
 
1257 1257
 			'edit' => array(
1258 1258
 				'caption' => 'Edit',
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 	 * @param int $_mailaccountToSearch
1292 1292
 	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1293 1293
 	 */
1294
-	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1294
+	function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false)
1295 1295
 	{
1296 1296
 		$mailCompose = new mail_compose();
1297 1297
 		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.
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.
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
 		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'));
172 172
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
173 173
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			{
180 180
 				$this->ui->changeProfile($_profileID);
181 181
 			} catch (Exception $ex) {
182
-				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
182
+				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
183 183
 			}
184 184
 		}
185 185
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
192 192
 			{
193 193
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
194
-				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
194
+				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly);
195 195
 
196 196
 				$childrenNode = array();
197 197
 				foreach ($folders as &$node)
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 					$nodeData = Mail::pathToFolderData($nodeId, $node['delimiter']);
201 201
 					$childrenNode[] = array(
202 202
 						Tree::ID=> $nodeId,
203
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node),
203
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ?false:self::nodeHasChildren($node),
204 204
 						Tree::CHILDREN =>array(),
205 205
 						Tree::LABEL => $nodeData['text'],
206 206
 						Tree::TOOLTIP => $nodeData['tooltip'],
207 207
 						Tree::IMAGE_LEAF => self::$leafImages['folderLeaf'],
208 208
 						Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'],
209 209
 						Tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClosed'],
210
-						Tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false,
210
+						Tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false,
211 211
 						'parent' => $_parent
212 212
 					);
213 213
 				}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 				}
228 228
 
229 229
 				//List of folders
230
-				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, false);
230
+				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, false);
231 231
 
232 232
 				// User defined folders based on account
233 233
 				$definedFolders = array(
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 
249 249
 					$data = array(
250 250
 						Tree::ID=>$_profileID.self::DELIMITER.$folder['MAILBOX'],
251
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder),
251
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ?false:self::nodeHasChildren($folder),
252 252
 						Tree::CHILDREN =>array(),
253 253
 						Tree::LABEL =>lang($folder['MAILBOX']),
254
-						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0,
254
+						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0,
255 255
 						Tree::TOOLTIP => lang($folder['MAILBOX']),
256
-						Tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false,
256
+						Tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false,
257 257
 						Tree::NOCHECKBOX => 0,
258
-						'parent' => $parent?$_profileID.self::DELIMITER.implode($folder['delimiter'], $parent):$_profileID,
258
+						'parent' => $parent ? $_profileID.self::DELIMITER.implode($folder['delimiter'], $parent) : $_profileID,
259 259
 						'path' => $path,
260 260
 						'folderarray' => $folder
261 261
 					);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		catch (Exception $ex) // Catch exceptions
294 294
 		{
295 295
 			//mail_ui::callWizard($ex->getMessage(), false, 'error');
296
-			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
296
+			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
297 297
 		}
298 298
 
299 299
 		return $tree;
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
 	 *					as clearance for access may be limited to a single branch-node of a tree
311 311
 	 * @return void
312 312
 	 */
313
-	static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array())
313
+	static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array())
314 314
 	{
315 315
 		//error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
316 316
 		$components = $data['path'];
317
-		array_pop($components);	// remove own name
317
+		array_pop($components); // remove own name
318 318
 
319 319
 		$insert = &$out;
320 320
 		$parents = array();
321
-		foreach($components as $component)
321
+		foreach ($components as $component)
322 322
 		{
323
-			if (count($parents)>1)
323
+			if (count($parents) > 1)
324 324
 			{
325
-				$helper = array_slice($parents,1,null,true);
325
+				$helper = array_slice($parents, 1, null, true);
326 326
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
327 327
 				if ($parent) $parent .= $del;
328 328
 			}
@@ -345,21 +345,21 @@  discard block
 block discarded – undo
345 345
 				{
346 346
 					// if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent
347 347
 					// we want to create the node in question as we meet the above considerations
348
-					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
348
+					if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::DELIMITER.$nsp['prefix']) === 0)
349 349
 					{
350 350
 						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
351
-						$break=false;
351
+						$break = false;
352 352
 					}
353 353
 				}
354 354
 				if ($break) break;
355 355
 			}
356 356
 			if ($insert['item'])
357 357
 			{
358
-				foreach($insert['item'] as &$item)
358
+				foreach ($insert['item'] as &$item)
359 359
 				{
360 360
 					if ($item['id'] == $parent.$component)
361 361
 					{
362
-						$insert =& $item;
362
+						$insert = & $item;
363 363
 						break;
364 364
 					}
365 365
 				}
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 						'im2' => self::$leafImages["folderNoSelectClosed"],
378 378
 						'tooltip' => lang('no access')
379 379
 					);
380
-					$insert['item'][] =& $item;
381
-					$insert =& $item;
380
+					$insert['item'][] = & $item;
381
+					$insert = & $item;
382 382
 				}
383 383
 				else
384 384
 				{
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 					$data[Tree::IMAGE_FOLDER_OPEN] =
412 412
 					$data [Tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png";
413 413
 			}
414
-			elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false)
414
+			elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false)
415 415
 			{
416 416
 				$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
417 417
 				$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@@ -453,20 +453,20 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return array an array of baseNodes of accounts
455 455
 	 */
456
-	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 )
456
+	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0)
457 457
 	{
458 458
 		$roots = array(Tree::ID => 0, Tree::CHILDREN => array());
459 459
 
460
-		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
460
+		foreach (Mail\Account::search(true, false) as $acc_id => $accObj)
461 461
 		{
462
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
463
-			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
462
+			if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue;
463
+			$identity = Mail\Account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']);
464 464
 			// Open top level folders for active account
465
-			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
465
+			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0;
466 466
 
467 467
 			$baseNode = array(
468 468
 							Tree::ID=> (string)$acc_id,
469
-							Tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity),
469
+							Tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity),
470 470
 							Tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity),
471 471
 							Tree::IMAGE_LEAF => self::$leafImages['folderAccount'],
472 472
 							Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'],
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
 							Tree::CHILDREN => array(), // dynamic loading on unfold
476 476
 							Tree::AUTOLOAD_CHILDREN => true,
477 477
 							'parent' => '',
478
-							Tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount,
478
+							Tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount,
479 479
 							// mark on account if Sieve is enabled
480 480
 							'data' => array(
481 481
 										'sieve' => $accObj->imapServer()->acc_sieve_enabled,
482
-										'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
483
-										'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
482
+										'spamfolder'=> $accObj->imapServer()->acc_folder_junk && (strtolower($accObj->imapServer()->acc_folder_junk) != 'none') ?true:false,
483
+										'archivefolder'=> $accObj->imapServer()->acc_folder_archive && (strtolower($accObj->imapServer()->acc_folder_archive) != 'none') ?true:false
484 484
 									),
485 485
 							Tree::NOCHECKBOX  => $_noCheckbox
486 486
 			);
487
-			self::setOutStructure($baseNode, $roots,self::DELIMITER);
487
+			self::setOutStructure($baseNode, $roots, self::DELIMITER);
488 488
 		}
489 489
 		return $roots;
490 490
 	}
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
504 504
 	 * @return type an array of tree
505 505
 	 */
506
-	function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false)
506
+	function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false)
507 507
 	{
508 508
 		$tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo);
509
-		$branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo);
509
+		$branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo);
510 510
 		foreach ($tree[Tree::CHILDREN] as &$account)
511 511
 		{
512 512
 			if ($account[Tree::ID] == $_profileID)
513 513
 			{
514
-				$account = array_merge($account , $branches);
514
+				$account = array_merge($account, $branches);
515 515
 			}
516 516
 		}
517 517
 		return $tree;
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   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 */
187 187
 	public function __construct() {
188
-		$this->config = (object) Api\Config::read(self::_appname);
188
+		$this->config = (object)Api\Config::read(self::_appname);
189 189
 	}
190 190
 
191 191
 	/**
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param boolean $reset =false true: reset all errors
195 195
 	 * @return array
196 196
 	 */
197
-	public static function errors($reset=false)
197
+	public static function errors($reset = false)
198 198
 	{
199 199
 		$ret = self::$errors;
200 200
 		if ($reset) self::$errors = array();
@@ -209,19 +209,19 @@  discard block
 block discarded – undo
209 209
 	 * it's an int with the account id or the e-mail address of a non-eGW user
210 210
 	 */
211 211
 	public function set_sender($_sender) {
212
-		if(is_object($_sender)) {
212
+		if (is_object($_sender)) {
213 213
 			$this->sender = $_sender;
214 214
 			return true;
215 215
 		} else {
216 216
 			// no object atm, we have to handle this and make a pseudo-object
217
-			if(is_numeric($_sender)) {
218
-				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
217
+			if (is_numeric($_sender)) {
218
+				$this->sender = (object)$GLOBALS['egw']->accounts->read($_sender);
219 219
 				return true;
220 220
 			}
221
-			if(is_string($_sender) && strpos($_sender,'@')) {
222
-				$this->sender = (object) array (
223
-									'account_email' => $this->get_addresspart($_sender,'email'),
224
-									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
221
+			if (is_string($_sender) && strpos($_sender, '@')) {
222
+				$this->sender = (object)array(
223
+									'account_email' => $this->get_addresspart($_sender, 'email'),
224
+									'account_fullname' => $this->get_addresspart($_sender, 'fullname'),
225 225
 									);
226 226
 				return true;
227 227
 			}
@@ -251,19 +251,19 @@  discard block
 block discarded – undo
251 251
 	 * it's an int with the account id or the e-mail address of a non-eGW user
252 252
 	 */
253 253
 	public function add_receiver($_receiver) {
254
-		if(is_object($_receiver)) {
254
+		if (is_object($_receiver)) {
255 255
 			$this->receivers[] = $_receiver;
256 256
 			return true;
257 257
 		} else {
258 258
 			// no object atm, we have to handle this and make a pseudo-object
259
-			if(is_numeric($_receiver)) {
260
-				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
259
+			if (is_numeric($_receiver)) {
260
+				$this->receivers[] = (object)$GLOBALS['egw']->accounts->read($_receiver);
261 261
 				return true;
262 262
 			}
263
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
264
-				$this->receivers[] = (object) array (
265
-									'account_email' => $this->get_addresspart($_receiver,'email'),
266
-									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
263
+			if (is_string($_receiver) && strpos($_receiver, '@')) {
264
+				$this->receivers[] = (object)array(
265
+									'account_email' => $this->get_addresspart($_receiver, 'email'),
266
+									'account_fullname' => $this->get_addresspart($_receiver, 'fullname'),
267 267
 									);
268 268
 				return true;
269 269
 			}
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 	 * @param string $_type Type of message, 'plain' or 'html'
305 305
 	 */
306 306
 	public function set_message($_message, $_type = false) {
307
-		if(!$_type)
307
+		if (!$_type)
308 308
 		{
309 309
 			$_type = strlen($_message) == strlen(strip_tags($_message)) ? 'plain' : 'html';
310 310
 		}
311
-		if($_type == 'plain') {
311
+		if ($_type == 'plain') {
312 312
 			$this->message_plain = $_message;
313 313
 		} else {
314 314
 			$this->message_html = $_message;
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function set_popupmessage($_message) {
328 328
 		//popup requires html
329
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
329
+		if (strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
330 330
 		$this->message_popup = $_message;
331 331
 		return true;
332 332
 	}
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function set_links(array $_links) {
340 340
 		$this->links = array(); // clear array if set
341
-		foreach($_links as $link) {
342
-			if(is_array($link)) {
343
-				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
341
+		foreach ($_links as $link) {
342
+			if (is_array($link)) {
343
+				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'], $link['id']);
344 344
 			}
345 345
 		}
346 346
 		return true;
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 */
354 354
 	public function set_popuplinks(array $_links) {
355 355
 		$this->popup_links = array(); // clear array if set
356
-		foreach($_links as $link) {
357
-			if(is_array($link)) {
356
+		foreach ($_links as $link) {
357
+			if (is_array($link)) {
358 358
 				$this->add_popuplink($link['text'], $link['view'], $link['popup'], $link['app']);
359 359
 			}
360 360
 		}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
372 372
 	 */
373 373
 	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
374
-		if(!$_view || !$_text) { return false; }
374
+		if (!$_view || !$_text) { return false; }
375 375
 		$this->links[] = (object)array(
376 376
 			'text'	=> $_text,
377 377
 			'view'	=> $_view,
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 * @param string $_app application name
392 392
 	 */
393 393
 	public function add_popuplink($_text, $_view, $_popup = false, $_app = '') {
394
-		if(!$_view || !$_text) { return false; }
394
+		if (!$_view || !$_text) { return false; }
395 395
 		$this->popup_links[] = (object)array(
396 396
 										'text'	=> $_text,
397 397
 										'view'	=> $_view,
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 */
409 409
 	public function set_attachments(array $_attachments) {
410 410
 		$this->attachments = array(); // clear array if set
411
-		foreach($_attachments as $attachment) {
412
-			if(is_array($attachment)) {
411
+		foreach ($_attachments as $attachment) {
412
+			if (is_array($attachment)) {
413 413
 				$this->add_attachment(
414 414
 					$attachment['string'],
415 415
 					$attachment['filename'],
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 * @param string $_type File extension (MIME) type.
434 434
 	 * @param string $_path optional path to attachment, if !$_string
435 435
 	 */
436
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
437
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
436
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path = null) {
437
+		if (!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
438 438
 		$this->attachments[] = (object)array(
439 439
 			'string' => $_string,
440 440
 			'filename' => $_filename,
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 		if (!is_array($this->receivers) || count($this->receivers) == 0) {
467 467
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
468 468
 		}
469
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
469
+		if (!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
470 470
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
471 471
 		}
472 472
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 			$backend_errors = array();
481 481
 			try {
482 482
 				// system or non-system user
483
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
483
+				if ($receiver->account_id && is_numeric($receiver->account_id)) {
484 484
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
485 485
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
486 486
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -493,17 +493,17 @@  discard block
 block discarded – undo
493 493
 					}
494 494
 					$receiver->handle = $receiver->account_lid;
495 495
 					// check if the receiver has rights to run the notifcation app
496
-					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
496
+					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id, true);
497 497
 					$ids[] = $receiver->account_id;
498
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
498
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids, 'run', 'notifications')) {
499 499
 						// read the users notification chain
500 500
 						$prefs = new Api\Preferences($receiver->account_id);
501 501
 						$preferences_all = $prefs->read();
502 502
 						$preferences = (object)$preferences_all[self::_appname];
503
-						if($preferences->notification_chain) {
503
+						if ($preferences->notification_chain) {
504 504
 							// fallback: admin disabled user-chosen chain
505
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
506
-								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
505
+							if (!$notification_chain = $available_chains[$preferences->notification_chain]) {
506
+								$prepend_message .= lang('This eGroupWare notification has been sent to you by mail because your'
507 507
 															.' chosen notification-chain has been disabled by the administrator.'
508 508
 															.' Please choose another notification-chain in your preferences!');
509 509
 								$notification_chain = $available_chains[self::_fallback];
@@ -520,28 +520,28 @@  discard block
 block discarded – undo
520 520
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
521 521
 				}
522 522
 
523
-				if($notification_chain == 'disable') {
523
+				if ($notification_chain == 'disable') {
524 524
 					continue; //user disabled notifications
525 525
 				}
526 526
 
527
-				foreach($notification_chain as $backend => $action) {
527
+				foreach ($notification_chain as $backend => $action) {
528 528
 					$notification_backend = null;
529 529
 					try {
530 530
 						// check if backend should be skipped
531
-						if( in_array($backend, $this->skip_backends) ) {
531
+						if (in_array($backend, $this->skip_backends)) {
532 532
 							// log as error just for the case too much skipping prevents user from being notified
533 533
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
534 534
 							continue;
535 535
 						}
536 536
 
537 537
 						$notification_backend = self::_appname.'_'.$backend;
538
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
539
-							throw new Exception('file for '.$notification_backend. ' does not exist');
538
+						if (!file_exists(EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.'.$notification_backend.'.inc.php')) {
539
+							throw new Exception('file for '.$notification_backend.' does not exist');
540 540
 						}
541
-						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
542
-						if ( !($obj instanceof notifications_iface) ) {
543
-							unset ( $obj );
544
-					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
541
+						$obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences);
542
+						if (!($obj instanceof notifications_iface)) {
543
+							unset ($obj);
544
+					 		throw new Exception($notification_backend.' is no implementation of notifications_iface');
545 545
 						}
546 546
 						$lsubject = $this->subject;
547 547
 						$llinks = $this->links;
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 						// This is to make popup_or_email option sensfull since
557 557
 						// we save popup notifications in database anyway, email
558 558
 						// notifications should be based on user availability.
559
-						if ($backend == 'popup' && $action== 'fail' && !Api\Session::notifications_active($receiver->account_id))
559
+						if ($backend == 'popup' && $action == 'fail' && !Api\Session::notifications_active($receiver->account_id))
560 560
 						{
561 561
 							throw new Exception();
562 562
 						}
@@ -564,17 +564,17 @@  discard block
 block discarded – undo
564 564
 					catch (Exception $exception) {
565 565
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
566 566
 						// try next backend
567
-						if($action == 'fail' || $action == 'continue') {
567
+						if ($action == 'fail' || $action == 'continue') {
568 568
 							continue;
569 569
 						}
570 570
 						break; // stop running through chain
571 571
 					}
572 572
 					// backend sucseeded
573 573
 					$user_notified = true;
574
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
574
+					if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain
575 575
 				}
576 576
 				// check if the user has been notified at all
577
-				if(!$user_notified) {
577
+				if (!$user_notified) {
578 578
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
579 579
 					foreach($backend_errors as $id=>$backend_error) {
580 580
 						error_log($backend_error);
@@ -601,22 +601,22 @@  discard block
 block discarded – undo
601 601
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
602 602
 	 */
603 603
 	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
604
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
604
+		if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
605 605
 		$messages = array();
606 606
 
607 607
 		// create the messages
608
-		if(!empty($_message_plain)) {
608
+		if (!empty($_message_plain)) {
609 609
 			$messages['plain'] = $_message_plain;
610 610
 		} else {
611 611
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
612 612
 		}
613 613
 
614
-		if(!empty($_message_html)) {
614
+		if (!empty($_message_html)) {
615 615
 			$messages['html'] = $_message_html;
616 616
 		} else {
617 617
 			$messages['html'] = self::plain2html($_message_plain);
618 618
 		}
619
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
619
+		if (!empty($_message_popup)) $messages['popup'] = $_message_popup;
620 620
 		return $messages;
621 621
 	}
622 622
 
@@ -639,9 +639,9 @@  discard block
 block discarded – undo
639 639
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
640 640
 	 */
641 641
 	 private function prepend_message(array $_messages, $_prepend = null) {
642
-		if(strlen($_prepend) > 0) {
643
-			foreach($_messages as $key => $value) {
644
-				switch($key) {
642
+		if (strlen($_prepend) > 0) {
643
+			foreach ($_messages as $key => $value) {
644
+				switch ($key) {
645 645
 					case 'plain':
646 646
 						$_messages[$key] = $_prepend."\n\n".$value;
647 647
 						break;
@@ -665,17 +665,17 @@  discard block
 block discarded – undo
665 665
 	 * @param string $_part
666 666
 	 * @return string chosen part of the address
667 667
 	 */
668
-	private function get_addresspart($_address, $_part='email')
668
+	private function get_addresspart($_address, $_part = 'email')
669 669
 	{
670 670
 		$parts = null;
671
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
672
-	 		$fullname = trim(trim($parts[1]),'\"');
671
+	 	if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part
672
+	 		$fullname = trim(trim($parts[1]), '\"');
673 673
 	 		$email = $parts[2];
674 674
 	 	} else {
675 675
 	 		$fullname = false;
676 676
 	 		$email = $_address;
677 677
 	 	}
678
-	 	switch($_part) {
678
+	 	switch ($_part) {
679 679
 	 		case 'fullname':
680 680
 	 			return $fullname;
681 681
 	 		case 'email':
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	public function get_available_chains($_output = 'routing') {
698 698
 		// determine enabled backends from Api\Config
699 699
 		$enabled_backends = array();
700
-		foreach($this->backends as $backend) {
701
-			switch($backend) {
700
+		foreach ($this->backends as $backend) {
701
+			switch ($backend) {
702 702
 				case 'email':
703 703
 				case 'popup':
704 704
 				case 'jpopup':
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 
714 714
 		$enabled_chains = array();
715 715
 		$disabled_chains = array();
716
-		foreach($this->notification_chains as $key => $chain) {
716
+		foreach ($this->notification_chains as $key => $chain) {
717 717
 			$allow_chain = true;
718
-			if(is_array($chain)) {
719
-				foreach(array_keys($chain) as $name) {
720
-					if(!$enabled_backends[$name]) {
718
+			if (is_array($chain)) {
719
+				foreach (array_keys($chain) as $name) {
720
+					if (!$enabled_backends[$name]) {
721 721
 						$allow_chain = false; // disable whole chain if one backend is disabled
722 722
 					}
723 723
 				}
724
-				if($allow_chain) {
724
+				if ($allow_chain) {
725 725
 					$enabled_chains[$key] = $chain;
726 726
 				} else {
727 727
 					$disabled_chains[$key] = $chain;
@@ -736,15 +736,15 @@  discard block
 block discarded – undo
736 736
 		// create the 'all' chain from the enabled backends
737 737
 		$chain_all = array();
738 738
 		$backend_count = 1;
739
-		foreach($enabled_backends as $backend => $enabled) {
740
-			if($enabled) {
739
+		foreach ($enabled_backends as $backend => $enabled) {
740
+			if ($enabled) {
741 741
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
742 742
 			}
743 743
 			$backend_count++;
744 744
 		}
745 745
 		$common_chains['all'] = $chain_all;
746 746
 
747
-		switch($_output) {
747
+		switch ($_output) {
748 748
 			case 'human':
749 749
 				$chain_groups = array(
750 750
 					lang('Common chains')	=> 'common_chains',
@@ -753,10 +753,10 @@  discard block
 block discarded – undo
753 753
 					);
754 754
 				$suffix = '_human';
755 755
 				// create descriptions for each chain key in each group
756
-				foreach($chain_groups as $name => $arr_name) {
756
+				foreach ($chain_groups as $name => $arr_name) {
757 757
 					${$arr_name.$suffix} = array();
758
-					foreach(array_keys(${$arr_name}) as $key) {
759
-						if($arr_name == 'disabled_chains') {
758
+					foreach (array_keys(${$arr_name}) as $key) {
759
+						if ($arr_name == 'disabled_chains') {
760 760
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
761 761
 						} else {
762 762
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 				}
766 766
 				// summarize all groups with minimum one chain to the final array
767 767
 				$chains_final = array();
768
-				foreach($chain_groups as $name => $arr_name) {
769
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
768
+				foreach ($chain_groups as $name => $arr_name) {
769
+					if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
770 770
 						$chains_final[$name] = ${$arr_name.$suffix};
771 771
 					}
772 772
 				}
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
787 787
 	 */
788 788
 	public function deleteaccount($settings) {
789
-		foreach($this->backends as $backend) {
790
-			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
789
+		foreach ($this->backends as $backend) {
790
+			$backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount');
791 791
 			if (is_callable($backend_hook)) {
792
-				call_user_func($backend_hook,$settings);
792
+				call_user_func($backend_hook, $settings);
793 793
 			}
794 794
 		}
795 795
 	}
Please login to merge, or discard this patch.
Braces   +228 added lines, -98 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
-class notifications {
27
+class notifications
28
+{
28 29
 
29 30
 	/**
30 31
 	 * Appname
@@ -184,7 +185,8 @@  discard block
 block discarded – undo
184 185
 	 * constructor of notifications
185 186
 	 *
186 187
 	 */
187
-	public function __construct() {
188
+	public function __construct()
189
+	{
188 190
 		$this->config = (object) Api\Config::read(self::_appname);
189 191
 	}
190 192
 
@@ -197,7 +199,10 @@  discard block
 block discarded – undo
197 199
 	public static function errors($reset=false)
198 200
 	{
199 201
 		$ret = self::$errors;
200
-		if ($reset) self::$errors = array();
202
+		if ($reset)
203
+		{
204
+			self::$errors = array();
205
+		}
201 206
 		return $ret;
202 207
 	}
203 208
 
@@ -208,17 +213,23 @@  discard block
 block discarded – undo
208 213
 	 * as long as the accounts class isn't a nice object,
209 214
 	 * it's an int with the account id or the e-mail address of a non-eGW user
210 215
 	 */
211
-	public function set_sender($_sender) {
212
-		if(is_object($_sender)) {
216
+	public function set_sender($_sender)
217
+	{
218
+		if(is_object($_sender))
219
+		{
213 220
 			$this->sender = $_sender;
214 221
 			return true;
215
-		} else {
222
+		}
223
+		else
224
+		{
216 225
 			// no object atm, we have to handle this and make a pseudo-object
217
-			if(is_numeric($_sender)) {
226
+			if(is_numeric($_sender))
227
+			{
218 228
 				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
219 229
 				return true;
220 230
 			}
221
-			if(is_string($_sender) && strpos($_sender,'@')) {
231
+			if(is_string($_sender) && strpos($_sender,'@'))
232
+			{
222 233
 				$this->sender = (object) array (
223 234
 									'account_email' => $this->get_addresspart($_sender,'email'),
224 235
 									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
@@ -236,9 +247,11 @@  discard block
 block discarded – undo
236 247
 	 * as long as the accounts class isn't a nice object,
237 248
 	 * it's an array with the int of the account id or the e-mail address of a non-eGW user
238 249
 	 */
239
-	public function set_receivers(array $_receivers) {
250
+	public function set_receivers(array $_receivers)
251
+	{
240 252
 		$this->receivers = array();
241
-		foreach ($_receivers as $receiver) {
253
+		foreach ($_receivers as $receiver)
254
+		{
242 255
 			$this->add_receiver($receiver);
243 256
 		}
244 257
 	}
@@ -250,17 +263,23 @@  discard block
 block discarded – undo
250 263
 	 * as long as the accounts class isn't a nice object,
251 264
 	 * it's an int with the account id or the e-mail address of a non-eGW user
252 265
 	 */
253
-	public function add_receiver($_receiver) {
254
-		if(is_object($_receiver)) {
266
+	public function add_receiver($_receiver)
267
+	{
268
+		if(is_object($_receiver))
269
+		{
255 270
 			$this->receivers[] = $_receiver;
256 271
 			return true;
257
-		} else {
272
+		}
273
+		else
274
+		{
258 275
 			// no object atm, we have to handle this and make a pseudo-object
259
-			if(is_numeric($_receiver)) {
276
+			if(is_numeric($_receiver))
277
+			{
260 278
 				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
261 279
 				return true;
262 280
 			}
263
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
281
+			if(is_string($_receiver) && strpos($_receiver,'@'))
282
+			{
264 283
 				$this->receivers[] = (object) array (
265 284
 									'account_email' => $this->get_addresspart($_receiver,'email'),
266 285
 									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
@@ -276,7 +295,8 @@  discard block
 block discarded – undo
276 295
 	 *
277 296
 	 * @param string $_subject
278 297
 	 */
279
-	public function set_subject($_subject) {
298
+	public function set_subject($_subject)
299
+	{
280 300
 		$this->subject = $_subject;
281 301
 		return true;
282 302
 	}
@@ -286,7 +306,8 @@  discard block
 block discarded – undo
286 306
 	 *
287 307
 	 * @param string $_subject
288 308
 	 */
289
-	public function set_popupsubject($_subject) {
309
+	public function set_popupsubject($_subject)
310
+	{
290 311
 		$this->popupsubject = $_subject;
291 312
 		return true;
292 313
 	}
@@ -303,14 +324,18 @@  discard block
 block discarded – undo
303 324
 	 * @param string $_message
304 325
 	 * @param string $_type Type of message, 'plain' or 'html'
305 326
 	 */
306
-	public function set_message($_message, $_type = false) {
327
+	public function set_message($_message, $_type = false)
328
+	{
307 329
 		if(!$_type)
308 330
 		{
309 331
 			$_type = strlen($_message) == strlen(strip_tags($_message)) ? 'plain' : 'html';
310 332
 		}
311
-		if($_type == 'plain') {
333
+		if($_type == 'plain')
334
+		{
312 335
 			$this->message_plain = $_message;
313
-		} else {
336
+		}
337
+		else
338
+		{
314 339
 			$this->message_html = $_message;
315 340
 		}
316 341
 		return true;
@@ -324,9 +349,13 @@  discard block
 block discarded – undo
324 349
 	 *
325 350
 	 * @param string $_message
326 351
 	 */
327
-	public function set_popupmessage($_message) {
352
+	public function set_popupmessage($_message)
353
+	{
328 354
 		//popup requires html
329
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
355
+		if(strlen($_message) == strlen(strip_tags($_message)))
356
+		{
357
+			$_message = self::plain2html($_message);
358
+		}
330 359
 		$this->message_popup = $_message;
331 360
 		return true;
332 361
 	}
@@ -336,10 +365,13 @@  discard block
 block discarded – undo
336 365
 	 *
337 366
 	 * @param array $_links link array (like defined in $this->add_link)
338 367
 	 */
339
-	public function set_links(array $_links) {
368
+	public function set_links(array $_links)
369
+	{
340 370
 		$this->links = array(); // clear array if set
341
-		foreach($_links as $link) {
342
-			if(is_array($link)) {
371
+		foreach($_links as $link)
372
+		{
373
+			if(is_array($link))
374
+			{
343 375
 				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
344 376
 			}
345 377
 		}
@@ -351,10 +383,13 @@  discard block
 block discarded – undo
351 383
 	 *
352 384
 	 * @param array $_links link array (like defined in $this->add_link)
353 385
 	 */
354
-	public function set_popuplinks(array $_links) {
386
+	public function set_popuplinks(array $_links)
387
+	{
355 388
 		$this->popup_links = array(); // clear array if set
356
-		foreach($_links as $link) {
357
-			if(is_array($link)) {
389
+		foreach($_links as $link)
390
+		{
391
+			if(is_array($link))
392
+			{
358 393
 				$this->add_popuplink($link['text'], $link['view'], $link['popup'], $link['app']);
359 394
 			}
360 395
 		}
@@ -370,8 +405,11 @@  discard block
 block discarded – undo
370 405
 	 * @param string $_app Application name, to use link registry (popup & view ignored)
371 406
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
372 407
 	 */
373
-	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
374
-		if(!$_view || !$_text) { return false; }
408
+	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false)
409
+	{
410
+		if(!$_view || !$_text)
411
+		{
412
+return false; }
375 413
 		$this->links[] = (object)array(
376 414
 			'text'	=> $_text,
377 415
 			'view'	=> $_view,
@@ -390,8 +428,11 @@  discard block
 block discarded – undo
390 428
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
391 429
 	 * @param string $_app application name
392 430
 	 */
393
-	public function add_popuplink($_text, $_view, $_popup = false, $_app = '') {
394
-		if(!$_view || !$_text) { return false; }
431
+	public function add_popuplink($_text, $_view, $_popup = false, $_app = '')
432
+	{
433
+		if(!$_view || !$_text)
434
+		{
435
+return false; }
395 436
 		$this->popup_links[] = (object)array(
396 437
 										'text'	=> $_text,
397 438
 										'view'	=> $_view,
@@ -406,10 +447,13 @@  discard block
 block discarded – undo
406 447
 	 *
407 448
 	 * @param array $_attachments attachment array (like defined in $this->add_attachment)
408 449
 	 */
409
-	public function set_attachments(array $_attachments) {
450
+	public function set_attachments(array $_attachments)
451
+	{
410 452
 		$this->attachments = array(); // clear array if set
411
-		foreach($_attachments as $attachment) {
412
-			if(is_array($attachment)) {
453
+		foreach($_attachments as $attachment)
454
+		{
455
+			if(is_array($attachment))
456
+			{
413 457
 				$this->add_attachment(
414 458
 					$attachment['string'],
415 459
 					$attachment['filename'],
@@ -433,8 +477,12 @@  discard block
 block discarded – undo
433 477
 	 * @param string $_type File extension (MIME) type.
434 478
 	 * @param string $_path optional path to attachment, if !$_string
435 479
 	 */
436
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
437
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
480
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null)
481
+	{
482
+		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename)
483
+		{
484
+			return false;
485
+		}
438 486
 		$this->attachments[] = (object)array(
439 487
 			'string' => $_string,
440 488
 			'filename' => $_filename,
@@ -452,21 +500,26 @@  discard block
 block discarded – undo
452 500
 	 * @param array $_skip_backends array with names of the backends to be skipped
453 501
 	 * e.g. array('popup', 'winpopup')
454 502
 	 */
455
-	public function set_skip_backends(array $_skip_backends) {
503
+	public function set_skip_backends(array $_skip_backends)
504
+	{
456 505
 		$this->skip_backends = $_skip_backends;
457 506
 	}
458 507
 
459 508
 	/**
460 509
 	 * sends notifications
461 510
 	 */
462
-	public function send() {
463
-		if (!is_object($this->sender)) {
511
+	public function send()
512
+	{
513
+		if (!is_object($this->sender))
514
+		{
464 515
 			throw new Exception('Error: cannot send notifications. No sender supplied');
465 516
 		}
466
-		if (!is_array($this->receivers) || count($this->receivers) == 0) {
517
+		if (!is_array($this->receivers) || count($this->receivers) == 0)
518
+		{
467 519
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
468 520
 		}
469
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
521
+		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup))
522
+		{
470 523
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
471 524
 		}
472 525
 
@@ -474,13 +527,15 @@  discard block
 block discarded – undo
474 527
 
475 528
 		$available_chains = $this->get_available_chains('routing');
476 529
 
477
-		foreach ($this->receivers as $receiver) {
530
+		foreach ($this->receivers as $receiver)
531
+		{
478 532
 			$user_notified = false;
479 533
 			$prepend_message = '';
480 534
 			$backend_errors = array();
481 535
 			try {
482 536
 				// system or non-system user
483
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
537
+				if($receiver->account_id && is_numeric($receiver->account_id))
538
+				{
484 539
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
485 540
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
486 541
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -495,51 +550,65 @@  discard block
 block discarded – undo
495 550
 					// check if the receiver has rights to run the notifcation app
496 551
 					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
497 552
 					$ids[] = $receiver->account_id;
498
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
553
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications'))
554
+					{
499 555
 						// read the users notification chain
500 556
 						$prefs = new Api\Preferences($receiver->account_id);
501 557
 						$preferences_all = $prefs->read();
502 558
 						$preferences = (object)$preferences_all[self::_appname];
503
-						if($preferences->notification_chain) {
559
+						if($preferences->notification_chain)
560
+						{
504 561
 							// fallback: admin disabled user-chosen chain
505
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
562
+							if(!$notification_chain = $available_chains[$preferences->notification_chain])
563
+							{
506 564
 								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
507 565
 															.' chosen notification-chain has been disabled by the administrator.'
508 566
 															.' Please choose another notification-chain in your preferences!');
509 567
 								$notification_chain = $available_chains[self::_fallback];
510 568
 							}
511
-						} else {
569
+						}
570
+						else
571
+						{
512 572
 							$notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs
513 573
 						}
514
-					} else {
574
+					}
575
+					else
576
+					{
515 577
 						$notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app
516 578
 					}
517
-				} else {
579
+				}
580
+				else
581
+				{
518 582
 					// non-system user
519 583
 					$receiver->handle = $receiver->account_email;
520 584
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
521 585
 				}
522 586
 
523
-				if($notification_chain == 'disable') {
587
+				if($notification_chain == 'disable')
588
+				{
524 589
 					continue; //user disabled notifications
525 590
 				}
526 591
 
527
-				foreach($notification_chain as $backend => $action) {
592
+				foreach($notification_chain as $backend => $action)
593
+				{
528 594
 					$notification_backend = null;
529 595
 					try {
530 596
 						// check if backend should be skipped
531
-						if( in_array($backend, $this->skip_backends) ) {
597
+						if( in_array($backend, $this->skip_backends) )
598
+						{
532 599
 							// log as error just for the case too much skipping prevents user from being notified
533 600
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
534 601
 							continue;
535 602
 						}
536 603
 
537 604
 						$notification_backend = self::_appname.'_'.$backend;
538
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
605
+						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php'))
606
+						{
539 607
 							throw new Exception('file for '.$notification_backend. ' does not exist');
540 608
 						}
541 609
 						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
542
-						if ( !($obj instanceof notifications_iface) ) {
610
+						if ( !($obj instanceof notifications_iface) )
611
+						{
543 612
 							unset ( $obj );
544 613
 					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
545 614
 						}
@@ -547,9 +616,18 @@  discard block
 block discarded – undo
547 616
 						$llinks = $this->links;
548 617
 						if ($backend == 'popup')
549 618
 						{
550
-							if (!empty($this->popupsubject)) $lsubject = $this->popupsubject;
551
-							if ($this->popup_links) $llinks = $this->popup_links;
552
-							if (is_array($this->popup_data)) $popup_data = $this->popup_data;
619
+							if (!empty($this->popupsubject))
620
+							{
621
+								$lsubject = $this->popupsubject;
622
+							}
623
+							if ($this->popup_links)
624
+							{
625
+								$llinks = $this->popup_links;
626
+							}
627
+							if (is_array($this->popup_data))
628
+							{
629
+								$popup_data = $this->popup_data;
630
+							}
553 631
 						}
554 632
 						$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments, $popup_data);
555 633
 
@@ -564,23 +642,30 @@  discard block
 block discarded – undo
564 642
 					catch (Exception $exception) {
565 643
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
566 644
 						// try next backend
567
-						if($action == 'fail' || $action == 'continue') {
645
+						if($action == 'fail' || $action == 'continue')
646
+						{
568 647
 							continue;
569 648
 						}
570 649
 						break; // stop running through chain
571 650
 					}
572 651
 					// backend sucseeded
573 652
 					$user_notified = true;
574
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
653
+					if($action == 'stop' || $action == 'fail')
654
+					{
655
+break; } // stop running through chain
575 656
 				}
576 657
 				// check if the user has been notified at all
577
-				if(!$user_notified) {
658
+				if(!$user_notified)
659
+				{
578 660
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
579 661
 					foreach($backend_errors as $id=>$backend_error) {
580 662
 						error_log($backend_error);
581 663
 					}*/
582 664
 					$error = implode(', ', $backend_errors);
583
-					if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error;
665
+					if (stripos($error, (string)$receiver->handle) !== false)
666
+					{
667
+						$error = $receiver->handle.': '.$error;
668
+					}
584 669
 					self::$errors[] = $error;
585 670
 				}
586 671
 			}
@@ -600,23 +685,35 @@  discard block
 block discarded – undo
600 685
 	 * @param string $_message_popup
601 686
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
602 687
 	 */
603
-	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
604
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
688
+	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '')
689
+	{
690
+		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup))
691
+		{
692
+return false; } // no message set
605 693
 		$messages = array();
606 694
 
607 695
 		// create the messages
608
-		if(!empty($_message_plain)) {
696
+		if(!empty($_message_plain))
697
+		{
609 698
 			$messages['plain'] = $_message_plain;
610
-		} else {
699
+		}
700
+		else
701
+		{
611 702
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
612 703
 		}
613 704
 
614
-		if(!empty($_message_html)) {
705
+		if(!empty($_message_html))
706
+		{
615 707
 			$messages['html'] = $_message_html;
616
-		} else {
708
+		}
709
+		else
710
+		{
617 711
 			$messages['html'] = self::plain2html($_message_plain);
618 712
 		}
619
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
713
+		if (!empty($_message_popup))
714
+		{
715
+			$messages['popup']=$_message_popup;
716
+		}
620 717
 		return $messages;
621 718
 	}
622 719
 
@@ -638,10 +735,14 @@  discard block
 block discarded – undo
638 735
 	 * @param string $_prepend just a plain message to prepend, no html!
639 736
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
640 737
 	 */
641
-	 private function prepend_message(array $_messages, $_prepend = null) {
642
-		if(strlen($_prepend) > 0) {
643
-			foreach($_messages as $key => $value) {
644
-				switch($key) {
738
+	 private function prepend_message(array $_messages, $_prepend = null)
739
+	 {
740
+		if(strlen($_prepend) > 0)
741
+		{
742
+			foreach($_messages as $key => $value)
743
+			{
744
+				switch($key)
745
+				{
645 746
 					case 'plain':
646 747
 						$_messages[$key] = $_prepend."\n\n".$value;
647 748
 						break;
@@ -668,14 +769,19 @@  discard block
 block discarded – undo
668 769
 	private function get_addresspart($_address, $_part='email')
669 770
 	{
670 771
 		$parts = null;
671
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
772
+	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts))
773
+	 	{
774
+// _address contains a fullname part
672 775
 	 		$fullname = trim(trim($parts[1]),'\"');
673 776
 	 		$email = $parts[2];
674
-	 	} else {
777
+	 	}
778
+	 	else
779
+	 	{
675 780
 	 		$fullname = false;
676 781
 	 		$email = $_address;
677 782
 	 	}
678
-	 	switch($_part) {
783
+	 	switch($_part)
784
+	 	{
679 785
 	 		case 'fullname':
680 786
 	 			return $fullname;
681 787
 	 		case 'email':
@@ -694,11 +800,14 @@  discard block
 block discarded – undo
694 800
 	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
695 801
 	 * @return array containing notification chains, output like given in $_output
696 802
 	 */
697
-	public function get_available_chains($_output = 'routing') {
803
+	public function get_available_chains($_output = 'routing')
804
+	{
698 805
 		// determine enabled backends from Api\Config
699 806
 		$enabled_backends = array();
700
-		foreach($this->backends as $backend) {
701
-			switch($backend) {
807
+		foreach($this->backends as $backend)
808
+		{
809
+			switch($backend)
810
+			{
702 811
 				case 'email':
703 812
 				case 'popup':
704 813
 				case 'jpopup':
@@ -713,17 +822,24 @@  discard block
 block discarded – undo
713 822
 
714 823
 		$enabled_chains = array();
715 824
 		$disabled_chains = array();
716
-		foreach($this->notification_chains as $key => $chain) {
825
+		foreach($this->notification_chains as $key => $chain)
826
+		{
717 827
 			$allow_chain = true;
718
-			if(is_array($chain)) {
719
-				foreach(array_keys($chain) as $name) {
720
-					if(!$enabled_backends[$name]) {
828
+			if(is_array($chain))
829
+			{
830
+				foreach(array_keys($chain) as $name)
831
+				{
832
+					if(!$enabled_backends[$name])
833
+					{
721 834
 						$allow_chain = false; // disable whole chain if one backend is disabled
722 835
 					}
723 836
 				}
724
-				if($allow_chain) {
837
+				if($allow_chain)
838
+				{
725 839
 					$enabled_chains[$key] = $chain;
726
-				} else {
840
+				}
841
+				else
842
+				{
727 843
 					$disabled_chains[$key] = $chain;
728 844
 				}
729 845
 			}
@@ -736,15 +852,18 @@  discard block
 block discarded – undo
736 852
 		// create the 'all' chain from the enabled backends
737 853
 		$chain_all = array();
738 854
 		$backend_count = 1;
739
-		foreach($enabled_backends as $backend => $enabled) {
740
-			if($enabled) {
855
+		foreach($enabled_backends as $backend => $enabled)
856
+		{
857
+			if($enabled)
858
+			{
741 859
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
742 860
 			}
743 861
 			$backend_count++;
744 862
 		}
745 863
 		$common_chains['all'] = $chain_all;
746 864
 
747
-		switch($_output) {
865
+		switch($_output)
866
+		{
748 867
 			case 'human':
749 868
 				$chain_groups = array(
750 869
 					lang('Common chains')	=> 'common_chains',
@@ -753,20 +872,27 @@  discard block
 block discarded – undo
753 872
 					);
754 873
 				$suffix = '_human';
755 874
 				// create descriptions for each chain key in each group
756
-				foreach($chain_groups as $name => $arr_name) {
875
+				foreach($chain_groups as $name => $arr_name)
876
+				{
757 877
 					${$arr_name.$suffix} = array();
758
-					foreach(array_keys(${$arr_name}) as $key) {
759
-						if($arr_name == 'disabled_chains') {
878
+					foreach(array_keys(${$arr_name}) as $key)
879
+					{
880
+						if($arr_name == 'disabled_chains')
881
+						{
760 882
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
761
-						} else {
883
+						}
884
+						else
885
+						{
762 886
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
763 887
 						}
764 888
 					}
765 889
 				}
766 890
 				// summarize all groups with minimum one chain to the final array
767 891
 				$chains_final = array();
768
-				foreach($chain_groups as $name => $arr_name) {
769
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
892
+				foreach($chain_groups as $name => $arr_name)
893
+				{
894
+					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0)
895
+					{
770 896
 						$chains_final[$name] = ${$arr_name.$suffix};
771 897
 					}
772 898
 				}
@@ -785,10 +911,13 @@  discard block
 block discarded – undo
785 911
 	 *
786 912
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
787 913
 	 */
788
-	public function deleteaccount($settings) {
789
-		foreach($this->backends as $backend) {
914
+	public function deleteaccount($settings)
915
+	{
916
+		foreach($this->backends as $backend)
917
+		{
790 918
 			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
791
-			if (is_callable($backend_hook)) {
919
+			if (is_callable($backend_hook))
920
+			{
792 921
 				call_user_func($backend_hook,$settings);
793 922
 			}
794 923
 		}
@@ -802,7 +931,8 @@  discard block
 block discarded – undo
802 931
 	 * @param array $_data
803 932
 	 * @return boolean
804 933
 	 */
805
-	public function set_popupdata($_appname, $_data) {
934
+	public function set_popupdata($_appname, $_data)
935
+	{
806 936
 		$this->popup_data = array(
807 937
 			'appname' => $_appname,
808 938
 			'data' => $_data
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
 		}
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
 			// embed images as inline
113 113
 			\EGroupware\Api\Mail::processURL2InlineImages($this->mail, $body_html, null);
114 114
 		}
115
-		$this->mail->setHtmlBody($body_html, null, false);	// no automatic alternativ
115
+		$this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ
116 116
 		$this->mail->setBody($body_plain);
117 117
 
118
-		if(is_array($_attachments) && count($_attachments) > 0)
118
+		if (is_array($_attachments) && count($_attachments) > 0)
119 119
 		{
120
-			foreach($_attachments as $attachment)
120
+			foreach ($_attachments as $attachment)
121 121
 			{
122 122
 				if ($attachment->string)
123 123
 				{
124 124
 					$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
125 125
 				}
126
-				elseif($attachment->path)
126
+				elseif ($attachment->path)
127 127
 				{
128 128
 					$this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type);
129 129
 				}
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 * @return plain or html rendered link(s) as complete string
143 143
 	 */
144 144
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
145
-		if(!is_array($_links) || count($_links) == 0) { return false; }
145
+		if (!is_array($_links) || count($_links) == 0) { return false; }
146 146
 
147 147
 		// provide defaults if given arguments are null
148 148
 		// php distinguishes between missing and present(null) arguments
149
-		if(is_null($_render_html)) { $_render_html = false; }
150
-		if(is_null($_render_external)) { $_render_external = true; }
149
+		if (is_null($_render_html)) { $_render_html = false; }
150
+		if (is_null($_render_external)) { $_render_external = true; }
151 151
 		$newline = $_render_html ? "<br />" : "\n";
152 152
 		$hruler = $_render_html ? Api\Html::hr() : '';
153 153
 
154 154
 		$rendered_links = array();
155
-		foreach($_links as $link) {
156
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
155
+		foreach ($_links as $link) {
156
+			if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; }
157 157
 			// do not expose sensitive data
158
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
158
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', Api\Html::link('/index.php', $link->view));
159 159
 			// complete missing protocol and domain part if needed
160 160
 			if ($url[0] == '/' && $_render_external) $url = Api\Framework::getUrl($url);
161 161
 			$a_href = '<a href="'.$url.'" target="_blank">'.$link->text.'</a>';
162 162
 			$rendered_links[] = $_render_html ? $a_href : $url;
163 163
 		}
164 164
 
165
-		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links);
165
+		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links);
166 166
 	}
167 167
 
168 168
 }
Please login to merge, or discard this patch.
Braces   +30 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;
@@ -141,23 +147,36 @@  discard block
 block discarded – undo
141 147
 	 * @param boolean $_render_external
142 148
 	 * @return plain or html rendered link(s) as complete string
143 149
 	 */
144
-	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
145
-		if(!is_array($_links) || count($_links) == 0) { return false; }
150
+	private function render_links($_links = false, $_render_html = false, $_render_external = true)
151
+	{
152
+		if(!is_array($_links) || count($_links) == 0)
153
+		{
154
+return false; }
146 155
 
147 156
 		// provide defaults if given arguments are null
148 157
 		// php distinguishes between missing and present(null) arguments
149
-		if(is_null($_render_html)) { $_render_html = false; }
150
-		if(is_null($_render_external)) { $_render_external = true; }
158
+		if(is_null($_render_html))
159
+		{
160
+$_render_html = false; }
161
+		if(is_null($_render_external))
162
+		{
163
+$_render_external = true; }
151 164
 		$newline = $_render_html ? "<br />" : "\n";
152 165
 		$hruler = $_render_html ? Api\Html::hr() : '';
153 166
 
154 167
 		$rendered_links = array();
155
-		foreach($_links as $link) {
156
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
168
+		foreach($_links as $link)
169
+		{
170
+			if($_render_external || ! $link->popup)
171
+			{
172
+$link->view['no_popup'] = 1; }
157 173
 			// do not expose sensitive data
158 174
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
159 175
 			// complete missing protocol and domain part if needed
160
-			if ($url[0] == '/' && $_render_external) $url = Api\Framework::getUrl($url);
176
+			if ($url[0] == '/' && $_render_external)
177
+			{
178
+				$url = Api\Framework::getUrl($url);
179
+			}
161 180
 			$a_href = '<a href="'.$url.'" target="_blank">'.$link->text.'</a>';
162 181
 			$rendered_links[] = $_render_html ? $a_href : $url;
163 182
 		}
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.
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.
Indentation   +51 added lines, -51 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,14 +85,14 @@  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
-	* @param array $_data
95
-	*/
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
+	 * @param array $_data
95
+	 */
96 96
 	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false, $_data = false)
97 97
 	{
98 98
 		unset($_attachments, $_data);	// not used
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 	/**
137
-	* renders additional infos from sender and subject
138
-	*
139
-	* @param string $_subject
140
-	* @return string html rendered info as complete string
141
-	*/
137
+	 * renders additional infos from sender and subject
138
+	 *
139
+	 * @param string $_subject
140
+	 * @return string html rendered info as complete string
141
+	 */
142 142
 	private function render_infos($_subject = false) {
143 143
 		$infos = array();
144 144
 		$newline = "<br />";
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	/**
153
-	* saves notification into database so that the client can fetch it from there
154
-	*
155
-	* @param string $_message
156
-	* @param array $_user_sessions
157
-	*/
153
+	 * saves notification into database so that the client can fetch it from there
154
+	 *
155
+	 * @param string $_message
156
+	 * @param array $_user_sessions
157
+	 */
158 158
 	private function save( $_message ) {
159 159
 		$result = $this->db->insert( self::_notification_table, array(
160 160
 			'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
 	/**
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	* @param array $_attachments
94 94
 	* @param array $_data
95 95
 	*/
96
-	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false, $_data = false)
96
+	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false, $_data = false)
97 97
 	{
98
-		unset($_attachments, $_data);	// not used
98
+		unset($_attachments, $_data); // not used
99 99
 
100 100
 		$jmessage = array();
101 101
 
102 102
 		// app-message
103
-		if( ($_links != null) && (count($_links) > 0) )
103
+		if (($_links != null) && (count($_links) > 0))
104 104
 		{
105
-			$tlink		= $_links[0];
106
-			$appname	= "";
105
+			$tlink = $_links[0];
106
+			$appname = "";
107 107
 
108
-			if( key_exists('menuaction', $tlink->view) )
108
+			if (key_exists('menuaction', $tlink->view))
109 109
 			{
110 110
 				$tmp = explode(".", $tlink->view['menuaction']);
111 111
 				$appname = $tmp[0];
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
 			$link = array();
115 115
 
116
-			foreach( $tlink->view as $pkey => $pvalue )
116
+			foreach ($tlink->view as $pkey => $pvalue)
117 117
 			{
118
-				$link[] = $pkey . '=' . $pvalue;
118
+				$link[] = $pkey.'='.$pvalue;
119 119
 			}
120 120
 
121 121
 			// TODO more links?
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 			.Api\Html::hr()
127 127
 			.$_messages['html'];
128 128
 
129
-		$jmessage['msghtml']	= $message;
130
-		$jmessage['app']		= $appname;
129
+		$jmessage['msghtml'] = $message;
130
+		$jmessage['app'] = $appname;
131 131
 
132 132
 
133
-		$this->save( serialize($jmessage) );
133
+		$this->save(serialize($jmessage));
134 134
 	}
135 135
 
136 136
 	/**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 
146 146
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
147 147
 		$infos[] = lang('Message from').': '.$sender;
148
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
149
-		return implode($newline,$infos);
148
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
149
+		return implode($newline, $infos);
150 150
 	}
151 151
 
152 152
 	/**
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 	* @param string $_message
156 156
 	* @param array $_user_sessions
157 157
 	*/
158
-	private function save( $_message ) {
159
-		$result = $this->db->insert( self::_notification_table, array(
158
+	private function save($_message) {
159
+		$result = $this->db->insert(self::_notification_table, array(
160 160
 			'account_id'     => $this->recipient->account_id,
161 161
 			'notify_message' => $_message,
162 162
 			'notify_type'	 => self::_type
163
-			), false,__LINE__,__FILE__,self::_appname);
163
+			), false, __LINE__, __FILE__, self::_appname);
164 164
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
165 165
 	}
166 166
 }
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.
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;
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false, $_data = false)
107 107
 	{
108
-		unset($_links, $_attachments, $_data);	// not used
108
+		unset($_links, $_attachments, $_data); // not used
109 109
 
110 110
 		$user_sessions = array();
111 111
 		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
112
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
113
-				if($this->valid_ip($session['session_ip'])) {
112
+			if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) {
113
+				if ($this->valid_ip($session['session_ip'])) {
114 114
 					$user_sessions[] = $session['session_ip'];
115 115
 				}
116 116
 			}
117 117
 		}
118
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
118
+		if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
119 119
 
120
-		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
120
+		$this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions);
121 121
 		return true;
122 122
 	}
123 123
 
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 	 * @param string $_message
128 128
 	 * @param array $_user_sessions
129 129
 	 */
130
-	private function send_winpopup( $_message, array $_user_sessions ) {
131
-		foreach($_user_sessions as $user_session) {
132
-			$ip_octets=explode(".",$user_session);
130
+	private function send_winpopup($_message, array $_user_sessions) {
131
+		foreach ($_user_sessions as $user_session) {
132
+			$ip_octets = explode(".", $user_session);
133 133
 			// format the ip_octets to 3 digits each
134
-			foreach($ip_octets as $id=>$ip_octet) {
135
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
136
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
134
+			foreach ($ip_octets as $id=>$ip_octet) {
135
+				if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; }
136
+				if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; }
137 137
 			}
138
-			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138
+			$placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
139 139
 									'/\[1\]/' => $ip_octets[0],
140 140
 									'/\[2\]/' => $ip_octets[1],
141 141
 									'/\[3\]/' => $ip_octets[2],
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 									);
146 146
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
147 147
 			$output = $returncode = null;
148
-			exec($command,$output,$returncode);
149
-			if($returncode != 0) {
148
+			exec($command, $output, $returncode);
149
+			if ($returncode != 0) {
150 150
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
151 151
 			}
152 152
 		}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @return true or false
160 160
 	 */
161 161
 	private function valid_ip($_ip) {
162
-		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
162
+		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip);
163 163
 	}
164 164
 
165 165
 	/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function render_infos($_subject = false) {
172 172
 		$newline = "\n";
173
-		if(!empty($_subject)) { return $_subject.$newline; }
173
+		if (!empty($_subject)) { return $_subject.$newline; }
174 174
 		return false;
175 175
 	}
176 176
 }
177 177
\ No newline at end of file
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. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
@@ -108,14 +115,20 @@  discard block
 block discarded – undo
108 115
 		unset($_links, $_attachments, $_data);	// not used
109 116
 
110 117
 		$user_sessions = array();
111
-		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
112
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
113
-				if($this->valid_ip($session['session_ip'])) {
118
+		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session)
119
+		{
120
+			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain'])
121
+			{
122
+				if($this->valid_ip($session['session_ip']))
123
+				{
114 124
 					$user_sessions[] = $session['session_ip'];
115 125
 				}
116 126
 			}
117 127
 		}
118
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
128
+		if ( empty($user_sessions) )
129
+		{
130
+			throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
131
+		}
119 132
 
120 133
 		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
121 134
 		return true;
@@ -127,13 +140,20 @@  discard block
 block discarded – undo
127 140
 	 * @param string $_message
128 141
 	 * @param array $_user_sessions
129 142
 	 */
130
-	private function send_winpopup( $_message, array $_user_sessions ) {
131
-		foreach($_user_sessions as $user_session) {
143
+	private function send_winpopup( $_message, array $_user_sessions )
144
+	{
145
+		foreach($_user_sessions as $user_session)
146
+		{
132 147
 			$ip_octets=explode(".",$user_session);
133 148
 			// format the ip_octets to 3 digits each
134
-			foreach($ip_octets as $id=>$ip_octet) {
135
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
136
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
149
+			foreach($ip_octets as $id=>$ip_octet)
150
+			{
151
+				if(strlen($ip_octet)==1)
152
+				{
153
+$ip_octets[$id] = '00'.$ip_octet; }
154
+				if(strlen($ip_octet)==2)
155
+				{
156
+$ip_octets[$id] = '0'.$ip_octet; }
137 157
 			}
138 158
 			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
139 159
 									'/\[1\]/' => $ip_octets[0],
@@ -146,7 +166,8 @@  discard block
 block discarded – undo
146 166
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
147 167
 			$output = $returncode = null;
148 168
 			exec($command,$output,$returncode);
149
-			if($returncode != 0) {
169
+			if($returncode != 0)
170
+			{
150 171
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
151 172
 			}
152 173
 		}
@@ -158,7 +179,8 @@  discard block
 block discarded – undo
158 179
 	 * @param string $_ip
159 180
 	 * @return true or false
160 181
 	 */
161
-	private function valid_ip($_ip) {
182
+	private function valid_ip($_ip)
183
+	{
162 184
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
163 185
 	}
164 186
 
@@ -168,9 +190,12 @@  discard block
 block discarded – undo
168 190
 	 * @param string $_subject
169 191
 	 * @return plain rendered info as complete string
170 192
 	 */
171
-	private function render_infos($_subject = false) {
193
+	private function render_infos($_subject = false)
194
+	{
172 195
 		$newline = "\n";
173
-		if(!empty($_subject)) { return $_subject.$newline; }
196
+		if(!empty($_subject))
197
+		{
198
+return $_subject.$newline; }
174 199
 		return false;
175 200
 	}
176 201
 }
177 202
\ No newline at end of file
Please login to merge, or discard this patch.
pixelegg/inc/class.pixelegg_framework.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	 * Overwritten to load our slider.js
56 56
 	 *
57 57
 	 * @param array $extra
58
-	 * @return type
58
+	 * @return string|null
59 59
 	 */
60 60
 	function header(array $extra=array())
61 61
 	{
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @param string $template ='pixelegg' name of the template
43 43
 	 */
44
-	function __construct($template=self::APP)
44
+	function __construct($template = self::APP)
45 45
 	{
46
-		parent::__construct($template);		// call the constructor of the extended class
46
+		parent::__construct($template); // call the constructor of the extended class
47 47
 
48 48
 		// search 'mobile' dirs first
49
-		if (Api\Header\UserAgent::mobile()) array_unshift ($this->template_dirs, 'mobile');
49
+		if (Api\Header\UserAgent::mobile()) array_unshift($this->template_dirs, 'mobile');
50 50
 	}
51 51
 
52 52
 	/**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param array $extra
58 58
 	 * @return type
59 59
 	 */
60
-	function header(array $extra=array())
60
+	function header(array $extra = array())
61 61
 	{
62 62
 		// load our slider.js, but only if framework requested
63 63
 		if (!self::$header_done && $_GET['cd'] === 'yes' &&
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	{
80 80
 		if ($color[0] == '#') $color = ltrim($color, '#');
81 81
 
82
-		$R = hexdec(substr($color,0,2));
83
-		$G = hexdec(substr($color,2,2));
84
-		$B = hexdec(substr($color,4,2));
82
+		$R = hexdec(substr($color, 0, 2));
83
+		$G = hexdec(substr($color, 2, 2));
84
+		$B = hexdec(substr($color, 4, 2));
85 85
 
86 86
 		$Rs = round($R * (100 + $percent) / 100);
87 87
 		$Gs = round($G * (100 + $percent) / 100);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	{
105 105
 		$ret = parent::_get_css();
106 106
 		// color to use
107
-		$color = str_replace('custom',$GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'],
107
+		$color = str_replace('custom', $GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'],
108 108
 			$GLOBALS['egw_info']['user']['preferences']['common']['template_color']);
109 109
 
110 110
 		// Create a dark variant of the color
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 			$loginbox_color = $color_darker;
130 130
 		}
131 131
 
132
-		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color))	// a little xss check
132
+		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i', $color))	// a little xss check
133 133
 		{
134 134
 			if (!Api\Header\UserAgent::mobile())
135 135
 			{
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @param string $extra_vars for login url
207 207
 	 * @param string $change_passwd =null string with message to render input fields for password change
208 208
 	 */
209
-	function login_screen($extra_vars, $change_passwd=null)
209
+	function login_screen($extra_vars, $change_passwd = null)
210 210
 	{
211 211
 		if (empty($GLOBALS['loginscreenmessage']))
212 212
 		{
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,10 @@  discard block
 block discarded – undo
46 46
 		parent::__construct($template);		// call the constructor of the extended class
47 47
 
48 48
 		// search 'mobile' dirs first
49
-		if (Api\Header\UserAgent::mobile()) array_unshift ($this->template_dirs, 'mobile');
49
+		if (Api\Header\UserAgent::mobile())
50
+		{
51
+			array_unshift ($this->template_dirs, 'mobile');
52
+		}
50 53
 	}
51 54
 
52 55
 	/**
@@ -77,7 +80,10 @@  discard block
 block discarded – undo
77 80
 	 */
78 81
 	function _color_shader($color, $percent)
79 82
 	{
80
-		if ($color[0] == '#') $color = ltrim($color, '#');
83
+		if ($color[0] == '#')
84
+		{
85
+			$color = ltrim($color, '#');
86
+		}
81 87
 
82 88
 		$R = hexdec(substr($color,0,2));
83 89
 		$G = hexdec(substr($color,2,2));
@@ -87,9 +93,18 @@  discard block
 block discarded – undo
87 93
 		$Gs = round($G * (100 + $percent) / 100);
88 94
 		$Bs = round($B * (100 + $percent) / 100);
89 95
 
90
-		if ($Rs > 255) $Rs = 255;
91
-		if ($Gs > 255) $Gs = 255;
92
-		if ($Bs > 255) $Bs = 255;
96
+		if ($Rs > 255)
97
+		{
98
+			$Rs = 255;
99
+		}
100
+		if ($Gs > 255)
101
+		{
102
+			$Gs = 255;
103
+		}
104
+		if ($Bs > 255)
105
+		{
106
+			$Bs = 255;
107
+		}
93 108
 
94 109
 		return '#'.sprintf('%02X%02X%02X', $Rs, $Gs, $Bs);
95 110
 	}
@@ -129,7 +144,9 @@  discard block
 block discarded – undo
129 144
 			$loginbox_color = $color_darker;
130 145
 		}
131 146
 
132
-		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color))	// a little xss check
147
+		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color))
148
+		{
149
+			// a little xss check
133 150
 		{
134 151
 			if (!Api\Header\UserAgent::mobile())
135 152
 			{
@@ -177,6 +194,7 @@  discard block
 block discarded – undo
177 194
 .ui-datepicker div.ui-timepicker-div div.ui_tpicker_hour_slider span.ui-slider-handle,
178 195
 .ui-widget-header {background-color: $sidebox_color;}
179 196
 ";
197
+		}
180 198
 				if ($GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'traditional')
181 199
 				{
182 200
 					$ret['app_css'] .= ".dialogFooterToolbar {background-color: $color !important;}";
Please login to merge, or discard this patch.
preferences/inc/class.preferences_settings.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -292,7 +292,7 @@
 block discarded – undo
292 292
 	 * @param array &$sel_options
293 293
 	 * @param array &$readonlys
294 294
 	 * @param array &$types on return setting-name => setting-type
295
-	 * @param etemplate $tpl
295
+	 * @param Etemplate $tpl
296 296
 	 * @throws Api\Exception\WrongParameter
297 297
 	 * @return array content
298 298
 	 */
Please login to merge, or discard this patch.
Spacing   +61 added lines, -62 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param array $content =null
46 46
 	 * @param string $msg =''
47 47
 	 */
48
-	function index(array $content=null, $msg='')
48
+	function index(array $content = null, $msg = '')
49 49
 	{
50 50
 		$tpl = new Etemplate('preferences.settings');
51 51
 		if (!is_array($content))
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			{
73 73
 				list($button) = each($content['button']);
74 74
 				$appname = $content['old_appname'] ? $content['old_appname'] : 'common';
75
-				switch($button)
75
+				switch ($button)
76 76
 				{
77 77
 					case 'save':
78 78
 					case 'apply':
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 						{
82 82
 							throw new Api\Exception\NoPermission\Admin;
83 83
 						}
84
-						list($type,$account_id) = explode(':', $content['old_type']);
84
+						list($type, $account_id) = explode(':', $content['old_type']);
85 85
 						// merge prefs of all tabs together again
86 86
 						$prefs = array();
87
-						foreach($content as $name => $val)
87
+						foreach ($content as $name => $val)
88 88
 						{
89 89
 							if (is_array($val) && strpos($name, 'tab') === 0)
90 90
 							{
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 						$old_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array_flip($require_reload));
103 103
 
104 104
 						$attribute = $type == 'group' ? 'user' : $type;
105
-						if (!($msg=$this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute, $content)))
105
+						if (!($msg = $this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute, $content)))
106 106
 						{
107 107
 							$msg_type = 'success';
108 108
 							$msg = lang('Preferences saved.');
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 						// update client-side Api\Preferences in response
127 127
 						Framework::ajax_get_preference($appname);
128 128
 				}
129
-				if (in_array($button, array('save','cancel')))
129
+				if (in_array($button, array('save', 'cancel')))
130 130
 				{
131 131
 					Api\Json\Response::get()->call('egw.message', $msg, $msg_type);
132 132
 					Framework::window_close();
133 133
 				}
134 134
 			}
135 135
 			$appname = $content['appname'] ? $content['appname'] : 'common';
136
-			list($type,$account_id) = explode(':', $content['type']);
136
+			list($type, $account_id) = explode(':', $content['type']);
137 137
 			//_debug_array($prefs);
138 138
 		}
139 139
 		if ($account_id && $account_id != $GLOBALS['egw']->preferences->get_account_id())
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$preserve['current_app'] = $content['current_app'];
153 153
 		$GLOBALS['egw_info']['flags']['currentapp'] = $content['current_app'] == 'common' ?
154 154
 			'preferences' : $content['current_app'];
155
-		Framework::includeCSS('preferences','app');
155
+		Framework::includeCSS('preferences', 'app');
156 156
 
157 157
 		// if not just saved, call validation before, to be able to show failed validation of current prefs
158 158
 		if (!isset($button))
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 		$preserve['is_admin'] = $is_admin;
170 170
 
171 171
 		// preserve the old values since we need them for admin cmd data comparison
172
-		$preserve['old_values'] = array ();
173
-		foreach($data as $key => $val)
172
+		$preserve['old_values'] = array();
173
+		foreach ($data as $key => $val)
174 174
 		{
175 175
 			if (is_array($val) && strpos($key, 'tab') === 0)
176 176
 			{
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	static function admin_cmd_run($content, $values, $account_id)
199 199
 	{
200
-		$changes = array_udiff_assoc($values, $content['old_values'], function($a, $b){
201
-			return (int) $a !== $b;
200
+		$changes = array_udiff_assoc($values, $content['old_values'], function($a, $b) {
201
+			return (int)$a !== $b;
202 202
 		});
203 203
 		$old = array_intersect_key($content['old_values'], $changes);
204 204
 		$cmd = new admin_cmd_edit_preferences(array(
205 205
 			'account' => $account_id,
206 206
 			'set'	=> $changes,
207 207
 			'old' =>$old
208
-		)+(array)$content['admin_cmd']);
208
+		) + (array)$content['admin_cmd']);
209 209
 		$cmd->run();
210 210
 	}
211 211
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 * @param boolean $only_verify =false
222 222
 	 * @return string with verification error or null on success
223 223
 	 */
224
-	function process_array(array &$repository, array $values, array $types, $appname, $type, $content, $only_verify=false)
224
+	function process_array(array &$repository, array $values, array $types, $appname, $type, $content, $only_verify = false)
225 225
 	{
226 226
 		//fetch application specific settings from a hook
227 227
 		$settings = Api\Hooks::single(array(
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
 		unset($prefs['']);
236 236
 
237 237
 		//_debug_array($values);exit;
238
-		foreach($values as $var => $value)
238
+		foreach ($values as $var => $value)
239 239
 		{
240 240
 			// type specific validation
241
-			switch((string)$types[$var])
241
+			switch ((string)$types[$var])
242 242
 			{
243 243
 				case 'password':	// dont write empty password-fields
244 244
 					if (empty($value)) continue 2;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 						// empty is always allowed
252 252
 
253 253
 						// If forced, empty == not set
254
-						if($type == 'forced')
254
+						if ($type == 'forced')
255 255
 						{
256 256
 							unset($prefs[$var]);
257 257
 							// need to call preferences::delete, to also set affective prefs!
@@ -263,19 +263,19 @@  discard block
 block discarded – undo
263 263
 					{
264 264
 						if ($value[0] != '/' || !Vfs::stat($value) || Vfs::is_dir($value))
265 265
 						{
266
-							$error = lang('%1 is no existing vfs file!',htmlspecialchars($value));
266
+							$error = lang('%1 is no existing vfs file!', htmlspecialchars($value));
267 267
 						}
268 268
 					}
269 269
 					else
270 270
 					{
271 271
 						// split multiple comma or whitespace separated directories
272 272
 						// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
273
-						foreach($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir)
273
+						foreach ($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir)
274 274
 						{
275
-							if ($n) $dir = '/'.$dir;	// re-adding trailing slash removed by split
275
+							if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split
276 276
 							if ($dir[0] != '/' || !Vfs::stat($dir) || !Vfs::is_dir($dir))
277 277
 							{
278
-								$error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!',$dir);
278
+								$error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!', $dir);
279 279
 							}
280 280
 						}
281 281
 					}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
 			if (isset($value) && $value !== '' && $value !== '**NULL**' && $value !== array())
291 291
 			{
292
-				if (is_array($value) && !$settings[$var]['no_sel_options']) $value = implode(',',$value);	// multiselect
292
+				if (is_array($value) && !$settings[$var]['no_sel_options']) $value = implode(',', $value); // multiselect
293 293
 
294 294
 				$prefs[$var] = $value;
295 295
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		// if you return something else than False, it is treated as an error-msg and
310 310
 		// displayed to the user (the prefs are not saved)
311 311
 		//
312
-		if(($error .= Api\Hooks::single(array(
312
+		if (($error .= Api\Hooks::single(array(
313 313
 				'location' => 'verify_settings',
314 314
 				'prefs'    => &$repository[$appname],
315 315
 				'type'     => $type,
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			}
331 331
 			else
332 332
 			{
333
-				$GLOBALS['egw']->preferences->save_repository(True,$type);
333
+				$GLOBALS['egw']->preferences->save_repository(True, $type);
334 334
 			}
335 335
 
336 336
 			// certain common prefs (language, template, ...) require the session to be re-created
@@ -368,19 +368,19 @@  discard block
 block discarded – undo
368 368
 		$sel_options = $readonlys = $content = $tabs = array();
369 369
 		// disable all but first tab and name current tab "tab1", for apps not using sections
370 370
 		$tab = 'tab1';
371
-		foreach($this->settings as $setting)
371
+		foreach ($this->settings as $setting)
372 372
 		{
373 373
 			if (!is_array($setting)) continue;
374 374
 			if ($type != 'forced' && (string)$GLOBALS['egw']->preferences->forced[$appname][$setting['name']] !== '')
375 375
 			{
376
-				continue;	// forced preferences are not displayed, unless we edit them
376
+				continue; // forced preferences are not displayed, unless we edit them
377 377
 			}
378 378
 			$types[$setting['name']] = $old_type = $setting['type'];
379 379
 
380
-			switch($old_type)
380
+			switch ($old_type)
381 381
 			{
382 382
 				case 'section':
383
-					$tab = 'tab'.(1+count($tabs));
383
+					$tab = 'tab'.(1 + count($tabs));
384 384
 					$tabs[] = array(
385 385
 						'id' => $tab,
386 386
 						'template' => 'preferences.settings.tab1',
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
 					if (is_array($setting['values'])) $vars += $setting['values'];
396 396
 					$GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']] =
397 397
 						$GLOBALS['egw']->preferences->lang_notify($GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']], $vars);
398
-					$types[$setting['name']] = $vars;	// store vars for re-translation, instead type "notify"
398
+					$types[$setting['name']] = $vars; // store vars for re-translation, instead type "notify"
399 399
 					if ($setting['help'] && ($setting['run_lang'] || !isset($setting['run_lang'])))
400 400
 					{
401 401
 						$setting['help'] = lang($setting['help']);
402 402
 					}
403 403
 					$setting['help'] .= '<p><b>'.lang('Substitutions and their meanings:').'</b>';
404
-					foreach($vars as $var => $var_help)
404
+					foreach ($vars as $var => $var_help)
405 405
 					{
406 406
 						$lname = ($lname = lang($var)) == $var.'*' ? $var : $lname;
407 407
 						$setting['help'] .= "<br>\n".'<b>$$'.$lname.'$$</b>: '.$var_help;
408 408
 					}
409 409
 					$setting['help'] .= "</p>\n";
410
-					$setting['run_lang'] = false;	// already done now
410
+					$setting['run_lang'] = false; // already done now
411 411
 					// handle as textarea
412 412
 				case 'textarea':
413 413
 					$setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'textbox';
414 414
 					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'multiline', 'true');
415
-					$tpl->setElementAttribute($tab. '[' . $setting['name'] . ']','width', '99%' );
415
+					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'width', '99%');
416 416
 					// anyway setting via css: width: 99%, height: 5em
417 417
 					// for old eT use size attribute
418 418
 					if (is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows'])))
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 				case 'multiselect':
435 435
 					$setting['type'] = 'select';
436 436
 					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5);
437
-					if (!isset($setting['size'])) $setting['size'] = '5';	// old eT
437
+					if (!isset($setting['size'])) $setting['size'] = '5'; // old eT
438 438
 					break;
439 439
 				case 'color':
440 440
 					$setting['type'] = 'colorpicker';
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 				case 'date-duration':
443 443
 					if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1';
444 444
 					$attrs = explode(',', $setting['size']);
445
-					foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
445
+					foreach (array("data_format", "display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
446 446
 					{
447 447
 						if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
448 448
 					}
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 				case 'taglist':
451 451
 					if ($setting['no_sel_options'])
452 452
 					{
453
-						$tpl->setElementAttribute ($tab.'['.$setting['name'].']', 'autocomplete_url', '');
453
+						$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'autocomplete_url', '');
454 454
 					}
455 455
 					break;
456 456
 			}
@@ -459,17 +459,17 @@  discard block
 block discarded – undo
459 459
 			{
460 460
 				if ($old_type != 'multiselect' && $old_type != 'notify')
461 461
 				{
462
-					switch($type)
462
+					switch ($type)
463 463
 					{
464 464
 						case 'user':
465
-							$setting['values'] = array('' => lang('Use default'))+$setting['values'];
465
+							$setting['values'] = array('' => lang('Use default')) + $setting['values'];
466 466
 							break;
467 467
 						case 'default':
468 468
 						case 'group':
469
-							$setting['values'] = array('' => lang('No default'))+$setting['values'];
469
+							$setting['values'] = array('' => lang('No default')) + $setting['values'];
470 470
 							break;
471 471
 						case 'forced';
472
-							$setting['values'] = array('**NULL**' => lang('Users choice'))+$setting['values'];
472
+							$setting['values'] = array('**NULL**' => lang('Users choice')) + $setting['values'];
473 473
 							break;
474 474
 					}
475 475
 				}
@@ -478,8 +478,7 @@  discard block
 block discarded – undo
478 478
 			if ($type == 'user')
479 479
 			{
480 480
 				$default = $GLOBALS['egw']->preferences->group[$appname][$setting['name']] ?
481
-					$GLOBALS['egw']->preferences->group[$appname][$setting['name']] :
482
-					$GLOBALS['egw']->preferences->default[$appname][$setting['name']];
481
+					$GLOBALS['egw']->preferences->group[$appname][$setting['name']] : $GLOBALS['egw']->preferences->default[$appname][$setting['name']];
483 482
 
484 483
 				// replace default value(s) for selectboxes with selectbox labels
485 484
 				if (isset($setting['values']) && is_array($setting['values']))
@@ -499,7 +498,7 @@  discard block
 block discarded – undo
499 498
 				'name' => $setting['name'],
500 499
 				'type' => $setting['type'],
501 500
 				'label' => preg_replace('|<br[ /]*>|i', "\n", $setting['label']),
502
-				'help' => lang($setting['help']),	// is html
501
+				'help' => lang($setting['help']), // is html
503 502
 				'default' => (string)$default !== '' ? lang('Default').': '.$default : null,
504 503
 				'onchange' => $setting['onchange'],
505 504
 				'attributes' => $setting['attributes']
@@ -525,7 +524,7 @@  discard block
 block discarded – undo
525 524
 
526 525
 		$content['appname'] = $appname;
527 526
 		$sel_options['appname'] = array();
528
-		foreach(Api\Hooks::implemented('settings') as $app)
527
+		foreach (Api\Hooks::implemented('settings') as $app)
529 528
 		{
530 529
 			if ($app != 'preferences' && $GLOBALS['egw_info']['user']['apps'][$app])
531 530
 			{
@@ -551,7 +550,7 @@  discard block
 block discarded – undo
551 550
 				$user_apps = $GLOBALS['egw']->acl->get_user_applications($id);
552 551
 				$sel_options['appname'] = array_intersect_key($sel_options['appname'], $user_apps);
553 552
 			}
554
-			foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'order' => 'account_lid')) as $account_id => $group)
553
+			foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'order' => 'account_lid')) as $account_id => $group)
555 554
 			{
556 555
 				$sel_options['type']['group:'.$account_id] = lang('Preferences').' '.Api\Accounts::format_username($group['account_lid'], '', '', $account_id);
557 556
 			}
@@ -574,7 +573,7 @@  discard block
 block discarded – undo
574 573
 	 * @param boolean $lang =true
575 574
 	 * @return string comma-separated and translated labels
576 575
 	 */
577
-	protected static function get_default_label($default, array $values, $lang=true)
576
+	protected static function get_default_label($default, array $values, $lang = true)
578 577
 	{
579 578
 		// explode comma-separated multiple default values
580 579
 		if (!is_array($default) && !isset($values[$default]) && strpos($default, ',') !== false)
@@ -585,7 +584,7 @@  discard block
 block discarded – undo
585 584
 		{
586 585
 			$labels = (array)$default;
587 586
 		}
588
-		foreach($labels as &$def)
587
+		foreach ($labels as &$def)
589 588
 		{
590 589
 			if (isset($values[$def]))
591 590
 			{
@@ -593,7 +592,7 @@  discard block
 block discarded – undo
593 592
 			}
594 593
 			else	// value could be in an optgroup
595 594
 			{
596
-				foreach($values as $value)
595
+				foreach ($values as $value)
597 596
 				{
598 597
 					if (is_array($value) && !isset($value['label']) && isset($value[$def]))
599 598
 					{
@@ -619,16 +618,16 @@  discard block
 block discarded – undo
619 618
 	 * @param int|string $account_id =null account_id for user or group prefs, or "forced" or "default"
620 619
 	 * @return boolean
621 620
 	 */
622
-	protected function call_hook($appname, $type='user', $account_id=null)
621
+	protected function call_hook($appname, $type = 'user', $account_id = null)
623 622
 	{
624 623
 		$this->appname = $appname == 'common' ? 'preferences' : $appname;
625 624
 
626 625
 		// Set framework here to make sure we get the right settings for user's [newly] selected template
627 626
 		$GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw']->preferences->data['common']['template_set'];
628 627
 		Api\Translation::add_app($this->appname);
629
-		if($this->appname != 'preferences')
628
+		if ($this->appname != 'preferences')
630 629
 		{
631
-			Api\Translation::add_app('preferences');	// we need the prefs translations too
630
+			Api\Translation::add_app('preferences'); // we need the prefs translations too
632 631
 		}
633 632
 
634 633
 		// make type available, to hooks from Egw\Applications can use it, eg. activesync
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
 			'type' => $type,
638 637
 			'account_id' => $account_id,
639 638
 		);
640
-		$GLOBALS['type'] = $type;	// old global variable
639
+		$GLOBALS['type'] = $type; // old global variable
641 640
 
642 641
 		// calling app specific settings hook
643 642
 		$settings = Api\Hooks::single($hook_data, $this->appname);
@@ -646,30 +645,30 @@  discard block
 block discarded – undo
646 645
 		{
647 646
 			$this->settings = array_merge($this->settings, $settings);
648 647
 		}
649
-		elseif(isset($GLOBALS['settings']) && is_array($GLOBALS['settings']) && $GLOBALS['settings'])
648
+		elseif (isset($GLOBALS['settings']) && is_array($GLOBALS['settings']) && $GLOBALS['settings'])
650 649
 		{
651 650
 			$this->settings = array_merge($this->settings, $GLOBALS['settings']);
652 651
 		}
653 652
 		else
654 653
 		{
655
-			return False;	// no settings returned
654
+			return False; // no settings returned
656 655
 		}
657 656
 
658 657
 		// calling settings hook all apps can answer (for a specific app)
659 658
 		$hook_data['location'] = 'settings_'.$this->appname;
660
-		foreach(Api\Hooks::process($hook_data, $this->appname,true) as $settings)
659
+		foreach (Api\Hooks::process($hook_data, $this->appname, true) as $settings)
661 660
 		{
662 661
 			if (isset($settings) && is_array($settings) && $settings)
663 662
 			{
664
-				$this->settings = array_merge($this->settings,$settings);
663
+				$this->settings = array_merge($this->settings, $settings);
665 664
 			}
666 665
 		}
667 666
 		/* Remove ui-only settings */
668
-		if($this->xmlrpc)
667
+		if ($this->xmlrpc)
669 668
 		{
670
-			foreach($this->settings as $key => $valarray)
669
+			foreach ($this->settings as $key => $valarray)
671 670
 			{
672
-				if(!$valarray['xmlrpc'])
671
+				if (!$valarray['xmlrpc'])
673 672
 				{
674 673
 					unset($this->settings[$key]);
675 674
 				}
@@ -681,10 +680,10 @@  discard block
 block discarded – undo
681 680
 			 This is not handled by the hooks class and is only valid if not using xml-rpc.
682 681
 			*/
683 682
 			$tmpl_settings = EGW_SERVER_ROOT.$GLOBALS['egw']->framework->template_dir.'/hook_settings.inc.php';
684
-			if($this->appname == 'preferences' && file_exists($tmpl_settings))
683
+			if ($this->appname == 'preferences' && file_exists($tmpl_settings))
685 684
 			{
686 685
 				include($tmpl_settings);
687
-				$this->settings = array_merge($this->settings,$GLOBALS['settings']);
686
+				$this->settings = array_merge($this->settings, $GLOBALS['settings']);
688 687
 			}
689 688
 		}
690 689
 		// check if we have a default/forced value from the settings hook,
@@ -705,9 +704,9 @@  discard block
 block discarded – undo
705 704
 		}
706 705
 		if ($need_update)
707 706
 		{
708
-			$GLOBALS['egw']->preferences->save_repository(false,'default',true);
707
+			$GLOBALS['egw']->preferences->save_repository(false, 'default', true);
709 708
 		}
710
-		if($this->debug)
709
+		if ($this->debug)
711 710
 		{
712 711
 			_debug_array($this->settings);
713 712
 		}
Please login to merge, or discard this patch.
Braces   +69 added lines, -17 removed lines patch added patch discarded remove patch
@@ -176,14 +176,23 @@  discard block
 block discarded – undo
176 176
 			{
177 177
 				foreach ($val as $k => $v)
178 178
 				{
179
-					if (!is_int($k)) $preserve['old_values'][$k] = $v;
179
+					if (!is_int($k))
180
+					{
181
+						$preserve['old_values'][$k] = $v;
182
+					}
180 183
 				}
181 184
 			}
182 185
 		}
183 186
 
184
-		if (isset($old_tab)) $data['tabs'] = $old_tab;
187
+		if (isset($old_tab))
188
+		{
189
+			$data['tabs'] = $old_tab;
190
+		}
185 191
 
186
-		if ($msg) Framework::message($msg, $msg_type ? $msg_type : 'error');
192
+		if ($msg)
193
+		{
194
+			Framework::message($msg, $msg_type ? $msg_type : 'error');
195
+		}
187 196
 
188 197
 		$tpl->exec('preferences.preferences_settings.index', $data, $sel_options, $readonlys, $preserve, 2);
189 198
 	}
@@ -197,7 +206,8 @@  discard block
 block discarded – undo
197 206
 	 */
198 207
 	static function admin_cmd_run($content, $values, $account_id)
199 208
 	{
200
-		$changes = array_udiff_assoc($values, $content['old_values'], function($a, $b){
209
+		$changes = array_udiff_assoc($values, $content['old_values'], function($a, $b)
210
+		{
201 211
 			return (int) $a !== $b;
202 212
 		});
203 213
 		$old = array_intersect_key($content['old_values'], $changes);
@@ -241,7 +251,10 @@  discard block
 block discarded – undo
241 251
 			switch((string)$types[$var])
242 252
 			{
243 253
 				case 'password':	// dont write empty password-fields
244
-					if (empty($value)) continue 2;
254
+					if (empty($value))
255
+					{
256
+						continue 2;
257
+					}
245 258
 					break;
246 259
 				case 'vfs_file':
247 260
 				case 'vfs_dir':
@@ -255,7 +268,10 @@  discard block
 block discarded – undo
255 268
 						{
256 269
 							unset($prefs[$var]);
257 270
 							// need to call preferences::delete, to also set affective prefs!
258
-							if (!$only_verify) $GLOBALS['egw']->preferences->delete($appname, $var, $type);
271
+							if (!$only_verify)
272
+							{
273
+								$GLOBALS['egw']->preferences->delete($appname, $var, $type);
274
+							}
259 275
 							continue 2;
260 276
 						}
261 277
 					}
@@ -272,7 +288,11 @@  discard block
 block discarded – undo
272 288
 						// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
273 289
 						foreach($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir)
274 290
 						{
275
-							if ($n) $dir = '/'.$dir;	// re-adding trailing slash removed by split
291
+							if ($n)
292
+							{
293
+								$dir = '/'.$dir;
294
+							}
295
+							// re-adding trailing slash removed by split
276 296
 							if ($dir[0] != '/' || !Vfs::stat($dir) || !Vfs::is_dir($dir))
277 297
 							{
278 298
 								$error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!',$dir);
@@ -289,19 +309,29 @@  discard block
 block discarded – undo
289 309
 
290 310
 			if (isset($value) && $value !== '' && $value !== '**NULL**' && $value !== array())
291 311
 			{
292
-				if (is_array($value) && !$settings[$var]['no_sel_options']) $value = implode(',',$value);	// multiselect
312
+				if (is_array($value) && !$settings[$var]['no_sel_options'])
313
+				{
314
+					$value = implode(',',$value);
315
+				}
316
+				// multiselect
293 317
 
294 318
 				$prefs[$var] = $value;
295 319
 
296 320
 				// need to call preferences::add, to also set affective prefs!
297
-				if (!$only_verify) $GLOBALS['egw']->preferences->add($appname, $var, $prefs[$var], $type);
321
+				if (!$only_verify)
322
+				{
323
+					$GLOBALS['egw']->preferences->add($appname, $var, $prefs[$var], $type);
324
+				}
298 325
 			}
299 326
 			else
300 327
 			{
301 328
 				unset($prefs[$var]);
302 329
 
303 330
 				// need to call preferences::delete, to also set affective prefs!
304
-				if (!$only_verify) $GLOBALS['egw']->preferences->delete($appname, $var, $type);
331
+				if (!$only_verify)
332
+				{
333
+					$GLOBALS['egw']->preferences->delete($appname, $var, $type);
334
+				}
305 335
 			}
306 336
 		}
307 337
 
@@ -370,7 +400,10 @@  discard block
 block discarded – undo
370 400
 		$tab = 'tab1';
371 401
 		foreach($this->settings as $setting)
372 402
 		{
373
-			if (!is_array($setting)) continue;
403
+			if (!is_array($setting))
404
+			{
405
+				continue;
406
+			}
374 407
 			if ($type != 'forced' && (string)$GLOBALS['egw']->preferences->forced[$appname][$setting['name']] !== '')
375 408
 			{
376 409
 				continue;	// forced preferences are not displayed, unless we edit them
@@ -392,7 +425,10 @@  discard block
 block discarded – undo
392 425
 
393 426
 				case 'notify':
394 427
 					$vars = $GLOBALS['egw']->preferences->vars;
395
-					if (is_array($setting['values'])) $vars += $setting['values'];
428
+					if (is_array($setting['values']))
429
+					{
430
+						$vars += $setting['values'];
431
+					}
396 432
 					$GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']] =
397 433
 						$GLOBALS['egw']->preferences->lang_notify($GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']], $vars);
398 434
 					$types[$setting['name']] = $vars;	// store vars for re-translation, instead type "notify"
@@ -434,17 +470,27 @@  discard block
 block discarded – undo
434 470
 				case 'multiselect':
435 471
 					$setting['type'] = 'select';
436 472
 					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5);
437
-					if (!isset($setting['size'])) $setting['size'] = '5';	// old eT
473
+					if (!isset($setting['size']))
474
+					{
475
+						$setting['size'] = '5';
476
+					}
477
+					// old eT
438 478
 					break;
439 479
 				case 'color':
440 480
 					$setting['type'] = 'colorpicker';
441 481
 					break;
442 482
 				case 'date-duration':
443
-					if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1';
483
+					if (!isset($setting['size']))
484
+					{
485
+						$setting['size'] = 'm,dhm,24,1';
486
+					}
444 487
 					$attrs = explode(',', $setting['size']);
445 488
 					foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
446 489
 					{
447
-						if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
490
+						if ((string)$attrs[$n] !== '')
491
+						{
492
+							$tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
493
+						}
448 494
 					}
449 495
 					break;
450 496
 				case 'taglist':
@@ -486,10 +532,13 @@  discard block
 block discarded – undo
486 532
 				{
487 533
 					$default = self::get_default_label($default, $setting['values']);
488 534
 				}
489
-				if (is_array($types[$setting['name']]))	// translate the substitution names
535
+				if (is_array($types[$setting['name']]))
536
+				{
537
+					// translate the substitution names
490 538
 				{
491 539
 					$default = $GLOBALS['egw']->preferences->lang_notify($default, $types[$setting['name']]);
492 540
 				}
541
+				}
493 542
 			}
494 543
 			if ($setting['help'] && ($setting['run_lang'] || !isset($setting['run_lang'])))
495 544
 			{
@@ -602,7 +651,10 @@  discard block
 block discarded – undo
602 651
 					}
603 652
 				}
604 653
 			}
605
-			if ($lang) $def = lang($def);
654
+			if ($lang)
655
+			{
656
+				$def = lang($def);
657
+			}
606 658
 		}
607 659
 		$label = implode(', ', $labels);
608 660
 		//error_log(__METHOD__."(".array2string($default).', '.array2string($values).") returning $label");
Please login to merge, or discard this patch.