Completed
Push — 16.1 ( 2b6741...abc73d )
by Nathan
50:22 queued 36:36
created
setup/check_install.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -316,6 +316,7 @@
 block discarded – undo
316 316
  * Check if given package is installed via composer in EGroupware's vendor directory
317 317
  *
318 318
  * @param string $package package-name in composer notation eg. "pear-pear.horde.org/Horde_Imap_Client" or "pear-pear.php.net/Net_Sieve"
319
+ * @return string|null
319 320
  */
320 321
 function composer_check($package)
321 322
 {
Please login to merge, or discard this patch.
Spacing   +119 added lines, -123 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use EGroupware\Api;
14 14
 
15 15
 $run_by_webserver = !!$_SERVER['PHP_SELF'];
16
-$is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN';
16
+$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
17 17
 
18 18
 if ($run_by_webserver)
19 19
 {
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	$error_icon = '*** Error: ';
42 42
 	$warning_icon = '!!! Warning: ';
43 43
 
44
-	function lang($msg,$arg1=NULL,$arg2=NULL,$arg3=NULL,$arg4=NULL)
44
+	function lang($msg, $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL)
45 45
 	{
46
-		return is_null($arg1) ? $msg : str_replace(array('%1','%2','%3','%4'),array($arg1,$arg2,$arg3,$arg4),$msg);
46
+		return is_null($arg1) ? $msg : str_replace(array('%1', '%2', '%3', '%4'), array($arg1, $arg2, $arg3, $arg4), $msg);
47 47
 	}
48 48
 }
49 49
 
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 		'func' => 'php_ini_check',
80 80
 		'value' => 0,
81 81
 		'verbose_value' => 'Off',
82
-		'warning' => lang('%1 is set to %2. This is NOT recommeded for a production system, as displayed error messages can contain passwords or other sensitive information!','display_errors',ini_get('display_errors')),
82
+		'warning' => lang('%1 is set to %2. This is NOT recommeded for a production system, as displayed error messages can contain passwords or other sensitive information!', 'display_errors', ini_get('display_errors')),
83 83
 	),
84 84
 	'memory_limit' => array(
85 85
 		'func' => 'php_ini_check',
86 86
 		'value' => '128M',
87 87
 		'check' => '>=',
88
-		'error' => lang('memory_limit is set to less than %1: some applications of eGroupWare need more than the recommend 8M, expect occasional failures','24M'),
88
+		'error' => lang('memory_limit is set to less than %1: some applications of eGroupWare need more than the recommend 8M, expect occasional failures', '24M'),
89 89
 		'change' => 'memory_limit = 24M'
90 90
 	),
91 91
 	'max_execution_time' => array(
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 		'func' => 'php_ini_check',
106 106
 		'value' => '8M',
107 107
 		'check' => '>=',
108
-		'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!','upload_max_filesize',ini_get('upload_max_filesize')),
108
+		'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!', 'upload_max_filesize', ini_get('upload_max_filesize')),
109 109
 		'change' => 'upload_max_filesize = 8M'
110 110
 	),
111 111
 	'post_max_size' => array(
112 112
 		'func' => 'php_ini_check',
113 113
 		'value' => '8M',
114 114
 		'check' => '>=',
115
-		'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!','post_max_size',ini_get('max_post_size')),
115
+		'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!', 'post_max_size', ini_get('max_post_size')),
116 116
 		'change' => 'post_max_size = 8M'
117 117
 	),
118 118
 	'allow_url_fopen' => array(
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		'verbose_value' => '"System/Localtime"',
139 139
 		'check' => '!=',
140 140
 		'error' => lang('No VALID timezone set! ("%1" is NOT sufficient, you have to use a timezone identifer like "%2", see %3full list of valid identifers%4)',
141
-			'System/Localtime','Europe/Berlin','<a href="http://www.php.net/manual/en/timezones.php" target="_blank">','</a>'),
141
+			'System/Localtime', 'Europe/Berlin', '<a href="http://www.php.net/manual/en/timezones.php" target="_blank">', '</a>'),
142 142
 	),
143 143
 	'pdo' => array(
144 144
 		'func' => 'extension_check',
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	),
147 147
 	'mysqli' => array(
148 148
 		'func' => 'extension_check',
149
-		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','mysql','MySQL')
149
+		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'mysql', 'MySQL')
150 150
 	),
151 151
 	'pdo_mysql' => array(
152 152
 		'func' => 'extension_check',
153
-		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pdo_mysql','MySQL')
153
+		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pdo_mysql', 'MySQL')
154 154
 	),
155 155
 	'pgsql' => array(
156 156
 		'func' => 'extension_check',
157
-		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pgsql','pgSQL')
157
+		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pgsql', 'pgSQL')
158 158
 	),
159 159
 	'pdo_pgsql' => array(
160 160
 		'func' => 'extension_check',
161
-		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pdo_pgsql','pgSQL')
161
+		'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pdo_pgsql', 'pgSQL')
162 162
 	),
163 163
 	/* disable checks for other database extensions, as we are not really supporting them anymore
164 164
 	'mssql' => array(
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	realpath('..') => array(
203 203
 		'func' => 'permission_check',
204 204
 		'is_world_writable' => False,
205
-		'only_if_exists' => true,	// quitens "file does not exist" for doc symlinks in Debian to files outside open_basedir
205
+		'only_if_exists' => true, // quitens "file does not exist" for doc symlinks in Debian to files outside open_basedir
206 206
 		'recursiv' => True
207 207
 	),
208 208
 	realpath('../header.inc.php') => array(
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 	$sp_visible = true;
237 237
 	if (($open_basedir = ini_get('open_basedir')) && $open_basedir != 'none')
238 238
 	{
239
-		foreach(explode(PATH_SEPARATOR,$open_basedir) as $dir)
239
+		foreach (explode(PATH_SEPARATOR, $open_basedir) as $dir)
240 240
 		{
241 241
 			$dir = realpath($dir);
242
-			if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) break;
242
+			if (($sp_visible = substr($session_path, 0, strlen($dir)) == $dir)) break;
243 243
 		}
244 244
 	}
245 245
 	if ($sp_visible)	// only check if session_save_path is visible by webserver
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 		$checks[$session_path] = array(
248 248
 			'func' => 'permission_check',
249 249
 			'is_writable' => true,
250
-			'msg' => lang("Checking if php.ini setting session.save_path='%1' is writable by the webserver",session_save_path()),
250
+			'msg' => lang("Checking if php.ini setting session.save_path='%1' is writable by the webserver", session_save_path()),
251 251
 			'error' => lang('You will NOT be able to log into eGroupWare using PHP sessions: "session could not be verified" !!!'),
252 252
 		);
253 253
 	}
254 254
 }
255 255
 $setup_info = $GLOBALS['egw_setup']->detection->get_versions();
256
-foreach($setup_info as $app => $app_data)
256
+foreach ($setup_info as $app => $app_data)
257 257
 {
258 258
 	if (!isset($app_data['check_install'])) continue;
259 259
 
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	{
262 262
 		if (isset($checks[$name]))
263 263
 		{
264
-			if ($checks[$name] == $data) continue;	// identical check --> ignore it
264
+			if ($checks[$name] == $data) continue; // identical check --> ignore it
265 265
 
266
-			if ($data['func'] == 'pear_check' || in_array($data['func'],array('extension_check','php_ini_check')) && !isset($data['warning']))
266
+			if ($data['func'] == 'pear_check' || in_array($data['func'], array('extension_check', 'php_ini_check')) && !isset($data['warning']))
267 267
 			{
268 268
 				if (isset($checks[$name]['from']) && $checks[$name]['from'] && !is_array($checks[$name]['from']))
269 269
 				{
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 				}
272 272
 				if (!isset($data['from'])) $data['from'] = $app;
273 273
 				if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) $checks[$name]['from'] = array();
274
-				if (!in_array($data['from'],$checks[$name]['from'])) $checks[$name]['from'][] = $data['from'];
274
+				if (!in_array($data['from'], $checks[$name]['from'])) $checks[$name]['from'][] = $data['from'];
275 275
 			}
276 276
 			else
277 277
 			{
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 	}
288 288
 }
289 289
 $sorted_checks = array();
290
-foreach(array('php_version','php_ini_check','extension_check','pear_check','gd_check','permission_check') as $func)
290
+foreach (array('php_version', 'php_ini_check', 'extension_check', 'pear_check', 'gd_check', 'permission_check') as $func)
291 291
 {
292
-	foreach($checks as $name => $data)
292
+	foreach ($checks as $name => $data)
293 293
 	{
294 294
 		if ($data['func'] == $func)
295 295
 		{
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 }
301 301
 if ($checks) $sorted_checks += $checks;
302 302
 
303
-function php_version($name,$args)
303
+function php_version($name, $args)
304 304
 {
305 305
 	global $passed_icon, $error_icon;
306
-	unset($name);	// not used, but required by function signature
306
+	unset($name); // not used, but required by function signature
307 307
 
308
-	$version_ok = version_compare(phpversion(),$args['value']) >= 0;
308
+	$version_ok = version_compare(phpversion(), $args['value']) >= 0;
309 309
 
310 310
 	echo '<div>'.($version_ok ? $passed_icon : $error_icon).' <span'.($version_ok ? '' : ' class="setup_error"').'>'.
311
-		lang('Checking required PHP version %1 (recommended %2)',$args['verbose_value'],$args['recommended']).': '.
311
+		lang('Checking required PHP version %1 (recommended %2)', $args['verbose_value'], $args['recommended']).': '.
312 312
 		phpversion().' ==> '.($version_ok ? lang('True') : lang('False'))."</span></div>\n";
313 313
 }
314 314
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
  */
320 320
 function composer_check($package)
321 321
 {
322
-	static $installed=null;
322
+	static $installed = null;
323 323
 	if (!isset($installed))
324 324
 	{
325 325
 		$installed = array();
326
-		if (file_exists(EGW_SERVER_ROOT.'/vendor') && file_exists($json=EGW_SERVER_ROOT.'/vendor/composer/installed.json'))
326
+		if (file_exists(EGW_SERVER_ROOT.'/vendor') && file_exists($json = EGW_SERVER_ROOT.'/vendor/composer/installed.json'))
327 327
 		{
328
-			foreach(json_decode(file_get_contents($json), true) as $package_data)
328
+			foreach (json_decode(file_get_contents($json), true) as $package_data)
329 329
 			{
330 330
 				$installed[strtolower($package_data['name'])] = $package_data['version'];
331 331
 			}
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
  * @param $channel =null use default or given channel
342 342
  * @return array with package-name => version pairs, eg. array('Log' => '1.9.8','PEAR' => '1.4.11')
343 343
  */
344
-function get_installed_pear_packages($channel=null)
344
+function get_installed_pear_packages($channel = null)
345 345
 {
346
-	$pear_config = '';	// use the system default
346
+	$pear_config = ''; // use the system default
347 347
 	// fix for SuSE having the pear.conf only for cli, will fail with open_basedir - no idea what to do then
348 348
 	if (@is_dir('/etc/php5/apache2') && !file_exists('/etc/php5/apache2/pear.conf') && @file_exists('/etc/php5/cli/pear.conf'))
349 349
 	{
@@ -353,13 +353,13 @@  discard block
 block discarded – undo
353 353
 
354 354
 	if (!class_exists('PEAR_Config')) return false;
355 355
 
356
-	$config = new PEAR_Config('',$pear_config);
356
+	$config = new PEAR_Config('', $pear_config);
357 357
 	//echo "<pre>config = ".print_r($config,true)."</pre>\n";
358 358
 
359 359
 	if (empty($channel)) $channel = $config->get('default_channel');
360 360
 	//echo "<pre>channel = ".print_r($channel,true)."</pre>\n";
361 361
 
362
-	if (!method_exists($config,'getRegistry')) return false;	// PEAR version to old
362
+	if (!method_exists($config, 'getRegistry')) return false; // PEAR version to old
363 363
 
364 364
 	$reg = &$config->getRegistry();
365 365
 	//echo "<pre>reg = ".print_r($reg,true)."</pre>\n";
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
 	// bug reported: http://pear.php.net/bugs/bug.php?id=11317
369 369
 	if (!file_exists($reg->install_dir)) return false;
370 370
 
371
-	$installed = $reg->packageInfo(null,null,$channel);
371
+	$installed = $reg->packageInfo(null, null, $channel);
372 372
 
373 373
 	//echo "<pre>installed =".print_r($installed,true)."</pre>\n";
374 374
 	$packages = array();
375
-	foreach($installed as $package)
375
+	foreach ($installed as $package)
376 376
 	{
377 377
 		$name = isset($package['package']) ? $package['package'] : $package['name'];
378 378
 		$version = $package['version'];
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	return $packages;
387 387
 }
388 388
 
389
-function pear_check($package,$args)
389
+function pear_check($package, $args)
390 390
 {
391 391
 	global $passed_icon, $warning_icon;
392 392
 	static $pear_available = null;
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			$found = $pear_available;
431 431
 			if ($pear_available && $package)
432 432
 			{
433
-				$file = str_replace('_','/',$package == 'Mail_Mime' ? 'Mail_mime' : $package).'.php';
433
+				$file = str_replace('_', '/', $package == 'Mail_Mime' ? 'Mail_mime' : $package).'.php';
434 434
 
435 435
 				$found = @include_once($file);
436 436
 
@@ -439,16 +439,15 @@  discard block
 block discarded – undo
439 439
 		}
440 440
 	}
441 441
 	// is the right version availible
442
-	$available = $found && (!$min_version || version_compare($min_version,$version_available) <= 0);
442
+	$available = $found && (!$min_version || version_compare($min_version, $version_available) <= 0);
443 443
 	echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.
444
-		lang('Checking PEAR%1 is installed',($package?($channel?' '.$channel.'/':'::').$package:'').($min_version?" ($min_version)":'')).': '.
445
-		($available ? ($version_available ? $version_available : lang('True')) :
446
-		($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n";
444
+		lang('Checking PEAR%1 is installed', ($package ? ($channel ? ' '.$channel.'/' : '::').$package : '').($min_version ? " ($min_version)" : '')).': '.
445
+		($available ? ($version_available ? $version_available : lang('True')) : ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n";
447 446
 
448 447
 	if (!$available)	// give further info only if not availible
449 448
 	{
450
-		echo '<div class="setup_info">' . lang('PEAR%1 is needed by: %2.',$package ? '::'.$package : '',
451
-			is_array($args['from']) ? implode(', ',$args['from']) : $args['from']);
449
+		echo '<div class="setup_info">'.lang('PEAR%1 is needed by: %2.', $package ? '::'.$package : '',
450
+			is_array($args['from']) ? implode(', ', $args['from']) : $args['from']);
452 451
 
453 452
 		// if using Composer, dont confuse user with PEAR ;-)
454 453
 		if (file_exists(EGW_SERVER_ROOT.'/vendor'))
@@ -461,7 +460,7 @@  discard block
 block discarded – undo
461 460
 			if (!$pear_available)
462 461
 			{
463 462
 				echo '<br/>'.lang('PEAR (%1) is a PHP repository and is usually in a package called %2.',
464
-					'<a href="http://pear.php.net" target="_blank">pear.php.net</a>','php-pear');
463
+					'<a href="http://pear.php.net" target="_blank">pear.php.net</a>', 'php-pear');
465 464
 			}
466 465
 			elseif ($package && !$found)
467 466
 			{
@@ -471,12 +470,12 @@  discard block
 block discarded – undo
471 470
 			}
472 471
 			elseif ($min_version && !$version_available)
473 472
 			{
474
-				echo '<br/>'.lang('We could not determine the version of %1, please make sure it is at least %2',$package,$min_version);
473
+				echo '<br/>'.lang('We could not determine the version of %1, please make sure it is at least %2', $package, $min_version);
475 474
 			}
476
-			elseif ($min_version && version_compare($min_version,$version_available) > 0)
475
+			elseif ($min_version && version_compare($min_version, $version_available) > 0)
477 476
 			{
478 477
 				echo '<br/>'.lang('Your installed version of %1 is %2, required is at least %3, please run: ',
479
-					$package,$version_available,$min_version).' pear upgrade '.$package;
478
+					$package, $version_available, $min_version).' pear upgrade '.$package;
480 479
 			}
481 480
 			echo '<br/>'.lang('Alternatively you can use %1Composer%2 to install all requirements at once. Downloading it and run:',
482 481
 				'<a href="https://getcomposer.org/" target="_blank">', '</a>').
@@ -489,26 +488,26 @@  discard block
 block discarded – undo
489 488
 	return $available;
490 489
 }
491 490
 
492
-function extension_check($name,$args)
491
+function extension_check($name, $args)
493 492
 {
494 493
 	//echo "<p>extension_check($name,".print_r($args,true).")</p>\n";
495 494
 	global $passed_icon, $warning_icon, $is_windows;
496 495
 
497 496
 	if (isset($args['win_only']) && $args['win_only'] && !$is_windows)
498 497
 	{
499
-		return True;	// check only under windows
498
+		return True; // check only under windows
500 499
 	}
501 500
 	// we check for the existens of 'dl', as multithreaded webservers dont have it !!!
502 501
 	$available = check_load_extension($name);
503 502
 
504
-	echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking extension %1 is loaded or loadable',$name).': '.($available ? lang('True') : lang('False'))."</span></div>\n";
503
+	echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking extension %1 is loaded or loadable', $name).': '.($available ? lang('True') : lang('False'))."</span></div>\n";
505 504
 
506 505
 	if (!$available)
507 506
 	{
508 507
 		if (!isset($args['warning']))
509 508
 		{
510
-			$args['warning'] = lang('The %1 extension is needed from: %2.',$name,
511
-				is_array($args['from']) ? implode(', ',$args['from']) : $args['from']);
509
+			$args['warning'] = lang('The %1 extension is needed from: %2.', $name,
510
+				is_array($args['from']) ? implode(', ', $args['from']) : $args['from']);
512 511
 		}
513 512
 		echo "<div class='setup_info'>".$args['warning'].'</div>';
514 513
 	}
@@ -517,20 +516,20 @@  discard block
 block discarded – undo
517 516
 	return $available;
518 517
 }
519 518
 
520
-function function_check($name,$args)
519
+function function_check($name, $args)
521 520
 {
522 521
 	global $passed_icon, $warning_icon;
523 522
 
524 523
 	$available = function_exists($name);
525 524
 
526
-	echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking function %1 exists',$name).': '.($available ? lang('True') : lang('False'))."</span></div>\n";
525
+	echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking function %1 exists', $name).': '.($available ? lang('True') : lang('False'))."</span></div>\n";
527 526
 
528 527
 	if (!$available)
529 528
 	{
530 529
 		if (!isset($args['warning']))
531 530
 		{
532
-			$args['warning'] = lang('The function %1 is needed from: %2.',$name,
533
-				is_array($args['from'] ? implode(', ',$args['from']) : $args['from']));
531
+			$args['warning'] = lang('The function %1 is needed from: %2.', $name,
532
+				is_array($args['from'] ? implode(', ', $args['from']) : $args['from']));
534 533
 		}
535 534
 		echo "<div class='setup_info'>".$args['warning'].'</div>';
536 535
 	}
@@ -539,33 +538,33 @@  discard block
 block discarded – undo
539 538
 	return $available;
540 539
 }
541 540
 
542
-function verbosePerms( $in_Perms )
541
+function verbosePerms($in_Perms)
543 542
 {
544
-	if($in_Perms & 0x1000)     // FIFO pipe
543
+	if ($in_Perms&0x1000)     // FIFO pipe
545 544
 	{
546 545
 		$sP = 'p';
547 546
 	}
548
-	elseif($in_Perms & 0x2000) // Character special
547
+	elseif ($in_Perms&0x2000) // Character special
549 548
 	{
550 549
 		$sP = 'c';
551 550
 	}
552
-	elseif($in_Perms & 0x4000) // Directory
551
+	elseif ($in_Perms&0x4000) // Directory
553 552
 	{
554 553
 		$sP = 'd';
555 554
 	}
556
-	elseif($in_Perms & 0x6000) // Block special
555
+	elseif ($in_Perms&0x6000) // Block special
557 556
 	{
558 557
 		$sP = 'b';
559 558
 	}
560
-	elseif($in_Perms & 0x8000) // Regular
559
+	elseif ($in_Perms&0x8000) // Regular
561 560
 	{
562 561
 		$sP = '-';
563 562
 	}
564
-	elseif($in_Perms & 0xA000) // Symbolic Link
563
+	elseif ($in_Perms&0xA000) // Symbolic Link
565 564
 	{
566 565
 		$sP = 'l';
567 566
 	}
568
-	elseif($in_Perms & 0xC000) // Socket
567
+	elseif ($in_Perms&0xC000) // Socket
569 568
 	{
570 569
 		$sP = 's';
571 570
 	}
@@ -575,33 +574,30 @@  discard block
 block discarded – undo
575 574
 	}
576 575
 
577 576
 	// owner
578
-	$sP .= (($in_Perms & 0x0100) ? 'r' : '-') .
579
-	(($in_Perms & 0x0080) ? 'w' : '-') .
580
-	(($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) :
581
-	(($in_Perms & 0x0800) ? 'S' : '-'));
577
+	$sP .= (($in_Perms&0x0100) ? 'r' : '-').
578
+	(($in_Perms&0x0080) ? 'w' : '-').
579
+	(($in_Perms&0x0040) ? (($in_Perms&0x0800) ? 's' : 'x') : (($in_Perms&0x0800) ? 'S' : '-'));
582 580
 
583 581
 	// group
584
-	$sP .= (($in_Perms & 0x0020) ? 'r' : '-') .
585
-	(($in_Perms & 0x0010) ? 'w' : '-') .
586
-	(($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) :
587
-	(($in_Perms & 0x0400) ? 'S' : '-'));
582
+	$sP .= (($in_Perms&0x0020) ? 'r' : '-').
583
+	(($in_Perms&0x0010) ? 'w' : '-').
584
+	(($in_Perms&0x0008) ? (($in_Perms&0x0400) ? 's' : 'x') : (($in_Perms&0x0400) ? 'S' : '-'));
588 585
 
589 586
 	// world
590
-	$sP .= (($in_Perms & 0x0004) ? 'r' : '-') .
591
-	(($in_Perms & 0x0002) ? 'w' : '-') .
592
-	(($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) :
593
-	(($in_Perms & 0x0200) ? 'T' : '-'));
587
+	$sP .= (($in_Perms&0x0004) ? 'r' : '-').
588
+	(($in_Perms&0x0002) ? 'w' : '-').
589
+	(($in_Perms&0x0001) ? (($in_Perms&0x0200) ? 't' : 'x') : (($in_Perms&0x0200) ? 'T' : '-'));
594 590
 	return $sP;
595 591
 }
596 592
 
597
-function permission_check($name,$args,$verbose=True)
593
+function permission_check($name, $args, $verbose = True)
598 594
 {
599
-	global $passed_icon, $error_icon, $warning_icon,$is_windows;
595
+	global $passed_icon, $error_icon, $warning_icon, $is_windows;
600 596
 	//echo "<p>permision_check('$name',".print_r($args,True).",'$verbose')</p>\n";
601 597
 
602 598
 	// add a ../ for non-absolute pathes
603 599
 	$rel_name = $name;
604
-	if ($name && substr($name,0,3) != '../' && $name[0] != '/' && $name[0] != '\\' && strpos($name,':') === false)
600
+	if ($name && substr($name, 0, 3) != '../' && $name[0] != '/' && $name[0] != '\\' && strpos($name, ':') === false)
605 601
 	{
606 602
 		$name = '../'.$name;
607 603
 	}
@@ -623,22 +619,22 @@  discard block
 block discarded – undo
623 619
 	if (isset($args['is_readable']))
624 620
 	{
625 621
 		$checks[] = lang('readable by the webserver');
626
-		$check_not = (!$args['is_readable']?lang('not'):'');
622
+		$check_not = (!$args['is_readable'] ? lang('not') : '');
627 623
 	}
628 624
 	if (isset($args['is_writable']))
629 625
 	{
630 626
 		$checks[] = lang('writable by the webserver');
631
-		$check_not = (!$args['is_writable']?lang('not'):'');
627
+		$check_not = (!$args['is_writable'] ? lang('not') : '');
632 628
 	}
633 629
 	if (isset($args['is_world_readable']))
634 630
 	{
635 631
 		$checks[] = lang('world readable');
636
-		$check_not = (!$args['is_world_readable']?lang('not'):'');
632
+		$check_not = (!$args['is_world_readable'] ? lang('not') : '');
637 633
 	}
638 634
 	if (isset($args['is_world_writable']))
639 635
 	{
640 636
 		$checks[] = lang('world writable');
641
-		$check_not = (!$args['is_world_writable']?lang('not'):'');
637
+		$check_not = (!$args['is_world_writable'] ? lang('not') : '');
642 638
 	}
643 639
 
644 640
 	if (isset($args['msg']) && ($msg = $args['msg']))
@@ -647,7 +643,7 @@  discard block
 block discarded – undo
647 643
 	}
648 644
 	else
649 645
 	{
650
-		$msg = lang('Checking file-permissions of %1 for %2 %3: %4',$rel_name,$check_not,implode(', ',$checks),$perms)."<br />\n";
646
+		$msg = lang('Checking file-permissions of %1 for %2 %3: %4', $rel_name, $check_not, implode(', ', $checks), $perms)."<br />\n";
651 647
 	}
652 648
 	$extra_error_msg = '';
653 649
 	if (isset($args['error']) && $args['error'])
@@ -656,13 +652,13 @@  discard block
 block discarded – undo
656 652
 	}
657 653
 	if (!file_exists($name))
658 654
 	{
659
-		echo '<div>'. $error_icon . '<span class="setup_error">' . $msg . lang('%1 does not exist !!!',$rel_name).$extra_error_msg."</span></div>\n";
655
+		echo '<div>'.$error_icon.'<span class="setup_error">'.$msg.lang('%1 does not exist !!!', $rel_name).$extra_error_msg."</span></div>\n";
660 656
 		return False;
661 657
 	}
662 658
 	$warning = False;
663 659
 	if (!$GLOBALS['run_by_webserver'] && (@$args['is_readable'] || @$args['is_writable']))
664 660
 	{
665
-		echo $warning_icon.' '.$msg. lang('Check can only be performed, if called via a webserver, as the user-id/-name of the webserver is not known.')."\n";
661
+		echo $warning_icon.' '.$msg.lang('Check can only be performed, if called via a webserver, as the user-id/-name of the webserver is not known.')."\n";
666 662
 		unset($args['is_readable']);
667 663
 		unset($args['is_writable']);
668 664
 		$warning = True;
@@ -670,22 +666,22 @@  discard block
 block discarded – undo
670 666
 	$Ok = True;
671 667
 	if (isset($args['is_writable']) && is_writable($name) != $args['is_writable'])
672 668
 	{
673
-		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_writable']?lang('not').' ':'',lang('writable by the webserver')).$extra_error_msg."</span></div>\n";
669
+		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_writable'] ? lang('not').' ' : '', lang('writable by the webserver')).$extra_error_msg."</span></div>\n";
674 670
 		$Ok = False;
675 671
 	}
676 672
 	if (isset($args['is_readable']) && is_readable($name) != $args['is_readable'])
677 673
 	{
678
-		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_readable']?lang('not').' ':'',lang('readable by the webserver')).$extra_error_msg."</span></div>\n";
674
+		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_readable'] ? lang('not').' ' : '', lang('readable by the webserver')).$extra_error_msg."</span></div>\n";
679 675
 		$Ok = False;
680 676
 	}
681
-	if (!$is_windows && isset($args['is_world_readable']) && !(fileperms($name) & 04) == $args['is_world_readable'])
677
+	if (!$is_windows && isset($args['is_world_readable']) && !(fileperms($name)&04) == $args['is_world_readable'])
682 678
 	{
683
-		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_world_readable']?lang('not').' ':'',lang('world readable')).$extra_error_msg."</span></div>\n";
679
+		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_world_readable'] ? lang('not').' ' : '', lang('world readable')).$extra_error_msg."</span></div>\n";
684 680
 		$Ok = False;
685 681
 	}
686
-	if (!$is_windows && isset($args['is_world_writable']) && !(fileperms($name) & 02) == $args['is_world_writable'])
682
+	if (!$is_windows && isset($args['is_world_writable']) && !(fileperms($name)&02) == $args['is_world_writable'])
687 683
 	{
688
-		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_world_writable']?lang('not').' ':'',lang('world writable')).$extra_error_msg."</span></div>\n";
684
+		echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_world_writable'] ? lang('not').' ' : '', lang('world writable')).$extra_error_msg."</span></div>\n";
689 685
 		$Ok = False;
690 686
 	}
691 687
 	if ($Ok && !$warning && $verbose)
@@ -697,16 +693,16 @@  discard block
 block discarded – undo
697 693
 		if ($verbose)
698 694
 		{
699 695
 			@set_time_limit(0);
700
-			echo "<div class='setup_info'>" . lang('This might take a while, please wait ...')."</div>\n";
696
+			echo "<div class='setup_info'>".lang('This might take a while, please wait ...')."</div>\n";
701 697
 			flush();
702 698
 		}
703 699
 		@set_time_limit(0);
704 700
 		$handle = @opendir($name);
705
-		while($handle && ($file = readdir($handle)))
701
+		while ($handle && ($file = readdir($handle)))
706 702
 		{
707 703
 			if ($file != '.' && $file != '..')
708 704
 			{
709
-				$Ok = $Ok && permission_check(($name!='.'?$name.'/':'').$file,$args,False);
705
+				$Ok = $Ok && permission_check(($name != '.' ? $name.'/' : '').$file, $args, False);
710 706
 			}
711 707
 		}
712 708
 		if ($handle) closedir($handle);
@@ -719,12 +715,12 @@  discard block
 block discarded – undo
719 715
 function mk_value($value)
720 716
 {
721 717
 	$matches = null;
722
-	if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) return $value;
718
+	if (!preg_match('/^([0-9]+)([mk]+)$/i', $value, $matches)) return $value;
723 719
 
724
-	return (strtolower($matches[2]) == 'm' ? 1024*1024 : 1024) * (int) $matches[1];
720
+	return (strtolower($matches[2]) == 'm' ? 1024 * 1024 : 1024) * (int)$matches[1];
725 721
 }
726 722
 
727
-function php_ini_check($name,$args)
723
+function php_ini_check($name, $args)
728 724
 {
729 725
 	global $passed_icon, $error_icon, $warning_icon, $is_windows;
730 726
 
@@ -742,20 +738,20 @@  discard block
 block discarded – undo
742 738
 	{
743 739
 		case 'not set':
744 740
 			$check = lang('not set');
745
-			$result = !($ini_value & $args['value']);
741
+			$result = !($ini_value&$args['value']);
746 742
 			break;
747 743
 		case 'set':
748 744
 			$check = lang('set');
749
-			$result = !!($ini_value & $args['value']);
745
+			$result = !!($ini_value&$args['value']);
750 746
 			break;
751 747
 		case '>=':
752
-			$result = !$ini_value ||	// value not used, eg. no memory limit
753
-			(int) mk_value($ini_value) >= (int) mk_value($args['value']);
748
+			$result = !$ini_value || // value not used, eg. no memory limit
749
+			(int)mk_value($ini_value) >= (int)mk_value($args['value']);
754 750
 			break;
755 751
 		case 'contain':
756 752
 			$check = lang('contain');
757 753
 			$sep = $is_windows ? '/[; ]+/' : '/[: ]+/';
758
-			$result = in_array($args['value'],preg_split($sep,$ini_value));
754
+			$result = in_array($args['value'], preg_split($sep, $ini_value));
759 755
 			break;
760 756
 		case '!=':
761 757
 			$check = lang('set and not');
@@ -772,9 +768,9 @@  discard block
 block discarded – undo
772 768
 			$tz = new DateTimeZone($ini_value);
773 769
 			unset($tz);
774 770
 		}
775
-		catch(Exception $e) {
771
+		catch (Exception $e) {
776 772
 			unset($e);
777
-			$result = false;	// no valid timezone
773
+			$result = false; // no valid timezone
778 774
 		}
779 775
 	}
780 776
 	$msg = ' '.lang('Checking php.ini').": $name $check $verbose_value: <span class='setup_info'>ini_get('$name')='$ini_value'$ini_value_verbose</span>";
@@ -796,7 +792,7 @@  discard block
 block discarded – undo
796 792
 		elseif (!isset($args['safe_mode']))
797 793
 		{
798 794
 			echo "<div>".$warning_icon.' <span class="setup_warning">'.$msg.'</span><div class="setup_info">'.
799
-				lang('%1 is needed by: %2.',$name,is_array($args['from']) ? implode(', ',$args['from']) : $args['from'])
795
+				lang('%1 is needed by: %2.', $name, is_array($args['from']) ? implode(', ', $args['from']) : $args['from'])
800 796
 				."</div></div>\n";
801 797
 		}
802 798
 		if (isset($args['safe_mode']) && $safe_mode || @$args['change'])
@@ -806,7 +802,7 @@  discard block
 block discarded – undo
806 802
 				echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.'</span></div>';
807 803
 			}
808 804
 			echo "<div class='setup_error'>\n";
809
-			echo '*** '.lang('Please make the following change in your php.ini').' ('.get_php_ini().'): '.(@$args['safe_mode']?$args['safe_mode']:$args['change'])."<br />\n";
805
+			echo '*** '.lang('Please make the following change in your php.ini').' ('.get_php_ini().'): '.(@$args['safe_mode'] ? $args['safe_mode'] : $args['change'])."<br />\n";
810 806
 			echo '*** '.lang('AND reload your webserver, so the above changes take effect !!!')."</div>\n";
811 807
 		}
812 808
 	}
@@ -821,16 +817,16 @@  discard block
 block discarded – undo
821 817
 	ob_end_clean();
822 818
 
823 819
 	$found = null;
824
-	return preg_match('/\(php.ini\).*<\/td><td[^>]*>([^ <]+)/',$phpinfo,$found) ? $found[1] : False;
820
+	return preg_match('/\(php.ini\).*<\/td><td[^>]*>([^ <]+)/', $phpinfo, $found) ? $found[1] : False;
825 821
 }
826 822
 
827 823
 function gd_check()
828 824
 {
829 825
 	global $passed_icon, $warning_icon;
830 826
 
831
-	$available = (function_exists('imagecopyresampled')  || function_exists('imagecopyresized'));
827
+	$available = (function_exists('imagecopyresampled') || function_exists('imagecopyresized'));
832 828
 
833
-	echo "<div>".($available ? $passed_icon : $warning_icon).' <span'.($available?'':' class="setup_warning"').'>'.lang('Checking for GD support...').': '.($available ? lang('True') : lang('False'))."</span></div>\n";
829
+	echo "<div>".($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking for GD support...').': '.($available ? lang('True') : lang('False'))."</span></div>\n";
834 830
 
835 831
 	if (!$available)
836 832
 	{
@@ -849,24 +845,24 @@  discard block
 block discarded – undo
849 845
 	));
850 846
 	$ConfigDomain = $_REQUEST['ConfigDomain'];
851 847
 	if (@$_GET['intro']) {
852
-		if(($ConfigLang = setup::get_lang()))
848
+		if (($ConfigLang = setup::get_lang()))
853 849
 		{
854
-			$GLOBALS['egw_setup']->set_cookie('ConfigLang',$ConfigLang,(int) (time()+(1200*9)),'/');
850
+			$GLOBALS['egw_setup']->set_cookie('ConfigLang', $ConfigLang, (int)(time() + (1200 * 9)), '/');
855 851
 		}
856
-		$GLOBALS['egw_setup']->html->show_header(lang('Welcome to the eGroupWare Installation'),False,'config');
852
+		$GLOBALS['egw_setup']->html->show_header(lang('Welcome to the eGroupWare Installation'), False, 'config');
857 853
 		echo '<h1>'.lang('Welcome to the eGroupWare Installation')."</h1>\n";
858
-		if(!$ConfigLang)
854
+		if (!$ConfigLang)
859 855
 		{
860
-			echo '<p><form action="check_install.php?intro=1" method="Post">Please Select your language '.setup_html::lang_select(True,'en')."</form></p>\n";
856
+			echo '<p><form action="check_install.php?intro=1" method="Post">Please Select your language '.setup_html::lang_select(True, 'en')."</form></p>\n";
861 857
 		}
862 858
 		echo '<p>'.lang('The first step in installing eGroupWare is to ensure your environment has the necessary settings to correctly run the application.').'</p>';
863 859
 		echo '<p>'.lang('We will now run a series of tests, which may take a few minutes.  Click the link below to proceed.').'</p>';
864 860
 		echo '<h3><a href="check_install.php">'.lang('Run installation tests').'</a></h3>';
865 861
 		echo '<p><a href="manageheader.php">'.lang('Skip the installation tests (not recommended)')."</a></p>\n";
866
-		$setup_tpl->pparse('out','T_footer');
862
+		$setup_tpl->pparse('out', 'T_footer');
867 863
 		exit;
868 864
 	} else {
869
-		$GLOBALS['egw_setup']->html->show_header(lang('Checking the eGroupWare Installation'),False,'config',$ConfigDomain ? $ConfigDomain . '(' . @$GLOBALS['egw_domain'][$ConfigDomain]['db_type'] . ')' : '');
865
+		$GLOBALS['egw_setup']->html->show_header(lang('Checking the eGroupWare Installation'), False, 'config', $ConfigDomain ? $ConfigDomain.'('.@$GLOBALS['egw_domain'][$ConfigDomain]['db_type'].')' : '');
870 866
 		echo '<h1>'.lang('Checking the eGroupWare Installation')."</h1>\n";
871 867
 		# echo "<pre style=\"text-align: left;\">\n";;
872 868
 	}
@@ -880,7 +876,7 @@  discard block
 block discarded – undo
880 876
 $Ok = True;
881 877
 foreach ($sorted_checks as $name => $args)
882 878
 {
883
-	$check_ok = $args['func']($name,$args);
879
+	$check_ok = $args['func']($name, $args);
884 880
 	$Ok = $Ok && $check_ok;
885 881
 }
886 882
 
@@ -892,9 +888,9 @@  discard block
 block discarded – undo
892 888
 	{
893 889
 		if (!$Ok)
894 890
 		{
895
-			echo '<h3>'.lang('Please fix the above errors (%1) and warnings(%2)',$error_icon,$warning_icon)."</h3>\n";
891
+			echo '<h3>'.lang('Please fix the above errors (%1) and warnings(%2)', $error_icon, $warning_icon)."</h3>\n";
896 892
 			echo '<h3><a href="check_install.php">'.lang('Click here to re-run the installation tests')."</a></h3>\n";
897
-			echo '<h3>'.lang('or %1Continue to the Header Admin%2','<a href="manageheader.php">','</a>')."</h3>\n";
893
+			echo '<h3>'.lang('or %1Continue to the Header Admin%2', '<a href="manageheader.php">', '</a>')."</h3>\n";
898 894
 		}
899 895
 		else
900 896
 		{
@@ -906,10 +902,10 @@  discard block
 block discarded – undo
906 902
 		echo '<h3>';
907 903
 		if (!$Ok)
908 904
 		{
909
-			echo lang('Please fix the above errors (%1) and warnings(%2)',$error_icon,$warning_icon).'. ';
905
+			echo lang('Please fix the above errors (%1) and warnings(%2)', $error_icon, $warning_icon).'. ';
910 906
 		}
911
-		echo '<br /><a href="'.str_replace('check_install.php','',@$_SERVER['HTTP_REFERER']).'">'.lang('Return to Setup')."</a></h3>\n";
907
+		echo '<br /><a href="'.str_replace('check_install.php', '', @$_SERVER['HTTP_REFERER']).'">'.lang('Return to Setup')."</a></h3>\n";
912 908
 	}
913
-	$setup_tpl->pparse('out','T_footer');
909
+	$setup_tpl->pparse('out', 'T_footer');
914 910
 	//echo "</body>\n</html>\n";
915 911
 }
Please login to merge, or discard this patch.
Braces   +119 added lines, -30 removed lines patch added patch discarded remove patch
@@ -239,10 +239,15 @@  discard block
 block discarded – undo
239 239
 		foreach(explode(PATH_SEPARATOR,$open_basedir) as $dir)
240 240
 		{
241 241
 			$dir = realpath($dir);
242
-			if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) break;
242
+			if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir))
243
+			{
244
+				break;
245
+			}
243 246
 		}
244 247
 	}
245
-	if ($sp_visible)	// only check if session_save_path is visible by webserver
248
+	if ($sp_visible)
249
+	{
250
+		// only check if session_save_path is visible by webserver
246 251
 	{
247 252
 		$checks[$session_path] = array(
248 253
 			'func' => 'permission_check',
@@ -251,17 +256,25 @@  discard block
 block discarded – undo
251 256
 			'error' => lang('You will NOT be able to log into eGroupWare using PHP sessions: "session could not be verified" !!!'),
252 257
 		);
253 258
 	}
259
+	}
254 260
 }
255 261
 $setup_info = $GLOBALS['egw_setup']->detection->get_versions();
256 262
 foreach($setup_info as $app => $app_data)
257 263
 {
258
-	if (!isset($app_data['check_install'])) continue;
264
+	if (!isset($app_data['check_install']))
265
+	{
266
+		continue;
267
+	}
259 268
 
260 269
 	foreach ($app_data['check_install'] as $name => $data)
261 270
 	{
262 271
 		if (isset($checks[$name]))
263 272
 		{
264
-			if ($checks[$name] == $data) continue;	// identical check --> ignore it
273
+			if ($checks[$name] == $data)
274
+			{
275
+				continue;
276
+			}
277
+			// identical check --> ignore it
265 278
 
266 279
 			if ($data['func'] == 'pear_check' || in_array($data['func'],array('extension_check','php_ini_check')) && !isset($data['warning']))
267 280
 			{
@@ -269,9 +282,18 @@  discard block
 block discarded – undo
269 282
 				{
270 283
 					$checks[$name]['from'] = array($checks[$name]['from']);
271 284
 				}
272
-				if (!isset($data['from'])) $data['from'] = $app;
273
-				if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) $checks[$name]['from'] = array();
274
-				if (!in_array($data['from'],$checks[$name]['from'])) $checks[$name]['from'][] = $data['from'];
285
+				if (!isset($data['from']))
286
+				{
287
+					$data['from'] = $app;
288
+				}
289
+				if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from']))
290
+				{
291
+					$checks[$name]['from'] = array();
292
+				}
293
+				if (!in_array($data['from'],$checks[$name]['from']))
294
+				{
295
+					$checks[$name]['from'][] = $data['from'];
296
+				}
275 297
 			}
276 298
 			else
277 299
 			{
@@ -280,7 +302,10 @@  discard block
 block discarded – undo
280 302
 		}
281 303
 		else
282 304
 		{
283
-			if (!isset($data['from'])) $data['from'] = $app;
305
+			if (!isset($data['from']))
306
+			{
307
+				$data['from'] = $app;
308
+			}
284 309
 			$checks[$name] = $data;
285 310
 		}
286 311
 		//echo "added check $data[func]($name) for $app"; _debug_array($data);
@@ -298,7 +323,10 @@  discard block
 block discarded – undo
298 323
 		}
299 324
 	}
300 325
 }
301
-if ($checks) $sorted_checks += $checks;
326
+if ($checks)
327
+{
328
+	$sorted_checks += $checks;
329
+}
302 330
 
303 331
 function php_version($name,$args)
304 332
 {
@@ -351,22 +379,35 @@  discard block
 block discarded – undo
351 379
 	}
352 380
 	@include_once 'PEAR/Config.php';
353 381
 
354
-	if (!class_exists('PEAR_Config')) return false;
382
+	if (!class_exists('PEAR_Config'))
383
+	{
384
+		return false;
385
+	}
355 386
 
356 387
 	$config = new PEAR_Config('',$pear_config);
357 388
 	//echo "<pre>config = ".print_r($config,true)."</pre>\n";
358 389
 
359
-	if (empty($channel)) $channel = $config->get('default_channel');
390
+	if (empty($channel))
391
+	{
392
+		$channel = $config->get('default_channel');
393
+	}
360 394
 	//echo "<pre>channel = ".print_r($channel,true)."</pre>\n";
361 395
 
362
-	if (!method_exists($config,'getRegistry')) return false;	// PEAR version to old
396
+	if (!method_exists($config,'getRegistry'))
397
+	{
398
+		return false;
399
+	}
400
+	// PEAR version to old
363 401
 
364 402
 	$reg = &$config->getRegistry();
365 403
 	//echo "<pre>reg = ".print_r($reg,true)."</pre>\n";
366 404
 
367 405
 	// a bug in pear causes an endless loop if the install-dir does not exist
368 406
 	// bug reported: http://pear.php.net/bugs/bug.php?id=11317
369
-	if (!file_exists($reg->install_dir)) return false;
407
+	if (!file_exists($reg->install_dir))
408
+	{
409
+		return false;
410
+	}
370 411
 
371 412
 	$installed = $reg->packageInfo(null,null,$channel);
372 413
 
@@ -376,7 +417,10 @@  discard block
 block discarded – undo
376 417
 	{
377 418
 		$name = isset($package['package']) ? $package['package'] : $package['name'];
378 419
 		$version = $package['version'];
379
-		if (is_array($version)) $version = $version['release'];
420
+		if (is_array($version))
421
+		{
422
+			$version = $version['release'];
423
+		}
380 424
 
381 425
 		$packages[$name] = $version;
382 426
 		//echo "<p>$name: ".print_r($package['version'],true)."</p>\n";
@@ -415,7 +459,10 @@  discard block
 block discarded – undo
415 459
 		{
416 460
 			$pear_available = $found = true;
417 461
 			// check if package is installed
418
-			if ($package && isset($pear_packages[$package])) $available = true;
462
+			if ($package && isset($pear_packages[$package]))
463
+			{
464
+				$available = true;
465
+			}
419 466
 			// check if it's the right version
420 467
 			$version_available = $pear_packages[$package ? $package : 'PEAR'];
421 468
 		}
@@ -425,7 +472,10 @@  discard block
 block discarded – undo
425 472
 			{
426 473
 				$pear_available = @include_once('PEAR.php');
427 474
 
428
-				if (!class_exists('PEAR')) $pear_available = false;
475
+				if (!class_exists('PEAR'))
476
+				{
477
+					$pear_available = false;
478
+				}
429 479
 			}
430 480
 			$found = $pear_available;
431 481
 			if ($pear_available && $package)
@@ -434,7 +484,10 @@  discard block
 block discarded – undo
434 484
 
435 485
 				$found = @include_once($file);
436 486
 
437
-				if (!class_exists($package)) $found = false;
487
+				if (!class_exists($package))
488
+				{
489
+					$found = false;
490
+				}
438 491
 			}
439 492
 		}
440 493
 	}
@@ -445,10 +498,13 @@  discard block
 block discarded – undo
445 498
 		($available ? ($version_available ? $version_available : lang('True')) :
446 499
 		($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n";
447 500
 
448
-	if (!$available)	// give further info only if not availible
501
+	if (!$available)
502
+	{
503
+		// give further info only if not availible
449 504
 	{
450 505
 		echo '<div class="setup_info">' . lang('PEAR%1 is needed by: %2.',$package ? '::'.$package : '',
451 506
 			is_array($args['from']) ? implode(', ',$args['from']) : $args['from']);
507
+	}
452 508
 
453 509
 		// if using Composer, dont confuse user with PEAR ;-)
454 510
 		if (file_exists(EGW_SERVER_ROOT.'/vendor'))
@@ -541,34 +597,55 @@  discard block
 block discarded – undo
541 597
 
542 598
 function verbosePerms( $in_Perms )
543 599
 {
544
-	if($in_Perms & 0x1000)     // FIFO pipe
600
+	if($in_Perms & 0x1000)
601
+	{
602
+		// FIFO pipe
545 603
 	{
546 604
 		$sP = 'p';
547 605
 	}
548
-	elseif($in_Perms & 0x2000) // Character special
606
+	}
607
+	elseif($in_Perms & 0x2000)
608
+	{
609
+		// Character special
549 610
 	{
550 611
 		$sP = 'c';
551 612
 	}
552
-	elseif($in_Perms & 0x4000) // Directory
613
+	}
614
+	elseif($in_Perms & 0x4000)
615
+	{
616
+		// Directory
553 617
 	{
554 618
 		$sP = 'd';
555 619
 	}
556
-	elseif($in_Perms & 0x6000) // Block special
620
+	}
621
+	elseif($in_Perms & 0x6000)
622
+	{
623
+		// Block special
557 624
 	{
558 625
 		$sP = 'b';
559 626
 	}
560
-	elseif($in_Perms & 0x8000) // Regular
627
+	}
628
+	elseif($in_Perms & 0x8000)
629
+	{
630
+		// Regular
561 631
 	{
562 632
 		$sP = '-';
563 633
 	}
564
-	elseif($in_Perms & 0xA000) // Symbolic Link
634
+	}
635
+	elseif($in_Perms & 0xA000)
636
+	{
637
+		// Symbolic Link
565 638
 	{
566 639
 		$sP = 'l';
567 640
 	}
568
-	elseif($in_Perms & 0xC000) // Socket
641
+	}
642
+	elseif($in_Perms & 0xC000)
643
+	{
644
+		// Socket
569 645
 	{
570 646
 		$sP = 's';
571 647
 	}
648
+	}
572 649
 	else                         // UNKNOWN
573 650
 	{
574 651
 		$sP = 'u';
@@ -709,9 +786,15 @@  discard block
 block discarded – undo
709 786
 				$Ok = $Ok && permission_check(($name!='.'?$name.'/':'').$file,$args,False);
710 787
 			}
711 788
 		}
712
-		if ($handle) closedir($handle);
789
+		if ($handle)
790
+		{
791
+			closedir($handle);
792
+		}
793
+	}
794
+	if ($verbose)
795
+	{
796
+		echo "\n";
713 797
 	}
714
-	if ($verbose) echo "\n";
715 798
 
716 799
 	return $Ok;
717 800
 }
@@ -719,7 +802,10 @@  discard block
 block discarded – undo
719 802
 function mk_value($value)
720 803
 {
721 804
 	$matches = null;
722
-	if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) return $value;
805
+	if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches))
806
+	{
807
+		return $value;
808
+	}
723 809
 
724 810
 	return (strtolower($matches[2]) == 'm' ? 1024*1024 : 1024) * (int) $matches[1];
725 811
 }
@@ -848,7 +934,8 @@  discard block
 block discarded – undo
848 934
 		'T_footer' => 'footer.tpl',
849 935
 	));
850 936
 	$ConfigDomain = $_REQUEST['ConfigDomain'];
851
-	if (@$_GET['intro']) {
937
+	if (@$_GET['intro'])
938
+	{
852 939
 		if(($ConfigLang = setup::get_lang()))
853 940
 		{
854 941
 			$GLOBALS['egw_setup']->set_cookie('ConfigLang',$ConfigLang,(int) (time()+(1200*9)),'/');
@@ -865,7 +952,9 @@  discard block
 block discarded – undo
865 952
 		echo '<p><a href="manageheader.php">'.lang('Skip the installation tests (not recommended)')."</a></p>\n";
866 953
 		$setup_tpl->pparse('out','T_footer');
867 954
 		exit;
868
-	} else {
955
+	}
956
+	else
957
+	{
869 958
 		$GLOBALS['egw_setup']->html->show_header(lang('Checking the eGroupWare Installation'),False,'config',$ConfigDomain ? $ConfigDomain . '(' . @$GLOBALS['egw_domain'][$ConfigDomain]['db_type'] . ')' : '');
870 959
 		echo '<h1>'.lang('Checking the eGroupWare Installation')."</h1>\n";
871 960
 		# echo "<pre style=\"text-align: left;\">\n";;
Please login to merge, or discard this patch.
setup/inc/class.setup.inc.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
 	/**
742 742
 	 * egw version checking, is param 1 < param 2 in phpgw versionspeak?
743 743
 	 * @param	$a	phpgw version number to check if less than $b
744
-	 * @param	$b	phpgw version number to check $a against
745
-	 * @return	True if $a < $b
744
+	 * @param	string $b	phpgw version number to check $a against
745
+	 * @return	boolean if $a < $b
746 746
 	 */
747 747
 	function alessthanb($a,$b,$DEBUG=False)
748 748
 	{
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 	 *
830 830
 	 * @param	$a	phpgw version number to check if more than $b
831 831
 	 * @param	$b	phpgw version number to check $a against
832
-	 * @return	True if $a < $b
832
+	 * @return	boolean if $a < $b
833 833
 	 */
834 834
 	function amorethanb($a,$b,$DEBUG=False)
835 835
 	{
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 	 *
1102 1102
 	 * Dont use it to set group-membership, use set_memberships instead!
1103 1103
 	 *
1104
-	 * @param string|array $apps app-names
1104
+	 * @param string $apps app-names
1105 1105
 	 * @param string $location eg. "run"
1106 1106
 	 * @param int|string $account accountid or account_lid
1107 1107
 	 * @param int $rights rights to set, default 1
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 	/**
1148 1148
 	 * checks if one of the given tables exist, returns the first match
1149 1149
 	 *
1150
-	 * @param array $tables array with possible table-names
1150
+	 * @param string[] $tables array with possible table-names
1151 1151
 	 * @return string/boolean tablename or false
1152 1152
 	 */
1153 1153
 	function table_exist($tables,$force_refresh=False)
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 	/**
154
-	* Set the domain used for cookies
155
-	*
156
-	* @return string domain
157
-	*/
154
+	 * Set the domain used for cookies
155
+	 *
156
+	 * @return string domain
157
+	 */
158 158
 	static function cookiedomain()
159 159
 	{
160 160
 		// Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 	/**
178
-	* Set a cookie
179
-	*
180
-	* @param string $cookiename name of cookie to be set
181
-	* @param string $cookievalue value to be used, if unset cookie is cleared (optional)
182
-	* @param int $cookietime when cookie should expire, 0 for session only (optional)
183
-	*/
178
+	 * Set a cookie
179
+	 *
180
+	 * @param string $cookiename name of cookie to be set
181
+	 * @param string $cookievalue value to be used, if unset cookie is cleared (optional)
182
+	 * @param int $cookietime when cookie should expire, 0 for session only (optional)
183
+	 */
184 184
 	function set_cookie($cookiename,$cookievalue='',$cookietime=0)
185 185
 	{
186 186
 		if(!isset($this->cookie_domain))
@@ -344,19 +344,19 @@  discard block
 block discarded – undo
344 344
 		return true;
345 345
 	}
346 346
 
347
-    /**
348
-    * check if username and password is valid
349
-    *
350
-    * this function compares the supplied and stored username and password
351
-	* as any of the passwords can be clear text or md5 we convert them to md5
352
-	* internal and compare always the md5 hashs
353
-    *
354
-    * @param string $user the user supplied username
355
-    * @param string $pw the user supplied password
356
-    * @param string $conf_user the configured username
357
-    * @param string $hash hash to check password agains (no {prefix} for plain and md5!)
358
-    * @returns bool true on success
359
-    */
347
+	/**
348
+	 * check if username and password is valid
349
+	 *
350
+	 * this function compares the supplied and stored username and password
351
+	 * as any of the passwords can be clear text or md5 we convert them to md5
352
+	 * internal and compare always the md5 hashs
353
+	 *
354
+	 * @param string $user the user supplied username
355
+	 * @param string $pw the user supplied password
356
+	 * @param string $conf_user the configured username
357
+	 * @param string $hash hash to check password agains (no {prefix} for plain and md5!)
358
+	 * @returns bool true on success
359
+	 */
360 360
 	static function check_auth($user, $pw, $conf_user, $hash)
361 361
 	{
362 362
 		if ($user !== $conf_user)
@@ -728,10 +728,10 @@  discard block
 block discarded – undo
728 728
 	}
729 729
 
730 730
 	/**
731
-	  * call the hooks for a single application
732
-	  *
733
-	  * @param $location hook location - required
734
-	  * @param $appname application name - optional
731
+	 * call the hooks for a single application
732
+	 *
733
+	 * @param $location hook location - required
734
+	 * @param $appname application name - optional
735 735
 	 */
736 736
 	static function hook($location, $appname='')
737 737
 	{
Please login to merge, or discard this patch.
Braces   +128 added lines, -37 removed lines patch added patch discarded remove patch
@@ -85,11 +85,20 @@  discard block
 block discarded – undo
85 85
 		$this->detection = new setup_detection();
86 86
 		$this->process   = new setup_process();
87 87
 
88
-		if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) $this->system_charset = $_REQUEST['system_charset'];
88
+		if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset']))
89
+		{
90
+			$this->system_charset = $_REQUEST['system_charset'];
91
+		}
89 92
 
90 93
 		/* The setup application needs these */
91
-		if ($html) $this->html = new setup_html();
92
-		if ($translation) $this->translation = new setup_translation();
94
+		if ($html)
95
+		{
96
+			$this->html = new setup_html();
97
+		}
98
+		if ($translation)
99
+		{
100
+			$this->translation = new setup_translation();
101
+		}
93 102
 	}
94 103
 
95 104
 	/**
@@ -132,12 +141,15 @@  discard block
 block discarded – undo
132 141
 					$this->db_charset_was = $this->db->Link_ID->GetCharSet();	// needed for the update
133 142
 
134 143
 					// we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!!
135
-					if (substr($this->db->Type,0,5) == 'mysql')	// we need to check the api version
144
+					if (substr($this->db->Type,0,5) == 'mysql')
145
+					{
146
+						// we need to check the api version
136 147
 					{
137 148
 						$api_version = $this->db->select($this->applications_table,'app_version',array(
138 149
 								'app_name'  => 'phpgwapi',
139 150
 							),__LINE__,__FILE__)->fetchColumn();
140 151
 					}
152
+					}
141 153
 					if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019'))
142 154
 					{
143 155
 						$this->db->Link_ID->SetCharSet($this->system_charset);
@@ -205,7 +217,10 @@  discard block
 block discarded – undo
205 217
 		}
206 218
 		else
207 219
 		{
208
-			if (!isset($_SESSION)) self::session_start();
220
+			if (!isset($_SESSION))
221
+			{
222
+				self::session_start();
223
+			}
209 224
 			$ConfigLang = $_SESSION['ConfigLang'];
210 225
 		}
211 226
 		if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang))
@@ -240,7 +255,10 @@  discard block
 block discarded – undo
240 255
 			// if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true)
241 256
 			!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off', true);
242 257
 
243
-		if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]);
258
+		if (isset($_COOKIE[self::SESSIONID]))
259
+		{
260
+			session_id($_COOKIE[self::SESSIONID]);
261
+		}
244 262
 
245 263
 		$ok = @session_start();	// suppress notice if session already started or warning in CLI
246 264
 		// need to decrypt session, in case session encryption is switched on in header.inc.php
@@ -453,7 +471,10 @@  discard block
 block discarded – undo
453 471
 	 */
454 472
 	function register_app($appname, $_enable=99, array $setup_info=null)
455 473
 	{
456
-		if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info'];
474
+		if (!isset($setup_info))
475
+		{
476
+			$setup_info = $GLOBALS['setup_info'];
477
+		}
457 478
 
458 479
 		if(!$appname)
459 480
 		{
@@ -547,7 +568,10 @@  discard block
 block discarded – undo
547 568
 	 */
548 569
 	function update_app($appname, array $setup_info=null)
549 570
 	{
550
-		if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info'];
571
+		if (!isset($setup_info))
572
+		{
573
+			$setup_info = $GLOBALS['setup_info'];
574
+		}
551 575
 
552 576
 		if(!$appname)
553 577
 		{
@@ -695,7 +719,10 @@  discard block
 block discarded – undo
695 719
 		{
696 720
 			$GLOBALS['settings'] = array();
697 721
 			include_once($file);
698
-			if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']);
722
+			if ($GLOBALS['settings'])
723
+			{
724
+				$settings = array_merge($settings,$GLOBALS['settings']);
725
+			}
699 726
 		}
700 727
 		$default = $forced = array();
701 728
 		foreach($settings as $name => $setting)
@@ -777,52 +804,72 @@  discard block
 block discarded – undo
777 804
 
778 805
 		for($i=0;$i<count($testa);$i++)
779 806
 		{
780
-			if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; }
807
+			if($DEBUG)
808
+			{
809
+echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; }
781 810
 			if((int)$testa[$i] < (int)$testb[$i])
782 811
 			{
783
-				if ($DEBUG) { echo ' yes.'; }
812
+				if ($DEBUG)
813
+				{
814
+echo ' yes.'; }
784 815
 				$less++;
785 816
 				if($i<3)
786 817
 				{
787 818
 					/* Ensure that this is definitely smaller */
788
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely less than B."; }
819
+					if($DEBUG)
820
+					{
821
+echo"  This is the $num[$i] octet, so A is definitely less than B."; }
789 822
 					$less = 5;
790 823
 					break;
791 824
 				}
792 825
 			}
793 826
 			elseif((int)$testa[$i] > (int)$testb[$i])
794 827
 			{
795
-				if($DEBUG) { echo ' no.'; }
828
+				if($DEBUG)
829
+				{
830
+echo ' no.'; }
796 831
 				$less--;
797 832
 				if($i<2)
798 833
 				{
799 834
 					/* Ensure that this is definitely greater */
800
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
835
+					if($DEBUG)
836
+					{
837
+echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
801 838
 					$less = -5;
802 839
 					break;
803 840
 				}
804 841
 			}
805 842
 			else
806 843
 			{
807
-				if($DEBUG) { echo ' no, they are equal or of different length.'; }
844
+				if($DEBUG)
845
+				{
846
+echo ' no, they are equal or of different length.'; }
808 847
 				// makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' !
809 848
 				$less = count($testa) < count($testb) ? 1 : 0;
810 849
 			}
811 850
 		}
812
-		if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
851
+		if($DEBUG)
852
+		{
853
+echo '<br>Check value is: "'.$less.'"'; }
813 854
 		if($less>0)
814 855
 		{
815
-			if($DEBUG) { echo '<br>A is less than B'; }
856
+			if($DEBUG)
857
+			{
858
+echo '<br>A is less than B'; }
816 859
 			return True;
817 860
 		}
818 861
 		elseif($less<0)
819 862
 		{
820
-			if($DEBUG) { echo '<br>A is greater than B'; }
863
+			if($DEBUG)
864
+			{
865
+echo '<br>A is greater than B'; }
821 866
 			return False;
822 867
 		}
823 868
 		else
824 869
 		{
825
-			if($DEBUG) { echo '<br>A is equal to B'; }
870
+			if($DEBUG)
871
+			{
872
+echo '<br>A is equal to B'; }
826 873
 			return False;
827 874
 		}
828 875
 	}
@@ -859,51 +906,71 @@  discard block
 block discarded – undo
859 906
 
860 907
 		for($i=0;$i<count($testa);$i++)
861 908
 		{
862
-			if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; }
909
+			if($DEBUG)
910
+			{
911
+echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; }
863 912
 			if((int)$testa[$i] > (int)$testb[$i])
864 913
 			{
865
-				if($DEBUG) { echo ' yes.'; }
914
+				if($DEBUG)
915
+				{
916
+echo ' yes.'; }
866 917
 				$less++;
867 918
 				if($i<3)
868 919
 				{
869 920
 					/* Ensure that this is definitely greater */
870
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
921
+					if($DEBUG)
922
+					{
923
+echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
871 924
 					$less = 5;
872 925
 					break;
873 926
 				}
874 927
 			}
875 928
 			elseif((int)$testa[$i] < (int)$testb[$i])
876 929
 			{
877
-				if($DEBUG) { echo ' no.'; }
930
+				if($DEBUG)
931
+				{
932
+echo ' no.'; }
878 933
 				$less--;
879 934
 				if($i<2)
880 935
 				{
881 936
 					/* Ensure that this is definitely smaller */
882
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely less than B."; }
937
+					if($DEBUG)
938
+					{
939
+echo"  This is the $num[$i] octet, so A is definitely less than B."; }
883 940
 					$less = -5;
884 941
 					break;
885 942
 				}
886 943
 			}
887 944
 			else
888 945
 			{
889
-				if($DEBUG) { echo ' no, they are equal.'; }
946
+				if($DEBUG)
947
+				{
948
+echo ' no, they are equal.'; }
890 949
 				$less = 0;
891 950
 			}
892 951
 		}
893
-		if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
952
+		if($DEBUG)
953
+		{
954
+echo '<br>Check value is: "'.$less.'"'; }
894 955
 		if($less>0)
895 956
 		{
896
-			if($DEBUG) { echo '<br>A is greater than B'; }
957
+			if($DEBUG)
958
+			{
959
+echo '<br>A is greater than B'; }
897 960
 			return True;
898 961
 		}
899 962
 		elseif($less<0)
900 963
 		{
901
-			if($DEBUG) { echo '<br>A is less than B'; }
964
+			if($DEBUG)
965
+			{
966
+echo '<br>A is less than B'; }
902 967
 			return False;
903 968
 		}
904 969
 		else
905 970
 		{
906
-			if($DEBUG) { echo '<br>A is equal to B'; }
971
+			if($DEBUG)
972
+			{
973
+echo '<br>A is equal to B'; }
907 974
 			return False;
908 975
 		}
909 976
 	}
@@ -940,7 +1007,10 @@  discard block
 block discarded – undo
940 1007
 				echo "<p><b>".$e->getMessage()."</b></p>\n";
941 1008
 				return false;
942 1009
 			}
943
-			if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts;
1010
+			if (!isset($GLOBALS['egw']->accounts))
1011
+			{
1012
+				$GLOBALS['egw']->accounts = $this->accounts;
1013
+			}
944 1014
 			Api\Accounts::cache_invalidate();	// the cache is shared for all instances of the class
945 1015
 		}
946 1016
 		return true;
@@ -975,7 +1045,10 @@  discard block
 block discarded – undo
975 1045
 
976 1046
 		if ($username == 'anonymous')
977 1047
 		{
978
-			if (!isset($this->anonpw)) $this->anonpw = Api\Auth::randomstring(16);
1048
+			if (!isset($this->anonpw))
1049
+			{
1050
+				$this->anonpw = Api\Auth::randomstring(16);
1051
+			}
979 1052
 			$passwd = $anonpw = $this->anonpw;
980 1053
 		}
981 1054
 
@@ -1034,11 +1107,17 @@  discard block
 block discarded – undo
1034 1107
 				'account_lid' => $username,
1035 1108
 			));
1036 1109
 		}
1037
-		if ($primary_group)	// only for users, NOT groups
1110
+		if ($primary_group)
1111
+		{
1112
+			// only for users, NOT groups
1038 1113
 		{
1039 1114
 			$this->set_memberships(array($primary_group_id), $accountid);
1115
+		}
1040 1116
 
1041
-			if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid);
1117
+			if (!$changepw)
1118
+			{
1119
+				$this->add_acl('preferences','nopasswordchange',$accountid);
1120
+			}
1042 1121
 		}
1043 1122
 		//error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid");
1044 1123
 		return $accountid;
@@ -1075,7 +1154,10 @@  discard block
 block discarded – undo
1075 1154
 	function accounts_exist()
1076 1155
 	{
1077 1156
 		try {
1078
-			if (!$this->setup_account_object()) return false;
1157
+			if (!$this->setup_account_object())
1158
+			{
1159
+				return false;
1160
+			}
1079 1161
 
1080 1162
 			$this->accounts->search(array(
1081 1163
 				'type'   => 'accounts',
@@ -1162,9 +1244,15 @@  discard block
 block discarded – undo
1162 1244
 	{
1163 1245
 		static $table_names = False;
1164 1246
 
1165
-		if (!$table_names || $force_refresh) $table_names = $this->db->table_names();
1247
+		if (!$table_names || $force_refresh)
1248
+		{
1249
+			$table_names = $this->db->table_names();
1250
+		}
1166 1251
 
1167
-		if (!$table_names) return false;
1252
+		if (!$table_names)
1253
+		{
1254
+			return false;
1255
+		}
1168 1256
 
1169 1257
 		foreach($table_names as $data)
1170 1258
 		{
@@ -1194,10 +1282,13 @@  discard block
 block discarded – undo
1194 1282
 		{
1195 1283
 			$table = $this->table_exist($tables,$force_refresh);
1196 1284
 
1197
-			if ($table && $table != $this->$name)	// only overwrite the default name, if we realy got one (important for new installs)
1285
+			if ($table && $table != $this->$name)
1286
+			{
1287
+				// only overwrite the default name, if we realy got one (important for new installs)
1198 1288
 			{
1199 1289
 				$this->$name = $table;
1200 1290
 			}
1291
+			}
1201 1292
 			//echo "<p>setup::set_table_names: $name = '{$this->$name}'</p>\n";
1202 1293
 		}
1203 1294
 	}
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	var $recommended_php_version = '5.6';
75 75
 
76
-	function __construct($html=False, $translation=False)
76
+	function __construct($html = False, $translation = False)
77 77
 	{
78 78
 		// setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects
79
-		$GLOBALS['egw_setup'] =& $this;
79
+		$GLOBALS['egw_setup'] = & $this;
80 80
 
81 81
 		if (!is_object($GLOBALS['egw']))
82 82
 		{
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	 * include api db class for the ConfigDomain and connect to the db
97 97
 	 */
98
-	function loaddb($connect_and_setcharset=true)
98
+	function loaddb($connect_and_setcharset = true)
99 99
 	{
100
-		if(!isset($this->ConfigDomain) || empty($this->ConfigDomain))
100
+		if (!isset($this->ConfigDomain) || empty($this->ConfigDomain))
101 101
 		{
102 102
 			$this->ConfigDomain = isset($_REQUEST['ConfigDomain']) ? $_REQUEST['ConfigDomain'] : $_POST['FormDomain'];
103 103
 		}
@@ -121,24 +121,24 @@  discard block
 block discarded – undo
121 121
 		if ($connect_and_setcharset)
122 122
 		{
123 123
 			try {
124
-				$this->set_table_names();		// sets/checks config- and applications-table-name
124
+				$this->set_table_names(); // sets/checks config- and applications-table-name
125 125
 
126 126
 				// Set the DB's client charset if a system-charset is set
127
-				if (($this->system_charset = $this->db->select($this->config_table,'config_value',array(
127
+				if (($this->system_charset = $this->db->select($this->config_table, 'config_value', array(
128 128
 						'config_app'  => 'phpgwapi',
129 129
 						'config_name' => 'system_charset',
130
-					),__LINE__,__FILE__)->fetchColumn()))
130
+					), __LINE__, __FILE__)->fetchColumn()))
131 131
 				{
132
-					$this->db_charset_was = $this->db->Link_ID->GetCharSet();	// needed for the update
132
+					$this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update
133 133
 
134 134
 					// we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!!
135
-					if (substr($this->db->Type,0,5) == 'mysql')	// we need to check the api version
135
+					if (substr($this->db->Type, 0, 5) == 'mysql')	// we need to check the api version
136 136
 					{
137
-						$api_version = $this->db->select($this->applications_table,'app_version',array(
137
+						$api_version = $this->db->select($this->applications_table, 'app_version', array(
138 138
 								'app_name'  => 'phpgwapi',
139
-							),__LINE__,__FILE__)->fetchColumn();
139
+							), __LINE__, __FILE__)->fetchColumn();
140 140
 					}
141
-					if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019'))
141
+					if (!$api_version || !$this->alessthanb($api_version, '1.0.1.019'))
142 142
 					{
143 143
 						$this->db->Link_ID->SetCharSet($this->system_charset);
144 144
 					}
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
 	static function cookiedomain()
159 159
 	{
160 160
 		// Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy
161
-		$cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ?  $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'];
161
+		$cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'];
162 162
 
163 163
 		// remove port from HTTP_HOST
164 164
 		$arr = null;
165
-		if (preg_match("/^(.*):(.*)$/",$cookie_domain,$arr))
165
+		if (preg_match("/^(.*):(.*)$/", $cookie_domain, $arr))
166 166
 		{
167 167
 			$cookie_domain = $arr[1];
168 168
 		}
169
-		if (count(explode('.',$cookie_domain)) <= 1)
169
+		if (count(explode('.', $cookie_domain)) <= 1)
170 170
 		{
171 171
 			// setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in
172 172
 			$cookie_domain = '';
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	* @param string $cookievalue value to be used, if unset cookie is cleared (optional)
182 182
 	* @param int $cookietime when cookie should expire, 0 for session only (optional)
183 183
 	*/
184
-	function set_cookie($cookiename,$cookievalue='',$cookietime=0)
184
+	function set_cookie($cookiename, $cookievalue = '', $cookietime = 0)
185 185
 	{
186
-		if(!isset($this->cookie_domain))
186
+		if (!isset($this->cookie_domain))
187 187
 		{
188 188
 			$this->cookie_domain = self::cookiedomain();
189 189
 		}
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 			if (!isset($_SESSION)) self::session_start();
209 209
 			$ConfigLang = $_SESSION['ConfigLang'];
210 210
 		}
211
-		if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang))
211
+		if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $ConfigLang))
212 212
 		{
213
-			$ConfigLang = null;	// not returning 'en', as it suppresses the language selection in check_install and manageheader
213
+			$ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader
214 214
 		}
215 215
 		//error_log(__METHOD__."() \$_POST['ConfigLang']=".array2string($_POST['ConfigLang']).", \$_SESSION['ConfigLang']=".array2string($_SESSION['ConfigLang'])." returning ".array2string($ConfigLang));
216 216
 		return $ConfigLang;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 		if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]);
244 244
 
245
-		$ok = @session_start();	// suppress notice if session already started or warning in CLI
245
+		$ok = @session_start(); // suppress notice if session already started or warning in CLI
246 246
 		// need to decrypt session, in case session encryption is switched on in header.inc.php
247 247
 		Api\Session::decrypt();
248 248
 		//error_log(__METHOD__."() returning ".array2string($ok).' _SESSION='.array2string($_SESSION));
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @param string $_auth_type ='config' 'config' or 'header' (caseinsensitiv)
256 256
 	 */
257
-	function auth($_auth_type='config')
257
+	function auth($_auth_type = 'config')
258 258
 	{
259 259
 		$auth_type = strtolower($_auth_type);
260 260
 		$GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = '';
261 261
 
262
-		if(!$this->checkip(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
262
+		if (!$this->checkip(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
263 263
 			$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']))
264 264
 		{
265 265
 			//error_log(__METHOD__."('$auth_type') invalid IP");
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			//error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION).", \$_POST=".array2string($_POST));
273 273
 			if (isset($_REQUEST['FormLogout']))
274 274
 			{
275
-				$this->set_cookie(self::SESSIONID, '', time()-86400);
275
+				$this->set_cookie(self::SESSIONID, '', time() - 86400);
276 276
 				session_destroy();
277 277
 				if ($_REQUEST['FormLogout'] == 'config')
278 278
 				{
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 			{
289 289
 				return false;
290 290
 			}
291
-			switch($auth_type)
291
+			switch ($auth_type)
292 292
 			{
293 293
 				case 'config':
294 294
 					if (!isset($GLOBALS['egw_domain'][$_POST['FormDomain']]) ||
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		//error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION));
329 329
 		if ($_SESSION['egw_last_action_time'] < time() - self::TIMEOUT)
330 330
 		{
331
-			$this->set_cookie(self::SESSIONID, '', time()-86400);
331
+			$this->set_cookie(self::SESSIONID, '', time() - 86400);
332 332
 			session_destroy();
333 333
 			$GLOBALS['egw_info']['setup'][$_SESSION['egw_setup_auth_type'] == 'config' ? 'ConfigLoginMSG' : 'HeaderLoginMSG'] =
334 334
 				lang('Session expired');
@@ -383,37 +383,37 @@  discard block
 block discarded – undo
383 383
 	 * @param string $remoteip
384 384
 	 * @return boolean
385 385
 	 */
386
-	function checkip($remoteip='')
386
+	function checkip($remoteip = '')
387 387
 	{
388 388
 		//echo "<p>setup::checkip($remoteip) against setup_acl='".$GLOBALS['egw_info']['server']['setup_acl']."'</p>\n";
389
-		$allowed_ips = explode(',',@$GLOBALS['egw_info']['server']['setup_acl']);
390
-		if(empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips))
389
+		$allowed_ips = explode(',', @$GLOBALS['egw_info']['server']['setup_acl']);
390
+		if (empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips))
391 391
 		{
392
-			return True;	// no test
392
+			return True; // no test
393 393
 		}
394
-		$remotes = explode('.',$remoteip);
395
-		foreach($allowed_ips as $value)
394
+		$remotes = explode('.', $remoteip);
395
+		foreach ($allowed_ips as $value)
396 396
 		{
397
-			if (!preg_match('/^[0-9.]+$/',$value))
397
+			if (!preg_match('/^[0-9.]+$/', $value))
398 398
 			{
399
-				$value = gethostbyname($was=$value);		// resolve domain-name, eg. a dyndns account
399
+				$value = gethostbyname($was = $value); // resolve domain-name, eg. a dyndns account
400 400
 				//echo "resolving '$was' to '$value'<br>\n";
401 401
 			}
402
-			$values = explode('.',$value);
403
-			for($i = 0; $i < count($values); ++$i)
402
+			$values = explode('.', $value);
403
+			for ($i = 0; $i < count($values); ++$i)
404 404
 			{
405
-				if ((int) $values[$i] != (int) $remotes[$i])
405
+				if ((int)$values[$i] != (int)$remotes[$i])
406 406
 				{
407 407
 					break;
408 408
 				}
409 409
 			}
410 410
 			if ($i == count($values))
411 411
 			{
412
-				return True;	// match
412
+				return True; // match
413 413
 			}
414 414
 		}
415 415
 		$GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = lang('Invalid IP address').' '.$remoteip;
416
-		error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip,true));
416
+		error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip, true));
417 417
 		return False;
418 418
 	}
419 419
 
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	function get_major($versionstring)
426 426
 	{
427
-		if(!$versionstring)
427
+		if (!$versionstring)
428 428
 		{
429 429
 			return False;
430 430
 		}
431 431
 
432
-		$version = str_replace('pre','.',$versionstring);
433
-		$varray  = explode('.',$version);
434
-		$major   = implode('.',array($varray[0],$varray[1],$varray[2]));
432
+		$version = str_replace('pre', '.', $versionstring);
433
+		$varray  = explode('.', $version);
434
+		$major   = implode('.', array($varray[0], $varray[1], $varray[2]));
435 435
 
436 436
 		return $major;
437 437
 	}
@@ -452,55 +452,55 @@  discard block
 block discarded – undo
452 452
 	 * @param $_enable =99 set to True/False to override setup.inc.php setting
453 453
 	 * @param array $setup_info =null default use $GLOBALS['setup_info']
454 454
 	 */
455
-	function register_app($appname, $_enable=99, array $setup_info=null)
455
+	function register_app($appname, $_enable = 99, array $setup_info = null)
456 456
 	{
457 457
 		if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info'];
458 458
 
459
-		if(!$appname)
459
+		if (!$appname)
460 460
 		{
461 461
 			return False;
462 462
 		}
463 463
 
464
-		if($_enable == 99)
464
+		if ($_enable == 99)
465 465
 		{
466 466
 			$_enable = $setup_info[$appname]['enable'];
467 467
 		}
468 468
 		$enable = (int)$_enable;
469 469
 
470
-		if($GLOBALS['DEBUG'])
470
+		if ($GLOBALS['DEBUG'])
471 471
 		{
472
-			echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', tables: ' . implode(', ',$setup_info[$appname]['tables']) . '<br>';
472
+			echo '<br>register_app(): '.$appname.', version: '.$setup_info[$appname]['version'].', tables: '.implode(', ', $setup_info[$appname]['tables']).'<br>';
473 473
 			// _debug_array($setup_info[$appname]);
474 474
 		}
475 475
 
476
-		if($setup_info[$appname]['version'])
476
+		if ($setup_info[$appname]['version'])
477 477
 		{
478
-			if($setup_info[$appname]['tables'])
478
+			if ($setup_info[$appname]['tables'])
479 479
 			{
480
-				$tables = implode(',',$setup_info[$appname]['tables']);
480
+				$tables = implode(',', $setup_info[$appname]['tables']);
481 481
 			}
482 482
 			if ($setup_info[$appname]['tables_use_prefix'] == True)
483 483
 			{
484
-				if($GLOBALS['DEBUG'])
484
+				if ($GLOBALS['DEBUG'])
485 485
 				{
486
-					echo "<br>$appname uses tables_use_prefix, storing ". $setup_info[$appname]['tables_prefix']." as prefix for tables\n";
486
+					echo "<br>$appname uses tables_use_prefix, storing ".$setup_info[$appname]['tables_prefix']." as prefix for tables\n";
487 487
 				}
488
-				$this->db->insert($this->config_table,array(
488
+				$this->db->insert($this->config_table, array(
489 489
 						'config_app'	=> $appname,
490 490
 						'config_name'	=> $appname.'_tables_prefix',
491 491
 						'config_value'	=> $setup_info[$appname]['tables_prefix'],
492
-					),False,__LINE__,__FILE__);
492
+					), False, __LINE__, __FILE__);
493 493
 			}
494
-			$this->db->insert($this->applications_table,array(
494
+			$this->db->insert($this->applications_table, array(
495 495
 					'app_name'		=> $appname,
496 496
 					'app_enabled'	=> $enable,
497 497
 					'app_order'		=> $setup_info[$appname]['app_order'],
498
-					'app_tables'	=> (string)$tables,	// app_tables is NOT NULL
498
+					'app_tables'	=> (string)$tables, // app_tables is NOT NULL
499 499
 					'app_version'	=> $setup_info[$appname]['version'],
500 500
 					'app_index'     => $setup_info[$appname]['index'],
501 501
 					'app_icon'      => $setup_info[$appname]['icon'],
502 502
 					'app_icon_app'  => $setup_info[$appname]['icon_app'],
503
-				),False,__LINE__,__FILE__);
503
+				), False, __LINE__, __FILE__);
504 504
 
505 505
 			Api\Egw\Applications::invalidate();
506 506
 		}
@@ -514,26 +514,26 @@  discard block
 block discarded – undo
514 514
 	 */
515 515
 	function app_registered($appname)
516 516
 	{
517
-		if(!$appname)
517
+		if (!$appname)
518 518
 		{
519 519
 			return False;
520 520
 		}
521 521
 
522
-		if(@$GLOBALS['DEBUG'])
522
+		if (@$GLOBALS['DEBUG'])
523 523
 		{
524
-			echo '<br>app_registered(): checking ' . $appname . ', table: ' . $this->applications_table;
524
+			echo '<br>app_registered(): checking '.$appname.', table: '.$this->applications_table;
525 525
 			// _debug_array($setup_info[$appname]);
526 526
 		}
527 527
 
528
-		if ($this->db->select($this->applications_table,'COUNT(*)',array('app_name' => $appname),__LINE__,__FILE__)->fetchColumn())
528
+		if ($this->db->select($this->applications_table, 'COUNT(*)', array('app_name' => $appname), __LINE__, __FILE__)->fetchColumn())
529 529
 		{
530
-			if(@$GLOBALS['DEBUG'])
530
+			if (@$GLOBALS['DEBUG'])
531 531
 			{
532 532
 				echo '... app previously registered.';
533 533
 			}
534 534
 			return True;
535 535
 		}
536
-		if(@$GLOBALS['DEBUG'])
536
+		if (@$GLOBALS['DEBUG'])
537 537
 		{
538 538
 			echo '... app not registered';
539 539
 		}
@@ -546,42 +546,42 @@  discard block
 block discarded – undo
546 546
 	 * @param string $appname	Application 'name' with a matching $setup_info[$appname] array slice
547 547
 	 * @param array $setup_info =null default use $GLOBALS['setup_info']
548 548
 	 */
549
-	function update_app($appname, array $setup_info=null)
549
+	function update_app($appname, array $setup_info = null)
550 550
 	{
551 551
 		if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info'];
552 552
 
553
-		if(!$appname)
553
+		if (!$appname)
554 554
 		{
555 555
 			return False;
556 556
 		}
557 557
 
558
-		if($GLOBALS['DEBUG'])
558
+		if ($GLOBALS['DEBUG'])
559 559
 		{
560
-			echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $this->applications_table . '<br>';
560
+			echo '<br>update_app(): '.$appname.', version: '.$setup_info[$appname]['currentver'].', table: '.$this->applications_table.'<br>';
561 561
 			// _debug_array($setup_info[$appname]);
562 562
 		}
563 563
 
564
-		if(!$this->app_registered($appname))
564
+		if (!$this->app_registered($appname))
565 565
 		{
566 566
 			return False;
567 567
 		}
568 568
 
569
-		if($setup_info[$appname]['version'])
569
+		if ($setup_info[$appname]['version'])
570 570
 		{
571 571
 			//echo '<br>' . $setup_info[$appname]['version'];
572
-			if($setup_info[$appname]['tables'])
572
+			if ($setup_info[$appname]['tables'])
573 573
 			{
574
-				$tables = implode(',',$setup_info[$appname]['tables']);
574
+				$tables = implode(',', $setup_info[$appname]['tables']);
575 575
 			}
576
-			$this->db->update($this->applications_table,array(
576
+			$this->db->update($this->applications_table, array(
577 577
 					'app_enabled'	=> $setup_info[$appname]['enable'],
578 578
 					'app_order'		=> $setup_info[$appname]['app_order'],
579
-					'app_tables'	=> (string)$tables,	// app_tables is NOT NULL
579
+					'app_tables'	=> (string)$tables, // app_tables is NOT NULL
580 580
 					'app_version'	=> $setup_info[$appname]['version'],
581 581
 					'app_index'     => $setup_info[$appname]['index'],
582 582
 					'app_icon'      => $setup_info[$appname]['icon'],
583 583
 					'app_icon_app'  => $setup_info[$appname]['icon_app'],
584
-				),array('app_name'=>$appname),__LINE__,__FILE__);
584
+				), array('app_name'=>$appname), __LINE__, __FILE__);
585 585
 
586 586
 			Api\Egw\Applications::invalidate();
587 587
 		}
@@ -596,20 +596,20 @@  discard block
 block discarded – undo
596 596
 	 */
597 597
 	function update_app_version($setup_info, $appname, $tableschanged = True)
598 598
 	{
599
-		if(!$appname)
599
+		if (!$appname)
600 600
 		{
601 601
 			return False;
602 602
 		}
603 603
 
604
-		if($tableschanged == True)
604
+		if ($tableschanged == True)
605 605
 		{
606 606
 			$GLOBALS['egw_info']['setup']['tableschanged'] = True;
607 607
 		}
608
-		if($setup_info[$appname]['currentver'])
608
+		if ($setup_info[$appname]['currentver'])
609 609
 		{
610
-			$this->db->update($this->applications_table,array(
610
+			$this->db->update($this->applications_table, array(
611 611
 					'app_version'	=> $setup_info[$appname]['currentver'],
612
-				),array('app_name'=>$appname),__LINE__,__FILE__);
612
+				), array('app_name'=>$appname), __LINE__, __FILE__);
613 613
 
614 614
 			Api\Egw\Applications::invalidate();
615 615
 		}
@@ -623,22 +623,22 @@  discard block
 block discarded – undo
623 623
 	 */
624 624
 	function deregister_app($appname)
625 625
 	{
626
-		if(!$appname)
626
+		if (!$appname)
627 627
 		{
628 628
 			return False;
629 629
 		}
630 630
 
631 631
 		// Remove categories
632
-		$this->db->delete(Api\Categories::TABLE, array('cat_appname'=>$appname),__LINE__,__FILE__);
632
+		$this->db->delete(Api\Categories::TABLE, array('cat_appname'=>$appname), __LINE__, __FILE__);
633 633
 		Api\Categories::invalidate_cache($appname);
634 634
 
635 635
 		// Remove config, if we are not deinstalling old phpgwapi (as that's global api config!)
636 636
 		if ($appname != 'phpgwapi')
637 637
 		{
638
-			$this->db->delete(Api\Config::TABLE, array('config_app'=>$appname),__LINE__,__FILE__);
638
+			$this->db->delete(Api\Config::TABLE, array('config_app'=>$appname), __LINE__, __FILE__);
639 639
 		}
640 640
 		//echo 'DELETING application: ' . $appname;
641
-		$this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__);
641
+		$this->db->delete($this->applications_table, array('app_name'=>$appname), __LINE__, __FILE__);
642 642
 
643 643
 		Api\Egw\Applications::invalidate();
644 644
 
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 */
654 654
 	function register_hooks($appname)
655 655
 	{
656
-		if(!$appname)
656
+		if (!$appname)
657 657
 		{
658 658
 			return False;
659 659
 		}
@@ -673,21 +673,21 @@  discard block
 block discarded – undo
673 673
 
674 674
 		if (!isset($setup_info) || !isset($setup_info['hooks']))
675 675
 		{
676
-			return false;	// app not found or no hook
676
+			return false; // app not found or no hook
677 677
 		}
678 678
 		$GLOBALS['settings'] = array();
679
-		$hook_data = array('location' => 'settings','setup' => true);
679
+		$hook_data = array('location' => 'settings', 'setup' => true);
680 680
 		if (isset($setup_info['hooks']['settings']))
681 681
 		{
682
-			$settings = ExecMethod($setup_info['hooks']['settings'],$hook_data);
682
+			$settings = ExecMethod($setup_info['hooks']['settings'], $hook_data);
683 683
 		}
684
-		elseif(in_array('settings',$setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php'))
684
+		elseif (in_array('settings', $setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php'))
685 685
 		{
686 686
 			include_once($file);
687 687
 		}
688 688
 		if (!isset($settings) || !is_array($settings))
689 689
 		{
690
-			$settings = $GLOBALS['settings'];	// old file hook or not updated new hook
690
+			$settings = $GLOBALS['settings']; // old file hook or not updated new hook
691 691
 		}
692 692
 		if (!is_array($settings) || !count($settings))
693 693
 		{
@@ -700,10 +700,10 @@  discard block
 block discarded – undo
700 700
 		{
701 701
 			$GLOBALS['settings'] = array();
702 702
 			include_once($file);
703
-			if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']);
703
+			if ($GLOBALS['settings']) $settings = array_merge($settings, $GLOBALS['settings']);
704 704
 		}
705 705
 		$default = $forced = array();
706
-		foreach($settings as $name => $setting)
706
+		foreach ($settings as $name => $setting)
707 707
 		{
708 708
 			if (isset($setting['default']))
709 709
 			{
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 		// store default/forced preferences, if any found
718 718
 		$preferences = new Api\Preferences();
719 719
 		$preferences->read_repository(false);
720
-		foreach(array(
720
+		foreach (array(
721 721
 			'default' => $default,
722 722
 			'forced'  => $forced,
723 723
 		) as $type => $prefs)
724 724
 		{
725 725
 			if ($prefs)
726 726
 			{
727
-				foreach($prefs as $name => $value)
727
+				foreach ($prefs as $name => $value)
728 728
 				{
729 729
 					$preferences->add($appname == 'preferences' ? 'common' : $appname, $name, $value, $type);
730 730
 				}
@@ -741,9 +741,9 @@  discard block
 block discarded – undo
741 741
 	  * @param $location hook location - required
742 742
 	  * @param $appname application name - optional
743 743
 	 */
744
-	static function hook($location, $appname='')
744
+	static function hook($location, $appname = '')
745 745
 	{
746
-		return Api\Hooks::single($location,$appname,True,True);
746
+		return Api\Hooks::single($location, $appname, True, True);
747 747
 	}
748 748
 
749 749
 	/**
@@ -752,82 +752,82 @@  discard block
 block discarded – undo
752 752
 	 * @param	$b	phpgw version number to check $a against
753 753
 	 * @return	True if $a < $b
754 754
 	 */
755
-	function alessthanb($a,$b,$DEBUG=False)
755
+	function alessthanb($a, $b, $DEBUG = False)
756 756
 	{
757
-		$num = array('1st','2nd','3rd','4th');
757
+		$num = array('1st', '2nd', '3rd', '4th');
758 758
 
759
-		if($DEBUG)
759
+		if ($DEBUG)
760 760
 		{
761 761
 			echo'<br>Input values: '
762 762
 				. 'A="'.$a.'", B="'.$b.'"';
763 763
 		}
764
-		$newa = str_replace('pre','.',$a);
765
-		$newb = str_replace('pre','.',$b);
766
-		$testa = explode('.',$newa);
767
-		if(@$testa[1] == '')
764
+		$newa = str_replace('pre', '.', $a);
765
+		$newb = str_replace('pre', '.', $b);
766
+		$testa = explode('.', $newa);
767
+		if (@$testa[1] == '')
768 768
 		{
769 769
 			$testa[1] = 0;
770 770
 		}
771 771
 
772
-		$testb = explode('.',$newb);
773
-		if(@$testb[1] == '')
772
+		$testb = explode('.', $newb);
773
+		if (@$testb[1] == '')
774 774
 		{
775 775
 			$testb[1] = 0;
776 776
 		}
777
-		if(@$testb[3] == '')
777
+		if (@$testb[3] == '')
778 778
 		{
779 779
 			$testb[3] = 0;
780 780
 		}
781 781
 		$less = 0;
782 782
 
783
-		for($i=0;$i<count($testa);$i++)
783
+		for ($i = 0; $i < count($testa); $i++)
784 784
 		{
785
-			if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; }
786
-			if((int)$testa[$i] < (int)$testb[$i])
785
+			if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is less than '.(int)$testb[$i].' ...'; }
786
+			if ((int)$testa[$i] < (int)$testb[$i])
787 787
 			{
788 788
 				if ($DEBUG) { echo ' yes.'; }
789 789
 				$less++;
790
-				if($i<3)
790
+				if ($i < 3)
791 791
 				{
792 792
 					/* Ensure that this is definitely smaller */
793
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely less than B."; }
793
+					if ($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely less than B."; }
794 794
 					$less = 5;
795 795
 					break;
796 796
 				}
797 797
 			}
798
-			elseif((int)$testa[$i] > (int)$testb[$i])
798
+			elseif ((int)$testa[$i] > (int)$testb[$i])
799 799
 			{
800
-				if($DEBUG) { echo ' no.'; }
800
+				if ($DEBUG) { echo ' no.'; }
801 801
 				$less--;
802
-				if($i<2)
802
+				if ($i < 2)
803 803
 				{
804 804
 					/* Ensure that this is definitely greater */
805
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
805
+					if ($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
806 806
 					$less = -5;
807 807
 					break;
808 808
 				}
809 809
 			}
810 810
 			else
811 811
 			{
812
-				if($DEBUG) { echo ' no, they are equal or of different length.'; }
812
+				if ($DEBUG) { echo ' no, they are equal or of different length.'; }
813 813
 				// makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' !
814 814
 				$less = count($testa) < count($testb) ? 1 : 0;
815 815
 			}
816 816
 		}
817
-		if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
818
-		if($less>0)
817
+		if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
818
+		if ($less > 0)
819 819
 		{
820
-			if($DEBUG) { echo '<br>A is less than B'; }
820
+			if ($DEBUG) { echo '<br>A is less than B'; }
821 821
 			return True;
822 822
 		}
823
-		elseif($less<0)
823
+		elseif ($less < 0)
824 824
 		{
825
-			if($DEBUG) { echo '<br>A is greater than B'; }
825
+			if ($DEBUG) { echo '<br>A is greater than B'; }
826 826
 			return False;
827 827
 		}
828 828
 		else
829 829
 		{
830
-			if($DEBUG) { echo '<br>A is equal to B'; }
830
+			if ($DEBUG) { echo '<br>A is equal to B'; }
831 831
 			return False;
832 832
 		}
833 833
 	}
@@ -839,76 +839,76 @@  discard block
 block discarded – undo
839 839
 	 * @param	$b	phpgw version number to check $a against
840 840
 	 * @return	True if $a < $b
841 841
 	 */
842
-	function amorethanb($a,$b,$DEBUG=False)
842
+	function amorethanb($a, $b, $DEBUG = False)
843 843
 	{
844
-		$num = array('1st','2nd','3rd','4th');
844
+		$num = array('1st', '2nd', '3rd', '4th');
845 845
 
846
-		if($DEBUG)
846
+		if ($DEBUG)
847 847
 		{
848 848
 			echo'<br>Input values: '
849 849
 				. 'A="'.$a.'", B="'.$b.'"';
850 850
 		}
851
-		$newa = str_replace('pre','.',$a);
852
-		$newb = str_replace('pre','.',$b);
853
-		$testa = explode('.',$newa);
854
-		if($testa[3] == '')
851
+		$newa = str_replace('pre', '.', $a);
852
+		$newb = str_replace('pre', '.', $b);
853
+		$testa = explode('.', $newa);
854
+		if ($testa[3] == '')
855 855
 		{
856 856
 			$testa[3] = 0;
857 857
 		}
858
-		$testb = explode('.',$newb);
859
-		if($testb[3] == '')
858
+		$testb = explode('.', $newb);
859
+		if ($testb[3] == '')
860 860
 		{
861 861
 			$testb[3] = 0;
862 862
 		}
863 863
 		$less = 0;
864 864
 
865
-		for($i=0;$i<count($testa);$i++)
865
+		for ($i = 0; $i < count($testa); $i++)
866 866
 		{
867
-			if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; }
868
-			if((int)$testa[$i] > (int)$testb[$i])
867
+			if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is more than '.(int)$testb[$i].' ...'; }
868
+			if ((int)$testa[$i] > (int)$testb[$i])
869 869
 			{
870
-				if($DEBUG) { echo ' yes.'; }
870
+				if ($DEBUG) { echo ' yes.'; }
871 871
 				$less++;
872
-				if($i<3)
872
+				if ($i < 3)
873 873
 				{
874 874
 					/* Ensure that this is definitely greater */
875
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
875
+					if ($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely greater than B."; }
876 876
 					$less = 5;
877 877
 					break;
878 878
 				}
879 879
 			}
880
-			elseif((int)$testa[$i] < (int)$testb[$i])
880
+			elseif ((int)$testa[$i] < (int)$testb[$i])
881 881
 			{
882
-				if($DEBUG) { echo ' no.'; }
882
+				if ($DEBUG) { echo ' no.'; }
883 883
 				$less--;
884
-				if($i<2)
884
+				if ($i < 2)
885 885
 				{
886 886
 					/* Ensure that this is definitely smaller */
887
-					if($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely less than B."; }
887
+					if ($DEBUG) { echo"  This is the $num[$i] octet, so A is definitely less than B."; }
888 888
 					$less = -5;
889 889
 					break;
890 890
 				}
891 891
 			}
892 892
 			else
893 893
 			{
894
-				if($DEBUG) { echo ' no, they are equal.'; }
894
+				if ($DEBUG) { echo ' no, they are equal.'; }
895 895
 				$less = 0;
896 896
 			}
897 897
 		}
898
-		if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
899
-		if($less>0)
898
+		if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
899
+		if ($less > 0)
900 900
 		{
901
-			if($DEBUG) { echo '<br>A is greater than B'; }
901
+			if ($DEBUG) { echo '<br>A is greater than B'; }
902 902
 			return True;
903 903
 		}
904
-		elseif($less<0)
904
+		elseif ($less < 0)
905 905
 		{
906
-			if($DEBUG) { echo '<br>A is less than B'; }
906
+			if ($DEBUG) { echo '<br>A is less than B'; }
907 907
 			return False;
908 908
 		}
909 909
 		else
910 910
 		{
911
-			if($DEBUG) { echo '<br>A is equal to B'; }
911
+			if ($DEBUG) { echo '<br>A is equal to B'; }
912 912
 			return False;
913 913
 		}
914 914
 	}
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 	 */
921 921
 	var $accounts;
922 922
 
923
-	function setup_account_object(array $config=array())
923
+	function setup_account_object(array $config = array())
924 924
 	{
925 925
 		if (!isset($this->accounts) || $this->accounts->config || $config)
926 926
 		{
@@ -931,9 +931,9 @@  discard block
 block discarded – undo
931 931
 			if (!$config)
932 932
 			{
933 933
 				// load the configuration from the database
934
-				foreach($this->db->select($this->config_table,'config_name,config_value',
934
+				foreach ($this->db->select($this->config_table, 'config_name,config_value',
935 935
 					"config_name LIKE 'ads%' OR config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'",
936
-					__LINE__,__FILE__) as $row)
936
+					__LINE__, __FILE__) as $row)
937 937
 				{
938 938
 					$GLOBALS['egw_info']['server'][$row['config_name']] = $config[$row['config_name']] = $row['config_value'];
939 939
 				}
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 				return false;
947 947
 			}
948 948
 			if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts;
949
-			Api\Accounts::cache_invalidate();	// the cache is shared for all instances of the class
949
+			Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class
950 950
 		}
951 951
 		return true;
952 952
 	}
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 	 * @param string &$anonpw=null on return password for anonymous user
973 973
 	 * @return int the numerical user-id
974 974
 	 */
975
-	function add_account($username,$first,$last,$passwd,$primary_group='Default',$changepw=False,$email='',&$anonpw=null)
975
+	function add_account($username, $first, $last, $passwd, $primary_group = 'Default', $changepw = False, $email = '', &$anonpw = null)
976 976
 	{
977 977
 		$this->setup_account_object();
978 978
 
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 			$passwd = $anonpw = $this->anonpw;
985 985
 		}
986 986
 
987
-		if(!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g')))
987
+		if (!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g')))
988 988
 		{
989 989
 			$account = array(
990 990
 				'account_type'      => $primary_group ? 'u' : 'g',
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 			}
1006 1006
 		}
1007 1007
 		// set password for existing account, if given and not '*unchanged*'
1008
-		elseif($passwd && $passwd != '*unchanged*')
1008
+		elseif ($passwd && $passwd != '*unchanged*')
1009 1009
 		{
1010 1010
 			try {
1011 1011
 				$auth = new Api\Auth;
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		{
1044 1044
 			$this->set_memberships(array($primary_group_id), $accountid);
1045 1045
 
1046
-			if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid);
1046
+			if (!$changepw) $this->add_acl('preferences', 'nopasswordchange', $accountid);
1047 1047
 		}
1048 1048
 		//error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid");
1049 1049
 		return $accountid;
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	 * @param int|string $account accountid or account_lid
1120 1120
 	 * @param int $rights rights to set, default 1
1121 1121
 	 */
1122
-	function add_acl($apps,$location,$account,$rights=1)
1122
+	function add_acl($apps, $location, $account, $rights = 1)
1123 1123
 	{
1124 1124
 		//error_log("setup::add_acl(".(is_array($apps) ? "array('".implode("','",$apps)."')" : "'$apps'").",'$location',$account,$rights)");
1125 1125
 		if (!is_numeric($account))
@@ -1127,32 +1127,32 @@  discard block
 block discarded – undo
1127 1127
 			$this->setup_account_object();
1128 1128
 			$account = $this->accounts->name2id($account);
1129 1129
 		}
1130
-		if(!is_object($this->db))
1130
+		if (!is_object($this->db))
1131 1131
 		{
1132 1132
 			$this->loaddb();
1133 1133
 		}
1134 1134
 
1135
-		if(!is_array($apps))
1135
+		if (!is_array($apps))
1136 1136
 		{
1137 1137
 			$apps = array($apps);
1138 1138
 		}
1139
-		foreach($apps as $app)
1139
+		foreach ($apps as $app)
1140 1140
 		{
1141
-			$this->db->delete($this->acl_table,array(
1141
+			$this->db->delete($this->acl_table, array(
1142 1142
 				'acl_appname'  => $app,
1143 1143
 				'acl_location' => $location,
1144 1144
 				'acl_account'  => $account
1145
-			),__LINE__,__FILE__);
1145
+			), __LINE__, __FILE__);
1146 1146
 
1147
-			if ((int) $rights)
1147
+			if ((int)$rights)
1148 1148
 			{
1149
-				$this->db->insert($this->acl_table,array(
1149
+				$this->db->insert($this->acl_table, array(
1150 1150
 					'acl_rights' => $rights
1151
-				),array(
1151
+				), array(
1152 1152
 					'acl_appname'  => $app,
1153 1153
 					'acl_location' => $location,
1154 1154
 					'acl_account'  => $account,
1155
-				),__LINE__,__FILE__);
1155
+				), __LINE__, __FILE__);
1156 1156
 			}
1157 1157
 		}
1158 1158
 	}
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 	 * @param array $tables array with possible table-names
1164 1164
 	 * @return string/boolean tablename or false
1165 1165
 	 */
1166
-	function table_exist($tables,$force_refresh=False)
1166
+	function table_exist($tables, $force_refresh = False)
1167 1167
 	{
1168 1168
 		static $table_names = False;
1169 1169
 
@@ -1171,9 +1171,9 @@  discard block
 block discarded – undo
1171 1171
 
1172 1172
 		if (!$table_names) return false;
1173 1173
 
1174
-		foreach($table_names as $data)
1174
+		foreach ($table_names as $data)
1175 1175
 		{
1176
-			if (($key = array_search($data['table_name'],$tables)) !== false)
1176
+			if (($key = array_search($data['table_name'], $tables)) !== false)
1177 1177
 			{
1178 1178
 				return $tables[$key];
1179 1179
 			}
@@ -1186,18 +1186,18 @@  discard block
 block discarded – undo
1186 1186
 	 *
1187 1187
 	 * Other tables can always use the most up to date name
1188 1188
 	 */
1189
-	function set_table_names($force_refresh=False)
1189
+	function set_table_names($force_refresh = False)
1190 1190
 	{
1191
-		foreach(array(
1192
-			'config_table'       => array('egw_config','phpgw_config','config'),
1193
-			'applications_table' => array('egw_applications','phpgw_applications','applications'),
1194
-			'accounts_table'     => array('egw_accounts','phpgw_accounts'),
1195
-			'acl_table'          => array('egw_acl','phpgw_acl'),
1196
-			'lang_table'         => array('egw_lang','phpgw_lang','lang'),
1197
-			'languages_table'    => array('egw_languages','phpgw_languages','languages'),
1191
+		foreach (array(
1192
+			'config_table'       => array('egw_config', 'phpgw_config', 'config'),
1193
+			'applications_table' => array('egw_applications', 'phpgw_applications', 'applications'),
1194
+			'accounts_table'     => array('egw_accounts', 'phpgw_accounts'),
1195
+			'acl_table'          => array('egw_acl', 'phpgw_acl'),
1196
+			'lang_table'         => array('egw_lang', 'phpgw_lang', 'lang'),
1197
+			'languages_table'    => array('egw_languages', 'phpgw_languages', 'languages'),
1198 1198
 		) as $name => $tables)
1199 1199
 		{
1200
-			$table = $this->table_exist($tables,$force_refresh);
1200
+			$table = $this->table_exist($tables, $force_refresh);
1201 1201
 
1202 1202
 			if ($table && $table != $this->$name)	// only overwrite the default name, if we realy got one (important for new installs)
1203 1203
 			{
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_header.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	/**
36 36
 	 * Constructor
37 37
 	 *
38
-	 * @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments
38
+	 * @param string $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments
39 39
 	 * @param array $arguments =null comand line arguments
40 40
 	 */
41 41
 	function __construct($sub_command='create',$arguments=null)
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments
39 39
 	 * @param array $arguments =null comand line arguments
40 40
 	 */
41
-	function __construct($sub_command='create',$arguments=null)
41
+	function __construct($sub_command = 'create', $arguments = null)
42 42
 	{
43 43
 		if (!is_array($sub_command))
44 44
 		{
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
74 74
 	 * @throws Exception('header.inc.php not found!');
75 75
 	 */
76
-	protected function exec($check_only=false)
76
+	protected function exec($check_only = false)
77 77
 	{
78 78
 		if ($check_only && $this->remote_id)
79 79
 		{
80
-			return true;	// can only check locally
80
+			return true; // can only check locally
81 81
 		}
82 82
 		if (!file_exists($this->header_path) || filesize($this->header_path) < 200)	// redirect header in rpms is ~150 byte
83 83
 		{
84 84
 			if ($this->sub_command != 'create')
85 85
 			{
86
-				throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1);
86
+				throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'), 1);
87 87
 			}
88 88
 			$this->defaults(false);
89 89
 		}
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 			if ($this->sub_command == 'create')
93 93
 			{
94 94
 				throw new Api\Exception\WrongUserinput(
95
-					lang('EGroupware configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'),20);
95
+					lang('EGroupware configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'), 20);
96 96
 			}
97 97
 			if ($this->arguments)
98 98
 			{
99
-				list($this->header_admin_password,$this->header_admin_user) = explode(',',$this->arguments[1]);
99
+				list($this->header_admin_password, $this->header_admin_user) = explode(',', $this->arguments[1]);
100 100
 			}
101
-			$this->check_setup_auth($this->header_admin_user,$this->header_admin_password);	// no domain, we require header access!
101
+			$this->check_setup_auth($this->header_admin_user, $this->header_admin_password); // no domain, we require header access!
102 102
 
103 103
 			$GLOBALS['egw_info']['server']['server_root'] = EGW_SERVER_ROOT;
104 104
 			$GLOBALS['egw_info']['server']['include_root'] = EGW_INCLUDE_ROOT;
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
 				echo '$GLOBALS[egw_info] = '; print_r($GLOBALS['egw_info']);
126 126
 				echo '$GLOBALS[egw_domain] = '; print_r($GLOBALS['egw_domain']);
127 127
 			}
128
-			throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ",$errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"),23);
128
+			throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ", $errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"), 23);
129 129
 		}
130 130
 		if ($check_only)
131 131
 		{
132 132
 			return true;
133 133
 		}
134
-		$header = $this->generate($GLOBALS['egw_info'],$GLOBALS['egw_domain']);
134
+		$header = $this->generate($GLOBALS['egw_info'], $GLOBALS['egw_domain']);
135 135
 
136 136
 		if ($this->arguments)
137 137
 		{
138
-			echo $header;	// for cli, we echo the header
138
+			echo $header; // for cli, we echo the header
139 139
 		}
140 140
 		if (file_exists($this->header_path) && is_writable($this->header_path) || is_writable(dirname($this->header_path)) ||
141 141
 			function_exists('posix_getuid') && !posix_getuid())	// root has all rights
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 			{
145 145
 				unlink($this->header_path);
146 146
 			}
147
-			if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header))
147
+			if (($f = fopen($this->header_path, 'wb')) && fwrite($f, $header))
148 148
 			{
149 149
 				fclose($f);
150 150
 				return lang('header.inc.php successful written.');
151 151
 			}
152 152
 		}
153
-		throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"),24);
153
+		throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"), 24);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 * @param array $args =null
161 161
 	 * @return mixed
162 162
 	 */
163
-	function __call($method,array $args=null)
163
+	function __call($method, array $args = null)
164 164
 	{
165
-		if (method_exists($this->setup_header,$method))
165
+		if (method_exists($this->setup_header, $method))
166 166
 		{
167
-			return call_user_func_array(array($this->setup_header,$method),$args);
167
+			return call_user_func_array(array($this->setup_header, $method), $args);
168 168
 		}
169 169
 	}
170 170
 
@@ -189,21 +189,21 @@  discard block
 block discarded – undo
189 189
 		'--session-type' => array(
190 190
 			'sessions_type' => array(
191 191
 				'type' => 'egw_info/server/',
192
-				'allowed' => array('php'=>'php4','php4'=>'php4','php-restore'=>'php4-restore','php4-restore'=>'php4-restore','db'=>'db'),
192
+				'allowed' => array('php'=>'php4', 'php4'=>'php4', 'php-restore'=>'php4-restore', 'php4-restore'=>'php4-restore', 'db'=>'db'),
193 193
 			),
194 194
 		),
195 195
 		'--session-handler' => array(
196 196
 			'session_handler' => array(
197 197
 				'type' => 'egw_info/server/',
198
-				'allowed' => array('files'=>'files','memcache'=>'memcache','db'=>'db'),
198
+				'allowed' => array('files'=>'files', 'memcache'=>'memcache', 'db'=>'db'),
199 199
 			),
200 200
 		),
201
-		'--limit-access' => 'egw_info/server/setup_acl',	// name used in setup
202
-		'--setup-acl'    => 'egw_info/server/setup_acl',	// alias to match the real name
201
+		'--limit-access' => 'egw_info/server/setup_acl', // name used in setup
202
+		'--setup-acl'    => 'egw_info/server/setup_acl', // alias to match the real name
203 203
 		'--mcrypt' => array(
204 204
 			'mcrypt_enabled' => array(
205 205
 				'type' => 'egw_info/server/',
206
-				'allowed' => array('on' => true,'off' => false),
206
+				'allowed' => array('on' => true, 'off' => false),
207 207
 			),
208 208
 			'mcrypt_iv' => 'egw_info/server/',
209 209
 			'mcrypt' => 'egw_info/versions/mcrypt',
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
 		'--domain-selectbox' => array(
212 212
 			'show_domain_selectbox' => array(
213 213
 				'type' => 'egw_info/server/',
214
-				'allowed' => array('on' => true,'off' => false),
214
+				'allowed' => array('on' => true, 'off' => false),
215 215
 			),
216 216
 		),
217 217
 		'--db-persistent' => array(
218 218
 			'db_persistent' => array(
219 219
 				'type' => 'egw_info/server/',
220
-				'allowed' => array('on' => true,'off' => false),
220
+				'allowed' => array('on' => true, 'off' => false),
221 221
 			),
222 222
 		),
223 223
 		'--domain' => array(
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	private function _parse_properties()
241 241
 	{
242
-		foreach(self::$options as $arg => $option)
242
+		foreach (self::$options as $arg => $option)
243 243
 		{
244
-			foreach(is_array($option) ? $option : array($option => $option) as $name => $data)
244
+			foreach (is_array($option) ? $option : array($option => $option) as $name => $data)
245 245
 			{
246
-				if (strpos($name,'/') !== false)
246
+				if (strpos($name, '/') !== false)
247 247
 				{
248
-					$name = array_pop($parts = explode('/',$name));
248
+					$name = array_pop($parts = explode('/', $name));
249 249
 				}
250 250
 				if (isset($this->$name))
251 251
 				{
252
-					$this->_parse_value($arg,$name,$data,$this->$name);
252
+					$this->_parse_value($arg, $name, $data, $this->$name);
253 253
 				}
254 254
 			}
255 255
 		}
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	private function _parse_cli_arguments()
262 262
 	{
263 263
 		$arguments = $this->arguments;
264
-		while(($arg = array_shift($arguments)))
264
+		while (($arg = array_shift($arguments)))
265 265
 		{
266
-			$values = count($arguments) && substr($arguments[0],0,2) !== '--' ? array_shift($arguments) : 'on';
266
+			$values = count($arguments) && substr($arguments[0], 0, 2) !== '--' ? array_shift($arguments) : 'on';
267 267
 
268 268
 			if ($arg == '--delete-domain')
269 269
 			{
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
 
274 274
 			if (!isset(self::$options[$arg]))
275 275
 			{
276
-				throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90);
276
+				throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!", $arg), 90);
277 277
 			}
278 278
 
279 279
 			$option = self::$options[$arg];
280
-			$vals = !is_array($option) ? array($values) : explode(',',$values);
280
+			$vals = !is_array($option) ? array($values) : explode(',', $values);
281 281
 			if (!is_array($option)) $option = array($option => $option);
282 282
 			$n = 0;
283
-			foreach($option as $name => $data)
283
+			foreach ($option as $name => $data)
284 284
 			{
285 285
 				if ($n >= count($vals)) break;
286 286
 
287
-				$this->_parse_value($arg,$name,$data,$vals[$n++]);
287
+				$this->_parse_value($arg, $name, $data, $vals[$n++]);
288 288
 			}
289 289
 		}
290 290
 	}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	{
299 299
 		if (!isset($GLOBALS['egw_domain'][$domain]))
300 300
 		{
301
-			throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain),92);
301
+			throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!", $domain), 92);
302 302
 		}
303 303
 		unset($GLOBALS['egw_domain'][$domain]);
304 304
 	}
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 * @param array/string $data string with type or array containing values for type, allowed
312 312
 	 * @param mixed $value value to set
313 313
 	 */
314
-	private function _parse_value($arg,$name,$data,$value)
314
+	private function _parse_value($arg, $name, $data, $value)
315 315
 	{
316
-		static $domain=null;
316
+		static $domain = null;
317 317
 
318 318
 		if (!is_array($data)) $data = array('type' => $data);
319 319
 		$type = $data['type'];
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		{
323 323
 			if (!isset($data['allowed'][$value]))
324 324
 			{
325
-				throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1,$arg),91);
325
+				throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1, $arg), 91);
326 326
 			}
327 327
 			$value = $data['allowed'][$value];
328 328
 		}
@@ -331,15 +331,15 @@  discard block
 block discarded – undo
331 331
 			$domain = $arg == '--domain' && !$value ? 'default' : $value;
332 332
 			if ($arg == '--domain' && (!isset($GLOBALS['egw_domain'][$domain]) || $this->sub_command == 'create'))
333 333
 			{
334
-				$GLOBALS['egw_domain'][$domain] = $this->domain_defaults($GLOBALS['egw_info']['server']['header_admin_user'],$GLOBALS['egw_info']['server']['header_admin_password']);
334
+				$GLOBALS['egw_domain'][$domain] = $this->domain_defaults($GLOBALS['egw_info']['server']['header_admin_user'], $GLOBALS['egw_info']['server']['header_admin_password']);
335 335
 			}
336 336
 		}
337 337
 		elseif ($value !== '')
338 338
 		{
339
-			self::_set_value($GLOBALS,str_replace('@',$domain,$type),$name,$value);
339
+			self::_set_value($GLOBALS, str_replace('@', $domain, $type), $name, $value);
340 340
 			if ($type == 'egw_info/server/server_root')
341 341
 			{
342
-				self::_set_value($GLOBALS,'egw_info/server/include_root',$name,$value);
342
+				self::_set_value($GLOBALS, 'egw_info/server/include_root', $name, $value);
343 343
 			}
344 344
 		}
345 345
 	}
@@ -352,15 +352,15 @@  discard block
 block discarded – undo
352 352
 	 * @param string $name additional index to use if $index end with a slash
353 353
 	 * @param mixed $value value to set
354 354
 	 */
355
-	static private function _set_value(&$arr,$index,$name,$value)
355
+	static private function _set_value(&$arr, $index, $name, $value)
356 356
 	{
357
-		if (substr($index,-1) == '/') $index .= $name;
357
+		if (substr($index, -1) == '/') $index .= $name;
358 358
 
359
-		$var =& $arr;
360
-		foreach(explode('/',$index) as $name)
359
+		$var = & $arr;
360
+		foreach (explode('/', $index) as $name)
361 361
 		{
362
-			$var =& $var[$name];
362
+			$var = & $var[$name];
363 363
 		}
364
-		if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value;
364
+		if (true) $var = strpos($name, 'passw') !== false ? md5($value) : $value;
365 365
 	}
366 366
 }
Please login to merge, or discard this patch.
Braces   +32 added lines, -8 removed lines patch added patch discarded remove patch
@@ -79,11 +79,14 @@  discard block
 block discarded – undo
79 79
 		{
80 80
 			return true;	// can only check locally
81 81
 		}
82
-		if (!file_exists($this->header_path) || filesize($this->header_path) < 200)	// redirect header in rpms is ~150 byte
82
+		if (!file_exists($this->header_path) || filesize($this->header_path) < 200)
83
+		{
84
+			// redirect header in rpms is ~150 byte
83 85
 		{
84 86
 			if ($this->sub_command != 'create')
85 87
 			{
86 88
 				throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1);
89
+		}
87 90
 			}
88 91
 			$this->defaults(false);
89 92
 		}
@@ -104,10 +107,13 @@  discard block
 block discarded – undo
104 107
 			$GLOBALS['egw_info']['server']['include_root'] = EGW_INCLUDE_ROOT;
105 108
 		}
106 109
 
107
-		if ($this->arguments)	// we have command line arguments
110
+		if ($this->arguments)
111
+		{
112
+			// we have command line arguments
108 113
 		{
109 114
 			$this->_parse_cli_arguments();
110 115
 		}
116
+		}
111 117
 		elseif ($this->sub_command == 'delete')
112 118
 		{
113 119
 			self::_delete_domain($this->domain);
@@ -138,11 +144,14 @@  discard block
 block discarded – undo
138 144
 			echo $header;	// for cli, we echo the header
139 145
 		}
140 146
 		if (file_exists($this->header_path) && is_writable($this->header_path) || is_writable(dirname($this->header_path)) ||
141
-			function_exists('posix_getuid') && !posix_getuid())	// root has all rights
147
+			function_exists('posix_getuid') && !posix_getuid())
148
+		{
149
+			// root has all rights
142 150
 		{
143 151
 			if (file_exists($this->header_path) && !is_writable($this->header_path))
144 152
 			{
145 153
 				unlink($this->header_path);
154
+		}
146 155
 			}
147 156
 			if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header))
148 157
 			{
@@ -278,11 +287,17 @@  discard block
 block discarded – undo
278 287
 
279 288
 			$option = self::$options[$arg];
280 289
 			$vals = !is_array($option) ? array($values) : explode(',',$values);
281
-			if (!is_array($option)) $option = array($option => $option);
290
+			if (!is_array($option))
291
+			{
292
+				$option = array($option => $option);
293
+			}
282 294
 			$n = 0;
283 295
 			foreach($option as $name => $data)
284 296
 			{
285
-				if ($n >= count($vals)) break;
297
+				if ($n >= count($vals))
298
+				{
299
+					break;
300
+				}
286 301
 
287 302
 				$this->_parse_value($arg,$name,$data,$vals[$n++]);
288 303
 			}
@@ -315,7 +330,10 @@  discard block
 block discarded – undo
315 330
 	{
316 331
 		static $domain=null;
317 332
 
318
-		if (!is_array($data)) $data = array('type' => $data);
333
+		if (!is_array($data))
334
+		{
335
+			$data = array('type' => $data);
336
+		}
319 337
 		$type = $data['type'];
320 338
 
321 339
 		if (isset($data['allowed']))
@@ -354,13 +372,19 @@  discard block
 block discarded – undo
354 372
 	 */
355 373
 	static private function _set_value(&$arr,$index,$name,$value)
356 374
 	{
357
-		if (substr($index,-1) == '/') $index .= $name;
375
+		if (substr($index,-1) == '/')
376
+		{
377
+			$index .= $name;
378
+		}
358 379
 
359 380
 		$var =& $arr;
360 381
 		foreach(explode('/',$index) as $name)
361 382
 		{
362 383
 			$var =& $var[$name];
363 384
 		}
364
-		if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value;
385
+		if (true)
386
+		{
387
+			$var = strpos($name,'passw') !== false ? md5($value) : $value;
388
+		}
365 389
 	}
366 390
 }
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_hooks.inc.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,9 +19,8 @@
 block discarded – undo
19 19
 	 * Constructor
20 20
 	 *
21 21
 	 * @param string $domain string with domain-name or array with all arguments
22
-	 * @param string $config_user=null user to config the domain (or header_admin_user)
23
-	 * @param string $config_passwd=null pw of above user
24
-	 * @param boolean $verbose=false if true, echos out some status information during the run
22
+	 * @param string $config_user user to config the domain (or header_admin_user)
23
+	 * @param string $config_passwd pw of above user
25 24
 	 */
26 25
 	function __construct($domain,$config_user=null,$config_passwd=null)
27 26
 	{
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param string $config_passwd=null pw of above user
24 24
 	 * @param boolean $verbose=false if true, echos out some status information during the run
25 25
 	 */
26
-	function __construct($domain,$config_user=null,$config_passwd=null)
26
+	function __construct($domain, $config_user = null, $config_passwd = null)
27 27
 	{
28 28
 		if (!is_array($domain))
29 29
 		{
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
46 46
 	 * @throws Exception('header.inc.php not found!');
47 47
 	 */
48
-	protected function exec($check_only=false)
48
+	protected function exec($check_only = false)
49 49
 	{
50
-		if ($check_only) return true;	// nothing to check, no arguments ...
50
+		if ($check_only) return true; // nothing to check, no arguments ...
51 51
 
52 52
 		// instanciate setup object and check authorisation
53
-		$this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain);
53
+		$this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain);
54 54
 
55
-		$this->check_installed($this->domain,15,$this->verbose);
55
+		$this->check_installed($this->domain, 15, $this->verbose);
56 56
 
57 57
 		global $setup_info;
58
-		foreach($setup_info as $appname => $info)
58
+		foreach ($setup_info as $appname => $info)
59 59
 		{
60 60
 			if ($info['currentver']) self::$egw_setup->register_hooks($appname);
61 61
 		}
Please login to merge, or discard this patch.
Braces   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,11 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	protected function exec($check_only=false)
49 49
 	{
50
-		if ($check_only) return true;	// nothing to check, no arguments ...
50
+		if ($check_only)
51
+		{
52
+			return true;
53
+		}
54
+		// nothing to check, no arguments ...
51 55
 
52 56
 		// instanciate setup object and check authorisation
53 57
 		$this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain);
@@ -57,7 +61,10 @@  discard block
 block discarded – undo
57 61
 		global $setup_info;
58 62
 		foreach($setup_info as $appname => $info)
59 63
 		{
60
-			if ($info['currentver']) self::$egw_setup->register_hooks($appname);
64
+			if ($info['currentver'])
65
+			{
66
+				self::$egw_setup->register_hooks($appname);
67
+			}
61 68
 		}
62 69
 		$this->restore_db();
63 70
 
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_ldap.inc.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -936,9 +936,6 @@
 block discarded – undo
936 936
 	 *
937 937
 	 * Uses $this->ldap_host, $this->ldap_admin and $this->ldap_admin_pw to connect.
938 938
 	 *
939
-	 * @param string $this->object_class ='qmailUser'
940
-	 * @param string $this->mbox_attr ='mailmessagestore' lowercase!!!
941
-	 * @param string $this->mail_login_type ='email' 'email', 'vmailmgr', 'standard' or 'uidNumber'
942 939
 	 * @return string with success message N entries modified
943 940
 	 * @throws Api\Exception if dn not found, not listable or delete fails
944 941
 	 */
Please login to merge, or discard this patch.
Braces   +124 added lines, -30 removed lines patch added patch discarded remove patch
@@ -203,7 +203,10 @@  discard block
 block discarded – undo
203 203
 		$change_account_id = '';
204 204
 		foreach($entries as $key => $entry)
205 205
 		{
206
-			if ($key === 'count') continue;
206
+			if ($key === 'count')
207
+			{
208
+				continue;
209
+			}
207 210
 
208 211
 			$entry = Api\Ldap::result2array($entry);
209 212
 			$accounts[$entry['dn']] = $entry;
@@ -230,7 +233,10 @@  discard block
 block discarded – undo
230 233
 		//print_r($change); die('Stop');
231 234
 
232 235
 		// change account-ids inside EGroupware
233
-		if ($check_only) $msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id";
236
+		if ($check_only)
237
+		{
238
+			$msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id";
239
+		}
234 240
 		//$cmd = new admin_cmd_change_account_id($change);
235 241
 		//$msg[] = $cmd->run($time=null, $set_modifier=false, $skip_checks=false, $check_only);
236 242
 
@@ -252,7 +258,10 @@  discard block
 block discarded – undo
252 258
 				throw new Api\Exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds).
253 259
 					"\n- ".implode("\n- ", $msg));	// EGroupware change already run successful
254 260
 			}
255
-			if ($modify) ++$changed;
261
+			if ($modify)
262
+			{
263
+				++$changed;
264
+			}
256 265
 		}
257 266
 		$msg[] = "You need to run now on your samba share(s):\nsetup/doc/chown.php -R $change_account_id <share>";
258 267
 
@@ -279,7 +288,10 @@  discard block
 block discarded – undo
279 288
 			else
280 289
 			{
281 290
 				list($to, $from) = explode('=', $attr);
282
-				if ($from) $attrs[] = $from;
291
+				if ($from)
292
+				{
293
+					$attrs[] = $from;
294
+				}
283 295
 				$rename[strtolower($from)] = $to;
284 296
 			}
285 297
 		}
@@ -294,7 +306,10 @@  discard block
 block discarded – undo
294 306
 		{
295 307
 			$this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain));
296 308
 		}
297
-		if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator';
309
+		if (empty($this->ads_admin_user))
310
+		{
311
+			$this->ads_admin_user = 'Administrator';
312
+		}
298 313
 		$admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user :
299 314
 			'CN='.$this->ads_admin_user.','.$this->ads_context;
300 315
 		switch($this->ads_connection)
@@ -338,7 +353,10 @@  discard block
 block discarded – undo
338 353
 		$utc_diff = null;
339 354
 		foreach($entries as $key => $entry)
340 355
 		{
341
-			if ($key === 'count') continue;
356
+			if ($key === 'count')
357
+			{
358
+				continue;
359
+			}
342 360
 
343 361
 			$entry_arr = Api\Ldap::result2array($entry);
344 362
 			$uid = $entry_arr['uid'];
@@ -352,7 +370,10 @@  discard block
 block discarded – undo
352 370
 				continue;
353 371
 			}
354 372
 			$dn = $dest[0]['dn'];
355
-			if (isset($rename[''])) $entry[''] = '';
373
+			if (isset($rename['']))
374
+			{
375
+				$entry[''] = '';
376
+			}
356 377
 			// special handling for copying shadowExpires to accountExpires
357 378
 			if (strtolower($rename['shadowexpire']) === 'accountexpires')
358 379
 			{
@@ -363,7 +384,10 @@  discard block
 block discarded – undo
363 384
 				}
364 385
 				else
365 386
 				{
366
-					if (is_null($utc_diff)) $utc_diff = date('Z');
387
+					if (is_null($utc_diff))
388
+					{
389
+						$utc_diff = date('Z');
390
+					}
367 391
 					$entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime(
368 392
 						$entry['shadowexpire']*24*3600+$utc_diff);	// ldap time to unixTime
369 393
 				}
@@ -375,20 +399,29 @@  discard block
 block discarded – undo
375 399
 				{
376 400
 					$to = isset($rename[$attr]) ? $rename[$attr] : $attr;
377 401
 					$prefix = null;
378
-					if ($to[0] == '{')	// eg. {smtp:}proxyAddresses=forwardTo
402
+					if ($to[0] == '{')
403
+					{
404
+						// eg. {smtp:}proxyAddresses=forwardTo
379 405
 					{
380 406
 						list($prefix, $to) = explode('}', substr($to, 1));
381 407
 					}
408
+					}
382 409
 					foreach((array)$value as $val)
383 410
 					{
384 411
 						if (isset($update[$to]))
385 412
 						{
386
-							if (!is_array($update[$to])) $update[$to] = array($update[$to]);
413
+							if (!is_array($update[$to]))
414
+							{
415
+								$update[$to] = array($update[$to]);
416
+							}
387 417
 							// we need to check (caseinsensitive) if value already exists in set
388 418
 							// as AD chokes on doublicate values "Type or value exists"
389 419
 							foreach($update[$to] as $v)
390 420
 							{
391
-								if (!strcasecmp($v, $prefix.$val)) continue 2;
421
+								if (!strcasecmp($v, $prefix.$val))
422
+								{
423
+									continue 2;
424
+								}
392 425
 							}
393 426
 							$update[$to][] = $prefix.$val;
394 427
 						}
@@ -415,7 +448,10 @@  discard block
 block discarded – undo
415 448
 				$changed++;
416 449
 			}
417 450
 		}
418
-		if ($check_only) return lang("%1 accounts to copy found.", count($entries));
451
+		if ($check_only)
452
+		{
453
+			return lang("%1 accounts to copy found.", count($entries));
454
+		}
419 455
 
420 456
 		return "Copied data of $changed accounts from LDAP to AD ".
421 457
 			(count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : '');
@@ -431,7 +467,10 @@  discard block
 block discarded – undo
431 467
 	private function migrate($mode)
432 468
 	{
433 469
 		// support old boolean mode
434
-		if (is_bool($mode)) $mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql';
470
+		if (is_bool($mode))
471
+		{
472
+			$mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql';
473
+		}
435 474
 
436 475
 		$passwords2sql = $mode === "passwords_to_sql";
437 476
 		list(,$to) = explode('_to_', $mode);
@@ -597,7 +636,10 @@  discard block
 block discarded – undo
597 636
 					{
598 637
 						foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name)
599 638
 						{
600
-							 if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name;
639
+							 if (!empty($this->$name))
640
+							 {
641
+							 	$GLOBALS['egw_info']['server'][$name] = $this->$name;
642
+							 }
601 643
 						}
602 644
 						//error_log(__METHOD__."() setup up egw_info[server]: ldap_host='{$GLOBALS['egw_info']['server']['ldap_host']}', ldap_root_dn='{$GLOBALS['egw_info']['server']['ldap_root_dn']}', ldap_root_pw='{$GLOBALS['egw_info']['server']['ldap_root_pw']}', ldap_context='{$GLOBALS['egw_info']['server']['ldap_context']}', mail_suffix='{$GLOBALS['egw_info']['server']['mail_suffix']}', mail_logig_type='{$GLOBALS['egw_info']['server']['mail_login-type']}'");
603 645
 					}
@@ -684,7 +726,10 @@  discard block
 block discarded – undo
684 726
 	 */
685 727
 	public static function hash_sql2ldap($hash)
686 728
 	{
687
-		if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5';
729
+		if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type']))
730
+		{
731
+			$type = 'md5';
732
+		}
688 733
 
689 734
 		$matches = null;
690 735
 		if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches))
@@ -718,10 +763,13 @@  discard block
 block discarded – undo
718 763
 	 */
719 764
 	public static function hash_ldap2sql($hash)
720 765
 	{
721
-		if ($hash[0] != '{')	// plain has to be explicitly specified for sql, in ldap it's the default
766
+		if ($hash[0] != '{')
767
+		{
768
+			// plain has to be explicitly specified for sql, in ldap it's the default
722 769
 		{
723 770
 			$hash = '{PLAIN}'.$hash;
724 771
 		}
772
+		}
725 773
 		return $hash;
726 774
 	}
727 775
 
@@ -741,9 +789,12 @@  discard block
 block discarded – undo
741 789
 
742 790
 		foreach($accounts as $account_id => &$account)
743 791
 		{
744
-			if ($account_id != $account['account_id'])	// not all backends have as key the account_id
792
+			if ($account_id != $account['account_id'])
793
+			{
794
+				// not all backends have as key the account_id
745 795
 			{
746 796
 				unset($account);
797
+			}
747 798
 				$account_id = $account['account_id'];
748 799
 			}
749 800
 			$account += $accounts_obj->read($account_id);
@@ -776,7 +827,11 @@  discard block
 block discarded – undo
776 827
 			parent::_setup_enviroment($this->domain);
777 828
 			$enviroment_setup = true;
778 829
 		}
779
-		if ($type != 'sql') $this->connect();	// throws exception, if it can NOT connect
830
+		if ($type != 'sql')
831
+		{
832
+			$this->connect();
833
+		}
834
+		// throws exception, if it can NOT connect
780 835
 
781 836
 		// otherwise search does NOT work, as accounts_sql uses addressbook_bo for it
782 837
 		$GLOBALS['egw_info']['server']['account_repository'] = $type;
@@ -803,14 +858,26 @@  discard block
 block discarded – undo
803 858
 	 */
804 859
 	private function connect($dn=null,$pw=null,$host=null)
805 860
 	{
806
-		if (is_null($dn)) $dn = $this->ldap_root_dn;
807
-		if (is_null($pw)) $pw = $this->ldap_root_pw;
808
-		if (is_null($host)) $host = $this->ldap_host;
861
+		if (is_null($dn))
862
+		{
863
+			$dn = $this->ldap_root_dn;
864
+		}
865
+		if (is_null($pw))
866
+		{
867
+			$pw = $this->ldap_root_pw;
868
+		}
869
+		if (is_null($host))
870
+		{
871
+			$host = $this->ldap_host;
872
+		}
809 873
 
810
-		if (!$pw)	// Api\Ldap::ldapConnect use the current eGW's pw otherwise
874
+		if (!$pw)
875
+		{
876
+			// Api\Ldap::ldapConnect use the current eGW's pw otherwise
811 877
 		{
812 878
 			throw new Api\Exception\WrongUserinput(lang('You need to specify a password!'));
813 879
 		}
880
+		}
814 881
 
815 882
 		try {
816 883
 			$this->test_ldap = Api\Ldap::factory(false, $host, $dn, $pw);
@@ -841,8 +908,14 @@  discard block
 block discarded – undo
841 908
 		$num = 0;
842 909
 		foreach($entries as $n => $entry)
843 910
 		{
844
-			if ($n === 'count') continue;
845
-			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue;
911
+			if ($n === 'count')
912
+			{
913
+				continue;
914
+			}
915
+			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time())
916
+			{
917
+				continue;
918
+			}
846 919
 			++$num;
847 920
 		}
848 921
 		return $num;
@@ -921,7 +994,10 @@  discard block
 block discarded – undo
921 994
 		$deleted = 0;
922 995
 		foreach($entries as $n => $entry)
923 996
 		{
924
-			if ($n === 'count') continue;
997
+			if ($n === 'count')
998
+			{
999
+				continue;
1000
+			}
925 1001
 			$deleted += $this->rdelete($entry['dn']);
926 1002
 		}
927 1003
 		if (!ldap_delete($this->test_ldap->ds,$dn))
@@ -969,7 +1045,10 @@  discard block
 block discarded – undo
969 1045
 		$modified = 0;
970 1046
 		foreach($entries as $n => $entry)
971 1047
 		{
972
-			if ($n === 'count') continue;
1048
+			if ($n === 'count')
1049
+			{
1050
+				continue;
1051
+			}
973 1052
 
974 1053
 			$mbox = Api\Mail\Smtp\Ldap::mailbox_addr(array(
975 1054
 				'account_id' => $entry['uidnumber'][0],
@@ -977,7 +1056,11 @@  discard block
 block discarded – undo
977 1056
 				'account_email' => $entry['mail'][0],
978 1057
 			),$this->domain,$mail_login_type);
979 1058
 
980
-			if ($mbox === $entry[$mbox_attr][0]) continue;	// nothing to change
1059
+			if ($mbox === $entry[$mbox_attr][0])
1060
+			{
1061
+				continue;
1062
+			}
1063
+			// nothing to change
981 1064
 
982 1065
 			if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array(
983 1066
 				$mbox_attr => $mbox,
@@ -986,7 +1069,10 @@  discard block
 block discarded – undo
986 1069
 				throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox));
987 1070
 			}
988 1071
 			++$modified;
989
-			if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n";
1072
+			if ($check_only)
1073
+			{
1074
+				echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n";
1075
+			}
990 1076
 		}
991 1077
 		return $check_only ? lang('%1 entries would have been modified.',$modified) :
992 1078
 			lang('%1 entries modified.',$modified);
@@ -1034,8 +1120,16 @@  discard block
 block discarded – undo
1034 1120
 			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).' '.
1035 1121
 				lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses)));
1036 1122
 		}
1037
-		if ($name == 'dc') $extra['o'] = $value;	// required by organisation
1038
-		if ($name == 'uid') $extra['cn'] = $value;	// required by organizationalRole
1123
+		if ($name == 'dc')
1124
+		{
1125
+			$extra['o'] = $value;
1126
+		}
1127
+		// required by organisation
1128
+		if ($name == 'uid')
1129
+		{
1130
+			$extra['cn'] = $value;
1131
+		}
1132
+		// required by organizationalRole
1039 1133
 
1040 1134
 		if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array(
1041 1135
 			$name => $value,
Please login to merge, or discard this patch.
Spacing   +139 added lines, -142 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @param string $ldap_encryption_type ='des'
85 85
 	 * @param boolean $truncate_egw_accounts =false truncate accounts table before migration to SQL
86 86
 	 */
87
-	function __construct($domain,$ldap_host=null,$ldap_suffix=null,$ldap_admin=null,$ldap_admin_pw=null,
88
-		$ldap_base=null,$ldap_root_dn=null,$ldap_root_pw=null,$ldap_context=null,$ldap_search_filter=null,
89
-		$ldap_group_context=null,$sub_command='create_ldap',$ldap_encryption_type='des',$truncate_egw_accounts=false)
87
+	function __construct($domain, $ldap_host = null, $ldap_suffix = null, $ldap_admin = null, $ldap_admin_pw = null,
88
+		$ldap_base = null, $ldap_root_dn = null, $ldap_root_pw = null, $ldap_context = null, $ldap_search_filter = null,
89
+		$ldap_group_context = null, $sub_command = 'create_ldap', $ldap_encryption_type = 'des', $truncate_egw_accounts = false)
90 90
 	{
91 91
 		if (!is_array($domain))
92 92
 		{
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
120 120
 	 * @throws Exception('header.inc.php not found!');
121 121
 	 */
122
-	protected function exec($check_only=false)
122
+	protected function exec($check_only = false)
123 123
 	{
124
-		if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain))
124
+		if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i', $this->domain))
125 125
 		{
126
-			throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!",$this->domain));
126
+			throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!", $this->domain));
127 127
 		}
128 128
 		if ($this->remote_id && $check_only && !in_array($this->sub_command, array('set_mailbox', 'sid2uidnumber', 'copy2ad')))
129 129
 		{
130
-			return true;	// further checks can only done locally
130
+			return true; // further checks can only done locally
131 131
 		}
132 132
 		$this->_merge_defaults();
133 133
 		//_debug_array($this->as_array());
134 134
 
135
-		switch($this->sub_command)
135
+		switch ($this->sub_command)
136 136
 		{
137 137
 			case 'test_ldap_root':
138
-				$msg = $this->connect($this->ldap_admin,$this->ldap_admin_pw);
138
+				$msg = $this->connect($this->ldap_admin, $this->ldap_admin_pw);
139 139
 				break;
140 140
 			case 'test_ldap':
141 141
 				$msg = $this->connect();
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param boolean $check_only =false true: only connect and output necessary commands
182 182
 	 */
183
-	private function sid2uidnumber($check_only=false)
183
+	private function sid2uidnumber($check_only = false)
184 184
 	{
185 185
 		$msg = array();
186 186
 		$this->connect();
187 187
 
188 188
 		// check if base does exist
189
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
189
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
190 190
 		{
191
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
191
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
192 192
 		}
193 193
 
194
-		if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
195
-			$search='(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))',
196
-			array('uidNumber','gidNumber','uid','cn', 'objectClass',self::sambaSID))) ||
194
+		if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base,
195
+			$search = '(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))',
196
+			array('uidNumber', 'gidNumber', 'uid', 'cn', 'objectClass', self::sambaSID))) ||
197 197
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
198 198
 		{
199
-			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search));
199
+			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search));
200 200
 		}
201 201
 		$change = $accounts = array();
202 202
 		$cmd_change_account_id = 'admin/admin-cli.php --change-account-id <admin>@<domain>,<adminpw>';
203 203
 		$change_account_id = '';
204
-		foreach($entries as $key => $entry)
204
+		foreach ($entries as $key => $entry)
205 205
 		{
206 206
 			if ($key === 'count') continue;
207 207
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 		// now change them in LDAP
238 238
 		$changed = 0;
239
-		foreach($accounts as $dn => $account)
239
+		foreach ($accounts as $dn => $account)
240 240
 		{
241 241
 			$modify = array();
242 242
 			if (!empty($account['uidnumber']) && isset($change[$account['uidnumber']]))
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			if (!$check_only && $modify && !ldap_modify($this->test_ldap->ds, $dn, $modify))
251 251
 			{
252 252
 				throw new Api\Exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds).
253
-					"\n- ".implode("\n- ", $msg));	// EGroupware change already run successful
253
+					"\n- ".implode("\n- ", $msg)); // EGroupware change already run successful
254 254
 			}
255 255
 			if ($modify) ++$changed;
256 256
 		}
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @param boolean $check_only =false true: only connect and output necessary commands
267 267
 	 */
268
-	private function copy2ad($check_only=false)
268
+	private function copy2ad($check_only = false)
269 269
 	{
270 270
 		$msg = array();
271 271
 		$attrs = $rename = array();
272
-		foreach(explode(',', $this->attributes) as $attr)
272
+		foreach (explode(',', $this->attributes) as $attr)
273 273
 		{
274
-			if ($attr[0] == '@' ||	// copy whole objectclass without renaming, eg. @inetOrgPerson
274
+			if ($attr[0] == '@' || // copy whole objectclass without renaming, eg. @inetOrgPerson
275 275
 				strpos($attr, '=') === false)
276 276
 			{
277 277
 				$attrs[] = $attr;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		$ignore_attr = array_flip(array('dn', 'objectclass', 'cn', 'userpassword'));
287 287
 		if (!in_array('uid', $attrs))
288 288
 		{
289
-			$attrs[] = 'uid';	// need to match account
289
+			$attrs[] = 'uid'; // need to match account
290 290
 			$ignore_attr['uid'] = true;
291 291
 		}
292 292
 		// connect to destination ads
@@ -295,9 +295,8 @@  discard block
 block discarded – undo
295 295
 			$this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain));
296 296
 		}
297 297
 		if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator';
298
-		$admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user :
299
-			'CN='.$this->ads_admin_user.','.$this->ads_context;
300
-		switch($this->ads_connection)
298
+		$admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : 'CN='.$this->ads_admin_user.','.$this->ads_context;
299
+		switch ($this->ads_connection)
301 300
 		{
302 301
 			case 'ssl':
303 302
 				$url = 'ldaps://'.$this->ads_host.'/';
@@ -315,28 +314,27 @@  discard block
 block discarded – undo
315 314
 		// check if ads base does exist
316 315
 		if (!@ldap_read($ads->ds, $this->ads_context, 'objectClass=*'))
317 316
 		{
318
-			throw new Api\Exception\WrongUserinput(lang('Ads dn "%1" NOT found!',$this->ads_context));
317
+			throw new Api\Exception\WrongUserinput(lang('Ads dn "%1" NOT found!', $this->ads_context));
319 318
 		}
320 319
 
321 320
 		// connect to source ldap
322 321
 		$this->connect();
323 322
 
324 323
 		// check if ldap base does exist
325
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
324
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
326 325
 		{
327
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
326
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
328 327
 		}
329 328
 
330
-		if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
331
-			$search = $this->no_sid_check ? '(objectClass=posixAccount)' :
332
-				'(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) ||
329
+		if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base,
330
+			$search = $this->no_sid_check ? '(objectClass=posixAccount)' : '(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) ||
333 331
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
334 332
 		{
335
-			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search));
333
+			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search));
336 334
 		}
337 335
 		$changed = 0;
338 336
 		$utc_diff = null;
339
-		foreach($entries as $key => $entry)
337
+		foreach ($entries as $key => $entry)
340 338
 		{
341 339
 			if ($key === 'count') continue;
342 340
 
@@ -345,7 +343,7 @@  discard block
 block discarded – undo
345 343
 			$entry = array_diff_key($entry_arr, $ignore_attr);
346 344
 
347 345
 			if (!($sr = ldap_search($ads->ds, $this->ads_context,
348
-				$search='(&(objectClass=user)(sAMAccountName='.Api\Ldap::quote($uid).'))', array('dn'))) ||
346
+				$search = '(&(objectClass=user)(sAMAccountName='.Api\Ldap::quote($uid).'))', array('dn'))) ||
349 347
 				!($dest = ldap_get_entries($ads->ds, $sr)))
350 348
 			{
351 349
 				$msg[] = lang('User "%1" not found!', $uid);
@@ -365,11 +363,11 @@  discard block
 block discarded – undo
365 363
 				{
366 364
 					if (is_null($utc_diff)) $utc_diff = date('Z');
367 365
 					$entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime(
368
-						$entry['shadowexpire']*24*3600+$utc_diff);	// ldap time to unixTime
366
+						$entry['shadowexpire'] * 24 * 3600 + $utc_diff); // ldap time to unixTime
369 367
 				}
370 368
 			}
371 369
 			$update = array();
372
-			foreach($entry as $attr => $value)
370
+			foreach ($entry as $attr => $value)
373 371
 			{
374 372
 				if ($value || $attr === '')
375 373
 				{
@@ -379,14 +377,14 @@  discard block
 block discarded – undo
379 377
 					{
380 378
 						list($prefix, $to) = explode('}', substr($to, 1));
381 379
 					}
382
-					foreach((array)$value as $val)
380
+					foreach ((array)$value as $val)
383 381
 					{
384 382
 						if (isset($update[$to]))
385 383
 						{
386 384
 							if (!is_array($update[$to])) $update[$to] = array($update[$to]);
387 385
 							// we need to check (caseinsensitive) if value already exists in set
388 386
 							// as AD chokes on doublicate values "Type or value exists"
389
-							foreach($update[$to] as $v)
387
+							foreach ($update[$to] as $v)
390 388
 							{
391 389
 								if (!strcasecmp($v, $prefix.$val)) continue 2;
392 390
 							}
@@ -418,7 +416,7 @@  discard block
 block discarded – undo
418 416
 		if ($check_only) return lang("%1 accounts to copy found.", count($entries));
419 417
 
420 418
 		return "Copied data of $changed accounts from LDAP to AD ".
421
-			(count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : '');
419
+			(count($msg) > $changed ? ' ('.(count($msg) - $changed).' errors!)' : '');
422 420
 	}
423 421
 
424 422
 	/**
@@ -461,9 +459,9 @@  discard block
 block discarded – undo
461 459
 		$accounts_created = $groups_created = $errors = $egw_info_set = 0;
462 460
 		$emailadmin_src = $ldap_class = null;
463 461
 		$target = strtoupper($to);
464
-		foreach($accounts as $account_id => $account)
462
+		foreach ($accounts as $account_id => $account)
465 463
 		{
466
-			if (isset($this->only) && !in_array($account_id,$this->only))
464
+			if (isset($this->only) && !in_array($account_id, $this->only))
467 465
 			{
468 466
 				continue;
469 467
 			}
@@ -483,12 +481,12 @@  discard block
 block discarded – undo
483 481
 			{
484 482
 				if (!($sql_account = $accounts_obj->read($account_id)))
485 483
 				{
486
-					$msg[] = lang('%1 does NOT exist in %2.',$what,$target);
484
+					$msg[] = lang('%1 does NOT exist in %2.', $what, $target);
487 485
 					$errors++;
488 486
 				}
489
-				elseif(empty($account['account_pwd']))
487
+				elseif (empty($account['account_pwd']))
490 488
 				{
491
-					$msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!',$what);
489
+					$msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!', $what);
492 490
 					$errors++;
493 491
 				}
494 492
 				else
@@ -497,12 +495,12 @@  discard block
 block discarded – undo
497 495
 
498 496
 					if (!$accounts_obj->save($sql_account))
499 497
 					{
500
-						$msg[] = lang('Update of %1 in %2 failed !!!',$what,$target);
498
+						$msg[] = lang('Update of %1 in %2 failed !!!', $what, $target);
501 499
 						$errors++;
502 500
 					}
503 501
 					else
504 502
 					{
505
-						$msg[] = lang('%1 password set in %2.',$what,$target);
503
+						$msg[] = lang('%1 password set in %2.', $what, $target);
506 504
 						$accounts_created++;
507 505
 					}
508 506
 				}
@@ -513,7 +511,7 @@  discard block
 block discarded – undo
513 511
 			{
514 512
 				if ($accounts_obj->exists($account_id))
515 513
 				{
516
-					$msg[] = lang('%1 already exists in %2.',$what,$target);
514
+					$msg[] = lang('%1 already exists in %2.', $what, $target);
517 515
 					$errors++;
518 516
 					continue;
519 517
 				}
@@ -521,7 +519,7 @@  discard block
 block discarded – undo
521 519
 				{
522 520
 					if ($GLOBALS['egw_info']['server']['ldap_extra_attributes'])
523 521
 					{
524
-						$account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'] . '/' . $account['account_lid'];
522
+						$account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'].'/'.$account['account_lid'];
525 523
 						$account['loginshell'] = $GLOBALS['egw_info']['server']['ldap_account_shell'];
526 524
 					}
527 525
 					$account['account_passwd'] = self::hash_sql2ldap($account['account_pwd']);
@@ -534,12 +532,12 @@  discard block
 block discarded – undo
534 532
 
535 533
 				if (!$accounts_obj->save($account))
536 534
 				{
537
-					$msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target);
535
+					$msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target);
538 536
 					$errors++;
539 537
 					continue;
540 538
 				}
541
-				$accounts_obj->set_memberships($account['memberships'],$account_id);
542
-				$msg[] = lang('%1 created in %2.',$what,$target);
539
+				$accounts_obj->set_memberships($account['memberships'], $account_id);
540
+				$msg[] = lang('%1 created in %2.', $what, $target);
543 541
 				$accounts_created++;
544 542
 
545 543
 				// check if we need to migrate mail-account
@@ -547,7 +545,7 @@  discard block
 block discarded – undo
547 545
 				{
548 546
 					$ldap_class = false;
549 547
 					$ldap = Api\Ldap::factory(false);
550
-					foreach(array(	// todo: have these enumerated by emailadmin ...
548
+					foreach (array(	// todo: have these enumerated by emailadmin ...
551 549
 						'qmailUser' => 'EGroupware\\Api\\Mail\\Smtp\\Oldqmailuser',
552 550
 						'dbMailUser' => 'EGroupware\\Api\\Mail\\Smtp\\Dbmailuser',
553 551
 						// nothing to migrate for inetOrgPerson ...
@@ -594,7 +592,7 @@  discard block
 block discarded – undo
594 592
 					// setting up egw_info array with new ldap information, so hook can use Api\Ldap::ldapConnect()
595 593
 					if (!$egw_info_set++)
596 594
 					{
597
-						foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name)
595
+						foreach (array('ldap_host', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_group_context', 'ldap_search_filter', 'ldap_encryptin_type', 'mail_suffix', 'mail_login_type') as $name)
598 596
 						{
599 597
 							 if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name;
600 598
 						}
@@ -608,12 +606,12 @@  discard block
 block discarded – undo
608 606
 						{
609 607
 							Api\Hooks::process($account, array(), true);
610 608
 						}
611
-						elseif(is_callable($this->add_account_hook))
609
+						elseif (is_callable($this->add_account_hook))
612 610
 						{
613
-							call_user_func($this->add_account_hook,$account);
611
+							call_user_func($this->add_account_hook, $account);
614 612
 						}
615 613
 					}
616
-					catch(Exception $e)
614
+					catch (Exception $e)
617 615
 					{
618 616
 						$msg[] = $e->getMessage();
619 617
 						$errors++;
@@ -627,38 +625,38 @@  discard block
 block discarded – undo
627 625
 				{
628 626
 					if (!$accounts_obj->save($account))
629 627
 					{
630
-						$msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target);
628
+						$msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target);
631 629
 						++$errors;
632 630
 						continue;
633 631
 					}
634
-					$msg[] = lang('%1 created in %2.',$what,$target);
632
+					$msg[] = lang('%1 created in %2.', $what, $target);
635 633
 					$groups_created++;
636 634
 				}
637 635
 				else
638 636
 				{
639
-					$msg[] = lang('%1 already exists in %2.',$what,$target);
637
+					$msg[] = lang('%1 already exists in %2.', $what, $target);
640 638
 					$errors++;
641 639
 
642 640
 					if ($accounts_obj->id2name($account_id) != $account['account_lid'])
643 641
 					{
644
-						$msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!",$account['account_lid'],$account_id);
642
+						$msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!", $account['account_lid'], $account_id);
645 643
 						++$errors;
646
-						continue;	// different group under that gidnumber!
644
+						continue; // different group under that gidnumber!
647 645
 					}
648 646
 				}
649 647
 				// now saving / updating the memberships
650
-				$accounts_obj->set_members($account['members'],$account_id);
648
+				$accounts_obj->set_members($account['members'], $account_id);
651 649
 			}
652 650
 		}
653 651
 		if ($passwords2sql)
654 652
 		{
655
-			return lang('%1 passwords updated, %3 errors',$accounts_created,$groups_created,$errors).
656
-				($errors || $this->verbose ? "\n- ".implode("\n- ",$msg) : '');
653
+			return lang('%1 passwords updated, %3 errors', $accounts_created, $groups_created, $errors).
654
+				($errors || $this->verbose ? "\n- ".implode("\n- ", $msg) : '');
657 655
 		}
658 656
 		// migrate addressbook data
659
-		$GLOBALS['egw_info']['user']['apps']['admin'] = true;	// otherwise migration will not run in setup!
657
+		$GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup!
660 658
 		$addressbook = new Api\Contacts\Storage();
661
-		foreach($this->as_array() as $name => $value)
659
+		foreach ($this->as_array() as $name => $value)
662 660
 		{
663 661
 			if (substr($name, 5) == 'ldap_')
664 662
 			{
@@ -671,8 +669,8 @@  discard block
 block discarded – undo
671 669
 
672 670
 		$this->restore_db();
673 671
 
674
-		return lang('%1 users and %2 groups created, %3 errors',$accounts_created,$groups_created,$errors).
675
-			($errors || $this->verbose ? "\n- ".implode("\n- ",$msgs) : '');
672
+		return lang('%1 users and %2 groups created, %3 errors', $accounts_created, $groups_created, $errors).
673
+			($errors || $this->verbose ? "\n- ".implode("\n- ", $msgs) : '');
676 674
 	}
677 675
 
678 676
 	/**
@@ -686,22 +684,22 @@  discard block
 block discarded – undo
686 684
 		if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5';
687 685
 
688 686
 		$matches = null;
689
-		if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches))
687
+		if (preg_match('/^\\{(.*)\\}(.*)$/', $hash, $matches))
690 688
 		{
691
-			list(,$type,$hash) = $matches;
689
+			list(,$type, $hash) = $matches;
692 690
 		}
693
-		elseif (preg_match('/^[0-9a-f]{32}$/',$hash))
691
+		elseif (preg_match('/^[0-9a-f]{32}$/', $hash))
694 692
 		{
695 693
 			$type = 'md5';
696 694
 		}
697
-		switch(strtolower($type))
695
+		switch (strtolower($type))
698 696
 		{
699 697
 			case 'plain':
700 698
 				// ldap stores plaintext passwords without {plain} prefix
701 699
 				break;
702 700
 
703 701
 			case 'md5':
704
-				$hash = base64_encode(pack("H*",$hash));
702
+				$hash = base64_encode(pack("H*", $hash));
705 703
 				// fall through
706 704
 			default:
707 705
 				$hash = '{'.strtoupper($type).'}'.$hash;
@@ -731,14 +729,14 @@  discard block
 block discarded – undo
731 729
 	 * @param string $type ='both'
732 730
 	 * @return array
733 731
 	 */
734
-	public function accounts($from='ldap', $type='both')
732
+	public function accounts($from = 'ldap', $type = 'both')
735 733
 	{
736 734
 		$accounts_obj = $this->accounts_obj($from);
737 735
 		//error_log(__METHOD__."(from_ldap=".array2string($from_ldap).') get_class(accounts_obj->backend)='.get_class($accounts_obj->backend));
738 736
 
739 737
 		$accounts = $accounts_obj->search(array('type' => $type, 'objectclass' => true, 'active' => false));
740 738
 
741
-		foreach($accounts as $account_id => &$account)
739
+		foreach ($accounts as $account_id => &$account)
742 740
 		{
743 741
 			if ($account_id != $account['account_id'])	// not all backends have as key the account_id
744 742
 			{
@@ -749,11 +747,11 @@  discard block
 block discarded – undo
749 747
 
750 748
 			if ($account['account_type'] == 'g')
751 749
 			{
752
-				$account['members'] = $accounts_obj->members($account_id,true);
750
+				$account['members'] = $accounts_obj->members($account_id, true);
753 751
 			}
754 752
 			else
755 753
 			{
756
-				$account['memberships'] = $accounts_obj->memberships($account_id,true);
754
+				$account['memberships'] = $accounts_obj->memberships($account_id, true);
757 755
 			}
758 756
 		}
759 757
 		Api\Accounts::cache_invalidate();
@@ -769,13 +767,13 @@  discard block
 block discarded – undo
769 767
 	 */
770 768
 	private function accounts_obj($type)
771 769
 	{
772
-		static $enviroment_setup=null;
770
+		static $enviroment_setup = null;
773 771
 		if (!$enviroment_setup)
774 772
 		{
775 773
 			parent::_setup_enviroment($this->domain);
776 774
 			$enviroment_setup = true;
777 775
 		}
778
-		if ($type != 'sql') $this->connect();	// throws exception, if it can NOT connect
776
+		if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect
779 777
 
780 778
 		// otherwise search does NOT work, as accounts_sql uses addressbook_bo for it
781 779
 		$GLOBALS['egw_info']['server']['account_repository'] = $type;
@@ -800,7 +798,7 @@  discard block
 block discarded – undo
800 798
 	 * @param string $host =null default $this->ldap_host, hostname, ip or ldap-url
801 799
 	 * @throws Api\Exception\WrongUserinput Can not connect to ldap ...
802 800
 	 */
803
-	private function connect($dn=null,$pw=null,$host=null)
801
+	private function connect($dn = null, $pw = null, $host = null)
804 802
 	{
805 803
 		if (is_null($dn)) $dn = $this->ldap_root_dn;
806 804
 		if (is_null($pw)) $pw = $this->ldap_root_pw;
@@ -817,9 +815,9 @@  discard block
 block discarded – undo
817 815
 		catch (Api\Exception\NoPermission $e) {
818 816
 			_egw_log_exception($e);
819 817
 			throw new Api\Exception\WrongUserinput(lang('Can not connect to LDAP server on host %1 using DN %2!',
820
-				$host,$dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : ''));
818
+				$host, $dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : ''));
821 819
 		}
822
-		return lang('Successful connected to LDAP server on %1 using DN %2.',$this->ldap_host,$dn);
820
+		return lang('Successful connected to LDAP server on %1 using DN %2.', $this->ldap_host, $dn);
823 821
 	}
824 822
 
825 823
 	/**
@@ -832,16 +830,16 @@  discard block
 block discarded – undo
832 830
 	{
833 831
 		$this->connect();
834 832
 
835
-		$sr = ldap_list($this->test_ldap->ds,$this->ldap_context,'ObjectClass=posixAccount',array('dn','shadowExpire'));
833
+		$sr = ldap_list($this->test_ldap->ds, $this->ldap_context, 'ObjectClass=posixAccount', array('dn', 'shadowExpire'));
836 834
 		if (!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
837 835
 		{
838
-			throw new Api\Exception('Error listing "dn=%1"!',$this->ldap_context);
836
+			throw new Api\Exception('Error listing "dn=%1"!', $this->ldap_context);
839 837
 		}
840 838
 		$num = 0;
841
-		foreach($entries as $n => $entry)
839
+		foreach ($entries as $n => $entry)
842 840
 		{
843 841
 			if ($n === 'count') continue;
844
-			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue;
842
+			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0] * 24 * 3600 < time()) continue;
845 843
 			++$num;
846 844
 		}
847 845
 		return $num;
@@ -855,23 +853,23 @@  discard block
 block discarded – undo
855 853
 	 */
856 854
 	private function create()
857 855
 	{
858
-		$this->connect($this->ldap_admin,$this->ldap_admin_pw);
856
+		$this->connect($this->ldap_admin, $this->ldap_admin_pw);
859 857
 
860
-		foreach(array(
858
+		foreach (array(
861 859
 			$this->ldap_base => array(),
862 860
 			$this->ldap_context => array(),
863 861
 			$this->ldap_group_context => array(),
864
-			$this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw,'ssha')),
862
+			$this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw, 'ssha')),
865 863
 		) as $dn => $extra)
866 864
 		{
867
-			if (!$this->_create_node($dn,$extra,$this->check_only) && $dn == $this->ldap_root_dn)
865
+			if (!$this->_create_node($dn, $extra, $this->check_only) && $dn == $this->ldap_root_dn)
868 866
 			{
869 867
 				// ldap_root already existed, lets check the pw is correct
870 868
 				$this->connect();
871 869
 			}
872 870
 		}
873 871
 		return lang('Successful connected to LDAP server on %1 and created/checked required structur %2.',
874
-			$this->ldap_host,$this->ldap_base);
872
+			$this->ldap_host, $this->ldap_base);
875 873
 	}
876 874
 
877 875
 	/**
@@ -882,25 +880,25 @@  discard block
 block discarded – undo
882 880
 	 */
883 881
 	private function delete_base()
884 882
 	{
885
-		$this->connect($this->ldap_admin,$this->ldap_admin_pw);
883
+		$this->connect($this->ldap_admin, $this->ldap_admin_pw);
886 884
 
887 885
 		// if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local)
888 886
 		if (empty($this->ldap_base) && $this->ldap_context)
889 887
 		{
890
-			list(,$this->ldap_base) = explode(',',$this->ldap_context,2);
888
+			list(,$this->ldap_base) = explode(',', $this->ldap_context, 2);
891 889
 		}
892 890
 		// some precausion to not delete whole ldap tree!
893
-		if (count(explode(',',$this->ldap_base)) < 2)
891
+		if (count(explode(',', $this->ldap_base)) < 2)
894 892
 		{
895
-			throw new Api\Exception\AssertionFailed(lang('Refusing to delete dn "%1"!',$this->ldap_base));
893
+			throw new Api\Exception\AssertionFailed(lang('Refusing to delete dn "%1"!', $this->ldap_base));
896 894
 		}
897 895
 		// check if base does exist
898
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
896
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
899 897
 		{
900
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
898
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
901 899
 		}
902 900
 		return lang('LDAP dn="%1" with %2 entries deleted.',
903
-			$this->ldap_base,$this->rdelete($this->ldap_base));
901
+			$this->ldap_base, $this->rdelete($this->ldap_base));
904 902
 	}
905 903
 
906 904
 	/**
@@ -912,20 +910,20 @@  discard block
 block discarded – undo
912 910
 	 */
913 911
 	private function rdelete($dn)
914 912
 	{
915
-		if (!($sr = ldap_list($this->test_ldap->ds,$dn,'ObjectClass=*',array(''))) ||
913
+		if (!($sr = ldap_list($this->test_ldap->ds, $dn, 'ObjectClass=*', array(''))) ||
916 914
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
917 915
 		{
918
-			throw new Api\Exception(lang('Error listing "dn=%1"!',$dn));
916
+			throw new Api\Exception(lang('Error listing "dn=%1"!', $dn));
919 917
 		}
920 918
 		$deleted = 0;
921
-		foreach($entries as $n => $entry)
919
+		foreach ($entries as $n => $entry)
922 920
 		{
923 921
 			if ($n === 'count') continue;
924 922
 			$deleted += $this->rdelete($entry['dn']);
925 923
 		}
926
-		if (!ldap_delete($this->test_ldap->ds,$dn))
924
+		if (!ldap_delete($this->test_ldap->ds, $dn))
927 925
 		{
928
-			throw new Api\Exception(lang('Error deleting "dn=%1"!',$dn));
926
+			throw new Api\Exception(lang('Error deleting "dn=%1"!', $dn));
929 927
 		}
930 928
 		return ++$deleted;
931 929
 	}
@@ -941,32 +939,32 @@  discard block
 block discarded – undo
941 939
 	 * @return string with success message N entries modified
942 940
 	 * @throws Api\Exception if dn not found, not listable or delete fails
943 941
 	 */
944
-	private function set_mailbox($check_only=false)
942
+	private function set_mailbox($check_only = false)
945 943
 	{
946
-		$this->connect($this->ldap_admin,$this->ldap_admin_pw);
944
+		$this->connect($this->ldap_admin, $this->ldap_admin_pw);
947 945
 
948 946
 		// if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local)
949 947
 		if (empty($this->ldap_base) && $this->ldap_context)
950 948
 		{
951
-			list(,$this->ldap_base) = explode(',',$this->ldap_context,2);
949
+			list(,$this->ldap_base) = explode(',', $this->ldap_context, 2);
952 950
 		}
953 951
 		// check if base does exist
954
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
952
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
955 953
 		{
956
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
954
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
957 955
 		}
958 956
 		$object_class = $this->object_class ? $this->object_class : 'qmailUser';
959 957
 		$mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore';
960 958
 		$mail_login_type = $this->mail_login_type ? $this->mail_login_type : 'email';
961 959
 
962
-		if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
963
-				'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) ||
960
+		if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base,
961
+				'objectClass='.$object_class, array('mail', 'uidNumber', 'uid', $mbox_attr))) ||
964 962
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
965 963
 		{
966
-			throw new Api\Exception(lang('Error listing "dn=%1"!',$this->ldap_base));
964
+			throw new Api\Exception(lang('Error listing "dn=%1"!', $this->ldap_base));
967 965
 		}
968 966
 		$modified = 0;
969
-		foreach($entries as $n => $entry)
967
+		foreach ($entries as $n => $entry)
970 968
 		{
971 969
 			if ($n === 'count') continue;
972 970
 
@@ -974,21 +972,20 @@  discard block
 block discarded – undo
974 972
 				'account_id' => $entry['uidnumber'][0],
975 973
 				'account_lid' => $entry['uid'][0],
976 974
 				'account_email' => $entry['mail'][0],
977
-			),$this->domain,$mail_login_type);
975
+			), $this->domain, $mail_login_type);
978 976
 
979
-			if ($mbox === $entry[$mbox_attr][0]) continue;	// nothing to change
977
+			if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change
980 978
 
981
-			if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array(
979
+			if (!$check_only && !ldap_modify($this->test_ldap->ds, $entry['dn'], array(
982 980
 				$mbox_attr => $mbox,
983 981
 			)))
984 982
 			{
985
-				throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox));
983
+				throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!", $entry['dn'], $mbox_attr, $mbox));
986 984
 			}
987 985
 			++$modified;
988 986
 			if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n";
989 987
 		}
990
-		return $check_only ? lang('%1 entries would have been modified.',$modified) :
991
-			lang('%1 entries modified.',$modified);
988
+		return $check_only ? lang('%1 entries would have been modified.', $modified) : lang('%1 entries modified.', $modified);
992 989
 	}
993 990
 
994 991
 	/**
@@ -999,9 +996,9 @@  discard block
 block discarded – undo
999 996
 	static $requiredObjectclasses = array(
1000 997
 		'o' => 'organization',
1001 998
 		'ou' => 'organizationalUnit',
1002
-		'cn' => array('organizationalRole','simpleSecurityObject'),
1003
-		'uid' => array('uidObject','organizationalRole','simpleSecurityObject'),
1004
-		'dc' => array('organization','dcObject'),
999
+		'cn' => array('organizationalRole', 'simpleSecurityObject'),
1000
+		'uid' => array('uidObject', 'organizationalRole', 'simpleSecurityObject'),
1001
+		'dc' => array('organization', 'dcObject'),
1005 1002
 	);
1006 1003
 
1007 1004
 	/**
@@ -1012,37 +1009,37 @@  discard block
 block discarded – undo
1012 1009
 	 * @return boolean true if the node was create, false if it was already there
1013 1010
 	 * @throws Api\Exception\WrongUserinput
1014 1011
 	 */
1015
-	private function _create_node($dn,$extra=array())
1012
+	private function _create_node($dn, $extra = array())
1016 1013
 	{
1017 1014
 		// check if the node already exists and return if it does
1018
-		if (@ldap_read($this->test_ldap->ds,$dn,'objectClass=*'))
1015
+		if (@ldap_read($this->test_ldap->ds, $dn, 'objectClass=*'))
1019 1016
 		{
1020 1017
 			return false;
1021 1018
 		}
1022
-		list($node,$base) = explode(',',$dn,2);
1019
+		list($node, $base) = explode(',', $dn, 2);
1023 1020
 
1024
-		if (!@ldap_read($this->test_ldap->ds,$base,'objectClass=*'))
1021
+		if (!@ldap_read($this->test_ldap->ds, $base, 'objectClass=*'))
1025 1022
 		{
1026
-			$this->_create_node($base);		// create the base if it's not already there
1023
+			$this->_create_node($base); // create the base if it's not already there
1027 1024
 		}
1028 1025
 		// now we need to create the node itself
1029
-		list($name,$value) = explode('=',$node);
1026
+		list($name, $value) = explode('=', $node);
1030 1027
 
1031 1028
 		if (!isset(self::$requiredObjectclasses[$name]))
1032 1029
 		{
1033
-			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).' '.
1034
-				lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses)));
1030
+			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!', $dn).' '.
1031
+				lang('Supported node types:').implode(', ', array_keys(self::$requiredObjectclasses)));
1035 1032
 		}
1036
-		if ($name == 'dc') $extra['o'] = $value;	// required by organisation
1037
-		if ($name == 'uid') $extra['cn'] = $value;	// required by organizationalRole
1033
+		if ($name == 'dc') $extra['o'] = $value; // required by organisation
1034
+		if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole
1038 1035
 
1039
-		if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array(
1036
+		if (!@ldap_add($this->test_ldap->ds, $dn, $attr = array(
1040 1037
 			$name => $value,
1041 1038
 			'objectClass' => self::$requiredObjectclasses[$name],
1042
-		)+$extra))
1039
+		) + $extra))
1043 1040
 		{
1044
-			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).
1045
-				' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr,true).')');
1041
+			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!', $dn).
1042
+				' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr, true).')');
1046 1043
 		}
1047 1044
 		return true;
1048 1045
 	}
@@ -1073,30 +1070,30 @@  discard block
 block discarded – undo
1073 1070
 	 */
1074 1071
 	private function _merge_defaults()
1075 1072
 	{
1076
-		foreach(self::defaults() as $name => $default)
1073
+		foreach (self::defaults() as $name => $default)
1077 1074
 		{
1078
-			if ($this->sub_command == 'delete_ldap' && in_array($name,array('ldap_base','ldap_context')))
1075
+			if ($this->sub_command == 'delete_ldap' && in_array($name, array('ldap_base', 'ldap_context')))
1079 1076
 			{
1080
-				continue;	// no default on what to delete!
1077
+				continue; // no default on what to delete!
1081 1078
 			}
1082 1079
 			if (!$this->$name)
1083 1080
 			{
1084 1081
 				//echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n";
1085 1082
 				$this->set_defaults[$name] = $this->$name = $default;
1086 1083
 			}
1087
-			if (strpos($this->$name,'$') !== false)
1084
+			if (strpos($this->$name, '$') !== false)
1088 1085
 			{
1089 1086
 				$this->set_defaults[$name] = $this->$name = str_replace(array(
1090 1087
 					'$domain',
1091 1088
 					'$suffix',
1092 1089
 					'$base',
1093 1090
 					'$admin_pw',
1094
-				),array(
1091
+				), array(
1095 1092
 					$this->domain,
1096 1093
 					$this->ldap_suffix,
1097 1094
 					$this->ldap_base,
1098 1095
 					$this->ldap_admin_pw,
1099
-				),$this->$name);
1096
+				), $this->$name);
1100 1097
 			}
1101 1098
 		}
1102 1099
 	}
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_showheader.inc.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -28,9 +28,6 @@
 block discarded – undo
28 28
 	/**
29 29
 	 * Constructor
30 30
 	 *
31
-	 * @param boolean $data=true true: send only the remote_hash, domain and webserver_url,
32
-	 *                           false: the complete header vars, plus install_id and webserver_url from the config table,
33
-	 *                           null:  only the header vars
34 31
 	 */
35 32
 	function __construct($data=true,$header_admin_user=null,$header_admin_password=null)
36 33
 	{
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *                           false: the complete header vars, plus install_id and webserver_url from the config table,
33 33
 	 *                           null:  only the header vars
34 34
 	 */
35
-	function __construct($data=true,$header_admin_user=null,$header_admin_password=null)
35
+	function __construct($data = true, $header_admin_user = null, $header_admin_password = null)
36 36
 	{
37 37
 		if (!is_array($data))
38 38
 		{
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
55 55
 	 * @throws Exception('header.inc.php not found!');
56 56
 	 */
57
-	function exec($check_only=false)
57
+	function exec($check_only = false)
58 58
 	{
59
-		if ($this->remote_id && $check_only) return true;	// cant check for the remote site locally!
59
+		if ($this->remote_id && $check_only) return true; // cant check for the remote site locally!
60 60
 
61 61
 		$this->_check_header_access();
62 62
 
63 63
 		if ($check_only) return true;
64 64
 
65 65
 		$egw_info_backup = $GLOBALS['egw_info'];
66
-		$GLOBALS['egw_info'] = array (
66
+		$GLOBALS['egw_info'] = array(
67 67
 			'flags' => array(
68 68
 				'noapi' => true,
69 69
 			),
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		{
73 73
 			throw new Exception('header.inc.php not found!');
74 74
 		}
75
-		eval(str_replace(array('<?php','perfgetmicrotime'),array('','perfgetmicrotime2'),$header));
75
+		eval(str_replace(array('<?php', 'perfgetmicrotime'), array('', 'perfgetmicrotime2'), $header));
76 76
 
77 77
 		// unset the flags, they are not part of  the header
78 78
 		unset($GLOBALS['egw_info']['flags']);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $egw_info_backup['server']['versions']['phpgwapi'];
82 82
 
83 83
 		// fetching the install id's stored in the database
84
-		foreach($GLOBALS['egw_domain'] as &$data)
84
+		foreach ($GLOBALS['egw_domain'] as &$data)
85 85
 		{
86 86
 			if (!is_null($this->hash_only))
87 87
 			{
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 			}
90 90
 			try {
91 91
 				// it's saver to only send the remote_hash and not install_id and config_pw
92
-				$data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']);
92
+				$data['remote_hash'] = admin_cmd::remote_hash($data['install_id'], $data['config_passwd']);
93 93
 			}
94
-			catch(Exception $e) {
94
+			catch (Exception $e) {
95 95
 				if ($data['install_id']) $data['error'] .= $e->getMessage();
96 96
 			}
97 97
 			if ($this->hash_only)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 					'remote_hash'   => $data['remote_hash'],
101 101
 					'webserver_url' => $data['webserver_url'],
102 102
 					'install_id'     => $data['install_id'],
103
-				)+($data['error'] ? array(
103
+				) + ($data['error'] ? array(
104 104
 					'error' => $data['error'],
105 105
 				) : array());
106 106
 			}
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
 	{
134 134
 		$db = new Api\Db();
135 135
 
136
-		ob_start();		// not available db connection echos a lot grab ;-)
136
+		ob_start(); // not available db connection echos a lot grab ;-)
137 137
 		$err_rep = error_reporting(0);
138 138
 
139 139
 		$config = array();
140 140
 		try {
141
-			$db->connect($data['db_name'],$data['db_host'],$data['db_port'],$data['db_user'],$data['db_pass'],$data['db_type']);
141
+			$db->connect($data['db_name'], $data['db_host'], $data['db_port'], $data['db_user'], $data['db_pass'], $data['db_type']);
142 142
 			$db->set_app('phpgwapi');
143
-			$db->select('egw_config','config_name,config_value',array(
144
-				'config_name'=>array('install_id','webserver_url','account_repository','allow_remote_admin','mail_suffix'),
143
+			$db->select('egw_config', 'config_name,config_value', array(
144
+				'config_name'=>array('install_id', 'webserver_url', 'account_repository', 'allow_remote_admin', 'mail_suffix'),
145 145
 				'config_app'=>'phpgwapi',
146
-			),__LINE__,__FILE__);
146
+			), __LINE__, __FILE__);
147 147
 			while (($row = $db->row(true)))
148 148
 			{
149 149
 				$config[$row['config_name']] = $row['config_value'];
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
168 168
 	 * @return boolean true on success, false otherwise
169 169
 	 */
170
-	function save($set_modifier=true)
170
+	function save($set_modifier = true)
171 171
 	{
172 172
 		if ($this->remote_id)
173 173
 		{
Please login to merge, or discard this patch.
Braces   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,11 +56,18 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function exec($check_only=false)
58 58
 	{
59
-		if ($this->remote_id && $check_only) return true;	// cant check for the remote site locally!
59
+		if ($this->remote_id && $check_only)
60
+		{
61
+			return true;
62
+		}
63
+		// cant check for the remote site locally!
60 64
 
61 65
 		$this->_check_header_access();
62 66
 
63
-		if ($check_only) return true;
67
+		if ($check_only)
68
+		{
69
+			return true;
70
+		}
64 71
 
65 72
 		$egw_info_backup = $GLOBALS['egw_info'];
66 73
 		$GLOBALS['egw_info'] = array (
@@ -92,7 +99,10 @@  discard block
 block discarded – undo
92 99
 				$data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']);
93 100
 			}
94 101
 			catch(Exception $e) {
95
-				if ($data['install_id']) $data['error'] .= $e->getMessage();
102
+				if ($data['install_id'])
103
+				{
104
+					$data['error'] .= $e->getMessage();
105
+				}
96 106
 			}
97 107
 			if ($this->hash_only)
98 108
 			{
Please login to merge, or discard this patch.
setup/inc/class.setup_detection.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@
 block discarded – undo
252 252
 	/**
253 253
 	 * Check if header exists and is up to date
254 254
 	 *
255
-	 * @return int 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok
255
+	 * @return string 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok
256 256
 	 */
257 257
 	function check_header()
258 258
 	{
Please login to merge, or discard this patch.
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@  discard block
 block discarded – undo
65 65
 					foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row)
66 66
 					{
67 67
 						$app = $row['app_name'];
68
-						if (!isset($setup_info[$app]))	// app source no longer there
68
+						if (!isset($setup_info[$app]))
69
+						{
70
+							// app source no longer there
69 71
 						{
70 72
 							$setup_info[$app] = array(
71 73
 								'name' => $app,
@@ -73,6 +75,7 @@  discard block
 block discarded – undo
73 75
 								'version' => 'deleted',
74 76
 							);
75 77
 						}
78
+						}
76 79
 						$setup_info[$app]['currentver'] = $row['app_version'];
77 80
 						$setup_info[$app]['enabled'] = $row['app_enabled'];
78 81
 					}
@@ -212,7 +215,9 @@  discard block
 block discarded – undo
212 215
 					if ($setup_info['depends'][$depkey]['status'] == False)
213 216
 					{
214 217
 						/* Only set this if it has not already failed to upgrade - Milosch */
215
-						if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
218
+						if($setup_info[$key]['status'] != 'F')
219
+						{
220
+							//&& $setup_info[$key]['status'] != 'C')
216 221
 						{
217 222
 							/* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install).
218 223
 							 * This should fix apps showing post-install dep failure when they are not yet installed.
@@ -220,6 +225,7 @@  discard block
 block discarded – undo
220 225
 							if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
221 226
 							{
222 227
 								$setup_info[$key]['status'] = 'D';
228
+						}
223 229
 							}
224 230
 							else
225 231
 							{
@@ -292,7 +298,10 @@  discard block
 block discarded – undo
292 298
 	 */
293 299
 	function check_db($setup_info=null)
294 300
 	{
295
-		if (!$setup_info) $setup_info = $GLOBALS['setup_info'];
301
+		if (!$setup_info)
302
+		{
303
+			$setup_info = $GLOBALS['setup_info'];
304
+		}
296 305
 
297 306
 		try {	// catch DB errors
298 307
 			if (!$GLOBALS['egw_setup']->db->Link_ID)
@@ -482,11 +491,14 @@  discard block
 block discarded – undo
482 491
 				{
483 492
 					echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
484 493
 				}
485
-				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))	// names in tables might be lowercase
494
+				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))
495
+				{
496
+					// names in tables might be lowercase
486 497
 				{
487 498
 					if($GLOBALS['DEBUG'])
488 499
 					{
489 500
 						echo '<br>check_app_tables(): ' . $val . ' missing!';
501
+				}
490 502
 					}
491 503
 					if(!$any)
492 504
 					{
@@ -543,9 +555,12 @@  discard block
 block discarded – undo
543 555
 			$msg = lang('does not exist');
544 556
 			return false;
545 557
 		}
546
-		if (!@is_writeable($dir) && $_SERVER['HTTP_HOST'])	// only do the check if we run by the webserver
558
+		if (!@is_writeable($dir) && $_SERVER['HTTP_HOST'])
559
+		{
560
+			// only do the check if we run by the webserver
547 561
 		{
548 562
 			$msg = lang('is not writeable by the webserver');
563
+		}
549 564
 			return false;
550 565
 		}
551 566
 		if ($check_in_docroot)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@
 block discarded – undo
464 464
 		{
465 465
 			/* Make a copy, else we send some callers into an infinite loop */
466 466
 			$copy = $setup_info;
467
-			$tables = Array();
467
+			$tables = array();
468 468
 			try {
469 469
 				$table_names = $GLOBALS['egw_setup']->db->table_names();
470 470
 				foreach($table_names as $key => $val)
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		$setup_info = array();
29 29
 		$d = dir(EGW_SERVER_ROOT);
30
-		while($entry=$d->read())
30
+		while ($entry = $d->read())
31 31
 		{
32
-			if($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT . '/' . $entry))
32
+			if ($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT.'/'.$entry))
33 33
 			{
34
-				$f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
35
-				if (@file_exists ($f))
34
+				$f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php';
35
+				if (@file_exists($f))
36 36
 				{
37 37
 					include($f);
38 38
 					$setup_info[$entry]['filename'] = $f;
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
 	 * @param array $setup_info
53 53
 	 * @return array $setup_info
54 54
 	 */
55
-	function get_db_versions($setup_info=null)
55
+	function get_db_versions($setup_info = null)
56 56
 	{
57 57
 		try {	// catch DB errors
58 58
 			$GLOBALS['egw_setup']->set_table_names();
59 59
 
60
-			if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table),true))
60
+			if ($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table), true))
61 61
 			{
62 62
 				/* one of these tables exists. checking for post/pre beta version */
63
-				if($GLOBALS['egw_setup']->applications_table != 'applications')
63
+				if ($GLOBALS['egw_setup']->applications_table != 'applications')
64 64
 				{
65
-					foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row)
65
+					foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table, '*', false, __LINE__, __FILE__) as $row)
66 66
 					{
67 67
 						$app = $row['app_name'];
68 68
 						if (!isset($setup_info[$app]))	// app source no longer there
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 					{
83 83
 						// new api, dont care about old pre egroupware stuff
84 84
 					}
85
-					elseif(!@$setup_info['phpgwapi']['currentver'])
85
+					elseif (!@$setup_info['phpgwapi']['currentver'])
86 86
 					{
87 87
 						$setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver'];
88 88
 						$setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver'];
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 				}
102 102
 				else
103 103
 				{
104
-					foreach($GLOBALS['egw_setup']->db->query('select * from applications') as $row)
104
+					foreach ($GLOBALS['egw_setup']->db->query('select * from applications') as $row)
105 105
 					{
106
-						if($row['app_name'] == 'admin')
106
+						if ($row['app_name'] == 'admin')
107 107
 						{
108 108
 							$setup_info['phpgwapi']['currentver'] = $row['app_version'];
109 109
 						}
@@ -136,25 +136,25 @@  discard block
 block discarded – undo
136 136
 	 * 	V	Version mismatch at end of upgrade (Not used, proposed only)
137 137
 	 * 	M	Missing files at start of upgrade (Not used, proposed only)
138 138
 	 */
139
-	function compare_versions($setup_info,$try_downgrade=false)
139
+	function compare_versions($setup_info, $try_downgrade = false)
140 140
 	{
141
-		foreach($setup_info as $key => $value)
141
+		foreach ($setup_info as $key => $value)
142 142
 		{
143 143
 			//echo '<br>'.$value['name'].'STATUS: '.$value['status'];
144 144
 			/* Only set this if it has not already failed to upgrade - Milosch */
145
-			if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') ))
145
+			if (!((@$value['status'] == 'F') || (@$value['status'] == 'C')))
146 146
 			{
147 147
 				//if ($setup_info[$key]['currentver'] > $setup_info[$key]['version'])
148
-				if(!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']) ||
148
+				if (!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'], @$value['version']) ||
149 149
 					$value['version'] == 'deleted')
150 150
 				{
151 151
 					$setup_info[$key]['status'] = 'V';
152 152
 				}
153
-				elseif(@$value['currentver'] == @$value['version'])
153
+				elseif (@$value['currentver'] == @$value['version'])
154 154
 				{
155 155
 					$setup_info[$key]['status'] = 'C';
156 156
 				}
157
-				elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version']))
157
+				elseif ($GLOBALS['egw_setup']->alessthanb(@$value['currentver'], @$value['version']))
158 158
 				{
159 159
 					$setup_info[$key]['status'] = 'U';
160 160
 				}
@@ -171,35 +171,35 @@  discard block
 block discarded – undo
171 171
 	function check_depends($setup_info)
172 172
 	{
173 173
 		/* Run the list of apps */
174
-		foreach($setup_info as $key => $value)
174
+		foreach ($setup_info as $key => $value)
175 175
 		{
176 176
 			/* Does this app have any depends */
177
-			if(isset($value['depends']))
177
+			if (isset($value['depends']))
178 178
 			{
179 179
 				/* If so find out which apps it depends on */
180
-				foreach($value['depends'] as $depkey => $depvalue)
180
+				foreach ($value['depends'] as $depkey => $depvalue)
181 181
 				{
182 182
 					/* I set this to False until we find a compatible version of this app */
183 183
 					$setup_info['depends'][$depkey]['status'] = False;
184 184
 					/* Now we loop thru the versions looking for a compatible version */
185 185
 
186
-					foreach($depvalue['versions'] as $depsvalue)
186
+					foreach ($depvalue['versions'] as $depsvalue)
187 187
 					{
188 188
 						$currentver = $setup_info[$depvalue['appname']]['currentver'];
189
-						if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99')
189
+						if ($depvalue['appname'] == 'phpgwapi' && substr($currentver, 0, 6) == '0.9.99')
190 190
 						{
191 191
 							$currentver = '0.9.14.508';
192 192
 						}
193 193
 						$major = $GLOBALS['egw_setup']->get_major($currentver);
194
-						if ($major >= $depsvalue || $major == $depsvalue && substr($major,0,strlen($depsvalue)+1) == $depsvalue.'.')
194
+						if ($major >= $depsvalue || $major == $depsvalue && substr($major, 0, strlen($depsvalue) + 1) == $depsvalue.'.')
195 195
 						{
196 196
 							$setup_info['depends'][$depkey]['status'] = True;
197 197
 						}
198 198
 						else	// check if majors are equal and minors greater or equal
199 199
 						{
200 200
 							$major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue);
201
-							$tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp);
202
-							$tmp2 = explode('.',$currentver); $minor = array_pop($tmp2);
201
+							$tmp = explode('.', $depsvalue); $minor_depsvalue = array_pop($tmp);
202
+							$tmp2 = explode('.', $currentver); $minor = array_pop($tmp2);
203 203
 							if ($major == $major_depsvalue && $minor <= $minor_depsvalue)
204 204
 							{
205 205
 								$setup_info['depends'][$depkey]['status'] = True;
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
 				 Finally, we loop through the dependencies again to look for apps that still have a failure status
213 213
 				 If we find one, we set the apps overall status as a dependency failure.
214 214
 				*/
215
-				foreach($value['depends'] as $depkey => $depvalue)
215
+				foreach ($value['depends'] as $depkey => $depvalue)
216 216
 				{
217 217
 					if ($setup_info['depends'][$depkey]['status'] == False)
218 218
 					{
219 219
 						/* Only set this if it has not already failed to upgrade - Milosch */
220
-						if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
220
+						if ($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
221 221
 						{
222 222
 							/* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install).
223 223
 							 * This should fix apps showing post-install dep failure when they are not yet installed.
224 224
 							 */
225
-							if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
225
+							if ($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
226 226
 							{
227 227
 								$setup_info[$key]['status'] = 'D';
228 228
 							}
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	function upgrade_exclude($setup_info)
246 246
 	{
247
-		foreach($setup_info as $key => $value)
247
+		foreach ($setup_info as $key => $value)
248 248
 		{
249
-			if(isset($value['no_mass_update']))
249
+			if (isset($value['no_mass_update']))
250 250
 			{
251 251
 				unset($setup_info[$key]);
252 252
 			}
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	function check_header()
263 263
 	{
264
-		if(!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200)
264
+		if (!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200)
265 265
 		{
266 266
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One';
267 267
 			return '1';
268 268
 		}
269 269
 		else
270 270
 		{
271
-			if(!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
271
+			if (!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
272 272
 			{
273 273
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)';
274 274
 				return '2';
275 275
 			}
276
-			elseif(!@isset($GLOBALS['egw_domain']))
276
+			elseif (!@isset($GLOBALS['egw_domain']))
277 277
 			{
278 278
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)';
279 279
 				return '3';
280 280
 			}
281
-			elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
281
+			elseif (@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
282 282
 			{
283 283
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)';
284 284
 				return '4';
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 * @param array $setup_info =null default use $GLOBALS['setup_info']
296 296
 	 * @return int 1=no database, 3=empty, 4=need upgrade, 10=complete
297 297
 	 */
298
-	function check_db($setup_info=null)
298
+	function check_db($setup_info = null)
299 299
 	{
300 300
 		if (!$setup_info) $setup_info = $GLOBALS['setup_info'];
301 301
 
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
 			if (!$GLOBALS['egw_setup']->db->Link_ID)
304 304
 			{
305 305
 				$old = error_reporting();
306
-				error_reporting($old & ~E_WARNING);	// no warnings
306
+				error_reporting($old&~E_WARNING); // no warnings
307 307
 				$GLOBALS['egw_setup']->db->connect();
308 308
 				error_reporting($old);
309 309
 
310 310
 				$GLOBALS['egw_setup']->set_table_names();
311 311
 			}
312 312
 		}
313
-		catch(Api\Db\Exception $e) {
313
+		catch (Api\Db\Exception $e) {
314 314
 			// ignore error
315 315
 		}
316 316
 
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
320 320
 			return 1;
321 321
 		}
322
-		if(!isset($setup_info['api']['currentver']))
322
+		if (!isset($setup_info['api']['currentver']))
323 323
 		{
324 324
 			$setup_info = $this->get_db_versions($setup_info);
325 325
 		}
326 326
 		// first check new api installed and up to date
327 327
 		if (isset($setup_info['api']['currentver']))
328 328
 		{
329
-			if($setup_info['api']['currentver'] == $setup_info['api']['version'])
329
+			if ($setup_info['api']['currentver'] == $setup_info['api']['version'])
330 330
 			{
331 331
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
332 332
 				return 10;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		// then check old phpgwapi
341 341
 		elseif (isset($setup_info['phpgwapi']['currentver']))
342 342
 		{
343
-			if($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version'])
343
+			if ($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version'])
344 344
 			{
345 345
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
346 346
 				return 10;
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	function check_config()
377 377
 	{
378
-		if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
378
+		if (@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
379 379
 		{
380 380
 			return '';
381 381
 		}
382 382
 
383 383
 		try {	// catch db errors
384
-			foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,
385
-				'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__) as $row)
384
+			foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,
385
+				'config_name,config_value', array('config_app' => 'phpgwapi'), __LINE__, __FILE__) as $row)
386 386
 			{
387 387
 				$config[$row['config_name']] = $row['config_value'];
388 388
 			}
@@ -392,21 +392,21 @@  discard block
 block discarded – undo
392 392
 			// ignore db errors
393 393
 		}
394 394
 		$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)';
395
-		if(!count($config))
395
+		if (!count($config))
396 396
 		{
397 397
 			return 1;
398 398
 		}
399
-		$config_errors =& $GLOBALS['egw_info']['setup']['config_errors'];
399
+		$config_errors = & $GLOBALS['egw_info']['setup']['config_errors'];
400 400
 		$GLOBALS['egw_info']['setup']['config_errors'] = array();
401 401
 		$error_msg = null;
402
-		if (!$this->check_dir($config['temp_dir'],$error_msg))
402
+		if (!$this->check_dir($config['temp_dir'], $error_msg))
403 403
 		{
404
-			$config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg);
404
+			$config_errors[] = lang("Your temporary directory '%1' %2", $config['temp_dir'], $error_msg);
405 405
 		}
406 406
 
407
-		if (!$this->check_dir($config['files_dir'],$error_msg,true))
407
+		if (!$this->check_dir($config['files_dir'], $error_msg, true))
408 408
 		{
409
-			$config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg);
409
+			$config_errors[] = lang("Your files directory '%1' %2", $config['files_dir'], $error_msg);
410 410
 		}
411 411
 		// set and create the default backup_dir
412 412
 		if (@is_writeable($config['files_dir']) && empty($config['backup_dir']))
@@ -414,35 +414,35 @@  discard block
 block discarded – undo
414 414
 			$config['backup_dir'] = $config['files_dir'].'/db_backup';
415 415
 			if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir']))
416 416
 			{
417
-				$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
417
+				$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
418 418
 					'config_value' => $config['backup_dir'],
419
-				),array(
419
+				), array(
420 420
 					'config_app'  => 'phpgwapi',
421 421
 					'config_name' => 'backup_dir',
422
-				),__LINE__,__FILE__);
422
+				), __LINE__, __FILE__);
423 423
 			}
424 424
 		}
425 425
 		if (isset($config['backup_mincount']))
426 426
 		{
427
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
427
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
428 428
 				'config_value' => $config['backup_mincount'],
429
-				),array(
429
+				), array(
430 430
 				'config_app'  => 'phpgwapi',
431 431
 				'config_name' => 'backup_mincount',
432
-			),__LINE__,__FILE__);
432
+			), __LINE__, __FILE__);
433 433
 		}
434 434
 		if (isset($config['backup_files']))
435 435
 		{
436
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
436
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
437 437
 				'config_value' => (int)$config['backup_files'],
438
-				),array(
438
+				), array(
439 439
 				'config_app'  => 'phpgwapi',
440 440
 				'config_name' => 'backup_files',
441
-			),__LINE__,__FILE__);
441
+			), __LINE__, __FILE__);
442 442
 		}
443
-		if (!$this->check_dir($config['backup_dir'],$error_msg,true))
443
+		if (!$this->check_dir($config['backup_dir'], $error_msg, true))
444 444
 		{
445
-			$config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg);
445
+			$config_errors[] = lang("Your backup directory '%1' %2", $config['backup_dir'], $error_msg);
446 446
 		}
447 447
 		if ($config_errors)
448 448
 		{
@@ -458,19 +458,19 @@  discard block
 block discarded – undo
458 458
 	 * @param $appname
459 459
 	 * @param $any		optional, set to True to see if any of the apps tables are installed
460 460
 	 */
461
-	function check_app_tables($appname,$any=False)
461
+	function check_app_tables($appname, $any = False)
462 462
 	{
463 463
 		$none = 0;
464 464
 		$setup_info = $GLOBALS['setup_info'];
465 465
 
466
-		if(@$setup_info[$appname]['tables'])
466
+		if (@$setup_info[$appname]['tables'])
467 467
 		{
468 468
 			/* Make a copy, else we send some callers into an infinite loop */
469 469
 			$copy = $setup_info;
470 470
 			$tables = Array();
471 471
 			try {
472 472
 				$table_names = $GLOBALS['egw_setup']->db->table_names();
473
-				foreach($table_names as $key => $val)
473
+				foreach ($table_names as $key => $val)
474 474
 				{
475 475
 					$tables[] = $val['table_name'];
476 476
 				}
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
 				unset($e);
480 480
 				// ignore db error
481 481
 			}
482
-			foreach($copy[$appname]['tables'] as $key => $val)
482
+			foreach ($copy[$appname]['tables'] as $key => $val)
483 483
 			{
484
-				if($GLOBALS['DEBUG'])
484
+				if ($GLOBALS['DEBUG'])
485 485
 				{
486
-					echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
486
+					echo '<br>check_app_tables(): Checking: '.$appname.',table: '.$val;
487 487
 				}
488
-				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))	// names in tables might be lowercase
488
+				if (!in_array($val, $tables) && !in_array(strtolower($val), $tables))	// names in tables might be lowercase
489 489
 				{
490
-					if($GLOBALS['DEBUG'])
490
+					if ($GLOBALS['DEBUG'])
491 491
 					{
492
-						echo '<br>check_app_tables(): ' . $val . ' missing!';
492
+						echo '<br>check_app_tables(): '.$val.' missing!';
493 493
 					}
494
-					if(!$any)
494
+					if (!$any)
495 495
 					{
496 496
 						return False;
497 497
 					}
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 				}
503 503
 				else
504 504
 				{
505
-					if($any)
505
+					if ($any)
506 506
 					{
507
-						if($GLOBALS['DEBUG'])
507
+						if ($GLOBALS['DEBUG'])
508 508
 						{
509 509
 							echo '<br>check_app_tables(): Some tables installed';
510 510
 						}
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 				}
514 514
 			}
515 515
 		}
516
-		if($none && $any)
516
+		if ($none && $any)
517 517
 		{
518
-			if($GLOBALS['DEBUG'])
518
+			if ($GLOBALS['DEBUG'])
519 519
 			{
520 520
 				echo '<br>check_app_tables(): No tables installed';
521 521
 			}
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		}
524 524
 		else
525 525
 		{
526
-			if($GLOBALS['DEBUG'])
526
+			if ($GLOBALS['DEBUG'])
527 527
 			{
528 528
 				echo '<br>check_app_tables(): All tables installed';
529 529
 			}
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
 	 * @param boolean $check_in_docroot =false run an optional in docroot check
540 540
 	 * @return boolean
541 541
 	 */
542
-	static function check_dir($dir,&$msg,$check_in_docroot=false)
542
+	static function check_dir($dir, &$msg, $check_in_docroot = false)
543 543
 	{
544
-		if (!@is_dir($dir) && !@mkdir($dir,0700,true))
544
+		if (!@is_dir($dir) && !@mkdir($dir, 0700, true))
545 545
 		{
546 546
 			$msg = lang('does not exist');
547 547
 			return false;
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 		}
554 554
 		if ($check_in_docroot)
555 555
 		{
556
-			$docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT']));
556
+			$docroots = array(realpath(EGW_SERVER_ROOT), realpath($_SERVER['DOCUMENT_ROOT']));
557 557
 			$dir = realpath($dir);
558 558
 
559 559
 			foreach ($docroots as $docroot)
560 560
 			{
561 561
 				$len = strlen($docroot);
562 562
 
563
-				if ($docroot == substr($dir,0,$len) && $len>0)
563
+				if ($docroot == substr($dir, 0, $len) && $len > 0)
564 564
 				{
565
-					$rest = substr($dir,$len);
565
+					$rest = substr($dir, $len);
566 566
 
567 567
 					if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
568 568
 					{
Please login to merge, or discard this patch.
setup/inc/class.setup_process.inc.php 3 patches
Doc Comments   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,10 +53,7 @@
 block discarded – undo
53 53
 	 * the mother of all multipass upgrade parental loop functions
54 54
 	 *
55 55
 	 * @param array $setup_info array of application info from setup.inc.php files
56
-	 * @param string $type='new' defaults to new(install), could also be 'upgrade'
57
-	 * @param boolean $DEBUG=false print debugging info
58
-	 * @param boolean $force_en=false install english language files, not used anymore
59
-	 * @param string $system_charset=null charset to use
56
+	 * @param boolean $force_en install english language files, not used anymore
60 57
 	 * @param array $preset_config=array()
61 58
 	 */
62 59
 	function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array())
Please login to merge, or discard this patch.
Braces   +53 added lines, -16 removed lines patch added patch discarded remove patch
@@ -108,7 +108,9 @@  discard block
 block discarded – undo
108 108
 		while($pass_string != $passing_string)
109 109
 		{
110 110
 			$passing = array();
111
-			if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
111
+			if($DEBUG)
112
+			{
113
+echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
112 114
 
113 115
 			// Check current versions and dependencies
114 116
 			$setup_info = $GLOBALS['egw_setup']->detection->check_depends(
@@ -143,7 +145,10 @@  discard block
 block discarded – undo
143 145
 					}
144 146
 					/* Create tables and insert new records for each app in this list */
145 147
 					$passing_c = $this->current($pass,$DEBUG);
146
-					if (isset($pass['api'])) $this->save_minimal_config($preset_config);
148
+					if (isset($pass['api']))
149
+					{
150
+						$this->save_minimal_config($preset_config);
151
+					}
147 152
 					$passing = $this->default_records($passing_c,$DEBUG);
148 153
 					break;
149 154
 				case 'upgrade':
@@ -162,29 +167,40 @@  discard block
 block discarded – undo
162 167
 				if($value['status'] == 'C')
163 168
 				{
164 169
 					$passed[$value['name']] = $passing[$value['name']];
165
-					if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
170
+					if($DEBUG)
171
+					{
172
+echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
166 173
 				}
167 174
 				elseif($value['status'] == 'F')
168 175
 				{
169 176
 					$setup_info[$value['name']] = $passing[$value['name']];
170
-					if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
177
+					if($DEBUG)
178
+					{
179
+echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
171 180
 				}
172 181
 				elseif($value['status'] == 'D')
173 182
 				{
174 183
 					$pass[$value['name']] = $setup_info[$value['name']];
175
-					if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
184
+					if($DEBUG)
185
+					{
186
+echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
176 187
 				}
177 188
 				else
178 189
 				{
179 190
 					$tmp = $passing[$value['name']]['name'];
180
-					if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; }
191
+					if($DEBUG)
192
+					{
193
+echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; }
181 194
 				}
182 195
 			}
183 196
 
184 197
 			$i++;
185
-			if($i == 20) /* Then oops it broke */
198
+			if($i == 20)
199
+			{
200
+				/* Then oops it broke */
186 201
 			{
187 202
 				echo '<br>Setup failure: excess looping in process->pass():'."\n";
203
+			}
188 204
 				echo '<br>Pass:<br>'."\n";
189 205
 				_debug_array($pass);
190 206
 				echo '<br>Passed:<br>'."\n";
@@ -376,7 +392,9 @@  discard block
 block discarded – undo
376 392
 					//echo $table;
377 393
 					if(in_array($table,$tables))
378 394
 					{
379
-						if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; }
395
+						if($DEBUG)
396
+						{
397
+echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; }
380 398
 						$GLOBALS['egw_setup']->oProc->DropTable($table);
381 399
 						// Update the array values for return below
382 400
 						$setup_info[$app_name]['status'] = 'U';
@@ -408,13 +426,17 @@  discard block
 block discarded – undo
408 426
 			$enabled = False;
409 427
 			$apptitle = $appdata['title'];
410 428
 
411
-			if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; }
429
+			if($DEBUG)
430
+			{
431
+echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; }
412 432
 
413 433
 			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
414 434
 
415 435
 			if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php'))
416 436
 			{
417
-				if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; }
437
+				if($DEBUG)
438
+				{
439
+echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; }
418 440
 				$phpgw_baseline = null;
419 441
 				include ($appdir.'tables_current.inc.php');
420 442
 				$ret = $this->post_process($phpgw_baseline,$DEBUG);
@@ -435,13 +457,17 @@  discard block
 block discarded – undo
435 457
 				else
436 458
 				{
437 459
 					/* script processing failed */
438
-					if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; }
460
+					if($DEBUG)
461
+					{
462
+echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; }
439 463
 					$appdata['status'] = 'F';
440 464
 				}
441 465
 			}
442 466
 			else
443 467
 			{
444
-				if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; }
468
+				if($DEBUG)
469
+				{
470
+echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; }
445 471
 				/*
446 472
 				 Add the app, but disable it if it has tables defined.
447 473
 				 A manual sql script install is needed, but we do add the hooks
@@ -462,7 +488,9 @@  discard block
 block discarded – undo
462 488
 				}
463 489
 				$appdata['status'] = 'C';
464 490
 			}
465
-			if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; }
491
+			if($DEBUG)
492
+			{
493
+echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; }
466 494
 		}
467 495
 
468 496
 		// update hooks
@@ -638,9 +666,12 @@  discard block
 block discarded – undo
638 666
 			{
639 667
 				echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n";
640 668
 			}
641
-			if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
669
+			if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '')
670
+			{
671
+				// TODO this is not getting set for api upgrade, sometimes ???
642 672
 			{
643 673
 				$currentver = $appdata['currentver'];
674
+			}
644 675
 				$targetver  = $appdata['version'];	// The version we need to match when done
645 676
 				$appdir     = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
646 677
 
@@ -674,11 +705,14 @@  discard block
 block discarded – undo
674 705
 							}
675 706
 						}
676 707
 					}
677
-					if ($currentver == $targetver)	// upgrades succesful
708
+					if ($currentver == $targetver)
709
+					{
710
+						// upgrades succesful
678 711
 					{
679 712
 						if($DEBUG)
680 713
 						{
681 714
 							echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n";
715
+					}
682 716
 						}
683 717
 						$appstatus = 'C';
684 718
 					}
@@ -700,9 +734,12 @@  discard block
 block discarded – undo
700 734
 					}
701 735
 					$appstatus  = 'C';
702 736
 				}
703
-				if ($appstatus == 'C')	// update successful completed
737
+				if ($appstatus == 'C')
738
+				{
739
+					// update successful completed
704 740
 				{
705 741
 					$appdata['currentver'] = $targetver;
742
+				}
706 743
 
707 744
 					if($GLOBALS['egw_setup']->app_registered($appname))
708 745
 					{
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @param string $system_charset=null charset to use
60 60
 	 * @param array $preset_config=array()
61 61
 	 */
62
-	function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array())
62
+	function pass(array $setup_info, $method = 'new', $DEBUG = False, $force_en = False, $preset_config = array())
63 63
 	{
64
-		unset($force_en);	// no longer used
64
+		unset($force_en); // no longer used
65 65
 
66
-		if(!$method)
66
+		if (!$method)
67 67
 		{
68 68
 			return False;
69 69
 		}
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
 			// ignore emailadmin, it's only there for updates
95 95
 			unset($setup_info['emailadmin']);
96 96
 		}
97
-		$pass['admin']    = $setup_info['admin'];
97
+		$pass['admin'] = $setup_info['admin'];
98 98
 		$pass['preferences'] = $setup_info['preferences'];
99 99
 		if (file_exists(EGW_SERVER_ROOT.'/etemplate'))
100 100
 		{
101
-			$pass['etemplate'] = $setup_info['etemplate'];	// helps to minimize passes, as many apps depend on it
101
+			$pass['etemplate'] = $setup_info['etemplate']; // helps to minimize passes, as many apps depend on it
102 102
 		}
103 103
 		$this->api_version_target = $setup_info['api']['version'];
104 104
 
105 105
 		$i = 1;
106 106
 		$passed = array();
107 107
 		$passing = array();
108
-		$pass_string = implode (':', $pass);
109
-		$passing_string = implode (':', $passing);
110
-		while($pass_string != $passing_string)
108
+		$pass_string = implode(':', $pass);
109
+		$passing_string = implode(':', $passing);
110
+		while ($pass_string != $passing_string)
111 111
 		{
112 112
 			$passing = array();
113
-			if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
113
+			if ($DEBUG) { echo '<br>process->pass(): #'.$i.' for '.$method.' processing'."\n"; }
114 114
 
115 115
 			// Check current versions and dependencies
116 116
 			$setup_info = $GLOBALS['egw_setup']->detection->check_depends(
@@ -118,25 +118,25 @@  discard block
 block discarded – undo
118 118
 					$GLOBALS['egw_setup']->detection->get_db_versions($setup_info), true));
119 119
 
120 120
 			// stuff the rest of the apps, but only those with available upgrades
121
-			foreach($setup_info as $key => $value)
121
+			foreach ($setup_info as $key => $value)
122 122
 			{
123 123
 				// check if app is either installed or supports the used database
124 124
 				if (!isset($value['currentver']) && isset($value['only_db']) && (
125
-					is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type,$value['only_db']) ||
125
+					is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type, $value['only_db']) ||
126 126
 					!is_array($value['only_db']) && $GLOBALS['egw_setup']->db->Type != $value['only_db']))
127 127
 				{
128
-					continue;	// app does not support this db-type, dont try installing it
128
+					continue; // app does not support this db-type, dont try installing it
129 129
 				}
130
-				if(/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U')
130
+				if (/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U')
131 131
 				{
132
-					if($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C')
132
+					if ($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C')
133 133
 					{
134 134
 						$pass[$value['name']] = $setup_info[$value['name']];
135 135
 					}
136 136
 				}
137 137
 			}
138 138
 
139
-			switch($method)
139
+			switch ($method)
140 140
 			{
141 141
 				case 'new':
142 142
 					if (empty($GLOBALS['egw_info']['server']['temp_dir']))
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 						$GLOBALS['egw_info']['server']['temp_dir'] = sys_get_temp_dir();
145 145
 					}
146 146
 					/* Create tables and insert new records for each app in this list */
147
-					$passing_c = $this->current($pass,$DEBUG);
147
+					$passing_c = $this->current($pass, $DEBUG);
148 148
 					if (isset($pass['api'])) $this->save_minimal_config($preset_config);
149
-					$passing = $this->default_records($passing_c,$DEBUG);
149
+					$passing = $this->default_records($passing_c, $DEBUG);
150 150
 					break;
151 151
 				case 'upgrade':
152 152
 					/* Run upgrade scripts on each app in the list */
153
-					$passing = $this->upgrade($pass,$DEBUG);
153
+					$passing = $this->upgrade($pass, $DEBUG);
154 154
 					//_debug_array($pass);exit;
155 155
 					break;
156 156
 				default:
@@ -159,32 +159,32 @@  discard block
 block discarded – undo
159 159
 			}
160 160
 
161 161
 			$pass = array();
162
-			foreach($passing as $key => $value)
162
+			foreach ($passing as $key => $value)
163 163
 			{
164
-				if($value['status'] == 'C')
164
+				if ($value['status'] == 'C')
165 165
 				{
166 166
 					$passed[$value['name']] = $passing[$value['name']];
167
-					if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
167
+					if ($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'].' install completed'."\n"; }
168 168
 				}
169
-				elseif($value['status'] == 'F')
169
+				elseif ($value['status'] == 'F')
170 170
 				{
171 171
 					$setup_info[$value['name']] = $passing[$value['name']];
172
-					if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
172
+					if ($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'].' install failed'."\n"; }
173 173
 				}
174
-				elseif($value['status'] == 'D')
174
+				elseif ($value['status'] == 'D')
175 175
 				{
176 176
 					$pass[$value['name']] = $setup_info[$value['name']];
177
-					if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
177
+					if ($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'].' fails dependency check on this pass'."\n"; }
178 178
 				}
179 179
 				else
180 180
 				{
181 181
 					$tmp = $passing[$value['name']]['name'];
182
-					if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; }
182
+					if ($DEBUG) { echo '<br>process->pass(): '.$tmp.' skipped on this pass'."\n"; }
183 183
 				}
184 184
 			}
185 185
 
186 186
 			$i++;
187
-			if($i == 20) /* Then oops it broke */
187
+			if ($i == 20) /* Then oops it broke */
188 188
 			{
189 189
 				echo '<br>Setup failure: excess looping in process->pass():'."\n";
190 190
 				echo '<br>Pass:<br>'."\n";
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
 				_debug_array($passed);
194 194
 				exit;
195 195
 			}
196
-			$pass_string = implode (':', $pass);
197
-			$passing_string = implode (':', $passing);
196
+			$pass_string = implode(':', $pass);
197
+			$passing_string = implode(':', $passing);
198 198
 		}
199 199
 		try {
200 200
 			// flush instance cache: also registers hooks and flushes image cache
201 201
 			Api\Cache::flush(Api\Cache::INSTANCE);
202 202
 		}
203
-		catch(Exception $e) {
203
+		catch (Exception $e) {
204 204
 			unset($e);
205 205
 			// ignore exception, as during a new install, there's no cache configured and therefore no need to unset
206 206
 		}
207 207
 		/* now return the list */
208
-		return array_merge($setup_info,$passed);
208
+		return array_merge($setup_info, $passed);
209 209
 	}
210 210
 
211 211
 	/**
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @param array $preset_config =array()
215 215
 	 */
216
-	function save_minimal_config(array $preset_config=array())
216
+	function save_minimal_config(array $preset_config = array())
217 217
 	{
218
-		$is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN';
218
+		$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
219 219
 
220 220
 		$current_config['site_title'] = 'EGroupware';
221
-		$current_config['hostname']  = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
221
+		$current_config['hostname'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
222 222
 
223 223
 		// guessing the eGW url
224 224
 		if (isset($_SERVER['HTTP_HOST']))
225 225
 		{
226
-			$parts = explode('/',$_SERVER['PHP_SELF']);
227
-			array_pop($parts);	// remove config.php
228
-			array_pop($parts);	// remove setup
229
-			$current_config['webserver_url'] = implode('/',$parts);
226
+			$parts = explode('/', $_SERVER['PHP_SELF']);
227
+			array_pop($parts); // remove config.php
228
+			array_pop($parts); // remove setup
229
+			$current_config['webserver_url'] = implode('/', $parts);
230 230
 			$egroupwareDirName = end($parts);
231 231
 		}
232 232
 		else	// eg. cli install --> use defaults
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 			$current_config['webserver_url'] = '/egroupware';
235 235
 			$egroupwareDirName = 'egroupware';
236 236
 		}
237
-		if(!$is_windows)
237
+		if (!$is_windows)
238 238
 		{
239
-			if(@is_dir('/tmp'))
239
+			if (@is_dir('/tmp'))
240 240
 			{
241 241
 				$current_config['temp_dir'] = '/tmp';
242 242
 			}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		}
251 251
 		else
252 252
 		{
253
-			if(@is_dir('c:\\windows\\temp'))
253
+			if (@is_dir('c:\\windows\\temp'))
254 254
 			{
255 255
 				$current_config['temp_dir'] = 'c:\\windows\\temp';
256 256
 			}
@@ -271,15 +271,15 @@  discard block
 block discarded – undo
271 271
 		$current_config['enabled_spellcheck'] = 'YesBrowserBased';
272 272
 
273 273
 		// always enable history logging for calendar, addressbook and infolog
274
-		$current_config['history'] = 'history';	// addressbook: only admin
275
-		$current_config['calendar_delete_history'] = 'history';	// only admins
274
+		$current_config['history'] = 'history'; // addressbook: only admin
275
+		$current_config['calendar_delete_history'] = 'history'; // only admins
276 276
 		// infolog does NOT use config_app='phpgwapi', but 'infolog'
277
-		$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
278
-			'config_value' => 'history_admin_delete',	// only admins
279
-		),array(
277
+		$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
278
+			'config_value' => 'history_admin_delete', // only admins
279
+		), array(
280 280
 			'config_app' => 'infolog',
281 281
 			'config_name' => 'history',
282
-		),__FILE__,__LINE__);
282
+		), __FILE__, __LINE__);
283 283
 
284 284
 
285 285
 		// RalfBecker: php.net recommend this for security reasons, it should be our default too
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			$tz = new DateTimeZone(date_default_timezone_get());
296 296
 			$current_config['server_timezone'] = $tz->getName();
297 297
 		}
298
-		catch(Exception $e)
298
+		catch (Exception $e)
299 299
 		{
300 300
 			unset($e);
301 301
 			// do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it!
@@ -303,42 +303,42 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 		$current_config['install_id'] = md5($_SERVER['HTTP_HOST'].microtime(true).$GLOBALS['egw_setup']->ConfigDomain);
305 305
 
306
-		$current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400;	// ask user in 2 month from now, when he has something to report
306
+		$current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400; // ask user in 2 month from now, when he has something to report
307 307
 
308 308
 		// use securest password hash by default
309
-		require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php';	// for sql_passwdhashes, to get securest available password hash
309
+		require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php'; // for sql_passwdhashes, to get securest available password hash
310 310
 		$securest = null;
311 311
 		sql_passwdhashes(array(), true, $securest);
312 312
 		$current_config['sql_encryption_type'] = $current_config['ldap_encryption_type'] = $securest;
313 313
 
314 314
 		if ($preset_config)
315 315
 		{
316
-			$current_config = array_merge($current_config,$preset_config);
316
+			$current_config = array_merge($current_config, $preset_config);
317 317
 		}
318 318
 
319
-		foreach($current_config as $name => $value)
319
+		foreach ($current_config as $name => $value)
320 320
 		{
321 321
 			$app = 'phpgwapi';
322 322
 			if ($name == 'postpone_statistics_submit')
323 323
 			{
324 324
 				$app = 'admin';
325 325
 			}
326
-			elseif(strpos($name, '/') !== false)
326
+			elseif (strpos($name, '/') !== false)
327 327
 			{
328 328
 				list($app, $name) = explode('/', $name);
329 329
 			}
330
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
330
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
331 331
 				'config_value' => $value,
332
-			),array(
332
+			), array(
333 333
 				'config_app' => $app,
334 334
 				'config_name' => $name,
335
-			),__FILE__,__LINE__);
335
+			), __FILE__, __LINE__);
336 336
 		}
337 337
 
338 338
 		// so the default_records use the current data
339 339
 		$GLOBALS['egw_info']['server'] = array_merge((array)$GLOBALS['egw_info']['server'], $current_config);
340
-		Api\Cache::flush();	// flush whole instance cache
341
-		Api\Config::init_static();	// flush internal cache of Api\Config class
340
+		Api\Cache::flush(); // flush whole instance cache
341
+		Api\Config::init_static(); // flush internal cache of Api\Config class
342 342
 		$GLOBALS['egw_setup']->setup_account_object($current_config);
343 343
 	}
344 344
 
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @param $setup_info	array of application info from setup.inc.php files, etc.
349 349
 	 */
350
-	function droptables(array $setup_info,$DEBUG=False)
350
+	function droptables(array $setup_info, $DEBUG = False)
351 351
 	{
352
-		if(!@$GLOBALS['egw_setup']->oProc)
352
+		if (!@$GLOBALS['egw_setup']->oProc)
353 353
 		{
354 354
 			$this->init_process();
355 355
 		}
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 		$tablenames = $GLOBALS['egw_setup']->db->table_names();
358 358
 		if (!is_array($setup_info) || !is_array($tablenames))
359 359
 		{
360
-			return $setup_info;	// nothing to do
360
+			return $setup_info; // nothing to do
361 361
 		}
362 362
 		$tables = array();
363
-		foreach($tablenames as $data)
363
+		foreach ($tablenames as $data)
364 364
 		{
365 365
 			$tables[] = $data['table_name'];
366 366
 		}
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 		{
370 370
 			return $setup_info;
371 371
 		}
372
-		foreach($setup_info as $app_name => $data)
372
+		foreach ($setup_info as $app_name => $data)
373 373
 		{
374
-			if(is_array($data['tables']))
374
+			if (is_array($data['tables']))
375 375
 			{
376
-				foreach($data['tables'] as $table)
376
+				foreach ($data['tables'] as $table)
377 377
 				{
378 378
 					//echo $table;
379
-					if(in_array($table,$tables))
379
+					if (in_array($table, $tables))
380 380
 					{
381
-						if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; }
381
+						if ($DEBUG) { echo '<br>process->droptables(): Dropping :'.$app_name.' table: '.$table; }
382 382
 						$GLOBALS['egw_setup']->oProc->DropTable($table);
383 383
 						// Update the array values for return below
384 384
 						$setup_info[$app_name]['status'] = 'U';
@@ -398,31 +398,31 @@  discard block
 block discarded – undo
398 398
 	 * @param boolean $DEBUG =false output further diagnostics
399 399
 	 * @return array $setup_info
400 400
 	 */
401
-	function current(array $setup_info,$DEBUG=False)
401
+	function current(array $setup_info, $DEBUG = False)
402 402
 	{
403 403
 		//echo __METHOD__; _debug_array($setup_info);
404
-		if(!isset($GLOBALS['egw_setup']->oProc))
404
+		if (!isset($GLOBALS['egw_setup']->oProc))
405 405
 		{
406 406
 			$this->init_process();
407 407
 		}
408
-		foreach($setup_info as $appname => &$appdata)
408
+		foreach ($setup_info as $appname => &$appdata)
409 409
 		{
410 410
 			$enabled = False;
411 411
 			$apptitle = $appdata['title'];
412 412
 
413
-			if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; }
413
+			if ($DEBUG) { echo '<br>process->current(): Incoming status: '.$appname.',status: '.$appdata['status']; }
414 414
 
415
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
415
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
416 416
 
417
-			if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php'))
417
+			if ($appdata['tables'] && file_exists($appdir.'tables_current.inc.php'))
418 418
 			{
419
-				if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; }
419
+				if ($DEBUG) { echo '<br>process->current(): Including: '.$appdir.'tables_current.inc.php'; }
420 420
 				$phpgw_baseline = null;
421 421
 				include ($appdir.'tables_current.inc.php');
422
-				$ret = $this->post_process($phpgw_baseline,$DEBUG);
423
-				if($ret)
422
+				$ret = $this->post_process($phpgw_baseline, $DEBUG);
423
+				if ($ret)
424 424
 				{
425
-					if($GLOBALS['egw_setup']->app_registered($appname))
425
+					if ($GLOBALS['egw_setup']->app_registered($appname))
426 426
 					{
427 427
 						$GLOBALS['egw_setup']->update_app($appname);
428 428
 					}
@@ -437,34 +437,34 @@  discard block
 block discarded – undo
437 437
 				else
438 438
 				{
439 439
 					/* script processing failed */
440
-					if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; }
440
+					if ($DEBUG) { echo '<br>process->current(): Failed for '.$appname.',status: '.$appdata['status']; }
441 441
 					$appdata['status'] = 'F';
442 442
 				}
443 443
 			}
444 444
 			else
445 445
 			{
446
-				if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; }
446
+				if ($DEBUG) { echo '<br>process->current(): No current tables for '.$apptitle."\n"; }
447 447
 				/*
448 448
 				 Add the app, but disable it if it has tables defined.
449 449
 				 A manual sql script install is needed, but we do add the hooks
450 450
 				*/
451 451
 				$enabled = 99;
452
-				if($appdata['tables'][0] != '')
452
+				if ($appdata['tables'][0] != '')
453 453
 				{
454 454
 					$enabled = False;
455 455
 				}
456
-				if($GLOBALS['egw_setup']->app_registered($appname))
456
+				if ($GLOBALS['egw_setup']->app_registered($appname))
457 457
 				{
458 458
 					$GLOBALS['egw_setup']->update_app($appname);
459 459
 				}
460 460
 				else
461 461
 				{
462
-					$GLOBALS['egw_setup']->register_app($appname,$enabled);
462
+					$GLOBALS['egw_setup']->register_app($appname, $enabled);
463 463
 					$GLOBALS['egw_setup']->set_default_preferences($appname);
464 464
 				}
465 465
 				$appdata['status'] = 'C';
466 466
 			}
467
-			if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; }
467
+			if ($DEBUG) { echo '<br>process->current(): Outgoing status: '.$appname.',status: '.$appdata['status']; }
468 468
 		}
469 469
 
470 470
 		// update hooks
@@ -481,25 +481,25 @@  discard block
 block discarded – undo
481 481
 	 * @param boolean $DEBUG =false output further diagnostics
482 482
 	 * @return array $setup_info
483 483
 	 */
484
-	function default_records(array $setup_info,$DEBUG=False)
484
+	function default_records(array $setup_info, $DEBUG = False)
485 485
 	{
486 486
 		//echo __METHOD__; _debug_array($setup_info);
487
-		if(!@$GLOBALS['egw_setup']->oProc)
487
+		if (!@$GLOBALS['egw_setup']->oProc)
488 488
 		{
489 489
 			$this->init_process();
490 490
 		}
491
-		foreach($setup_info as $appname => &$appdata)
491
+		foreach ($setup_info as $appname => &$appdata)
492 492
 		{
493
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
493
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
494 494
 
495
-			if(file_exists($appdir.'default_records.inc.php'))
495
+			if (file_exists($appdir.'default_records.inc.php'))
496 496
 			{
497
-				if($DEBUG)
497
+				if ($DEBUG)
498 498
 				{
499
-					echo '<br>process->default_records(): Including default records for ' . $appname . "\n";
499
+					echo '<br>process->default_records(): Including default records for '.$appname."\n";
500 500
 				}
501 501
 				$GLOBALS['egw_setup']->oProc->m_odb->transaction_begin();
502
-				$oProc = &$GLOBALS['egw_setup']->oProc;	// to be compatible with old apps
502
+				$oProc = &$GLOBALS['egw_setup']->oProc; // to be compatible with old apps
503 503
 				include ($appdir.'default_records.inc.php');
504 504
 				$GLOBALS['egw_setup']->oProc->m_odb->transaction_commit();
505 505
 			}
@@ -523,21 +523,21 @@  discard block
 block discarded – undo
523 523
 	 * @param boolean $DEBUG =false output further diagnostics
524 524
 	 * @return array $setup_info
525 525
 	 */
526
-	function test_data(array $setup_info,$DEBUG=False)
526
+	function test_data(array $setup_info, $DEBUG = False)
527 527
 	{
528
-		if(!@$GLOBALS['egw_setup']->oProc)
528
+		if (!@$GLOBALS['egw_setup']->oProc)
529 529
 		{
530 530
 			$this->init_process();
531 531
 		}
532
-		foreach($setup_info as $appname => &$appdata)
532
+		foreach ($setup_info as $appname => &$appdata)
533 533
 		{
534
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
534
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
535 535
 
536
-			if(file_exists($appdir.'test_data.inc.php'))
536
+			if (file_exists($appdir.'test_data.inc.php'))
537 537
 			{
538
-				if($DEBUG)
538
+				if ($DEBUG)
539 539
 				{
540
-					echo '<br>process->test_data(): Including baseline test data for ' . $appname . "\n";
540
+					echo '<br>process->test_data(): Including baseline test data for '.$appname."\n";
541 541
 				}
542 542
 				$GLOBALS['egw_setup']->oProc->m_odb->transaction_begin();
543 543
 				include ($appdir.'test_data.inc.php');
@@ -557,35 +557,35 @@  discard block
 block discarded – undo
557 557
 	 * @param boolean $DEBUG =false output further diagnostics
558 558
 	 * @return array $setup_info
559 559
 	 */
560
-	function baseline(array $setup_info,$DEBUG=False)
560
+	function baseline(array $setup_info, $DEBUG = False)
561 561
 	{
562
-		if(!@$GLOBALS['egw_setup']->oProc)
562
+		if (!@$GLOBALS['egw_setup']->oProc)
563 563
 		{
564 564
 			$this->init_process();
565 565
 		}
566
-		foreach($setup_info as $appname => &$appdata)
566
+		foreach ($setup_info as $appname => &$appdata)
567 567
 		{
568
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
568
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
569 569
 
570
-			if(file_exists($appdir.'tables_baseline.inc.php'))
570
+			if (file_exists($appdir.'tables_baseline.inc.php'))
571 571
 			{
572
-				if($DEBUG)
572
+				if ($DEBUG)
573 573
 				{
574
-					echo '<br>process->baseline(): Including baseline tables for ' . $appname . "\n";
574
+					echo '<br>process->baseline(): Including baseline tables for '.$appname."\n";
575 575
 				}
576 576
 				$phpgw_baseline = null;
577 577
 				include ($appdir.'tables_baseline.inc.php');
578 578
 				$GLOBALS['egw_setup']->oProc->GenerateScripts($phpgw_baseline, $DEBUG);
579
-				$this->post_process($phpgw_baseline,$DEBUG);
579
+				$this->post_process($phpgw_baseline, $DEBUG);
580 580
 
581 581
 				/* Update the array values for return below */
582 582
 				/* $setup_info[$key]['status'] = 'R'; */
583 583
 			}
584 584
 			else
585 585
 			{
586
-				if($DEBUG)
586
+				if ($DEBUG)
587 587
 				{
588
-					echo '<br>process->baseline(): No baseline tables for ' . $appname . "\n";
588
+					echo '<br>process->baseline(): No baseline tables for '.$appname."\n";
589 589
 				}
590 590
 				//$setup_info[$key]['status'] = 'C';
591 591
 			}
@@ -603,19 +603,19 @@  discard block
 block discarded – undo
603 603
 	 * @param boolean $DEBUG =false output further diagnostics
604 604
 	 * @return array $setup_info
605 605
 	 */
606
-	function upgrade($setup_info,$DEBUG=False)
606
+	function upgrade($setup_info, $DEBUG = False)
607 607
 	{
608 608
 		//echo __METHOD__; _debug_array($setup_info);
609
-		if(!@$GLOBALS['egw_setup']->oProc)
609
+		if (!@$GLOBALS['egw_setup']->oProc)
610 610
 		{
611 611
 			$this->init_process();
612 612
 		}
613 613
 		$GLOBALS['egw_setup']->oProc->m_odb->HaltOnError = 'yes';
614 614
 
615
-		foreach($setup_info as $appname => &$appdata)
615
+		foreach ($setup_info as $appname => &$appdata)
616 616
 		{
617 617
 			// check if app is NOT installed
618
-			if(!$GLOBALS['egw_setup']->app_registered($appname))
618
+			if (!$GLOBALS['egw_setup']->app_registered($appname))
619 619
 			{
620 620
 				// check if app wants to be automatically installed on update to version x or allways
621 621
 				if (isset($appdata['autoinstall']) && ($appdata['autoinstall'] === true ||
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 					continue;
628 628
 				}
629 629
 				/* Don't try to upgrade an app that is not installed */
630
-				if($DEBUG)
630
+				if ($DEBUG)
631 631
 				{
632 632
 					echo "<p>process->upgrade(): Application not installed: $appname</p>\n";
633 633
 				}
@@ -636,41 +636,41 @@  discard block
 block discarded – undo
636 636
 			}
637 637
 
638 638
 			/* if upgrade required, or if we are running again after an upgrade or dependency failure */
639
-			if($DEBUG)
639
+			if ($DEBUG)
640 640
 			{
641 641
 				echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n";
642 642
 			}
643
-			if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
643
+			if ($appdata['status'] == 'U' || $appdata['status'] == 'D' || $appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
644 644
 			{
645 645
 				$currentver = $appdata['currentver'];
646
-				$targetver  = $appdata['version'];	// The version we need to match when done
647
-				$appdir     = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
646
+				$targetver  = $appdata['version']; // The version we need to match when done
647
+				$appdir     = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
648 648
 
649
-				if(file_exists($appdir . 'tables_update.inc.php'))
649
+				if (file_exists($appdir.'tables_update.inc.php'))
650 650
 				{
651 651
 					if (!@$this->updateincluded[$appname])
652 652
 					{
653
-						include ($appdir . 'tables_update.inc.php');
653
+						include ($appdir.'tables_update.inc.php');
654 654
 						$this->updateincluded[$appname] = True;
655 655
 					}
656 656
 					while ($currentver && $currentver != $targetver &&
657
-						function_exists($function = $appname . '_upgrade' . str_replace('.','_',$currentver)))
657
+						function_exists($function = $appname.'_upgrade'.str_replace('.', '_', $currentver)))
658 658
 					{
659
-						if($DEBUG)
659
+						if ($DEBUG)
660 660
 						{
661 661
 							echo "<br>process->upgrade(): $appname($currentver --> $targetver): running $function()\n";
662 662
 						}
663 663
 						if (!($currentver = $function()))
664 664
 						{
665
-							if($DEBUG)
665
+							if ($DEBUG)
666 666
 							{
667 667
 								echo "<b>failed!!!</b>\n";
668 668
 							}
669
-							$appstatus  = 'F';
669
+							$appstatus = 'F';
670 670
 						}
671 671
 						else
672 672
 						{
673
-							if($DEBUG)
673
+							if ($DEBUG)
674 674
 							{
675 675
 								echo "--> $currentver\n";
676 676
 							}
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 					}
679 679
 					if ($currentver == $targetver)	// upgrades succesful
680 680
 					{
681
-						if($DEBUG)
681
+						if ($DEBUG)
682 682
 						{
683 683
 							echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n";
684 684
 						}
@@ -686,27 +686,27 @@  discard block
 block discarded – undo
686 686
 					}
687 687
 					elseif ($currentver)
688 688
 					{
689
-						if($DEBUG)
689
+						if ($DEBUG)
690 690
 						{
691 691
 							echo "<br><b>process->upgrade(): No table upgrade available for appname: $appname, version: $currentver</b>\n";
692 692
 						}
693 693
 						$appdate['currentver'] = $targetver;
694
-						$appstatus  = 'F';
694
+						$appstatus = 'F';
695 695
 					}
696 696
 				}
697 697
 				else
698 698
 				{
699
-					if($DEBUG)
699
+					if ($DEBUG)
700 700
 					{
701 701
 						echo "<br>process->upgrade(): No table upgrade required/availible for $appname\n";
702 702
 					}
703
-					$appstatus  = 'C';
703
+					$appstatus = 'C';
704 704
 				}
705 705
 				if ($appstatus == 'C')	// update successful completed
706 706
 				{
707 707
 					$appdata['currentver'] = $targetver;
708 708
 
709
-					if($GLOBALS['egw_setup']->app_registered($appname))
709
+					if ($GLOBALS['egw_setup']->app_registered($appname))
710 710
 					{
711 711
 						$GLOBALS['egw_setup']->update_app($appname);
712 712
 					}
@@ -719,14 +719,14 @@  discard block
 block discarded – undo
719 719
 			}
720 720
 			else
721 721
 			{
722
-				if($DEBUG)
722
+				if ($DEBUG)
723 723
 				{
724 724
 					echo "<br>process->upgrade(): No upgrade required for $appname\n";
725 725
 				}
726
-				$appstatus  = 'C';
726
+				$appstatus = 'C';
727 727
 			}
728 728
 			/* Done with this app, update status */
729
-			if($DEBUG)
729
+			if ($DEBUG)
730 730
 			{
731 731
 				echo "<br>process->upgrade(): Outgoing : appname: $appname, status: $appstatus</div>\n";
732 732
 			}
@@ -744,13 +744,13 @@  discard block
 block discarded – undo
744 744
 	 * commit above processing to the db
745 745
 	 *
746 746
 	 */
747
-	function post_process($tables,$DEBUG=False)
747
+	function post_process($tables, $DEBUG = False)
748 748
 	{
749
-		if(!$tables)
749
+		if (!$tables)
750 750
 		{
751 751
 			return False;
752 752
 		}
753
-		return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables,$DEBUG);
753
+		return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables, $DEBUG);
754 754
 	}
755 755
 
756 756
 	/**
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @param	$tablename	table whose array you want to see
760 760
 	 */
761
-	function sql_to_array($tablename='')
761
+	function sql_to_array($tablename = '')
762 762
 	{
763
-		if(!$tablename)
763
+		if (!$tablename)
764 764
 		{
765 765
 			return False;
766 766
 		}
767 767
 
768
-		if(!$GLOBALS['egw_setup']->oProc)
768
+		if (!$GLOBALS['egw_setup']->oProc)
769 769
 		{
770 770
 			$this->init_process();
771 771
 		}
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		$sColumns = null;
774 774
 		$GLOBALS['egw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['egw_setup']->oProc, $tablename, $sColumns);
775 775
 
776
-		while(list($key,$tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol))
776
+		while (list($key, $tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol))
777 777
 		{
778 778
 			$arr .= $tbldata;
779 779
 		}
@@ -782,6 +782,6 @@  discard block
 block discarded – undo
782 782
 		$ix = $GLOBALS['egw_setup']->oProc->m_oTranslator->ix;
783 783
 		$uc = $GLOBALS['egw_setup']->oProc->m_oTranslator->uc;
784 784
 
785
-		return array($arr,$pk,$fk,$ix,$uc);
785
+		return array($arr, $pk, $fk, $ix, $uc);
786 786
 	}
787 787
 }
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_bo.inc.php 5 patches
Doc Comments   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param statuses List of statuses to process, with sub-statuses in a 'substatus' array
263 263
 	 * @param labels Array of labels, pass array() and labels will be built in it
264
-	 * @param depth Current depth
264
+	 * @param depth integer depth
265 265
 	 *
266 266
 	 * @return None, labels are built in labels parameter
267 267
 	 */
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 *
306 306
 	 * @param array|int $data =null use $this->data or $this->data['ts_id'] (to fetch the data)
307 307
 	 * @param int $user =null for which user to check, default current user
308
-	 * @return boolean true if the rights are ok, false if no rights
308
+	 * @return null|boolean true if the rights are ok, false if no rights
309 309
 	 */
310 310
 	function check_statusForEditRights($data=null,$user=null)
311 311
 	{
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * @param int $required Acl::READ, EGW_ACL_WRITE, Acl::ADD, Acl::DELETE, EGW_ACL_BUDGET, EGW_ACL_EDIT_BUDGET
341 341
 	 * @param array|int $data =null project or project-id to use, default the project in $this->data
342 342
 	 * @param int $user =null for which user to check, default current user
343
-	 * @return boolean true if the rights are ok, null if not found, false if no rights
343
+	 * @return null|boolean true if the rights are ok, null if not found, false if no rights
344 344
 	 */
345 345
 	function check_acl($required,$data=null,$user=null)
346 346
 	{
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
398 398
 	 * @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return
399 399
 	 * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
400
-	 * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
400
+	 * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
401 401
 	 * @param string $wildcard ='' appended befor and after each criteria
402 402
 	 * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
403 403
 	 * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
404
-	 * @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num)
404
+	 * @param boolean $start =false if != false, return only maxmatch rows begining with start, or array($start,$num)
405 405
 	 * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
406 406
 	 * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
407 407
 	 *	"LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
@@ -658,8 +658,6 @@  discard block
 block discarded – undo
658 658
 	 * delete / move all timesheets of a given user
659 659
 	 *
660 660
 	 * @param array $data
661
-	 * @param int $data['account_id'] owner to change
662
-	 * @param int $data['new_owner']  new owner or 0 for delete
663 661
 	 */
664 662
 	function deleteaccount($data)
665 663
 	{
@@ -686,7 +684,7 @@  discard block
 block discarded – undo
686 684
 	 *
687 685
 	 * @param array $keys =null if given array with col => value pairs to characterise single timesheet or null for $this->data
688 686
 	 * @param int $status =0
689
-	 * @return int affected rows, should be 1 if ok, 0 if an error
687
+	 * @return boolean affected rows, should be 1 if ok, 0 if an error
690 688
 	 */
691 689
 	function set_status($keys=null, $status=0)
692 690
 	{
@@ -816,7 +814,7 @@  discard block
 block discarded – undo
816 814
 	 * @param int $check Acl::READ for read and Acl::EDIT for write or delete access
817 815
 	 * @param string $rel_path =null currently not used in InfoLog
818 816
 	 * @param int $user =null for which user to check, default current user
819
-	 * @return boolean true if access is granted or false otherwise
817
+	 * @return null|boolean true if access is granted or false otherwise
820 818
 	 */
821 819
 	function file_access($id,$check,$rel_path=null,$user=null)
822 820
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -152,8 +152,8 @@
 block discarded – undo
152 152
 	const EXTRA_TABLE = 'egw_timesheet_extra';
153 153
 
154 154
 	/**
155
-	* Columns to search when user does a text search
156
-	*/
155
+	 * Columns to search when user does a text search
156
+	 */
157 157
 	var $columns_to_search = array('egw_timesheet.ts_id', 'ts_project', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_unitprice');
158 158
 
159 159
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -792,7 +792,7 @@
 block discarded – undo
792 792
 	 * @param array $options Array of options for the search
793 793
 	 * @return array with ts_id - title pairs of the matching entries
794 794
 	 */
795
-	function link_query( $pattern, Array &$options = array() )
795
+	function link_query( $pattern, array &$options = array() )
796 796
 	{
797 797
 		$limit = false;
798 798
 		$need_count = false;
Please login to merge, or discard this patch.
Braces   +82 added lines, -21 removed lines patch added patch discarded remove patch
@@ -167,12 +167,18 @@  discard block
 block discarded – undo
167 167
 	{
168 168
 		parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id');
169 169
 
170
-		if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
170
+		if ($this->customfields)
171
+		{
172
+			$this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
173
+		}
171 174
 		$this->config_data = Api\Config::read(TIMESHEET_APP);
172 175
 		$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
173 176
 
174 177
 		// Load & process statuses
175
-		if($this->config_data['status_labels']) $this->load_statuses();
178
+		if($this->config_data['status_labels'])
179
+		{
180
+			$this->load_statuses();
181
+		}
176 182
 
177 183
 		$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));
178 184
 
@@ -190,12 +196,16 @@  discard block
 block discarded – undo
190 196
 	protected function load_statuses()
191 197
 	{
192 198
 		$this->status_labels =&  $this->config_data['status_labels'];
193
-		if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels);
199
+		if (!is_array($this->status_labels))
200
+		{
201
+			$this->status_labels= array($this->status_labels);
202
+		}
194 203
 
195 204
 		foreach ($this->status_labels as $status_id => $label)
196 205
 		{
197 206
 			if (!is_array($label))
198
-			{	//old values, before parent status
207
+			{
208
+//old values, before parent status
199 209
 				$name = $label;
200 210
 				$label=array();
201 211
 				$label['name'] = $name;
@@ -243,7 +253,10 @@  discard block
 block discarded – undo
243 253
 	 */
244 254
 	function get_sub_status($status)
245 255
 	{
246
-		if (!isset($this->status_labels_config)) $this->load_statuses();
256
+		if (!isset($this->status_labels_config))
257
+		{
258
+			$this->load_statuses();
259
+		}
247 260
 		$stati = array($status);
248 261
 		foreach($this->status_labels_config as $stat)
249 262
 		{
@@ -286,7 +299,10 @@  discard block
 block discarded – undo
286 299
 	 */
287 300
 	function grant_list($required=Acl::READ, $hide_deactive=null)
288 301
 	{
289
-		if (!isset($hide_deactive)) $hide_deactive = $required == Acl::EDIT;
302
+		if (!isset($hide_deactive))
303
+		{
304
+			$hide_deactive = $required == Acl::EDIT;
305
+		}
290 306
 
291 307
 		$result = array();
292 308
 		foreach($this->grants as $uid => $grant)
@@ -322,9 +338,16 @@  discard block
 block discarded – undo
322 338
 			$data = $this->read($data,true);
323 339
 			$this->data = $save_data;
324 340
 
325
-			if (!$data) return null; 	// entry not found
341
+			if (!$data)
342
+			{
343
+				return null;
344
+			}
345
+			// entry not found
346
+		}
347
+		if (!$user)
348
+		{
349
+			$user = $this->user;
326 350
 		}
327
-		if (!$user) $user = $this->user;
328 351
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status'])
329 352
 		{
330 353
 			if ($this->status_labels_config[$data['ts_status']]['admin'])
@@ -357,9 +380,16 @@  discard block
 block discarded – undo
357 380
 			$data = $this->read($data,true);
358 381
 			$this->data = $save_data;
359 382
 
360
-			if (!$data) return null; 	// entry not found
383
+			if (!$data)
384
+			{
385
+				return null;
386
+			}
387
+			// entry not found
388
+		}
389
+		if (!$user)
390
+		{
391
+			$user = $this->user;
361 392
 		}
362
-		if (!$user) $user = $this->user;
363 393
 		if ($user == $this->user)
364 394
 		{
365 395
 			$grants = $this->grants;
@@ -433,7 +463,10 @@  discard block
 block discarded – undo
433 463
 		}
434 464
 		else
435 465
 		{
436
-			if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
466
+			if (!is_array($filter['ts_owner']))
467
+			{
468
+				$filter['ts_owner'] = array($filter['ts_owner']);
469
+			}
437 470
 
438 471
 			foreach($filter['ts_owner'] as $key => $owner)
439 472
 			{
@@ -488,7 +521,10 @@  discard block
 block discarded – undo
488 521
 		$this->summary = $this->summary[0];
489 522
 		$this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']);
490 523
 
491
-		if ($only_summary) return $this->summary;
524
+		if ($only_summary)
525
+		{
526
+			return $this->summary;
527
+		}
492 528
 
493 529
 		if ($this->show_sums && strpos($order_by,'ts_start') !== false && 	// sums only make sense if ordered by ts_start
494 530
 			$this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start')))
@@ -564,7 +600,10 @@  discard block
 block discarded – undo
564 600
 	 */
565 601
 	function save($keys=null,$touch_modified=true,$ignore_acl=false)
566 602
 	{
567
-		if ($keys) $this->data_merge($keys);
603
+		if ($keys)
604
+		{
605
+			$this->data_merge($keys);
606
+		}
568 607
 
569 608
 		if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT))
570 609
 		{
@@ -586,10 +625,13 @@  discard block
 block discarded – undo
586 625
 			$old =& $this->data;
587 626
 			$this->data =& $new;
588 627
 			$changed = array();
589
-			if (isset($old)) foreach($old as $name => $value)
628
+			if (isset($old))
629
+			{
630
+				foreach($old as $name => $value)
590 631
 			{
591 632
 				if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name;
592 633
 			}
634
+			}
593 635
 		}
594 636
 		if (isset($old) && !$changed)
595 637
 		{
@@ -706,7 +748,10 @@  discard block
 block discarded – undo
706 748
 		}
707 749
 
708 750
 		$this->data['ts_status'] = $status;
709
-		if ($this->save($ts_id)!=0) $ret = false;
751
+		if ($this->save($ts_id)!=0)
752
+		{
753
+			$ret = false;
754
+		}
710 755
 
711 756
 		return $ret;
712 757
 	}
@@ -750,10 +795,13 @@  discard block
 block discarded – undo
750 795
 			return $entry;
751 796
 		}
752 797
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
753
-		if (date('H:i',$entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
798
+		if (date('H:i',$entry['ts_start']) != '00:00')
799
+		{
800
+			// dont show 00:00 time, as it means date only
754 801
 		{
755 802
 			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
756 803
 		}
804
+		}
757 805
 		return date($format,$entry['ts_start']).': '.$entry['ts_title'];
758 806
 	}
759 807
 
@@ -799,14 +847,18 @@  discard block
 block discarded – undo
799 847
 	{
800 848
 		$limit = false;
801 849
 		$need_count = false;
802
-		if($options['start'] || $options['num_rows']) {
850
+		if($options['start'] || $options['num_rows'])
851
+		{
803 852
 			$limit = array($options['start'], $options['num_rows']);
804 853
 			$need_count = true;
805 854
 		}
806 855
 		$result = array();
807 856
 		foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts )
808 857
 		{
809
-			if ($ts) $result[$ts['ts_id']] = $this->link_title($ts);
858
+			if ($ts)
859
+			{
860
+				$result[$ts['ts_id']] = $this->link_title($ts);
861
+			}
810 862
 		}
811 863
 		$options['total'] = $need_count ? $this->total : count($result);
812 864
 		return $result;
@@ -925,7 +977,10 @@  discard block
 block discarded – undo
925 977
 				//error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update));
926 978
 			}
927 979
 		}
928
-		if ($backup) $this->data = $backup;
980
+		if ($backup)
981
+		{
982
+			$this->data = $backup;
983
+		}
929 984
 	}
930 985
 
931 986
 
@@ -950,7 +1005,10 @@  discard block
 block discarded – undo
950 1005
 			$first_pm_id = null;
951 1006
 			foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
952 1007
 			{
953
-				if (!isset($first_pm_id)) $first_pm_id = $pm_id;
1008
+				if (!isset($first_pm_id))
1009
+				{
1010
+					$first_pm_id = $pm_id;
1011
+				}
954 1012
 				if ($data['ts_project'] == Link::title('projectmanager', $pm_id))
955 1013
 				{
956 1014
 					$data['pm_id'] = $pm_id;
@@ -959,7 +1017,10 @@  discard block
 block discarded – undo
959 1017
 					break;
960 1018
 				}
961 1019
 			}
962
-			if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id;
1020
+			if (!isset($data['pm_id']) && isset($first_pm_id))
1021
+			{
1022
+				$data['pm_id'] = $first_pm_id;
1023
+			}
963 1024
 		}
964 1025
 		elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project'])
965 1026
 		{
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 if (!defined('TIMESHEET_APP'))
18 18
 {
19
-	define('TIMESHEET_APP','timesheet');
19
+	define('TIMESHEET_APP', 'timesheet');
20 20
 }
21 21
 
22 22
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @var boolean
45 45
 	 */
46
-	var $quantity_sum=false;
46
+	var $quantity_sum = false;
47 47
 	/**
48 48
 	 * current user
49 49
 	 *
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @var array
57 57
 	 */
58 58
 	var $timestamps = array(
59
-		'ts_start','ts_modified'
59
+		'ts_start', 'ts_modified'
60 60
 	);
61 61
 	/**
62 62
 	 * Start of today in user-time
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 * @var array
71 71
 	 */
72 72
 	var $date_filters = array(	// Start: year,month,day,week, End: year,month,day,week
73
-		'Today'       => array(0,0,0,0,  0,0,1,0),
74
-		'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
75
-		'This week'   => array(0,0,0,0,  0,0,0,1),
76
-		'Last week'   => array(0,0,0,-1, 0,0,0,0),
77
-		'This month'  => array(0,0,0,0,  0,1,0,0),
78
-		'Last month'  => array(0,-1,0,0, 0,0,0,0),
79
-		'2 month ago' => array(0,-2,0,0, 0,-1,0,0),
80
-		'This year'   => array(0,0,0,0,  1,0,0,0),
81
-		'Last year'   => array(-1,0,0,0, 0,0,0,0),
82
-		'2 years ago' => array(-2,0,0,0, -1,0,0,0),
83
-		'3 years ago' => array(-3,0,0,0, -2,0,0,0),
73
+		'Today'       => array(0, 0, 0, 0, 0, 0, 1, 0),
74
+		'Yesterday'   => array(0, 0, -1, 0, 0, 0, 0, 0),
75
+		'This week'   => array(0, 0, 0, 0, 0, 0, 0, 1),
76
+		'Last week'   => array(0, 0, 0, -1, 0, 0, 0, 0),
77
+		'This month'  => array(0, 0, 0, 0, 0, 1, 0, 0),
78
+		'Last month'  => array(0, -1, 0, 0, 0, 0, 0, 0),
79
+		'2 month ago' => array(0, -2, 0, 0, 0, -1, 0, 0),
80
+		'This year'   => array(0, 0, 0, 0, 1, 0, 0, 0),
81
+		'Last year'   => array(-1, 0, 0, 0, 0, 0, 0, 0),
82
+		'2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0),
83
+		'3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0),
84 84
 	);
85 85
 	/**
86 86
 	 * Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @var array
107 107
 	 */
108
-	var $customfields=array();
108
+	var $customfields = array();
109 109
 	/**
110 110
 	 * Array with status label
111 111
 	 *
@@ -165,21 +165,21 @@  discard block
 block discarded – undo
165 165
 
166 166
 	function __construct()
167 167
 	{
168
-		parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id');
168
+		parent::__construct(TIMESHEET_APP, 'egw_timesheet', self::EXTRA_TABLE, '', 'ts_extra_name', 'ts_extra_value', 'ts_id');
169 169
 
170 170
 		if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
171 171
 		$this->config_data = Api\Config::read(TIMESHEET_APP);
172 172
 		$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
173 173
 
174 174
 		// Load & process statuses
175
-		if($this->config_data['status_labels']) $this->load_statuses();
175
+		if ($this->config_data['status_labels']) $this->load_statuses();
176 176
 
177
-		$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));
177
+		$this->today = mktime(0, 0, 0, date('m', $this->now), date('d', $this->now), date('Y', $this->now));
178 178
 
179 179
 		// save us in $GLOBALS['timesheet_bo'] for ExecMethod used in hooks
180 180
 		if (!is_object($GLOBALS['timesheet_bo']))
181 181
 		{
182
-			$GLOBALS['timesheet_bo'] =& $this;
182
+			$GLOBALS['timesheet_bo'] = & $this;
183 183
 		}
184 184
 		$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
185 185
 	}
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	protected function load_statuses()
191 191
 	{
192
-		$this->status_labels =&  $this->config_data['status_labels'];
193
-		if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels);
192
+		$this->status_labels = &  $this->config_data['status_labels'];
193
+		if (!is_array($this->status_labels)) $this->status_labels = array($this->status_labels);
194 194
 
195 195
 		foreach ($this->status_labels as $status_id => $label)
196 196
 		{
197 197
 			if (!is_array($label))
198 198
 			{	//old values, before parent status
199 199
 				$name = $label;
200
-				$label=array();
200
+				$label = array();
201 201
 				$label['name'] = $name;
202 202
 				$label['parent'] = '';
203 203
 			}
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 		$map = array(
210 210
 			'' => array('substatus' => array())
211 211
 		);
212
-		foreach($this->status_labels_config as $id => &$status)
212
+		foreach ($this->status_labels_config as $id => &$status)
213 213
 		{
214 214
 			$status['substatus'] = array();
215 215
 			$map[$id] = &$status;
216 216
 		}
217
-		foreach($this->status_labels_config as &$status)
217
+		foreach ($this->status_labels_config as &$status)
218 218
 		{
219 219
 			$map[$status['parent']]['substatus'][] = &$status;
220 220
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 		// Sort Api\Config based on tree
228 228
 		$sorted = array();
229
-		foreach($this->status_labels as $status_id => $label)
229
+		foreach ($this->status_labels as $status_id => $label)
230 230
 		{
231 231
 			$sorted[$status_id] = $this->status_labels_config[$status_id];
232 232
 			//$sorted[$status_id]['name'] = $label;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	{
246 246
 		if (!isset($this->status_labels_config)) $this->load_statuses();
247 247
 		$stati = array($status);
248
-		foreach($this->status_labels_config as $stat)
248
+		foreach ($this->status_labels_config as $stat)
249 249
 		{
250 250
 			if ($stat['parent'] && in_array($stat['parent'], $stati))
251 251
 			{
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @return None, labels are built in labels parameter
267 267
 	 */
268
-	protected function make_status_labels($statuses, &$labels, $depth=0)
268
+	protected function make_status_labels($statuses, &$labels, $depth = 0)
269 269
 	{
270
-		foreach($statuses as $status)
270
+		foreach ($statuses as $status)
271 271
 		{
272
-			$labels[$status['id']] = str_pad('',$depth*12, "&nbsp;",STR_PAD_LEFT).trim(str_replace('&nbsp;','',$status['name']));
273
-			if(count($status['substatus']) > 0)
272
+			$labels[$status['id']] = str_pad('', $depth * 12, "&nbsp;", STR_PAD_LEFT).trim(str_replace('&nbsp;', '', $status['name']));
273
+			if (count($status['substatus']) > 0)
274 274
 			{
275
-				$this->make_status_labels($status['substatus'], $labels, $depth+1);
275
+				$this->make_status_labels($status['substatus'], $labels, $depth + 1);
276 276
 			}
277 277
 		}
278 278
 	}
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
 	 * @param boolean $hide_deactive =null default only Acl::EDIT hides deactivates users
285 285
 	 * @return array with uid => Username pairs
286 286
 	 */
287
-	function grant_list($required=Acl::READ, $hide_deactive=null)
287
+	function grant_list($required = Acl::READ, $hide_deactive = null)
288 288
 	{
289 289
 		if (!isset($hide_deactive)) $hide_deactive = $required == Acl::EDIT;
290 290
 
291 291
 		$result = array();
292
-		foreach($this->grants as $uid => $grant)
292
+		foreach ($this->grants as $uid => $grant)
293 293
 		{
294
-			if ($grant & $required && (!$hide_deactive || Api\Accounts::getInstance()->is_active($uid)))
294
+			if ($grant&$required && (!$hide_deactive || Api\Accounts::getInstance()->is_active($uid)))
295 295
 			{
296 296
 				$result[$uid] = Api\Accounts::username($uid);
297 297
 			}
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
 	 * @param int $user =null for which user to check, default current user
311 311
 	 * @return boolean true if the rights are ok, false if no rights
312 312
 	 */
313
-	function check_statusForEditRights($data=null,$user=null)
313
+	function check_statusForEditRights($data = null, $user = null)
314 314
 	{
315 315
 		if (is_null($data) || (int)$data == $this->data['ts_id'])
316 316
 		{
317
-			$data =& $this->data;
317
+			$data = & $this->data;
318 318
 		}
319 319
 		if (!is_array($data))
320 320
 		{
321 321
 			$save_data = $this->data;
322
-			$data = $this->read($data,true);
322
+			$data = $this->read($data, true);
323 323
 			$this->data = $save_data;
324 324
 
325
-			if (!$data) return null; 	// entry not found
325
+			if (!$data) return null; // entry not found
326 326
 		}
327 327
 		if (!$user) $user = $this->user;
328 328
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status'])
@@ -345,19 +345,19 @@  discard block
 block discarded – undo
345 345
 	 * @param int $user =null for which user to check, default current user
346 346
 	 * @return boolean true if the rights are ok, null if not found, false if no rights
347 347
 	 */
348
-	function check_acl($required,$data=null,$user=null)
348
+	function check_acl($required, $data = null, $user = null)
349 349
 	{
350 350
 		if (is_null($data) || (int)$data == $this->data['ts_id'])
351 351
 		{
352
-			$data =& $this->data;
352
+			$data = & $this->data;
353 353
 		}
354 354
 		if (!is_array($data))
355 355
 		{
356 356
 			$save_data = $this->data;
357
-			$data = $this->read($data,true);
357
+			$data = $this->read($data, true);
358 358
 			$this->data = $save_data;
359 359
 
360
-			if (!$data) return null; 	// entry not found
360
+			if (!$data) return null; // entry not found
361 361
 		}
362 362
 		if (!$user) $user = $this->user;
363 363
 		if ($user == $this->user)
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 		}
367 367
 		else
368 368
 		{
369
-			$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user);
369
+			$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP, true, $user);
370 370
 		}
371
-		$ret = $data && !!($grants[$data['ts_owner']] & $required);
371
+		$ret = $data && !!($grants[$data['ts_owner']]&$required);
372 372
 
373
-		if(($required & Acl::DELETE) && $this->config_data['history'] == 'history' &&
373
+		if (($required&Acl::DELETE) && $this->config_data['history'] == 'history' &&
374 374
 			$data['ts_status'] == self::DELETED_STATUS)
375 375
 		{
376 376
 			$ret = !!($GLOBALS['egw_info']['user']['apps']['admin']);
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * @param int &$end
388 388
 	 * @return string
389 389
 	 */
390
-	function date_filter($name,&$start,&$end)
390
+	function date_filter($name, &$start, &$end)
391 391
 	{
392 392
 		return Api\DateTime::sql_filter($name, $start, $end, 'ts_start', $this->date_filters);
393 393
 	}
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	 * @param boolean $only_summary =false If true only return the sums as array with keys duration and price, default false
414 414
 	 * @return array of matching rows (the row is an array of the cols) or False
415 415
 	 */
416
-	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false,$only_summary=false)
416
+	function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false, $only_summary = false)
417 417
 	{
418 418
 		//error_log(__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')");
419 419
 		//echo "<p>".__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
 
423 423
 		if (!is_array($extra_cols))
424 424
 		{
425
-			$extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
425
+			$extra_cols = $extra_cols ? explode(',', $extra_cols) : array();
426 426
 		}
427
-		if ($only_keys === false || $this->show_sums && strpos($order_by,'ts_start') !== false)
427
+		if ($only_keys === false || $this->show_sums && strpos($order_by, 'ts_start') !== false)
428 428
 		{
429 429
 			$extra_cols[] = $total_sql.' AS ts_total';
430 430
 		}
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 		{
442 442
 			if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
443 443
 
444
-			foreach($filter['ts_owner'] as $key => $owner)
444
+			foreach ($filter['ts_owner'] as $key => $owner)
445 445
 			{
446 446
 				if (!isset($this->grants[$owner]))
447 447
 				{
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 		}
456 456
 		else
457 457
 		{
458
-			$filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=':'!= ') . self::DELETED_STATUS .
459
-				($filter['ts_status'] == self::DELETED_STATUS ? '':' OR ts_status IS NULL') . ')';
458
+			$filter[] = '(ts_status '.($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ').self::DELETED_STATUS.
459
+				($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL').')';
460 460
 		}
461 461
 		if (!count($filter['ts_owner']))
462 462
 		{
@@ -464,15 +464,15 @@  discard block
 block discarded – undo
464 464
 			$this->summary = array();
465 465
 			return array();
466 466
 		}
467
-		if ($only_summary==false && $criteria && $this->show_sums)
467
+		if ($only_summary == false && $criteria && $this->show_sums)
468 468
 		{
469 469
 			// if we have a criteria AND intend to show the sums we first query the affected ids,
470 470
 			// then we throw away criteria and filter, and replace the filter with the list of ids
471
-			$ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join);
471
+			$ids = parent::search($criteria, 'egw_timesheet.ts_id as id', '', '', $wildcard, $empty, $op, false, $filter, $join);
472 472
 			//_debug_array($ids);
473 473
 			if (empty($ids))
474 474
 			{
475
-				$this->summary = array('duration'=>0,'price'=>null,'quantity'=>0);
475
+				$this->summary = array('duration'=>0, 'price'=>null, 'quantity'=>0);
476 476
 				return array();
477 477
 			}
478 478
 			unset($criteria);
@@ -496,45 +496,45 @@  discard block
 block discarded – undo
496 496
 
497 497
 		if ($only_summary) return $this->summary;
498 498
 
499
-		if ($this->show_sums && strpos($order_by,'ts_start') !== false && 	// sums only make sense if ordered by ts_start
499
+		if ($this->show_sums && strpos($order_by, 'ts_start') !== false && // sums only make sense if ordered by ts_start
500 500
 			$this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start')))
501 501
 		{
502 502
 			$sum_sql = array(
503
-				'year'  => $this->db->date_format($from_unixtime_ts_start,'%Y'),
504
-				'month' => $this->db->date_format($from_unixtime_ts_start,'%Y%m'),
505
-				'week'  => $this->db->date_format($from_unixtime_ts_start,$GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'),
506
-				'day'   => $this->db->date_format($from_unixtime_ts_start,'%Y-%m-%d'),
503
+				'year'  => $this->db->date_format($from_unixtime_ts_start, '%Y'),
504
+				'month' => $this->db->date_format($from_unixtime_ts_start, '%Y%m'),
505
+				'week'  => $this->db->date_format($from_unixtime_ts_start, $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'),
506
+				'day'   => $this->db->date_format($from_unixtime_ts_start, '%Y-%m-%d'),
507 507
 			);
508
-			foreach($this->show_sums as $type)
508
+			foreach ($this->show_sums as $type)
509 509
 			{
510 510
 				$extra_cols[] = $sum_sql[$type].' AS ts_'.$type;
511 511
 				$extra_cols[] = '0 AS is_sum_'.$type;
512
-				$sum_extra_cols[] = str_replace('ts_start','MIN(ts_start)',$sum_sql[$type]);	// as we dont group by ts_start
512
+				$sum_extra_cols[] = str_replace('ts_start', 'MIN(ts_start)', $sum_sql[$type]); // as we dont group by ts_start
513 513
 				$sum_extra_cols[$type] = '0 AS is_sum_'.$type;
514 514
 			}
515 515
 			// regular entries
516
-			parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
516
+			parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count);
517 517
 
518
-			$sort = substr($order_by,8);
518
+			$sort = substr($order_by, 8);
519 519
 			$union_order = array();
520
-			$sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0);
521
-			foreach($this->show_sums as $type)
520
+			$sum_ts_id = array('year' => -3, 'month' => -2, 'week' => -1, 'day' => 0);
521
+			foreach ($this->show_sums as $type)
522 522
 			{
523
-				$union_order[] = 'ts_'.$type . ' ' . $sort;
523
+				$union_order[] = 'ts_'.$type.' '.$sort;
524 524
 				$union_order[] = 'is_sum_'.$type;
525 525
 				$sum_extra_cols[$type]{0} = '1';
526 526
 				// the $type sum
527
-				parent::search($criteria,array(
528
-					(string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration',
527
+				parent::search($criteria, array(
528
+					(string)$sum_ts_id[$type], "''", "''", "''", 'MIN(ts_start)', 'SUM(ts_duration) AS ts_duration',
529 529
 					($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'),
530
-					'0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total"
531
-				),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
530
+					'0', 'NULL', '0', '0', '0', '0', '0', "SUM($total_sql) AS ts_total"
531
+				), 'GROUP BY '.$sum_sql[$type], $sum_extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count);
532 532
 				$sum_extra_cols[$type]{0} = '0';
533 533
 			}
534 534
 			$union_order[] = 'ts_start '.$sort;
535
-			return parent::search('','',implode(',',$union_order),'','',false,'',$start);
535
+			return parent::search('', '', implode(',', $union_order), '', '', false, '', $start);
536 536
 		}
537
-		return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
537
+		return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count);
538 538
 	}
539 539
 
540 540
 	/**
@@ -544,16 +544,16 @@  discard block
 block discarded – undo
544 544
 	 * @param boolean $ignore_acl =false should the Acl be checked
545 545
 	 * @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights
546 546
 	 */
547
-	function read($ts_id,$ignore_acl=false)
547
+	function read($ts_id, $ignore_acl = false)
548 548
 	{
549 549
 		//error_log(__METHOD__."($ts_id,$ignore_acl) ".function_backtrace());
550 550
 		if (!(int)$ts_id || (int)$ts_id != $this->data['ts_id'] && !parent::read($ts_id))
551 551
 		{
552
-			return null;	// entry not found
552
+			return null; // entry not found
553 553
 		}
554 554
 		if (!$ignore_acl && !($ret = $this->check_acl(Acl::READ)))
555 555
 		{
556
-			return false;	// no read rights
556
+			return false; // no read rights
557 557
 		}
558 558
 		return $this->data;
559 559
 	}
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * @param boolean $ignore_acl =false should the Acl be checked, returns true if no edit-rigts
569 569
 	 * @return int 0 on success and errno != 0 else
570 570
 	 */
571
-	function save($keys=null,$touch_modified=true,$ignore_acl=false)
571
+	function save($keys = null, $touch_modified = true, $ignore_acl = false)
572 572
 	{
573 573
 		if ($keys) $this->data_merge($keys);
574 574
 
@@ -586,13 +586,13 @@  discard block
 block discarded – undo
586 586
 		// check if we have a real modification of an existing record
587 587
 		if ($this->data['ts_id'])
588 588
 		{
589
-			$new =& $this->data;
589
+			$new = & $this->data;
590 590
 			unset($this->data);
591 591
 			$this->read($new['ts_id']);
592
-			$old =& $this->data;
593
-			$this->data =& $new;
592
+			$old = & $this->data;
593
+			$this->data = & $new;
594 594
 			$changed = array();
595
-			if (isset($old)) foreach($old as $name => $value)
595
+			if (isset($old)) foreach ($old as $name => $value)
596 596
 			{
597 597
 				if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name;
598 598
 			}
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 		))
608 608
 		{
609 609
 			$this->data['ts_project'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : '';
610
-			if($this->data['ts_title'] == Link::title('projectmanager', $old['pm_id']))
610
+			if ($this->data['ts_title'] == Link::title('projectmanager', $old['pm_id']))
611 611
 			{
612 612
 				$this->data['ts_title'] = $this->data['ts_project'];
613 613
 			}
614 614
 		}
615 615
 
616 616
 		// Check for restore of deleted contact, restore held links
617
-		if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
617
+		if ($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
618 618
 		{
619 619
 			Link::restore(TIMESHEET_APP, $new['ts_id']);
620 620
 		}
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
 
626 626
 			$this->tracking->html_content_allow = true;
627 627
 		}
628
-		if ($this->tracking->track($this->data,$old,$this->user) === false)
628
+		if ($this->tracking->track($this->data, $old, $this->user) === false)
629 629
 		{
630
-			return implode(', ',$this->tracking->errors);
630
+			return implode(', ', $this->tracking->errors);
631 631
 		}
632 632
 		if (!($err = parent::save()))
633 633
 		{
634 634
 			// notify the link-class about the update, as other apps may be subscribt to it
635
-			Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
635
+			Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data);
636 636
 		}
637 637
 
638 638
 		return $err;
@@ -645,15 +645,15 @@  discard block
 block discarded – undo
645 645
 	 * @param boolean $ignore_acl =false should the Acl be checked, returns false if no delete-rigts
646 646
 	 * @return int affected rows, should be 1 if ok, 0 if an error
647 647
 	 */
648
-	function delete($keys=null,$ignore_acl=false)
648
+	function delete($keys = null, $ignore_acl = false)
649 649
 	{
650
-		if (!is_array($keys) && (int) $keys)
650
+		if (!is_array($keys) && (int)$keys)
651 651
 		{
652
-			$keys = array('ts_id' => (int) $keys);
652
+			$keys = array('ts_id' => (int)$keys);
653 653
 		}
654 654
 		$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
655 655
 
656
-		if (!$ignore_acl && !$this->check_acl(Acl::DELETE,$ts_id) || !($old = $this->read($ts_id)))
656
+		if (!$ignore_acl && !$this->check_acl(Acl::DELETE, $ts_id) || !($old = $this->read($ts_id)))
657 657
 		{
658 658
 			return false;
659 659
 		}
@@ -664,12 +664,12 @@  discard block
 block discarded – undo
664 664
 			$delete = $old;
665 665
 			$delete['ts_status'] = self::DELETED_STATUS;
666 666
 			$ret = !($this->save($delete));
667
-			Link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true);
667
+			Link::unlink(0, TIMESHEET_APP, $ts_id, '', '', '', true);
668 668
 		}
669 669
 		elseif (($ret = parent::delete($keys)) && $ts_id)
670 670
 		{
671 671
 			// delete all links to timesheet entry $ts_id
672
-			Link::unlink(0,TIMESHEET_APP,$ts_id);
672
+			Link::unlink(0, TIMESHEET_APP, $ts_id);
673 673
 		}
674 674
 		return $ret;
675 675
 	}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	function deleteaccount($data)
685 685
 	{
686 686
 		$account_id = $data['account_id'];
687
-		$new_owner =  $data['new_owner'];
687
+		$new_owner = $data['new_owner'];
688 688
 
689 689
 		if (!$new_owner)
690 690
 		{
@@ -708,22 +708,22 @@  discard block
 block discarded – undo
708 708
 	 * @param int $status =0
709 709
 	 * @return int affected rows, should be 1 if ok, 0 if an error
710 710
 	 */
711
-	function set_status($keys=null, $status=0)
711
+	function set_status($keys = null, $status = 0)
712 712
 	{
713 713
 		$ret = true;
714
-		if (!is_array($keys) && (int) $keys)
714
+		if (!is_array($keys) && (int)$keys)
715 715
 		{
716
-			$keys = array('ts_id' => (int) $keys);
716
+			$keys = array('ts_id' => (int)$keys);
717 717
 		}
718 718
 		$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
719 719
 
720
-		if (!$this->check_acl(Acl::EDIT,$ts_id) || !$this->read($ts_id,true))
720
+		if (!$this->check_acl(Acl::EDIT, $ts_id) || !$this->read($ts_id, true))
721 721
 		{
722 722
 			return false;
723 723
 		}
724 724
 
725 725
 		$this->data['ts_status'] = $status;
726
-		if ($this->save($ts_id)!=0) $ret = false;
726
+		if ($this->save($ts_id) != 0) $ret = false;
727 727
 
728 728
 		return $ret;
729 729
 	}
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 		{
741 741
 			return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null);
742 742
 		}
743
-		return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true);
743
+		return $this->search(array('ts_id'=>$ids), true, '', '', '', false, 'AND', false, null, '', false, true);
744 744
 	}
745 745
 
746 746
 	/**
@@ -751,27 +751,27 @@  discard block
 block discarded – undo
751 751
 	 * @param int|array $entry int ts_id or array with timesheet entry
752 752
 	 * @return string/boolean string with title, null if timesheet not found, false if no perms to view it
753 753
 	 */
754
-	function link_title( $entry )
754
+	function link_title($entry)
755 755
 	{
756 756
 		if (!is_array($entry))
757 757
 		{
758 758
 			// need to preserve the $this->data
759
-			$backup =& $this->data;
759
+			$backup = & $this->data;
760 760
 			unset($this->data);
761
-			$entry = $this->read( $entry,false,false);
761
+			$entry = $this->read($entry, false, false);
762 762
 			// restore the data again
763
-			$this->data =& $backup;
763
+			$this->data = & $backup;
764 764
 		}
765 765
 		if (!$entry)
766 766
 		{
767 767
 			return $entry;
768 768
 		}
769 769
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
770
-		if (date('H:i',$entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
770
+		if (date('H:i', $entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
771 771
 		{
772 772
 			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
773 773
 		}
774
-		return date($format,$entry['ts_start']).': '.$entry['ts_title'];
774
+		return date($format, $entry['ts_start']).': '.$entry['ts_title'];
775 775
 	}
776 776
 
777 777
 	/**
@@ -782,18 +782,18 @@  discard block
 block discarded – undo
782 782
 	 * @param array $ids array with ts_id's
783 783
 	 * @return array with titles, see link_title
784 784
 	 */
785
-	function link_titles( array $ids )
785
+	function link_titles(array $ids)
786 786
 	{
787 787
 		$titles = array();
788
-		if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start')))
788
+		if (($entries = $this->search(array('ts_id' => $ids), 'ts_id,ts_title,ts_start')))
789 789
 		{
790
-			foreach($entries as $entry)
790
+			foreach ($entries as $entry)
791 791
 			{
792 792
 				$titles[$entry['ts_id']] = $this->link_title($entry);
793 793
 			}
794 794
 		}
795 795
 		// we assume all not returned entries are not readable by the user, as we notify Link about all deletes
796
-		foreach($ids as $id)
796
+		foreach ($ids as $id)
797 797
 		{
798 798
 			if (!isset($titles[$id]))
799 799
 			{
@@ -812,16 +812,16 @@  discard block
 block discarded – undo
812 812
 	 * @param array $options Array of options for the search
813 813
 	 * @return array with ts_id - title pairs of the matching entries
814 814
 	 */
815
-	function link_query( $pattern, Array &$options = array() )
815
+	function link_query($pattern, Array &$options = array())
816 816
 	{
817 817
 		$limit = false;
818 818
 		$need_count = false;
819
-		if($options['start'] || $options['num_rows']) {
819
+		if ($options['start'] || $options['num_rows']) {
820 820
 			$limit = array($options['start'], $options['num_rows']);
821 821
 			$need_count = true;
822 822
 		}
823 823
 		$result = array();
824
-		foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts )
824
+		foreach ((array)$this->search($pattern, false, '', '', '%', false, 'OR', $limit, null, '', $need_count) as $ts)
825 825
 		{
826 826
 			if ($ts) $result[$ts['ts_id']] = $this->link_title($ts);
827 827
 		}
@@ -838,11 +838,11 @@  discard block
 block discarded – undo
838 838
 	 * @param int $user =null for which user to check, default current user
839 839
 	 * @return boolean true if access is granted or false otherwise
840 840
 	 */
841
-	function file_access($id,$check,$rel_path=null,$user=null)
841
+	function file_access($id, $check, $rel_path = null, $user = null)
842 842
 	{
843
-		unset($rel_path);	// not used, but required by function signature
843
+		unset($rel_path); // not used, but required by function signature
844 844
 
845
-		return $this->check_acl($check,$id,$user);
845
+		return $this->check_acl($check, $id, $user);
846 846
 	}
847 847
 
848 848
 	/**
@@ -854,16 +854,16 @@  discard block
 block discarded – undo
854 854
 	 * @param string $newtitle => the new title of the project
855 855
 	 * @return boolean true for success, false for invalid parameters
856 856
 	 */
857
-	 function update_ts_project($oldtitle='', $newtitle='')
857
+	 function update_ts_project($oldtitle = '', $newtitle = '')
858 858
 	 {
859
-		if(strlen($oldtitle) > 0 && strlen($newtitle) > 0)
859
+		if (strlen($oldtitle) > 0 && strlen($newtitle) > 0)
860 860
 		{
861
-			$this->db->update('egw_timesheet',array(
861
+			$this->db->update('egw_timesheet', array(
862 862
 				'ts_project' => $newtitle,
863 863
 				'ts_title' => $newtitle,
864
-			),array(
864
+			), array(
865 865
 				'ts_project' => $oldtitle,
866
-			),__LINE__,__FILE__,TIMESHEET_APP);
866
+			), __LINE__, __FILE__, TIMESHEET_APP);
867 867
 
868 868
 			return true;
869 869
 		}
@@ -876,16 +876,16 @@  discard block
 block discarded – undo
876 876
 	 * @param int $pm_id ID of selected project
877 877
 	 * @return array containing link_id and ts_id
878 878
 	 */
879
-	function get_ts_links($pm_id=0)
879
+	function get_ts_links($pm_id = 0)
880 880
 	{
881
-		if($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
881
+		if ($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
882 882
 		{
883
-			$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id);
883
+			$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children', $pm_id);
884 884
 			$pm_ids[] = $pm_id;
885
-			$links = Link\Storage::get_links('projectmanager',$pm_ids,'timesheet');	// Link\Storage::get_links not egw_links::get_links!
885
+			$links = Link\Storage::get_links('projectmanager', $pm_ids, 'timesheet'); // Link\Storage::get_links not egw_links::get_links!
886 886
 			if ($links)
887 887
 			{
888
-				$links = array_unique(call_user_func_array('array_merge',$links));
888
+				$links = array_unique(call_user_func_array('array_merge', $links));
889 889
 			}
890 890
 			return $links;
891 891
 		}
@@ -903,17 +903,17 @@  discard block
 block discarded – undo
903 903
 	function notify($data)
904 904
 	{
905 905
 		//error_log(__METHOD__.'('.array2string($data).')');
906
-		$backup =& $this->data;	// backup internal data in case class got re-used by ExecMethod
906
+		$backup = & $this->data; // backup internal data in case class got re-used by ExecMethod
907 907
 		unset($this->data);
908 908
 
909 909
 		if ($data['target_app'] == 'projectmanager' && $this->read($data['id']))
910 910
 		{
911 911
 			$old_title = isset($data['data']) ? $data['data'][Link::OLD_LINK_TITLE] : null;
912
-			switch($data['type'])
912
+			switch ($data['type'])
913 913
 			{
914 914
 				case 'link':
915 915
 				case 'update':
916
-					if (empty($this->data['ts_project']) ||	// timesheet has not yet project set --> set just linked one
916
+					if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one
917 917
 						isset($old_title) && $this->data['ts_project'] === $old_title)
918 918
 					{
919 919
 						$pm_id = $data['target_id'];
@@ -955,17 +955,17 @@  discard block
 block discarded – undo
955 955
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
956 956
 	 * @return array
957 957
 	 */
958
-	function db2data($data=null)
958
+	function db2data($data = null)
959 959
 	{
960 960
 		if (($intern = !is_array($data)))
961 961
 		{
962
-			$data =& $this->data;
962
+			$data = & $this->data;
963 963
 		}
964 964
 		// get pm_id from links and ts_project: either project matching ts_project or first found project
965 965
 		if (!isset($data['pm_id']) && $data['ts_id'])
966 966
 		{
967 967
 			$first_pm_id = null;
968
-			foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
968
+			foreach (Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
969 969
 			{
970 970
 				if (!isset($first_pm_id)) $first_pm_id = $pm_id;
971 971
 				if ($data['ts_project'] == Link::title('projectmanager', $pm_id))
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 			$data['ts_project_blur'] = $data['ts_project'];
984 984
 			$data['ts_project'] = '';
985 985
 		}
986
-		return parent::db2data($intern ? null : $data);	// important to use null, if $intern!
986
+		return parent::db2data($intern ? null : $data); // important to use null, if $intern!
987 987
 	}
988 988
 
989 989
 	/**
@@ -995,17 +995,17 @@  discard block
 block discarded – undo
995 995
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
996 996
 	 * @return array
997 997
 	 */
998
-	function data2db($data=null)
998
+	function data2db($data = null)
999 999
 	{
1000 1000
 		if (($intern = !is_array($data)))
1001 1001
 		{
1002
-			$data =& $this->data;
1002
+			$data = & $this->data;
1003 1003
 		}
1004 1004
 		// allways store ts_project to be able to search for it, even if no custom project is set
1005 1005
 		if (empty($data['ts_project']) && !is_null($data['ts_project']))
1006 1006
 		{
1007 1007
 			$data['ts_project'] = $data['pm_id'] ? Link::title('projectmanager', $data['pm_id']) : '';
1008 1008
 		}
1009
-		return parent::data2db($intern ? null : $data);	// important to use null, if $intern!
1009
+		return parent::data2db($intern ? null : $data); // important to use null, if $intern!
1010 1010
 	}
1011 1011
 }
Please login to merge, or discard this patch.